getAttribute('rel')) !== 'alternate' || !$link->getAttribute('type') || !$link->getAttribute('href')) { continue; } if (!isset($this->rss) && $link->getAttribute('type') == 'application/rss+xml') { $this->rss = $this->_absolutiseUri(trim($link->getAttribute('href')), $uri); } elseif(!isset($this->atom) && $link->getAttribute('type') == 'application/atom+xml') { $this->atom = $this->_absolutiseUri(trim($link->getAttribute('href')), $uri); } elseif(!isset($this->rdf) && $link->getAttribute('type') == 'application/rdf+xml') { $this->rdf = $this->_absolutiseUri(trim($link->getAttribute('href')), $uri); } $this[] = new self(array( 'rel' => 'alternate', 'type' => $link->getAttribute('type'), 'href' => $this->_absolutiseUri(trim($link->getAttribute('href')), $uri), )); } } /** * Attempt to turn a relative URI into an absolute URI */ protected function _absolutiseUri($link, $uri = null) { if (!Zend_Uri::check($link)) { if (!is_null($uri)) { $link = rtrim($uri, '/') . '/' . ltrim($link, '/'); if (!Zend_Uri::check($link)) { $link = null; } } } return $link; } /** * Supports lazy loading of feeds using Zend_Feed_Reader::import() but * delegates any other operations to the parent class. * * @param string $offset * @return mixed * @uses Zend_Feed_Reader */ public function offsetGet($offset) { if ($offset == 'feed' && !$this->offsetExists('feed')) { if (!$this->offsetExists('href')) { return null; } $feed = Zend_Feed_Reader::import($this->offsetGet('href')); $this->offsetSet('feed', $feed); return $feed; } return parent::offsetGet($offset); } }