本文整理汇总了PHP中Feed::getTitle方法的典型用法代码示例。如果您正苦于以下问题:PHP Feed::getTitle方法的具体用法?PHP Feed::getTitle怎么用?PHP Feed::getTitle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Feed
的用法示例。
在下文中一共展示了Feed::getTitle方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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;
}
示例3: saveFeedItem
function saveFeedItem($feedId,$feedVisibility,$item){
global $database, $db, $event;
$db->query("SELECT id FROM {$database['prefix']}DeleteHistory WHERE feed='$feedId' and permalink='{$item['permalink']}'");
if ($db->numRows() > 0)
return false;
if ($item['written']>gmmktime()+86400)
return false;
$item['title']=$db->escape($db->lessen(UTF8::correct($item['title'])));
list($useRssOut) = Settings::gets('useRssOut');
list($feedCreated,$localFilter,$localFilterType) = Feed::gets($feedId, 'created,filter,filterType');
$tagString=$db->escape($db->lessen(UTF8::correct(implode(', ',$item['tags']))));
list($globalFilter,$blackFilter,$globalFilterType,$blackFilterType) = Settings::gets('filter,blackfilter,filterType,blackfilterType');
$filter = empty($globalFilter)?$localFilter:$globalFilter;
$filterType = empty($globalFilter)?$localFilterType:$globalFilterType;
if (!Validator::is_empty($filter)) {
$filtered = true;
$allowTags = explode(',', $filter);
if($filterType == 'tag' || $filterType == 'tag+title') {
foreach ($allowTags as $ftag) {
if (Validator::enum($ftag, $tagString)) {
$filtered = false;
break;
}
}
}
if($filtered && ($filterType == 'title' || $filterType == 'tag+title')) {
foreach ($allowTags as $ftag) {
if(strpos($item['title'],$ftag)!==false) {
$filtered = false;
break;
}
}
}
if ($filtered) return false;
}
if (!Validator::is_empty($blackFilter)) {
$filtered = false;
$denyTags = explode(',', $blackFilter);
if($blackFilterType == 'tag' || $blackFilterType == 'tag+title') {
foreach ($denyTags as $ftag) {
if (Validator::enum($ftag, $tagString)) {
$filtered = true;
break;
}
}
}
if($filtered && ($filterType == 'title' || $filterType == 'tag+title')) {
foreach ($denyTags as $ftag) {
if(strpos($item['title'],$ftag)!==false) {
$filtered = true;
break;
}
}
}
if ($filtered) return false;
}
if (preg_match('/\((.[^\)]+)\)$/Ui', trim($item['author']), $_matches)) $item['author'] = $_matches[1];
$item['author']=$db->escape($db->lessen(UTF8::correct($item['author'])));
$item['permalink']=$db->escape($db->lessen(UTF8::correct($item['permalink'])));
$item['description']=$db->escape($db->lessen(UTF8::correct(trim($item['description'])),65535));
$enclosures = array();
foreach($item['enclosures'] as $en) {
array_push($enclosures, $en['url']);
}
$enclosureString=$db->escape($db->lessen(UTF8::correct(implode('|',$enclosures))));
$deadLine=0;
$feedLife = Settings::get('archivePeriod');
if ($feedLife > 0) $deadLine=gmmktime()-($feedLife*86400);
requireComponent('Bloglounge.Data.FeedItems');
$oldTags = null;
$id = FeedItem::getIdByURL($item['permalink']);
if($id === false && isset($item['guid'])) {
$item['guid']=$db->escape($db->lessen(UTF8::correct($item['guid'])));
$id = FeedItem::getIdByURL($item['guid']);
}
$item['author'] = Feed::getAuthor($item, $feedId, $id);
$item['title'] = Feed::getTitle($item, $feedId, $id);
$affected = 0;
//.........这里部分代码省略.........