本文整理汇总了PHP中RSSFeed类的典型用法代码示例。如果您正苦于以下问题:PHP RSSFeed类的具体用法?PHP RSSFeed怎么用?PHP RSSFeed使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RSSFeed类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testRSSFeed
function testRSSFeed()
{
$list = new DataObjectSet();
$list->push(new RSSFeedTest_ItemA());
$list->push(new RSSFeedTest_ItemB());
$list->push(new RSSFeedTest_ItemC());
$origServer = $_SERVER;
$_SERVER['HTTP_HOST'] = 'www.example.org';
Director::setBaseURL('/');
$rssFeed = new RSSFeed($list, "http://www.example.com", "Test RSS Feed", "Test RSS Feed Description");
$content = $rssFeed->feedContent();
//Debug::message($content);
$this->assertContains('<link>http://www.example.org/item-a/</link>', $content);
$this->assertContains('<link>http://www.example.com/item-b.html</link>', $content);
$this->assertContains('<link>http://www.example.com/item-c.html</link>', $content);
$this->assertContains('<title>ItemA</title>', $content);
$this->assertContains('<title>ItemB</title>', $content);
$this->assertContains('<title>ItemC</title>', $content);
$this->assertContains('<description>ItemA Content</description>', $content);
$this->assertContains('<description>ItemB Content</description>', $content);
$this->assertContains('<description>ItemC Content</description>', $content);
// Feed #2 - put Content() into <title> and AltContent() into <description>
$rssFeed = new RSSFeed($list, "http://www.example.com", "Test RSS Feed", "Test RSS Feed Description", "Content", "AltContent");
$content = $rssFeed->feedContent();
$this->assertContains('<title>ItemA Content</title>', $content);
$this->assertContains('<title>ItemB Content</title>', $content);
$this->assertContains('<title>ItemC Content</title>', $content);
$this->assertContains('<description>ItemA AltContent</description>', $content);
$this->assertContains('<description>ItemB AltContent</description>', $content);
$this->assertContains('<description>ItemC AltContent</description>', $content);
Director::setBaseURL(null);
$_SERVER = $origServer;
}
示例2: rss
/**
* Return an RSS feed of comments for a given set of comments or all
* comments on the website.
*
* To maintain backwards compatibility with 2.4 this supports mapping
* of PageComment/rss?pageid= as well as the new RSS format for comments
* of CommentingController/rss/{classname}/{id}
*
* @return RSS
*/
public function rss()
{
$link = $this->Link('rss');
$class = $this->urlParams['ID'];
$id = $this->urlParams['OtherID'];
if (isset($_GET['pageid'])) {
$id = Convert::raw2sql($_GET['pageid']);
$comments = Comment::get()->where(sprintf("BaseClass = 'SiteTree' AND ParentID = '%s' AND Moderated = 1 AND IsSpam = 0", $id));
$link = $this->Link('rss', 'SiteTree', $id);
} else {
if ($class && $id) {
if (Commenting::has_commenting($class)) {
$comments = Comment::get()->where(sprintf("BaseClass = '%s' AND ParentID = '%s' AND Moderated = 1 AND IsSpam = 0", Convert::raw2sql($class), Convert::raw2sql($id)));
$link = $this->Link('rss', Convert::raw2xml($class), (int) $id);
} else {
return $this->httpError(404);
}
} else {
if ($class) {
if (Commenting::has_commenting($class)) {
$comments = Comment::get()->where(sprintf("BaseClass = '%s' AND Moderated = 1 AND IsSpam = 0", Convert::raw2sql($class)));
} else {
return $this->httpError(404);
}
} else {
$comments = Comment::get();
}
}
}
$title = _t('CommentingController.RSSTITLE', "Comments RSS Feed");
$feed = new RSSFeed($comments, $link, $title, $link, 'Title', 'Comment', 'AuthorName');
$feed->outputToBrowser();
}
示例3: rss
function rss()
{
$request = Controller::curr()->getRequest();
$foundation = $request->requestVar('foundation');
$jobs = $this->repository->getDateSortedJobs($foundation);
$rss = new RSSFeed($jobs, $this->Link(), "OpenStack Jobs Feed");
$rss->outputToBrowser();
}
示例4: rss
public function rss()
{
$config = SiteConfig::current_site_config();
// Creates a new RSS Feed list
$rss = new RSSFeed($list = NewsArticle::get(), $link = $this->Link("rss"), $title = $config->Title . " News", $description = "All the latest news from " . $config->Title . ".");
// Outputs the RSS feed to the user.
return $rss->outputToBrowser();
}
示例5: testRenderWithTemplate
public function testRenderWithTemplate()
{
$rssFeed = new RSSFeed(new ArrayList(), "", "", "");
$rssFeed->setTemplate('RSSFeedTest');
$content = $rssFeed->outputToBrowser();
$this->assertContains('<title>Test Custom Template</title>', $content);
$rssFeed->setTemplate('RSSFeed');
$content = $rssFeed->outputToBrowser();
$this->assertNotContains('<title>Test Custom Template</title>', $content);
}
示例6: on_get_rss
/**
* Возвращает RSS комментариев.
* @route GET//comments.rss
*/
public static function on_get_rss(Context $ctx)
{
if (!class_exists('RSSFeed')) {
throw new PageNotFoundException(t('Модуль rss не установлен.'));
}
$filter = array('class' => 'comment', 'deleted' => 0, 'published' => 1, '#limit' => 20, '#sort' => '-id');
$title = t('Комментарии на %host', array('%host' => MCMS_HOST_NAME));
$feed = new RSSFeed($filter);
return $feed->render($ctx, array('title' => $title, 'description' => $title . '.', 'xsl' => os::path('lib', 'modules', 'comment', 'rss.xsl')));
}
示例7: tag
function tag()
{
$blogName = $this->owner->Title . " - " . ucwords($this->owner->request->latestParam('ID'));
if ($this->owner->request->param('Action') == 'tag' && $this->owner->request->param('OtherID') == "rss") {
$entries = $this->owner->Entries(20, Convert::raw2xml($this->owner->request->latestParam('ID')));
if ($entries) {
$rss = new RSSFeed($entries, $this->owner->Link('rss'), $blogName, "", "Title", "RSSContent");
return $rss->outputToBrowser();
}
} else {
return $this->owner;
}
}
示例8: on_get_custom
public static function on_get_custom(Context $ctx)
{
$filter = array();
if (!($filter['class'] = $ctx->get('type'))) {
$filter['class'] = $ctx->db->getResultsV("name", "SELECT name FROM node WHERE class = 'type' AND deleted = 0 AND published = 1");
}
if ($tmp = $ctx->get('tags')) {
$filter['tags'] = explode('+', $tmp);
}
if ($tmp = $ctx->get('author')) {
$filter['uid'] = $tmp;
}
$feed = new RSSFeed($filter);
return $feed->render($ctx);
}
示例9: init
/**
*
*/
function init()
{
RSSFeed::linkToFeed(Director::baseURL() . $this->URLSegment . "/episodesRSS");
if (Director::is_ajax()) {
$this->isAjax = true;
} else {
$this->isAjax = false;
}
parent::init();
}
示例10: init
public function init()
{
// Adds the requirements for the Podcast and Episode Page in the correct order
Requirements::javascript('framework/thirdparty/jquery/jquery.js');
Requirements::javascript('podcast/thirdparty/mediaelement/mediaelement-and-player.min.js');
Requirements::javascript('podcast/javascript/podcast-page.js');
Requirements::css('podcast/thirdparty/mediaelement/mediaelementplayer.min.css');
Requirements::css('podcast/css/podcast-page.css');
// Provides a link to the Podcast RSS in the HTML head
RSSFeed::linkToFeed($this->Link('rss'));
parent::init();
}
示例11: importString
public static function importString($string)
{
$xml = simplexml_load_string($string);
if ($xml === false) {
return;
}
if (isset($xml->channel)) {
// RSS
return RSSFeed::import($xml->channel[0]);
}
if (isset($xml->entry)) {
// Atom
return AtomFeed::import($xml);
}
}
示例12: rss
public function rss()
{
$SiteConfig = SiteConfig::current_site_config();
$rss = new RSSFeed(NewsArticle::get(), $this->Link(), $SiteConfig->Title);
return $rss->outputToBrowser();
}
示例13: OpXML
$xssDomain = $tmp[2];
$tmp = "";
//$getData = XML_unserialize($test);
//print_r($getData);
/*******************************************************
* 开始存储数据到xml文件
********************************************************/
$fpath = "../slave/slave.xml";
$slaveData = new OpXML('slaveData', $fpath);
//增加一条记录
$arr = array('requestDate' => $requestDate, 'slaveWatermark' => $slaveWatermark, 'slaveIP' => $slaveIP, 'slaveUA' => $slaveUA, 'slaveLang' => $slaveLang, 'slaveProxy' => $slaveProxy, 'slaveLocation' => $slaveLocation, 'xssGot' => $qstr);
$slaveData->insert($arr);
/*******************************************************
* 生成rss feed
********************************************************/
$myFeed = new RSSFeed();
$myFeed->addChannel("Anehta!", "http://anehta.googlecode.com", "Anehta Slave Events!", "zh-cn");
// 下面去掉$qstr 里的 "<![CDATA["和 "]]>"
$qstr = str_replace("\r\n<![CDATA[\r\n", "", $qstr);
$qstr = str_replace("\r\n]]>\r\n", "", $qstr);
/**
* Encodes HTML safely for UTF-8. Use instead of htmlentities.
*
* @param string $var
* @return string
*/
function html_encode($var)
{
return htmlentities($var, ENT_QUOTES, 'UTF-8');
}
$qstr = html_encode($qstr);
示例14: init
public function init()
{
RSSFeed::linkToFeed($this->Parent()->Link() . "rss", _t("CalendarEvent.RSSFEED", "RSS Feed of this calendar"));
parent::init();
Requirements::css('event_calendar/css/calendar.css');
Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
Requirements::javascript('event_calendar/javascript/calendar_core.js');
}
示例15: display
public function display($part = 'all')
{
switch ($part) {
case 'page-menu-only':
if (file_exists('theme/' . $this->get_config('es_theme') . '/page_menu.php')) {
$page_menu_file = 'theme/' . $this->get_config('es_theme') . '/page_menu.php';
} else {
$page_menu_file = 'includes/layout/theme//page_menu.php';
}
ob_start();
include $page_menu_file;
$page_menu = ob_get_contents();
ob_end_clean();
echo $page_menu;
break;
case 'posts-only':
echo '<div id="new-post"></div>';
$this->get_posts();
break;
case 'topbar-only':
ob_start();
include 'includes/layout/topbar.php';
$this->topbar = ob_get_contents();
ob_end_clean();
echo $this->topbar;
break;
case 'sidebar-only':
if (file_exists('theme/' . $this->get_config('es_theme') . '/sidebar.php')) {
$sidebar_file = 'theme/' . $this->get_config('es_theme') . '/sidebar.php';
} else {
$sidebar_file = 'includes/layout/theme/sidebar.php';
}
ob_start();
include $sidebar_file;
$sidebar = ob_get_contents();
ob_end_clean();
echo $sidebar;
break;
case 'first-load':
if ($this->configFileExists()) {
ob_start();
include 'includes/layout/topbar.php';
$this->topbar = ob_get_contents();
ob_end_clean();
$script_uri = 'http://' . str_replace('www.', '', $_SERVER['HTTP_HOST']) . $_SERVER['REQUEST_URI'];
if (substr($script_uri, -1) != '/') {
$script_uri .= '/';
}
$editsee_request = str_replace(str_replace('www.', '', $this->get_config('es_main_url')), '', $script_uri);
if (substr($editsee_request, 0, 5) == 'feed/') {
include "includes/RSSFeed.class.php";
header("Content-type: text/xml; charset=UTF-8");
$myfeed = new RSSFeed();
$myfeed->SetChannel($this->get_config('es_main_url'), $this->get_config('es_title'), $this->get_config('es_description'), 'en-us', date(Y) . ' ' . $_SERVER['HTTP_HOST'], 'webmaster@' . $_SERVER['HTTP_HOST'], $this->get_config('es_title'));
$myfeed->SetImage('');
$query = $this->db->_query("select id,title,urltag,content,date_entered from " . $this->db->get_table_prefix() . "post \n\t\t\t\t\t\t\t\t\t\t\t\t\twhere type='post' and deleted='0' and (date_entered <= NOW())\n\t\t\t\t\t\t\t\t\t\t\t\t\torder by date_entered desc");
while ($post = $query->_fetch_assoc()) {
$post['content'] = strip_tags($post['content'], '<br/><br>');
if (strpos($post['content'], '!--full-post--!')) {
$post['content'] = substr($post['content'], 0, strpos($post['content'], '!--full-post--!'));
$add_dots = true;
} else {
if (strlen($post['content']) > 280) {
$post['content'] = substr(substr($post['content'], 0, 280), 0, strrpos(substr($post['content'], 0, 280), ' '));
$add_dots = true;
}
}
$post['content'] = htmlentities(stripslashes($post['content']));
if ($add_dots) {
$post['content'] .= ' [...]';
}
$myfeed->SetItem($this->get_config('es_main_url') . 'post/' . $post['id'], $this->get_config('es_main_url') . 'post/' . $post['urltag'], $post['title'], $post['date_entered'], $post['content']);
}
echo $myfeed->output();
exit;
}
$editsee_index = '';
if ($editsee_request == '' || $editsee_request == $this->get_config('es_postpage') . '/' || $editsee_request == 'index.php/') {
$post_start = 0;
$page_number = 1;
if ($this->get_config('es_homepage') == '!posts!' || $editsee_request == $this->get_config('es_postpage') . '/') {
$this->is_posts = true;
} else {
$editsee_request = $this->get_config('es_homepage') . '/';
}
}
if (substr($editsee_request, 0, 5) == 'page/') {
$page_number = substr(substr($editsee_request, 5), 0, strpos(substr($editsee_request, 5), '/'));
$post_start = ($page_number - 1) * $this->get_config('es_posts_per_page');
$this->is_posts = true;
}
if ($this->is_posts) {
ob_start();
$this->get_posts($post_start);
$editsee_index .= ob_get_contents();
ob_end_clean();
} else {
$query = $this->db->_query("select id,title from " . $this->db->get_table_prefix() . "post where urltag='" . substr($editsee_request, 0, -1) . "'");
if ($query->_num_rows() == 1) {
$this->is_page = true;
//.........这里部分代码省略.........