diff options
author | Art4 <[email protected]> | 2015-02-19 23:17:43 +0100 |
---|---|---|
committer | Art4 <[email protected]> | 2015-02-19 23:17:43 +0100 |
commit | d9c042c4c536f1afbf206aeea09b0b127b7b6418 (patch) | |
tree | 9d7ef18c6d9d4c8f8f4d1c9a5dbfceeb9fd5acf4 /classes | |
parent | cf42b79120290ee5866136a0c4656e6999f06045 (diff) | |
parent | 4ca621a36016de1fbb5447e1c1de0b607ba94a7c (diff) |
Merge branch 'master' into patch-1
Conflicts:
locale/de_DE/LC_MESSAGES/messages.po
Diffstat (limited to 'classes')
-rw-r--r-- | classes/api.php | 53 | ||||
-rw-r--r-- | classes/dlg.php | 47 | ||||
-rw-r--r-- | classes/feeditem/rss.php | 8 | ||||
-rw-r--r-- | classes/feedparser.php | 1 | ||||
-rw-r--r-- | classes/handler/public.php | 5 | ||||
-rw-r--r-- | classes/opml.php | 2 | ||||
-rw-r--r-- | classes/pref/feeds.php | 6 | ||||
-rw-r--r-- | classes/pref/prefs.php | 3 |
8 files changed, 65 insertions, 60 deletions
diff --git a/classes/api.php b/classes/api.php index 6bcb92152..3c5d08408 100644 --- a/classes/api.php +++ b/classes/api.php @@ -2,7 +2,7 @@ class API extends Handler { - const API_LEVEL = 8; + const API_LEVEL = 11; const STATUS_OK = 0; const STATUS_ERR = 1; @@ -200,6 +200,11 @@ class API extends Handler { $include_nested = sql_bool_to_bool($_REQUEST["include_nested"]); $sanitize_content = !isset($_REQUEST["sanitize"]) || sql_bool_to_bool($_REQUEST["sanitize"]); + $force_update = sql_bool_to_bool($_REQUEST["force_update"]); + $has_sandbox = sql_bool_to_bool($_REQUEST["has_sandbox"]); + $excerpt_length = (int)$this->dbh->escape_string($_REQUEST["excerpt_length"]); + + $_SESSION['hasSandbox'] = $has_sandbox; $override_order = false; switch ($_REQUEST["order_by"]) { @@ -222,7 +227,7 @@ class API extends Handler { $headlines = $this->api_get_headlines($feed_id, $limit, $offset, $filter, $is_cat, $show_excerpt, $show_content, $view_mode, $override_order, $include_attachments, $since_id, $search, $search_mode, - $include_nested, $sanitize_content); + $include_nested, $sanitize_content, $force_update, $excerpt_length); $this->wrap(self::STATUS_OK, $headlines); } else { @@ -632,7 +637,28 @@ class API extends Handler { $filter, $is_cat, $show_excerpt, $show_content, $view_mode, $order, $include_attachments, $since_id, $search = "", $search_mode = "", - $include_nested = false, $sanitize_content = true) { + $include_nested = false, $sanitize_content = true, $force_update = false, $excerpt_length = 100) { + + 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 + FROM 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' + WHERE id = '$feed_id'"); + } + } + } $qfh_ret = queryFeedHeadlines($feed_id, $limit, $view_mode, $is_cat, $search, $search_mode, @@ -644,16 +670,31 @@ class API extends Handler { $headlines = array(); while ($line = db_fetch_assoc($result)) { - $line["content_preview"] = truncate_string(strip_tags($line["content"]), 100); + $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, 100, true); + $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"]); - $labels = json_decode($line["label_cache"], true); + + $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"]); diff --git a/classes/dlg.php b/classes/dlg.php index 25a194bed..e3931bc3a 100644 --- a/classes/dlg.php +++ b/classes/dlg.php @@ -220,52 +220,5 @@ class Dlg extends Handler_Protected { //return; } - function newVersion() { - - $version_data = check_for_update(); - $version = $version_data['version']; - $id = $version_data['version_id']; - - if ($version && $id) { - print "<div class='tagCloudContainer'>"; - - print T_sprintf("New version of Tiny Tiny RSS is available (%s).", - "<b>$version</b>"); - - print "</div>"; - - $details = "http://tt-rss.org/redmine/versions/$id"; - $download = "http://tt-rss.org/#Download"; - - print "<p align='center'>".__("You can update using built-in updater in the Preferences or by using update.php")."</p>"; - - print "<div style='text-align : center'>"; - print "<button dojoType=\"dijit.form.Button\" - onclick=\"return window.open('$details')\">".__("See the release notes")."</button>"; - print "<button dojoType=\"dijit.form.Button\" - onclick=\"return window.open('$download')\">".__("Download")."</button>"; - print "<button dojoType=\"dijit.form.Button\" - onclick=\"return dijit.byId('newVersionDlg').hide()\">". - __('Close this window')."</button>"; - - } else { - print "<div class='tagCloudContainer'>"; - - print "<p align='center'>".__("Error receiving version information or no new version available.")."</p>"; - - print "</div>"; - - print "<div style='text-align : center'>"; - print "<button dojoType=\"dijit.form.Button\" - onclick=\"return dijit.byId('newVersionDlg').hide()\">". - __('Close this window')."</button>"; - print "</div>"; - - } - print "</div>"; - - } - - } ?> diff --git a/classes/feeditem/rss.php b/classes/feeditem/rss.php index c9a7467cd..27a364b81 100644 --- a/classes/feeditem/rss.php +++ b/classes/feeditem/rss.php @@ -51,6 +51,14 @@ class FeedItem_RSS extends FeedItem_Common { } function get_title() { + $title = $this->xpath->query("title", $this->elem)->item(0); + + if ($title) { + return trim($title->nodeValue); + } + + // if the document has a default namespace then querying for + // title would fail because of reasons so let's try the old way $title = $this->elem->getElementsByTagName("title")->item(0); if ($title) { diff --git a/classes/feedparser.php b/classes/feedparser.php index 239fdb7a6..30af6f62e 100644 --- a/classes/feedparser.php +++ b/classes/feedparser.php @@ -115,6 +115,7 @@ class FeedParser { $this->type = $this::FEED_RSS; break; case "feed": + case "atom:feed": $this->type = $this::FEED_ATOM; break; default: diff --git a/classes/handler/public.php b/classes/handler/public.php index e89318c6f..34d577441 100644 --- a/classes/handler/public.php +++ b/classes/handler/public.php @@ -39,11 +39,10 @@ class Handler_Public extends Handler { //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) { - $qfh_ret = queryFeedHeadlines($feed, 1, $view_mode, $is_cat, $search, $search_mode, $date_sort_field, $offset, $owner_uid, - false, 0, false, true, false, false, $start_ts); + false, 0, true, true, false, false, $start_ts); $result = $qfh_ret[0]; @@ -64,7 +63,7 @@ class Handler_Public extends Handler { $qfh_ret = queryFeedHeadlines($feed, $limit, $view_mode, $is_cat, $search, $search_mode, $date_sort_field, $offset, $owner_uid, - false, 0, false, true, false, false, $start_ts); + false, 0, true, true, false, false, $start_ts); $result = $qfh_ret[0]; diff --git a/classes/opml.php b/classes/opml.php index c8c59e8a2..04516dde4 100644 --- a/classes/opml.php +++ b/classes/opml.php @@ -491,7 +491,9 @@ class Opml extends Handler_Protected { if (is_file($tmp_file)) { $doc = new DOMDocument(); + libxml_disable_entity_loader(false); $doc->load($tmp_file); + libxml_disable_entity_loader(true); unlink($tmp_file); } else if (!$doc) { print_error(__('Error: unable to find moved OPML file.')); diff --git a/classes/pref/feeds.php b/classes/pref/feeds.php index 43b474278..d70c1a26a 100644 --- a/classes/pref/feeds.php +++ b/classes/pref/feeds.php @@ -495,7 +495,7 @@ class Pref_Feeds extends Handler_Protected { $feed_id = $this->dbh->escape_string($_REQUEST["feed_id"]); if (is_file($icon_file) && $feed_id) { - if (filesize($icon_file) < 20000) { + if (filesize($icon_file) < 65535) { $result = $this->dbh->query("SELECT id FROM ttrss_feeds WHERE id = '$feed_id' AND owner_uid = ". $_SESSION["uid"]); @@ -738,9 +738,9 @@ class Pref_Feeds extends Handler_Protected { <input type=\"hidden\" name=\"op\" value=\"pref-feeds\"> <input type=\"hidden\" name=\"feed_id\" value=\"$feed_id\"> <input type=\"hidden\" name=\"method\" value=\"uploadicon\"> - <button dojoType=\"dijit.form.Button\" onclick=\"return uploadFeedIcon();\" + <button class=\"small\" dojoType=\"dijit.form.Button\" onclick=\"return uploadFeedIcon();\" type=\"submit\">".__('Replace')."</button> - <button dojoType=\"dijit.form.Button\" onclick=\"return removeFeedIcon($feed_id);\" + <button class=\"small\" dojoType=\"dijit.form.Button\" onclick=\"return removeFeedIcon($feed_id);\" type=\"submit\">".__('Remove')."</button> </form>"; diff --git a/classes/pref/prefs.php b/classes/pref/prefs.php index 571237239..da11f55e1 100644 --- a/classes/pref/prefs.php +++ b/classes/pref/prefs.php @@ -571,7 +571,8 @@ class Pref_Prefs extends Handler_Protected { } else if ($pref_name == "USER_CSS_THEME") { - $themes = array_map("basename", glob("themes/*.css")); + $themes = array_filter(array_map("basename", glob("themes/*.css")), + "theme_valid"); print_select($pref_name, $value, $themes, 'dojoType="dijit.form.Select"'); |