Esempio n. 1
0
 /**
  * Add in the right RSS feed to the HTML head
  *
  * @param array $rData
  * @return array
  */
 public function hookCntrlrPreDispatch($rData)
 {
     if (Registry::has('theme')) {
         if ($rData['module'] != 'rss' && $rData['controller'] != 'feed') {
             // Get the default feed
             try {
                 $defFeed = array();
                 $defFeed[] = $this->_config->get('rss/default_feed');
                 if (!Rss::feedExists($defFeed[0])) {
                     unset($defFeed[0]);
                 }
             } catch (Config_KeyNoExist $e) {
                 $this->_log->message('RSS config key "rss/default_feed" does not exist, unable to add default feed to head.', Log::L_WARNING);
             }
             // Find all the RSS feeds for the current page
             $feeds = Hooks::notifyAll('rss_insert_head', $rData['module'], $rData['controller'], $rData['section']);
             if (is_array($feeds)) {
                 foreach (array_filter(array_merge($defFeed, $feeds)) as $feed) {
                     // Add all found feeds to head
                     $rss = new Rss($feed);
                     if ($rss->hasFeedInfo()) {
                         $details = array('rel' => 'alternate', 'type' => 'application/rss+xml', 'href' => $this->_router->makeFullUrl('rss', 'feed', $feed), 'title' => $rss->getFeedInfo('title'));
                         $this->_theme->addHead('link', $details);
                     } else {
                         $this->_log->message('Feed "' . $feed . '" does not have feed info set.', Log::L_WARNING);
                     }
                 }
             }
         }
     }
     return $rData;
 }