]>
Commit | Line | Data |
---|---|---|
901dd67a AD |
1 | <?php |
2 | class Af_Comics_GoComics extends Af_ComicFilter { | |
3 | ||
4 | function supported() { | |
5 | return array("GoComics"); | |
6 | } | |
7 | ||
8 | function process(&$article) { | |
9 | $owner_uid = $article["owner_uid"]; | |
10 | ||
11 | if (strpos($article["guid"], "gocomics.com") !== FALSE) { | |
12 | if (strpos($article["plugin_data"], "af_comics,$owner_uid:") === FALSE) { | |
13 | $doc = new DOMDocument(); | |
14 | @$doc->loadHTML(fetch_file_contents($article["link"])); | |
15 | ||
16 | $basenode = false; | |
17 | ||
18 | if ($doc) { | |
19 | $xpath = new DOMXPath($doc); | |
20 | $entries = $xpath->query('(//img[@src])'); // we might also check for img[@class='strip'] I guess... | |
21 | ||
22 | $matches = array(); | |
23 | ||
24 | foreach ($entries as $entry) { | |
25 | ||
26 | if (preg_match("/(http:\/\/assets.amuniversal.com\/.*width.*)/i", $entry->getAttribute("src"), $matches)) { | |
27 | ||
28 | $entry->setAttribute("src", $matches[0]); | |
29 | $basenode = $entry; | |
30 | break; | |
31 | } | |
32 | } | |
33 | ||
34 | if (!$basenode) { | |
35 | // fallback on the smaller version | |
36 | foreach ($entries as $entry) { | |
37 | ||
38 | if (preg_match("/(http:\/\/assets.amuniversal.com\/.*)/i", $entry->getAttribute("src"), $matches)) { | |
39 | ||
40 | $entry->setAttribute("src", $matches[0]); | |
41 | $basenode = $entry; | |
42 | break; | |
43 | } | |
44 | } | |
45 | } | |
46 | ||
47 | if ($basenode) { | |
48 | $article["content"] = $doc->saveXML($basenode); | |
49 | $article["plugin_data"] = "af_comics,$owner_uid:" . $article["plugin_data"]; | |
50 | } | |
51 | } | |
52 | } else if (isset($article["stored"]["content"])) { | |
53 | $article["content"] = $article["stored"]["content"]; | |
54 | } | |
55 | ||
56 | return true; | |
57 | } | |
58 | ||
59 | return false; | |
60 | } | |
61 | } | |
62 | ?> |