]> git.wh0rd.org - tt-rss.git/blobdiff - include/functions.php
use favicon in some auxiliar dialogs
[tt-rss.git] / include / functions.php
index 8ede14a0bfa7a188b036d8ac704aff70dd7c22a9..7e08d22965af8ff3dcff13c4a3e12f216f188f40 100644 (file)
@@ -1,6 +1,6 @@
 <?php
        define('EXPECTED_CONFIG_VERSION', 26);
-       define('SCHEMA_VERSION', 122);
+       define('SCHEMA_VERSION', 123);
 
        define('LABEL_BASE_INDEX', -1024);
        define('PLUGIN_FEED_BASE_INDEX', -128);
@@ -11,6 +11,7 @@
        $fetch_last_error_code = false;
        $fetch_last_content_type = false;
        $fetch_curl_used = false;
+       $suppress_debugging = false;
 
        mb_internal_encoding("UTF-8");
        date_default_timezone_set('UTC');
 
        $schema_version = false;
 
+       function _debug_suppress($suppress) {
+               global $suppress_debugging;
+
+               $suppress_debugging = $suppress;
+       }
+
        /**
         * Print a timestamped debug message.
         *
         * @return void
         */
        function _debug($msg, $show = true) {
-               if (defined('SUPPRESS_DEBUGGING'))
-                       return false;
+               global $suppress_debugging;
+
+               //echo "[$suppress_debugging] $msg $show\n";
+
+               if ($suppress_debugging) return false;
 
                $ts = strftime("%H:%M:%S", time());
                if (function_exists('posix_getpid')) {
 
                $owner_uid = $_SESSION["uid"];
 
-               $result = db_query("SELECT id,caption,COUNT(u1.unread) AS unread,COUNT(u2.unread) AS total
+               $result = db_query("SELECT id,caption,SUM(CASE WHEN u1.unread = true THEN 1 ELSE 0 END) AS unread, COUNT(u1.unread) AS total
                        FROM ttrss_labels2 LEFT JOIN ttrss_user_labels2 ON
                                (ttrss_labels2.id = label_id)
-                               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)
+                               LEFT JOIN ttrss_user_entries AS u1 ON u1.ref_id = article_id
                                WHERE ttrss_labels2.owner_uid = $owner_uid GROUP BY ttrss_labels2.id,
                                        ttrss_labels2.caption");
 
                $result = db_query("SELECT id,title,link,content,feed_id,comments,int_id,lang,
                        ".SUBSTRING_FOR_DATE."(updated,1,16) as updated,
                        (SELECT site_url FROM ttrss_feeds WHERE id = feed_id) as site_url,
+                       (SELECT title FROM ttrss_feeds WHERE id = feed_id) as feed_title,
                        (SELECT hide_images FROM ttrss_feeds WHERE id = feed_id) as hide_images,
                        (SELECT always_display_enclosures FROM ttrss_feeds WHERE id = feed_id) as always_display_enclosures,
                        num_comments,
                                } else {
                                        $comments_url = htmlspecialchars($line["link"]);
                                }
-                               $entry_comments = "<a target='_blank' href=\"$comments_url\">$num_comments comments</a>";
+                               $entry_comments = "<a class=\"postComments\"
+                                       target='_blank' href=\"$comments_url\">$num_comments ".
+                                       _ngettext("comment", "comments", $num_comments)."</a>";
+
                        } else {
                                if ($line["comments"] && $line["link"] != $line["comments"]) {
-                                       $entry_comments = "<a target='_blank' href=\"".htmlspecialchars($line["comments"])."\">comments</a>";
+                                       $entry_comments = "<a class=\"postComments\" target='_blank' href=\"".htmlspecialchars($line["comments"])."\">".__("comments")."</a>";
                                }
                        }
 
                                                <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=\"css/tt-rss.css\">
+                                               <link rel=\"shortcut icon\" type=\"image/png\" href=\"images/favicon.png\">
+                                               <link rel=\"icon\" type=\"image/png\" sizes=\"72x72\" href=\"images/favicon-72px.png\">
+
                                                <script type=\"text/javascript\">
                                                function openSelectedAttachment(elem) {
                                                        try {
                                $rv['content'] .= "<div class='postTitle'>" . $line["title"] . "$entry_author</div>";
                        }
 
-                       if ($zoom_mode)
+                       if ($zoom_mode) {
+                               $feed_title = "<a href=\"".htmlspecialchars($line["site_url"]).
+                                       "\" target=\"_blank\">".
+                                       htmlspecialchars($line["feed_title"])."</a>";
+
+                               $rv['content'] .= "<div class=\"postFeedTitle\">$feed_title</div>";
+
                                $rv['content'] .= "<div class=\"postDate\">$parsed_updated</div>";
+                       }
 
                        $tags_str = format_tags_string($line["tags"], $id);
                        $tags_str_full = join(", ", $line["tags"]);