本文整理汇总了PHP中Feed类的典型用法代码示例。如果您正苦于以下问题:PHP Feed类的具体用法?PHP Feed怎么用?PHP Feed使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Feed类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __setup_crawl__
/**
* 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: __construct
/**
* 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());
}
示例3: executeEdit
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: updateMemcache
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: testConstructor
public function testConstructor()
{
$f1 = new Feed();
$this->assertEquals(0, $f1->size());
$f1->createItem();
$this->assertEquals(1, $f1->size());
}
示例6: actionCreate
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)) . '";');
}
示例7: listnews
function listnews()
{
include "config/site.php";
require_once 'model/Feed.php';
$feed = new Feed();
$feeds = $feed->getFeeds();
require "view/admin/feednews.php";
}
示例8: isSavedFeed
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: addEntry
/**
* 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: actionFeed
/**
* 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);
}
示例11: getRequestAndAnswer
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: __construct
/**
* 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: rssmaker_plugin_action
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: findByItemRef
/**
* 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: verifyCurrent
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;
}