ezcFeedModule) */ private $modules = array(); /** * Sets the property $name to $value. * * @param string $name The property name * @param mixed $value The property value * @ignore */ public function __set( $name, $value ) { switch ( $name ) { case 'title': case 'description': case 'comments': case 'copyright': case 'language': $element = $this->add( $name ); $element->text = $value; break; case 'content': $element = $this->add( $name ); $element->text = $value; break; case 'author': case 'contributor': $element = $this->add( $name ); $element->name = $value; break; case 'updated': case 'published': $element = $this->add( $name ); $element->date = $value; break; case 'id': $element = $this->add( $name ); $element->id = $value; break; case 'link': $element = $this->add( $name ); $element->href = $value; break; case 'enclosure': $element = $this->add( $name ); $element->url = $value; break; case 'source': $element = $this->add( $name ); $element->source = $value; break; default: $supportedModules = ezcFeed::getSupportedModules(); if ( isset( $supportedModules[$name] ) ) { $this->modules[$name] = $value; } break; } } /** * Returns the value of property $name. * * @throws ezcFeedUndefinedModuleException * if trying to fetch a module not defined yet * * @param string $name The property name * @return mixed * @ignore */ public function __get( $name ) { switch ( $name ) { case 'author': case 'category': case 'comments': case 'content': case 'contributor': case 'copyright': case 'description': case 'enclosure': case 'id': case 'link': case 'published': case 'title': case 'updated': case 'source': case 'language': if ( isset( $this->properties[$name] ) ) { return $this->properties[$name]; } break; default: $supportedModules = ezcFeed::getSupportedModules(); if ( isset( $supportedModules[$name] ) ) { if ( isset( $this->$name ) ) { return $this->modules[$name]; } else { throw new ezcFeedUndefinedModuleException( $name ); } } break; } } /** * Returns if the property $name is set. * * @param string $name The property name * @return bool * @ignore */ public function __isset( $name ) { switch ( $name ) { case 'author': case 'category': case 'comments': case 'content': case 'contributor': case 'copyright': case 'description': case 'enclosure': case 'id': case 'link': case 'published': case 'title': case 'updated': case 'source': case 'language': return isset( $this->properties[$name] ); default: $supportedModules = ezcFeed::getSupportedModules(); if ( isset( $supportedModules[$name] ) ) { return isset( $this->modules[$name] ); } } } /** * Adds a new element with name $name to the feed item and returns it. * * Example: * * // $item is an ezcFeedEntryElement object * $link = $item->add( 'link' ); * $link->href = 'http://ez.no/'; * * * @throws ezcFeedUnsupportedElementException * if the element $name is not supported * * @apichange All items are not encoded at all, in future versions this * should be done in one of the ways as described in * http://issues.ez.no/14093 * * @param string $name The name of the element to add * @return ezcFeedElement */ public function add( $name ) { switch ( $name ) { case 'author': case 'contributor': $element = new ezcFeedPersonElement(); $this->properties[$name][] = $element; break; case 'id': $element = new ezcFeedIdElement(); $this->properties[$name] = $element; break; case 'category': $element = new ezcFeedCategoryElement(); $this->properties[$name][] = $element; break; case 'title': case 'description': case 'comments': case 'copyright': case 'language': $element = new ezcFeedTextElement(); $this->properties[$name] = $element; break; case 'content': $element = new ezcFeedContentElement(); $this->properties[$name] = $element; break; case 'updated': case 'published': $element = new ezcFeedDateElement(); $this->properties[$name] = $element; break; case 'link': $element = new ezcFeedLinkElement(); $this->properties[$name][] = $element; break; case 'enclosure': $element = new ezcFeedEnclosureElement(); $this->properties[$name][] = $element; break; case 'source': $element = new ezcFeedSourceElement(); $this->properties[$name] = $element; break; default: throw new ezcFeedUnsupportedElementException( $name ); } return $element; } /** * Adds a new module to this item and returns it. * * @param string $name The name of the module to add * @return ezcFeedModule */ public function addModule( $name ) { $this->$name = ezcFeedModule::create( $name, 'item' ); return $this->$name; } /** * Returns true if the module $name is loaded, false otherwise. * * @param string $name The name of the module to check if loaded for this item * @return bool */ public function hasModule( $name ) { return isset( $this->modules[$name] ); } /** * Returns an array with all the modules defined for this feed item. * * @return array(ezcFeedModule) */ public function getModules() { return $this->modules; } } ?>