]> git.wh0rd.org - tt-rss.git/blobdiff - classes/feeds.php
experimental new plugin system
[tt-rss.git] / classes / feeds.php
index 72abc41e2cdfa49a1fd2d1d14ea9dc293516f18e..a90b1c8ed7059679231df43ac86b32d53972a7cd 100644 (file)
@@ -45,6 +45,8 @@ class Feeds extends Handler_Protected {
                $tog_marked_link = "selectionToggleMarked()";\r
                $tog_published_link = "selectionTogglePublished()";\r
 \r
+               $set_score_link = "setSelectionScore()";\r
+\r
                if ($is_cat) $cat_q = "&is_cat=$is_cat";\r
 \r
                if ($search) {\r
@@ -59,6 +61,7 @@ class Feeds extends Handler_Protected {
                // right part\r
 \r
                $reply .= "<span class='r'>";\r
+               $reply .= "<span id='feed_title'>";\r
 \r
                if ($feed_site_url) {\r
                        $target = "target=\"_blank\"";\r
@@ -73,6 +76,8 @@ class Feeds extends Handler_Protected {
                        $reply .= $feed_title;\r
                }\r
 \r
+               $reply .= "</span>";\r
+\r
                $reply .= "\r
                        <a href=\"#\"\r
                                title=\"".__("View as RSS feed")."\"\r
@@ -104,6 +109,7 @@ class Feeds extends Handler_Protected {
                $reply .= "<option value=\"0\" disabled=\"1\">".__('Selection:')."</option>";\r
 \r
                $reply .= "<option value=\"$catchup_sel_link\">".__('Mark as read')."</option>";\r
+               $reply .= "<option value=\"$set_score_link\">".__('Set score')."</option>";\r
 \r
                if ($feed_id != "0") {\r
                        $reply .= "<option value=\"$archive_sel_link\">".__('Archive')."</option>";\r
@@ -152,14 +158,20 @@ class Feeds extends Handler_Protected {
                        // Update the feed if required with some basic flood control\r
 \r
                        $result = db_query($this->link,\r
-                               "SELECT ".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated\r
+                               "SELECT cache_images,cache_content,".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated\r
                                        FROM ttrss_feeds WHERE id = '$feed'");\r
 \r
                                if (db_num_rows($result) != 0) {\r
                                        $last_updated = strtotime(db_fetch_result($result, 0, "last_updated"));\r
-                                       if (time() - $last_updated > 120) {\r
+                                       $cache_images = sql_bool_to_bool(db_fetch_result($result, 0, "cache_images"));\r
+                                       $cache_content = sql_bool_to_bool(db_fetch_result($result, 0, "cache_content"));\r
+\r
+                                       if (!$cache_images && !$cache_content && time() - $last_updated > 120 || isset($_REQUEST['DevForceUpdate'])) {\r
                                                include "rssfuncs.php";\r
                                                update_rss_feed($this->link, $feed, true, true);\r
+                                       } else {\r
+                                               db_query($this->link, "UPDATE ttrss_feeds SET last_updated = '1970-01-01', last_update_started = '1970-01-01'\r
+                                                       WHERE id = '$feed'");\r
                                        }\r
                                }\r
                }\r
@@ -207,11 +219,7 @@ class Feeds extends Handler_Protected {
                }\r
 \r
                @$search_mode = db_escape_string($_REQUEST["search_mode"]);\r
-               @$match_on = db_escape_string($_REQUEST["match_on"]);\r
-\r
-               if (!$match_on) {\r
-                       $match_on = "both";\r
-               }\r
+               $match_on = "both"; // deprecated, TODO: remove\r
 \r
                if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H0", $timing_info);\r
 \r
@@ -230,32 +238,30 @@ class Feeds extends Handler_Protected {
                $feed_title = $qfh_ret[1];\r
                $feed_site_url = $qfh_ret[2];\r
                $last_error = $qfh_ret[3];\r
+               $cache_content = true;\r
 \r
                $vgroup_last_feed = $vgr_last_feed;\r
 \r
-//             if (!$offset) {\r
-\r
-                       if (db_num_rows($result) > 0) {\r
-                               $reply['toolbar'] = $this->format_headline_subtoolbar($feed_site_url,\r
-                                       $feed_title,\r
-                                       $feed, $cat_view, $search, $match_on, $search_mode, $view_mode,\r
-                                       $last_error);\r
-                       }\r
-//             }\r
+               $reply['toolbar'] = $this->format_headline_subtoolbar($feed_site_url,\r
+                       $feed_title,\r
+                       $feed, $cat_view, $search, $match_on, $search_mode, $view_mode,\r
+                       $last_error);\r
 \r
                $headlines_count = db_num_rows($result);\r
 \r
-               if (get_pref($this->link, 'COMBINED_DISPLAY_MODE')) {\r
+               /* if (get_pref($this->link, 'COMBINED_DISPLAY_MODE')) {\r
                        $button_plugins = array();\r
                        foreach (explode(",", ARTICLE_BUTTON_PLUGINS) as $p) {\r
-                               $pclass = trim("button_${p}");\r
+                               $pclass = "button_" . trim($p);\r
 \r
                                if (class_exists($pclass)) {\r
                                        $plugin = new $pclass($link);\r
                                        array_push($button_plugins, $plugin);\r
                                }\r
                        }\r
-               }\r
+               } */\r
+\r
+               global $pluginhost;\r
 \r
                if (db_num_rows($result) > 0) {\r
 \r
@@ -390,7 +396,7 @@ class Feeds extends Handler_Protected {
                                $score_pic = "<img class='hlScorePic' src=\"images/$score_pic\"\r
                                        onclick=\"adjustArticleScore($id, $score)\" title=\"$score $score_title\">"; */\r
 \r
-                               $score_pic = "<img class='hlScorePic' src=\"$score_pic\"\r
+                               $score_pic = "<img class='hlScorePic' score='$score' onclick='changeScore($id, this)' src=\"$score_pic\"\r
                                        title=\"$score\">";\r
 \r
                                if ($score > 500) {\r
@@ -628,6 +634,10 @@ class Feeds extends Handler_Protected {
 \r
                                        $feed_site_url = $line["site_url"];\r
 \r
+                                       if ($cache_content && $line["cached_content"] != "") {\r
+                                               $line["content_preview"] =& $line["cached_content"];\r
+                                       }\r
+\r
                                        $article_content = sanitize($this->link, $line["content_preview"],\r
                                                        false, false, $feed_site_url);\r
 \r
@@ -638,7 +648,7 @@ class Feeds extends Handler_Protected {
                                        $reply['content'] .= "</div>";\r
 \r
                                        $reply['content'] .= "<span id=\"CWRAP-$id\">";\r
-                                       $reply['content'] .= $expand_cdm ? $article_content : '';\r
+                                       $reply['content'] .= $article_content;\r
                                        $reply['content'] .= "</span>";\r
 \r
 /*                                     $tmp_result = db_query($this->link, "SELECT always_display_enclosures FROM\r
@@ -698,8 +708,8 @@ class Feeds extends Handler_Protected {
 \r
                                        //$note_escaped = htmlspecialchars($line['note'], ENT_QUOTES);\r
 \r
-                                       foreach ($button_plugins as $p) {\r
-                                               $reply['content'] .= $p->render($id, $line);\r
+                                       foreach ($pluginhost->get_hooks($pluginhost::HOOK_ARTICLE_BUTTON) as $p) {\r
+                                               $reply['content'] .= $p->hook_article_button($line);\r
                                        }\r
 \r
                                        $reply['content'] .= "<img src=\"images/digest_checkbox.png\"\r