本文整理汇总了PHP中get_article_enclosures函数的典型用法代码示例。如果您正苦于以下问题:PHP get_article_enclosures函数的具体用法?PHP get_article_enclosures怎么用?PHP get_article_enclosures使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_article_enclosures函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: api_get_headlines
static function api_get_headlines($feed_id, $limit, $offset, $filter, $is_cat, $show_excerpt, $show_content, $view_mode, $order, $include_attachments, $since_id, $search = "", $include_nested = false, $sanitize_content = true, $force_update = false, $excerpt_length = 100, $check_first_id = false)
{
if ($force_update && $feed_id > 0 && is_numeric($feed_id)) {
// Update the feed if required with some basic flood control
$result = db_query("SELECT cache_images," . SUBSTRING_FOR_DATE . "(last_updated,1,19) AS last_updated\n\t\t\t\t\t\tFROM ttrss_feeds WHERE id = '{$feed_id}'");
if (db_num_rows($result) != 0) {
$last_updated = strtotime(db_fetch_result($result, 0, "last_updated"));
$cache_images = sql_bool_to_bool(db_fetch_result($result, 0, "cache_images"));
if (!$cache_images && time() - $last_updated > 120) {
include "rssfuncs.php";
update_rss_feed($feed_id, true, true);
} else {
db_query("UPDATE ttrss_feeds SET last_updated = '1970-01-01', last_update_started = '1970-01-01'\n\t\t\t\t\t\t\tWHERE id = '{$feed_id}'");
}
}
}
/*$qfh_ret = queryFeedHeadlines($feed_id, $limit,
$view_mode, $is_cat, $search, false,
$order, $offset, 0, false, $since_id, $include_nested);*/
//function queryFeedHeadlines($feed, $limit,
// $view_mode, $cat_view, $search, $search_mode,
// $override_order = false, $offset = 0, $owner_uid = 0, $filter = false, $since_id = 0, $include_children = false,
// $ignore_vfeed_group = false, $override_strategy = false, $override_vfeed = false, $start_ts = false, $check_top_id = false) {
$params = array("feed" => $feed_id, "limit" => $limit, "view_mode" => $view_mode, "cat_view" => $is_cat, "search" => $search, "override_order" => $order, "offset" => $offset, "since_id" => $since_id, "include_children" => $include_nested, "check_first_id" => $check_first_id, "api_request" => true);
$qfh_ret = queryFeedHeadlines($params);
$result = $qfh_ret[0];
$feed_title = $qfh_ret[1];
$first_id = $qfh_ret[6];
$headlines = array();
$headlines_header = array('id' => $feed_id, 'first_id' => $first_id, 'is_cat' => $is_cat);
if (!is_numeric($result)) {
while ($line = db_fetch_assoc($result)) {
$line["content_preview"] = truncate_string(strip_tags($line["content"]), $excerpt_length);
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) {
$line = $p->hook_query_headlines($line, $excerpt_length, true);
}
$is_updated = $line["last_read"] == "" && ($line["unread"] != "t" && $line["unread"] != "1");
$tags = explode(",", $line["tag_cache"]);
$label_cache = $line["label_cache"];
$labels = false;
if ($label_cache) {
$label_cache = json_decode($label_cache, true);
if ($label_cache) {
if ($label_cache["no-labels"] == 1) {
$labels = array();
} else {
$labels = $label_cache;
}
}
}
if (!is_array($labels)) {
$labels = get_article_labels($line["id"]);
}
//if (!$tags) $tags = get_article_tags($line["id"]);
//if (!$labels) $labels = get_article_labels($line["id"]);
$headline_row = array("id" => (int) $line["id"], "unread" => sql_bool_to_bool($line["unread"]), "marked" => sql_bool_to_bool($line["marked"]), "published" => sql_bool_to_bool($line["published"]), "updated" => (int) strtotime($line["updated"]), "is_updated" => $is_updated, "title" => $line["title"], "link" => $line["link"], "feed_id" => $line["feed_id"], "tags" => $tags);
if ($include_attachments) {
$headline_row['attachments'] = get_article_enclosures($line['id']);
}
if ($show_excerpt) {
$headline_row["excerpt"] = $line["content_preview"];
}
if ($show_content) {
if ($sanitize_content) {
$headline_row["content"] = sanitize($line["content"], sql_bool_to_bool($line['hide_images']), false, $line["site_url"], false, $line["id"]);
} else {
$headline_row["content"] = $line["content"];
}
}
// unify label output to ease parsing
if ($labels["no-labels"] == 1) {
$labels = array();
}
$headline_row["labels"] = $labels;
$headline_row["feed_title"] = $line["feed_title"] ? $line["feed_title"] : $feed_title;
$headline_row["comments_count"] = (int) $line["num_comments"];
$headline_row["comments_link"] = $line["comments"];
$headline_row["always_display_attachments"] = sql_bool_to_bool($line["always_display_enclosures"]);
$headline_row["author"] = $line["author"];
$headline_row["score"] = (int) $line["score"];
$headline_row["note"] = $line["note"];
$headline_row["lang"] = $line["lang"];
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE_API) as $p) {
$headline_row = $p->hook_render_article_api(array("headline" => $headline_row));
}
array_push($headlines, $headline_row);
}
} else {
if (is_numeric($result) && $result == -1) {
$headlines_header['first_id_changed'] = true;
}
}
return array($headlines, $headlines_header);
}
示例2: outputArticleXML
//.........这里部分代码省略.........
$parsed_updated = date(get_pref($link, 'LONG_DATE_FORMAT'), strtotime($line["updated"]));
print "<div class=\"postDate{$rtl_class}\">{$parsed_updated}</div>";
if ($line["link"]) {
print "<div clear='both'><a target='_blank' href=\"" . $line["link"] . "\">" . $line["title"] . "</a><span class='author'>{$entry_author}</span></div>";
} else {
print "<div clear='both'>" . $line["title"] . "{$entry_author}</div>";
}
$tags_str = format_tags_string(get_article_tags($link, $id), $id);
if (!$entry_comments) {
$entry_comments = " ";
}
# placeholder
print "<div style='float : right'>\n\t\t\t\t<img src='" . theme_image($link, 'images/tag.png') . "' \n\t\t\t\tclass='tagsPic' alt='Tags' title='Tags'> ";
if (!$zoom_mode) {
print "<span id=\"ATSTR-{$id}\">{$tags_str}</span>\n\t\t\t\t\t<a title=\"" . __('Edit tags for this article') . "\" \n\t\t\t\t\thref=\"javascript:editArticleTags({$id}, {$feed_id})\">(+)</a>";
print "<img src=\"" . theme_image($link, 'images/art-zoom.png') . "\" \n\t\t\t\t\t\tclass='tagsPic' style=\"cursor : pointer\" style=\"cursor : pointer\"\n\t\t\t\t\t\tonclick=\"zoomToArticle({$id})\"\n\t\t\t\t\t\talt='Zoom' title='" . __('Show article summary in new window') . "'>";
$note_escaped = htmlspecialchars($line['note'], ENT_QUOTES);
print "<img src=\"" . theme_image($link, 'images/art-pub-note.png') . "\" \n\t\t\t\t\t\tclass='tagsPic' style=\"cursor : pointer\" style=\"cursor : pointer\"\n\t\t\t\t\t\tonclick=\"publishWithNote({$id}, '{$note_escaped}')\"\n\t\t\t\t\t\talt='PubNote' title='" . __('Publish article with a note') . "'>";
} else {
$tags_str = strip_tags($tags_str);
print "<span id=\"ATSTR-{$id}\">{$tags_str}</span>";
}
print "</div>";
print "<div clear='both'>{$entry_comments}</div>";
if ($line["orig_feed_id"]) {
$tmp_result = db_query($link, "SELECT * FROM ttrss_archived_feeds\n\t\t\t\t\tWHERE id = " . $line["orig_feed_id"]);
if (db_num_rows($tmp_result) != 0) {
print "<div clear='both'>";
print __("Originally from:");
print " ";
$tmp_line = db_fetch_assoc($tmp_result);
print "<a target='_blank' \n\t\t\t\t\t\thref=' " . htmlspecialchars($tmp_line['site_url']) . "'>" . $tmp_line['title'] . "</a>";
print " ";
print "<a target='_blank' href='" . htmlspecialchars($tmp_line['feed_url']) . "'>";
print "<img title='" . __('Feed URL') . "'class='tinyFeedIcon' src='images/pub_set.gif'></a>";
print "</div>";
}
}
print "</div>";
print "<div class=\"postIcon\">" . $feed_icon . "</div>";
print "<div class=\"postContent\">";
$article_content = sanitize_rss($link, $line["content"]);
print "<div id=\"POSTNOTE-{$id}\">";
if ($line['note']) {
print format_article_note($id, $line['note']);
}
print "</div>";
print $article_content;
// $result = db_query($link, "SELECT * FROM ttrss_enclosures WHERE
// post_id = '$id' AND content_url != ''");
$result = get_article_enclosures($link, $id);
// if (db_num_rows($result) > 0) {
if (count($result) > 0) {
$entries_html = array();
$entries = array();
//while ($line = db_fetch_assoc($result)) {
foreach ($result as $line) {
$url = $line["content_url"];
$ctype = $line["content_type"];
if (!$ctype) {
$ctype = __("unknown type");
}
$filename = substr($url, strrpos($url, "/") + 1);
$entry = format_inline_player($link, $url, $ctype);
$entry .= " <a target=\"_blank\" href=\"" . htmlspecialchars($url) . "\">" . $filename . " (" . $ctype . ")" . "</a>";
array_push($entries_html, $entry);
$entry = array();
$entry["type"] = $ctype;
$entry["filename"] = $filename;
$entry["url"] = $url;
array_push($entries, $entry);
}
print "<div class=\"postEnclosures\">";
if (!get_pref($link, "STRIP_IMAGES")) {
if ($always_display_enclosures || !preg_match("/<img/i", $article_content)) {
foreach ($entries as $entry) {
if (preg_match("/image/", $entry["type"]) || preg_match("/\\.(jpg|png|gif|bmp)/i", $entry["filename"])) {
print "<p><img\n\t\t\t\t\t\t\t\t\talt=\"" . htmlspecialchars($entry["filename"]) . "\"\n\t\t\t\t\t\t\t\t\tsrc=\"" . htmlspecialchars($entry["url"]) . "\"/></p>";
}
}
}
}
if (db_num_rows($result) == 1) {
print __("Attachment:") . " ";
} else {
print __("Attachments:") . " ";
}
print join(", ", $entries_html);
print "</div>";
}
print "</div>";
print "</div>";
}
if (!$zoom_mode) {
print "]]></article>";
} else {
print "\n\t\t\t\t<div style=\"text-align : center\">\n\t\t\t\t<button onclick=\"return window.close()\">" . __("Close this window") . "</button></div>";
print "</body></html>";
}
}
示例3: format_article_enclosures
function format_article_enclosures($link, $id, $always_display_enclosures, $article_content)
{
$result = get_article_enclosures($link, $id);
$rv = '';
if (count($result) > 0) {
$entries_html = array();
$entries = array();
$entries_inline = array();
foreach ($result as $line) {
$url = $line["content_url"];
$ctype = $line["content_type"];
if (!$ctype) {
$ctype = __("unknown type");
}
$filename = substr($url, strrpos($url, "/") + 1);
$player = format_inline_player($link, $url, $ctype);
if ($player) {
array_push($entries_inline, $player);
}
# $entry .= " <a target=\"_blank\" href=\"" . htmlspecialchars($url) . "\">" .
# $filename . " (" . $ctype . ")" . "</a>";
$entry = "<div onclick=\"window.open('" . htmlspecialchars($url) . "')\"\n\t\t\t\t\tdojoType=\"dijit.MenuItem\">{$filename} ({$ctype})</div>";
array_push($entries_html, $entry);
$entry = array();
$entry["type"] = $ctype;
$entry["filename"] = $filename;
$entry["url"] = $url;
array_push($entries, $entry);
}
if (!get_pref($link, "STRIP_IMAGES")) {
if ($always_display_enclosures || !preg_match("/<img/i", $article_content)) {
foreach ($entries as $entry) {
if (preg_match("/image/", $entry["type"]) || preg_match("/\\.(jpg|png|gif|bmp)/i", $entry["filename"])) {
$rv .= "<p><img\n\t\t\t\t\t\t\t\talt=\"" . htmlspecialchars($entry["filename"]) . "\"\n\t\t\t\t\t\t\t\tsrc=\"" . htmlspecialchars($entry["url"]) . "\"/></p>";
}
}
}
}
if (count($entries_inline) > 0) {
$rv .= "<hr clear='both'/>";
foreach ($entries_inline as $entry) {
$rv .= $entry;
}
$rv .= "<hr clear='both'/>";
}
$rv .= "<br/><div dojoType=\"dijit.form.DropDownButton\">" . "<span>" . __('Attachments') . "</span>";
$rv .= "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
foreach ($entries_html as $entry) {
$rv .= $entry;
}
$rv .= "</div></div>";
}
return $rv;
}
示例4: generate_syndicated_feed
private function generate_syndicated_feed($owner_uid, $feed, $is_cat, $limit, $offset, $search, $search_mode, $match_on, $view_mode = false, $format = 'atom')
{
require_once "lib/MiniTemplator.class.php";
$note_style = "background-color : #fff7d5;\n\t\t\tborder-width : 1px; " . "padding : 5px; border-style : dashed; border-color : #e7d796;" . "margin-bottom : 1em; color : #9a8c59;";
if (!$limit) {
$limit = 100;
}
if (get_pref($this->link, "SORT_HEADLINES_BY_FEED_DATE", $owner_uid)) {
$date_sort_field = "updated";
} else {
$date_sort_field = "date_entered";
}
if ($feed == -2) {
$date_sort_field = "last_read";
}
$qfh_ret = queryFeedHeadlines($this->link, $feed, $limit, $view_mode, $is_cat, $search, $search_mode, $match_on, "{$date_sort_field} DESC", $offset, $owner_uid, false, 0, false, true);
$result = $qfh_ret[0];
$feed_title = htmlspecialchars($qfh_ret[1]);
$feed_site_url = $qfh_ret[2];
$last_error = $qfh_ret[3];
$feed_self_url = get_self_url_prefix() . "/public.php?op=rss&id=-2&key=" . get_feed_access_key($this->link, -2, false, $owner_uid);
if (!$feed_site_url) {
$feed_site_url = get_self_url_prefix();
}
if ($format == 'atom') {
$tpl = new MiniTemplator();
$tpl->readTemplateFromFile("templates/generated_feed.txt");
$tpl->setVariable('FEED_TITLE', $feed_title, true);
$tpl->setVariable('VERSION', VERSION, true);
$tpl->setVariable('FEED_URL', htmlspecialchars($feed_self_url), true);
if (PUBSUBHUBBUB_HUB && $feed == -2) {
$tpl->setVariable('HUB_URL', htmlspecialchars(PUBSUBHUBBUB_HUB), true);
$tpl->addBlock('feed_hub');
}
$tpl->setVariable('SELF_URL', htmlspecialchars(get_self_url_prefix()), true);
while ($line = db_fetch_assoc($result)) {
$tpl->setVariable('ARTICLE_ID', htmlspecialchars($line['link']), true);
$tpl->setVariable('ARTICLE_LINK', htmlspecialchars($line['link']), true);
$tpl->setVariable('ARTICLE_TITLE', htmlspecialchars($line['title']), true);
$tpl->setVariable('ARTICLE_EXCERPT', truncate_string(strip_tags($line["content_preview"]), 100, '...'), true);
$content = sanitize($this->link, $line["content_preview"], false, $owner_uid);
if ($line['note']) {
$content = "<div style=\"{$note_style}\">Article note: " . $line['note'] . "</div>" . $content;
}
$tpl->setVariable('ARTICLE_CONTENT', $content, true);
$tpl->setVariable('ARTICLE_UPDATED_ATOM', date('c', strtotime($line["updated"])), true);
$tpl->setVariable('ARTICLE_UPDATED_RFC822', date(DATE_RFC822, strtotime($line["updated"])), true);
$tpl->setVariable('ARTICLE_AUTHOR', htmlspecialchars($line['author']), true);
$tags = get_article_tags($this->link, $line["id"], $owner_uid);
foreach ($tags as $tag) {
$tpl->setVariable('ARTICLE_CATEGORY', htmlspecialchars($tag), true);
$tpl->addBlock('category');
}
$enclosures = get_article_enclosures($this->link, $line["id"]);
foreach ($enclosures as $e) {
$type = htmlspecialchars($e['content_type']);
$url = htmlspecialchars($e['content_url']);
$length = $e['duration'];
$tpl->setVariable('ARTICLE_ENCLOSURE_URL', $url, true);
$tpl->setVariable('ARTICLE_ENCLOSURE_TYPE', $type, true);
$tpl->setVariable('ARTICLE_ENCLOSURE_LENGTH', $length, true);
$tpl->addBlock('enclosure');
}
$tpl->addBlock('entry');
}
$tmp = "";
$tpl->addBlock('feed');
$tpl->generateOutputToString($tmp);
if (@(!$_REQUEST["noxml"])) {
header("Content-Type: text/xml; charset=utf-8");
} else {
header("Content-Type: text/plain; charset=utf-8");
}
print $tmp;
} else {
if ($format == 'json') {
$feed = array();
$feed['title'] = $feed_title;
$feed['version'] = VERSION;
$feed['feed_url'] = $feed_self_url;
if (PUBSUBHUBBUB_HUB && $feed == -2) {
$feed['hub_url'] = PUBSUBHUBBUB_HUB;
}
$feed['self_url'] = get_self_url_prefix();
$feed['articles'] = array();
while ($line = db_fetch_assoc($result)) {
$article = array();
$article['id'] = $line['link'];
$article['link'] = $line['link'];
$article['title'] = $line['title'];
$article['excerpt'] = truncate_string(strip_tags($line["content_preview"]), 100, '...');
$article['content'] = sanitize($this->link, $line["content_preview"], false, $owner_uid);
$article['updated'] = date('c', strtotime($line["updated"]));
if ($line['note']) {
$article['note'] = $line['note'];
}
if ($article['author']) {
$article['author'] = $line['author'];
}
$tags = get_article_tags($this->link, $line["id"], $owner_uid);
//.........这里部分代码省略.........
示例5: generate_syndicated_feed
private function generate_syndicated_feed($owner_uid, $feed, $is_cat, $limit, $offset, $search, $search_mode, $view_mode = false, $format = 'atom', $order = false, $orig_guid = false)
{
require_once "lib/MiniTemplator.class.php";
$note_style = "background-color : #fff7d5;\n\t\t\tborder-width : 1px; " . "padding : 5px; border-style : dashed; border-color : #e7d796;" . "margin-bottom : 1em; color : #9a8c59;";
if (!$limit) {
$limit = 60;
}
$date_sort_field = "date_entered DESC, updated DESC";
if ($feed == -2) {
$date_sort_field = "last_published DESC";
} else {
if ($feed == -1) {
$date_sort_field = "last_marked DESC";
}
}
switch ($order) {
case "title":
$date_sort_field = "ttrss_entries.title";
break;
case "date_reverse":
$date_sort_field = "date_entered, updated";
break;
case "feed_dates":
$date_sort_field = "updated DESC";
break;
}
$qfh_ret = queryFeedHeadlines($feed, 1, $view_mode, $is_cat, $search, $search_mode, $date_sort_field, $offset, $owner_uid, false, 0, false, true);
$result = $qfh_ret[0];
if ($this->dbh->num_rows($result) != 0) {
$ts = strtotime($this->dbh->fetch_result($result, 0, "date_entered"));
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= $ts) {
header('HTTP/1.0 304 Not Modified');
return;
}
$last_modified = gmdate("D, d M Y H:i:s", $ts) . " GMT";
header("Last-Modified: {$last_modified}", true);
}
$qfh_ret = queryFeedHeadlines($feed, $limit, $view_mode, $is_cat, $search, $search_mode, $date_sort_field, $offset, $owner_uid, false, 0, false, true);
$result = $qfh_ret[0];
$feed_title = htmlspecialchars($qfh_ret[1]);
$feed_site_url = $qfh_ret[2];
$last_error = $qfh_ret[3];
$feed_self_url = get_self_url_prefix() . "/public.php?op=rss&id={$feed}&key=" . get_feed_access_key($feed, false, $owner_uid);
if (!$feed_site_url) {
$feed_site_url = get_self_url_prefix();
}
if ($format == 'atom') {
$tpl = new MiniTemplator();
$tpl->readTemplateFromFile("templates/generated_feed.txt");
$tpl->setVariable('FEED_TITLE', $feed_title, true);
$tpl->setVariable('VERSION', VERSION, true);
$tpl->setVariable('FEED_URL', htmlspecialchars($feed_self_url), true);
if (PUBSUBHUBBUB_HUB && $feed == -2) {
$tpl->setVariable('HUB_URL', htmlspecialchars(PUBSUBHUBBUB_HUB), true);
$tpl->addBlock('feed_hub');
}
$tpl->setVariable('SELF_URL', htmlspecialchars(get_self_url_prefix()), true);
$line["content_preview"] = truncate_string(strip_tags($line["content_preview"]), 100, '...');
while ($line = $this->dbh->fetch_assoc($result)) {
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) {
$line = $p->hook_query_headlines($line);
}
$tpl->setVariable('ARTICLE_ID', htmlspecialchars($orig_guid ? $line['link'] : get_self_url_prefix() . "/public.php?url=" . urlencode($line['link'])), true);
$tpl->setVariable('ARTICLE_LINK', htmlspecialchars($line['link']), true);
$tpl->setVariable('ARTICLE_TITLE', htmlspecialchars($line['title']), true);
$tpl->setVariable('ARTICLE_EXCERPT', $line["content_preview"], true);
$content = sanitize($line["content"], false, $owner_uid);
if ($line['note']) {
$content = "<div style=\"{$note_style}\">Article note: " . $line['note'] . "</div>" . $content;
$tpl->setVariable('ARTICLE_NOTE', htmlspecialchars($line['note']), true);
}
$tpl->setVariable('ARTICLE_CONTENT', $content, true);
$tpl->setVariable('ARTICLE_UPDATED_ATOM', date('c', strtotime($line["updated"])), true);
$tpl->setVariable('ARTICLE_UPDATED_RFC822', date(DATE_RFC822, strtotime($line["updated"])), true);
$tpl->setVariable('ARTICLE_AUTHOR', htmlspecialchars($line['author']), true);
$tpl->setVariable('ARTICLE_SOURCE_LINK', htmlspecialchars($line['site_url']), true);
$tpl->setVariable('ARTICLE_SOURCE_TITLE', htmlspecialchars($line['feed_title']), true);
$tags = get_article_tags($line["id"], $owner_uid);
foreach ($tags as $tag) {
$tpl->setVariable('ARTICLE_CATEGORY', htmlspecialchars($tag), true);
$tpl->addBlock('category');
}
$enclosures = get_article_enclosures($line["id"]);
foreach ($enclosures as $e) {
$type = htmlspecialchars($e['content_type']);
$url = htmlspecialchars($e['content_url']);
$length = $e['duration'];
$tpl->setVariable('ARTICLE_ENCLOSURE_URL', $url, true);
$tpl->setVariable('ARTICLE_ENCLOSURE_TYPE', $type, true);
$tpl->setVariable('ARTICLE_ENCLOSURE_LENGTH', $length, true);
$tpl->addBlock('enclosure');
}
$tpl->addBlock('entry');
}
$tmp = "";
$tpl->addBlock('feed');
$tpl->generateOutputToString($tmp);
if (@(!$_REQUEST["noxml"])) {
header("Content-Type: text/xml; charset=utf-8");
} else {
//.........这里部分代码省略.........
示例6: getArticle
function getArticle()
{
$article_id = join(",", array_filter(explode(",", db_escape_string($_REQUEST["article_id"])), is_numeric));
$query = "SELECT id,title,link,content,cached_content,feed_id,comments,int_id,\n\t\t\tmarked,unread,published,\n\t\t\t" . SUBSTRING_FOR_DATE . "(updated,1,16) as updated,\n\t\t\tauthor\n\t\t\tFROM ttrss_entries,ttrss_user_entries\n\t\t\tWHERE\tid IN ({$article_id}) AND ref_id = id AND owner_uid = " . $_SESSION["uid"];
$result = db_query($this->link, $query);
$articles = array();
if (db_num_rows($result) != 0) {
while ($line = db_fetch_assoc($result)) {
$attachments = get_article_enclosures($this->link, $line['id']);
$article = array("id" => $line["id"], "title" => $line["title"], "link" => $line["link"], "labels" => get_article_labels($this->link, $line['id']), "unread" => sql_bool_to_bool($line["unread"]), "marked" => sql_bool_to_bool($line["marked"]), "published" => sql_bool_to_bool($line["published"]), "comments" => $line["comments"], "author" => $line["author"], "updated" => strtotime($line["updated"]), "content" => $line["cached_content"] != "" ? $line["cached_content"] : $line["content"], "feed_id" => $line["feed_id"], "attachments" => $attachments);
array_push($articles, $article);
}
}
print $this->wrap(self::STATUS_OK, $articles);
}
示例7: format_article_enclosures
function format_article_enclosures($id, $always_display_enclosures, $article_content, $hide_images = false)
{
$result = get_article_enclosures($id);
$rv = '';
if (count($result) > 0) {
$entries_html = array();
$entries = array();
$entries_inline = array();
foreach ($result as $line) {
$url = $line["content_url"];
$ctype = $line["content_type"];
if (!$ctype) {
$ctype = __("unknown type");
}
$filename = substr($url, strrpos($url, "/") + 1);
$player = format_inline_player($url, $ctype);
if ($player) {
array_push($entries_inline, $player);
}
# $entry .= " <a target=\"_blank\" href=\"" . htmlspecialchars($url) . "\">" .
# $filename . " (" . $ctype . ")" . "</a>";
$entry = "<div onclick=\"window.open('" . htmlspecialchars($url) . "')\"\n\t\t\t\t\tdojoType=\"dijit.MenuItem\">{$filename} ({$ctype})</div>";
array_push($entries_html, $entry);
$entry = array();
$entry["type"] = $ctype;
$entry["filename"] = $filename;
$entry["url"] = $url;
array_push($entries, $entry);
}
if ($_SESSION['uid'] && !get_pref("STRIP_IMAGES") && !$_SESSION["bw_limit"]) {
if ($always_display_enclosures || !preg_match("/<img/i", $article_content)) {
foreach ($entries as $entry) {
if (preg_match("/image/", $entry["type"]) || preg_match("/\\.(jpg|png|gif|bmp)/i", $entry["filename"])) {
if (!$hide_images) {
$rv .= "<p><img\n\t\t\t\t\t\t\t\t\talt=\"" . htmlspecialchars($entry["filename"]) . "\"\n\t\t\t\t\t\t\t\t\tsrc=\"" . htmlspecialchars($entry["url"]) . "\"/></p>";
} else {
$rv .= "<p><a target=\"_blank\"\n\t\t\t\t\t\t\t\t\thref=\"" . htmlspecialchars($entry["url"]) . "\"\n\t\t\t\t\t\t\t\t\t>" . htmlspecialchars($entry["url"]) . "</a></p>";
}
}
}
}
}
if (count($entries_inline) > 0) {
$rv .= "<hr clear='both'/>";
foreach ($entries_inline as $entry) {
$rv .= $entry;
}
$rv .= "<hr clear='both'/>";
}
$rv .= "<select class=\"attachments\" onchange=\"openSelectedAttachment(this)\">" . "<option value=''>" . __('Attachments') . "</option>";
foreach ($entries as $entry) {
$rv .= "<option value=\"" . htmlspecialchars($entry["url"]) . "\">" . htmlspecialchars($entry["filename"]) . "</option>";
}
$rv .= "</select>";
}
return $rv;
}
示例8: format_article_enclosures
function format_article_enclosures($link, $id, $always_display_enclosures, $article_content)
{
$result = get_article_enclosures($link, $id);
$rv = '';
if (count($result) > 0) {
$entries_html = array();
$entries = array();
foreach ($result as $line) {
$url = $line["content_url"];
$ctype = $line["content_type"];
if (!$ctype) {
$ctype = __("unknown type");
}
# $filename = substr($url, strrpos($url, "/")+1);
$entry = format_inline_player($link, $url, $ctype);
# $entry .= " <a target=\"_blank\" href=\"" . htmlspecialchars($url) . "\">" .
# $filename . " (" . $ctype . ")" . "</a>";
array_push($entries_html, $entry);
$entry = array();
$entry["type"] = $ctype;
$entry["filename"] = $filename;
$entry["url"] = $url;
array_push($entries, $entry);
}
$rv .= "<div class=\"postEnclosures\">";
if (!get_pref($link, "STRIP_IMAGES")) {
if ($always_display_enclosures || !preg_match("/<img/i", $article_content)) {
foreach ($entries as $entry) {
if (preg_match("/image/", $entry["type"]) || preg_match("/\\.(jpg|png|gif|bmp)/i", $entry["filename"])) {
$rv .= "<p><img\n\t\t\t\t\t\t\t\talt=\"" . htmlspecialchars($entry["filename"]) . "\"\n\t\t\t\t\t\t\t\tsrc=\"" . htmlspecialchars($entry["url"]) . "\"/></p>";
}
}
}
}
if (count($entries) == 1) {
$rv .= __("Attachment:") . " ";
} else {
$rv .= __("Attachments:") . " ";
}
$rv .= join(", ", $entries_html);
$rv .= "</div>";
}
return $rv;
}
示例9: format_article_enclosures
function format_article_enclosures($id, $always_display_enclosures, $article_content, $hide_images = false)
{
$result = get_article_enclosures($id);
$rv = '';
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_FORMAT_ENCLOSURES) as $plugin) {
$retval = $plugin->hook_format_enclosures($rv, $result, $id, $always_display_enclosures, $article_content, $hide_images);
if (is_array($retval)) {
$rv = $retval[0];
$result = $retval[1];
} else {
$rv = $retval;
}
}
if ($rv === '' && !empty($result)) {
$entries_html = array();
$entries = array();
$entries_inline = array();
foreach ($result as $line) {
$url = $line["content_url"];
$ctype = $line["content_type"];
$title = $line["title"];
$width = $line["width"];
$height = $line["height"];
if (!$ctype) {
$ctype = __("unknown type");
}
$filename = substr($url, strrpos($url, "/") + 1);
$player = format_inline_player($url, $ctype);
if ($player) {
array_push($entries_inline, $player);
}
# $entry .= " <a target=\"_blank\" href=\"" . htmlspecialchars($url) . "\">" .
# $filename . " (" . $ctype . ")" . "</a>";
$entry = "<div onclick=\"window.open('" . htmlspecialchars($url) . "')\"\n\t\t\t\t\tdojoType=\"dijit.MenuItem\">{$filename} ({$ctype})</div>";
array_push($entries_html, $entry);
$entry = array();
$entry["type"] = $ctype;
$entry["filename"] = $filename;
$entry["url"] = $url;
$entry["title"] = $title;
$entry["width"] = $width;
$entry["height"] = $height;
array_push($entries, $entry);
}
if ($_SESSION['uid'] && !get_pref("STRIP_IMAGES") && !$_SESSION["bw_limit"]) {
if ($always_display_enclosures || !preg_match("/<img/i", $article_content)) {
foreach ($entries as $entry) {
if (preg_match("/image/", $entry["type"]) || preg_match("/\\.(jpg|png|gif|bmp)/i", $entry["filename"])) {
if (!$hide_images) {
$encsize = '';
if ($entry['height'] > 0) {
$encsize .= ' height="' . intval($entry['width']) . '"';
}
if ($entry['width'] > 0) {
$encsize .= ' width="' . intval($entry['height']) . '"';
}
$rv .= "<p><img\n\t\t\t\t\t\t\t\t\talt=\"" . htmlspecialchars($entry["filename"]) . "\"\n\t\t\t\t\t\t\t\t\tsrc=\"" . htmlspecialchars($entry["url"]) . "\"\n\t\t\t\t\t\t\t\t\t" . $encsize . " /></p>";
} else {
$rv .= "<p><a target=\"_blank\"\n\t\t\t\t\t\t\t\t\thref=\"" . htmlspecialchars($entry["url"]) . "\"\n\t\t\t\t\t\t\t\t\t>" . htmlspecialchars($entry["url"]) . "</a></p>";
}
if ($entry['title']) {
$rv .= "<div class=\"enclosure_title\">{$entry['title']}</div>";
}
}
}
}
}
if (count($entries_inline) > 0) {
$rv .= "<hr clear='both'/>";
foreach ($entries_inline as $entry) {
$rv .= $entry;
}
$rv .= "<hr clear='both'/>";
}
$rv .= "<select class=\"attachments\" onchange=\"openSelectedAttachment(this)\">" . "<option value=''>" . __('Attachments') . "</option>";
foreach ($entries as $entry) {
if ($entry["title"]) {
$title = "— " . truncate_string($entry["title"], 30);
} else {
$title = "";
}
$rv .= "<option value=\"" . htmlspecialchars($entry["url"]) . "\">" . htmlspecialchars($entry["filename"]) . "{$title}</option>";
}
$rv .= "</select>";
}
return $rv;
}
示例10: getItems
//.........这里部分代码省略.........
if ($num_feed_ids <= 0) {
$query = " feed_id IN ('') ";
} else {
$query = trim($query, ",") . ")";
}
if (!empty($where)) {
$where .= " AND ";
}
$where .= $query;
}
if (isset($_REQUEST["max_id"])) {
// use the max_id argument to request the previous $item_limit items
if (is_numeric($_REQUEST["max_id"])) {
$max_id = $_REQUEST["max_id"] > 0 ? intval($_REQUEST["max_id"]) : 0;
if ($max_id) {
if (!empty($where)) {
$where .= " AND ";
}
$where .= "id < " . db_escape_string($max_id) . " ";
} else {
if (empty($where)) {
$where .= "1";
}
}
$where .= " ORDER BY id DESC";
}
} else {
if (isset($_REQUEST["with_ids"])) {
if (!empty($where)) {
$where .= " AND ";
}
// group_ids & feed_ids don't make sense with this query but just in case
$item_ids = explode(",", $_REQUEST["with_ids"]);
$query = "id IN (";
$num_ids = sizeof($item_ids);
foreach ($item_ids as $item_id) {
if (is_numeric($item_id)) {
$query .= db_escape_string(intval($item_id)) . ",";
} else {
$num_ids--;
}
}
if ($num_ids <= 0) {
$query = "id IN ('') ";
} else {
$query = trim($query, ",") . ") ";
}
$where .= $query;
} else {
if (is_numeric($_REQUEST["since_id"])) {
// use the since_id argument to request the next $item_limit items
$since_id = isset($_GET["since_id"]) ? intval($_GET["since_id"]) : 0;
if ($since_id) {
if (!empty($where)) {
$where .= " AND ";
}
if ($this->ID_HACK_FOR_MRREADER) {
$where .= "id > " . db_escape_string($since_id * 1000) . " ";
// NASTY hack for Mr. Reader 2.0 on iOS and TinyTiny RSS Fever
} else {
$where .= "id > " . db_escape_string($since_id) . " ";
}
} else {
if (empty($where)) {
$where .= "1";
}
}
$where .= " ORDER BY id ASC";
}
}
}
$where .= " LIMIT " . $item_limit;
// id, feed_id, title, author, html, url, is_saved, is_read, created_on_time
$result = $this->dbh->query("SELECT ref_id, feed_id, title, link, content, id, marked, unread, author, updated\n\t\t\t\t\t\t\t\t\t FROM ttrss_entries, ttrss_user_entries\n\t\t\t\t\t\t\t\t\t WHERE " . $where);
while ($line = $this->dbh->fetch_assoc($result)) {
$line_content = $this->my_sanitize($line["content"], $line["link"]);
if (ADD_ATTACHED_FILES) {
$enclosures = get_article_enclosures($line["id"]);
if (count($enclosures) > 0) {
$line_content .= '<ul type="lower-greek">';
foreach ($enclosures as $enclosure) {
if (!empty($enclosure['content_url'])) {
$enc_type = '';
if (!empty($enclosure['content_type'])) {
$enc_type = ', ' . $enclosure['content_type'];
}
$enc_size = '';
if (!empty($enclosure['duration'])) {
$enc_size = ' , ' . $this->formatBytes($enclosure['duration']);
}
$line_content .= '<li><a href="' . $enclosure['content_url'] . '" target="_blank">' . basename($enclosure['content_url']) . $enc_type . $enc_size . '</a>' . '</li>';
}
}
$line_content .= '</ul>';
}
}
array_push($items, array("id" => intval($line["id"]), "feed_id" => intval($line["feed_id"]), "title" => $line["title"], "author" => $line["author"], "html" => $line_content, "url" => $line["link"], "is_saved" => sql_bool_to_bool($line["marked"]) ? 1 : 0, "is_read" => !sql_bool_to_bool($line["unread"]) ? 1 : 0, "created_on_time" => strtotime($line["updated"])));
}
return $items;
}
示例11: api_get_headlines
static function api_get_headlines($link, $feed_id, $limit, $offset, $filter, $is_cat, $show_excerpt, $show_content, $view_mode, $order, $include_attachments, $since_id, $search = "", $search_mode = "", $match_on = "", $include_nested = false, $sanitize_content = true)
{
$qfh_ret = queryFeedHeadlines($link, $feed_id, $limit, $view_mode, $is_cat, $search, $search_mode, $match_on, $order, $offset, 0, false, $since_id, $include_nested);
$result = $qfh_ret[0];
$feed_title = $qfh_ret[1];
$headlines = array();
while ($line = db_fetch_assoc($result)) {
$is_updated = $line["last_read"] == "" && ($line["unread"] != "t" && $line["unread"] != "1");
$tags = explode(",", $line["tag_cache"]);
$labels = json_decode($line["label_cache"], true);
//if (!$tags) $tags = get_article_tags($link, $line["id"]);
//if (!$labels) $labels = get_article_labels($link, $line["id"]);
$headline_row = array("id" => (int) $line["id"], "unread" => sql_bool_to_bool($line["unread"]), "marked" => sql_bool_to_bool($line["marked"]), "published" => sql_bool_to_bool($line["published"]), "updated" => (int) strtotime($line["updated"]), "is_updated" => $is_updated, "title" => $line["title"], "link" => $line["link"], "feed_id" => $line["feed_id"], "tags" => $tags);
if ($include_attachments) {
$headline_row['attachments'] = get_article_enclosures($link, $line['id']);
}
if ($show_excerpt) {
$excerpt = truncate_string(strip_tags($line["content_preview"]), 100);
$headline_row["excerpt"] = $excerpt;
}
if ($show_content) {
if ($line["cached_content"] != "") {
$line["content_preview"] =& $line["cached_content"];
}
if ($sanitize_content) {
$headline_row["content"] = sanitize($link, $line["content_preview"], false, false, $line["site_url"]);
} else {
$headline_row["content"] = $line["content_preview"];
}
}
// unify label output to ease parsing
if ($labels["no-labels"] == 1) {
$labels = array();
}
$headline_row["labels"] = $labels;
$headline_row["feed_title"] = $line["feed_title"];
$headline_row["comments_count"] = (int) $line["num_comments"];
$headline_row["comments_link"] = $line["comments"];
$headline_row["always_display_attachments"] = sql_bool_to_bool($line["always_display_enclosures"]);
array_push($headlines, $headline_row);
}
return $headlines;
}
示例12: generate_syndicated_feed
private function generate_syndicated_feed($owner_uid, $feed, $is_cat, $limit, $search, $search_mode, $match_on, $view_mode = false)
{
require_once "lib/MiniTemplator.class.php";
$note_style = "background-color : #fff7d5;\n\t\t\tborder-width : 1px; " . "padding : 5px; border-style : dashed; border-color : #e7d796;" . "margin-bottom : 1em; color : #9a8c59;";
if (!$limit) {
$limit = 30;
}
if (get_pref($this->link, "SORT_HEADLINES_BY_FEED_DATE", $owner_uid)) {
$date_sort_field = "updated";
} else {
$date_sort_field = "date_entered";
}
$qfh_ret = queryFeedHeadlines($this->link, $feed, $limit, $view_mode, $is_cat, $search, $search_mode, $match_on, "{$date_sort_field} DESC", 0, $owner_uid);
$result = $qfh_ret[0];
$feed_title = htmlspecialchars($qfh_ret[1]);
$feed_site_url = $qfh_ret[2];
$last_error = $qfh_ret[3];
$feed_self_url = get_self_url_prefix() . "/public.php?op=rss&id=-2&key=" . get_feed_access_key($this->link, -2, false, $owner_uid);
if (!$feed_site_url) {
$feed_site_url = get_self_url_prefix();
}
$tpl = new MiniTemplator();
$tpl->readTemplateFromFile("templates/generated_feed.txt");
$tpl->setVariable('FEED_TITLE', $feed_title, true);
$tpl->setVariable('VERSION', VERSION, true);
$tpl->setVariable('FEED_URL', htmlspecialchars($feed_self_url), true);
if (PUBSUBHUBBUB_HUB && $feed == -2) {
$tpl->setVariable('HUB_URL', htmlspecialchars(PUBSUBHUBBUB_HUB), true);
$tpl->addBlock('feed_hub');
}
$tpl->setVariable('SELF_URL', htmlspecialchars(get_self_url_prefix()), true);
while ($line = db_fetch_assoc($result)) {
$tpl->setVariable('ARTICLE_ID', htmlspecialchars($line['link']), true);
$tpl->setVariable('ARTICLE_LINK', htmlspecialchars($line['link']), true);
$tpl->setVariable('ARTICLE_TITLE', htmlspecialchars($line['title']), true);
$tpl->setVariable('ARTICLE_EXCERPT', truncate_string(strip_tags($line["content_preview"]), 100, '...'), true);
$content = sanitize($this->link, $line["content_preview"], false, $owner_uid);
if ($line['note']) {
$content = "<div style=\"{$note_style}\">Article note: " . $line['note'] . "</div>" . $content;
}
$tpl->setVariable('ARTICLE_CONTENT', $content, true);
$tpl->setVariable('ARTICLE_UPDATED_ATOM', date('c', strtotime($line["updated"])), true);
$tpl->setVariable('ARTICLE_UPDATED_RFC822', date(DATE_RFC822, strtotime($line["updated"])), true);
$tpl->setVariable('ARTICLE_AUTHOR', htmlspecialchars($line['author']), true);
$tags = get_article_tags($this->link, $line["id"], $owner_uid);
foreach ($tags as $tag) {
$tpl->setVariable('ARTICLE_CATEGORY', htmlspecialchars($tag), true);
$tpl->addBlock('category');
}
$enclosures = get_article_enclosures($this->link, $line["id"]);
foreach ($enclosures as $e) {
$type = htmlspecialchars($e['content_type']);
$url = htmlspecialchars($e['content_url']);
$length = $e['duration'];
$tpl->setVariable('ARTICLE_ENCLOSURE_URL', $url, true);
$tpl->setVariable('ARTICLE_ENCLOSURE_TYPE', $type, true);
$tpl->setVariable('ARTICLE_ENCLOSURE_LENGTH', $length, true);
$tpl->addBlock('enclosure');
}
$tpl->addBlock('entry');
}
$tmp = "";
$tpl->addBlock('feed');
$tpl->generateOutputToString($tmp);
print $tmp;
}
示例13: ccache_update
ccache_update($link, $line["feed_id"], $_SESSION["uid"]);
}
}
print api_wrap_reply(API_STATUS_OK, $seq, array("status" => "OK", "updated" => $num_updated));
} else {
print api_wrap_reply(API_STATUS_ERR, $seq, array("error" => 'INCORRECT_USAGE'));
}
break;
case "getArticle":
$article_id = join(",", array_filter(explode(",", db_escape_string($_REQUEST["article_id"])), is_numeric));
$query = "SELECT id,title,link,content,feed_id,comments,int_id,\n\t\t\t\tmarked,unread,published,\n\t\t\t\t" . SUBSTRING_FOR_DATE . "(updated,1,16) as updated,\n\t\t\t\tauthor\n\t\t\t\tFROM ttrss_entries,ttrss_user_entries\n\t\t\t\tWHERE\tid IN ({$article_id}) AND ref_id = id AND owner_uid = " . $_SESSION["uid"];
$result = db_query($link, $query);
$articles = array();
if (db_num_rows($result) != 0) {
while ($line = db_fetch_assoc($result)) {
$attachments = get_article_enclosures($link, $line['id']);
$article = array("id" => $line["id"], "title" => $line["title"], "link" => $line["link"], "labels" => get_article_labels($link, $line['id']), "unread" => sql_bool_to_bool($line["unread"]), "marked" => sql_bool_to_bool($line["marked"]), "published" => sql_bool_to_bool($line["published"]), "comments" => $line["comments"], "author" => $line["author"], "updated" => strtotime($line["updated"]), "content" => $line["content"], "feed_id" => $line["feed_id"], "attachments" => $attachments);
array_push($articles, $article);
}
}
print api_wrap_reply(API_STATUS_OK, $seq, $articles);
break;
case "getConfig":
$config = array("icons_dir" => ICONS_DIR, "icons_url" => ICONS_URL);
$config["daemon_is_running"] = file_is_locked("update_daemon.lock");
$result = db_query($link, "SELECT COUNT(*) AS cf FROM\n\t\t\t\tttrss_feeds WHERE owner_uid = " . $_SESSION["uid"]);
$num_feeds = db_fetch_result($result, 0, "cf");
$config["num_feeds"] = (int) $num_feeds;
print api_wrap_reply(API_STATUS_OK, $seq, $config);
break;
case "updateFeed":
示例14: api_get_headlines
static function api_get_headlines($feed_id, $limit, $offset, $filter, $is_cat, $show_excerpt, $show_content, $view_mode, $order, $include_attachments, $since_id, $search = "", $search_mode = "", $include_nested = false, $sanitize_content = true)
{
$qfh_ret = queryFeedHeadlines($feed_id, $limit, $view_mode, $is_cat, $search, $search_mode, $order, $offset, 0, false, $since_id, $include_nested);
$result = $qfh_ret[0];
$feed_title = $qfh_ret[1];
$headlines = array();
while ($line = db_fetch_assoc($result)) {
$line["content_preview"] = truncate_string(strip_tags($line["content"]), 100);
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) {
$line = $p->hook_query_headlines($line, 100, true);
}
$is_updated = $line["last_read"] == "" && ($line["unread"] != "t" && $line["unread"] != "1");
$tags = explode(",", $line["tag_cache"]);
$labels = json_decode($line["label_cache"], true);
//if (!$tags) $tags = get_article_tags($line["id"]);
//if (!$labels) $labels = get_article_labels($line["id"]);
$headline_row = array("id" => (int) $line["id"], "unread" => sql_bool_to_bool($line["unread"]), "marked" => sql_bool_to_bool($line["marked"]), "published" => sql_bool_to_bool($line["published"]), "updated" => (int) strtotime($line["updated"]), "is_updated" => $is_updated, "title" => $line["title"], "link" => $line["link"], "feed_id" => $line["feed_id"], "tags" => $tags);
if ($include_attachments) {
$headline_row['attachments'] = get_article_enclosures($line['id']);
}
if ($show_excerpt) {
$headline_row["excerpt"] = $line["content_preview"];
}
if ($show_content) {
if ($sanitize_content) {
$headline_row["content"] = sanitize($line["content"], sql_bool_to_bool($line['hide_images']), false, $line["site_url"], false, $line["id"]);
} else {
$headline_row["content"] = $line["content"];
}
}
// unify label output to ease parsing
if ($labels["no-labels"] == 1) {
$labels = array();
}
$headline_row["labels"] = $labels;
$headline_row["feed_title"] = $line["feed_title"] ? $line["feed_title"] : $feed_title;
$headline_row["comments_count"] = (int) $line["num_comments"];
$headline_row["comments_link"] = $line["comments"];
$headline_row["always_display_attachments"] = sql_bool_to_bool($line["always_display_enclosures"]);
$headline_row["author"] = $line["author"];
$headline_row["score"] = (int) $line["score"];
$headline_row["note"] = $line["note"];
$headline_row["lang"] = $line["lang"];
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE_API) as $p) {
$headline_row = $p->hook_render_article_api(array("headline" => $headline_row));
}
array_push($headlines, $headline_row);
}
return $headlines;
}