]> git.wh0rd.org Git - tt-rss.git/blob - plugins/af_comics/filters/af_comics_dilbert.php
plugins: remove obsolete plugin_data/stored stuff
[tt-rss.git] / plugins / af_comics / filters / af_comics_dilbert.php
1 <?php
2 class Af_Comics_Dilbert extends Af_ComicFilter {
3
4         function supported() {
5                 return array("Dilbert");
6         }
7
8         function process(&$article) {
9                 $owner_uid = $article["owner_uid"];
10
11                 if (strpos($article["guid"], "dilbert.com") !== FALSE) {
12                                 $doc = new DOMDocument();
13                                 @$doc->loadHTML(fetch_file_contents($article["link"]));
14
15                                 $basenode = false;
16
17                                 if ($doc) {
18                                         $xpath = new DOMXPath($doc);
19                                         $entries = $xpath->query('(//img[@src])'); // we might also check for img[@class='strip'] I guess...
20
21                                         $matches = array();
22
23                                         foreach ($entries as $entry) {
24
25                                                 if (preg_match("/dyn\/str_strip\/.*zoom\.gif$/", $entry->getAttribute("src"), $matches)) {
26
27                                                         $entry->setAttribute("src",
28                                                                 rewrite_relative_url("http://dilbert.com/",
29                                                                 $matches[0]));
30
31                                                         $basenode = $entry;
32                                                         break;
33                                                 }
34                                         }
35
36                                         if ($basenode) {
37                                                 $article["content"] = $doc->saveXML($basenode);
38                                         }
39                                 }
40
41                         return true;
42                 }
43
44                 return false;
45         }
46 }
47 ?>