本文整理汇总了PHP中UniversalFeedCreator::useCached方法的典型用法代码示例。如果您正苦于以下问题:PHP UniversalFeedCreator::useCached方法的具体用法?PHP UniversalFeedCreator::useCached怎么用?PHP UniversalFeedCreator::useCached使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UniversalFeedCreator
的用法示例。
在下文中一共展示了UniversalFeedCreator::useCached方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createXML
function createXML($title = '', $url = '', $rssurl = '', $description = '', $query = NULL)
{
require_once PATH_CORE . '/utilities/feedcreator.class.php';
$rssFeed = new UniversalFeedCreator();
$rssFeed->useCached();
// use cached version if age<1 hour
$rssFeed->title = $title;
$rssFeed->link = $url;
$rssFeed->syndicationURL = $rssFeedurl;
$rssFeed->description = $description;
$rssFeed->descriptionTruncSize = 500;
$rssFeed->descriptionHtmlSyndicated = true;
$rssFeed->language = "en-us";
$number = $this->db->countQ($query);
while ($data = $this->db->readQ($query)) {
$item = new FeedItem();
$temptitle = str_replace("\\'", "'", $data->title);
$temptitle = str_replace('\\"', '"', $temptitle);
$item->title = $temptitle;
$item->link = $this->baseUrl . '?p=read&cid=' . $data->siteContentId . '&viaRSS';
$tempdesc = str_replace("\\'", "'", $data->caption);
$tempdesc = str_replace('\\"', '"', $tempdesc);
$tempdesc = $this->utilObj->shorten($tempdesc, 500);
$item->description = $this->safexml($tempdesc);
$item->descriptionTruncSize = 500;
$item->descriptionHtmlSyndicated = true;
$item->date = $data->mydate;
$item->source = $this->baseUrl;
$rssFeed->addItem($item);
}
$temp_file = PATH_CACHE . '/rss' . rand(1, 1000) . '.tmp';
$text = $rssFeed->saveFeed("RSS2.0", $temp_file, false);
return $text;
}
示例2: index
function index()
{
global $G;
include_once CLASS_PATH . 'feedcreator.class.php';
$rss = new UniversalFeedCreator();
$rss->useCached();
$rss->title = $G['setting']['site_name'];
$rss->description = $this->setting->getValue("site_description");
$rss->link = URL;
$rss->syndicationURL = URL . "rss.php";
//announce
$announce = $this->setting->dbstuff->GetArray("SELECT * FROM {$this->setting->table_prefix}announcements ORDER BY display_order ASC,id DESC LIMIT 0,5");
if (!empty($announce)) {
foreach ($announce as $key => $val) {
$item = new FeedItem();
$item->title = $val['subject'];
$item->link = $this->url(array("module" => "announce", "id" => $val['id']));
$item->description = $val['message'];
$item->date = $val['created'];
$item->source = $this->url(array("module" => "announce", "id" => $val['id']));
$item->author = $G['setting']['company_name'];
$rss->addItem($item);
}
}
$image = new FeedImage();
$image->title = $G['setting']['site_banner_word'];
$image->url = URL . STATICURL . "images/logo.jpg";
$image->link = URL;
$image->description = $rss->description;
$rss->image = $image;
$rss->saveFeed("RSS1.0", DATA_PATH . "appcache/rss.xml");
}
示例3: index
public function index()
{
$rss = new UniversalFeedCreator();
$rss->useCached();
// use cached version if age<1 hour
$rss->title = app_conf("SHOP_TITLE") . " - " . app_conf("SHOP_SEO_TITLE");
$rss->description = app_conf("SHOP_SEO_TITLE");
//optional
$rss->descriptionTruncSize = 500;
$rss->descriptionHtmlSyndicated = true;
$rss->link = get_domain() . APP_ROOT;
$rss->syndicationURL = get_domain() . APP_ROOT;
//optional
$image->descriptionTruncSize = 500;
$image->descriptionHtmlSyndicated = true;
$domain = app_conf("PUBLIC_DOMAIN_ROOT") == '' ? get_domain() . $GLOBALS['IMG_APP_ROOT'] : app_conf("PUBLIC_DOMAIN_ROOT");
$city = get_current_deal_city();
$city_id = $city['id'];
$deal_list = get_deal_list(app_conf("DEAL_PAGE_SIZE"), 0, 0, array(DEAL_ONLINE), " buy_type <> 1 or ( is_shop = 1 and is_effect =1 and is_delete = 0 and buy_type <> 1)");
$deal_list = $deal_list['list'];
foreach ($deal_list as $data) {
$item = new FeedItem();
if ($data['uname'] != '') {
$gurl = url("shop", "goods", array("id" => $data['uname']));
} else {
$gurl = url("shop", "goods", array("id" => $data['id']));
}
$data['url'] = $gurl;
$item->title = msubstr($data['name'], 0, 30);
$item->link = get_domain() . $data['url'];
$data['description'] = str_replace($GLOBALS['IMG_APP_ROOT'] . "./public/", $domain . "/public/", $data['description']);
$data['description'] = str_replace("./public/", $domain . "/public/", $data['description']);
$data['img'] = str_replace("./public/", $domain . "/public/", $data['img']);
$item->description = "<img src='" . $data['img'] . "' /><br />" . $data['brief'] . "<br /> <a href='" . get_domain() . $data['url'] . "' target='_blank' >" . $GLOBALS['lang']['VIEW_DETAIL'] . "</a>";
//optional
$item->descriptionTruncSize = 500;
$item->descriptionHtmlSyndicated = true;
if ($data['end_time'] != 0) {
$item->date = date('r', $data['end_time']);
}
$item->source = $data['url'];
$item->author = app_conf("SHOP_TITLE");
$rss->addItem($item);
}
$rss->saveFeed($format = "RSS0.91", $filename = APP_ROOT_PATH . "public/runtime/app/tpl_caches/rss.xml");
}
示例4: indexAction
public static function indexAction()
{
$rss = new \UniversalFeedCreator();
$rss->useCached('RSS1.0', ROOT_DIR . '/runtime/rss.xml');
$rss->title = P_TITLE;
$rss->link = ENV_PREFERED_PROTOCOL . '://' . CONFIG_HOST . P_PREFIX;
$rss->syndicationURL = $rss->link . '/feed';
$posts = \BWBlog\Post::list_all([], 1, 0);
foreach ($posts as $post) {
$item = new \FeedItem();
$item->title = $post['title'];
$item->link = ENV_PREFERED_PROTOCOL . '://' . CONFIG_HOST . P_PREFIX . $post['rest_url'];
$item->description = $post['content']['html'];
$item->date = $post['time']['main'];
$rss->addItem($item);
}
echo $rss->saveFeed('RSS1.0', ROOT_DIR . '/runtime/rss.xml');
}
示例5: fab_feed
function fab_feed($type, $filename, $timeout)
{
global $sitename, $slogan, $nuke_url, $backend_image, $backend_title, $backend_width, $backend_height, $backend_language, $storyhome;
include "lib/feedcreator.class.php";
$rss = new UniversalFeedCreator();
$rss->useCached($type, $filename, $timeout);
$rss->title = $sitename;
$rss->description = $slogan;
$rss->descriptionTruncSize = 250;
$rss->descriptionHtmlSyndicated = true;
$rss->link = $nuke_url;
$rss->syndicationURL = $nuke_url . "/backend.php?op=" . $type;
$image = new FeedImage();
$image->title = $sitename;
$image->url = $backend_image;
$image->link = $nuke_url;
$image->description = $backend_title;
$image->width = $backend_width;
$image->height = $backend_height;
$rss->image = $image;
$xtab = news_aff("index", "where ihome='0' and archive='0'", $storyhome, "");
$story_limit = 0;
while ($story_limit < $storyhome and $story_limit < sizeof($xtab)) {
list($sid, $catid, $aid, $title, $time, $hometext, $bodytext, $comments, $counter, $topic, $informant, $notes) = $xtab[$story_limit];
$story_limit++;
$item = new FeedItem();
$item->title = preview_local_langue($backend_language, str_replace(""", "\"", $title));
$item->link = $nuke_url . "/article.php?sid={$sid}";
$item->description = meta_lang(preview_local_langue($backend_language, $hometext));
$item->descriptionHtmlSyndicated = true;
$item->date = convertdateTOtimestamp($time) + $gmt * 3600;
$item->source = $nuke_url;
$item->author = $aid;
$rss->addItem($item);
}
echo $rss->saveFeed($type, $filename);
}
示例6: feed
function feed($id, $showFeed)
{
global $database, $mainframe;
global $mosConfig_live_site, $mosConfig_offset, $mosConfig_absolute_path;
$params = rdRss::getParameters($id);
//print_r($params);
// set filename for live bookmarks feed
if (!$showFeed & $params->live_bookmark) {
// standard bookmark filename
$params->file = $mosConfig_absolute_path . '/cache/' . $params->live_bookmark . "_" . $id;
} else {
// set filename for rss feeds
$params->file = strtolower(str_replace('.', '', $params->feed));
$params->file = $mosConfig_absolute_path . '/cache/' . $params->file . "_" . $id . '.xml';
}
// load feed creator class
$rss = new UniversalFeedCreator();
// load image creator class
$image = new FeedImage();
// loads cache file
if ($showFeed && $params->cache) {
$rss->useCached($params->feed, $params->file, $params->cache_time);
}
$rss->title = $params->title;
$rss->description = $params->description;
$rss->link = $params->link;
$rss->syndicationURL = $params->link;
$rss->cssStyleSheet = NULL;
$rss->encoding = $params->encoding;
if ($params->image) {
$image->url = $params->image;
$image->link = $params->link;
$image->title = $params->image_alt;
$image->description = $params->description;
// loads image info into rss array
$rss->image = $image;
}
if ($id == '1') {
$fp = 1;
} else {
$fp = 0;
}
$rows = rdRss::getData($params, $fp);
if (count($rows) && $params->published) {
foreach ($rows as $row) {
// title for particular item
$item_title = htmlspecialchars($row->title);
$item_title = html_entity_decode($item_title);
// url link to article
// & used instead of & as this is converted by feed creator
$item_link = $mosConfig_live_site . '/index.php?option=com_content&task=view&id=' . $row->id . '&Itemid=' . $mainframe->getItemid($row->id);
$item_link = sefRelToAbs($item_link);
// removes all formating from the intro text for the description text
$item_description = $row->introtext;
$item_description = mosHTML::cleanText($item_description);
$item_description = html_entity_decode($item_description);
if ($params->limit_text) {
if ($params->text_length) {
// limits description text to x words
$item_description_array = split(' ', $item_description);
$count = count($item_description_array);
if ($count > $params->text_length) {
$item_description = '';
for ($a = 0; $a < $params->text_length; $a++) {
$item_description .= $item_description_array[$a] . ' ';
}
$item_description = trim($item_description);
$item_description .= '...';
}
} else {
// do not include description when text_length = 0
$item_description = NULL;
}
}
// load individual item creator class
$item = new FeedItem();
// item info
$item->title = $item_title;
$item->link = $item_link;
$item->description = $item_description;
$item->source = $params->link;
$item->date = date('r', $row->created_ts);
// loads item info into rss array
$rss->addItem($item);
}
}
//save feed file
$rss->saveFeed($params->feed, $params->file, $showFeed);
}
示例7: UniversalFeedCreator
/**
* 掲示板RSSを出力する
*
* @param $community_row 対象コミュニティ情報
* @param $bbs_row_array 掲示板親記事一覧
* @param $params パラメータ等
*/
static function print_bbs_rss($community_row, $bbs_row_array, $params)
{
// 使用クラス: acs/webapp/lib/feedcreator/feedcreator.class.php
$rss = new UniversalFeedCreator();
// 概要等 <channel>
$rss->useCached();
$rss->title = $community_row['community_name'];
// コミュニティ名
$rss->description = $community_row['community_profile']['contents_value'];
// プロフィール (公開範囲別)
$rss->link = $params['base_url'] . $community_row['top_page_url'];
// コミュニティトップページURL
$rss->url = $params['base_url'] . $community_row['image_url'];
// 画像URL <image rdf:resource="...">
$rss->syndicationURL = $rss_syndication_url;
// 自身のURL <channel rdf:about="...">
// ロゴ画像 <image>
$image = new FeedImage();
$image->title = $community_row['image_title'];
// ファイル名
$image->link = ACSMsg::get_mdmsg(__FILE__, 'M006');
// 研究室ロゴ画像
$image->url = $params['base_url'] . $community_row['image_url'];
$rss->image = $image;
// 1件のダイアリー: <item>
foreach ($bbs_row_array as $index => $bbs_row) {
// CRLF → LF
$body = preg_replace('/\\r\\n/', "\n", $bbs_row['body']);
$item = new FeedItem();
$item->post_date = $bbs_row['post_date'];
$item->title = $bbs_row['subject'];
$item->link = $params['base_url'] . $bbs_row['bbs_res_url'];
$item->description = $body;
if ($bbs_row['file_url'] != '') {
$item->image_link = $params['base_url'] . $bbs_row['file_url'];
}
$item->description2 = $body;
//第2の本文 <content:encoded>
$rss->addItem($item);
}
// http-header
mb_http_output('pass');
header('Content-type: application/xml; charset=UTF-8');
echo mb_convert_encoding($rss->createFeed("RSS1.0"), 'UTF-8', mb_internal_encoding());
}
示例8: feedFrontpage
//.........这里部分代码省略.........
}
break;
case 'atom03':
if (!$params->get('atom03', 1)) {
echo _NOT_AUTH;
return;
}
break;
case 'opml':
if (!$params->get('opml', 1)) {
echo _NOT_AUTH;
return;
}
break;
default:
echo _NOT_AUTH;
return;
break;
}
}
$filename = $info['file'] . '.xml';
// security check to stop server path disclosure
if (strstr($filename, '/')) {
echo _NOT_AUTH;
return;
}
$info['file'] = $mosConfig_cachepath . '/' . $filename;
// load feed creator class
$rss = new UniversalFeedCreator();
// load image creator class
$image = new FeedImage();
// loads cache file
if ($showFeed && $info['cache']) {
$rss->useCached($info['feed'], $info['file'], $info['cache_time']);
}
$rss->title = $info['title'];
$rss->description = $info['description'];
$rss->link = $info['link'];
$rss->syndicationURL = $info['link'];
$rss->cssStyleSheet = NULL;
$rss->encoding = $info['encoding'];
if ($info['image']) {
$image->url = $info['image'];
$image->link = $info['link'];
$image->title = $info['image_alt'];
$image->description = $info['description'];
// loads image info into rss array
$rss->image = $image;
}
// Determine ordering for sql
switch (strtolower($info['orderby'])) {
case 'date':
$orderby = 'a.created';
break;
case 'rdate':
$orderby = 'a.created DESC';
break;
case 'alpha':
$orderby = 'a.title';
break;
case 'ralpha':
$orderby = 'a.title DESC';
break;
case 'hits':
$orderby = 'a.hits DESC';
break;
示例9: UniversalFeedCreator
/**
* Show given array as RSS page
*/
function show_rss_page($data = [], $params = [])
{
require_php_lib('yf_feedcreator');
$rss = new UniversalFeedCreator();
if (!isset($params['use_cached']) || !empty($params['use_cached'])) {
$rss->useCached();
}
$rss->title = _prepare_html(!empty($params['feed_title']) ? $params['feed_title'] : 'Site feed title');
$rss->description = _prepare_html(!empty($params['feed_desc']) ? $params['feed_desc'] : 'Site feed description');
// optional feed params
$rss->descriptionTruncSize = !empty($params['feed_trunc_size']) ? intval($params['item_trunc_size']) : 500;
$rss->descriptionHtmlSyndicated = isset($params['feed_insert_html']) ? (bool) $params['feed_insert_html'] : true;
$rss->link = _prepare_html(process_url($params['feed_url'] ?: './?object=' . $_GET['object']));
$this->self_link = $rss->link;
$rss->syndicationURL = _prepare_html(process_url($params['feed_source'] ?: './?object=' . $_GET['object'] . '&action=' . $_GET['action'] . (!empty($_GET['id']) ? '&id=' . $_GET['id'] : '')));
if (!empty($this->SHOW_RSS_ENCODING)) {
$rss->encoding = $this->SHOW_RSS_ENCODING;
}
foreach ((array) $data as $A) {
$item = new FeedItem();
if (isset($A['date'])) {
$A['date'] = intval($A['date']);
}
if (isset($A['link'])) {
$A['link'] = process_url($A['link']);
}
// Process known fields
foreach ((array) $this->avail_item_fields as $field_name) {
if (isset($A[$field_name])) {
$item->{$field_name} = $A[$field_name];
}
}
if (!isset($item->guid)) {
$item->guid = $A['link'] . '#' . md5($params['feed_source'] . '&' . $A['date'] . '&' . $A['title'] . '&' . $A['author']);
}
// optional params
$item->descriptionTruncSize = !empty($params['item_trunc_size']) ? intval($params['item_trunc_size']) : $this->DESC_TRUNC_SIZE;
$item->descriptionHtmlSyndicated = isset($params['item_insert_html']) ? (bool) $params['item_insert_html'] : true;
// optional (enclosure)
// Sample: $A['enclosure'] = array('url'=>'http://lh3.ggpht.com/smoliarov/Rwygj8ucrbE/AAAAAAAABIA/UkNlwQ7eniw/_200708.jpg','length'=>'65036','type'=>'image/jpeg');
if (!empty($A['enclosure']) && is_array($A['enclosure'])) {
$E = $A['enclosure'];
$item->enclosure = new EnclosureItem();
$item->enclosure->url = _prepare_html($E['url']);
$item->enclosure->length = intval($E['length']);
$item->enclosure->type = _prepare_html($E['type']);
}
$rss->addItem($item);
}
// Set format of the resulting feed
$feed_format = isset($params['feed_format']) && in_array($params['feed_format'], $this->avail_formats) ? $params['feed_format'] : 'RSS2.0';
$feed_file_name = $params['feed_file_name'];
if (!strlen($feed_file_name)) {
$feed_file_name = md5($_SERVER['HTTP_HOST'] . '_' . $rss->title . $rss->description . $this->self_link);
}
$feed_file_name = common()->_propose_url_from_name($feed_file_name);
$feed_cache_path = $this->FEEDS_CACHE_PATH . $feed_file_name . '.xml';
$feed_cache_dir = dirname($feed_cache_path);
if (!file_exists($feed_cache_dir)) {
_mkdir_m($feed_cache_dir);
}
$feed_redirect = $params['return_feed_text'] ? false : true;
$body = $rss->saveFeed($feed_format, $feed_cache_path, $feed_redirect);
if (!empty($params['return_feed_text'])) {
if ($body) {
return $body;
} elseif (file_exists($feed_cache_path)) {
return file_get_contents($feed_cache_path);
}
} else {
main()->NO_GRAPHICS = true;
echo $body;
}
}
示例10: buildRSS
/**
* buildRSS
*
* @access protected
* @author halt <halt.hde@gmail.com>
*/
function buildRSS($r_data, $r_filepath, $r_type = "RSS1.0")
{
require_once "feedcreator.class.php";
$rss = new UniversalFeedCreator();
//$rss->encoding = 'UTF-8'; can't override FeedCreator::encoding :-<
$rss->useCached();
$rss->title = $r_data['title'];
$rss->description = $r_data['description'];
$rss->link = $r_data['link'];
//$rss->syndicationURL = "http://www.dailyphp.net/".$PHP_SELF;
if (isset($r_data['image'])) {
$image = new FeedImage();
$image->title = $r_data['image']['title'];
$image->url = $r_data['image']['url'];
$image->link = $r_data['image']['link'];
$image->description = $r_data['image']['description'];
$rss->image = $image;
}
foreach ($r_data['feeds'] as $feed) {
$item = new FeedItem();
$item->title = $feed['title'];
$item->link = $feed['link'];
$item->description = $feed['description'];
$item->date = $feed['date'];
$item->source = $feed['source'];
$item->author = $feed['author'];
$rss->addItem($item);
}
$rss->saveFeed($r_type, $r_filepath);
}
示例11: action_getfeed
/**
* createFeed
*
* URL-Parameters: ?items=15 or 30
*/
public function action_getfeed()
{
// Load Feedcreator Class
if (false === class_exists('UniversalFeedCreator', false)) {
include ROOT_LIBRARIES . 'feedcreator/feedcreator.class.php';
}
/**
* Get Number of Feed Items to create
*/
$feed_items = (int) $this->request->getParameter('items');
// Set Number of Items Range 0<15 || MAX 30
if ($feed_items == null or $feed_items < 15) {
$feed_items = self::getConfigValue('feed_items', '15');
} elseif ($feed_items > 15) {
$feed_items = 30;
}
/**
* Get Format of Feed to create
*/
// white list for valid feed format strings
$feed_format_array = array('RSS0.91', 'RSS1.0', 'RSS2.0', 'MBOX', 'OPML', 'ATOM', 'ATOM0.3', 'HTML', 'JS');
// get format from request
$feed_format = (string) $this->request->getParameter('format');
// check its a valid string or set default
if (in_array($feed_format, $feed_format_array) == false or $feed_format === null) {
$feed_format = self::getConfigValue('feed_format', 'RSS2.0');
}
/**
* Create Main Feed Object
*/
$rss = new UniversalFeedCreator();
$rss->useCached();
// use cached version if age<1 hour
$rss->title = self::getConfigValue('feed_title', 'Feedname');
$rss->description = self::getConfigValue('feed_description', 'Descriptiontext');
// optional
$rss->descriptionTruncSize = 500;
$rss->descriptionHtmlSyndicated = true;
$rss->link = "http://www.clanswebsite.net/news";
$rss->syndicationURL = "http://www.clanwebsite.net/" . $_SERVER['PHP_SELF'];
/**
* Create Feed Image Object
*/
$image = new FeedImage();
$image->title = self::getConfigValue('feed_imagetitle', 'logo');
$image->url = self::getConfigValue('feed_image', 'http://www.clanwebsite.net/images/logo.gif');
$image->link = self::getConfigValue('feed_imageurl', 'http://www.clanwebsite.net');
$image->description = self::getConfigValue('feed_imagedescription', 'Feed provided by clanwebsite.net. Click to visit.');
// optional
$image->descriptionTruncSize = 500;
$image->descriptionHtmlSyndicated = true;
// Set Feed Image Object to Main Feed Object
$rss->image = $image;
// Fetch News via Doctrine
$news_array = Doctrine::getTable('CsNews')->fetchNewsForFeed();
/**
* Loop over Dataset
*/
foreach ($news_array as $key => $news) {
/**
* Create Feed Item Object
*/
$item = new FeedItem();
$item->title = $news['news_title'];
$item->link = WWW_ROOT . 'index.php?mod=news&action=showone&id=' . $news['news_id'];
$item->description = $news['news_body'];
// optional
$item->descriptionTruncSize = 500;
$item->descriptionHtmlSyndicated = true;
$item->date = $news['created_at'];
$item->source = "http://www.clanwebsite.net";
$item->author = $news['CsUsers']['nick'];
// Set Feed Item Object to Main Feed Object
$rss->addItem($item);
}
/**
* Set Feed Format and save to file
*
* Valid $feed_format strings are:
* RSS0.91, RSS1.0, RSS2.0, PIE0.1 (deprecated), MBOX, OPML, ATOM, ATOM0.3, HTML, JS
*/
$rss->saveFeed($feed_format, ROOT_MOD . 'news/newsfeed-' . $feed_items . '.xml');
}
示例12: make_rss
/**
* Genera el RSS.XML con una clase bajada de internet,
* ya voy a mejorar eso, pero por ahora NO.
*
* @return string
*/
function make_rss()
{
global $db, $preferences;
$rss = new UniversalFeedCreator();
$rss->useCached();
// use cached version if age < 1 hour
$rss->title = preg_replace("/(\\<)(.*?)(\\>)/mi", "", $preferences['site_name']);
$rss->description = $preferences['site_description'];
$rss->link = $preferences['site_url'];
$rss->syndicationURL = $preferences['site_url'] . '/rss.xml';
list($data) = get_posts();
foreach ($data as $key => $value) {
$item = new FeedItem();
$item->title = preg_replace("/(\\<)(.*?)(\\>)/mi", "", $value['title']);
$item->link = $preferences['site_url'] . '/?id_posts=' . $value['id_posts'];
$item->description = $value['content'];
$item->date = $value['date'];
$item->source = $preferences['site_url'];
$item->author = $value['user'];
$rss->addItem($item);
}
return $rss->saveFeed("RSS1.0", "../rss.xml", false);
}
示例13: UniversalFeedCreator
}
$info['image_alt'] = $params->def('image_alt', 'Powered by Mambo 4.5.1');
$info['limit_text'] = $params->def('limit_text', 1);
$info['text_length'] = $params->def('text_length', 20);
// load feed creator class
$rss = new UniversalFeedCreator();
// load image creator class
$image = new FeedImage();
// get feedtype from url
$info['feed '] = mosGetParam($_GET, 'feed', 'RSS2.0');
// set filename for feed
$info['file '] = strtolower(str_replace('.', '', $info['feed ']));
$info['file '] = $GLOBALS['mosConfig_absolute_path'] . '/cache/' . $info['file '] . '.xml';
// loads cache file
if ($info['cache']) {
$rss->useCached($info['feed '], $info['file '], $info['cache_time']);
}
$rss->title = $info['title'];
$rss->description = $info['description'];
$rss->link = $info['link'];
$rss->syndicationURL = $info['link'];
$rss->cssStyleSheet = NULL;
$rss->encoding = split('=', _ISO);
$image->url = $info['image'];
$image->link = $info['link'];
$image->title = $info['image_alt'];
$image->description = $info['description'];
// loads image info into rss array
$rss->image = $image;
// Determine ordering for sql
switch (strtolower($info['orderby'])) {
示例14: index
public function index()
{
$rss = new UniversalFeedCreator();
$rss->useCached();
// use cached version if age<1 hour
$rss->title = app_conf("SHOP_TITLE") . " - " . app_conf("SHOP_SEO_TITLE");
$rss->description = app_conf("SHOP_SEO_TITLE");
//optional
$rss->descriptionTruncSize = 500;
$rss->descriptionHtmlSyndicated = true;
$rss->link = get_domain() . APP_ROOT;
$rss->syndicationURL = get_domain() . APP_ROOT;
//optional
$image->descriptionTruncSize = 500;
$image->descriptionHtmlSyndicated = true;
//对图片路径的修复
if ($GLOBALS['distribution_cfg']['OSS_TYPE'] && $GLOBALS['distribution_cfg']['OSS_TYPE'] != "NONE") {
$domain = $GLOBALS['distribution_cfg']['OSS_DOMAIN'];
} else {
$domain = SITE_DOMAIN . APP_ROOT;
}
$city = City::locate_city();
$city_id = $city['id'];
$tuan_list = get_deal_list(10, array(DEAL_ONLINE), array("cid" => 0, "city_id" => 0), '', " is_shop = 0 and is_effect =1 and is_delete = 0 and buy_type <> 1", " create_time desc ");
$tuan_list = $tuan_list['list'];
foreach ($tuan_list as $data) {
$item = new FeedItem();
$gurl = url("index", "deal#" . $data['id']);
$data['url'] = $gurl;
$item->title = msubstr($data['name'], 0, 30);
$item->link = get_domain() . $data['url'];
$data['description'] = str_replace($GLOBALS['IMG_APP_ROOT'] . "./public/", $domain . "/public/", $data['description']);
$data['description'] = str_replace("./public/", $domain . "/public/", $data['description']);
$data['img'] = str_replace("./public/", $domain . "/public/", $data['img']);
$item->description = "<img src='" . $data['img'] . "' /><br />" . $data['brief'] . "<br /> <a href='" . get_domain() . $data['url'] . "' target='_blank' >" . $GLOBALS['lang']['VIEW_DETAIL'] . "</a>";
//optional
$item->descriptionTruncSize = 500;
$item->descriptionHtmlSyndicated = true;
if ($data['end_time'] != 0) {
$item->date = date('r', $data['end_time']);
}
$item->source = $data['url'];
$item->author = app_conf("SHOP_TITLE");
$rss->addItem($item);
}
$deal_list = get_deal_list(10, array(DEAL_ONLINE), array("cid" => 0, "city_id" => 0), '', " is_shop = 1 and is_effect =1 and is_delete = 0 and buy_type <> 1", " create_time desc ");
$deal_list = $deal_list['list'];
foreach ($deal_list as $data) {
$item = new FeedItem();
$gurl = url("index", "deal#" . $data['id']);
$data['url'] = $gurl;
$item->title = msubstr($data['name'], 0, 30);
$item->link = get_domain() . $data['url'];
$data['description'] = str_replace($GLOBALS['IMG_APP_ROOT'] . "./public/", $domain . "/public/", $data['description']);
$data['description'] = str_replace("./public/", $domain . "/public/", $data['description']);
$data['img'] = str_replace("./public/", $domain . "/public/", $data['img']);
$item->description = "<img src='" . $data['img'] . "' /><br />" . $data['brief'] . "<br /> <a href='" . get_domain() . $data['url'] . "' target='_blank' >" . $GLOBALS['lang']['VIEW_DETAIL'] . "</a>";
//optional
$item->descriptionTruncSize = 500;
$item->descriptionHtmlSyndicated = true;
if ($data['end_time'] != 0) {
$item->date = date('r', $data['end_time']);
}
$item->source = $data['url'];
$item->author = app_conf("SHOP_TITLE");
$rss->addItem($item);
}
$youhui_list = get_youhui_list(10, array(YOUHUI_ONLINE), array("cid" => 0, "city_id" => 0), '', " is_effect =1 ", " create_time desc ");
$youhui_list = $youhui_list['list'];
foreach ($youhui_list as $data) {
$item = new FeedItem();
$gurl = url("index", "youhui#" . $data['id']);
$data['url'] = $gurl;
$item->title = msubstr($data['name'], 0, 30);
$item->link = get_domain() . $data['url'];
$data['description'] = str_replace($GLOBALS['IMG_APP_ROOT'] . "./public/", $domain . "/public/", $data['description']);
$data['description'] = str_replace("./public/", $domain . "/public/", $data['description']);
$data['img'] = str_replace("./public/", $domain . "/public/", $data['img']);
$item->description = "<img src='" . $data['img'] . "' /><br />" . $data['brief'] . "<br /> <a href='" . get_domain() . $data['url'] . "' target='_blank' >" . $GLOBALS['lang']['VIEW_DETAIL'] . "</a>";
//optional
$item->descriptionTruncSize = 500;
$item->descriptionHtmlSyndicated = true;
if ($data['end_time'] != 0) {
$item->date = date('r', $data['end_time']);
}
$item->source = $data['url'];
$item->author = app_conf("SHOP_TITLE");
$rss->addItem($item);
}
$event_list = get_event_list(10, array(EVENT_ONLINE), array("cid" => 0, "city_id" => 0), '', " is_effect =1 ", " sort asc ");
$event_list = $event_list['list'];
foreach ($event_list as $data) {
$item = new FeedItem();
$gurl = url("index", "event#" . $data['id']);
$data['url'] = $gurl;
$item->title = msubstr($data['name'], 0, 30);
$item->link = get_domain() . $data['url'];
$data['description'] = str_replace($GLOBALS['IMG_APP_ROOT'] . "./public/", $domain . "/public/", $data['description']);
$data['description'] = str_replace("./public/", $domain . "/public/", $data['description']);
$data['img'] = str_replace("./public/", $domain . "/public/", $data['img']);
//.........这里部分代码省略.........
示例15: cached_feed
function cached_feed($feed_info)
{
global $sess, $mosConfig_cachepath;
// load feed creator class
require_once $GLOBALS['mosConfig_absolute_path'] . '/includes/feedcreator.class.php';
$products = getProducts($feed_info);
if (empty($products)) {
return;
}
$mosConfig_cachepath = empty($mosConfig_cachepath) ? $GLOBALS['mosConfig_absolute_path'] . '/cache' : $mosConfig_cachepath;
$filename = $mosConfig_cachepath . "/productfeed_" . $feed_info['feed'] . "_catid{$feed_info['category_id']}.xml";
// load feed creator class
$rss = new UniversalFeedCreator();
// load image creator class
$image = new FeedImage();
// loads cache file
if ($feed_info['cache']) {
$rss->useCached($feed_info['feed'], $filename, $feed_info['cache_time']);
}
$rss->title = $feed_info['title'];
$rss->description = $feed_info['feed_description'];
$rss->link = htmlspecialchars($feed_info['link']);
$rss->cssStyleSheet = NULL;
$rss->encoding = $feed_info['encoding'];
$feed_image = $feed_info['image_file'];
if ($feed_image) {
$image->url = $feed_image;
$image->link = $rss->link;
$image->title = $feed_info['image_alt'];
$image->description = $rss->description;
// loads image info into rss array
$rss->image = $image;
}
// parameter intilization
$feed_date = date('r');
$feed_year = date('Y');
$limit = min($feed_info['product_number'], 200);
$limit_text = $feed_info['limit_desc'];
$text_length = $feed_info['text_length'];
foreach ($products as $product) {
// load individual item creator class
$item = new FeedItem();
// item info
$product_link = $sess->url($GLOBALS['mosConfig_live_site'] . '/index.php?product_id=' . $product['id'] . '&page=shop.product_details&category_id=' . $product['category_id'] . '&flypage=' . $product['category_flypage'], true);
$item->title = htmlspecialchars($product['name']);
$item->link = vmHtmlEntityDecode($product_link);
$item->source = $product_link;
$item->description = getProductDescription($product, $feed_info);
$item->date = date('r', $product['cdate']);
$item->category = htmlspecialchars($product['category_name']);
// loads item info into rss array
$rss->addItem($item);
}
while (@ob_end_clean()) {
}
// save feed file
$rss->saveFeed($feed_info['feed'], $filename);
}