diff options
author | Andrew Dolgov <[email protected]> | 2016-01-31 14:14:31 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2016-01-31 14:14:31 +0300 |
commit | 891b77f90ec03d208c8ff5565315a0acc2432534 (patch) | |
tree | ffb1d916f02fc0c30f50d40ea0856ef6d253903e /plugins | |
parent | 902b1ac7b5fb1ef556aba46a17ac4bad82e6757c (diff) |
af_redditimgur: add option for previous
Diffstat (limited to 'plugins')
-rwxr-xr-x | plugins/af_redditimgur/init.php | 57 |
1 files changed, 35 insertions, 22 deletions
diff --git a/plugins/af_redditimgur/init.php b/plugins/af_redditimgur/init.php index 347afbc87..f8fb6edcf 100755 --- a/plugins/af_redditimgur/init.php +++ b/plugins/af_redditimgur/init.php @@ -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\"> "; + + 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); |