]>
git.wh0rd.org - tt-rss.git/blob - plugins/af_habr/init.php
2 class Af_Habr
extends Plugin
{
6 "Fetch content of Habrahabr feeds",
10 function init($host) {
13 $host->add_hook($host::HOOK_ARTICLE_FILTER
, $this);
16 function hook_article_filter($article) {
17 $owner_uid = $article["owner_uid"];
19 if (strpos($article["link"], "habrahabr.ru") !== FALSE) {
20 if (strpos($article["plugin_data"], "af_habr,$owner_uid:") === FALSE) {
22 $doc = new DOMDocument();
23 @$doc->loadHTML(fetch_file_contents($article["link"]));
28 $xpath = new DOMXPath($doc);
30 $basenode = $xpath->query("//div[contains(@class,'content') and contains(@class, 'html_format')]")->item(0);
33 $article["content"] = $doc->saveXML($basenode);
34 $article["plugin_data"] = "af_habr,$owner_uid:" . $article["plugin_data"];
37 } else if (isset($article["stored"]["content"])) {
38 $article["content"] = $article["stored"]["content"];
45 function api_version() {