From 52265e19c0d33aa6bb37a4e6f56c1c284595cfda Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 17 Feb 2014 12:26:46 +0400 Subject: [PATCH 1/1] af_comics: add cad embedding --- plugins/af_comics/init.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/plugins/af_comics/init.php b/plugins/af_comics/init.php index 993ddb7c..4672f335 100644 --- a/plugins/af_comics/init.php +++ b/plugins/af_comics/init.php @@ -27,6 +27,7 @@ class Af_Comics extends Plugin { print "
  • Buni
  • Buttersafe
  • CSection
  • +
  • Ctrl+Alt+Del
  • Dilbert
  • Explosm
  • GoComics
  • @@ -150,6 +151,29 @@ class Af_Comics extends Plugin { } } + if (strpos($article["link"], "cad-comic.com/cad/") !== FALSE) { + if (strpos($article["plugin_data"], "af_comics,$owner_uid:") === FALSE) { + + $doc = new DOMDocument(); + @$doc->loadHTML(fetch_file_contents($article["link"])); + + $basenode = false; + + if ($doc) { + $xpath = new DOMXPath($doc); + $basenode = $xpath->query('(//img[contains(@src, "/comics/cad-")])')->item(0); + + if ($basenode) { + $article["content"] = $doc->saveXML($basenode); + $article["plugin_data"] = "af_comics,$owner_uid:" . $article["plugin_data"]; + } + } + + } else if (isset($article["stored"]["content"])) { + $article["content"] = $article["stored"]["content"]; + } + } + if (strpos($article["guid"], "gocomics.com") !== FALSE) { if (strpos($article["plugin_data"], "af_comics,$owner_uid:") === FALSE) { $doc = new DOMDocument(); -- 2.39.2