mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2024-12-04 11:41:07 +03:00
a4b9611e66
- Do not add spaces after opening or before closing parenthesis // Wrong if( !is_null($var) ) { ... } // Right if(!is_null($var)) { ... } - Add space after closing parenthesis // Wrong if(true){ ... } // Right if(true) { ... } - Add body into new line - Close body in new line // Wrong if(true) { ... } // Right if(true) { ... } Notice: Spaces after keywords are not detected: // Wrong (not detected) // -> space after 'if' and missing space after 'else' if (true) { ... } else{ ... } // Right if(true) { ... } else { ... }
87 lines
1.9 KiB
PHP
87 lines
1.9 KiB
PHP
<?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());
|
|
}
|
|
}
|