]> git.wh0rd.org - tt-rss.git/blob - plugins/af_comics/filters/af_comics_cad.php
af_comics_cad: do not process news posts
[tt-rss.git] / plugins / af_comics / filters / af_comics_cad.php
1 <?php
2 class Af_Comics_Cad extends Af_ComicFilter {
3
4 function supported() {
5 return array("Ctrl+Alt+Del");
6 }
7
8 function process(&$article) {
9 $owner_uid = $article["owner_uid"];
10
11 if (strpos($article["link"], "cad-comic.com/cad/") !== FALSE) {
12 if (strpos($article["title"], "News:") === FALSE && strpos($article["plugin_data"], "af_comics,$owner_uid:") === FALSE) {
13
14 $doc = new DOMDocument();
15 @$doc->loadHTML(fetch_file_contents($article["link"]));
16
17 $basenode = false;
18
19 if ($doc) {
20 $xpath = new DOMXPath($doc);
21 $basenode = $xpath->query('(//img[contains(@src, "/comics/cad-")])')->item(0);
22
23 if ($basenode) {
24 $article["content"] = $doc->saveXML($basenode);
25 $article["plugin_data"] = "af_comics,$owner_uid:" . $article["plugin_data"];
26 }
27 }
28
29 } else if (isset($article["stored"]["content"])) {
30 $article["content"] = $article["stored"]["content"];
31 }
32
33 return true;
34 }
35
36 return false;
37 }
38 }
39 ?>