本文整理汇总了PHP中FeedItem类的典型用法代码示例。如果您正苦于以下问题:PHP FeedItem类的具体用法?PHP FeedItem怎么用?PHP FeedItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FeedItem类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: newFromFeedItem
/**
* Convert a FeedItem to an FeedSMItem.
* This is to make sitemap feed get along with normal MediaWiki feeds.
* @param FeedItem Original item.
* @return FeedSMItem Converted item.
*/
public static function newFromFeedItem(FeedItem $item)
{
// @todo FIXME: This is borked (esp. on history), but better than a fatal (not by much).
// maybe try and get title from url?
$title = Title::newFromText($item->getTitle());
if (!$title) {
throw new MWException('Error getting title object from string in FeedItem.');
}
$date = $item->getDate();
return new FeedSMItem($title, $date);
}
开发者ID:schwarer2006,项目名称:wikia,代码行数:17,代码来源:FeedSMItem.php
示例2: load_file
/**
* @desc Loads a feed by its url
* @param string $url the feed url
*/
public function load_file($url)
{
if (($file = @file_get_contents($url)) !== false) {
$this->data = new FeedData();
if (preg_match('`<entry>(.*)</entry>`is', $file)) {
$expParsed = explode('<entry>', $file);
$nbItems = count($expParsed) - 1 > $nbItems ? $nbItems : count($expParsed) - 1;
$this->data->set_date(preg_match('`<updated>(.*)</updated>`is', $expParsed[0], $var) ? $var[1] : '');
$this->data->set_title(preg_match('`<title>(.*)</title>`is', $expParsed[0], $var) ? $var[1] : '');
$this->data->set_link(preg_match('`<link href="(.*)"/>`is', $expParsed[0], $var) ? $var[1] : '');
$this->data->set_host(preg_match('`<link href="(.*)"/>`is', $expParsed[0], $var) ? $var[1] : '');
for ($i = 1; $i <= $nbItems; $i++) {
$item = new FeedItem();
$item->set_title(preg_match('`<title>(.*)</title>`is', $expParsed[$i], $title) ? $title[1] : '');
$item->set_link(preg_match('`<link href="(.*)"/>`is', $expParsed[$i], $url) ? $url[1] : '');
$item->set_guid(preg_match('`<id>(.*)</id>`is', $expParsed[$i], $guid) ? $guid[1] : '');
$item->set_desc(preg_match('`<summary>(.*)</summary>`is', $expParsed[$i], $desc) ? $desc[1] : '');
$item->set_date(preg_match('`<updated>(.*)</updated>`is', $expParsed[$i], $date) ? new Date(strtotime($date[1]), Timezone::SERVER_TIMEZONE) : null);
$enclosure = preg_match('`<enclosure rel="enclosure" url="(.*)" length="(.*)" type="(.*)" />`is', $expParsed[$i]);
if ($enclosure) {
$enclosure_item = new FeedItemEnclosure();
$enclosure_item->set_lenght($enclosure[2]);
$enclosure_item->set_type($enclosure[3]);
$enclosure_item->set_url($enclosure[1]);
$item->set_enclosure($enclosure_item);
}
$this->data->add_item($item);
}
return true;
}
return false;
}
return false;
}
开发者ID:AroundPBT,项目名称:PHPBoost,代码行数:38,代码来源:ATOM.class.php
示例3: get_feed_data_struct
function get_feed_data_struct($idcat = 0, $name = '')
{
global $Cache, $Sql, $LANG, $CONFIG, $CONFIG_NEWS;
import('content/syndication/feed_data');
import('util/date');
import('util/url');
load_module_lang('news');
$data = new FeedData();
$data->set_title($LANG['xml_news_desc'] . ' ' . $CONFIG['server_name']);
$data->set_date(new Date());
$data->set_link(new Url('/syndication.php?m=news&cat=' . $idcat));
$data->set_host(HOST);
$data->set_desc($LANG['xml_news_desc'] . ' ' . $CONFIG['server_name']);
$data->set_lang($LANG['xml_lang']);
$Cache->load('news');
$result = $Sql->query_while("SELECT id, title, contents, timestamp, img\n FROM " . PREFIX . "news\n WHERE visible = 1\n ORDER BY timestamp DESC" . $Sql->limit(0, 2 * $CONFIG_NEWS['pagination_news']), __LINE__, __FILE__);
while ($row = $Sql->fetch_assoc($result)) {
$item = new FeedItem();
$item->set_title($row['title']);
$link = new Url('/news/news' . url('.php?id=' . $row['id'], '-0-' . $row['id'] . '+' . url_encode_rewrite($row['title']) . '.php'));
$item->set_link($link);
$item->set_guid($link);
$item->set_desc(second_parse($row['contents']));
$item->set_date(new Date(DATE_TIMESTAMP, TIMEZONE_SYSTEM, $row['timestamp']));
$item->set_image_url($row['img']);
$data->add_item($item);
}
$Sql->query_close($result);
return $data;
}
开发者ID:janus57,项目名称:PHPBoost_v3c,代码行数:30,代码来源:news_interface.class.php
示例4: get_feed_data_struct
function get_feed_data_struct($idcat = 0, $name = '')
{
if (MediaService::get_categories_manager()->get_categories_cache()->category_exists($idcat)) {
require_once PATH_TO_ROOT . '/media/media_constant.php';
$category = MediaService::get_categories_manager()->get_categories_cache()->get_category($idcat);
$site_name = GeneralConfig::load()->get_site_name();
$site_name = $idcat != Category::ROOT_CATEGORY ? $site_name . ' : ' . $category->get_name() : $site_name;
$feed_module_name = LangLoader::get_message('module_title', 'common', 'media');
$data = new FeedData();
$data->set_title($feed_module_name . ' - ' . $site_name);
$data->set_date(new Date());
$data->set_link(SyndicationUrlBuilder::rss('media', $idcat));
$data->set_host(HOST);
$data->set_desc($feed_module_name . ' - ' . $site_name);
$data->set_lang(LangLoader::get_message('xml_lang', 'main'));
$data->set_auth_bit(Category::READ_AUTHORIZATIONS);
$categories = MediaService::get_categories_manager()->get_childrens($idcat, new SearchCategoryChildrensOptions(), true);
$ids_categories = array_keys($categories);
$results = PersistenceContext::get_querier()->select('SELECT media.*, cat.image
FROM ' . MediaSetup::$media_table . ' media
LEFT JOIN ' . MediaSetup::$media_cats_table . ' cat ON cat.id = media.idcat
WHERE media.idcat IN :ids_categories
AND infos = :status_approved
ORDER BY timestamp DESC', array('ids_categories' => $ids_categories, 'status_approved' => MEDIA_STATUS_APROBED));
foreach ($results as $row) {
// Rewriting
$link = new Url('/media/media' . url('.php?id=' . $row['id'], '-' . $row['id'] . '+' . Url::encode_rewrite($row['name']) . '.php'));
$item = new FeedItem();
$item->set_title($row['name']);
$item->set_link($link);
$item->set_guid($link);
$item->set_desc(FormatingHelper::second_parse($row['contents']));
$item->set_date(new Date($row['timestamp'], Timezone::SERVER_TIMEZONE));
$item->set_image_url($row['image']);
$item->set_auth(MediaService::get_categories_manager()->get_heritated_authorizations($row['idcat'], Category::READ_AUTHORIZATIONS, Authorizations::AUTH_PARENT_PRIORITY));
$enclosure = new FeedItemEnclosure();
$enclosure->set_lenght(@filesize($row['url']));
$enclosure->set_type($row['mime_type']);
$enclosure->set_url($row['url']);
$item->set_enclosure($enclosure);
$data->add_item($item);
}
$results->dispose();
return $data;
}
}
开发者ID:AroundPBT,项目名称:PHPBoost,代码行数:46,代码来源:MediaFeedProvider.class.php
示例5: load_file
function load_file($url)
{
if (($file = @file_get_contents_emulate($url)) !== false) {
$this->data = new FeedData();
if (preg_match('`<item>(.*)</item>`is', $file)) {
$expParsed = explode('<item>', $file);
$nbItems = count($expParsed) - 1 > $nbItems ? $nbItems : count($expParsed) - 1;
$this->data->set_date(preg_match('`<!-- RSS generated by PHPBoost on (.*) -->`is', $expParsed[0], $var) ? $var[1] : '');
$this->data->set_title(preg_match('`<title>(.*)</title>`is', $expParsed[0], $var) ? $var[1] : '');
$this->data->set_link(preg_match('`<atom:link href="(.*)" rel="self" type="application/rss+xml" />`is', $expParsed[0], $var) ? $var[1] : '');
$this->data->set_host(preg_match('`<link>(.*)</link>`is', $expParsed[0], $var) ? $var[1] : '');
$this->data->set_desc(preg_match('`<description>(.*)</description>`is', $expParsed[0], $var) ? $var[1] : '');
$this->data->set_lang(preg_match('`<language>(.*)</language>`is', $expParsed[0], $var) ? $var[1] : '');
for ($i = 1; $i <= $nbItems; $i++) {
$item = new FeedItem();
$item->set_title(preg_match('`<title>(.*)</title>`is', $expParsed[$i], $title) ? $title[1] : '');
$item->set_link(preg_match('`<link>(.*)</link>`is', $expParsed[$i], $url) ? $url[1] : '');
$item->set_guid(preg_match('`<guid>(.*)</guid>`is', $expParsed[$i], $guid) ? $guid[1] : '');
$item->set_desc(preg_match('`<desc>(.*)</desc>`is', $expParsed[$i], $desc) ? $desc[1] : '');
$item->set_date_rfc822(preg_match('`<pubDate>(.*)</pubDate>`is', $expParsed[$i], $date) ? gmdate_format('date_format_tiny', strtotime($date[1])) : '');
$this->data->add_item($item);
}
return true;
}
return false;
}
return false;
}
开发者ID:janus57,项目名称:PHPBoost_v3c,代码行数:28,代码来源:rss.class.php
示例6: load_file
function load_file($url)
{
if (($file = @file_get_contents_emulate($url)) !== false) {
$this->data = new FeedData();
if (preg_match('`<entry>(.*)</entry>`is', $file)) {
$expParsed = explode('<entry>', $file);
$nbItems = count($expParsed) - 1 > $nbItems ? $nbItems : count($expParsed) - 1;
$this->data->set_date(preg_match('`<updated>(.*)</updated>`is', $expParsed[0], $var) ? $var[1] : '');
$this->data->set_title(preg_match('`<title>(.*)</title>`is', $expParsed[0], $var) ? $var[1] : '');
$this->data->set_link(preg_match('`<link href="(.*)"/>`is', $expParsed[0], $var) ? $var[1] : '');
$this->data->set_host(preg_match('`<link href="(.*)"/>`is', $expParsed[0], $var) ? $var[1] : '');
for ($i = 1; $i <= $nbItems; $i++) {
$item = new FeedItem();
$item->set_title(preg_match('`<title>(.*)</title>`is', $expParsed[$i], $title) ? $title[1] : '');
$item->set_link(preg_match('`<link href="(.*)"/>`is', $expParsed[$i], $url) ? $url[1] : '');
$item->set_guid(preg_match('`<id>(.*)</id>`is', $expParsed[$i], $guid) ? $guid[1] : '');
$item->set_desc(preg_match('`<summary>(.*)</summary>`is', $expParsed[$i], $desc) ? $desc[1] : '');
$item->set_date_rfc3339(preg_match('`<updated>(.*)</updated>`is', $expParsed[$i], $date) ? gmdate_format('date_format_tiny', strtotime($date[1])) : '');
$this->data->add_item($item);
}
return true;
}
return false;
}
return false;
}
开发者ID:janus57,项目名称:PHPBoost_v3c,代码行数:26,代码来源:atom.class.php
示例7: fromDB
public static function fromDB($data)
{
if (!isset($data['entityId'])) {
throw new Exception('Cannot create an FeedItem without the required entityId property');
}
if (!isset($data['feed'])) {
throw new Exception('Cannot create an FeedItem without the required feed property');
}
if (!isset($data['metadata'])) {
throw new Exception('Cannot create an FeedItem without the required metadata property');
}
if (!isset($data['disco'])) {
throw new Exception('Cannot create an FeedItem without the required disco property');
}
$new = new FeedItem($data['entityId'], $data['feed'], $data['metadata']);
$new->setDisco($data['disco']);
$new->stored = true;
return $new;
}
开发者ID:NIIF,项目名称:DiscoJuice-Backend,代码行数:19,代码来源:FeedItem.php
示例8: get_feed_data_struct
public function get_feed_data_struct($idcat = 0, $name = '')
{
if (ArticlesService::get_categories_manager()->get_categories_cache()->category_exists($idcat)) {
$querier = PersistenceContext::get_querier();
$category = ArticlesService::get_categories_manager()->get_categories_cache()->get_category($idcat);
$site_name = GeneralConfig::load()->get_site_name();
$site_name = $idcat != Category::ROOT_CATEGORY ? $site_name . ' : ' . $category->get_name() : $site_name;
$feed_module_name = LangLoader::get_message('articles.feed_name', 'common', 'articles');
$data = new FeedData();
$data->set_title($feed_module_name . ' - ' . $site_name);
$data->set_date(new Date());
$data->set_link(SyndicationUrlBuilder::rss('articles', $idcat));
$data->set_host(HOST);
$data->set_desc($feed_module_name . ' - ' . $site_name);
$data->set_lang(LangLoader::get_message('xml_lang', 'main'));
$data->set_auth_bit(Category::READ_AUTHORIZATIONS);
$categories = ArticlesService::get_categories_manager()->get_childrens($idcat, new SearchCategoryChildrensOptions(), true);
$ids_categories = array_keys($categories);
$now = new Date();
$results = $querier->select('SELECT articles.id, articles.id_category, articles.title, articles.rewrited_title, articles.picture_url,
articles.contents, articles.description, articles.date_created, cat.rewrited_name AS rewrited_name_cat
FROM ' . ArticlesSetup::$articles_table . ' articles
LEFT JOIN ' . ArticlesSetup::$articles_cats_table . ' cat ON cat.id = articles.id_category
WHERE articles.id_category IN :cats_ids
AND (published = 1 OR (published = 2 AND publishing_start_date < :timestamp_now AND (publishing_end_date > :timestamp_now OR publishing_end_date = 0)))
ORDER BY articles.date_created DESC', array('cats_ids' => $ids_categories, 'timestamp_now' => $now->get_timestamp()));
foreach ($results as $row) {
$row['rewrited_name_cat'] = !empty($row['id_category']) ? $row['rewrited_name_cat'] : 'root';
$link = ArticlesUrlBuilder::display_article($row['id_category'], $row['rewrited_name_cat'], $row['id'], $row['rewrited_title']);
$item = new FeedItem();
$item->set_title($row['title']);
$item->set_link($link);
$item->set_guid($link);
$item->set_desc(FormatingHelper::second_parse($row['contents']));
$item->set_date(new Date($row['date_created'], Timezone::SERVER_TIMEZONE));
$item->set_image_url($row['picture_url']);
$item->set_auth(ArticlesService::get_categories_manager()->get_heritated_authorizations($row['id_category'], Category::READ_AUTHORIZATIONS, Authorizations::AUTH_PARENT_PRIORITY));
$data->add_item($item);
}
$results->dispose();
return $data;
}
}
开发者ID:AroundPBT,项目名称:PHPBoost,代码行数:43,代码来源:ArticlesFeedProvider.class.php
示例9: process
public function process()
{
$start = microtime(true);
$this->idplist = array();
$processedEntities = array();
$i = 0;
foreach ($this->metadata as $entityId => $metadataEntry) {
// if (rand(0, 2) === 2) {
// DiscoUtils::log('Skipping random entity: ' . $entityId); continue;
// }
DiscoUtils::log('Processing ' . $entityId);
$entry = new FeedItem($entityId, $this->feedId, $metadataEntry, $this->feedconfig);
$entry->process();
$data = $entry->getJSON();
// echo json_encode($data['disco'], JSON_PRETTY_PRINT) . "\n\n";
$this->idplist[] = $entry;
$processedEntities[] = $entityId;
// if ($i++ > 5) break;
}
foreach ($this->idplist as $item) {
$this->store->insertOrUpdate($item);
}
$existingEntries = $this->store->listFeedEntities($this->feedId);
$toDelete = array_diff($existingEntries, $processedEntities);
foreach ($toDelete as $td) {
DiscoUtils::log('Removing entityId ' . $td);
$this->store->remove($this->feedId, $td);
}
if (count($toDelete) === count($processedEntities)) {
throw new Exception('Will not delete all entities. We assume there is a mistake somewhere... Please fix ASAP.');
}
if (count($toDelete) === 0) {
DiscoUtils::log('All existing entities found, not removing any existing from ' . $this->feedId);
}
$end = microtime(true);
$timer = $end - $start;
$this->store->logProcess($this->feedId, $timer);
}
开发者ID:NIIF,项目名称:DiscoJuice-Backend,代码行数:38,代码来源:DiscoFeed.php
示例10: get_feed_data_struct
public function get_feed_data_struct($idcat = 0, $name = '')
{
if (CalendarService::get_categories_manager()->get_categories_cache()->category_exists($idcat)) {
$now = new Date();
$lang = LangLoader::get('common', 'calendar');
$querier = PersistenceContext::get_querier();
$category = CalendarService::get_categories_manager()->get_categories_cache()->get_category($idcat);
$site_name = GeneralConfig::load()->get_site_name();
$site_name = $idcat != Category::ROOT_CATEGORY ? $site_name . ' : ' . $category->get_name() : $site_name;
$feed_module_name = $lang['calendar.feed.name'];
$data = new FeedData();
$data->set_title($feed_module_name . ' - ' . $site_name);
$data->set_date(new Date());
$data->set_link(SyndicationUrlBuilder::rss('calendar', $idcat));
$data->set_host(HOST);
$data->set_desc($feed_module_name . ' - ' . $site_name);
$data->set_lang(LangLoader::get_message('xml_lang', 'main'));
$data->set_auth_bit(Category::READ_AUTHORIZATIONS);
$categories = CalendarService::get_categories_manager()->get_childrens($idcat, new SearchCategoryChildrensOptions(), true);
$ids_categories = array_keys($categories);
$result = $querier->select('SELECT *
FROM ' . CalendarSetup::$calendar_events_table . ' event
LEFT JOIN ' . CalendarSetup::$calendar_events_content_table . ' event_content ON event_content.id = event.content_id
LEFT JOIN ' . DB_TABLE_MEMBER . ' member ON member.user_id = event_content.author_id
LEFT JOIN ' . CalendarSetup::$calendar_cats_table . ' cat ON cat.id = event_content.id_category
WHERE approved = 1
AND id_category IN :cats_ids
ORDER BY start_date DESC', array('cats_ids' => $ids_categories));
while ($row = $result->fetch()) {
$event = new CalendarEvent();
$event->set_properties($row);
$category = $categories[$event->get_content()->get_category_id()];
$link = CalendarUrlBuilder::display_event($category->get_id(), $category->get_rewrited_name() ? $category->get_rewrited_name() : 'root', $event->get_id(), $event->get_content()->get_rewrited_title());
$item = new FeedItem();
$item->set_title($event->get_content()->get_title());
$item->set_link($link);
$item->set_guid($link);
$item->set_desc(FormatingHelper::second_parse($event->get_content()->get_contents()) . ($event->get_content()->get_location() ? '<br />' . $lang['calendar.labels.location'] . ' : ' . $event->get_content()->get_location() . '<br />' : '') . '<br />' . $lang['calendar.labels.start_date'] . ' : ' . $event->get_start_date()->format(Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE) . '<br />' . $lang['calendar.labels.end_date'] . ' : ' . $event->get_end_date()->format(Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE));
$item->set_date($event->get_start_date());
$item->set_auth(CalendarService::get_categories_manager()->get_heritated_authorizations($category->get_id(), Category::READ_AUTHORIZATIONS, Authorizations::AUTH_PARENT_PRIORITY));
$data->add_item($item);
}
$result->dispose();
return $data;
}
}
开发者ID:AroundPBT,项目名称:PHPBoost,代码行数:46,代码来源:CalendarFeedProvider.class.php
示例11: insertOrUpdate
function insertOrUpdate(FeedItem $item)
{
$existing = $this->db->idps->findOne($this->getQuery($item));
if ($existing !== null) {
$existingItem = FeedItem::fromDB($existing);
if ($existingItem->equalTo($item)) {
DiscoUtils::log('No changes in metadata ' . tc_colored('SKIP', 'cyan') . ' ' . $item->entityId);
} else {
DiscoUtils::log('Metadata is changed, storing changes ' . tc_colored('UPDATE', 'red') . ' ' . $item->entityId);
$this->update($item);
}
} else {
DiscoUtils::log('Metadata is completely new ' . tc_colored('INSERT', 'green') . ' ' . $item->entityId);
$this->insert($item);
}
}
开发者ID:NIIF,项目名称:DiscoJuice-Backend,代码行数:16,代码来源:DiscoStore.php
示例12: makeItems
public function makeItems(SimpleXMLElement $xmlFeed)
{
$result = array();
foreach ($xmlFeed->entry as $entry) {
$feedItem = FeedItem::create((string) $entry->title);
if (isset($entry->content)) {
$feedItem->setContent($this->makeFeedItemContent($entry->content));
}
if (isset($entry->summary)) {
$feedItem->setSummary($this->makeFeedItemContent($entry->summary));
}
if (isset($entry->id)) {
$feedItem->setId($entry->id);
}
$result[] = $feedItem->setPublished(Timestamp::create(strtotime((string) $entry->updated)))->setLink((string) $entry->link);
}
return $result;
}
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:18,代码来源:AtomItemWorker.class.php
示例13: get_feed_data_struct
function get_feed_data_struct($idcat = 0)
{
global $Cache, $Sql, $LANG, $MEDIA_LANG, $CONFIG, $MEDIA_CONFIG, $MEDIA_CATS;
$Cache->load('media');
load_module_lang('media');
require_once PATH_TO_ROOT . '/media/media_constant.php';
require_once PATH_TO_ROOT . '/media/media_cats.class.php';
import('content/syndication/feed_data');
import('util/date');
import('util/url');
$data = new FeedData();
$data->set_title($MEDIA_LANG['xml_media_desc']);
$data->set_date(new Date());
$data->set_link(new Url('/syndication.php?m=media&cat=' . $idcat));
$data->set_host(HOST);
$data->set_desc($MEDIA_LANG['xml_media_desc']);
$data->set_lang($LANG['xml_lang']);
$data->set_auth_bit(MEDIA_AUTH_READ);
$cats = new MediaCats();
$children_cats = array();
$cats->build_children_id_list($idcat, $children_cats, RECURSIVE_EXPLORATION, ADD_THIS_CATEGORY_IN_LIST);
$result = $Sql->query_while("SELECT id, idcat, name, contents, timestamp FROM " . PREFIX . "media WHERE infos = '" . MEDIA_STATUS_APROBED . "' AND idcat IN (" . implode($children_cats, ',') . " ) ORDER BY timestamp DESC" . $Sql->limit(0, $MEDIA_CONFIG['pagin']), __LINE__, __FILE__);
while ($row = $Sql->fetch_assoc($result)) {
$item = new FeedItem();
$link = new Url('/media/media' . url('.php?id=' . $row['id'], '-' . $row['id'] . '+' . url_encode_rewrite($row['name']) . '.php'));
$item->set_title($row['name']);
$item->set_link($link);
$item->set_guid($link);
$item->set_desc(second_parse($row['contents']));
$item->set_date(new Date(DATE_TIMESTAMP, TIMEZONE_SYSTEM, $row['timestamp']));
$item->set_image_url($MEDIA_CATS[$row['idcat']]['image']);
$item->set_auth($cats->compute_heritated_auth($row['idcat'], MEDIA_AUTH_READ, AUTH_PARENT_PRIORITY));
$data->add_item($item);
}
$Sql->query_close($result);
return $data;
}
开发者ID:janus57,项目名称:PHPBoost_v3c,代码行数:37,代码来源:media_interface.class.php
示例14: get_feed_data_struct
public function get_feed_data_struct($idcat = 0, $name = '')
{
if (FaqService::get_categories_manager()->get_categories_cache()->category_exists($idcat)) {
$querier = PersistenceContext::get_querier();
$category = FaqService::get_categories_manager()->get_categories_cache()->get_category($idcat);
$site_name = GeneralConfig::load()->get_site_name();
$site_name = $idcat != Category::ROOT_CATEGORY ? $site_name . ' : ' . $category->get_name() : $site_name;
$feed_module_name = LangLoader::get_message('module_title', 'common', 'faq');
$data = new FeedData();
$data->set_title($feed_module_name . ' - ' . $site_name);
$data->set_date(new Date());
$data->set_link(SyndicationUrlBuilder::rss('faq', $idcat));
$data->set_host(HOST);
$data->set_desc($feed_module_name . ' - ' . $site_name);
$data->set_lang(LangLoader::get_message('xml_lang', 'main'));
$data->set_auth_bit(Category::READ_AUTHORIZATIONS);
$categories = FaqService::get_categories_manager()->get_childrens($idcat, new SearchCategoryChildrensOptions(), true);
$ids_categories = array_keys($categories);
$results = $querier->select('SELECT faq.id, faq.id_category, faq.question, faq.answer, faq.creation_date, cat.rewrited_name AS rewrited_name_cat
FROM ' . FaqSetup::$faq_table . ' faq
LEFT JOIN ' . FaqSetup::$faq_cats_table . ' cat ON cat.id = faq.id_category
WHERE approved = 1
AND faq.id_category IN :ids_categories
ORDER BY faq.creation_date DESC', array('ids_categories' => $ids_categories));
foreach ($results as $row) {
$row['rewrited_name_cat'] = !empty($row['id_category']) ? $row['rewrited_name_cat'] : 'root';
$link = FaqUrlBuilder::display($row['id_category'], $row['rewrited_name_cat'], $row['id']);
$item = new FeedItem();
$item->set_title($row['question']);
$item->set_link($link);
$item->set_guid($link);
$item->set_desc(FormatingHelper::second_parse($row['answer']));
$item->set_date(new Date($row['creation_date'], Timezone::SERVER_TIMEZONE));
$item->set_auth(FaqService::get_categories_manager()->get_heritated_authorizations($row['id_category'], Category::READ_AUTHORIZATIONS, Authorizations::AUTH_PARENT_PRIORITY));
$data->add_item($item);
}
$results->dispose();
return $data;
}
}
开发者ID:AroundPBT,项目名称:PHPBoost,代码行数:40,代码来源:FaqFeedProvider.class.php
示例15: get_feed_data_struct
function get_feed_data_struct($idcat = 0, $name = '')
{
if (GalleryService::get_categories_manager()->get_categories_cache()->category_exists($idcat)) {
$category = GalleryService::get_categories_manager()->get_categories_cache()->get_category($idcat);
$config = GalleryConfig::load();
$site_name = GeneralConfig::load()->get_site_name();
$site_name = $idcat != Category::ROOT_CATEGORY ? $site_name . ' : ' . $category->get_name() : $site_name;
$feed_module_name = LangLoader::get_message('module_title', 'common', 'gallery');
$data = new FeedData();
$data->set_title($feed_module_name . ' - ' . $site_name);
$data->set_date(new Date());
$data->set_link(SyndicationUrlBuilder::rss('gallery', $idcat));
$data->set_host(HOST);
$data->set_desc($feed_module_name . ' - ' . $site_name);
$data->set_lang(LangLoader::get_message('xml_lang', 'main'));
$data->set_auth_bit(Category::READ_AUTHORIZATIONS);
$categories = GalleryService::get_categories_manager()->get_childrens($idcat, new SearchCategoryChildrensOptions(), true);
$ids_categories = array_keys($categories);
$results = PersistenceContext::get_querier()->select('SELECT *
FROM ' . GallerySetup::$gallery_table . '
WHERE idcat IN :ids_categories
ORDER BY timestamp DESC
LIMIT :pics_number_per_page', array('ids_categories' => $ids_categories, 'pics_number_per_page' => $config->get_pics_number_per_page()));
foreach ($results as $row) {
$link = TextHelper::htmlentities(GalleryUrlBuilder::get_link_item($row['idcat'], $row['id']));
$item = new FeedItem();
$item->set_title($row['name']);
$item->set_link($link);
$item->set_guid($link);
$item->set_date(new Date($row['timestamp'], Timezone::SERVER_TIMEZONE));
$item->set_image_url(Url::to_rel('/gallery/pics/' . $row['path']));
$item->set_auth(GalleryService::get_categories_manager()->get_heritated_authorizations($row['idcat'], Category::READ_AUTHORIZATIONS, Authorizations::AUTH_PARENT_PRIORITY));
$data->add_item($item);
}
$results->dispose();
return $data;
}
}
开发者ID:AroundPBT,项目名称:PHPBoost,代码行数:38,代码来源:GalleryFeedProvider.class.php
示例16: get_feed_data_struct
public function get_feed_data_struct($idcat = 0, $name = '')
{
$querier = PersistenceContext::get_querier();
global $LANG;
load_module_lang('wiki');
$categories = WikiCategoriesCache::load()->get_categories();
$config = WikiConfig::load();
$parameters = array('limit' => 20);
if ($idcat > 0 && array_key_exists($idcat, $categories)) {
$desc = sprintf($LANG['wiki_rss_cat'], stripslashes($categories[$idcat]['title']));
$where = 'AND a.id_cat = :idcat';
$parameters['idcat'] = $idcat;
} else {
$desc = sprintf($LANG['wiki_rss_last_articles'], $config->get_wiki_name() ? $config->get_wiki_name() : $LANG['wiki']);
$where = '';
}
$data = new FeedData();
$data->set_title($config->get_wiki_name() ? $config->get_wiki_name() : $LANG['wiki']);
$data->set_date(new Date());
$data->set_link(SyndicationUrlBuilder::rss('wiki', $idcat));
$data->set_host(HOST);
$data->set_desc($desc);
$data->set_lang($LANG['xml_lang']);
// Last news
$results = $querier->select('SELECT a.title, a.encoded_title, c.content, c.timestamp
FROM ' . PREFIX . 'wiki_articles a
LEFT JOIN ' . PREFIX . 'wiki_contents c ON c.id_contents = a.id_contents
WHERE a.redirect = 0 ' . $where . '
ORDER BY c.timestamp DESC LIMIT :limit OFFSET 0', $parameters);
// Generation of the feed's items
foreach ($results as $row) {
$item = new FeedItem();
$item->set_title($row['title']);
$link = new Url('/wiki/' . url('wiki.php?title=' . $row['encoded_title'], $row['encoded_title']));
$item->set_link($link);
$item->set_guid($link);
$item->set_desc(FormatingHelper::second_parse($row['content']));
$item->set_date(new Date($row['timestamp'], Timezone::SERVER_TIMEZONE));
$data->add_item($item);
}
$results->dispose();
return $data;
}
开发者ID:AroundPBT,项目名称:PHPBoost,代码行数:43,代码来源:WikiFeedProvider.class.php
示例17: load_file
/**
* @desc Loads a feed by its url
* @param string $url the feed url
*/
public function load_file($url)
{
if (($file = @file_get_contents($url)) !== false) {
$this->data = new FeedData();
if (preg_match('`<item>(.*)</item>`is', $file)) {
$expParsed = explode('<item>', $file);
$nbItems = count($expParsed) - 1 > $nbItems ? $nbItems : count($expParsed) - 1;
$this->data->set_date(preg_match('`<!-- RSS generated by PHPBoost on (.*) -->`is', $expParsed[0], $var) ? $var[1] : '');
$this->data->set_title(preg_match('`<title>(.*)</title>`is', $expParsed[0], $var) ? $var[1] : '');
$this->data->set_link(preg_match('`<atom:link href="(.*)" rel="self" type="application/rss+xml" />`is', $expParsed[0], $var) ? $var[1] : '');
$this->data->set_host(preg_match('`<link>(.*)</link>`is', $expParsed[0], $var) ? $var[1] : '');
$this->data->set_desc(preg_match('`<description>(.*)</description>`is', $expParsed[0], $var) ? $var[1] : '');
$this->data->set_lang(preg_match('`<language>(.*)</language>`is', $expParsed[0], $var) ? $var[1] : '');
for ($i = 1; $i <= $nbItems; $i++) {
$pubDate = strtotime($date[1]);
$item = new FeedItem();
$item->set_title(preg_match('`<title>(.*)</title>`is', $expParsed[$i], $title) ? $title[1] : '');
$item->set_link(preg_match('`<link>(.*)</link>`is', $expParsed[$i], $url) ? $url[1] : '');
$item->set_guid(preg_match('`<guid>(.*)</guid>`is', $expParsed[$i], $guid) ? $guid[1] : '');
$item->set_desc(preg_match('`<desc>(.*)</desc>`is', $expParsed[$i], $desc) ? $desc[1] : '');
$item->set_date(preg_match('`<pubDate>(.*)</pubDate>`is', $expParsed[$i], $date) ? new Date(strtotime($date[1]), Timezone::SERVER_TIMEZONE) : null);
$enclosure = preg_match('`<enclosure url="(.*)" length="(.*)" type="(.*)" />`is', $expParsed[$i]);
if ($enclosure) {
$enclosure_item = new FeedItemEnclosure();
$enclosure_item->set_lenght($enclosure[2]);
$enclosure_item->set_type($enclosure[3]);
$enclosure_item->set_url($enclosure[1]);
$item->set_enclosure($enclosure_item);
}
$this->data->add_item($item);
}
return true;
}
return false;
}
return false;
}
开发者ID:AroundPBT,项目名称:PHPBoost,代码行数:41,代码来源:RSS.class.php
示例18: get_feed_data_struct
public function get_feed_data_struct($idcat = 0, $name = '')
{
$config = ForumConfig::load();
$category = ForumService::get_categories_manager()->get_categories_cache()->get_category($idcat);
$data = new FeedData();
$data->set_title(LangLoader::get_message('xml_forum_desc', 'common', 'forum'));
$data->set_date(new Date());
$data->set_link(DispatchManager::get_url('/syndication', '/rss/forum/' . $idcat . '/'));
$data->set_host(HOST);
$data->set_desc(LangLoader::get_message('xml_forum_desc', 'common', 'forum'));
$data->set_lang(LangLoader::get_message('xml_lang', 'main'));
$data->set_auth_bit(Category::READ_AUTHORIZATIONS);
$categories = ForumService::get_categories_manager()->get_childrens($idcat, new SearchCategoryChildrensOptions(), true);
$ids_categories = array_keys($categories);
$results = PersistenceContext::get_querier()->select('SELECT t.id, t.idcat, t.title, t.last_timestamp, t.last_msg_id, t.display_msg, t.nbr_msg AS t_nbr_msg, msg.id mid, msg.contents
FROM ' . PREFIX . 'forum_topics t
LEFT JOIN ' . PREFIX . 'forum_msg msg ON msg.id = t.last_msg_id
WHERE t.idcat IN :ids_categories
ORDER BY t.last_timestamp DESC LIMIT :limit OFFSET 0', array('ids_categories' => $ids_categories, 'limit' => 2 * $config->get_number_messages_per_page()));
foreach ($results as $row) {
$item = new FeedItem();
//Link
$last_page = ceil($row['t_nbr_msg'] / $config->get_number_messages_per_page());
$last_page_rewrite = $last_page > 1 ? '-' . $last_page : '';
$last_page = $last_page > 1 ? 'pt=' . $last_page . '&' : '';
$link = new Url('/forum/topic' . url('.php?' . $last_page . 'id=' . $row['id'], '-' . $row['id'] . $last_page_rewrite . '+' . Url::encode_rewrite($row['title']) . '.php') . '#m' . $row['last_msg_id']);
$item->set_title(($config->is_message_before_topic_title_displayed() && !empty($row['display_msg']) ? TextHelper::html_entity_decode($config->get_message_before_topic_title(), ENT_NOQUOTES) . ' ' : '') . stripslashes($row['title']));
$item->set_link($link);
$item->set_guid($link);
$item->set_desc(FormatingHelper::second_parse($row['contents']));
$item->set_date(new Date($row['last_timestamp'], Timezone::SERVER_TIMEZONE));
$item->set_auth(ForumService::get_categories_manager()->get_heritated_authorizations($row['idcat'], Category::READ_AUTHORIZATIONS, Authorizations::AUTH_PARENT_PRIORITY));
$data->add_item($item);
}
$results->dispose();
return $data;
}
开发者ID:AroundPBT,项目名称:PHPBoost,代码行数:37,代码来源:ForumFeedProvider.class.php
示例19: get_feed_data_struct
function get_feed_data_struct($idcat = 0, $name = '')
{
global $LANG;
$querier = PersistenceContext::get_querier();
$pages_config = PagesConfig::load();
if (!defined('READ_PAGE')) {
require_once PATH_TO_ROOT . '/pages/pages_defines.php';
}
load_module_lang('pages');
$data = new FeedData();
$data->set_title($LANG['pages_rss_desc']);
$data->set_date(new Date());
$data->set_link(SyndicationUrlBuilder::rss('pages', $idcat));
$data->set_host(HOST);
$data->set_desc($LANG['pages_rss_desc']);
$data->set_lang($LANG['xml_lang']);
$data->set_auth_bit(READ_PAGE);
$where_clause = !empty($idcat) ? ' WHERE p.id_cat = :idcat' : '';
$results = $querier->select('SELECT p.
|
请发表评论