]>
Commit | Line | Data |
---|---|---|
c30bbffb AD |
1 | <?php |
2 | class Af_CSection extends Plugin { | |
3 | ||
4 | private $host; | |
5 | ||
6 | function about() { | |
7 | return array(1.0, | |
8 | "Fix csection rss feed", | |
9 | "fox"); | |
10 | } | |
11 | ||
12 | function init($host) { | |
13 | $this->host = $host; | |
14 | ||
15 | $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); | |
16 | } | |
17 | ||
18 | function hook_article_filter($article) { | |
19 | $owner_uid = $article["owner_uid"]; | |
20 | ||
21 | if (strpos($article["guid"], "csectioncomics.com") !== FALSE) { | |
22 | if (strpos($article["plugin_data"], "csection,$owner_uid:") === FALSE) { | |
23 | ||
24 | $doc = new DOMDocument(); | |
25 | @$doc->loadHTML(fetch_file_contents($article["link"])); | |
26 | ||
27 | $basenode = false; | |
28 | ||
29 | if ($doc) { | |
30 | $xpath = new DOMXPath($doc); | |
31 | $basenode = $xpath->query('//div[@id="comic"]')->item(0); | |
32 | ||
33 | if ($basenode) { | |
34 | $article["content"] = $doc->saveXML($basenode); | |
35 | $article["plugin_data"] = "csection,$owner_uid:" . $article["plugin_data"]; | |
36 | } | |
37 | } | |
38 | } else if (isset($article["stored"]["content"])) { | |
39 | $article["content"] = $article["stored"]["content"]; | |
40 | } | |
41 | } | |
42 | ||
43 | return $article; | |
44 | } | |
45 | ||
46 | function api_version() { | |
47 | return 2; | |
48 | } | |
49 | ||
50 | } | |
51 | ?> |