af_redditimgur: do not process content multiple times

This commit is contained in:
Andrew Dolgov 2013-02-28 16:47:55 +04:00
parent b999f4c75a
commit a16d7a5d64
1 changed files with 28 additions and 22 deletions

View File

@ -18,8 +18,10 @@ class Af_RedditImgur extends Plugin {
}
function hook_article_filter($article) {
$owner_uid = $article["owner_uid"];
if (strpos($article["link"], "reddit.com/r/") !== FALSE) {
if (strpos($article["plugin_data"], "redditimgur,$owner_uid:") === FALSE) {
$doc = new DOMDocument();
@$doc->loadHTML($article["content"]);
@ -50,9 +52,13 @@ class Af_RedditImgur extends Plugin {
if ($node) {
$article["content"] = $doc->saveXML($node, LIBXML_NOEMPTYTAG);
$article["plugin_data"] = "redditimgur,$owner_uid:" . $article["plugin_data"];
}
}
}
} else if (isset($article["stored"]["content"])) {
$article["content"] = $article["stored"]["content"];
}
return $article;
}