コード例 #1
0
ファイル: IndexController.php プロジェクト: basdog22/Qool
 public function feedAction()
 {
     $data = $this->_request->getParams();
     $this->prefix = "Default_";
     $config = $this->config;
     $this->setupCache('default');
     //$this->totpl('theInclude','list');
     if ($data['lib']) {
         $feedtype = $data['type'];
         if (!($out = $this->loadCache('feed_' . $data['lib'] . "_" . $feedtype))) {
             //we have a lib... now get the content for this lib
             $type = $this->getContentTypeByLib($data['lib']);
             //some admins think it is a good thing to add more than one content type for each lib ;S
             if ($type['title']) {
                 $content = $this->getRecent($type['title'], 10);
             } else {
                 foreach ($type as $o => $s) {
                     $content[] = $this->getRecent($s['title'], 5);
                 }
             }
             //get recent items
             if (count($content) > 0) {
                 $feed = new Zend_Feed_Writer_Feed();
                 $feed->setTitle($config->site->frontend_title . " " . $data['lib'] . " feed");
                 $feed->setLink($this->http_location);
                 $feed->setCopyright($this->t($config->site->feed_copyright));
                 $feed->setGenerator($config->site->feed_generator);
                 $feed->setFeedLink($this->http_location . "/" . $data['lib'], 'atom');
                 $feed->setFeedLink($this->http_location . "/" . $data['lib'] . "?type=rss", 'rss');
                 $feed->addAuthor(array('name' => $config->site->feed_author_name, 'email' => $config->site->feed_author_email, 'uri' => $this->http_location));
                 $feed->setImage(array('uri' => $config->site->feed_logo_image));
                 $feed->setDateModified(time());
                 $feed->addHub('http://pubsubhubbub.appspot.com/');
                 //now we need to loop
                 foreach ($content as $k => $v) {
                     if ($v['title']) {
                         $entry = $feed->createEntry();
                         $entry->setTitle($v['title']);
                         $entry->setLink($this->http_location . "/" . $data['lib'] . "/" . $v['slug']);
                         $entry->setDateCreated($v['datestr']);
                         $entry->setDateModified(time());
                         if ($v['content']) {
                             $entry->setDescription(strip_tags(stripslashes(substr($v['content'], 0, 160))));
                         }
                         $feed->addEntry($entry);
                     } else {
                         foreach ($v as $r) {
                             $entry = $feed->createEntry();
                             $entry->setTitle($r['title']);
                             $entry->setLink($this->http_location . "/" . $data['lib'] . "/" . $r['slug']);
                             $entry->setDateCreated($r['datestr']);
                             $entry->setDateModified(time());
                             if ($r['content']) {
                                 $entry->setDescription(strip_tags(stripslashes(substr($r['content'], 0, 160))));
                             }
                             $feed->addEntry($entry);
                         }
                     }
                 }
                 $out = $feed->export($feedtype);
             }
             $this->cacheData($out, 'feed_' . $data['lib'] . "_" . $feedtype);
         }
         header("Content-type: text/xml");
         echo $out;
         die;
     }
 }
コード例 #2
0
ファイル: FeedTest.php プロジェクト: jsnshrmn/Suma
 public function testSetCopyrightThrowsExceptionOnInvalidParam()
 {
     $writer = new Zend_Feed_Writer_Feed();
     try {
         $writer->setCopyright('');
         $this->fail();
     } catch (Zend_Feed_Exception $e) {
     }
 }