';
/**
* Cache the individual feed elements so they don't need to be
* searched for on every operation.
* @return array
*/
protected function _buildListItemCache()
{
$entries = array();
foreach ($this->_element->childNodes as $child) {
if ($child->localName == 'entry') {
$entries[] = $child;
}
}
return $entries;
}
/**
* Easy access to tags keyed by "rel" attributes.
* @TODO rationalize this with other __get/__call access
*
* If $elt->link() is called with no arguments, we will attempt to return
* the value of the tag(s) like all other method-syntax attribute
* access. If an argument is passed to link(), however, then we will return
* the "href" value of the first tag that has a "rel" attribute
* matching $rel:
*
* $elt->link(): returns the value of the link tag.
* $elt->link('self'): returns the href from the first in the entry.
*
* @param string $rel The "rel" attribute to look for.
* @return mixed
*/
public function link($rel = null)
{
if ($rel === null) {
return parent::__call('link', null);
}
// Index link tags by their "rel" attribute.
$links = parent::__get('link');
if (!is_array($links)) {
if ($links instanceof Horde_Xml_Element) {
$links = array($links);
} else {
return $links;
}
}
foreach ($links as $link) {
if (empty($link['rel'])) {
continue;
}
if ($rel == $link['rel']) {
return $link['href'];
}
}
return null;
}
}