]> git.wh0rd.org - tt-rss.git/blob - plugins/af_comics/filters/af_comics_twp.php
af_comics: split filters to separate files to ease maintenance
[tt-rss.git] / plugins / af_comics / filters / af_comics_twp.php
1 <?php
2 class Af_Comics_Twp extends Af_ComicFilter {
3
4 function supported() {
5 return array("Three Word Phrase");
6 }
7
8 function process(&$article) {
9 $owner_uid = $article["owner_uid"];
10
11 if (strpos($article["link"], "threewordphrase.com") !== FALSE) {
12 if (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
22 $basenode = $xpath->query("//td/center/img")->item(0);
23
24 if ($basenode) {
25 $article["content"] = $doc->saveXML($basenode);
26 $article["plugin_data"] = "af_comics,$owner_uid:" . $article["plugin_data"];
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 ?>