add af_* plugin workaround for already processed article

This commit is contained in:
Andrew Dolgov 2013-02-23 12:07:46 +04:00
parent 389859b5d4
commit e02555c1b8
6 changed files with 128 additions and 108 deletions

View File

@ -516,14 +516,20 @@
_debug("update_rss_feed: applying plugin filters.."); _debug("update_rss_feed: applying plugin filters..");
} }
// Todo unify with id checking below // FIXME not sure if owner_uid is a good idea here, we may have a base entry without user entry (?)
$result = db_query($link, "SELECT plugin_data FROM ttrss_entries $result = db_query($link, "SELECT plugin_data,title,content,link,tag_cache,author FROM ttrss_entries, ttrss_user_entries
WHERE guid = '".db_escape_string($entry_guid)."'"); WHERE ref_id = id AND guid = '".db_escape_string($entry_guid)."' AND owner_uid = $owner_uid");
if (db_num_rows($result) != 0) { if (db_num_rows($result) != 0) {
$entry_plugin_data = db_fetch_result($result, 0, "plugin_data"); $entry_plugin_data = db_fetch_result($result, 0, "plugin_data");
$stored_article = array("title" => db_fetch_result($result, 0, "title"),
"content" => db_fetch_result($result, 0, "content"),
"link" => db_fetch_result($result, 0, "link"),
"tags" => explode(",", db_fetch_result($result, 0, "tag_cache")),
"author" => db_fetch_result($result, 0, "author"));
} else { } else {
$entry_plugin_data = ""; $entry_plugin_data = "";
$stored_article = array();
} }
$article = array("owner_uid" => $owner_uid, // read only $article = array("owner_uid" => $owner_uid, // read only
@ -533,7 +539,8 @@
"link" => $entry_link, "link" => $entry_link,
"tags" => $entry_tags, "tags" => $entry_tags,
"plugin_data" => $entry_plugin_data, "plugin_data" => $entry_plugin_data,
"author" => $entry_author); "author" => $entry_author,
"stored" => $stored_article);
foreach ($pluginhost->get_hooks($pluginhost::HOOK_ARTICLE_FILTER) as $plugin) { foreach ($pluginhost->get_hooks($pluginhost::HOOK_ARTICLE_FILTER) as $plugin) {
$article = $plugin->hook_article_filter($article); $article = $plugin->hook_article_filter($article);

View File

@ -20,8 +20,8 @@ class Af_Buttersafe extends Plugin {
function hook_article_filter($article) { function hook_article_filter($article) {
$owner_uid = $article["owner_uid"]; $owner_uid = $article["owner_uid"];
if (strpos($article["guid"], "buttersafe.com") !== FALSE && if (strpos($article["guid"], "buttersafe.com") !== FALSE) {
strpos($article["plugin_data"], "buttersafe,$owner_uid:") === FALSE) { if (strpos($article["plugin_data"], "buttersafe,$owner_uid:") === FALSE) {
$doc = new DOMDocument(); $doc = new DOMDocument();
@$doc->loadHTML(fetch_file_contents($article["link"])); @$doc->loadHTML(fetch_file_contents($article["link"]));
@ -45,11 +45,13 @@ class Af_Buttersafe extends Plugin {
if ($basenode) { if ($basenode) {
$article["content"] = $doc->saveXML($basenode, LIBXML_NOEMPTYTAG); $article["content"] = $doc->saveXML($basenode, LIBXML_NOEMPTYTAG);
}
}
$article["plugin_data"] = "buttersafe,$owner_uid:" . $article["plugin_data"]; $article["plugin_data"] = "buttersafe,$owner_uid:" . $article["plugin_data"];
} }
}
} else if (isset($article["stored"]["content"])) {
$article["content"] = $article["stored"]["content"];
}
}
return $article; return $article;
} }

View File

@ -20,8 +20,8 @@ class Af_Explosm extends Plugin {
function hook_article_filter($article) { function hook_article_filter($article) {
$owner_uid = $article["owner_uid"]; $owner_uid = $article["owner_uid"];
if (strpos($article["link"], "explosm.net/comics") !== FALSE && if (strpos($article["link"], "explosm.net/comics") !== FALSE) {
strpos($article["plugin_data"], "explosm,$owner_uid:") === FALSE) { if (strpos($article["plugin_data"], "explosm,$owner_uid:") === FALSE) {
$doc = new DOMDocument(); $doc = new DOMDocument();
@$doc->loadHTML(fetch_file_contents($article["link"])); @$doc->loadHTML(fetch_file_contents($article["link"]));
@ -45,11 +45,13 @@ class Af_Explosm extends Plugin {
if ($basenode) { if ($basenode) {
$article["content"] = $doc->saveXML($basenode, LIBXML_NOEMPTYTAG); $article["content"] = $doc->saveXML($basenode, LIBXML_NOEMPTYTAG);
}
}
$article["plugin_data"] = "explosm,$owner_uid:" . $article["plugin_data"]; $article["plugin_data"] = "explosm,$owner_uid:" . $article["plugin_data"];
} }
}
} else if (isset($article["stored"]["content"])) {
$article["content"] = $article["stored"]["content"];
}
}
return $article; return $article;
} }

View File

@ -20,7 +20,8 @@ class Af_GoComics extends Plugin {
function hook_article_filter($article) { function hook_article_filter($article) {
$owner_uid = $article["owner_uid"]; $owner_uid = $article["owner_uid"];
if (strpos($article["guid"], "gocomics.com") !== FALSE && strpos($article["plugin_data"], "gocomics,$owner_uid:") === FALSE) { if (strpos($article["guid"], "gocomics.com") !== FALSE) {
if (strpos($article["plugin_data"], "gocomics,$owner_uid:") === FALSE) {
$doc = new DOMDocument(); $doc = new DOMDocument();
@$doc->loadHTML(fetch_file_contents($article["link"])); @$doc->loadHTML(fetch_file_contents($article["link"]));
@ -44,11 +45,13 @@ class Af_GoComics extends Plugin {
if ($basenode) { if ($basenode) {
$article["content"] = $doc->saveXML($basenode, LIBXML_NOEMPTYTAG); $article["content"] = $doc->saveXML($basenode, LIBXML_NOEMPTYTAG);
}
}
$article["plugin_data"] = "gocomics,$owner_uid:" . $article["plugin_data"]; $article["plugin_data"] = "gocomics,$owner_uid:" . $article["plugin_data"];
} }
}
} else if (isset($article["stored"]["content"])) {
$article["content"] = $article["stored"]["content"];
}
}
return $article; return $article;
} }

View File

@ -20,8 +20,8 @@ class Af_PennyArcade extends Plugin {
function hook_article_filter($article) { function hook_article_filter($article) {
$owner_uid = $article["owner_uid"]; $owner_uid = $article["owner_uid"];
if (strpos($article["link"], "penny-arcade.com") !== FALSE && strpos($article["title"], "Comic:") !== FALSE && if (strpos($article["link"], "penny-arcade.com") !== FALSE && strpos($article["title"], "Comic:") !== FALSE) {
strpos($article["plugin_data"], "pennyarcade,$owner_uid:") === FALSE) { if (strpos($article["plugin_data"], "pennyarcade,$owner_uid:") === FALSE) {
$doc = new DOMDocument(); $doc = new DOMDocument();
@$doc->loadHTML(fetch_file_contents($article["link"])); @$doc->loadHTML(fetch_file_contents($article["link"]));
@ -45,11 +45,13 @@ class Af_PennyArcade extends Plugin {
if ($basenode) { if ($basenode) {
$article["content"] = $doc->saveXML($basenode, LIBXML_NOEMPTYTAG); $article["content"] = $doc->saveXML($basenode, LIBXML_NOEMPTYTAG);
}
}
$article["plugin_data"] = "pennyarcade,$owner_uid:" . $article["plugin_data"]; $article["plugin_data"] = "pennyarcade,$owner_uid:" . $article["plugin_data"];
} }
}
} else if (isset($article["stored"]["content"])) {
$article["content"] = $article["stored"]["content"];
}
}
return $article; return $article;
} }

View File

@ -25,8 +25,9 @@ class Af_Unburn extends Plugin {
if ((strpos($article["link"], "feedproxy.google.com") !== FALSE || if ((strpos($article["link"], "feedproxy.google.com") !== FALSE ||
strpos($article["link"], "/~r/") !== FALSE || strpos($article["link"], "/~r/") !== FALSE ||
strpos($article["link"], "feedsportal.com") !== FALSE) && strpos($article["link"], "feedsportal.com") !== FALSE)) {
strpos($article["plugin_data"], "unburn,$owner_uid:") === FALSE) {
if (strpos($article["plugin_data"], "unburn,$owner_uid:") === FALSE) {
$ch = curl_init($article["link"]); $ch = curl_init($article["link"]);
curl_setopt($ch, CURLOPT_TIMEOUT, 5); curl_setopt($ch, CURLOPT_TIMEOUT, 5);
@ -66,6 +67,9 @@ class Af_Unburn extends Plugin {
$article["plugin_data"] = "unburn,$owner_uid:" . $article["plugin_data"]; $article["plugin_data"] = "unburn,$owner_uid:" . $article["plugin_data"];
$article["link"] = $real_url; $article["link"] = $real_url;
} }
} else if (isset($article["stored"]["link"])) {
$article["link"] = $article["stored"]["link"];
}
} }
return $article; return $article;