/** * Returns if the property $name is set. * * @param string $name The property name * @return bool * @ignore */ public function __isset($name) { switch ($name) { case 'date': return isset($this->properties[$name]); default: return parent::__isset($name); } }
/** * Adds a new element with name $name to the feed item and returns it. * * The subcategory is only used by the iTunes module (ezcFeedITunesModule). * * Example: * <code> * // $feed is an ezcFeed object * $category = $feed->add( 'category' ); * $category->term = 'Technology'; * $subCategory = $category->add( 'category' ); * $subCategory->term = 'Gadgets'; * </code> * * @param string $name The name of the element to add * @return ezcFeedCategoryElement */ public function add($name) { if ($name === 'category') { $this->category = new ezcFeedCategoryElement(); return $this->category; } else { return parent::add($name); } }
/** * Returns the value of property $name. * * @param string $name The property name * @return mixed * @ignore */ public function __get($name) { switch ($name) { case 'days': if (isset($this->properties[$name])) { return $this->properties[$name]; } break; default: return parent::__get($name); } }
/** * Returns if the property $name is set. * * @param string $name The property name * @return bool * @ignore */ public function __isset($name) { switch ($name) { case 'title': case 'description': case 'copyright': case 'author': case 'contributor': case 'updated': case 'generator': case 'image': case 'icon': case 'id': case 'link': case 'category': return isset($this->properties[$name]); default: return parent::__isset($name); } }
/** * Parses the provided XML element object and stores it as a feed item in * the provided ezcFeed object. * * @param ezcFeedElement $element The feed element object that will contain the feed item * @param DOMElement $xml The XML element object to parse */ private function parseItem(ezcFeedElement $element, DOMElement $xml) { foreach ($xml->childNodes as $itemChild) { if ($itemChild->nodeType === XML_ELEMENT_NODE) { $tagName = $itemChild->tagName; switch ($tagName) { case 'title': case 'description': case 'comments': $subElement = $element->add($tagName); $subElement->text = $itemChild->textContent; break; case 'author': $subElement = $element->add($tagName); $subElement->name = $itemChild->textContent; // @todo parse textContent if it has the format: email@host (name) break; case 'pubDate': $element->published = $itemChild->textContent; break; case 'enclosure': $subElement = $element->add($tagName); $attributes = array('url' => 'url', 'type' => 'type', 'length' => 'length'); foreach ($attributes as $name => $alias) { if ($itemChild->hasAttribute($name)) { $subElement->{$alias} = $itemChild->getAttribute($name); } } break; case 'link': $subElement = $element->add($tagName); $subElement->href = $itemChild->textContent; break; case 'source': $subElement = $element->add($tagName); $subElement->source = $itemChild->textContent; if ($itemChild->hasAttribute('url')) { $subElement->url = $itemChild->getAttribute('url'); } break; case 'category': $subElement = $element->add($tagName); $subElement->term = $itemChild->textContent; if ($itemChild->hasAttribute('domain')) { $subElement->scheme = $itemChild->getAttribute('domain'); } break; case 'guid': $subElement = $element->add('id'); $subElement->id = $itemChild->textContent; if ($itemChild->hasAttribute('isPermaLink')) { $value = $itemChild->getAttribute('isPermaLink'); $subElement->isPermaLink = strtolower($value) === 'true' ? true : false; } break; default: // check if it's part of a known module/namespace $this->parseModules($element, $itemChild, $tagName); break; } } } if ($xml->hasAttribute('xml:lang')) { $element->language = $xml->getAttribute('xml:lang'); } }