Beispiel #1
0
 function callbackAddRssFeeds($hookName, $args)
 {
     if ($this->getEnabled()) {
         $current = $args[0];
         $output =& $args[1];
         $journal =& Request::getJournal();
         $journalId = $journal->getJournalId();
         $templateMgr =& TemplateManager::getManager();
         $this->import('SimplePie');
         $urls = $this->getSetting($journalId, 'urls');
         $months = $this->getSetting($journalId, 'months');
         $aggregate = $this->getSetting($journalId, 'aggregate');
         $feeds = array();
         foreach ($urls as $feedInfo) {
             $webSafe = array();
             foreach (explode(":", $feedInfo['pageName']) as $pageName) {
                 $webSafe[] = ContentManager::websafe($pageName);
             }
             $webSafe = implode(":", $webSafe);
             // skip all the ones that wont go on this page
             if (strcmp($webSafe, $current) != 0) {
                 continue;
             }
             $feed = new SimplePie();
             $feed->feed_url($feedInfo['url']);
             $feed->cache_location(Core::getBaseDir() . DIRECTORY_SEPARATOR . 'cache');
             $feed->replace_headers(true);
             $feed->init();
             if ($feed->data) {
                 $max = $feed->get_item_quantity(0);
                 $templateMgr->assign('feed', $feed);
                 for ($x = 0; $x < $max; $x++) {
                     $item = $feed->get_item($x);
                     $templateMgr->assign('item', $item);
                     $items[$item->get_date('U')] = trim($templateMgr->fetch($this->getTemplatePath() . 'rss.tpl'));
                 }
             }
         }
         if (is_array($items) && count($items) > 0) {
             if ($aggregate) {
                 krsort($items);
             }
             foreach ($items as $time => $post) {
                 if ($months > 0) {
                     if ($time > strtotime("-" . $months . " month")) {
                         $output .= $post;
                     }
                 } else {
                     $output .= $post;
                 }
             }
         }
     }
     return false;
 }