summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
authorHeiko Adams <[email protected]>2015-11-30 10:29:44 +0100
committerHeiko Adams <[email protected]>2015-11-30 10:29:44 +0100
commit05761788b7b5a8a7e6c14333669acd0793886223 (patch)
tree464ccc3d98900e5dcf1a437662056161fa1280a4 /classes
parent635ecdb9fa039adb8a0e8ead045bfda023e72bc4 (diff)
parent6f5d9c6889b6376527d7598857ac8816cf7980ab (diff)
Merge remote-tracking branch 'origin/master' into german-translation
Diffstat (limited to 'classes')
-rw-r--r--classes/api.php27
-rw-r--r--classes/article.php4
-rwxr-xr-x[-rw-r--r--]classes/feeds.php10
-rw-r--r--classes/pluginhost.php12
-rw-r--r--classes/pref/feeds.php4
-rwxr-xr-x[-rw-r--r--]classes/pref/filters.php74
-rw-r--r--classes/pref/prefs.php2
-rwxr-xr-x[-rw-r--r--]classes/rpc.php2
8 files changed, 84 insertions, 51 deletions
diff --git a/classes/api.php b/classes/api.php
index 2d420e527..c3ea627fd 100644
--- a/classes/api.php
+++ b/classes/api.php
@@ -2,7 +2,7 @@
class API extends Handler {
- const API_LEVEL = 12;
+ const API_LEVEL = 13;
const STATUS_OK = 0;
const STATUS_ERR = 1;
@@ -210,6 +210,8 @@ class API extends Handler {
$_SESSION['hasSandbox'] = $has_sandbox;
+ $skip_first_id_check = false;
+
$override_order = false;
switch ($_REQUEST["order_by"]) {
case "title":
@@ -217,6 +219,7 @@ class API extends Handler {
break;
case "date_reverse":
$override_order = "score DESC, date_entered, updated";
+ $skip_first_id_check = true;
break;
case "feed_dates":
$override_order = "updated DESC";
@@ -230,7 +233,7 @@ class API extends Handler {
list($headlines, $headlines_header) = $this->api_get_headlines($feed_id, $limit, $offset,
$filter, $is_cat, $show_excerpt, $show_content, $view_mode, $override_order,
$include_attachments, $since_id, $search,
- $include_nested, $sanitize_content, $force_update, $excerpt_length, $check_first_id);
+ $include_nested, $sanitize_content, $force_update, $excerpt_length, $check_first_id, $skip_first_id_check);
if ($include_header) {
$this->wrap(self::STATUS_OK, array($headlines_header, $headlines));
@@ -322,13 +325,17 @@ class API extends Handler {
function getArticle() {
$article_id = join(",", array_filter(explode(",", $this->dbh->escape_string($_REQUEST["article_id"])), is_numeric));
+ $sanitize_content = !isset($_REQUEST["sanitize"]) ||
+ sql_bool_to_bool($_REQUEST["sanitize"]);
if ($article_id) {
$query = "SELECT id,title,link,content,feed_id,comments,int_id,
marked,unread,published,score,note,lang,
".SUBSTRING_FOR_DATE."(updated,1,16) as updated,
- author,(SELECT title FROM ttrss_feeds WHERE id = feed_id) AS feed_title
+ author,(SELECT title FROM ttrss_feeds WHERE id = feed_id) AS feed_title,
+ (SELECT site_url FROM ttrss_feeds WHERE id = feed_id) AS site_url,
+ (SELECT hide_images FROM ttrss_feeds WHERE id = feed_id) AS hide_images
FROM ttrss_entries,ttrss_user_entries
WHERE id IN ($article_id) AND ref_id = id AND owner_uid = " .
$_SESSION["uid"] ;
@@ -354,7 +361,6 @@ class API extends Handler {
"comments" => $line["comments"],
"author" => $line["author"],
"updated" => (int) strtotime($line["updated"]),
- "content" => $line["content"],
"feed_id" => $line["feed_id"],
"attachments" => $attachments,
"score" => (int)$line["score"],
@@ -363,6 +369,15 @@ class API extends Handler {
"lang" => $line["lang"]
);
+ if ($sanitize_content) {
+ $article["content"] = sanitize(
+ $line["content"],
+ sql_bool_to_bool($line['hide_images']),
+ false, $line["site_url"], false, $line["id"]);
+ } else {
+ $article["content"] = $line["content"];
+ }
+
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE_API) as $p) {
$article = $p->hook_render_article_api(array("article" => $article));
}
@@ -644,7 +659,7 @@ class API extends Handler {
$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) {
+ $force_update = false, $excerpt_length = 100, $check_first_id = false, $skip_first_id_check = false) {
if ($force_update && $feed_id > 0 && is_numeric($feed_id)) {
// Update the feed if required with some basic flood control
@@ -687,7 +702,7 @@ class API extends Handler {
"since_id" => $since_id,
"include_children" => $include_nested,
"check_first_id" => $check_first_id,
- "api_request" => true
+ "skip_first_id_check" => $skip_first_id_check
);
$qfh_ret = queryFeedHeadlines($params);
diff --git a/classes/article.php b/classes/article.php
index bcd249873..01f6b5126 100644
--- a/classes/article.php
+++ b/classes/article.php
@@ -41,12 +41,12 @@ class Article extends Handler_Protected {
} else if ($mode == "zoom") {
array_push($articles, format_article($id, true, true));
} else if ($mode == "raw") {
- if ($_REQUEST['html']) {
+ if (isset($_REQUEST['html'])) {
header("Content-Type: text/html");
print '<link rel="stylesheet" type="text/css" href="css/tt-rss.css"/>';
}
- $article = format_article($id, false);
+ $article = format_article($id, false, isset($_REQUEST["zoom"]));
print $article['content'];
return;
}
diff --git a/classes/feeds.php b/classes/feeds.php
index c3cb72da8..07a18741d 100644..100755
--- a/classes/feeds.php
+++ b/classes/feeds.php
@@ -148,7 +148,8 @@ class Feeds extends Handler_Protected {
private function format_headlines_list($feed, $method, $view_mode, $limit, $cat_view,
$next_unread_feed, $offset, $vgr_last_feed = false,
- $override_order = false, $include_children = false, $check_first_id = false) {
+ $override_order = false, $include_children = false, $check_first_id = false,
+ $skip_first_id_check = false) {
$disable_cache = false;
@@ -252,7 +253,8 @@ class Feeds extends Handler_Protected {
"override_order" => $override_order,
"offset" => $offset,
"include_children" => $include_children,
- "check_first_id" => $check_first_id
+ "check_first_id" => $check_first_id,
+ "skip_first_id_check" => $skip_first_id_check
);
$qfh_ret = queryFeedHeadlines($params);
@@ -903,6 +905,7 @@ class Feeds extends Handler_Protected {
$reply['headlines'] = array();
$override_order = false;
+ $skip_first_id_check = false;
switch ($order_by) {
case "title":
@@ -910,6 +913,7 @@ class Feeds extends Handler_Protected {
break;
case "date_reverse":
$override_order = "score DESC, date_entered, updated";
+ $skip_first_id_check = true;
break;
case "feed_dates":
$override_order = "updated DESC";
@@ -920,7 +924,7 @@ class Feeds extends Handler_Protected {
$ret = $this->format_headlines_list($feed, $method,
$view_mode, $limit, $cat_view, $next_unread_feed, $offset,
- $vgroup_last_feed, $override_order, true, $check_first_id);
+ $vgroup_last_feed, $override_order, true, $check_first_id, $skip_first_id_check);
//$topmost_article_ids = $ret[0];
$headlines_count = $ret[1];
diff --git a/classes/pluginhost.php b/classes/pluginhost.php
index 75620a191..0f3d8f37c 100644
--- a/classes/pluginhost.php
+++ b/classes/pluginhost.php
@@ -133,7 +133,7 @@ class PluginHost {
return array();
}
}
- function load_all($kind, $owner_uid = false) {
+ function load_all($kind, $owner_uid = false, $skip_init = false) {
$plugins = array_merge(glob("plugins/*"), glob("plugins.local/*"));
$plugins = array_filter($plugins, "is_dir");
@@ -141,10 +141,10 @@ class PluginHost {
asort($plugins);
- $this->load(join(",", $plugins), $kind, $owner_uid);
+ $this->load(join(",", $plugins), $kind, $owner_uid, $skip_init);
}
- function load($classlist, $kind, $owner_uid = false) {
+ function load($classlist, $kind, $owner_uid = false, $skip_init = false) {
$plugins = explode(",", $classlist);
$this->owner_uid = (int) $owner_uid;
@@ -181,18 +181,18 @@ class PluginHost {
switch ($kind) {
case $this::KIND_SYSTEM:
if ($this->is_system($plugin)) {
- $plugin->init($this);
+ if (!$skip_init) $plugin->init($this);
$this->register_plugin($class, $plugin);
}
break;
case $this::KIND_USER:
if (!$this->is_system($plugin)) {
- $plugin->init($this);
+ if (!$skip_init) $plugin->init($this);
$this->register_plugin($class, $plugin);
}
break;
case $this::KIND_ALL:
- $plugin->init($this);
+ if (!$skip_init) $plugin->init($this);
$this->register_plugin($class, $plugin);
break;
}
diff --git a/classes/pref/feeds.php b/classes/pref/feeds.php
index a29b2acca..e839af34e 100644
--- a/classes/pref/feeds.php
+++ b/classes/pref/feeds.php
@@ -1461,8 +1461,10 @@ class Pref_Feeds extends Handler_Protected {
print "<hr>";
+ $opml_export_filename = "TinyTinyRSS_".date("Y-m-d").".opml";
+
print "<p>" . __('Filename:') .
- " <input type=\"text\" id=\"filename\" value=\"TinyTinyRSS.opml\" />&nbsp;" .
+ " <input type=\"text\" id=\"filename\" value=\"$opml_export_filename\" />&nbsp;" .
__('Include settings') . "<input type=\"checkbox\" id=\"settings\" checked=\"1\"/>";
print "</p><button dojoType=\"dijit.form.Button\"
diff --git a/classes/pref/filters.php b/classes/pref/filters.php
index a371fcff4..d768a136f 100644..100755
--- a/classes/pref/filters.php
+++ b/classes/pref/filters.php
@@ -43,8 +43,12 @@ class Pref_Filters extends Handler_Protected {
return;
}
+ function testFilterDo() {
+ require_once "include/rssfuncs.php";
+
+ $offset = (int) db_escape_string($_REQUEST["offset"]);
+ $limit = (int) db_escape_string($_REQUEST["limit"]);
- function testFilter() {
$filter = array();
$filter["enabled"] = true;
@@ -94,24 +98,14 @@ class Pref_Filters extends Handler_Protected {
}
}
- $found = 0;
- $offset = 0;
- $limit = 30;
- $started = time();
-
- print __("Articles matching this filter:");
-
- require_once "include/rssfuncs.php";
-
- print "<div class=\"filterTestHolder\">";
- print "<table width=\"100%\" cellspacing=\"0\" id=\"prefErrorFeedList\">";
-
$glue = $filter['match_any_rule'] ? " OR " : " AND ";
$scope_qpart = join($glue, $scope_qparts);
if (!$scope_qpart) $scope_qpart = "true";
- while ($found < $limit && $offset < $limit * 10 && time() - $started < ini_get("max_execution_time") * 0.7) {
+ $rv = array();
+
+ //while ($found < $limit && $offset < $limit * 1000 && time() - $started < ini_get("max_execution_time") * 0.7) {
$result = db_query("SELECT ttrss_entries.id,
ttrss_entries.title,
@@ -119,6 +113,7 @@ class Pref_Filters extends Handler_Protected {
ttrss_feeds.title AS feed_title,
ttrss_feed_categories.id AS cat_id,
content,
+ date_entered,
link,
author,
tag_cache
@@ -139,7 +134,7 @@ class Pref_Filters extends Handler_Protected {
if (count($rc) > 0) {
- $line["content_preview"] = truncate_string(strip_tags($line["content"]), 100, '...');
+ $line["content_preview"] = truncate_string(strip_tags($line["content"]), 200, '&hellip;');
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) {
$line = $p->hook_query_headlines($line, 100);
@@ -147,16 +142,16 @@ class Pref_Filters extends Handler_Protected {
$content_preview = $line["content_preview"];
- if ($line["feed_title"]) $feed_title = "(" . $line["feed_title"] . ")";
+ $tmp = "<tr style='margin-top : 5px'>";
- print "<tr>";
+ #$tmp .= "<td width='5%' align='center'><input dojoType=\"dijit.form.CheckBox\"
+ # checked=\"1\" disabled=\"1\" type=\"checkbox\"></td>";
- print "<td width='5%' align='center'><input dojoType=\"dijit.form.CheckBox\"
- checked=\"1\" disabled=\"1\" type=\"checkbox\"></td>";
- print "<td>";
+ $id = $line['id'];
+ $tmp .= "<td width='5%' align='center'><img style='cursor : pointer' title='".__("Preview article")."'
+ src='images/information.png' onclick='openArticlePopup($id)'></td><td>";
/*foreach ($filter['rules'] as $rule) {
- $reg_exp = $rule['reg_exp'];
$reg_exp = str_replace('/', '\/', $rule["reg_exp"]);
$line["title"] = preg_replace("/($reg_exp)/i",
@@ -166,25 +161,42 @@ class Pref_Filters extends Handler_Protected {
"<span class=\"highlight\">$1</span>", $content_preview);
}*/
- print $line["title"];
- print "<div class='small' style='float : right'>" . $feed_title . "</div>";
- print "<div class=\"insensitive\">" . $content_preview . "</div>";
- print " " . mb_substr($line["date_entered"], 0, 16);
+ $tmp .= "<strong>" . $line["title"] . "</strong><br/>";
+ $tmp .= $line['feed_title'] . ", " . mb_substr($line["date_entered"], 0, 16);
+ $tmp .= "<div class='insensitive'>" . $content_preview . "</div>";
+ $tmp .= "</td></tr>";
+
+ array_push($rv, $tmp);
- print "</td></tr>";
+ /*array_push($rv, array("title" => $line["title"],
+ "content" => $content_preview,
+ "date" => $line["date_entered"],
+ "feed" => $line["feed_title"])); */
- $found++;
}
}
- $offset += $limit;
- }
+ //$offset += $limit;
+ //}
- if ($found == 0) {
+ /*if ($found == 0) {
print "<tr><td align='center'>" .
__("No recent articles matching this filter have been found.");
- }
+ }*/
+
+ print json_encode($rv);
+ }
+
+ function testFilter() {
+
+ if (isset($_REQUEST["offset"])) return $this->testFilterDo();
+
+ //print __("Articles matching this filter:");
+
+ print "<div><img id='prefFilterLoadingIndicator' src='images/indicator_tiny.gif'>&nbsp;<span id='prefFilterProgressMsg'>Looking for articles...</span></div>";
+ print "<br/><div class=\"filterTestHolder\">";
+ print "<table width=\"100%\" cellspacing=\"0\" id=\"prefFilterTestResultList\">";
print "</table></div>";
print "<div style='text-align : center'>";
diff --git a/classes/pref/prefs.php b/classes/pref/prefs.php
index 41dc536f5..9cbc425c6 100644
--- a/classes/pref/prefs.php
+++ b/classes/pref/prefs.php
@@ -746,7 +746,7 @@ class Pref_Prefs extends Handler_Protected {
$user_enabled = array_map("trim", explode(",", get_pref("_ENABLED_PLUGINS")));
$tmppluginhost = new PluginHost();
- $tmppluginhost->load_all($tmppluginhost::KIND_ALL, $_SESSION["uid"]);
+ $tmppluginhost->load_all($tmppluginhost::KIND_ALL, $_SESSION["uid"], true);
$tmppluginhost->load_data(true);
foreach ($tmppluginhost->get_plugins() as $name => $plugin) {
diff --git a/classes/rpc.php b/classes/rpc.php
index a84883bfa..1c733ffca 100644..100755
--- a/classes/rpc.php
+++ b/classes/rpc.php
@@ -123,7 +123,7 @@ class RPC extends Handler_Protected {
$key = $_REQUEST['key'];
$value = str_replace("\n", "<br/>", $_REQUEST['value']);
- set_pref($key, $value, $_SESSION['uid'], $key != 'USER_STYLESHEET');
+ set_pref($key, $value, false, $key != 'USER_STYLESHEET');
print json_encode(array("param" =>$key, "value" => $value));
}