]>
git.wh0rd.org - tt-rss.git/blob - plugins/af_sciam/init.php
658265e507dfeca3c22fd6532ed2ee07cf3c9856
2 class Af_SciAm
extends Plugin
{
8 "Fetch content of Scientific American feeds",
12 function init($host) {
15 $host->add_hook($host::HOOK_ARTICLE_FILTER
, $this);
18 function hook_article_filter($article) {
19 $owner_uid = $article["owner_uid"];
21 if (strpos($article["link"], "scientificamerican.com") !== FALSE ||
strpos($article["link"], "rss.sciam.com") !== FALSE) {
22 if (strpos($article["plugin_data"], "sciam,$owner_uid:") === FALSE) {
24 $doc = new DOMDocument();
25 @$doc->loadHTML(fetch_file_contents($article["link"]));
30 $xpath = new DOMXpath($doc);
32 $basenode = $xpath->query("//*[@id='singleBlogPost' or @id='articleContent']")->item(0);
35 $article["content"] = $doc->saveXML($basenode);
36 $article["plugin_data"] = "sciam,$owner_uid:" . $article["plugin_data"];
39 } else if (isset($article["stored"]["content"])) {
40 $article["content"] = $article["stored"]["content"];
47 function api_version() {