Displays a feed
Автор: Electric Function, Inc.
Наследование: extends Front_Controller
Пример #1
0
 /**
  * Planet クロールする
  **/
 public static function __setup_crawl__()
 {
     $http_feed = new Feed();
     foreach (C(PlanetSubscription)->find_all() as $subscription) {
         Exceptions::clear();
         Log::debug(sprintf('[crawl] feed: %d (%s)', $subscription->id(), $subscription->title()));
         try {
             $feed = $http_feed->do_read($subscription->rss_url());
             $subscription->title($feed->title());
             if ($feed->is_link()) {
                 $subscription->link(self::_get_link_href($feed->link()));
             }
             $subscription->rss_url($http_feed->url());
             $subscription->save(true);
             foreach ($feed->entry() as $entry) {
                 Exceptions::clear();
                 try {
                     $planet_entry = new PlanetEntry();
                     $planet_entry->subscription_id($subscription->id());
                     $planet_entry->title(Tag::cdata($entry->title()));
                     $planet_entry->description(Text::htmldecode(Tag::cdata($entry->fm_content())));
                     $planet_entry->link($entry->first_href());
                     $planet_entry->updated($entry->published());
                     $planet_entry->save();
                 } catch (Exception $e) {
                     Log::warn($e->getMessage());
                 }
             }
         } catch (Exception $e) {
             Log::error($e);
         }
     }
 }
Пример #2
0
 /**
  * Takes a Feed object from a completed search and saves it
  *
  * @param Feed $feed
  */
 public function __construct(Feed $feed)
 {
     $this->upload_dir = wp_upload_dir();
     $this->feed = $feed;
     $this->mls = $feed->mls;
     self::posts($feed->get());
 }
 public function executeEdit($request, $new = false)
 {
     $this->form = new PodcastForm($new ? null : PodcastPeer::retrieveByPk($request->getParameter('id')));
     $this->podcast = $this->form->getObject();
     $this->episodes = $this->podcast->getEpisodes();
     $this->feeds = $this->podcast->getFeeds();
     $this->podcast_feed_form = new FeedForm();
     $this->podcast_feed_form->setDefaults(array('podcast_id' => $this->podcast->getId()), array());
     if ($request->isMethod('post')) {
         $this->form->bind($request->getPostParameters(), array());
         // FIXME bind to real files array
         if ($this->form->isValid()) {
             $podcast = $this->form->save();
             if ($new) {
                 $feed = new Feed();
                 // add a sensible default feed
                 $feed->setTitle('default');
                 $feed->setSlug('default');
                 $podcast->addFeed($feed);
                 $feed->save();
                 $podcast->setDefaultFeed($feed);
                 $podcast->save();
             }
             $this->redirect('podcast/edit?id=' . $podcast->getId());
         }
     }
 }
Пример #4
0
 function updateMemcache()
 {
     // ignore_user_abort();
     //set_time_limit(0);
     //$interval=3600; //(seconds)
     require_once 'model/Feed.php';
     require_once 'lib/BitMemCache.php';
     require_once 'lib/RssReader.php';
     $feed = new Feed();
     $feeds = $feed->getFeeds();
     $logger = LogUtil::getLogger();
     //do{
     include "config/site.php";
     foreach ($feeds as $feed) {
         $url = $feed['url'];
         $mem = new BitMemCache();
         $reader = new RssReader();
         $rss = $reader->fetch($url);
         if (!$rss) {
         } else {
             if ($mem->init()) {
                 $mem->set($url, json_encode($rss));
                 $logger->info("update memcache {$url}");
             }
         }
     }
     //  sleep($interval);
     //}while($memcache);
 }
Пример #5
0
 public function testConstructor()
 {
     $f1 = new Feed();
     $this->assertEquals(0, $f1->size());
     $f1->createItem();
     $this->assertEquals(1, $f1->size());
 }
Пример #6
0
 public function actionCreate($location = null)
 {
     $project = new Project();
     $project->location_id = $location;
     $project->created_by_user_id = Yii::app()->user->id;
     $project->champs = array($project->created_by_user_id);
     if (!isset($_POST['Project'])) {
         $this->render('create', array('model' => $project));
         Yii::app()->end();
     }
     $project->attributes = $_POST['Project'];
     $project->slug = slugify($project->name);
     if (isset($_POST['ajax'])) {
         echo CActiveForm::validate($project, null, false);
         Yii::app()->end();
     }
     if (!$project->validate()) {
         $this->render('create', array('model' => $project));
         Yii::app()->end();
     }
     $feed = new Feed();
     $feed->followers = array($project->created_by_user_id);
     $feed->save();
     $project->feed_id = $feed->id;
     if (!$project->save()) {
         Yii::log('Project::save() failed. $errors = ' . print_r($project->getErrors(), true), 'error', 'app.project.create');
         $form->addError('save', 'Failed save the new project.');
         $this->render('create', array('model' => $project));
         $feed->delete();
         Yii::app()->end();
     }
     $this->renderText('window.parent.location = "' . $this->createUrl('view', array('id' => $project->id)) . '";');
 }
 function listnews()
 {
     include "config/site.php";
     require_once 'model/Feed.php';
     $feed = new Feed();
     $feeds = $feed->getFeeds();
     require "view/admin/feednews.php";
 }
Пример #8
0
function isSavedFeed($feedId = '')
{
    if (!class_exists('Feed')) {
        include_once INST_PATH . 'app/models/feed.php';
    }
    $Feed = new Feed();
    return false or $Feed->Find_by_original_id_feed($feedId)->count() > 0;
}
Пример #9
0
 /**
  * Support method to turn a record driver object into an RSS entry.
  *
  * @param Feed                              $feed   Feed to update
  * @param \VuFind\RecordDriver\AbstractBase $record Record to add to feed
  *
  * @return void
  */
 protected function addEntry($feed, $record)
 {
     $entry = $feed->createEntry();
     $title = $record->tryMethod('getTitle');
     $title = empty($title) ? $record->getBreadcrumb() : $title;
     $entry->setTitle(empty($title) ? $this->translate('Title not available') : $title);
     $serverUrl = $this->getView()->plugin('serverurl');
     $recordLink = $this->getView()->plugin('recordlink');
     try {
         $url = $serverUrl($recordLink->getUrl($record));
     } catch (\Zend\Mvc\Router\Exception\RuntimeException $e) {
         // No route defined? See if we can get a URL out of the driver.
         // Useful for web results, among other things.
         $url = $record->tryMethod('getUrl');
         if (empty($url) || !is_string($url)) {
             throw new \Exception('Cannot find URL for record.');
         }
     }
     $entry->setLink($url);
     $date = $this->getDateModified($record);
     if (!empty($date)) {
         $entry->setDateModified($date);
     }
     $author = $record->tryMethod('getPrimaryAuthor');
     if (!empty($author)) {
         $entry->addAuthor(['name' => $author]);
     }
     $authors = $record->tryMethod('getSecondaryAuthors');
     if (is_array($authors)) {
         foreach ($authors as $author) {
             $entry->addAuthor(['name' => $author]);
         }
     }
     $formats = $record->tryMethod('getFormats');
     if (is_array($formats)) {
         // Take only the most specific format and get rid of level indicator
         // and trailing slash
         $format = end($formats);
         $format = implode('/', array_slice(explode('/', $format), 1, -1));
         $entry->addDCFormat($format);
     }
     $dcDate = $this->getDcDate($record);
     if (!empty($dcDate)) {
         $entry->setDCDate($dcDate);
     }
     $urlHelper = $this->getView()->plugin('url');
     $recordHelper = $this->getView()->plugin('record');
     $recordImage = $this->getView()->plugin('recordImage');
     $imageUrl = $recordImage($recordHelper($record))->getLargeImage();
     $entry->setEnclosure(['uri' => $serverUrl($imageUrl), 'type' => 'image/jpeg', 'length' => 1]);
     $entry->setCommentCount(count($record->getComments()));
     $summaries = $record->tryMethod('getSummary');
     if (!empty($summaries)) {
         $entry->setDescription(implode(' -- ', $summaries));
     }
     $feed->addEntry($entry);
 }
Пример #10
0
 /**
  * Feed ajax 读取
  */
 public function actionFeed()
 {
     $type = Yii::app()->request->getParam('type');
     $uid = Yii::app()->request->getParam('uid');
     $feeds = array();
     $model = new Feed();
     $feeds = $model->getFeeds($uid, $type, $page, $opts);
     $data = array('feeds' => $feeds);
     $this->renderPartial('feed', $data, '', false);
 }
 public function getRequestAndAnswer()
 {
     $feed = new Feed();
     if ($this->returnAll == false) {
         $content = $_POST['content'];
         echo json_encode($feed->getSpecific($content));
     } else {
         echo json_encode($feed->getAll());
     }
 }
Пример #12
0
 /**
  * Createas a new rss writer
  */
 function __construct(Feed $feed)
 {
     $this->domDoc = new \DOMDocument("1.0", "utf-8");
     $this->domDoc->formatOutput = true;
     $this->CreateRssElement();
     $this->feed = $feed;
     $this->domDoc->appendChild($this->rssElement);
     $channels = $this->feed->GetChannels();
     foreach ($channels as $rssChannel) {
         $this->AddChannel($rssChannel);
     }
 }
Пример #13
0
function rssmaker_plugin_action($_, $myUser)
{
    if ($_['action'] == 'show_folder_rss') {
        header('Content-Type: text/xml; charset=utf-8');
        $feedManager = new Feed();
        $feeds = $feedManager->loadAll(array('folder' => $_['id']));
        $items = array();
        foreach ($feeds as $feed) {
            $parsing = new SimplePie();
            $parsing->set_feed_url($feed->getUrl());
            $parsing->init();
            $parsing->set_useragent('Mozilla/4.0 Leed (LightFeed Agregator) ' . VERSION_NAME . ' by idleman http://projet.idleman.fr/leed');
            $parsing->handle_content_type();
            // UTF-8 par défaut pour SimplePie
            $items = array_merge($parsing->get_items(), $items);
        }
        $link = 'http://projet.idleman.fr/leed';
        echo '<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/">
	<channel>
				<title>Leed dossier ' . $_['name'] . '</title>
				<atom:link href="' . $link . '" rel="self" type="application/rss+xml"/>
				<link>' . $link . '</link>
				<description>Aggrégation des flux du dossier leed ' . $_['name'] . '</description>
				<language>fr-fr</language>
				<copyright>DWTFYW</copyright>
				<pubDate>' . date('r', gmstrftime(time())) . '</pubDate>
				<lastBuildDate>' . date('r', gmstrftime(time())) . '</lastBuildDate>
				<sy:updatePeriod>hourly</sy:updatePeriod>
				<sy:updateFrequency>1</sy:updateFrequency>
				<generator>Leed (LightFeed Agregator) ' . VERSION_NAME . '</generator>';
        usort($items, 'rssmaker_plugin_compare');
        foreach ($items as $item) {
            echo '<item>
				<title><![CDATA[' . $item->get_title() . ']]></title>
				<link>' . $item->get_permalink() . '</link>
				<pubDate>' . date('r', gmstrftime(strtotime($item->get_date()))) . '</pubDate>
				<guid isPermaLink="true">' . $item->get_permalink() . '</guid>

				<description>
				<![CDATA[
				' . $item->get_description() . '
				]]>
				</description>
				<content:encoded><![CDATA[' . $item->get_content() . ']]></content:encoded>

				<dc:creator>' . ('' == $item->get_author() ? 'Anonyme' : $item->get_author()->name) . '</dc:creator>
				</item>';
        }
        echo '</channel></rss>';
    }
}
Пример #14
0
 /**
  * Find item by given itemRef
  *
  * @param Newscoop\News\ItemRef $itemRef
  * @param Newscoop\News\Feed $feed
  * @return Newscoop\News\Item
  */
 public function findByItemRef(ItemRef $itemRef, Feed $feed)
 {
     $item = $this->find($itemRef->getResidRef());
     if (!$item) {
         $item = $feed->getItem($itemRef->getResidRef());
         if ($item) {
             $item->setFeed($feed);
             $this->odm->persist($item);
             $this->odm->flush();
         }
     }
     return $item;
 }
Пример #15
0
 public function verifyCurrent()
 {
     $current = self::getProperties(true);
     $expired = array();
     $checking = new Feed();
     $checking->start('meta');
     $results = $checking->metaSearch($current);
     $results = $results->toArray();
     //Loop through results, look for unavailable
     foreach ($results as $result) {
         if ($result['Status'] !== "A") {
             $expired[] = $result['Ml_num'];
         }
     }
     return $expired;
 }
Пример #16
0
 public static function hasView($feedid, $uid)
 {
     $feed = Feed::model()->get($feedid);
     $feedUser = User::model()->fetchByUid($feed["uid"]);
     $user = User::model()->fetchByUid($uid);
     if ($feed && $feed["view"] !== WbConst::SELF_VIEW_SCOPE) {
         $fuDeptIds = StringUtil::filterStr($feedUser["alldeptid"] . "," . $feedUser["alldowndeptid"]);
         $deptIds = StringUtil::filterStr($user["alldeptid"] . "," . $user["allupdeptid"]);
         if ($feed["view"] == WbConst::ALL_VIEW_SCOPE) {
             return true;
         } elseif ($feed["view"] == WbConst::SELFDEPT_VIEW_SCOPE) {
             if (StringUtil::findIn($fuDeptIds, $deptIds)) {
                 return true;
             }
         } else {
             if (StringUtil::findIn($feed["userid"], $uid)) {
                 return true;
             }
             if (StringUtil::findIn($feed["positionid"], $user["allposid"])) {
                 return true;
             }
             if (StringUtil::findIn($fuDeptIds, $deptIds)) {
                 return true;
             }
         }
     }
     return false;
 }
 private function delete_question(FaqQuestion $question)
 {
     FaqService::delete('WHERE id=:id', array('id' => $question->get_id()));
     PersistenceContext::get_querier()->delete(DB_TABLE_EVENTS, 'WHERE module=:module AND id_in_module=:id', array('module' => 'faq', 'id' => $question->get_id()));
     Feed::clear_cache('faq');
     FaqCache::invalidate();
 }
Пример #18
0
 public function testRender()
 {
     $atom = Feed::generate();
     $this->assertStringStartsWith('<?xml ', $atom);
     $this->assertRegExp('/www\\.w3\\.org\\/2005\\/Atom/', $atom);
     $this->assertStringEndsWith('</feed>', $atom);
 }
Пример #19
0
 /**
  * 运行
  */
 function run()
 {
     $rss = \Feed::loadRss($this->rssUrl);
     $data = ['title' => $rss->title, 'description' => $rss->description, 'link' => $rss->link, 'items' => $rss->item, 'articles' => $this->parseItems($rss->item)];
     $this->dataObject = (object) $data;
     return $this;
 }
Пример #20
0
 /**
  * generate xss/atom from spreadit
  *
  * @param string $section_title
  * @return Roumen\Feed
  */
 protected function generate($section_title)
 {
     $sections = $this->section->getByTitle(Utility::splitByTitle($section_title));
     if (empty($sections)) {
         App::abort(404);
     }
     $section = $this->section->sectionFromSections($sections);
     $posts = $this->post->getHotList(F::map($sections, function ($m) {
         return $m->id;
     }), $this->vote);
     $feed = Feed::make();
     $feed->title = $section_title;
     $feed->description = "read hot posts from {$section_title}";
     $feed->link = URL::to("/s/{$section_title}");
     $feed->lang = 'en';
     $created_at_counter = 0;
     foreach ($posts as $post) {
         $feed->add($post->title, $post->username, URL::to($post->url), date(DATE_ATOM, $post->created_at), $post->markdown);
         if ($post->created_at > $created_at_counter) {
             $created_at_counter = $post->created_at;
         }
     }
     $feed->pubdate = date(DATE_ATOM, $created_at_counter);
     return $feed;
 }
Пример #21
0
 public function generateFeed()
 {
     $articles = $this->getArticles();
     $feed = Feed::make();
     // set your feed's title, description, link, pubdate and language
     $feed->title = 'cnBeta1';
     $feed->description = '一个干净、现代、开放的cnBeta';
     $feed->logo = 'http://cnbeta1.com/assets/img/cnbeta1.png';
     $feed->link = URL::to('feed');
     $feed->pubdate = $articles[0]['date'];
     $feed->lang = 'zh-cn';
     foreach ($articles as $article) {
         $articleModel = new Article($article['article_id']);
         try {
             $articleModel->load();
         } catch (Exception $ex) {
             Log::error('feed: fail to fetch article: ' . $article['article_id'] . ', error: ' . $ex->getMessage());
         }
         $content = $article['intro'];
         $content .= $articleModel->data['content'] ? $articleModel->data['content'] : '';
         // set item's title, author, url, pubdate, description and content
         $feed->add($article['title'], 'cnBeta1', URL::to($article['article_id']), $article['date'], $content, $content);
     }
     $this->data = $feed->render('atom', -1);
     $this->saveToCache();
 }
Пример #22
0
 public function __construct($config)
 {
     $config['link'] = 'http://www.instapaper.com/';
     $config['url'] = sprintf('http://www.instapaper.com/archive/rss/%s/%s', $config['userid'], $config['token']);
     parent::__construct($config);
     $this->setItemTemplate('<li><a href="{{{link}}}">{{{title}}}</a></li>' . "\n");
 }
 function postAction()
 {
     $feed = new Feed($_POST['feed_id']);
     $content_id = $_POST['content_id'];
     $action = $_POST['action'];
     if ($action == "approve") {
         if (!is_numeric($_POST['duration'])) {
             $this->flash('Please enter a valid duration', 'error');
             if ($_POST['ajax']) {
                 echo "false";
                 return;
             } else {
                 redirect_to(ADMIN_URL . '/moderate/confirm/' . $action . '?feed_id=' . $feed->id . '&content_id=' . $content_id);
             }
         }
         $duration = $_POST['duration'] * 1000;
     }
     $notification = $_POST['notification'];
     if ($feed && $action == "approve") {
         $return_code = $feed->content_mod($content_id, 1, $_SESSION['user'], $duration, $notification);
     } elseif ($feed && $action == "deny") {
         if ($_POST['information']) {
             $notification = $_POST['information'] . "  " . $notification;
         }
         $return_code = $feed->content_mod($content_id, 0, $_SESSION['user'], $duration, $notification);
     } else {
         $return_code = false;
     }
     if ($_POST['ajax']) {
         echo json_encode($return_code);
     } else {
         if ($return_code) {
             if ($action == "approve") {
                 $this->flash('Content approved successfully.');
             } else {
                 $this->flash('Content denied successfully.');
             }
         } else {
             if ($action == "approve") {
                 $this->flash('Content approval failed.', 'error');
             } else {
                 $this->flash('Content denial failed.', 'error');
             }
         }
         redirect_to(ADMIN_URL . '/moderate/feed/' . $feed->id);
     }
 }
Пример #24
0
 /**
  * @test
  *
  * @dataProvider provider_create
  *
  * @covers feed::create
  *
  * @param string  $info     info to pass
  * @param integer $items    items to add
  * @param integer $matcher  output
  */
 public function test_create($info, $items, $enviroment, $matcher_item, $matchers_image)
 {
     $this->setEnvironment($enviroment);
     $this->assertTag($matcher_item, Feed::create($info, $items), '', FALSE);
     foreach ($matchers_image as $matcher_image) {
         $this->assertTag($matcher_image, Feed::create($info, $items), '', FALSE);
     }
 }
Пример #25
0
 public function processDataItem($item)
 {
     $item = parent::processDataItem($item);
     $text = substr($item['title'], strpos($item['title'], ':') + 2);
     $user_name = substr($item['title'], 0, strpos($item['title'], ':'));
     $item['date'] = trim($item['date']);
     return $item + array('user_name' => $user_name, 'user_link' => 'http://identi.ca/' . $user_name, 'text' => $text, 'status' => $this->filterContent($text));
 }
Пример #26
0
 public function loadModel($id)
 {
     $model = Feed::model()->findByPk($id);
     if (null === $model) {
         throw new CHttpException(404, Yii::t('app', 'The requested page does not exist.'));
     }
     return $model;
 }
Пример #27
0
 /**
  * @constructor
  */
 public function __construct($config)
 {
     $config['url'] = sprintf('https://github.com/%s.atom', $config['username']);
     $config['link'] = 'https://github.com/' . $config['username'];
     $config['contenttype'] = 'application/atom+xml';
     parent::__construct($config);
     $this->setItemTemplate('<li><a href="{{{link}}}">{{{title}}}</a> ({{{date}}})</li>' . PHP_EOL);
 }
 private function delete_question()
 {
     AppContext::get_session()->csrf_post_protect();
     FaqService::delete('WHERE id=:id', array('id' => $this->faq_question->get_id()));
     PersistenceContext::get_querier()->delete(DB_TABLE_EVENTS, 'WHERE module=:module AND id_in_module=:id', array('module' => 'faq', 'id' => $this->faq_question->get_id()));
     Feed::clear_cache('faq');
     FaqCache::invalidate();
 }
Пример #29
0
 /**
  * Generate an XML files and save them to the root directory
  * @param array
  */
 protected function generateFiles($arrArchive)
 {
     $time = time();
     $strType = $arrArchive['format'] == 'atom' ? 'generateAtom' : 'generateRss';
     $strLink = $arrArchive['feedBase'] != '' ? $arrArchive['feedBase'] : $this->Environment->base;
     $strFile = $arrArchive['feedName'];
     $objFeed = new Feed($strFile);
     $objFeed->link = $strLink;
     $objFeed->title = $arrArchive['title'];
     $objFeed->description = $arrArchive['description'];
     $objFeed->language = $arrArchive['language'];
     $objFeed->published = $arrArchive['tstamp'];
     // Get items
     $objArticleStmt = $this->Database->prepare("SELECT *, (SELECT name FROM tl_user u WHERE u.id=n.author) AS authorName FROM tl_news n WHERE pid=? AND (start='' OR start<{$time}) AND (stop='' OR stop>{$time}) AND published=1 ORDER BY date DESC");
     if ($arrArchive['maxItems'] > 0) {
         $objArticleStmt->limit($arrArchive['maxItems']);
     }
     $objArticle = $objArticleStmt->execute($arrArchive['id']);
     // Get the default URL
     $objParent = $this->Database->prepare("SELECT id, alias FROM tl_page WHERE id=?")->limit(1)->execute($arrArchive['jumpTo']);
     if ($objParent->numRows < 1) {
         return;
     }
     $objParent = $this->getPageDetails($objParent->id);
     $strUrl = $this->generateFrontendUrl($objParent->row(), $GLOBALS['TL_CONFIG']['useAutoItem'] ? '/%s' : '/items/%s', $objParent->language);
     // Parse items
     while ($objArticle->next()) {
         $objItem = new FeedItem();
         $objItem->title = $objArticle->headline;
         $objItem->link = ($objArticle->source == 'external' ? '' : $strLink) . $this->getLink($objArticle, $strUrl);
         $objItem->published = $objArticle->date;
         $objItem->author = $objArticle->authorName;
         // Prepare the description
         $strDescription = $arrArchive['source'] == 'source_text' ? $objArticle->text : $objArticle->teaser;
         $strDescription = $this->replaceInsertTags($strDescription);
         $objItem->description = $this->convertRelativeUrls($strDescription, $strLink);
         // Add the article image as enclosure
         if ($objArticle->addImage) {
             $objItem->addEnclosure($objArticle->singleSRC);
         }
         // Enclosure
         if ($objArticle->addEnclosure) {
             $arrEnclosure = deserialize($objArticle->enclosure, true);
             if (is_array($arrEnclosure)) {
                 foreach ($arrEnclosure as $strEnclosure) {
                     if (is_file(TL_ROOT . '/' . $strEnclosure)) {
                         $objItem->addEnclosure($strEnclosure);
                     }
                 }
             }
         }
         $objFeed->addItem($objItem);
     }
     // Create file
     $objRss = new File($strFile . '.xml');
     $objRss->write($this->replaceInsertTags($objFeed->{$strType}()));
     $objRss->close();
 }
 function showAction()
 {
     $this->group = new Group($this->args[1]);
     $this->feeds = Feed::get_all('WHERE group_id=' . $this->group->id);
     $this->screens = Screen::get_all('WHERE group_id=' . $this->group->id);
     $this->setTitle($this->group->name);
     $this->setSubject($this->group->name);
     $this->canEdit = $_SESSION['user']->can_write('group', $this->args[1]);
 }