diff options
Diffstat (limited to 'include/functions.php')
| -rw-r--r-- | include/functions.php | 97 |
1 files changed, 38 insertions, 59 deletions
diff --git a/include/functions.php b/include/functions.php index c39b4938c..7db040d04 100644 --- a/include/functions.php +++ b/include/functions.php @@ -1162,7 +1162,7 @@ $data = array_merge($data, getVirtCounters()); $data = array_merge($data, getLabelCounters()); - $data = array_merge($data, getFeedCounters($active_feed)); + $data = array_merge($data, getFeedCounters()); $data = array_merge($data, getCategoryCounters()); return $data; @@ -1286,7 +1286,7 @@ return $unread; } else if ($cat == -1) { - return getFeedUnread(-1) + getFeedUnread($link, -2) + getFeedUnread($link, -3) + getFeedUnread($link, 0); + return getFeedUnread(-1) + getFeedUnread(-2) + getFeedUnread(-3) + getFeedUnread(0); } else if ($cat == -2) { $result = db_query(" @@ -1459,8 +1459,14 @@ $count = getFeedUnread($i); + if ($i == 0 || $i == -1 || $i == -2) + $auxctr = getFeedArticles($i, false); + else + $auxctr = 0; + $cv = array("id" => $i, - "counter" => (int) $count); + "counter" => (int) $count, + "auxcounter" => $auxctr); // if (get_pref('EXTENDED_FEEDLIST')) // $cv["xmsg"] = getFeedArticles($i)." ".__("total"); @@ -1487,11 +1493,13 @@ $owner_uid = $_SESSION["uid"]; - $result = db_query("SELECT id,caption,COUNT(unread) AS unread + $result = db_query("SELECT id,caption,COUNT(u1.unread) AS unread,COUNT(u2.unread) AS total FROM ttrss_labels2 LEFT JOIN ttrss_user_labels2 ON (ttrss_labels2.id = label_id) - LEFT JOIN ttrss_user_entries ON (ref_id = article_id AND unread = true - AND ttrss_user_entries.owner_uid = $owner_uid) + LEFT JOIN ttrss_user_entries AS u1 ON (u1.ref_id = article_id AND u1.unread = true + AND u1.owner_uid = $owner_uid) + LEFT JOIN ttrss_user_entries AS u2 ON (u2.ref_id = article_id AND u2.unread = false + AND u2.owner_uid = $owner_uid) WHERE ttrss_labels2.owner_uid = $owner_uid GROUP BY ttrss_labels2.id, ttrss_labels2.caption"); @@ -1499,17 +1507,12 @@ $id = label_to_feed_id($line["id"]); - $label_name = $line["caption"]; - $count = $line["unread"]; - $cv = array("id" => $id, - "counter" => (int) $count); + "counter" => (int) $line["unread"], + "auxcounter" => (int) $line["total"]); if ($descriptions) - $cv["description"] = $label_name; - -// if (get_pref('EXTENDED_FEEDLIST')) -// $cv["xmsg"] = getFeedArticles($id)." ".__("total"); + $cv["description"] = $line["caption"]; array_push($ret_arr, $cv); } @@ -1726,7 +1729,8 @@ } if (!$root_id) { - $is_selected = ($default_id == "CAT:0") ? "selected=\"1\"" : ""; + $default_is_cat = ($default_id == "CAT:0"); + $is_selected = $default_is_cat ? "selected=\"1\"" : ""; printf("<option $is_selected value='CAT:0'>%s</option>", __("Uncategorized")); @@ -2327,8 +2331,10 @@ $filter_query_part = filter_to_sql($filter, $owner_uid); // Try to check if SQL regexp implementation chokes on a valid regexp + + $result = db_query("SELECT true AS true_val FROM ttrss_entries, - ttrss_user_entries, ttrss_feeds, ttrss_feed_categories + ttrss_user_entries, ttrss_feeds WHERE $filter_query_part LIMIT 1", false); if ($result) { @@ -2844,8 +2850,7 @@ if ($version_data) { $version_data = json_decode($version_data, true); if ($version_data && $version_data['version']) { - - if (version_compare(VERSION, $version_data['version']) == -1) { + if (version_compare(VERSION_STATIC, $version_data['version']) == -1) { return $version_data; } } @@ -2902,7 +2907,6 @@ ttrss_tags WHERE post_int_id = (SELECT int_id FROM ttrss_user_entries WHERE ref_id = '$a_id' AND owner_uid = '$owner_uid' LIMIT 1) ORDER BY tag_name"; - $obj_id = md5("TAGS:$owner_uid:$id"); $tags = array(); /* check cache first */ @@ -3119,7 +3123,7 @@ $rv['content'] .= "<html><head> <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/> <title>Tiny Tiny RSS - ".$line["title"]."</title> - <link rel=\"stylesheet\" type=\"text/css\" href=\"tt-rss.css\"> + <link rel=\"stylesheet\" type=\"text/css\" href=\"css/tt-rss.css\"> </head><body id=\"ttrssZoom\">"; } @@ -3249,7 +3253,7 @@ function print_checkpoint($n, $s) { $ts = microtime(true); - echo sprintf("<!-- CP[$n] %.4f seconds -->", $ts - $s); + echo sprintf("<!-- CP[$n] %.4f seconds -->\n", $ts - $s); return $ts; } @@ -3392,47 +3396,22 @@ } function format_tags_string($tags, $id) { + if (!is_array($tags) || count($tags) == 0) { + return __("no tags"); + } else { + $maxtags = min(5, count($tags)); - $tags_str = ""; - $tags_nolinks_str = ""; - - $num_tags = 0; - - $tag_limit = 6; - - $formatted_tags = array(); - - foreach ($tags as $tag) { - $num_tags++; - $tag_escaped = str_replace("'", "\\'", $tag); - - if (mb_strlen($tag) > 30) { - $tag = truncate_string($tag, 30); - } - - $tag_str = "<a href=\"javascript:viewfeed('$tag_escaped')\">$tag</a>"; - - array_push($formatted_tags, $tag_str); - - $tmp_tags_str = implode(", ", $formatted_tags); - - if ($num_tags == $tag_limit || mb_strlen($tmp_tags_str) > 150) { - break; + for ($i = 0; $i < $maxtags; $i++) { + $tags_str .= "<a class=\"tag\" href=\"#\" onclick=\"viewfeed('".$tags[$i]."'\")>" . $tags[$i] . "</a>, "; } - } - $tags_str = implode(", ", $formatted_tags); + $tags_str = mb_substr($tags_str, 0, mb_strlen($tags_str)-2); - if ($num_tags < count($tags)) { - $tags_str .= ", …"; - } + if (count($tags) > $maxtags) + $tags_str .= ", …"; - if ($num_tags == 0) { - $tags_str = __("no tags"); + return $tags_str; } - - return $tags_str; - } function format_article_labels($labels, $id) { @@ -4125,7 +4104,7 @@ preg_match("/(Location:|URI:)[^(\n)]*/", $header, $matches); $url = trim(str_replace($matches[1],"",$matches[0])); $url_parsed = parse_url($url); - return (isset($url_parsed))? geturl($url, $referer):''; + return (isset($url_parsed))? geturl($url):''; } $oline=''; foreach($status as $key=>$eline){$oline.='['.$key.']'.$eline.' ';} @@ -4144,7 +4123,7 @@ foreach ($files as $js) { if (!isset($_GET['debug'])) { - $cached_file = CACHE_DIR . "/js/$js.js"; + $cached_file = CACHE_DIR . "/js/".basename($js).".js"; if (file_exists($cached_file) && is_readable($cached_file) && @@ -4187,7 +4166,7 @@ } function calculate_dep_timestamp() { - $files = array_merge(glob("js/*.js"), glob("*.css")); + $files = array_merge(glob("js/*.js"), glob("css/*.css")); $max_ts = -1; |