本文整理汇总了PHP中get_article_labels函数的典型用法代码示例。如果您正苦于以下问题:PHP get_article_labels函数的具体用法?PHP get_article_labels怎么用?PHP get_article_labels使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_article_labels函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: label_update_cache
function label_update_cache($link, $owner_uid, $id, $labels = false, $force = false)
{
if ($force) {
label_clear_cache($link, $id);
}
if (!$labels) {
$labels = get_article_labels($link, $id);
}
$labels = db_escape_string(json_encode($labels));
db_query($link, "UPDATE ttrss_user_entries SET\n\t\t\tlabel_cache = '{$labels}' WHERE ref_id = '{$id}' AND owner_uid = '{$owner_uid}'");
}
开发者ID:bohoo,项目名称:tiny_tiny_rss-openshift-quickstart-1,代码行数:11,代码来源:labels.php
示例2: 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);
}
开发者ID:Verisor,项目名称:tt-rss,代码行数:94,代码来源:api.php
示例3: update_rss_feed
//.........这里部分代码省略.........
}
$article = array("owner_uid" => $owner_uid, "guid" => $entry_guid, "title" => $entry_title, "content" => $entry_content, "link" => $entry_link, "tags" => $entry_tags, "plugin_data" => $entry_plugin_data, "author" => $entry_author, "stored" => $stored_article);
foreach ($pluginhost->get_hooks(PluginHost::HOOK_ARTICLE_FILTER) as $plugin) {
$article = $plugin->hook_article_filter($article);
}
$entry_tags = $article["tags"];
$entry_guid = db_escape_string($entry_guid);
$entry_title = db_escape_string($article["title"]);
$entry_author = db_escape_string($article["author"]);
$entry_link = db_escape_string($article["link"]);
$entry_plugin_data = db_escape_string($article["plugin_data"]);
$entry_content = $article["content"];
// escaped below
_debug("plugin data: {$entry_plugin_data}", $debug_enabled);
if ($cache_images && is_writable(CACHE_DIR . '/images')) {
cache_images($entry_content, $site_url, $debug_enabled);
}
$entry_content = db_escape_string($entry_content, false);
$content_hash = "SHA1:" . sha1($entry_content);
db_query("BEGIN");
$result = db_query("SELECT id FROM\tttrss_entries\n\t\t\t\t\tWHERE (guid = '{$entry_guid}' OR guid = '{$entry_guid_hashed}')");
if (db_num_rows($result) == 0) {
_debug("base guid [{$entry_guid}] not found", $debug_enabled);
// base post entry does not exist, create it
$result = db_query("INSERT INTO ttrss_entries\n\t\t\t\t\t\t\t(title,\n\t\t\t\t\t\t\tguid,\n\t\t\t\t\t\t\tlink,\n\t\t\t\t\t\t\tupdated,\n\t\t\t\t\t\t\tcontent,\n\t\t\t\t\t\t\tcontent_hash,\n\t\t\t\t\t\t\tno_orig_date,\n\t\t\t\t\t\t\tdate_updated,\n\t\t\t\t\t\t\tdate_entered,\n\t\t\t\t\t\t\tcomments,\n\t\t\t\t\t\t\tnum_comments,\n\t\t\t\t\t\t\tplugin_data,\n\t\t\t\t\t\t\tauthor)\n\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t('{$entry_title}',\n\t\t\t\t\t\t\t'{$entry_guid_hashed}',\n\t\t\t\t\t\t\t'{$entry_link}',\n\t\t\t\t\t\t\t'{$entry_timestamp_fmt}',\n\t\t\t\t\t\t\t'{$entry_content}',\n\t\t\t\t\t\t\t'{$content_hash}',\n\t\t\t\t\t\t\t{$no_orig_date},\n\t\t\t\t\t\t\tNOW(),\n\t\t\t\t\t\t\t'{$date_feed_processed}',\n\t\t\t\t\t\t\t'{$entry_comments}',\n\t\t\t\t\t\t\t'{$num_comments}',\n\t\t\t\t\t\t\t'{$entry_plugin_data}',\n\t\t\t\t\t\t\t'{$entry_author}')");
$article_labels = array();
} else {
// we keep encountering the entry in feeds, so we need to
// update date_updated column so that we don't get horrible
// dupes when the entry gets purged and reinserted again e.g.
// in the case of SLOW SLOW OMG SLOW updating feeds
$base_entry_id = db_fetch_result($result, 0, "id");
db_query("UPDATE ttrss_entries SET date_updated = NOW()\n\t\t\t\t\t\tWHERE id = '{$base_entry_id}'");
$article_labels = get_article_labels($base_entry_id, $owner_uid);
}
// now it should exist, if not - bad luck then
$result = db_query("SELECT\n\t\t\t\t\t\tid,content_hash,no_orig_date,title,plugin_data,guid,\n\t\t\t\t\t\t" . SUBSTRING_FOR_DATE . "(date_updated,1,19) as date_updated,\n\t\t\t\t\t\t" . SUBSTRING_FOR_DATE . "(updated,1,19) as updated,\n\t\t\t\t\t\tnum_comments\n\t\t\t\t\tFROM\n\t\t\t\t\t\tttrss_entries\n\t\t\t\t\tWHERE guid = '{$entry_guid}' OR guid = '{$entry_guid_hashed}'");
$entry_ref_id = 0;
$entry_int_id = 0;
if (db_num_rows($result) == 1) {
_debug("base guid found, checking for user record", $debug_enabled);
// this will be used below in update handler
$orig_content_hash = db_fetch_result($result, 0, "content_hash");
$orig_title = db_fetch_result($result, 0, "title");
$orig_num_comments = db_fetch_result($result, 0, "num_comments");
$orig_date_updated = strtotime(db_fetch_result($result, 0, "date_updated"));
$orig_plugin_data = db_fetch_result($result, 0, "plugin_data");
$ref_id = db_fetch_result($result, 0, "id");
$entry_ref_id = $ref_id;
/* $stored_guid = db_fetch_result($result, 0, "guid");
if ($stored_guid != $entry_guid_hashed) {
if ($debug_enabled) _debug("upgrading compat guid to hashed one", $debug_enabled);
db_query("UPDATE ttrss_entries SET guid = '$entry_guid_hashed' WHERE
id = '$ref_id'");
} */
// check for user post link to main table
// do we allow duplicate posts with same GUID in different feeds?
if (get_pref("ALLOW_DUPLICATE_POSTS", $owner_uid, false)) {
$dupcheck_qpart = "AND (feed_id = '{$feed}' OR feed_id IS NULL)";
} else {
$dupcheck_qpart = "";
}
/* Collect article tags here so we could filter by them: */
$article_filters = get_article_filters($filters, $entry_title, $entry_content, $entry_link, $entry_timestamp, $entry_author, $entry_tags);
if ($debug_enabled) {
开发者ID:cs-team,项目名称:tiny_tiny_rss-openshift-quickstart,代码行数:67,代码来源:rssfuncs.php
示例4: format_headlines_list
//.........这里部分代码省略.........
foreach (explode(",", ARTICLE_BUTTON_PLUGINS) as $p) {
$pclass = trim("button_{$p}");
if (class_exists($pclass)) {
$plugin = new $pclass($link);
array_push($button_plugins, $plugin);
}
}
}
if (db_num_rows($result) > 0) {
$lnum = $offset;
$num_unread = 0;
$cur_feed_title = '';
$fresh_intl = get_pref($this->link, "FRESH_ARTICLE_MAX_AGE") * 60 * 60;
if ($_REQUEST["debug"]) {
$timing_info = print_checkpoint("PS", $timing_info);
}
while ($line = db_fetch_assoc($result)) {
$class = $lnum % 2 ? "even" : "odd";
$id = $line["id"];
$feed_id = $line["feed_id"];
$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($this->link, $id);
}
$labels_str = "<span id=\"HLLCTR-{$id}\">";
$labels_str .= format_article_labels($labels, $id);
$labels_str .= "</span>";
if (count($topmost_article_ids) < 3) {
array_push($topmost_article_ids, $id);
}
if ($line["last_read"] == "" && !sql_bool_to_bool($line["unread"])) {
$update_pic = "<img id='FUPDPIC-{$id}' src=\"" . theme_image($this->link, 'images/updated.png') . "\"\r\n\t\t\t\t\t\talt=\"Updated\">";
} else {
$update_pic = "<img id='FUPDPIC-{$id}' src=\"images/blank_icon.gif\"\r\n\t\t\t\t\t\talt=\"Updated\">";
}
if (sql_bool_to_bool($line["unread"]) && time() - strtotime($line["updated_noms"]) < $fresh_intl) {
$update_pic = "<img id='FUPDPIC-{$id}' src=\"" . theme_image($this->link, 'images/fresh_sign.png') . "\" alt=\"Fresh\">";
}
if ($line["unread"] == "t" || $line["unread"] == "1") {
$class .= " Unread";
++$num_unread;
$is_unread = true;
} else {
$is_unread = false;
}
if ($line["marked"] == "t" || $line["marked"] == "1") {
$marked_pic = "<img id=\"FMPIC-{$id}\"\r\n\t\t\t\t\t\tsrc=\"" . theme_image($this->link, 'images/mark_set.png') . "\"\r\n\t\t\t\t\t\tclass=\"markedPic\" alt=\"Unstar article\"\r\n\t\t\t\t\t\tonclick='javascript:toggleMark({$id})'>";
} else {
$marked_pic = "<img id=\"FMPIC-{$id}\"\r\n\t\t\t\t\t\tsrc=\"" . theme_image($this->link, 'images/mark_unset.png') . "\"\r\n\t\t\t\t\t\tclass=\"markedPic\" alt=\"Star article\"\r\n\t\t\t\t\t\tonclick='javascript:toggleMark({$id})'>";
}
if ($line["published"] == "t" || $line["published"] == "1") {
$published_pic = "<img id=\"FPPIC-{$id}\" src=\"" . theme_image($this->link, 'images/pub_set.png') . "\"\r\n\t\t\t\t\t\tclass=\"markedPic\"\r\n\t\t\t\t\t\talt=\"Unpublish article\" onclick='javascript:togglePub({$id})'>";
} else {
$published_pic = "<img id=\"FPPIC-{$id}\" src=\"" . theme_image($this->link, 'images/pub_unset.png') . "\"\r\n\t\t\t\t\t\tclass=\"markedPic\"\r\n\t\t\t\t\t\talt=\"Publish article\" onclick='javascript:togglePub({$id})'>";
}
开发者ID:nvdnkpr,项目名称:Tiny-Tiny-RSS,代码行数:67,代码来源:feeds.php
示例5: labelops
function labelops($assign)
{
$reply = array();
$ids = explode(",", db_escape_string($_REQUEST["ids"]));
$label_id = db_escape_string($_REQUEST["lid"]);
$label = db_escape_string(label_find_caption($this->link, $label_id, $_SESSION["uid"]));
$reply["info-for-headlines"] = array();
if ($label) {
foreach ($ids as $id) {
if ($assign) {
label_add_article($this->link, $id, $label, $_SESSION["uid"]);
} else {
label_remove_article($this->link, $id, $label, $_SESSION["uid"]);
}
$labels = get_article_labels($this->link, $id, $_SESSION["uid"]);
array_push($reply["info-for-headlines"], array("id" => $id, "labels" => format_article_labels($labels, $id)));
}
}
$reply["message"] = "UPDATE_COUNTERS";
print json_encode($reply);
}
开发者ID:nvdnkpr,项目名称:Tiny-Tiny-RSS,代码行数:21,代码来源:rpc.php
示例6: outputHeadlinesList
//.........这里部分代码省略.........
$result = $qfh_ret[0];
$feed_title = $qfh_ret[1];
$feed_site_url = $qfh_ret[2];
$last_error = $qfh_ret[3];
$vgroup_last_feed = $vgr_last_feed;
if ($feed == -2) {
$feed_site_url = article_publish_url($link);
}
/// STOP //////////////////////////////////////////////////////////////////////////////////
if (!$offset) {
print "<div id=\"headlinesContainer\" {$rtl_tag}>";
if (!$result) {
print "<div align='center'>" . __("Could not display feed (query failed). Please check label match syntax or local configuration.") . "</div>";
return;
}
print_headline_subtoolbar($link, $feed_site_url, $feed_title, $feed, $cat_view, $search, $match_on, $search_mode);
print "<div id=\"headlinesInnerContainer\" onscroll=\"headlines_scroll_handler()\">";
}
$headlines_count = db_num_rows($result);
if (db_num_rows($result) > 0) {
# print "\{$offset}";
if (!get_pref($link, 'COMBINED_DISPLAY_MODE') && !$offset) {
print "<table class=\"headlinesList\" id=\"headlinesList\" \n\t\t\t\t\tcellspacing=\"0\">";
}
$lnum = $limit * $offset;
error_reporting(DEFAULT_ERROR_LEVEL);
$num_unread = 0;
$cur_feed_title = '';
$fresh_intl = get_pref($link, "FRESH_ARTICLE_MAX_AGE") * 60 * 60;
while ($line = db_fetch_assoc($result)) {
$class = $lnum % 2 ? "even" : "odd";
$id = $line["id"];
$feed_id = $line["feed_id"];
$labels = get_article_labels($link, $id);
$labels_str = "<span id=\"HLLCTR-{$id}\">";
$labels_str .= format_article_labels($labels, $id);
$labels_str .= "</span>";
if (count($topmost_article_ids) < 5) {
array_push($topmost_article_ids, $id);
}
if ($line["last_read"] == "" && !sql_bool_to_bool($line["unread"])) {
$update_pic = "<img id='FUPDPIC-{$id}' src=\"" . theme_image($link, 'images/updated.png') . "\" \n\t\t\t\t\t\talt=\"Updated\">";
} else {
$update_pic = "<img id='FUPDPIC-{$id}' src=\"images/blank_icon.gif\" \n\t\t\t\t\t\talt=\"Updated\">";
}
if (sql_bool_to_bool($line["unread"]) && time() - strtotime($line["updated_noms"]) < $fresh_intl) {
$update_pic = "<img id='FUPDPIC-{$id}' src=\"" . theme_image($link, 'images/fresh_sign.png') . "\" alt=\"Fresh\">";
}
if ($line["unread"] == "t" || $line["unread"] == "1") {
$class .= "Unread";
++$num_unread;
$is_unread = true;
} else {
$is_unread = false;
}
if ($line["marked"] == "t" || $line["marked"] == "1") {
$marked_pic = "<img id=\"FMPIC-{$id}\" \n\t\t\t\t\t\tsrc=\"" . theme_image($link, 'images/mark_set.png') . "\" \n\t\t\t\t\t\tclass=\"markedPic\" alt=\"Unstar article\" \n\t\t\t\t\t\tonclick='javascript:tMark({$id})'>";
} else {
$marked_pic = "<img id=\"FMPIC-{$id}\" \n\t\t\t\t\t\tsrc=\"" . theme_image($link, 'images/mark_unset.png') . "\" \n\t\t\t\t\t\tclass=\"markedPic\" alt=\"Star article\" \n\t\t\t\t\t\tonclick='javascript:tMark({$id})'>";
}
if ($line["published"] == "t" || $line["published"] == "1") {
$published_pic = "<img id=\"FPPIC-{$id}\" src=\"" . theme_image($link, 'images/pub_set.png') . "\" \n\t\t\t\t\t\tclass=\"markedPic\"\n\t\t\t\t\t\talt=\"Unpublish article\" onclick='javascript:tPub({$id})'>";
} else {
$published_pic = "<img id=\"FPPIC-{$id}\" src=\"" . theme_image($link, 'images/pub_unset.png') . "\" \n\t\t\t\t\t\tclass=\"markedPic\"\n\t\t\t\t\t\talt=\"Publish article\" onclick='javascript:tPub({$id})'>";
}
# $content_link = "<a target=\"_blank\" href=\"".$line["link"]."\">" .
开发者ID:wangroot,项目名称:Tiny-Tiny-RSS,代码行数:67,代码来源:functions.php
示例7: format_headlines_list
//.........这里部分代码省略.........
}
}
if ($this->dbh->num_rows($result) > 0) {
$lnum = $offset;
$num_unread = 0;
$cur_feed_title = '';
if ($_REQUEST["debug"]) {
$timing_info = print_checkpoint("PS", $timing_info);
}
$expand_cdm = get_pref('CDM_EXPANDED');
while ($line = $this->dbh->fetch_assoc($result)) {
$line["content_preview"] = "— " . truncate_string(strip_tags($line["content"]), 250);
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) {
$line = $p->hook_query_headlines($line, 250, false);
}
if (get_pref('SHOW_CONTENT_PREVIEW')) {
$content_preview = $line["content_preview"];
}
$id = $line["id"];
$feed_id = $line["feed_id"];
$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($id);
}
$labels_str = "<span class=\"HLLCTR-{$id}\">";
$labels_str .= format_article_labels($labels, $id);
$labels_str .= "</span>";
if (count($topmost_article_ids) < 3) {
array_push($topmost_article_ids, $id);
}
$class = "";
if (sql_bool_to_bool($line["unread"])) {
$class .= " Unread";
++$num_unread;
}
if (sql_bool_to_bool($line["marked"])) {
$marked_pic = "<img\n\t\t\t\t\t\tsrc=\"images/mark_set.png\"\n\t\t\t\t\t\tclass=\"markedPic\" alt=\"Unstar article\"\n\t\t\t\t\t\tonclick='toggleMark({$id})'>";
$class .= " marked";
} else {
$marked_pic = "<img\n\t\t\t\t\t\tsrc=\"images/mark_unset.png\"\n\t\t\t\t\t\tclass=\"markedPic\" alt=\"Star article\"\n\t\t\t\t\t\tonclick='toggleMark({$id})'>";
}
if (sql_bool_to_bool($line["published"])) {
$published_pic = "<img src=\"images/pub_set.png\"\n\t\t\t\t\t\tclass=\"pubPic\"\n\t\t\t\t\t\t\talt=\"Unpublish article\" onclick='togglePub({$id})'>";
$class .= " published";
} else {
$published_pic = "<img src=\"images/pub_unset.png\"\n\t\t\t\t\t\tclass=\"pubPic\"\n\t\t\t\t\t\talt=\"Publish article\" onclick='togglePub({$id})'>";
}
# $content_link = "<a target=\"_blank\" href=\"".$line["link"]."\">" .
# $line["title"] . "</a>";
# $content_link = "<a
# href=\"" . htmlspecialchars($line["link"]) . "\"
# onclick=\"view($id,$feed_id);\">" .
# $line["title"] . "</a>";
# $content_link = "<a href=\"javascript:viewContentUrl('".$line["link"]."');\">" .
# $line["title"] . "</a>";
开发者ID:zamentur,项目名称:ttrss_ynh,代码行数:67,代码来源:feeds.php
示例8: getLabels
function getLabels()
{
//$article_ids = array_filter(explode(",", db_escape_string($_REQUEST["article_ids"])), is_numeric);
$article_id = (int) $_REQUEST['article_id'];
$rv = array();
$result = db_query($this->link, "SELECT id, caption, fg_color, bg_color\n\t\t\tFROM ttrss_labels2\n\t\t\tWHERE owner_uid = '" . $_SESSION['uid'] . "' ORDER BY caption");
if ($article_id) {
$article_labels = get_article_labels($this->link, $article_id);
} else {
$article_labels = array();
}
while ($line = db_fetch_assoc($result)) {
$checked = false;
foreach ($article_labels as $al) {
if ($al[0] == $line['id']) {
$checked = true;
break;
}
}
array_push($rv, array("id" => (int) $line['id'], "caption" => $line['caption'], "fg_color" => $line['fg_color'], "bg_color" => $line['bg_color'], "checked" => $checked));
}
print $this->wrap(self::STATUS_OK, $rv);
}
开发者ID:rolfkleef,项目名称:Tiny-Tiny-RSS,代码行数:23,代码来源:api.php
示例9: update_rss_feed
//.........这里部分代码省略.........
$article = $plugin->filter_article($article);
}
$entry_title = $article["title"];
$entry_content = $article["content"];
$entry_tags = $article["tags"];
$entry_author = $article["author"];
}
$content_hash = "SHA1:" . sha1(strip_tags($entry_content));
db_query($link, "BEGIN");
if (db_num_rows($result) == 0) {
if ($debug_enabled) {
_debug("update_rss_feed: base guid not found");
}
if ($cache_content) {
if ($debug_enabled) {
_debug("update_rss_feed: caching content (initial)...");
}
$entry_cached_content = cache_content($link, $entry_link, $auth_login, $auth_pass);
if ($cache_images && is_writable(CACHE_DIR . '/images')) {
$entry_cached_content = cache_images($entry_cached_content, $site_url, $debug_enabled);
}
$entry_cached_content = db_escape_string($entry_cached_content, false);
}
// base post entry does not exist, create it
$result = db_query($link, "INSERT INTO ttrss_entries\n\t\t\t\t\t\t\t(title,\n\t\t\t\t\t\t\tguid,\n\t\t\t\t\t\t\tlink,\n\t\t\t\t\t\t\tupdated,\n\t\t\t\t\t\t\tcontent,\n\t\t\t\t\t\t\tcontent_hash,\n\t\t\t\t\t\t\tcached_content,\n\t\t\t\t\t\t\tno_orig_date,\n\t\t\t\t\t\t\tdate_updated,\n\t\t\t\t\t\t\tdate_entered,\n\t\t\t\t\t\t\tcomments,\n\t\t\t\t\t\t\tnum_comments,\n\t\t\t\t\t\t\tauthor)\n\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t('{$entry_title}',\n\t\t\t\t\t\t\t'{$entry_guid}',\n\t\t\t\t\t\t\t'{$entry_link}',\n\t\t\t\t\t\t\t'{$entry_timestamp_fmt}',\n\t\t\t\t\t\t\t'{$entry_content}',\n\t\t\t\t\t\t\t'{$content_hash}',\n\t\t\t\t\t\t\t'{$entry_cached_content}',\n\t\t\t\t\t\t\t{$no_orig_date},\n\t\t\t\t\t\t\tNOW(),\n\t\t\t\t\t\t\tNOW(),\n\t\t\t\t\t\t\t'{$entry_comments}',\n\t\t\t\t\t\t\t'{$num_comments}',\n\t\t\t\t\t\t\t'{$entry_author}')");
$article_labels = array();
} else {
// we keep encountering the entry in feeds, so we need to
// update date_updated column so that we don't get horrible
// dupes when the entry gets purged and reinserted again e.g.
// in the case of SLOW SLOW OMG SLOW updating feeds
$base_entry_id = db_fetch_result($result, 0, "id");
db_query($link, "UPDATE ttrss_entries SET date_updated = NOW()\n\t\t\t\t\t\tWHERE id = '{$base_entry_id}'");
$article_labels = get_article_labels($link, $base_entry_id, $owner_uid);
}
// now it should exist, if not - bad luck then
$result = db_query($link, "SELECT\n\t\t\t\t\t\tid,content_hash,no_orig_date,title,\n\t\t\t\t\t\t" . SUBSTRING_FOR_DATE . "(date_updated,1,19) as date_updated,\n\t\t\t\t\t\t" . SUBSTRING_FOR_DATE . "(updated,1,19) as updated,\n\t\t\t\t\t\tnum_comments, cached_content\n\t\t\t\t\tFROM\n\t\t\t\t\t\tttrss_entries\n\t\t\t\t\tWHERE guid = '{$entry_guid}'");
$entry_ref_id = 0;
$entry_int_id = 0;
if (db_num_rows($result) == 1) {
if ($debug_enabled) {
_debug("update_rss_feed: base guid found, checking for user record");
}
// this will be used below in update handler
$orig_content_hash = db_fetch_result($result, 0, "content_hash");
$orig_title = db_fetch_result($result, 0, "title");
$orig_num_comments = db_fetch_result($result, 0, "num_comments");
$orig_cached_content = trim(db_fetch_result($result, 0, "cached_content"));
$orig_date_updated = strtotime(db_fetch_result($result, 0, "date_updated"));
$ref_id = db_fetch_result($result, 0, "id");
$entry_ref_id = $ref_id;
// check for user post link to main table
// do we allow duplicate posts with same GUID in different feeds?
if (get_pref($link, "ALLOW_DUPLICATE_POSTS", $owner_uid, false)) {
$dupcheck_qpart = "AND (feed_id = '{$feed}' OR feed_id IS NULL)";
} else {
$dupcheck_qpart = "";
}
/* Collect article tags here so we could filter by them: */
$article_filters = get_article_filters($filters, $entry_title, $entry_content, $entry_link, $entry_timestamp, $entry_author, $entry_tags);
if ($debug_enabled) {
_debug("update_rss_feed: article filters: ");
if (count($article_filters) != 0) {
print_r($article_filters);
}
}
开发者ID:rolfkleef,项目名称:Tiny-Tiny-RSS,代码行数:67,代码来源:rssfuncs.php
示例10: update_rss_feed
//.........这里部分代码省略.........
}
if ($_REQUEST["xdebug"] == 2) {
print "content: ";
print $entry_content;
print "\n";
}
$entry_comments = $item->get_comments_url();
$entry_author = $item->get_author();
$entry_guid = db_escape_string(mb_substr($entry_guid, 0, 245));
$entry_comments = db_escape_string(mb_substr(trim($entry_comments), 0, 245));
$entry_author = db_escape_string(mb_substr(trim($entry_author), 0, 245));
$num_comments = (int) $item->get_comments_count();
_debug("author {$entry_author}", $debug_enabled);
_debug("num_comments: {$num_comments}", $debug_enabled);
_debug("looking for tags...", $debug_enabled);
// parse <category> entries into tags
$additional_tags = array();
$additional_tags_src = $item->get_categories();
if (is_array($additional_tags_src)) {
foreach ($additional_tags_src as $tobj) {
array_push($additional_tags, $tobj);
}
}
$entry_tags = array_unique($additional_tags);
for ($i = 0; $i < count($entry_tags); $i++) {
$entry_tags[$i] = mb_strtolower($entry_tags[$i], 'utf-8');
}
_debug("tags found: " . join(",", $entry_tags), $debug_enabled);
_debug("done collecting data.", $debug_enabled);
$result = db_query("SELECT id, content_hash, lang FROM ttrss_entries\n\t\t\t\t\tWHERE guid = '" . db_escape_string($entry_guid) . "' OR guid = '{$entry_guid_hashed}'");
if (db_num_rows($result) != 0) {
$base_entry_id = db_fetch_result($result, 0, "id");
$entry_stored_hash = db_fetch_result($result, 0, "content_hash");
$article_labels = get_article_labels($base_entry_id, $owner_uid);
$entry_language = db_fetch_result($result, 0, "lang");
} else {
$base_entry_id = false;
$entry_stored_hash = "";
$article_labels = array();
$entry_language = "";
}
$article = array("owner_uid" => $owner_uid, "guid" => $entry_guid, "guid_hashed" => $entry_guid_hashed, "title" => $entry_title, "content" => $entry_content, "link" => $entry_link, "labels" => $article_labels, "tags" => $entry_tags, "author" => $entry_author, "force_catchup" => false, "score_modifier" => 0, "language" => $entry_language, "feed" => array("id" => $feed, "fetch_url" => $fetch_url, "site_url" => $site_url));
$entry_plugin_data = "";
$entry_current_hash = calculate_article_hash($article, $pluginhost);
_debug("article hash: {$entry_current_hash} [stored={$entry_stored_hash}]", $debug_enabled);
if ($entry_current_hash == $entry_stored_hash && !isset($_REQUEST["force_rehash"])) {
_debug("stored article seems up to date [IID: {$base_entry_id}], updating timestamp only", $debug_enabled);
// we keep encountering the entry in feeds, so we need to
// update date_updated column so that we don't get horrible
// dupes when the entry gets purged and reinserted again e.g.
// in the case of SLOW SLOW OMG SLOW updating feeds
$base_entry_id = db_fetch_result($result, 0, "id");
db_query("UPDATE ttrss_entries SET date_updated = NOW()\n\t\t\t\t\t\tWHERE id = '{$base_entry_id}'");
// if we allow duplicate posts, we have to continue to
// create the user entries for this feed
if (!get_pref("ALLOW_DUPLICATE_POSTS", $owner_uid, false)) {
continue;
}
}
_debug("hash differs, applying plugin filters:", $debug_enabled);
foreach ($pluginhost->get_hooks(PluginHost::HOOK_ARTICLE_FILTER) as $plugin) {
_debug("... " . get_class($plugin), $debug_enabled);
$start = microtime(true);
$article = $plugin->hook_article_filter($article);
_debug("=== " . sprintf("%.4f (sec)", microtime(true) - $start), $debug_enabled);
$entry_plugin_data .= mb_strtolower(get_class($plugin)) . ",";
开发者ID:rnavarro,项目名称:tt-rss,代码行数:67,代码来源:rssfuncs.php
示例11: update_rss_feed
//.........这里部分代码省略.........
foreach ($pluginhost->get_hooks($pluginhost::HOOK_ARTICLE_FILTER) as $plugin) {
$article = $plugin->hook_article_filter($article);
}
$entry_tags = $article["tags"];
$entry_guid = db_escape_string($entry_guid);
$entry_content = db_escape_string($article["content"], false);
$entry_title = db_escape_string($article["title"]);
$entry_author = db_escape_string($article["author"]);
$entry_link = db_escape_string($article["link"]);
$entry_plugin_data = db_escape_string($article["plugin_data"]);
if ($debug_enabled) {
_debug("update_rss_feed: plugin data: {$entry_plugin_data}");
}
if ($cache_images && is_writable(CACHE_DIR . '/images')) {
$entry_content = cache_images($entry_content, $site_url, $debug_enabled);
}
$content_hash = "SHA1:" . sha1($entry_content);
db_query($link, "BEGIN");
$result = db_query($link, "SELECT id FROM\tttrss_entries\n\t\t\t\t\tWHERE guid = '{$entry_guid}'");
if (db_num_rows($result) == 0) {
if ($debug_enabled) {
_debug("update_rss_feed: base guid [{$entry_guid}] not found");
}
// base post entry does not exist, create it
$result = db_query($link, "INSERT INTO ttrss_entries\n\t\t\t\t\t\t\t(title,\n\t\t\t\t\t\t\tguid,\n\t\t\t\t\t\t\tlink,\n\t\t\t\t\t\t\tupdated,\n\t\t\t\t\t\t\tcontent,\n\t\t\t\t\t\t\tcontent_hash,\n\t\t\t\t\t\t\tcached_content,\n\t\t\t\t\t\t\tno_orig_date,\n\t\t\t\t\t\t\tdate_updated,\n\t\t\t\t\t\t\tdate_entered,\n\t\t\t\t\t\t\tcomments,\n\t\t\t\t\t\t\tnum_comments,\n\t\t\t\t\t\t\tplugin_data,\n\t\t\t\t\t\t\tauthor)\n\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t('{$entry_title}',\n\t\t\t\t\t\t\t'{$entry_guid}',\n\t\t\t\t\t\t\t'{$entry_link}',\n\t\t\t\t\t\t\t'{$entry_timestamp_fmt}',\n\t\t\t\t\t\t\t'{$entry_content}',\n\t\t\t\t\t\t\t'{$content_hash}',\n\t\t\t\t\t\t\t'',\n\t\t\t\t\t\t\t{$no_orig_date},\n\t\t\t\t\t\t\tNOW(),\n\t\t\t\t\t\t\tNOW(),\n\t\t\t\t\t\t\t'{$entry_comments}',\n\t\t\t\t\t\t\t'{$num_comments}',\n\t\t\t\t\t\t\t'{$entry_plugin_data}',\n\t\t\t\t\t\t\t'{$entry_author}')");
$article_labels = array();
} else {
// we keep encountering the entry in feeds, so we need to
// update date_updated column so that we don't get horrible
// dupes when the entry gets purged and reinserted again e.g.
// in the case of SLOW SLOW OMG SLOW updating feeds
$base_entry_id = db_fetch_result($result, 0, "id");
db_query($link, "UPDATE ttrss_entries SET date_updated = NOW()\n\t\t\t\t\t\tWHERE id = '{$base_entry_id}'");
$article_labels = get_article_labels($link, $base_entry_id, $owner_uid);
}
// now it should exist, if not - bad luck then
$result = db_query($link, "SELECT\n\t\t\t\t\t\tid,content_hash,no_orig_date,title,plugin_data,\n\t\t\t\t\t\t" . SUBSTRING_FOR_DATE . "(date_updated,1,19) as date_updated,\n\t\t\t\t\t\t" . SUBSTRING_FOR_DATE . "(updated,1,19) as updated,\n\t\t\t\t\t\tnum_comments\n\t\t\t\t\tFROM\n\t\t\t\t\t\tttrss_entries\n\t\t\t\t\tWHERE guid = '{$entry_guid}'");
$entry_ref_id = 0;
$entry_int_id = 0;
if (db_num_rows($result) == 1) {
if ($debug_enabled) {
_debug("update_rss_feed: base guid [{$entry_guid}] found, checking for user record");
}
// this will be used below in update handler
$orig_content_hash = db_fetch_result($result, 0, "content_hash");
$orig_title = db_fetch_result($result, 0, "title");
$orig_num_comments = db_fetch_result($result, 0, "num_comments");
$orig_date_updated = strtotime(db_fetch_result($result, 0, "date_updated"));
$orig_plugin_data = db_fetch_result($result, 0, "plugin_data");
$ref_id = db_fetch_result($result, 0, "id");
$entry_ref_id = $ref_id;
// check for user post link to main table
// do we allow duplicate posts with same GUID in different feeds?
if (get_pref($link, "ALLOW_DUPLICATE_POSTS", $owner_uid, false)) {
$dupcheck_qpart = "AND (feed_id = '{$feed}' OR feed_id IS NULL)";
} else {
$dupcheck_qpart = "";
}
/* Collect article tags here so we could filter by them: */
$article_filters = get_article_filters($filters, $entry_title, $entry_content, $entry_link, $entry_timestamp, $entry_author, $entry_tags);
if ($debug_enabled) {
_debug("update_rss_feed: article filters: ");
if (count($article_filters) != 0) {
print_r($article_filters);
}
}
开发者ID:bohoo,项目名称:tiny_tiny_rss-openshift-quickstart-1,代码行数:67,代码来源:rssfuncs.php
示例12: api_wrap_reply
}
}
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":
$feed_id = db_escape_string($_REQUEST["feed_id"]);
开发者ID:nougad,项目名称:Tiny-Tiny-RSS,代码行数:31,代码来源:index.php
注:本文中的get_article_labels函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载 |
请发表评论