Add WordPressPluginUpdateBridge.

Fix phpcs check in WebFailBridge.
This commit is contained in:
Teromene 2017-03-03 13:27:41 +00:00
parent 100f3cd56d
commit 5d41a74067
2 changed files with 90 additions and 1 deletions

View file

@ -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'),

View file

@ -0,0 +1,87 @@
<?php
class WordPressPluginUpdateBridge extends BridgeAbstract {
const MAINTAINER = 'teromene';
const NAME = 'WordPress Plugins Update Bridge';
const URI = 'https://wordpress.org/plugins/';
const CACHE_TIMEOUT = 86400; // 24h = 86400s
const DESCRIPTION = 'Returns latest updates of WordPress.com plugins.';
const PARAMETERS = array(
array(
'pluginUrl' => 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());
}
}