Gentics Portal.Node PHP API
 All Classes Namespaces Functions Variables Pages
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
parserXML Class Reference

Public Member Functions

 __construct ($xml)
 getMeta ($field=null)
 getBody ($field=null)
 getHead ($field=null)
 getInfo ($field=null)
 getDocId ()
 getApaId ()
 getTitle ()
 getDate ()
 getDocType ()
 getRelations ()
 getFiles ()
 getPlace ()
 getSource ()
 getAuthor ()
 getTeaser ()
 getFilename ()
 getKeywords ()
 getText ()
 getDeleteId ()

Static Public Member Functions

static unaccent ($string)

Public Attributes

 $xml

Detailed Description

Class to work with content of an apa xml file. It provides an opportunity to get necessary parameters of news

Author
Andrew Voloshin andre.nosp@m.w.vo.nosp@m.loshi.nosp@m.n@ob.nosp@m.erig..nosp@m.com

Definition at line 10 of file parserXML.php.

Constructor & Destructor Documentation

parserXML::__construct (   $xml)

Constructor

Definition at line 20 of file parserXML.php.

{
$this->xml = $xml;
}

Member Function Documentation

parserXML::getApaId ( )

Function returns ID of current xml file

Returns
string - id of the document

Definition at line 98 of file parserXML.php.

References getMeta().

{
return (string)$this->getMeta('ID');
}
parserXML::getAuthor ( )

Function returns author

Returns
string - content of author tag

Definition at line 200 of file parserXML.php.

References getInfo().

{
return (string)$this->getInfo('AUTHOR');
}
parserXML::getBody (   $field = null)

Function returns content of tag with name $field from BODY tag

Parameters
string$fieldname of tag which content should be returned
Returns
string - content of tag

Definition at line 46 of file parserXML.php.

Referenced by getFiles(), getPlace(), getRelations(), getSource(), getTeaser(), and getText().

{
if(isset($field)){
return $this->xml->BODY->$field;
}else{
return $this->xml->BODY;
}
}
parserXML::getDate ( )

Function returns date of current xml file

Returns
string - date in unix form of the document

Definition at line 128 of file parserXML.php.

References getMeta().

{
$date = (string)$this->getMeta('TIMEDATE');
//Migrate to normal format
$date = date('Y-m-d G:i:s',strtotime($date));
$date = new DateTime($date);
return $date->format('U');
}
parserXML::getDeleteId ( )

Function returns docid of news line which should be removed

Returns
string - docid

Definition at line 260 of file parserXML.php.

{
return (string)$this->xml->delitem['apaid'];
}
parserXML::getDocId ( )

Function returns DOCID of current xml file

Returns
string - docid of the document

Definition at line 89 of file parserXML.php.

References getMeta().

{
return (string)$this->getMeta('DOCID');
}
parserXML::getDocType ( )

Function returns DOCTYP of current xml file

Returns
string - DOCTYP of the document

Definition at line 141 of file parserXML.php.

References getMeta().

{
return (string)$this->getMeta('DOCTYP');
}
parserXML::getFilename ( )

Function returns title of document without accents and shortened to 64 characters

Returns
string - document title

Definition at line 218 of file parserXML.php.

References getHead(), and unaccent().

{
$filename = self::unaccent((string)$this->getHead('TITLE'));
$filename = strtr($filename,array(' ' => '_', '"'=>''));
$filename = substr($filename,0,64);
return $filename;
}
parserXML::getFiles ( )

Function returns array of child files parameters

Returns
array child files parameters

Definition at line 163 of file parserXML.php.

References getBody().

{
$files = array();
foreach($this->getBody('TEXT')->LINK as $file){
$files[] = array(
'href' => (string)$file['HREF'],
'size' => (string)$file['SIZE'],
'width' => (string)$file['WIDTH'],
'height' => (string)$file['HEIGHT'],
'format' => (string)$file['FORMAT'],
);
}
return $files;
}
parserXML::getHead (   $field = null)

Function returns content of tag with name $field from HEAD tag

Parameters
string$fieldname of tag which content should be returned
Returns
string - content of tag

Definition at line 61 of file parserXML.php.

Referenced by getFilename(), getKeywords(), and getTitle().

{
if(isset($field)){
return $this->xml->HEAD->$field;
}else{
return $this->xml->HEAD;
}
}
parserXML::getInfo (   $field = null)

Function returns content of tag with name $field from INFO tag

Parameters
string$fieldname of tag which content should be returned
Returns
string - content of tag

Definition at line 76 of file parserXML.php.

Referenced by getAuthor().

{
if(isset($field)){
return $this->xml->INFO->$field;
}else{
return $this->xml->INFO;
}
}
parserXML::getKeywords ( )

Function returns keywords of document

Returns
array - keywords

Definition at line 230 of file parserXML.php.

References getHead().

{
$keywords = array();
foreach($this->getHead('KEYWORD') as $kw){
$keywords[] = (string)$kw;
}
$keywords = implode(',',$keywords);
return $keywords;
}
parserXML::getMeta (   $field = null)

Function returns content of tag with name $field from META tag

Parameters
string$fieldname of tag which content should be returned
Returns
string - content of tag

Definition at line 31 of file parserXML.php.

Referenced by getApaId(), getDate(), getDocId(), and getDocType().

{
if(isset($field)){
return (string)$this->xml->HEAD->META[$field];
}else{
return $this->xml->HEAD->META;
}
}
parserXML::getPlace ( )

Function returns place

Returns
string - content of place tag

Definition at line 182 of file parserXML.php.

References getBody().

{
return (string)$this->getBody('PLACE');
}
parserXML::getRelations ( )

Function returns array of child files

Returns
array - child files array

Definition at line 150 of file parserXML.php.

References getBody().

{
$relations = array();
foreach($this->getBody('TEXT')->LINK as $relation){
$relations[] = (string)$relation['HREF'];
}
return $relations;
}
parserXML::getSource ( )

Function returns source

Returns
string - content of source tag

Definition at line 191 of file parserXML.php.

References getBody().

{
return (string)$this->getBody('SOURCE');
}
parserXML::getTeaser ( )

Function returns title of article in text tag

Returns
string - title of article

Definition at line 209 of file parserXML.php.

References getBody().

{
return (string)$this->getBody('TEXT')->LEAD;
}
parserXML::getText ( )

Function returns text of article

Returns
string - text

Definition at line 245 of file parserXML.php.

References getBody().

{
$text = array();
foreach($this->getBody('TEXT')->P as $paragraph){
$text[] = (string)$paragraph;
}
$text = '<p>'.implode('</p><p>',$text).'</p>';
return $text;
}
parserXML::getTitle ( )

Function returns title of current xml file

Returns
string - title of the document

Definition at line 119 of file parserXML.php.

References getHead().

{
return (string)$this->getHead('TITLE');
}
static parserXML::unaccent (   $string)
static

Function returns string without accents

Parameters
string$stringstring in which should be removed accents
Returns
string - string without accents

Definition at line 109 of file parserXML.php.

Referenced by getFilename().

{
return strtr(utf8_decode($string),
utf8_decode('ŠŒŽšœžŸ¥µÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿ'),
'SOZsozYYuAAAAAAACEEEEIIIIDNOOOOOOUUUUYsaaaaaaaceeeeiiiionoooooouuuuyy');
}

The documentation for this class was generated from the following file: