Пример #1
0
 private function generateFeed($datasets)
 {
     Yii::import('ext.feed.*');
     // specify feed type
     $feed = new EFeed(EFeed::RSS1);
     $feed->title = $this->title;
     $feed->link = $this->rssLink;
     $feed->description = $this->rssDescription;
     $feed->RSS1ChannelAbout = $this->rssAbout;
     foreach ($datasets as $key => $dataset) {
         $title = $this->isDataset($dataset) ? $dataset->title : $dataset->message;
         $link = $this->isDataset($dataset) ? Yii::app()->request->hostInfo . "/dataset/" . $dataset->identifier : Yii::app()->request->hostInfo;
         $desc = $this->isDataset($dataset) ? $dataset->description : $dataset->message;
         // create dataset item
         $item = $feed->createNewItem();
         $item->title = $title;
         $item->link = $link;
         $item->date = $dataset->publication_date;
         $item->description = $desc;
         $item->addTag('dc:subject', $title);
         $feed->addItem($item);
     }
     if (count($datasets) == 0) {
         echo "No Item";
     } else {
         $feed->generateFeed();
     }
 }
Пример #2
0
 public function run()
 {
     $this->controller->layout = false;
     $feedSettings = CMap::mergeArray($this->getDefaultFeedSettings(), $this->getFeedSettings());
     $feedItems = $this->getRssItems();
     $feed = new EFeed($this->type);
     $channelTags = HArray::val($feedSettings, 'channelTags', array());
     unset($feedSettings['channelTags']);
     //Настраиваем канал
     foreach ($feedSettings as $settingName => $settingValue) {
         $feed->{$settingName} = $settingValue;
     }
     $feed->addChannelTagsArray($channelTags);
     //Заносим элементы канала
     $c = count($feedItems);
     for ($i = 0; $i < $c; $i++) {
         $feed->addItem($feedItems[$i]);
     }
     if ($c == 0) {
         echo 'No feed items';
         return;
     }
     //рендерим канал
     $feed->generateFeed();
 }
Пример #3
0
	/**
	 * (non-PHPdoc)
	 * @see EFeedItemAbstract::setLink()
	 */
	public function setLink( $link ){
		$validator = new CUrlValidator();
		if(!$validator->validateValue($link))
			throw new CException( Yii::t('EFeed', $link. ' does not seem to be a valid URL') );
			
		$this->addTag('link','',array('href'=>$link));
		$this->addTag('id', EFeed::uuid($link,'urn:uuid:'));
	}
Пример #4
0
 public function actionRss()
 {
     // disabling web log
     foreach (Yii::app()->log->routes as $route) {
         if ($route instanceof CWebLogRoute) {
             $route->enabled = false;
         }
     }
     Yii::import('ext.feed.*');
     $feed = new EFeed();
     $feed->title = Yii::app()->name . ' | ' . Yii::t('newsModule.common', 'Nouvelles');
     $feed->description = Yii::app()->name . ' | ' . Yii::t('newsModule.common', 'Nouvelles');
     $feed->addChannelTag('language', Yii::app()->language);
     $feed->addChannelTag('pubDate', date(DATE_RSS, time()));
     $feed->addChannelTag('link', $this->createAbsoluteUrl('index'));
     if ($news = News::model()->findAll(array('order' => 'date DESC', 'limit' => 25, 'condition' => "date <= '" . date('Y-m-d H:i:s') . "' AND section_id = " . Yii::app()->cms->currentSectionId))) {
         foreach ($news as $new) {
             $item = $feed->createNewItem();
             $item->title = $new->title;
             $item->link = $this->createAbsoluteUrl('detail', array('n' => $new->title_url));
             $item->date = $new->date;
             if (!empty($new->image)) {
                 $item->description = '<div style="margin-bottom: 1em;"><img src="' . Yii::app()->request->hostInfo . Yii::app()->request->baseUrl . '/' . $new->imageHandler->dir . '/' . Helper::encodeFileName(Helper::fileSuffix($new->image, 's')) . '" alt="' . CHtml::encode($new->title) . '" /></div><div>' . CHtml::encode($new->summary) . '</div>';
             } else {
                 $item->description = CHtml::encode($new->summary);
             }
             $feed->addItem($item);
         }
     }
     $feed->generateFeed();
     Yii::app()->end();
 }
Пример #5
0
 public function actionFeed()
 {
     Yii::import('aiajaya.extensions.efeed.*');
     // RSS 2.0 is the default type
     $feed = new EFeed();
     $feed->title = 'Gästebuch von ' . Yii::app()->name;
     $feed->description = 'Das Gästebuch vom ' . Yii::app()->name;
     $feed->addChannelTag('language', 'de-de');
     $feed->addChannelTag('pubDate', date(DATE_RSS, time()));
     $feed->addChannelTag('link', $this->createAbsoluteUrl('/page/guestbook/list'));
     // * self reference
     $feed->addChannelTag('atom:link', $this->createAbsoluteUrl('/page/guestbook/feed'));
     $criteria = new CDbCriteria(array('order' => '`createDate` DESC'));
     $dataProvider = new CActiveDataProvider('Comment', array('pagination' => array('pageSize' => 0), 'criteria' => $criteria));
     foreach ($dataProvider->getData() as $comment) {
         $item = $feed->createNewItem();
         $item->title = $comment->getBaseModel()->commentName;
         $item->link = $this->createAbsoluteUrl('/page/page/get', array('key' => $comment->getBaseModel()->key));
         $item->date = $comment->createDate;
         $item->description = $comment->message;
         $item->addTag('author', $comment->name);
         //$item->addTag('guid', 'http://www.ramirezcobos.com/',array('isPermaLink'=>'true'));
         $feed->addItem($item);
     }
     $feed->generateFeed();
     Yii::app()->end();
 }
Пример #6
0
 public function actionFeed()
 {
     Yii::import('ext.feed.*');
     // specify feed type
     $feed = new EFeed(EFeed::RSS1);
     $feed->title = 'Testing the RSS 1 EFeed class';
     $feed->link = 'http://www.ramirezcobos.com';
     $feed->description = 'This is test of creating a RSS 1.0 feed by Universal Feed Writer';
     $feed->RSS1ChannelAbout = 'http://www.ramirezcobos.com/about';
     // create our item
     $item = $feed->createNewItem();
     $item->title = 'The first feed';
     $item->link = 'http://www.yiiframework.com';
     $item->date = time();
     $item->description = 'Amaz-ii-ng <b>Yii Framework</b>';
     $item->addTag('dc:subject', 'Subject Testing');
     $feed->addItem($item);
     $feed->generateFeed();
 }
 public function setAtom($limit, $offset)
 {
     $feed = new EFeed(EFeed::ATOM);
     // IMPORTANT : No need to add id for feed or channel. It will be automatically created from link.
     $feed->title = 'ATOM RSS KESELEG';
     $feed->link = 'http://keseleg.com';
     $feed->addChannelTag('updated', date(DATE_ATOM, time()));
     $feed->addChannelTag('author', array('name' => Yii::app()->params['system_name']));
     $criteria = new CDbCriteria();
     $criteria->limit = $limit;
     $criteria->offset = $offset;
     $criteria->order = 'ID desc';
     $model = Post::model()->is_publish()->findAll($criteria);
     foreach ($model as $post) {
         $item = $feed->createNewItem();
         $item->title = $post->post_name;
         $item->link = Yii::app()->createAbsoluteUrl("/single/index", array('id' => $post->ID, 'slug' => $post->post_link));
         $item->date = $post->post_modified;
         $item->description = $post->post_excerpt;
         $feed->addItem($item);
     }
     $feed->generateFeed();
 }
Пример #8
0
 public function actionFeed()
 {
     Yii::import('aiajaya.extensions.efeed.*');
     // RSS 2.0 is the default type
     $feed = new EFeed();
     $feed->title = 'Termine vom ' . Yii::app()->name;
     $feed->description = '';
     // Alle Termine live im BlickDies ist ein Test die Termine als RSS 2.0 Feed anzubieten - Es wird keine Garantie auf Korrektheit und Aktualität gegeben.';
     //$feed->setImage('Testing RSS 2.0 EFeed class','http://www.ramirezcobos.com/rss',
     //'http://www.yiiframework.com/forum/uploads/profile/photo-7106.jpg');
     $feed->addChannelTag('language', 'de-de');
     $feed->addChannelTag('pubDate', date(DATE_RSS, time()));
     $feed->addChannelTag('link', $this->createAbsoluteUrl('/event/termin'));
     // * self reference
     $feed->addChannelTag('atom:link', $this->createAbsoluteUrl('/event/termin/feed'));
     $criteria = new CDbCriteria(array('condition' => '`to`>' . (time() - 60 * 30), 'order' => '`from` ASC'));
     $dataProvider = new CActiveDataProvider('Termin', array('pagination' => array('pageSize' => 0), 'criteria' => $criteria));
     foreach ($dataProvider->getData() as $termin) {
         $item = $feed->createNewItem();
         $item->title = $termin->titel;
         $url = $termin->getUrl();
         if (is_array($url)) {
             $part1 = $url[0];
             unset($url[0]);
             $part2 = $url;
             $item->link = $this->createAbsoluteUrl($part1, $part2);
         } else {
             $item->link = $url;
         }
         $item->date = $termin->from;
         $untertitel = str_replace('--', '<br/>', $termin->untertitel);
         $untertitel .= '<hr/>' . str_replace('--', '<br/>', $termin->datum) . ' ' . str_replace('--', '<br/>', $termin->zeit);
         if ($termin->url) {
             $untertitel .= '<hr/><a href="' . $termin->url . '">Weitere Informationen</a>';
         }
         $item->description = $untertitel;
         //$item->addTag('author', 'thisisnot@myemail.com (Antonio Ramirez)');
         //$item->addTag('guid', 'http://www.ramirezcobos.com/',array('isPermaLink'=>'true'));
         $feed->addItem($item);
     }
     $feed->generateFeed();
     Yii::app()->end();
 }
Пример #9
0
 public function actionRss()
 {
     // disabling web log
     foreach (Yii::app()->log->routes as $route) {
         if ($route instanceof CWebLogRoute) {
             $route->enabled = false;
         }
     }
     Yii::import('ext.feed.*');
     $feed = new EFeed();
     $feed->title = Yii::app()->name . ' | ' . Yii::t('jobModule.common', 'Offres demplois');
     $feed->description = Yii::app()->name . ' | ' . Yii::t('jobModule.common', 'Offres demplois');
     $feed->addChannelTag('language', Yii::app()->language);
     $feed->addChannelTag('pubDate', date(DATE_RSS, time()));
     $feed->addChannelTag('link', $this->createAbsoluteUrl('index'));
     if ($jobs = Job::model()->findAll(array('order' => 'publication_date DESC', 'limit' => 25, 'condition' => "publication_date <= '" . date('Y-m-d H:i:s') . "' AND active = 1"))) {
         foreach ($jobs as $job) {
             $item = $feed->createNewItem();
             $item->title = $job->title;
             $item->link = $this->createAbsoluteUrl('/job/default/detail', array('t' => $job->title_url));
             $item->date = $job->publication_date;
             $type = '';
             switch ($job->type) {
                 case '1':
                     $type = "Permanent";
                     break;
                 case '2':
                     $type = "Temps partiel";
                     break;
                 case '3':
                     $type = "Saisonnier";
                     break;
             }
             $item->description = "\n\t\t\t\t\t<p>\n\t\t\t\t\t\tType de l’emploi : " . $type . "<br/>\n\t\t\t\t\t\tDate de début : " . ((isset($job->start_date) and $job->start_date != '0000-00-00') ? Helper::formatDate($job->start_date, "reg") : Yii::t('jobModule.common', 'Indéterminée')) . "<br/>\n\t\t\t\t\t\tDate et heure limite pour postuler : " . (isset($job->postulation_end_date) ? substr(Helper::formatDate($job->postulation_end_date, "reg+time"), 0, -3) : Yii::t('jobModule.common', 'Indéterminée')) . "\n\t\t\t\t\t</p>\t\t\n\t\t\t\t" . strip_tags($job->description);
             $feed->addItem($item);
         }
     }
     $feed->generateFeed();
     Yii::app()->end();
 }
Пример #10
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));
 }