本文整理汇总了PHP中RSS类的典型用法代码示例。如果您正苦于以下问题:PHP RSS类的具体用法?PHP RSS怎么用?PHP RSS使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RSS类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionPerform
function actionPerform(&$skin, $moduleID)
{
$query = "SELECT * FROM {$skin->main->databaseTablePrefix}module_settings WHERE setting_key='feed_URL' AND module_id={$moduleID}";
$recordSet = $skin->main->databaseConnection->Execute($query);
//Check for error, if an error occured then report that error
if (!$recordSet) {
//Assign codeBehind variables
$skin->main->controlVariables["rssFeed"]["allItems"] = array();
$skin->main->controlVariables["rssFeed"]["itemCount"] = 0;
trigger_error("Unable to get rss feed url\nreason is : " . $skin->main->databaseConnection->ErrorMsg());
} else {
$rows = $recordSet->GetRows();
if (sizeof($rows) == 1) {
$feedURL = $rows[0]['setting_value'];
$rss = new RSS(implode("", file($feedURL)));
//Assign codeBehind variables
$allItems = $rss->getAllItems();
$skin->main->controlVariables["rssFeed"]["allItems"] = $allItems;
$skin->main->controlVariables["rssFeed"]["itemCount"] = count($allItems);
} else {
//Assign codeBehind variables
$skin->main->controlVariables["rssFeed"]["allItems"] = array();
$skin->main->controlVariables["rssFeed"]["itemCount"] = 0;
}
}
}
示例2: rss
/**
* Create an RSS Feed
*
* @param string $title - feed title
* @param string $link - url feed title should point to
* @param string $description - feed description
* @param array $items - $items[0] = array('title'=>TITLE, 'link'=>URL, 'date'=>TIMESTAMP, 'description'=>DESCRIPTION)
*/
public function rss($h, $title = '', $link = '', $description = '', $items = array())
{
require_once EXTENSIONS . 'RSSWriterClass/rsswriter.php';
$feed = new RSS();
$feed->title = stripslashes(html_entity_decode(urldecode($title), ENT_QUOTES, 'UTF-8'));
$feed->link = html_entity_decode($link, ENT_QUOTES, 'UTF-8');
$feed->description = $description;
if ($items) {
foreach ($items as $item) {
$rssItem = new RSSItem();
if (isset($item['title'])) {
$rssItem->title = stripslashes(html_entity_decode(urldecode($item['title']), ENT_QUOTES, 'UTF-8'));
}
if (isset($item['link'])) {
$rssItem->link = html_entity_decode($item['link'], ENT_QUOTES, 'UTF-8');
}
if (isset($item['date'])) {
$rssItem->setPubDate($item['date']);
}
if (isset($item['description'])) {
$rssItem->description = "<![CDATA[ " . stripslashes(urldecode($item['description'])) . " ]]>";
}
if (isset($item['enclosure'])) {
$rssItem->enclosure($item['enclosure']['url'], $item['enclosure']['type'], $item['enclosure']['length']);
}
if (isset($item['author'])) {
$rssItem->addTag('author', $item['author']);
}
$feed->addItem($rssItem);
}
}
echo $feed->serve();
}
示例3: crotypedia
public function crotypedia()
{
$RSS = new RSS($this->db);
$this->f3->set('feed_url', $this->f3->get('site') . $this->f3->get('ALIASES')['rss_all']);
$this->f3->set('feed_title', 'CR');
$this->f3->set('feeds', $RSS->crotypedia());
echo Template::instance()->render('rss/feed.xml', 'application/xml');
}
示例4: listPost
/**
* 文章feed
* @param string $type 文章类型
* @internal param $null 显示数量由 feed_num决定* 显示数量由 feed_num决定
*/
public function listPost($type = 'single')
{
$PostsList = new PostsLogic();
$post_list = $PostsList->getList(get_opinion('feed_num'), $type, 'post_date desc', true);
$RSS = new RSS(get_opinion('title'), '', get_opinion('description'), '');
// 站点标题的链接
foreach ($post_list as $list) {
$RSS->addItem($list['post_title'], 'http://' . $_SERVER["SERVER_NAME"] . get_post_url($list), $list['post_content'], $list['post_date']);
}
$RSS->display();
}
示例5: listsPage
/**
* 页面feed
* @param null
* 显示数量由 feed_num决定
*/
public function listsPage()
{
$PostsList = new PostsLogic();
$post_list = $PostsList->getList(get_opinion('feed_num'), 'page', 'post_id desc', true);
$RSS = new RSS(get_opinion('title'), '', get_opinion('description'), '');
// 站点标题的链接
foreach ($post_list as $list) {
$RSS->AddItem($list['post_title'], 'http://' . $_SERVER["SERVER_NAME"] . getPageURLByID($list['post_id']), $list['post_content'], $list['post_date']);
}
$RSS->Display();
}
示例6: rss
/**
* Create an RSS Feed
*
* @param string $title - feed title
* @param string $link - url feed title should point to
* @param string $description - feed description
* @param array $items - $items[0] = array('title'=>TITLE, 'link'=>URL, 'date'=>TIMESTAMP, 'description'=>DESCRIPTION)
* @param string $content_type e.g. 'application/xml' or 'text/plain'
*/
public function rss($h, $title = '', $link = '', $description = '', $items = array(), $content_type = 'application/xml')
{
require_once EXTENSIONS . 'RSSWriterClass/rsswriter.php';
$feed = new \RSS($h->url(array('page' => 'rss')));
$feed->title = stripslashes(html_entity_decode(urldecode($title), ENT_QUOTES, 'UTF-8'));
$feed->link = html_entity_decode($link, ENT_QUOTES, 'UTF-8');
$feed->description = $description;
if ($items) {
$feed->addItem($items);
}
echo $feed->out($content_type);
}
示例7: execute
public function execute()
{
$this->output->description = "News";
$this->output->keywords = "news";
$this->output->title = "News";
$this->output->add_alternate("News", "application/rss+xml", "/news.xml");
if ($this->page->type == "xml") {
/* RSS feed
*/
$rss = new RSS($this->output);
if ($rss->fetch_from_cache("news_rss") == false) {
$rss->title = $this->settings->head_title . " news";
$rss->description = $this->settings->head_description;
if (($news = $this->model->get_news(0, $this->settings->news_rss_page_size)) != false) {
foreach ($news as $item) {
$link = "/news/" . $item["id"];
$rss->add_item($item["title"], $item["content"], $link, $item["timestamp"]);
}
}
$rss->to_output();
}
} else {
if (valid_input($this->page->pathinfo[1], VALIDATE_NUMBERS, VALIDATE_NONEMPTY)) {
/* News item
*/
if (($item = $this->model->get_news_item($this->page->pathinfo[1])) == false) {
$this->output->add_tag("result", "Unknown news item");
} else {
$this->output->title = $item["title"] . " - News";
$item["timestamp"] = date("j F Y, H:i", strtotime($item["timestamp"]));
$this->output->record($item, "news");
}
} else {
/* News overview
*/
if (($count = $this->model->count_news()) === false) {
$this->output->add_tag("result", "Database error");
return;
}
$paging = new pagination($this->output, "news", $this->settings->news_page_size, $count);
if (($news = $this->model->get_news($paging->offset, $paging->size)) === false) {
$this->output->add_tag("result", "Database error");
return;
}
foreach ($news as $item) {
$item["timestamp"] = date("j F Y, H:i", $item["timestamp"]);
$this->output->record($item, "news");
}
$paging->show_browse_links(7, 3);
}
}
}
示例8: management_addlogentry
/**
* Add an entry to the modlog
*
* @param string $entry Entry text
* @param integer $category Category to file under. 0 - No category, 1 - Login, 2 - Cleanup/rebuild boards and html files, 3 - Board adding/deleting, 4 - Board updates, 5 - Locking/stickying, 6 - Staff changes, 7 - Thread deletion/post deletion, 8 - Bans, 9 - News, 10 - Global changes, 11 - Wordfilter
* @param string $forceusername Username to force as the entry username
*/
function management_addlogentry($entry, $category = 0, $forceusername = '')
{
global $tc_db;
$username = $forceusername == '' ? $_SESSION['manageusername'] : $forceusername;
if ($entry != '') {
$tc_db->Execute("INSERT INTO `" . KU_DBPREFIX . "modlog` ( `entry` , `user` , `category` , `timestamp` ) VALUES ( " . $tc_db->qstr($entry) . " , '" . $username . "' , " . $tc_db->qstr($category) . " , '" . time() . "' )");
}
if (KU_RSS) {
require_once KU_ROOTDIR . 'inc/classes/rss.class.php';
$rss_class = new RSS();
print_page(KU_BOARDSDIR . 'modlogrss.xml', $rss_class->GenerateModLogRSS($entry), '');
}
}
示例9: getRSSFromId
function getRSSFromId($id)
{
$query = "SELECT * FROM RSS WHERE id = {$id}";
try {
$r = $this->db->query($query)->fetch();
if ($r != NULL && !empty($r)) {
$rss = new RSS($r['url']);
$rss->update();
return $rss;
}
} catch (PDOException $ex) {
die("PDO Error :" . $ex->getMessage());
}
}
示例10: updateGlobalRSS
public function updateGlobalRSS()
{
echo '[' . date('H:m:s') . "] Updating global RSS channel...\n";
$filename = PATH_PUBLIC . 'rss-global.xml';
$sites = Database::sites();
$st = array();
$cursor = Database::jobs()->find();
$cursor->sort(array('stamp' => -1));
$cursor->limit(25);
date_default_timezone_set('GMT');
// generating global rss feed
$rss = RSS::create($filename);
while ($item = $cursor->getNext()) {
if (!isset($st[$item['site']])) {
$st[$item['site']] = $sites->findOne(array('code' => $item['site']));
}
$s = $st[$item['site']];
$desc = <<<EOF
{$item['desc']}<br /><p style="padding: 0.2em; background-color: silver; border: 1px dotted black; align: center;" align="center"><a href="{$item['url']}">{$item['title']}</a></p>
EOF;
$rss->addItem($s['name'] . ': ' . $item['title'], 'http://workbreeze.com/jobs/' . $s['folder'] . '/' . $item['id'], $desc, 'http://workbreeze.com/jobs/' . $s['folder'] . '/' . $item['id'], $item['stamp']);
}
$rss->save();
// compressing for nginx static gzip
$out = system('gzip -c9 ' . escapeshellarg($filename) . ' > ' . escapeshellarg($filename . '.gz'));
}
示例11: show
function show()
{
$url = FoodleUtils::getUrl() . 'foodle/' . $this->foodle->identifier;
$responses = $this->foodle->getResponses();
$rssentries = array();
foreach ($responses as $response) {
#echo '<pre>'; print_r($response); echo '</pre>';
$newrssentry = array('title' => $response->username, 'description' => 'Response: ' . self::encodeResponse($response->response['data']), 'pubDate' => $response->created);
if (isset($entry['notes'])) {
$newrssentry['description'] .= '<br /><strong>Comment from user: </strong><i>' . $response->notes . '</i>';
}
$newrssentry['description'] .= '<br />[ <a href="' . $url . '">go to foodle</a> ]';
$rssentries[] = $newrssentry;
}
$rss = new RSS($this->foodle->name);
#$rss->description = $this->foodle->description;
$rsstext = $rss->get($rssentries);
header('Content-Type: text/xml');
echo $rsstext;
}
示例12: action_handler_dev_feed
public function action_handler_dev_feed($handler_vars)
{
$rss = Plugins::get_by_interface('RSS');
if (count($rss) !== 1) {
exit;
}
$xml = reset($rss)->create_rss_wrapper();
$connection_string = Options::get('tracfeed__connection_string');
$username = Options::get('tracfeed__username');
$password = Options::get('tracfeed__password');
$db = DatabaseConnection::ConnectionFactory($connection_string);
$db->connect($connection_string, $username, $password);
$times = $db->get_column('SELECT time from ticket_change group by time order by time desc limit 15;');
$mintime = array_reduce($times, 'min', reset($times));
$comments = $db->get_results("\n\t\t\tSELECT *, ticket_change.time as changetime from ticket_change \n\t\t\tINNER JOIN ticket on ticket.id = ticket_change.ticket\n\t\t\twhere \n\t\t\tchangetime >= ? and\n\t\t\tnot (field ='comment' and newvalue = '') \n\t\t\torder by ticket_change.time DESC;\n\t\t", array($mintime));
$posts = array();
foreach ($comments as $comment) {
$post_id = md5($comment->ticket . ':' . $comment->changetime . ':' . $comment->author);
if (!array_key_exists($post_id, $posts)) {
$post = new Post();
$post->title = "Ticket #{$comment->ticket}: {$comment->summary}";
$post->content = "Changes by {$comment->author} on ticket <a href=\"http://trac.habariproject.org/habari/ticket/{$comment->ticket}\">#{$comment->ticket}</a>.\n<br>\n<br>";
$post->guid = 'tag:' . Site::get_url('hostname') . ',trac_comment,' . $post_id;
$post->content_type = 'dev_feed';
$post->slug = "http://trac.habariproject.org/habari/ticket/{$comment->ticket}";
$post->pubdate = date('r', $comment->changetime);
$posts[$post_id] = $post;
} else {
$post = $posts[$post_id];
}
switch ($comment->field) {
case 'comment':
$content = $comment->newvalue;
$content = preg_replace('/\\b(https?|ftp|file):\\/\\/[-A-Z0-9+&@#\\/%?=~_|!:,.;]*[-A-Z0-9+&@#\\/%=~_|]/i', '<a href="$0">[link]</a>', $content);
$content = preg_replace('%\\br([0-9]+)\\b%', '<a href="http://trac.habariproject.org/habari/changeset/$1">r$1</a>', $content);
$content = preg_replace('%\\b#([0-9]+)\\b%', '<a href="http://trac.habariproject.org/habari/ticket/$1">$1</a>', $content);
$post->content .= "Comment #{$comment->oldvalue} by {$comment->author}:\n<blockquote><pre>{$content}</pre></blockquote>\n<br>";
break;
default:
if (trim($comment->oldvalue) == '') {
$post->content .= "Set <b>{$comment->field}</b> to: {$comment->newvalue}\n<br>";
} else {
$post->content .= "Changed <b>{$comment->field}</b> from: {$comment->oldvalue}\n<br> To: {$comment->newvalue}\n<br>";
}
break;
}
}
$xml = RSS::add_posts($xml, $posts);
ob_clean();
header('Content-Type: application/xml');
echo $xml->asXML();
exit;
}
示例13: execute
public function execute()
{
if ($this->page->type == "xml") {
/* RSS feed
*/
$rss = new RSS($this->output);
if ($rss->fetch_from_cache("rss_cache_id") == false) {
$rss->title = "RSS title";
$rss->description = "RSS description";
if (($items = $this->model->get_items()) != false) {
foreach ($items as $item) {
$rss->add_item($item["title"], $item["content"], $item["link"], $item["timestamp"]);
}
$rss->to_output();
}
}
} else {
/* Other page type
*/
}
}
示例14: execute
public function execute(HTTPRequestCustom $request)
{
$module_id = $request->get_getstring('module_id', '');
if (empty($module_id)) {
AppContext::get_response()->redirect(Environment::get_home_page());
}
$this->init();
$module_category_id = $request->get_getint('module_category_id', 0);
$feed_name = $request->get_getstring('feed_name', Feed::DEFAULT_FEED_NAME);
$feed = new RSS($module_id, $feed_name, $module_category_id);
if ($feed !== null && $feed->is_in_cache()) {
$this->tpl->put('SYNDICATION', $feed->read());
} else {
$eps = AppContext::get_extension_provider_service();
if ($eps->provider_exists($module_id, FeedProvider::EXTENSION_POINT)) {
$provider = $eps->get_provider($module_id);
$feeds = $provider->feeds();
$data = $feeds->get_feed_data_struct($module_category_id, $feed_name);
if ($data === null) {
AppContext::get_response()->set_header('content-type', 'text/html');
DispatchManager::redirect(PHPBoostErrors::unexisting_element());
} else {
$feed->load_data($data);
$feed->cache();
$this->tpl->put('SYNDICATION', $feed->export());
}
} else {
DispatchManager::redirect(PHPBoostErrors::module_not_installed());
}
}
return $this->build_response($this->tpl);
}
示例15: __construct
public function __construct()
{
parent::__construct("https://i-share.carli.illinois.edu/newbooks/newbooks.cgi?library=WHEdb&list=all&day=7&op=and&text=&lang=English&submit=RSS");
$nitems = count($this->xml->channel->item);
for ($i = 0; $i < $nitems; ++$i) {
$tidy_desc = \str_replace(array('<B>', '</B>', '<description>', '</description>'), '', $this->xml->channel->item[$i]->description->asXML());
$matches = array();
if (\preg_match('@<img border="0" src="(.*)" vspace="3" border="0" align="right"/>@', $tidy_desc, $matches)) {
if (\util\Utility::isValidImage($matches[1])) {
$imgurl = $matches[1];
} else {
$imgurl = "";
}
$tidy_desc = str_replace($matches[0], '', $tidy_desc);
} else {
$imgurl = "";
}
$fieldstr = \explode('<BR/>', $tidy_desc);
$this->xml->channel->item[$i]->description = \implode("\n", $fieldstr);
$fields = array();
foreach ($fieldstr as $f) {
//separate field name and field value
$matches = array();
if (\preg_match("/^([-a-zA-Z_ ]*[a-zA-Z]{4}): /", $f, $matches)) {
$fname = \strtolower(str_replace(' ', '_', \trim($matches[1])));
$fvalue = \trim(str_replace($matches[0], '', $f));
$fields[$fname] = $fvalue;
$this->xml->channel->item[$i]->addChild($fname, $fvalue);
}
}
$cn_data = \cn\processor\Factory::make($fields)->data();
foreach ($cn_data as $name => $value) {
$name = \htmlspecialchars($name);
$value = \htmlspecialchars($value);
$this->xml->channel->item[$i]->addChild($name, $value);
}
unset($this->xml->channel->item[$i]->description[0]);
if (!\util\Utility::isValidImage($imgurl)) {
$imgurl = "";
}
$this->xml->channel->item[$i]->addChild('cover', $imgurl);
}
}