Exemplo n.º 1
0
 public function actionRssfeed()
 {
     // Don't Publish the RSS Feed if the Site index requires a login
     if (Yii::app()->params['requireLogin']) {
         return;
     }
     // OK to publish an RSS feed of Active Timers
     // get All the timers
     $model = new Pos();
     $poslist = $model->findAll();
     Yii::import('ext.feed.*');
     // Create a feed object
     // RSS 2.0 is the default type
     $feed = new EFeed();
     // Set the title to Match the Web Site
     $feed->title = Yii::app()->name;
     $feed->description = Yii::app()->params['indexHeader'];
     $sitename = str_replace('localhost', '127.0.0.1', Yii::app()->getBaseUrl($absolute = true));
     $feed->setLink($sitename);
     // add an item for each POS
     if (count($poslist)) {
         foreach ($poslist as $pos) {
             $item = $feed->createNewItem();
             $item->title = $pos->type . ' in ' . $pos->location . ' is due out of ' . $pos->cycle . ' cycle at ' . $pos->date;
             $item->link = Yii::app()->getBaseUrl($absolute = true) . '?=' . $pos->id;
             $item->date = $pos->date;
             $item->addTag('guid', Yii::app()->getBaseUrl($absolute = true) . '?=' . $pos->id, array('isPermaLink' => 'true'));
             $feed->addItem($item);
         }
     } else {
         //nothing to add
         $item = $feed->createNewItem();
         $item->title = "No Timers posted";
         $item->link = Yii::app()->getBaseUrl($absolute = true) . '?=' . $pos->id;
         $item->date = date(DATE_RFC822);
         $feed->addItem($item);
     }
     $feed->addChannelTag('language', 'en-us');
     $feed->addChannelTag('pubDate', date(DATE_RSS, time()));
     // generate the feed and display it
     $feed->generateFeed();
     // Dont need to render anything
     //$this->render('rssfeed',array('feed'=>$feed));
 }