本文整理汇总了PHP中Feed::getItems方法的典型用法代码示例。如果您正苦于以下问题:PHP Feed::getItems方法的具体用法?PHP Feed::getItems怎么用?PHP Feed::getItems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Feed
的用法示例。
在下文中一共展示了Feed::getItems方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render_rss_feed
/**
* Render a sepecific feed instance
*
* @param Feed $feed
* @param Smarty $smarty
* @return null
*/
function render_rss_feed($feed, $header = true)
{
if ($header) {
header('Content-Type: text/xml; charset=utf-8');
}
// if
$result = "<rss version=\"2.0\">\n<channel>\n";
$result .= '<title>' . clean($feed->getTitle()) . "</title>\n";
$result .= '<link>' . clean($feed->getLink()) . "</link>\n";
if ($description = trim($feed->getDescription())) {
$result .= '<description><![CDATA[' . clean($description) . "]]></description>\n";
}
// if
if ($language = trim($feed->getLanguage())) {
$result .= '<language>' . clean($language) . "</language>\n";
}
// if
foreach ($feed->getItems() as $item) {
$result .= "<item>\n";
$result .= '<title>' . clean($item->getTitle()) . "</title>\n";
$result .= '<link>' . clean($item->getLink()) . "</link>\n";
if ($description = trim($item->getDescription())) {
$result .= '<description><![CDATA[' . $description . "]]></description>\n";
}
// if
$author = $item->getAuthor();
if (instance_of($author, 'FeedAuthor')) {
$result .= '<author>' . clean($author->getEmail()) . ' (' . clean($author->getName()) . ")</author>\n";
}
// if
$pubdate = $item->getPublicationDate();
if (instance_of($pubdate, 'DateValue')) {
$result .= '<pubDate>' . $pubdate->toRSS() . "</pubDate>\n";
}
// if
$id = $item->getId();
if ($id) {
$result .= '<guid>' . clean($id) . "</guid>\n";
}
// if
$result .= "</item>\n";
}
// foreach
$result .= "</channel>\n</rss>";
return $result;
}
示例2: dirname
/*i*/
}
/*i*/
define('INSIGHT_IPS', '*');
/*i*/
define('INSIGHT_AUTHKEYS', '*');
/*i*/
define('INSIGHT_PATHS', dirname(__FILE__));
/*i*/
define('INSIGHT_SERVER_PATH', './index.php');
/*i*/
require_once 'FirePHP/Init.php';
/*i*/
FirePHP::plugin('firephp')->trapProblems();
/*i*/
FirePHP::plugin('firephp')->recordEnvironment(FirePHP::to('request')->console('Environment')->on('Show Environment'));
/*i*/
FirePHP::to('request')->console('Feed')->info('Startup');
// Application Code
require_once dirname(__FILE__) . '/feed.php';
$feed = new Feed('http://www.phpdeveloper.org/feed');
$items = $feed->getItems();
echo '<p><b>See:</b> <a target="_blank" href="http://www.christophdorn.com/Blog/2010/08/24/gain-insight-into-your-cache-interaction-with-firephp-companion/">http://www.christophdorn.com/Blog/2010/08/24/gain-insight-into-your-cache-interaction-with-firephp-companion/</a></p>' . "\n";
if ($feed->didLoad()) {
echo '<p><b>Loading feed from: ' . $feed->getUrl() . '</b></p>' . "\n";
}
foreach ($items as $item) {
echo '<p><a href="' . $item['link'] . '">' . $item['title'] . '</a></p>' . "\n";
}
/*i*/
FirePHP::to('request')->console('Feed')->info('Shutdown');
示例3: switch
<div class="container">
<?php
$top = false;
$middle = false;
if (isset($_GET['page'])) {
switch ($_GET['page']) {
case "news":
// Nieuwe feed
$feed = new Feed("https://news.google.com/news?cf=all&hl=nl_nl&pz=1&ned=" . $feed . "&topic=h&output=rss");
// Feed channel laten zien
$channel = $feed->getChannel();
$page = "<h2><a href='" . $channel->link . "' target='_blank'>" . $channel->title . "</a></h2>";
$page .= "<br />";
// Feed items laten zien
foreach ($feed->getItems() as $val) {
$page .= "<p>";
$page .= $val->title;
$page .= "<br />";
$page .= $val->description;
$page .= "</p>";
}
break;
case "educations":
$page = educationsPage();
break;
case "contact":
$page = contactPage();
break;
default:
$top = true;
示例4: save
public function save(Feed $feed, $folderid)
{
$title = $feed->getTitle();
$url = $feed->getUrl();
$url_hash = md5($url);
if (empty($title)) {
$l = \OC_L10N::get('news');
$title = $l->t('no title');
}
$favicon = $feed->getFavicon();
//FIXME: Detect when feed contains already a database id
$feedid = $this->findIdFromUrl($url);
if ($feedid === null) {
$query = \OCP\DB::prepare("\n\t\t\t\tINSERT INTO " . self::tableName . "(url, url_hash, title, favicon_link, folder_id, user_id, added, lastmodified)\n\t\t\t\tVALUES (?, ?, ?, ?, ?, ?, UNIX_TIMESTAMP(), UNIX_TIMESTAMP())\n\t\t\t\t");
$params = array($url, $url_hash, $title, $favicon, $folderid, $this->userid);
$query->execute($params);
$feedid = \OCP\DB::insertid(self::tableName);
} else {
//update the db. it needs to be done, since it might be the first save after a full fetch
$stmt = \OCP\DB::prepare('
UPDATE ' . self::tableName . ' SET favicon_link = ? , lastmodified = UNIX_TIMESTAMP() , folder_id = ?
WHERE id = ?
');
$params = array($favicon, $folderid, $feedid);
$stmt->execute($params);
}
$feed->setId($feedid);
$itemMapper = new ItemMapper();
$items = $feed->getItems();
if ($items !== null) {
foreach ($items as $item) {
$itemMapper->save($item, $feedid);
}
}
return $feedid;
}