summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
Diffstat (limited to 'classes')
-rw-r--r--classes/api.php32
-rw-r--r--classes/feeditem/common.php13
-rw-r--r--classes/feeds.php57
-rw-r--r--classes/handler/public.php38
-rw-r--r--classes/pluginhost.php1
-rw-r--r--classes/pref/feeds.php9
-rw-r--r--classes/pref/filters.php10
-rw-r--r--classes/pref/prefs.php8
-rw-r--r--classes/pref/users.php2
-rw-r--r--classes/rpc.php8
10 files changed, 96 insertions, 82 deletions
diff --git a/classes/api.php b/classes/api.php
index 23866072f..c1f4aa9fa 100644
--- a/classes/api.php
+++ b/classes/api.php
@@ -203,7 +203,7 @@ class API extends Handler {
$override_order = false;
switch ($_REQUEST["order_by"]) {
case "date_reverse":
- $override_order = "date_entered, updated";
+ $override_order = "score DESC, date_entered, updated";
break;
case "feed_dates":
$override_order = "updated DESC";
@@ -309,7 +309,7 @@ class API extends Handler {
if ($article_id) {
- $query = "SELECT id,title,link,content,cached_content,feed_id,comments,int_id,
+ $query = "SELECT id,title,link,content,feed_id,comments,int_id,
marked,unread,published,score,
".SUBSTRING_FOR_DATE."(updated,1,16) as updated,
author,(SELECT title FROM ttrss_feeds WHERE id = feed_id) AS feed_title
@@ -338,7 +338,7 @@ class API extends Handler {
"comments" => $line["comments"],
"author" => $line["author"],
"updated" => (int) strtotime($line["updated"]),
- "content" => $line["cached_content"] != "" ? $line["cached_content"] : $line["content"],
+ "content" => $line["content"],
"feed_id" => $line["feed_id"],
"attachments" => $attachments,
"score" => (int)$line["score"],
@@ -638,6 +638,11 @@ class API extends Handler {
$headlines = array();
while ($line = db_fetch_assoc($result)) {
+ $line["content_preview"] = truncate_string(strip_tags($line["content_preview"]), 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"));
@@ -660,28 +665,22 @@ class API extends Handler {
"tags" => $tags,
);
- if ($include_attachments)
- $headline_row['attachments'] = get_article_enclosures(
- $line['id']);
+ if ($include_attachments)
+ $headline_row['attachments'] = get_article_enclosures(
+ $line['id']);
- if ($show_excerpt) {
- $excerpt = truncate_string(strip_tags($line["content_preview"]), 100);
- $headline_row["excerpt"] = $excerpt;
- }
+ if (!$show_excerpt)
+ $headline_row["excerpt"] = $line["content_preview"];
if ($show_content) {
- if ($line["cached_content"] != "") {
- $line["content_preview"] =& $line["cached_content"];
- }
-
if ($sanitize_content) {
$headline_row["content"] = sanitize(
- $line["content_preview"],
+ $line["content"],
sql_bool_to_bool($line['hide_images']),
false, $line["site_url"]);
} else {
- $headline_row["content"] = $line["content_preview"];
+ $headline_row["content"] = $line["content"];
}
}
@@ -699,6 +698,7 @@ class API extends Handler {
$headline_row["always_display_attachments"] = sql_bool_to_bool($line["always_display_enclosures"]);
$headline_row["author"] = $line["author"];
+
$headline_row["score"] = (int)$line["score"];
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE_API) as $p) {
diff --git a/classes/feeditem/common.php b/classes/feeditem/common.php
index f8fd3c62a..58065b198 100644
--- a/classes/feeditem/common.php
+++ b/classes/feeditem/common.php
@@ -9,11 +9,16 @@ abstract class FeedItem_Common extends FeedItem {
$this->xpath = $xpath;
$this->doc = $doc;
- $source = $elem->getElementsByTagName("source")->item(0);
+ try {
- // we don't need <source> element
- if ($source)
- $elem->removeChild($source);
+ $source = $elem->getElementsByTagName("source")->item(0);
+
+ // we don't need <source> element
+ if ($source)
+ $elem->removeChild($source);
+ } catch (DOMException $e) {
+ //
+ }
}
function get_author() {
diff --git a/classes/feeds.php b/classes/feeds.php
index 33f239ee6..c57328fe7 100644
--- a/classes/feeds.php
+++ b/classes/feeds.php
@@ -61,7 +61,7 @@ class Feeds extends Handler_Protected {
truncate_string($feed_title,30)."</a>";
if ($error) {
- $reply .= " (<span class=\"error\" title=\"$error\">Error</span>)";
+ $reply .= "&nbsp;<img title='$error' src='images/error.png' alt='error' class=\"noborder\" style=\"vertical-align : middle\">";
}
} else {
@@ -74,7 +74,7 @@ class Feeds extends Handler_Protected {
<a href=\"#\"
title=\"".__("View as RSS feed")."\"
onclick=\"displayDlg('".__("View as RSS")."','generatedFeed', '$feed_id:$is_cat:$rss_link')\">
- <img class=\"noborder\" style=\"vertical-align : middle\" src=\"images/pub_set.svg\"></a>";
+ <img class=\"noborder\" style=\"vertical-align : middle\" src=\"images/pub_set.png\"></a>";
$reply .= "</span>";
@@ -288,6 +288,16 @@ class Feeds extends Handler_Protected {
$expand_cdm = get_pref('CDM_EXPANDED');
while ($line = $this->dbh->fetch_assoc($result)) {
+ $line["content_preview"] = "&mdash; " . truncate_string(strip_tags($line["content_preview"]), 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"];
@@ -323,24 +333,24 @@ class Feeds extends Handler_Protected {
if (sql_bool_to_bool($line["marked"])) {
$marked_pic = "<img
- src=\"images/mark_set.svg\"
+ src=\"images/mark_set.png\"
class=\"markedPic\" alt=\"Unstar article\"
onclick='toggleMark($id)'>";
$class .= " marked";
} else {
$marked_pic = "<img
- src=\"images/mark_unset.svg\"
+ src=\"images/mark_unset.png\"
class=\"markedPic\" alt=\"Star article\"
onclick='toggleMark($id)'>";
}
if (sql_bool_to_bool($line["published"])) {
- $published_pic = "<img src=\"images/pub_set.svg\"
+ $published_pic = "<img src=\"images/pub_set.png\"
class=\"pubPic\"
alt=\"Unpublish article\" onclick='togglePub($id)'>";
$class .= " published";
} else {
- $published_pic = "<img src=\"images/pub_unset.svg\"
+ $published_pic = "<img src=\"images/pub_unset.png\"
class=\"pubPic\"
alt=\"Publish article\" onclick='togglePub($id)'>";
}
@@ -360,11 +370,6 @@ class Feeds extends Handler_Protected {
$date_entered_fmt = T_sprintf("Imported at %s",
make_local_datetime($line["date_entered"], false));
- if (get_pref('SHOW_CONTENT_PREVIEW')) {
- $content_preview = " &mdash; " . truncate_string(strip_tags($line["content_preview"]),
- 250);
- }
-
$score = $line["score"];
$score_pic = "images/" . get_score_pic($score);
@@ -377,9 +382,9 @@ class Feeds extends Handler_Protected {
title=\"$score\">";
if ($score > 500) {
- $hlc_suffix = "H";
+ $hlc_suffix = "high";
} else if ($score < -100) {
- $hlc_suffix = "L";
+ $hlc_suffix = "low";
} else {
$hlc_suffix = "";
}
@@ -395,7 +400,7 @@ class Feeds extends Handler_Protected {
if ($has_feed_icon) {
$feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"".ICONS_URL."/$feed_id.ico\" alt=\"\">";
} else {
- $feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"images/pub_set.svg\" alt=\"\">";
+ $feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"images/pub_set.png\" alt=\"\">";
}
$entry_site_url = $line["site_url"];
@@ -448,16 +453,14 @@ class Feeds extends Handler_Protected {
$reply['content'] .= "</div>";
$reply['content'] .= "<div onclick='return hlClicked(event, $id)'
- class=\"hlTitle\"><span class='hlContent$hlc_suffix'>";
- $reply['content'] .= "<a id=\"RTITLE-$id\" class=\"title\"
+ class=\"hlTitle\"><span class='hlContent $hlc_suffix'>";
+ $reply['content'] .= "<a id=\"RTITLE-$id\" class=\"title $hlc_suffix\"
href=\"" . htmlspecialchars($line["link"]) . "\"
onclick=\"\">" .
truncate_string($line["title"], 200);
if (get_pref('SHOW_CONTENT_PREVIEW')) {
- if ($content_preview) {
- $reply['content'] .= "<span class=\"contentPreview\">$content_preview</span>";
- }
+ $reply['content'] .= "<span class=\"contentPreview\">" . $line["content_preview"] . "</span>";
}
$reply['content'] .= "</a></span>";
@@ -502,7 +505,7 @@ class Feeds extends Handler_Protected {
else
$tags = false;
- $line["content"] = sanitize($line["content_preview"],
+ $line["content"] = sanitize($line["content"],
sql_bool_to_bool($line['hide_images']), false, $entry_site_url);
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE_CDM) as $p) {
@@ -539,7 +542,7 @@ class Feeds extends Handler_Protected {
$expanded_class = $expand_cdm ? "expanded" : "expandable";
- $reply['content'] .= "<div class=\"cdm $expanded_class $class\"
+ $reply['content'] .= "<div class=\"cdm $hlc_suffix $expanded_class $class\"
id=\"RROW-$id\" $mouseover_attrs>";
$reply['content'] .= "<div class=\"cdmHeader\" style=\"$row_background\">";
@@ -556,8 +559,8 @@ class Feeds extends Handler_Protected {
$reply['content'] .= "<span id=\"RTITLE-$id\"
onclick=\"return cdmClicked(event, $id);\"
- class=\"titleWrap$hlc_suffix\">
- <a class=\"title\"
+ class=\"titleWrap $hlc_suffix\">
+ <a class=\"title $hlc_suffix\"
target=\"_blank\" href=\"".
htmlspecialchars($line["link"])."\">".
$line["title"] .
@@ -574,8 +577,8 @@ class Feeds extends Handler_Protected {
else
$excerpt_hidden = "style=\"display : none\"";
- $reply['content'] .= "<span $excerpt_hidden
- id=\"CEXC-$id\" class=\"cdmExcerpt\">$content_preview</span>";
+ $reply['content'] .= "<span $excerpt_hidden id=\"CEXC-$id\" class=\"cdmExcerpt\">" . $line["content_preview"] . "</span>";
+
$reply['content'] .= "</span>";
if (!get_pref('VFEED_GROUP_BY_FEED')) {
@@ -638,7 +641,7 @@ class Feeds extends Handler_Protected {
$reply['content'] .= "&nbsp;";
$reply['content'] .= "<a target='_blank' href='" . htmlspecialchars($tmp_line['feed_url']) . "'>";
- $reply['content'] .= "<img title='".__('Feed URL')."'class='tinyFeedIcon' src='images/pub_unset.svg'></a>";
+ $reply['content'] .= "<img title='".__('Feed URL')."'class='tinyFeedIcon' src='images/pub_unset.png'></a>";
$reply['content'] .= "</div>";
}
@@ -863,7 +866,7 @@ class Feeds extends Handler_Protected {
$override_order = "ttrss_entries.title";
break;
case "date_reverse":
- $override_order = "date_entered, updated";
+ $override_order = "score DESC, date_entered, updated";
break;
case "feed_dates":
$override_order = "updated DESC";
diff --git a/classes/handler/public.php b/classes/handler/public.php
index f05beafd2..60a961bfa 100644
--- a/classes/handler/public.php
+++ b/classes/handler/public.php
@@ -3,7 +3,7 @@ class Handler_Public extends Handler {
private function generate_syndicated_feed($owner_uid, $feed, $is_cat,
$limit, $offset, $search, $search_mode,
- $view_mode = false, $format = 'atom', $order = false) {
+ $view_mode = false, $format = 'atom', $order = false, $orig_guid = false) {
require_once "lib/MiniTemplator.class.php";
@@ -65,8 +65,8 @@ class Handler_Public extends Handler {
$last_error = $qfh_ret[3];
$feed_self_url = get_self_url_prefix() .
- "/public.php?op=rss&id=-2&key=" .
- get_feed_access_key(-2, false, $owner_uid);
+ "/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();
@@ -85,16 +85,21 @@ class Handler_Public extends Handler {
}
$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($line['link']), true);
+ $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',
- truncate_string(strip_tags($line["content_preview"]), 100, '...'), true);
+ $tpl->setVariable('ARTICLE_EXCERPT', $line["content_preview"], true);
- $content = sanitize($line["content_preview"], false, $owner_uid);
+ $content = sanitize($line["content"], false, $owner_uid);
if ($line['note']) {
$content = "<div style=\"$note_style\">Article note: " . $line['note'] . "</div>" .
@@ -111,6 +116,9 @@ class Handler_Public extends Handler {
$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) {
@@ -164,13 +172,17 @@ class Handler_Public extends Handler {
$feed['articles'] = array();
while ($line = $this->dbh->fetch_assoc($result)) {
+ $line["content_preview"] = truncate_string(strip_tags($line["content_preview"]), 100, '...');
+ foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) {
+ $line = $p->hook_query_headlines($line, 100);
+ }
$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($line["content_preview"], false, $owner_uid);
+ $article['excerpt'] = $line["content_preview"];
+ $article['content'] = sanitize($line["content"], false, $owner_uid);
$article['updated'] = date('c', strtotime($line["updated"]));
if ($line['note']) $article['note'] = $line['note'];
@@ -342,7 +354,7 @@ class Handler_Public extends Handler {
function rss() {
$feed = $this->dbh->escape_string($_REQUEST["id"]);
$key = $this->dbh->escape_string($_REQUEST["key"]);
- $is_cat = $_REQUEST["is_cat"] != false;
+ $is_cat = sql_bool_to_bool($_REQUEST["is_cat"]);
$limit = (int)$this->dbh->escape_string($_REQUEST["limit"]);
$offset = (int)$this->dbh->escape_string($_REQUEST["offset"]);
@@ -352,6 +364,7 @@ class Handler_Public extends Handler {
$order = $this->dbh->escape_string($_REQUEST["order"]);
$format = $this->dbh->escape_string($_REQUEST['format']);
+ $orig_guid = !sql_bool_to_bool($_REQUEST["no_orig_guid"]);
if (!$format) $format = 'atom';
@@ -371,7 +384,7 @@ class Handler_Public extends Handler {
if ($owner_id) {
$this->generate_syndicated_feed($owner_id, $feed, $is_cat, $limit,
- $offset, $search, $search_mode, $view_mode, $format, $order);
+ $offset, $search, $search_mode, $view_mode, $format, $order, $orig_guid);
} else {
header('HTTP/1.1 403 Forbidden');
}
@@ -543,6 +556,7 @@ class Handler_Public extends Handler {
}
} else {
$_SESSION["login_error_msg"] = __("Incorrect username or password");
+ user_error("Failed login attempt from {$_SERVER['REMOTE_ADDR']}", E_USER_WARNING);
}
if ($_REQUEST['return']) {
diff --git a/classes/pluginhost.php b/classes/pluginhost.php
index 53adf01f9..a1bd1b364 100644
--- a/classes/pluginhost.php
+++ b/classes/pluginhost.php
@@ -37,6 +37,7 @@ class PluginHost {
const HOOK_PREFS_EDIT_FEED = 20;
const HOOK_PREFS_SAVE_FEED = 21;
const HOOK_FETCH_FEED = 22;
+ const HOOK_QUERY_HEADLINES = 23;
const KIND_ALL = 1;
const KIND_SYSTEM = 2;
diff --git a/classes/pref/feeds.php b/classes/pref/feeds.php
index 870c4fed4..1f8c5e4a0 100644
--- a/classes/pref/feeds.php
+++ b/classes/pref/feeds.php
@@ -1471,15 +1471,6 @@ class Pref_Feeds extends Handler_Protected {
print "</p>";
- print_warning(__("You can disable all articles shared by unique URLs here."));
-
- print "<p>";
-
- print "<button dojoType=\"dijit.form.Button\" onclick=\"return clearArticleAccessKeys()\">".
- __('Unshare all articles')."</button> ";
-
- print "</p>";
-
PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION,
"hook_prefs_tab_section", "prefFeedsPublishedGenerated");
diff --git a/classes/pref/filters.php b/classes/pref/filters.php
index 6a70e622c..c4d6fea1d 100644
--- a/classes/pref/filters.php
+++ b/classes/pref/filters.php
@@ -96,13 +96,17 @@ class Pref_Filters extends Handler_Protected {
print "<div class=\"filterTestHolder\">";
print "<table width=\"100%\" cellspacing=\"0\" id=\"prefErrorFeedList\">";
+ $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, 100);
+ }
$entry_timestamp = strtotime($line["updated"]);
$entry_tags = get_article_tags($line["id"], $_SESSION["uid"]);
- $content_preview = truncate_string(
- strip_tags($line["content_preview"]), 100, '...');
+ $content_preview = $line["content_preview"];
if ($line["feed_title"])
$feed_title = $line["feed_title"];
@@ -118,7 +122,7 @@ class Pref_Filters extends Handler_Protected {
print "&nbsp;(";
print "<b>" . $feed_title . "</b>";
print "):&nbsp;";
- print "<span class=\"insensitive\">" . $content_preview . "</span>";
+ print "<span class=\"insensitive\">" . $line["content_preview"] . "</span>";
print " " . mb_substr($line["date_entered"], 0, 16);
print "</td></tr>";
diff --git a/classes/pref/prefs.php b/classes/pref/prefs.php
index 32071e3b3..671756f08 100644
--- a/classes/pref/prefs.php
+++ b/classes/pref/prefs.php
@@ -765,7 +765,9 @@ class Pref_Prefs extends Handler_Protected {
dojoType=\"dijit.form.CheckBox\" $checked
type=\"checkbox\"></td>";
- print "<td>$name</td>";
+ $plugin_icon = $checked ? "plugin.png" : "plugin_disabled.png";
+
+ print "<td><label><img src='images/$plugin_icon' alt=''> $name</label></td>";
print "<td>" . htmlspecialchars($about[1]);
if (@$about[4]) {
print " &mdash; <a target=\"_blank\" class=\"visibleLink\"
@@ -818,11 +820,13 @@ class Pref_Prefs extends Handler_Protected {
print "<tr class='$rowclass'>";
+ $plugin_icon = $checked ? "plugin.png" : "plugin_disabled.png";
+
print "<td align='center'><input id='FPCHK-$name' name='plugins[]' value='$name' onclick='toggleSelectRow2(this);'
dojoType=\"dijit.form.CheckBox\" $checked $disabled
type=\"checkbox\"></td>";
- print "<td><label for='FPCHK-$name'>$name</label></td>";
+ print "<td><label for='FPCHK-$name'><img src='images/$plugin_icon' alt=''> $name</label></td>";
print "<td><label for='FPCHK-$name'>" . htmlspecialchars($about[1]) . "</label>";
if (@$about[4]) {
print " &mdash; <a target=\"_blank\" class=\"visibleLink\"
diff --git a/classes/pref/users.php b/classes/pref/users.php
index 8a0202483..6db7d558b 100644
--- a/classes/pref/users.php
+++ b/classes/pref/users.php
@@ -418,7 +418,7 @@ class Pref_Users extends Handler_Protected {
$onclick = "onclick='editUser($uid, event)' title='".__('Click to edit')."'";
- print "<td $onclick>" . $line["login"] . "</td>";
+ print "<td $onclick><img src='images/user.png' class='markedPic' alt=''> " . $line["login"] . "</td>";
if (!$line["email"]) $line["email"] = "&nbsp;";
diff --git a/classes/rpc.php b/classes/rpc.php
index 46583feb5..9cc8e7046 100644
--- a/classes/rpc.php
+++ b/classes/rpc.php
@@ -467,14 +467,6 @@ class RPC extends Handler_Protected {
print_feed_cat_select("cat_id", $id, '');
}
- // Silent
- function clearArticleKeys() {
- $this->dbh->query("UPDATE ttrss_user_entries SET uuid = '' WHERE
- owner_uid = " . $_SESSION["uid"]);
-
- return;
- }
-
function setpanelmode() {
$wide = (int) $_REQUEST["wide"];