]>
Commit | Line | Data |
---|---|---|
901dd67a AD |
1 | <?php |
2 | class Af_Comics_Explosm extends Af_ComicFilter { | |
3 | ||
4 | function supported() { | |
5 | return array("Cyanide and Happiness"); | |
6 | } | |
7 | ||
8 | function process(&$article) { | |
9 | $owner_uid = $article["owner_uid"]; | |
10 | ||
11 | if (strpos($article["link"], "explosm.net/comics") !== 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 | $entries = $xpath->query('(//img[@src])'); // we might also check for img[@class='strip'] I guess... | |
22 | ||
23 | $matches = array(); | |
24 | ||
25 | foreach ($entries as $entry) { | |
26 | ||
27 | if (preg_match("/(http:\/\/.*\/db\/files\/Comics\/.*)/i", $entry->getAttribute("src"), $matches)) { | |
28 | ||
29 | $basenode = $entry; | |
30 | break; | |
31 | } | |
32 | } | |
33 | ||
34 | if ($basenode) { | |
35 | $article["content"] = $doc->saveXML($basenode); | |
36 | $article["plugin_data"] = "af_comics,$owner_uid:" . $article["plugin_data"]; | |
37 | } | |
38 | } | |
39 | } else if (isset($article["stored"]["content"])) { | |
40 | $article["content"] = $article["stored"]["content"]; | |
41 | } | |
42 | ||
43 | return true; | |
44 | } | |
45 | ||
46 | return false; | |
47 | } | |
48 | } | |
49 | ?> |