]> git.wh0rd.org - tt-rss.git/blobdiff - classes/feeds.php
implement mail plugin using mailto: links; deprecate mail plugin
[tt-rss.git] / classes / feeds.php
index b257ca35ed7f52766f6c7137ae1bfa87fb0861ed..5fa51768c5027761bd50600a7db99b28ffe8e39c 100644 (file)
@@ -126,6 +126,11 @@ class Feeds extends Handler_Protected {
                                "</option>";
                }
 
+               if ($pluginhost->get_plugin("mailto")) {
+                       $reply .= "<option value=\"mailtoArticle(false)\">".__('Forward by email').
+                               "</option>";
+               }
+
                $reply .= "<option value=\"0\" disabled=\"1\">".__('Feed:')."</option>";
 
                $reply .= "<option value=\"catchupPage()\">".__('Mark as read')."</option>";
@@ -152,7 +157,7 @@ class Feeds extends Handler_Protected {
 
                $reply = array();
 
-               $timing_info = getmicrotime();
+               $timing_info = microtime(true);
 
                $topmost_article_ids = array();
 
@@ -165,15 +170,14 @@ class Feeds extends Handler_Protected {
                        // Update the feed if required with some basic flood control
 
                        $result = db_query($this->link,
-                               "SELECT cache_images,cache_content,".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated
+                               "SELECT cache_images,".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated
                                        FROM ttrss_feeds WHERE id = '$feed'");
 
                                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"));
-                                       $cache_content = sql_bool_to_bool(db_fetch_result($result, 0, "cache_content"));
 
-                                       if (!$cache_images && !$cache_content && time() - $last_updated > 120 || isset($_REQUEST['DevForceUpdate'])) {
+                                       if (!$cache_images && time() - $last_updated > 120 || isset($_REQUEST['DevForceUpdate'])) {
                                                include "rssfuncs.php";
                                                update_rss_feed($this->link, $feed, true, true);
                                        } else {
@@ -198,27 +202,6 @@ class Feeds extends Handler_Protected {
                        }
                }
 
-               if (is_numeric($feed) && $feed > 0) {
-
-                       $result = db_query($this->link, "SELECT rtl_content FROM ttrss_feeds
-                               WHERE id = '$feed' AND owner_uid = " . $_SESSION["uid"]);
-
-                       if (db_num_rows($result) == 1) {
-                               $rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content"));
-                       } else {
-                               $rtl_content = false;
-                       }
-
-                       if ($rtl_content) {
-                               $rtl_tag = "dir=\"RTL\"";
-                       } else {
-                               $rtl_tag = "";
-                       }
-               } else {
-                       $rtl_tag = "";
-                       $rtl_content = false;
-               }
-
                @$search = db_escape_string($_REQUEST["query"]);
 
                if ($search) {
@@ -245,7 +228,6 @@ class Feeds extends Handler_Protected {
                $feed_title = $qfh_ret[1];
                $feed_site_url = $qfh_ret[2];
                $last_error = $qfh_ret[3];
-               $cache_content = true;
 
                $vgroup_last_feed = $vgr_last_feed;
 
@@ -411,6 +393,8 @@ class Feeds extends Handler_Protected {
                                        $feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"images/pub_set.svg\" alt=\"\">";
                                }
 
+                               $entry_site_url = $line["site_url"];
+
                                if (!get_pref($this->link, 'COMBINED_DISPLAY_MODE')) {
 
                                        if (get_pref($this->link, 'VFEED_GROUP_BY_FEED')) {
@@ -464,19 +448,18 @@ class Feeds extends Handler_Protected {
 
                                        $reply['content'] .= $labels_str;
 
-                                       if (!get_pref($this->link, 'VFEED_GROUP_BY_FEED') &&
-                                               defined('_SHOW_FEED_TITLE_IN_VFEEDS')) {
-                                               if (@$line["feed_title"]) {
-                                                       $reply['content'] .= "<span class=\"hlFeed\">
-                                                               (<a href=\"#\" onclick=\"viewfeed($feed_id)\">".
-                                                               $line["feed_title"]."</a>)
-                                                       </span>";
-                                               }
-                                       }
-
                                        $reply['content'] .= "</div>";
 
-                                       $reply['content'] .= "<span class=\"hlUpdated\">$updated_fmt</span>";
+                                       $reply['content'] .= "<span class=\"hlUpdated\">";
+
+                                       if (@$line["feed_title"]) {
+                                                       $reply['content'] .= "<div class=\"hlFeed\">
+                                                               <a href=\"#\" onclick=\"viewfeed($feed_id)\">".
+                                                               $line["feed_title"]."</a>
+                                                       </div>";
+                                               }
+
+                                       $reply['content'] .= "$updated_fmt</span>";
                                        $reply['content'] .= "<div class=\"hlRight\">";
 
                                        $reply['content'] .= $score_pic;
@@ -494,6 +477,16 @@ class Feeds extends Handler_Protected {
 
                                } else {
 
+                                       $line["tags"] = get_article_tags($this->link, $id, $_SESSION["uid"], $line["tag_cache"]);
+                                       unset($line["tag_cache"]);
+
+                                       $line["content"] = sanitize($this->link, $line["content_preview"],
+                                                       false, false, $entry_site_url);
+
+                                       foreach ($pluginhost->get_hooks($pluginhost::HOOK_RENDER_ARTICLE_CDM) as $p) {
+                                               $line = $p->hook_render_article_cdm($line);
+                                       }
+
                                        if (get_pref($this->link, 'VFEED_GROUP_BY_FEED') && $line["feed_title"]) {
                                                if ($feed_id != $vgroup_last_feed) {
 
@@ -524,15 +517,15 @@ class Feeds extends Handler_Protected {
                                        $mouseover_attrs = "onmouseover='postMouseIn($id)'
                                                onmouseout='postMouseOut($id)'";
 
-                                       $reply['content'] .= "<div class=\"$class\" $label_row_style
+                                       $reply['content'] .= "<div class=\"cdm $class\"
                                                id=\"RROW-$id\" $mouseover_attrs'>";
 
                                        $reply['content'] .= "<div class=\"cdmHeader\">";
 
-                                       $reply['content'] .= "<div>";
+                                       $reply['content'] .= "<div style=\"vertical-align : middle\">";
 
                                        $reply['content'] .= "<input dojoType=\"dijit.form.CheckBox\"
-                                                       type=\"checkbox\" onclick=\"toggleSelectRow2(this)\"
+                                                       type=\"checkbox\" onclick=\"toggleSelectRow2(this, false, true)\"
                                                        id=\"RCHK-$id\">";
 
                                        $reply['content'] .= "$marked_pic";
@@ -551,20 +544,10 @@ class Feeds extends Handler_Protected {
                                                target=\"_blank\" href=\"".
                                                htmlspecialchars($line["link"])."\">".
                                                $line["title"] .
-                                               " $entry_author</a>";
+                                               " <span class=\"author\">$entry_author</span></a>";
 
                                        $reply['content'] .= $labels_str;
 
-                                       if (!get_pref($this->link, 'VFEED_GROUP_BY_FEED') &&
-                                               defined('_SHOW_FEED_TITLE_IN_VFEEDS')) {
-                                               if (@$line["feed_title"]) {
-                                                       $reply['content'] .= "<span class=\"hlFeed\">
-                                                               (<a href=\"#\" onclick=\"viewfeed($feed_id)\">".
-                                                               $line["feed_title"]."</a>)
-                                                       </span>";
-                                               }
-                                       }
-
                                        if (!$expand_cdm)
                                                $content_hidden = "style=\"display : none\"";
                                        else
@@ -575,8 +558,18 @@ class Feeds extends Handler_Protected {
 
                                        $reply['content'] .= "</span>";
 
-                                       $reply['content'] .= "<div>";
+                                       if (!get_pref($this->link, 'VFEED_GROUP_BY_FEED')) {
+                                               if (@$line["feed_title"]) {
+                                                       $reply['content'] .= "<div class=\"hlFeed\">
+                                                               <a href=\"#\" onclick=\"viewfeed($feed_id)\">".
+                                                               $line["feed_title"]."</a>
+                                                       </div>";
+                                               }
+                                       }
+
                                        $reply['content'] .= "<span class='updated'>$updated_fmt</span>";
+
+                                       $reply['content'] .= "<div style=\"vertical-align : middle\">";
                                        $reply['content'] .= "$score_pic";
 
                                        if (!get_pref($this->link, "VFEED_GROUP_BY_FEED") && $line["feed_title"]) {
@@ -592,6 +585,13 @@ class Feeds extends Handler_Protected {
                                                onclick=\"return cdmClicked(event, $id);\"
                                                id=\"CICD-$id\">";
 
+                                       $reply['content'] .= "<div id=\"POSTNOTE-$id\">";
+                                       if ($line['note']) {
+                                               $reply['content'] .= format_article_note($id, $line['note']);
+                                       }
+                                       $reply['content'] .= "</div>";
+
+
                                        $reply['content'] .= "<div class=\"cdmContentInner\">";
 
                        if ($line["orig_feed_id"]) {
@@ -621,23 +621,8 @@ class Feeds extends Handler_Protected {
                                                }
                                        }
 
-                                       $feed_site_url = $line["site_url"];
-
-                                       if ($cache_content && $line["cached_content"] != "") {
-                                               $line["content_preview"] =& $line["cached_content"];
-                                       }
-
-                                       $article_content = sanitize($this->link, $line["content_preview"],
-                                                       false, false, $feed_site_url);
-
-                                       $reply['content'] .= "<div id=\"POSTNOTE-$id\">";
-                                       if ($line['note']) {
-                                               $reply['content'] .= format_article_note($id, $line['note']);
-                                       }
-                                       $reply['content'] .= "</div>";
-
                                        $reply['content'] .= "<span id=\"CWRAP-$id\">";
-                                       $reply['content'] .= $article_content;
+                                       $reply['content'] .= $line["content"];
                                        $reply['content'] .= "</span>";
 
 /*                                     $tmp_result = db_query($this->link, "SELECT always_display_enclosures FROM
@@ -651,17 +636,13 @@ class Feeds extends Handler_Protected {
                                        $always_display_enclosures = sql_bool_to_bool($line["always_display_enclosures"]);
 
                                        $reply['content'] .= format_article_enclosures($this->link, $id, $always_display_enclosures,
-                                               $article_content);
+                                               $line["content"]);
 
                                        $reply['content'] .= "</div>";
 
                                        $reply['content'] .= "<div class=\"cdmFooter\">";
 
-                                       $tag_cache = $line["tag_cache"];
-
-                                       $tags_str = format_tags_string(
-                                               get_article_tags($this->link, $id, $_SESSION["uid"], $tag_cache),
-                                               $id);
+                                       $tags_str = format_tags_string($line["tags"], $id);
 
                                        $reply['content'] .= "<img src='".theme_image($this->link,
                                                        'images/tag.png')."' alt='Tags' title='Tags'>
@@ -763,18 +744,12 @@ class Feeds extends Handler_Protected {
 
        function catchupAll() {
                db_query($this->link, "UPDATE ttrss_user_entries SET
-                                               last_read = NOW(),unread = false WHERE owner_uid = " . $_SESSION["uid"]);
+                                               last_read = NOW(), unread = false WHERE unread = true AND owner_uid = " . $_SESSION["uid"]);
                ccache_zero_all($this->link, $_SESSION["uid"]);
        }
 
-       function collapse() {
-               $cat_id = db_escape_string($_REQUEST["cid"]);
-               $mode = (int) db_escape_string($_REQUEST['mode']);
-               toggle_collapse_cat($this->link, $cat_id, $mode);
-       }
-
        function view() {
-               $timing_info = getmicrotime();
+               $timing_info = microtime(true);
 
                $reply = array();
 
@@ -886,7 +861,7 @@ class Feeds extends Handler_Protected {
                        $view_mode, $limit, $cat_view, $next_unread_feed, $offset,
                        $vgroup_last_feed, $override_order, true);
 
-               $topmost_article_ids = $ret[0];
+               //$topmost_article_ids = $ret[0];
                $headlines_count = $ret[1];
                $returned_feed = $ret[2];
                $disable_cache = $ret[3];
@@ -901,18 +876,6 @@ class Feeds extends Handler_Protected {
                                                "vgroup_last_feed" => $vgroup_last_feed,
                                                "disable_cache" => (bool) $disable_cache);
 
-               if ($_REQUEST["debug"]) $timing_info = print_checkpoint("20", $timing_info);
-
-               if (is_array($topmost_article_ids) && !get_pref($this->link, 'COMBINED_DISPLAY_MODE') && !$_SESSION["bw_limit"]) {
-                       $articles = array();
-
-                       foreach ($topmost_article_ids as $id) {
-                               array_push($articles, format_article($this->link, $id, false));
-                       }
-
-                       $reply['articles'] = $articles;
-               }
-
                if ($_REQUEST["debug"]) $timing_info = print_checkpoint("30", $timing_info);
 
                $reply['runtime-info'] = make_runtime_info($this->link);