]> git.wh0rd.org Git - tt-rss.git/commitdiff
af_redditimgur: add option for previous
authorAndrew Dolgov <noreply@fakecake.org>
Sun, 31 Jan 2016 11:14:31 +0000 (14:14 +0300)
committerAndrew Dolgov <noreply@fakecake.org>
Sun, 31 Jan 2016 11:14:31 +0000 (14:14 +0300)
plugins/af_redditimgur/init.php

index 347afbc87f6d8c25eb7cb4f7f40714772196c426..f8fb6edcfe95a5959b9b29a895b9a0fba094dc5e 100755 (executable)
@@ -27,6 +27,9 @@ class Af_RedditImgur extends Plugin {
                $enable_readability = $this->host->get($this, "enable_readability");
                $enable_readability_checked = $enable_readability ? "checked" : "";
 
+               $enable_content_dupcheck = $this->host->get($this, "enable_content_dupcheck");
+               $enable_content_dupcheck_checked = $enable_content_dupcheck ? "checked" : "";
+               
                print "<form dojoType=\"dijit.form.Form\">";
 
                print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\">
@@ -55,6 +58,12 @@ class Af_RedditImgur extends Plugin {
 
                print "<label for=\"enable_readability\">" . __("Extract missing content using Readability") . "</label>";
 
+               print "<br/>";
+               
+               print "<input dojoType=\"dijit.form.CheckBox\" id=\"enable_content_dupcheck\"
+                       $enable_content_dupcheck_checked name=\"enable_content_dupcheck\">&nbsp;";
+
+               print "<label for=\"enable_content_dupcheck\">" . __("Enable additional duplicate checking") . "</label>";
                print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">".
                        __("Save")."</button>";
 
@@ -65,8 +74,10 @@ class Af_RedditImgur extends Plugin {
 
        function save() {
                $enable_readability = checkbox_to_sql_bool($_POST["enable_readability"]) == "true";
+               $enable_content_dupcheck = checkbox_to_sql_bool($_POST["enable_content_dupcheck"]) == "true";
 
-               $this->host->set($this, "enable_readability", $enable_readability);
+               $this->host->set($this, "enable_readability", $enable_readability, false);
+               $this->host->set($this, "enable_content_dupcheck", $enable_content_dupcheck);
 
                echo __("Configuration saved");
        }
@@ -244,33 +255,35 @@ class Af_RedditImgur extends Plugin {
                        @$doc->loadHTML($article["content"]);
                        $xpath = new DOMXPath($doc);
 
-                       /*$content_link = $xpath->query("(//a[contains(., '[link]')])")->item(0);
+                       if ($this->host->get($this, "enable_content_dupcheck")) {
+                               $content_link = $xpath->query("(//a[contains(., '[link]')])")->item(0);
 
-                       if ($content_link) {
-                               $content_href = db_escape_string($content_link->getAttribute("href"));
-                               $entry_guid = db_escape_string($article["guid_hashed"]);
-                               $owner_uid = $article["owner_uid"];
+                               if ($content_link) {
+                                       $content_href = db_escape_string($content_link->getAttribute("href"));
+                                       $entry_guid = db_escape_string($article["guid_hashed"]);
+                                       $owner_uid = $article["owner_uid"];
 
-                               if (DB_TYPE == "pgsql") {
-                                       $interval_qpart = "date_entered < NOW() - INTERVAL '1 day'";
-                               } else {
-                                       $interval_qpart = "date_entered < DATE_SUB(NOW(), INTERVAL 1 DAY)";
-                               }
+                                       if (DB_TYPE == "pgsql") {
+                                               $interval_qpart = "date_entered < NOW() - INTERVAL '1 day'";
+                                       } else {
+                                               $interval_qpart = "date_entered < DATE_SUB(NOW(), INTERVAL 1 DAY)";
+                                       }
 
-                               $result = db_query("SELECT COUNT(id) AS cid
-                                       FROM ttrss_entries, ttrss_user_entries WHERE
-                                               ref_id = id AND
-                                               $interval_qpart AND
-                                               guid != '$entry_guid' AND
-                                               owner_uid = '$owner_uid' AND
-                                               content LIKE '%href=\"$content_href\">[link]%'");
+                                       $result = db_query("SELECT COUNT(id) AS cid
+                                               FROM ttrss_entries, ttrss_user_entries WHERE
+                                                       ref_id = id AND
+                                                       $interval_qpart AND
+                                                       guid != '$entry_guid' AND
+                                                       owner_uid = '$owner_uid' AND
+                                                       content LIKE '%href=\"$content_href\">[link]%'");
 
-                               if ($result) {
-                                       $num_found = db_fetch_result($result, 0, "cid");
+                                       if ($result) {
+                                               $num_found = db_fetch_result($result, 0, "cid");
 
-                                       if ($num_found > 0) $article["force_catchup"] = true;
+                                               if ($num_found > 0) $article["force_catchup"] = true;
+                                       }
                                }
-                       }*/
+                       }
 
                        $found = $this->inline_stuff($article, $doc, $xpath);