link = $host->get_link(); $this->host = $host; $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); $host->add_hook($host::HOOK_PREFS_TAB, $this); } function hook_article_filter($article) { $sometext = $this->host->get($this, "sometext"); $owner_uid = $article['owner_uid']; if (strpos($article['link'], 'heise.de') !== FALSE) { // only process heise.de articles if (strpos($article['plugin_data'], "feedmod,$owner_uid:") === FALSE) { // do not process an article more than once $doc = new DOMDocument(); @$doc->loadHTML(fetch_file_contents($article['link'])); $basenode = false; if ($doc) { $xpath = new DOMXPath($doc); $entries = $xpath->query('(//div.meldung_wrapper)'); // find main DIV $matches = array(); foreach ($entries as $entry) { $basenode = $entry; break; } if ($basenode) { $article['content'] = $doc->saveXML($basenode); $article['plugin_data'] = "feedmod,$owner_uid:" . $article['plugin_data']; } } } else if (isset($article['stored']['content'])) { $article['content'] = $article['stored']['content']; } } return $article; } function hook_prefs_tab($args) { if ($args != "prefPrefs") return; print "
"; print "
"; $sometext = $this->host->get($this, "sometext"); print "
"; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print "
".__("Some text")."
"; print "

"; print "

"; print "
"; #pane } function save() { $sometext = explode(",", db_escape_string($this->link, $_POST["sometext"])); $sometext = array_map("trim", $sometext); $sometext = array_map("mb_strtolower", $sometext); $sometext = join(", ", $sometext); $this->host->set($this, "sometext", $sometext); echo __("Configuration saved."); } }