diff --git a/bridges/WebfailBridge.php b/bridges/WebfailBridge.php index d4a6f13..fbe710b 100644 --- a/bridges/WebfailBridge.php +++ b/bridges/WebfailBridge.php @@ -42,7 +42,9 @@ class WebfailBridge extends BridgeAbstract { public function collectData(){ - ini_set('user_agent', 'Mozilla/5.0(X11; Linux x86_64; rv:30.0) Gecko/20121202 Firefox/30.0(rss-bridge/0.1; +https://github.com/RSS-Bridge/rss-bridge)'); + ini_set('user_agent', 'Mozilla/5.0(X11; Linux x86_64; rv:30.0) Gecko/20121202 Firefox/30.0(rss-bridge/0.1;\ + +https://github.com/RSS-Bridge/rss-bridge)'); + $html = getSimpleHTMLDOM($this->getURI() . $this->getInput('type')); $type = array_search($this->getInput('type'), diff --git a/bridges/WordPressPluginUpdateBridge.php b/bridges/WordPressPluginUpdateBridge.php new file mode 100644 index 0000000..a57ba1c --- /dev/null +++ b/bridges/WordPressPluginUpdateBridge.php @@ -0,0 +1,87 @@ + array( + 'name' => 'URL to the plugin', + 'required' => true + ) + ) + ); + + public function collectData(){ + + $request = str_replace('/', '', $this->getInput('pluginUrl')); + $page = self::URI . $request . '/changelog/'; + + $html = getSimpleHTMLDOM($page) + or returnServerError('No results for this query.'); + + $content = $html->find('.block-content', 0); + + $item = array(); + $item['content'] = ''; + $version = null; + + foreach($content->children() as $element) { + + if($element->tag != 'h4') { + + $item['content'] .= $element; + + } else { + + if($version == null) { + + $version = $element; + + } else { + + $item['title'] = $version; + $item['uri'] = 'https://downloads.wordpress.org/plugin/' . $request . '.' . strip_tags($version) . '.zip'; + $this->items[] = $item; + + $version = $element; + $item = array(); + $item['content'] = ''; + + } + + } + + } + + $item['uri'] = 'https://downloads.wordpress.org/plugin/' . $request . '.' . strip_tags($version) . '.zip'; + $item['title'] = $version; + $this->items[] = $item; + + } + + + public function getName(){ + if(!is_null($this->getInput('q'))){ + return $this->getInput('q') . ' : ' . self::NAME; + } + + return parent::getName(); + } + + private function getCachedDate($url){ + debugMessage('getting pubdate from url ' . $url . ''); + // Initialize cache + $cache = Cache::create('FileCache'); + $cache->setPath(CACHE_DIR . '/pages'); + $params = [$url]; + $cache->setParameters($params); + // Get cachefile timestamp + $time = $cache->getTime(); + return ($time !== false ? $time : time()); + } +}