]> git.wh0rd.org - tt-rss.git/blobdiff - include/functions2.php
add a wrapper for standard error codes returned by backend, also add explanation...
[tt-rss.git] / include / functions2.php
index 13b92225e607e6462996740c3cbae94c2c494032..a73f9a7a786342f0563e77680937fdbaffefbee0 100644 (file)
                $data['reload_on_ts_change'] = !defined('_NO_RELOAD_ON_TS_CHANGE');
 
 
-               if (true || $_SESSION["last_version_check"] + 86400 + rand(-1000, 1000) < time()) {
+               if (CHECK_FOR_UPDATES && $_SESSION["last_version_check"] + 86400 + rand(-1000, 1000) < time()) {
                        $update_result = @check_for_update();
 
                        $data["update_result"] = $update_result;
                                        else
                                                array_push($query_keywords, "($not (published = false))");
 
+                               } else {
+                                       array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER('%$k%')
+                                                       OR UPPER(ttrss_entries.content) $not LIKE UPPER('%$k%'))");
+                                       if (!$not) array_push($search_words, $k);
+                               }
+                               break;
+                       case "unread":
+                               if ($commandpair[1]) {
+                                       if ($commandpair[1] == "true")
+                                               array_push($query_keywords, "($not (unread = true))");
+                                       else
+                                               array_push($query_keywords, "($not (unread = false))");
+
                                } else {
                                        array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER('%$k%')
                                                        OR UPPER(ttrss_entries.content) $not LIKE UPPER('%$k%'))");
 
                        $order_by = "score DESC, date_entered DESC, updated DESC";
 
-                       if ($view_mode == "unread_first") {
-                               $order_by = "unread DESC, $order_by";
-                       }
-
                        if ($override_order) {
                                $order_by = $override_order;
                        }
                                        $cached_filename = CACHE_DIR . '/images/' . sha1($src) . '.png';
 
                                        if (file_exists($cached_filename)) {
-                                               $src = SELF_URL_PATH . '/image.php?hash=' . sha1($src);
+                                               $src = SELF_URL_PATH . '/public.php?op=cached_image&hash=' . sha1($src);
                                        }
 
                                        $entry->setAttribute('src', $src);
 
                return false;
        }
+
+       function error_json($code) {
+               require_once "errors.php";
+
+               @$message = $ERRORS[$code];
+
+               return json_encode(array("error" =>
+                       array("code" => $code, "message" => $message)));
+
+       }
 ?>