Apache Zeta Components Manual :: File Source for georss_module.php
Source for file georss_module.php
Documentation is available at georss_module.php
* File containing the ezcFeedGeoRssModule class.
* @version //autogentag//
* @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved.
* @license http://ez.no/licenses/new_bsd New BSD License
* Support for the GeoRss module: data container, generator, parser.
* Specifications: {@link http://www.w3.org/2003/01/geo/}.
* // $feed is an ezcFeed object
* $item = $feed->add( 'item' );
* $module = $item->addModule( 'GeoRss' );
* $module->long = -97.83;
* // $item is an ezcFeedEntryElement object
* $lat = isset( $item->GeoRss->lat ) ? $item->GeoRss->lat->__toString() : null;
* $long = isset( $item->GeoRss->long ) ? $item->GeoRss->long->__toString() : null;
* @property ezcFeedTextElement $lat
* {@link http://en.wikipedia.org/wiki/WGS84 WGS84} latitude
* on the globe as decimal degrees
* (eg. 25.03358300). Can also be negative.
* @property ezcFeedTextElement $long
* {@link http://en.wikipedia.org/wiki/WGS84 WGS84} longitude
* on the globe as decimal degrees
* (eg. 121.56430000). Can also be negative.
* @version //autogentag//
* Constructs a new ezcFeedContentModule object.
* @param string $level The level of the data container ('feed' or 'item')
* Sets the property $name to $value.
* @throws ezcBasePropertyNotFoundException
* if the property $name is not defined
* @param string $name The property name
* @param mixed $value The property value
public function __set( $name, $value )
$node =
$this->add( $name );
parent::__set( $name, $value );
* Returns the value of property $name.
* @throws ezcBasePropertyNotFoundException
* if the property $name is not defined
* @param string $name The property name
public function __get( $name )
return parent::__get( $name );
* Returns if the property $name is set.
* @param string $name The property name
public function __isset( $name )
return parent::__isset( $name );
* Returns true if the element $name is allowed in the current module at the
* current level (feed or item), and false otherwise.
* @param string $name The element name to check if allowed in the current module and level (feed or item)
if ( in_array( $name, array( 'lat', 'long', 'point', 'where', 'box' ) ) )
if ( in_array( $name, array( 'lat', 'long', 'point', 'where', 'box' ) ) )
* Adds a new ezcFeedElement element with name $name to this module and
* @throws ezcFeedUnsupportedElementException
* if trying to add an element which is not supported.
* @param string $name The element name
public function add( $name )
* Adds the module elements to the $xml XML document, in the container $root.
* @param DOMDocument $xml The XML document in which to add the module elements
* @param DOMNode $root The parent node which will contain the module elements
public function generate( DOMDocument $xml, DOMNode $root )
if ( isset
( $this->lat ) && isset
( $this->long ) )
$root->appendChild( $elementTag );
$elementTag->nodeValue =
"{
$this->lat} {
$this->long}";
* Parses the XML element $node and creates a feed element in the current
* module with name $name.
* @param string $name The name of the element belonging to the module
* @param DOMElement $node The XML child from which to take the values for $name
public function parse( $name, DOMElement $node )
$children = $node->childNodes;
$value =
trim( $children->item(1)->textContent );
list
( $lat, $long ) =
explode( ' ', $value );
$element =
$this->add( 'lat' );
$element =
$this->add( 'long' );
$value =
$node->textContent;
list
( $lat, $long ) =
explode( ' ', $value );
$element =
$this->add( 'lat' );
$element =
$this->add( 'long' );
$value =
$node->textContent;
list
( $lat1, $long1, $lat2, $long2 ) =
explode( ' ', $value );
$element =
$this->add( 'lat' );
$element->text =
( $lat1 +
$lat2 ) /
2;
$element =
$this->add( 'long' );
$element->text =
( $long1 +
$long2 ) /
2;
* Returns the module name (GeoRss').
public static function getModuleName()
* Returns the namespace for this module ('http://www.w3.org/2003/01/geo/wgs84_pos#').
public static function getNamespace()
return 'http://www.georss.org/georss';
* Returns the namespace prefix for this module ('georss').
public static function getNamespacePrefix()