Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into german-translation
Browse files Browse the repository at this point in the history
  • Loading branch information
HeikoAdams committed Nov 30, 2015
2 parents 635ecdb + 6f5d9c6 commit 0576178
Show file tree
Hide file tree
Showing 100 changed files with 45,666 additions and 48,186 deletions.
27 changes: 21 additions & 6 deletions classes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class API extends Handler {

const API_LEVEL = 12;
const API_LEVEL = 13;

const STATUS_OK = 0;
const STATUS_ERR = 1;
Expand Down Expand Up @@ -210,13 +210,16 @@ function getHeadlines() {

$_SESSION['hasSandbox'] = $has_sandbox;

$skip_first_id_check = false;

$override_order = false;
switch ($_REQUEST["order_by"]) {
case "title":
$override_order = "ttrss_entries.title";
break;
case "date_reverse":
$override_order = "score DESC, date_entered, updated";
$skip_first_id_check = true;
break;
case "feed_dates":
$override_order = "updated DESC";
Expand All @@ -230,7 +233,7 @@ function getHeadlines() {
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));
Expand Down Expand Up @@ -322,13 +325,17 @@ function updateArticle() {
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"] ;
Expand All @@ -354,7 +361,6 @@ function getArticle() {
"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"],
Expand All @@ -363,6 +369,15 @@ function getArticle() {
"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));
}
Expand Down Expand Up @@ -644,7 +659,7 @@ 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) {
$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
Expand Down Expand Up @@ -687,7 +702,7 @@ static function api_get_headlines($feed_id, $limit, $offset,
"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);
Expand Down
4 changes: 2 additions & 2 deletions classes/article.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ function view() {
} 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;
}
Expand Down
10 changes: 7 additions & 3 deletions classes/feeds.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ private function format_headline_subtoolbar($feed_site_url, $feed_title,

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;

Expand Down Expand Up @@ -252,7 +253,8 @@ private function format_headlines_list($feed, $method, $view_mode, $limit, $cat_
"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);
Expand Down Expand Up @@ -903,13 +905,15 @@ function view() {
$reply['headlines'] = array();

$override_order = false;
$skip_first_id_check = false;

switch ($order_by) {
case "title":
$override_order = "ttrss_entries.title";
break;
case "date_reverse":
$override_order = "score DESC, date_entered, updated";
$skip_first_id_check = true;
break;
case "feed_dates":
$override_order = "updated DESC";
Expand All @@ -920,7 +924,7 @@ function view() {

$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];
Expand Down
12 changes: 6 additions & 6 deletions classes/pluginhost.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,18 +133,18 @@ function get_hooks($type) {
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");
$plugins = array_map("basename", $plugins);

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;
Expand Down Expand Up @@ -181,18 +181,18 @@ function load($classlist, $kind, $owner_uid = false) {
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;
}
Expand Down
4 changes: 3 additions & 1 deletion classes/pref/feeds.php
Original file line number Diff line number Diff line change
Expand Up @@ -1461,8 +1461,10 @@ function index() {

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\"
Expand Down
74 changes: 43 additions & 31 deletions classes/pref/filters.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,12 @@ function savefilterorder() {
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;
Expand Down Expand Up @@ -94,31 +98,22 @@ function testFilter() {
}
}

$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,
ttrss_feeds.id AS feed_id,
ttrss_feeds.title AS feed_title,
ttrss_feed_categories.id AS cat_id,
content,
date_entered,
link,
author,
tag_cache
Expand All @@ -139,24 +134,24 @@ function testFilter() {

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);
}

$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",
Expand All @@ -166,25 +161,42 @@ function testFilter() {
"<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'>";
Expand Down
2 changes: 1 addition & 1 deletion classes/pref/prefs.php
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ function index() {
$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) {
Expand Down
2 changes: 1 addition & 1 deletion classes/rpc.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ function setpref() {
$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));
}
Expand Down
Loading

0 comments on commit 0576178

Please sign in to comment.