本文整理汇总了PHP中RSSFeed::addItem方法的典型用法代码示例。如果您正苦于以下问题:PHP RSSFeed::addItem方法的具体用法?PHP RSSFeed::addItem怎么用?PHP RSSFeed::addItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RSSFeed
的用法示例。
在下文中一共展示了RSSFeed::addItem方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doModel
//.........这里部分代码省略.........
break;
}
}
$p_iOrderType = $orderType;
}
}
// FILTERING USER
if ($p_sUser != '') {
$this->mSearch->fromUser($p_sUser);
}
// FILTERING IF WE ONLY WANT ITEMS WITH PICS
if ($p_bPic) {
$this->mSearch->withPicture(true);
}
//FILTERING BY RANGE PRICE
$this->mSearch->priceRange($p_sPriceMin, $p_sPriceMax);
//ORDERING THE SEARCH RESULTS
$this->mSearch->order($p_sOrder, $allowedTypesForSorting[$p_iOrderType]);
//SET PAGE
$this->mSearch->page($p_iPage, $p_iPageSize);
osc_run_hook('search_conditions', Params::getParamsAsArray());
if (!Params::existParam('sFeed')) {
// RETRIEVE ITEMS AND TOTAL
$aItems = $this->mSearch->doSearch();
$iTotalItems = $this->mSearch->count();
$iStart = $p_iPage * $p_iPageSize;
$iEnd = min(($p_iPage + 1) * $p_iPageSize, $iTotalItems);
$iNumPages = ceil($iTotalItems / $p_iPageSize);
osc_run_hook('search', $this->mSearch);
//preparing variables...
$regionName = $p_sRegion;
if (is_numeric($p_sRegion)) {
$r = Region::newInstance()->findByPrimaryKey($p_sRegion);
if ($r) {
$regionName = $r['s_name'];
}
}
$cityName = $p_sCity;
if (is_numeric($p_sCity)) {
$c = City::newInstance()->findByPrimaryKey($p_sCity);
if ($c) {
$cityName = $c['s_name'];
}
}
//$this->_exportVariableToView('non_empty_categories', $aCategories) ;
$this->_exportVariableToView('search_start', $iStart);
$this->_exportVariableToView('search_end', $iEnd);
$this->_exportVariableToView('search_category', $p_sCategory);
// hardcoded - non pattern and order by relevance
$p_sOrder = $old_order;
$this->_exportVariableToView('search_order_type', $p_iOrderType);
$this->_exportVariableToView('search_order', $p_sOrder);
$this->_exportVariableToView('search_pattern', $p_sPattern);
$this->_exportVariableToView('search_from_user', $p_sUser);
$this->_exportVariableToView('search_total_pages', $iNumPages);
$this->_exportVariableToView('search_page', $p_iPage);
$this->_exportVariableToView('search_has_pic', $p_bPic);
$this->_exportVariableToView('search_region', $regionName);
$this->_exportVariableToView('search_city', $cityName);
$this->_exportVariableToView('search_price_min', $p_sPriceMin);
$this->_exportVariableToView('search_price_max', $p_sPriceMax);
$this->_exportVariableToView('search_total_items', $iTotalItems);
$this->_exportVariableToView('items', $aItems);
$this->_exportVariableToView('search_show_as', $p_sShowAs);
$this->_exportVariableToView('search', $this->mSearch);
// json
$json = $this->mSearch->toJson();
$this->_exportVariableToView('search_alert', base64_encode($json));
//calling the view...
$this->doView('search.php');
} else {
$this->mSearch->page(0, osc_num_rss_items());
// RETRIEVE ITEMS AND TOTAL
$iTotalItems = $this->mSearch->count();
$aItems = $this->mSearch->doSearch();
$this->_exportVariableToView('items', $aItems);
if ($p_sFeed == '' || $p_sFeed == 'rss') {
// FEED REQUESTED!
header('Content-type: text/xml; charset=utf-8');
$feed = new RSSFeed();
$feed->setTitle(__('Latest listings added') . ' - ' . osc_page_title());
$feed->setLink(osc_base_url());
$feed->setDescription(__('Latest listings added in') . ' ' . osc_page_title());
if (osc_count_items() > 0) {
while (osc_has_items()) {
if (osc_count_item_resources() > 0) {
osc_has_item_resources();
$feed->addItem(array('title' => osc_item_title(), 'link' => htmlentities(osc_item_url(), ENT_COMPAT, "UTF-8"), 'description' => osc_item_description(), 'dt_pub_date' => osc_item_pub_date(), 'image' => array('url' => htmlentities(osc_resource_thumbnail_url(), ENT_COMPAT, "UTF-8"), 'title' => osc_item_title(), 'link' => htmlentities(osc_item_url(), ENT_COMPAT, "UTF-8"))));
} else {
$feed->addItem(array('title' => osc_item_title(), 'link' => htmlentities(osc_item_url(), ENT_COMPAT, "UTF-8"), 'description' => osc_item_description(), 'dt_pub_date' => osc_item_pub_date()));
}
}
}
osc_run_hook('feed', $feed);
$feed->dumpXML();
} else {
osc_run_hook('feed_' . $p_sFeed, $aItems);
}
}
}
示例2: doModel
//.........这里部分代码省略.........
foreach ($p_sCityArea as $city_area) {
$this->mSearch->addCityArea($city_area);
}
$p_sCityArea = implode(", ", $p_sCityArea);
//FILTERING CITY
foreach ($p_sCity as $city) {
$this->mSearch->addCity($city);
}
$p_sCity = implode(", ", $p_sCity);
//FILTERING REGION
foreach ($p_sRegion as $region) {
$this->mSearch->addRegion($region);
}
$p_sRegion = implode(", ", $p_sRegion);
//FILTERING COUNTRY
foreach ($p_sCountry as $country) {
$this->mSearch->addCountry($country);
}
$p_sCountry = implode(", ", $p_sCountry);
// FILTERING PATTERN
if ($p_sPattern != '') {
$this->mSearch->addConditions(sprintf("MATCH(d.s_title, d.s_description) AGAINST('%s' IN BOOLEAN MODE)", $p_sPattern));
$osc_request['sPattern'] = $p_sPattern;
}
// FILTERING USER
if ($p_sUser != '') {
$this->mSearch->fromUser(explode(",", $p_sUser));
}
// FILTERING IF WE ONLY WANT ITEMS WITH PICS
if ($p_bPic) {
$this->mSearch->withPicture(true);
}
//FILTERING BY RANGE PRICE
$this->mSearch->priceRange($p_sPriceMin, $p_sPriceMax);
//ORDERING THE SEARCH RESULTS
$this->mSearch->order($p_sOrder, $allowedTypesForSorting[$p_iOrderType]);
//SET PAGE
$this->mSearch->page($p_iPage, $p_iPageSize);
osc_run_hook('search_conditions', Params::getParamsAsArray());
if (!Params::existParam('sFeed')) {
// RETRIEVE ITEMS AND TOTAL
$aItems = $this->mSearch->doSearch();
$iTotalItems = $this->mSearch->count();
$iStart = $p_iPage * $p_iPageSize;
$iEnd = min(($p_iPage + 1) * $p_iPageSize, $iTotalItems);
$iNumPages = ceil($iTotalItems / $p_iPageSize);
osc_run_hook('search', $this->mSearch);
//preparing variables...
//$this->_exportVariableToView('non_empty_categories', $aCategories) ;
$this->_exportVariableToView('search_start', $iStart);
$this->_exportVariableToView('search_end', $iEnd);
$this->_exportVariableToView('search_category', $p_sCategory);
$this->_exportVariableToView('search_order_type', $p_iOrderType);
$this->_exportVariableToView('search_order', $p_sOrder);
$this->_exportVariableToView('search_pattern', $p_sPattern);
$this->_exportVariableToView('search_from_user', $p_sUser);
$this->_exportVariableToView('search_total_pages', $iNumPages);
$this->_exportVariableToView('search_page', $p_iPage);
$this->_exportVariableToView('search_has_pic', $p_bPic);
$this->_exportVariableToView('search_region', $p_sRegion);
$this->_exportVariableToView('search_city', $p_sCity);
$this->_exportVariableToView('search_price_min', $p_sPriceMin);
$this->_exportVariableToView('search_price_max', $p_sPriceMax);
$this->_exportVariableToView('search_total_items', $iTotalItems);
$this->_exportVariableToView('items', $aItems);
$this->_exportVariableToView('search_show_as', $p_sShowAs);
$this->_exportVariableToView('search', $this->mSearch);
$this->_exportVariableToView('search_alert', base64_encode(serialize($this->mSearch)));
//calling the view...
$this->doView('search.php');
} else {
$this->mSearch->page(0, osc_num_rss_items());
// RETRIEVE ITEMS AND TOTAL
$iTotalItems = $this->mSearch->count();
$aItems = $this->mSearch->doSearch();
$this->_exportVariableToView('items', $aItems);
if ($p_sFeed == '' || $p_sFeed == 'rss') {
// FEED REQUESTED!
header('Content-type: text/xml; charset=utf-8');
$feed = new RSSFeed();
$feed->setTitle(__('Latest items added') . ' - ' . osc_page_title());
$feed->setLink(osc_base_url());
$feed->setDescription(__('Latest items added in') . ' ' . osc_page_title());
if (osc_count_items() > 0) {
while (osc_has_items()) {
if (osc_count_item_resources() > 0) {
osc_has_item_resources();
$feed->addItem(array('title' => osc_item_title(), 'link' => htmlentities(osc_item_url()), 'description' => osc_item_description(), 'dt_pub_date' => osc_item_pub_date(), 'image' => array('url' => htmlentities(osc_resource_thumbnail_url()), 'title' => osc_item_title(), 'link' => htmlentities(osc_item_url()))));
} else {
$feed->addItem(array('title' => osc_item_title(), 'link' => htmlentities(osc_item_url()), 'description' => osc_item_description(), 'dt_pub_date' => osc_item_pub_date()));
}
}
}
osc_run_hook('feed', $feed);
$feed->dumpXML();
} else {
osc_run_hook('feed_' . $p_sFeed, $aItems);
}
}
}
示例3: doModel
//.........这里部分代码省略.........
//FILTERING CITY
foreach ($p_sCity as $city) {
$this->mSearch->addCity($city);
}
$p_sCity = implode(", ", $p_sCity);
//FILTERING REGION
foreach ($p_sRegion as $region) {
$this->mSearch->addRegion($region);
}
$p_sRegion = implode(", ", $p_sRegion);
//FILTERING COUNTRY
foreach ($p_sCountry as $country) {
$this->mSearch->addCountry($country);
}
$p_sCountry = implode(", ", $p_sCountry);
// FILTERING PATTERN
if ($p_sPattern != '') {
$this->mSearch->addConditions(sprintf("(d.s_title LIKE '%%%s%%' OR d.s_description LIKE '%%%s%%')", $p_sPattern, $p_sPattern));
$osc_request['sPattern'] = $p_sPattern;
}
// FILTERING IF WE ONLY WANT ITEMS WITH PICS
if ($p_bPic) {
$this->mSearch->withPicture(true);
}
//FILTERING BY RANGE PRICE
$this->mSearch->priceRange($p_sPriceMin, $p_sPriceMax);
//ORDERING THE SEARCH RESULTS
$this->mSearch->order($p_sOrder, $allowedTypesForSorting[$p_iOrderType]);
//SET PAGE
$this->mSearch->page($p_iPage, $p_iPageSize);
osc_run_hook('search_conditions', Params::getParamsAsArray());
$this->mSearch->addConditions(sprintf("%st_item.e_status = 'ACTIVE' ", DB_TABLE_PREFIX));
// RETRIEVE ITEMS AND TOTAL
$iTotalItems = $this->mSearch->count();
$aItems = $this->mSearch->doSearch();
if (!Params::existParam('sFeed')) {
$iStart = $p_iPage * $p_iPageSize;
$iEnd = min(($p_iPage + 1) * $p_iPageSize, $iTotalItems);
//Static data, which is the point?
/*$aOrders = array(
__('Newly listed') => array('sOrder' => 'dt_pub_date', 'iOrderType' => 'desc')
,__('Lower price first') => array('sOrder' => 'f_price', 'iOrderType' => 'asc')
,__('Higher price first') => array('sOrder' => 'f_price', 'iOrderType' => 'desc')
);*/
$iNumPages = ceil($iTotalItems / $p_iPageSize);
//Categories for select at view "search.php"
$mCategories = new Category();
$aCategories = $mCategories->findRootCategories();
$mCategoryStats = new CategoryStats();
$aCategories = $mCategories->toTree();
foreach ($aCategories as $k => $v) {
$iCategoryNumItems = CategoryStats::newInstance()->getNumItems($v);
if ($iCategoryNumItems > 0) {
$aCategories[$k]['total'] = $iCategoryNumItems;
} else {
unset($aCategories[$k]);
}
}
osc_run_hook('search', $this->mSearch);
//preparing variables...
$this->_exportVariableToView('categories', $aCategories);
$this->_exportVariableToView('search_start', $iStart);
$this->_exportVariableToView('search_end', $iEnd);
$this->_exportVariableToView('search_category', $p_sCategory);
$this->_exportVariableToView('search_order_type', $p_iOrderType);
$this->_exportVariableToView('search_order', $p_sOrder);
$this->_exportVariableToView('search_pattern', $p_sPattern);
$this->_exportVariableToView('search_total_pages', $iNumPages);
$this->_exportVariableToView('search_page', $p_iPage);
$this->_exportVariableToView('search_has_pic', $p_bPic);
$this->_exportVariableToView('search_city', $p_sCity);
$this->_exportVariableToView('search_price_min', $p_sPriceMin);
$this->_exportVariableToView('search_price_max', $p_sPriceMax);
$this->_exportVariableToView('search_total_items', $iTotalItems);
$this->_exportVariableToView('items', $aItems);
$this->_exportVariableToView('search_show_as', $p_sShowAs);
$this->_exportVariableToView('search', $this->mSearch);
//calling the view...
$this->doView('search.php');
} else {
$this->_exportVariableToView('items', $aItems);
if ($p_sFeed == '' || $p_sFeed == 'rss') {
// FEED REQUESTED!
header('Content-type: text/xml; charset=utf-8');
$feed = new RSSFeed();
$feed->setTitle(__('Latest items added') . ' - ' . osc_page_title());
$feed->setLink(osc_base_url());
$feed->setDescription(__('Latest items added in') . ' ' . osc_page_title());
if (osc_count_items() > 0) {
while (osc_has_items()) {
$feed->addItem(array('title' => osc_item_title(), 'link' => htmlentities(osc_item_url()), 'description' => osc_item_description()));
}
}
osc_run_hook('feed', $feed);
$feed->dumpXML();
} else {
osc_run_hook('feed_' . $p_sFeed, $aItems);
}
}
}
示例4: doModel
//.........这里部分代码省略.........
$iTotalItems = null;
if ($cache) {
$aItems = $cache['aItems'];
$iTotalItems = $cache['iTotalItems'];
} else {
$aItems = $this->mSearch->doSearch();
$iTotalItems = $this->mSearch->count();
$_cache['aItems'] = $aItems;
$_cache['iTotalItems'] = $iTotalItems;
osc_cache_set($key, $_cache, OSC_CACHE_TTL);
}
$iStart = $p_iPage * $p_iPageSize;
$iEnd = min(($p_iPage + 1) * $p_iPageSize, $iTotalItems);
$iNumPages = ceil($iTotalItems / $p_iPageSize);
// works with cache enabled ?
osc_run_hook('search', $this->mSearch);
//preparing variables...
$countryName = $p_sCountry;
if (strlen($p_sCountry) == 2) {
$c = Country::newInstance()->findByCode($p_sCountry);
if ($c) {
$countryName = $c['s_name'];
}
}
$regionName = $p_sRegion;
if (is_numeric($p_sRegion)) {
$r = Region::newInstance()->findByPrimaryKey($p_sRegion);
if ($r) {
$regionName = $r['s_name'];
}
}
$cityName = $p_sCity;
if (is_numeric($p_sCity)) {
$c = City::newInstance()->findByPrimaryKey($p_sCity);
if ($c) {
$cityName = $c['s_name'];
}
}
$this->_exportVariableToView('search_start', $iStart);
$this->_exportVariableToView('search_end', $iEnd);
$this->_exportVariableToView('search_category', $p_sCategory);
// hardcoded - non pattern and order by relevance
$p_sOrder = $old_order;
$this->_exportVariableToView('search_order_type', $p_iOrderType);
$this->_exportVariableToView('search_order', $p_sOrder);
$this->_exportVariableToView('search_pattern', $p_sPattern);
$this->_exportVariableToView('search_from_user', $p_sUser);
$this->_exportVariableToView('search_total_pages', $iNumPages);
$this->_exportVariableToView('search_page', $p_iPage);
$this->_exportVariableToView('search_has_pic', $p_bPic);
$this->_exportVariableToView('search_only_premium', $p_bPremium);
$this->_exportVariableToView('search_country', $countryName);
$this->_exportVariableToView('search_region', $regionName);
$this->_exportVariableToView('search_city', $cityName);
$this->_exportVariableToView('search_price_min', $p_sPriceMin);
$this->_exportVariableToView('search_price_max', $p_sPriceMax);
$this->_exportVariableToView('search_total_items', $iTotalItems);
$this->_exportVariableToView('items', $aItems);
$this->_exportVariableToView('search_show_as', $p_sShowAs);
$this->_exportVariableToView('search', $this->mSearch);
// json
$json = $this->mSearch->toJson();
$encoded_alert = base64_encode(osc_encrypt_alert($json));
// Create the HMAC signature and convert the resulting hex hash into base64
$stringToSign = osc_get_alert_public_key() . $encoded_alert;
$signature = hex2b64(hmacsha1(osc_get_alert_private_key(), $stringToSign));
$server_signature = Session::newInstance()->_set('alert_signature', $signature);
$this->_exportVariableToView('search_alert', $encoded_alert);
// calling the view...
if (count($aItems) === 0) {
header('HTTP/1.1 404 Not Found');
}
osc_run_hook("after_search");
if (!Params::existParam('sFeed')) {
$this->doView('search.php');
} else {
if ($p_sFeed == '' || $p_sFeed == 'rss') {
// FEED REQUESTED!
header('Content-type: text/xml; charset=utf-8');
$feed = new RSSFeed();
$feed->setTitle(__('Latest listings added') . ' - ' . osc_page_title());
$feed->setLink(osc_base_url());
$feed->setDescription(__('Latest listings added in') . ' ' . osc_page_title());
if (osc_count_items() > 0) {
while (osc_has_items()) {
if (osc_count_item_resources() > 0) {
osc_has_item_resources();
$feed->addItem(array('title' => osc_item_title(), 'link' => htmlentities(osc_item_url(), ENT_COMPAT, "UTF-8"), 'description' => osc_item_description(), 'country' => osc_item_country(), 'region' => osc_item_region(), 'city' => osc_item_city(), 'city_area' => osc_item_city_area(), 'category' => osc_item_category(), 'dt_pub_date' => osc_item_pub_date(), 'image' => array('url' => htmlentities(osc_resource_thumbnail_url(), ENT_COMPAT, "UTF-8"), 'title' => osc_item_title(), 'link' => htmlentities(osc_item_url(), ENT_COMPAT, "UTF-8"))));
} else {
$feed->addItem(array('title' => osc_item_title(), 'link' => htmlentities(osc_item_url(), ENT_COMPAT, "UTF-8"), 'description' => osc_item_description(), 'country' => osc_item_country(), 'region' => osc_item_region(), 'city' => osc_item_city(), 'city_area' => osc_item_city_area(), 'category' => osc_item_category(), 'dt_pub_date' => osc_item_pub_date()));
}
}
}
osc_run_hook('feed', $feed);
$feed->dumpXML();
} else {
osc_run_hook('feed_' . $p_sFeed, $aItems);
}
}
}
示例5: RSSFeed
<?php
error_reporting(E_ALL);
require_once './defines.php';
require_once './rss.class.php';
$myfeed = new RSSFeed();
$myfeed->setChannel('RHJunior Webcomics', 'http://rhjunior.com/', 'Updates on RHJunior Webcomics');
$myfeed->addItem('TOTQ', 'http://www.rhjunior.com/totq/00534.html', htmlspecialchars('<img src="http://www.rhjunior.com/totq/Images/00538.png"/>'));
echo $myfeed->buildRSS();