From 4180dafb4f0662fd11a800b3556aa4c952ed5f68 Mon Sep 17 00:00:00 2001 From: Markus Birth Date: Tue, 9 Apr 2013 12:16:49 +0200 Subject: Initial commit --- init.php | 118 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 init.php diff --git a/init.php b/init.php new file mode 100644 index 0000000..a00c3d5 --- /dev/null +++ b/init.php @@ -0,0 +1,118 @@ +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."); + } + +} -- cgit v1.3.1