forked from blallo/rss-bridge
Merge branch 'ImproveCore' of https://github.com/logmanoriginal/rss-bridge
This commit is contained in:
commit
6d1e8af982
39 changed files with 372 additions and 117 deletions
|
@ -51,10 +51,13 @@ class AmazonBridge extends BridgeAbstract {
|
||||||
));
|
));
|
||||||
|
|
||||||
public function getName(){
|
public function getName(){
|
||||||
|
if(!is_null($this->getInput('tld')) && !is_null($this->getInput('q'))){
|
||||||
return 'Amazon.'.$this->getInput('tld').': '.$this->getInput('q');
|
return 'Amazon.'.$this->getInput('tld').': '.$this->getInput('q');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return parent::getName();
|
||||||
|
}
|
||||||
|
|
||||||
public function collectData() {
|
public function collectData() {
|
||||||
|
|
||||||
$uri = 'https://www.amazon.'.$this->getInput('tld').'/';
|
$uri = 'https://www.amazon.'.$this->getInput('tld').'/';
|
||||||
|
|
|
@ -57,10 +57,18 @@ class AskfmBridge extends BridgeAbstract {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName(){
|
public function getName(){
|
||||||
|
if(!is_null($this->getInput('u'))){
|
||||||
return self::NAME . ' : ' . $this->getInput('u');
|
return self::NAME . ' : ' . $this->getInput('u');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return parent::getName();
|
||||||
|
}
|
||||||
|
|
||||||
public function getURI(){
|
public function getURI(){
|
||||||
|
if(!is_null($this->getInput('u'))){
|
||||||
return self::URI . urlencode($this->getInput('u')) . '/answers/more?page=0';
|
return self::URI . urlencode($this->getInput('u')) . '/answers/more?page=0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return parent::getURI();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,10 +46,18 @@ class BandcampBridge extends BridgeAbstract {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getURI(){
|
public function getURI(){
|
||||||
|
if(!is_null($this->getInput('tag'))){
|
||||||
return self::URI . 'tag/' . urlencode($this->getInput('tag')) . '?sort_field=date';
|
return self::URI . 'tag/' . urlencode($this->getInput('tag')) . '?sort_field=date';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return parent::getURI();
|
||||||
|
}
|
||||||
|
|
||||||
public function getName(){
|
public function getName(){
|
||||||
|
if(!is_null($this->getInput('tag'))){
|
||||||
return $this->getInput('tag') . ' - Bandcamp Tag';
|
return $this->getInput('tag') . ' - Bandcamp Tag';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return parent::getName();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,10 +28,18 @@ class BooruprojectBridge extends GelbooruBridge {
|
||||||
const PIDBYPAGE = 20;
|
const PIDBYPAGE = 20;
|
||||||
|
|
||||||
public function getURI(){
|
public function getURI(){
|
||||||
|
if(!is_null($this->getInput('i'))){
|
||||||
return 'http://' . $this->getInput('i') . '.booru.org/';
|
return 'http://' . $this->getInput('i') . '.booru.org/';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return parent::getURI();
|
||||||
|
}
|
||||||
|
|
||||||
public function getName(){
|
public function getName(){
|
||||||
|
if(!is_null($this->getInput('i'))){
|
||||||
return static::NAME . ' ' . $this->getInput('i');
|
return static::NAME . ' ' . $this->getInput('i');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return parent::getName();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,7 +83,11 @@ topic found in some section URLs, else all topics are selected.';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName(){
|
public function getName(){
|
||||||
|
if(!is_null($this->getInput('topic'))){
|
||||||
$topic = $this->getInput('topic');
|
$topic = $this->getInput('topic');
|
||||||
return 'CNET News Bridge' . (empty($topic) ? '' : ' - ' . $topic);
|
return 'CNET News Bridge' . (empty($topic) ? '' : ' - ' . $topic);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return parent::getName();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,9 +50,13 @@ class CpasbienBridge extends BridgeAbstract {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName(){
|
public function getName(){
|
||||||
|
if(!is_null($this->getInput('q'))){
|
||||||
return $this->getInput('q') . ' : ' . self::NAME;
|
return $this->getInput('q') . ' : ' . self::NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return parent::getName();
|
||||||
|
}
|
||||||
|
|
||||||
private function getCachedDate($url){
|
private function getCachedDate($url){
|
||||||
debugMessage('getting pubdate from url ' . $url . '');
|
debugMessage('getting pubdate from url ' . $url . '');
|
||||||
|
|
||||||
|
|
|
@ -116,6 +116,7 @@ class DailymotionBridge extends BridgeAbstract {
|
||||||
$uri .= '/' . $this->getInput('pa');
|
$uri .= '/' . $this->getInput('pa');
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
default: return parent::getURI();
|
||||||
}
|
}
|
||||||
return $uri;
|
return $uri;
|
||||||
}
|
}
|
||||||
|
|
|
@ -257,6 +257,11 @@ EOD;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName(){
|
public function getName(){
|
||||||
return isset($this->extraInfos['name']) ? $this->extraInfos['name'] : $this->authorName . ' - Facebook Bridge';
|
if(!empty($this->authorName)){
|
||||||
|
return isset($this->extraInfos['name']) ? $this->extraInfos['name'] : $this->authorName
|
||||||
|
. ' - Facebook Bridge';
|
||||||
|
}
|
||||||
|
|
||||||
|
return parent::getName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,9 +20,13 @@ class FourchanBridge extends BridgeAbstract {
|
||||||
));
|
));
|
||||||
|
|
||||||
public function getURI(){
|
public function getURI(){
|
||||||
|
if(!is_null($this->getInput('c')) && !is_null($this->getInput('t'))){
|
||||||
return static::URI . $this->getInput('c') . '/thread/' . $this->getInput('t');
|
return static::URI . $this->getInput('c') . '/thread/' . $this->getInput('t');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return parent::getURI();
|
||||||
|
}
|
||||||
|
|
||||||
public function collectData(){
|
public function collectData(){
|
||||||
|
|
||||||
$html = getSimpleHTMLDOM($this->getURI())
|
$html = getSimpleHTMLDOM($this->getURI())
|
||||||
|
|
|
@ -47,11 +47,13 @@ class GithubIssueBridge extends BridgeAbstract {
|
||||||
case 'Issue comments':
|
case 'Issue comments':
|
||||||
$name = static::NAME . ' ' . $name . ' #' . $this->getInput('i');
|
$name = static::NAME . ' ' . $name . ' #' . $this->getInput('i');
|
||||||
break;
|
break;
|
||||||
|
default: return parent::getName();
|
||||||
}
|
}
|
||||||
return $name;
|
return $name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getURI(){
|
public function getURI(){
|
||||||
|
if(!is_null($this->getInput('u')) && !is_null($this->getInput('p'))){
|
||||||
$uri = static::URI . $this->getInput('u') . '/' . $this->getInput('p') . '/issues';
|
$uri = static::URI . $this->getInput('u') . '/' . $this->getInput('p') . '/issues';
|
||||||
if($this->queriedContext === 'Issue comments'){
|
if($this->queriedContext === 'Issue comments'){
|
||||||
$uri .= '/' . $this->getInput('i');
|
$uri .= '/' . $this->getInput('i');
|
||||||
|
@ -61,6 +63,9 @@ class GithubIssueBridge extends BridgeAbstract {
|
||||||
return $uri;
|
return $uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return parent::getURI();
|
||||||
|
}
|
||||||
|
|
||||||
protected function extractIssueComment($issueNbr, $title, $comment){
|
protected function extractIssueComment($issueNbr, $title, $comment){
|
||||||
$class = $comment->getAttribute('class');
|
$class = $comment->getAttribute('class');
|
||||||
$classes = explode(' ', $class);
|
$classes = explode(' ', $class);
|
||||||
|
|
|
@ -42,10 +42,18 @@ class GoComicsBridge extends BridgeAbstract {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getURI(){
|
public function getURI(){
|
||||||
|
if(!is_null($this->getInput('comicname'))){
|
||||||
return self::URI . urlencode($this->getInput('comicname'));
|
return self::URI . urlencode($this->getInput('comicname'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return parent::getURI();
|
||||||
|
}
|
||||||
|
|
||||||
public function getName(){
|
public function getName(){
|
||||||
|
if(!is_null($this->getInput('comicname'))){
|
||||||
return $this->getInput('comicname') . ' - GoComics';
|
return $this->getInput('comicname') . ' - GoComics';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return parent::getName();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,6 +97,6 @@ class GooglePlusPostBridge extends BridgeAbstract{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getURI(){
|
public function getURI(){
|
||||||
return $this->_url ?: self::URI;
|
return $this->_url ?: parent::getURI();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,6 +55,10 @@ class GoogleSearchBridge extends BridgeAbstract {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName(){
|
public function getName(){
|
||||||
|
if(!is_null($this->getInput('q'))){
|
||||||
return $this->getInput('q') . ' - Google search';
|
return $this->getInput('q') . ' - Google search';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return parent::getName();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,10 +70,14 @@ class HDWallpapersBridge extends BridgeAbstract {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName(){
|
public function getName(){
|
||||||
|
if(!is_null($this->getInput('c')) && !is_null($this->getInput('r'))){
|
||||||
return 'HDWallpapers - '
|
return 'HDWallpapers - '
|
||||||
. str_replace(['__', '_'], [' & ', ' '], $this->getInput('c'))
|
. str_replace(['__', '_'], [' & ', ' '], $this->getInput('c'))
|
||||||
. ' ['
|
. ' ['
|
||||||
. $this->getInput('r')
|
. $this->getInput('r')
|
||||||
. ']';
|
. ']';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return parent::getName();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,10 +35,18 @@ class IdenticaBridge extends BridgeAbstract {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName(){
|
public function getName(){
|
||||||
|
if(!is_null($this->getInput('u'))){
|
||||||
return $this->getInput('u') . ' - Identica Bridge';
|
return $this->getInput('u') . ' - Identica Bridge';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return parent::getName();
|
||||||
|
}
|
||||||
|
|
||||||
public function getURI(){
|
public function getURI(){
|
||||||
|
if(!is_null($this->getInput('u'))){
|
||||||
return self::URI . urlencode($this->getInput('u'));
|
return self::URI . urlencode($this->getInput('u'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return parent::getURI();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,10 +53,18 @@ class InstagramBridge extends BridgeAbstract {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName(){
|
public function getName(){
|
||||||
|
if(!is_null($this->getInput('u'))){
|
||||||
return $this->getInput('u') . ' - Instagram Bridge';
|
return $this->getInput('u') . ' - Instagram Bridge';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return parent::getName();
|
||||||
|
}
|
||||||
|
|
||||||
public function getURI(){
|
public function getURI(){
|
||||||
|
if(!is_null($this->getInput('u'))){
|
||||||
return self::URI . urlencode($this->getInput('u'));
|
return self::URI . urlencode($this->getInput('u'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return parent::getURI();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,7 @@ class KununuBridge extends BridgeAbstract {
|
||||||
return ($this->companyName ?: $company) . ' - ' . self::NAME;
|
return ($this->companyName ?: $company) . ' - ' . self::NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
return paren::getName();
|
return parent::getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function collectData(){
|
public function collectData(){
|
||||||
|
|
|
@ -16,9 +16,13 @@ class MixCloudBridge extends BridgeAbstract {
|
||||||
));
|
));
|
||||||
|
|
||||||
public function getName(){
|
public function getName(){
|
||||||
|
if(!is_null($this->getInput('u'))){
|
||||||
return 'MixCloud - ' . $this->getInput('u');
|
return 'MixCloud - ' . $this->getInput('u');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return parent::getName();
|
||||||
|
}
|
||||||
|
|
||||||
public function collectData(){
|
public function collectData(){
|
||||||
|
|
||||||
$html = getSimpleHTMLDOM(self::URI . '/' . $this->getInput('u'))
|
$html = getSimpleHTMLDOM(self::URI . '/' . $this->getInput('u'))
|
||||||
|
|
|
@ -17,9 +17,13 @@ class NovelUpdatesBridge extends BridgeAbstract {
|
||||||
private $seriesTitle = '';
|
private $seriesTitle = '';
|
||||||
|
|
||||||
public function getURI(){
|
public function getURI(){
|
||||||
|
if(!is_null($this->getInput('n'))){
|
||||||
return static::URI . '/series/' . $this->getInput('n') . '/';
|
return static::URI . '/series/' . $this->getInput('n') . '/';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return parent::getURI();
|
||||||
|
}
|
||||||
|
|
||||||
public function collectData(){
|
public function collectData(){
|
||||||
$fullhtml = getSimpleHTMLDOM($this->getURI())
|
$fullhtml = getSimpleHTMLDOM($this->getURI())
|
||||||
or returnServerError('Could not request NovelUpdates, novel "' . $this->getInput('n') . '" not found');
|
or returnServerError('Could not request NovelUpdates, novel "' . $this->getInput('n') . '" not found');
|
||||||
|
@ -56,6 +60,10 @@ class NovelUpdatesBridge extends BridgeAbstract {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName(){
|
public function getName(){
|
||||||
|
if(!empty($this->seriesTitle)){
|
||||||
return $this->seriesTitle . ' - ' . static::NAME;
|
return $this->seriesTitle . ' - ' . static::NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return parent::getName();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,9 +27,13 @@ class OpenClassroomsBridge extends BridgeAbstract {
|
||||||
));
|
));
|
||||||
|
|
||||||
public function getURI(){
|
public function getURI(){
|
||||||
|
if(!is_null($this->getInput('u'))){
|
||||||
return self::URI . '/courses?categories=' . $this->getInput('u') . '&title=&sort=updatedAt+desc';
|
return self::URI . '/courses?categories=' . $this->getInput('u') . '&title=&sort=updatedAt+desc';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return parent::getURI();
|
||||||
|
}
|
||||||
|
|
||||||
public function collectData(){
|
public function collectData(){
|
||||||
$html = getSimpleHTMLDOM($this->getURI())
|
$html = getSimpleHTMLDOM($this->getURI())
|
||||||
or returnServerError('Could not request OpenClassrooms.');
|
or returnServerError('Could not request OpenClassrooms.');
|
||||||
|
|
|
@ -84,6 +84,7 @@ class ParuVenduImmoBridge extends BridgeAbstract {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName(){
|
public function getName(){
|
||||||
|
if(!is_null($this->getInput('minarea'))){
|
||||||
$request = '';
|
$request = '';
|
||||||
$minarea = $this->getInput('minarea');
|
$minarea = $this->getInput('minarea');
|
||||||
if(!empty($minarea)){
|
if(!empty($minarea)){
|
||||||
|
@ -95,4 +96,7 @@ class ParuVenduImmoBridge extends BridgeAbstract {
|
||||||
}
|
}
|
||||||
return 'Paru Vendu Immobilier' . $request;
|
return 'Paru Vendu Immobilier' . $request;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return parent::getName();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,6 +70,7 @@ class PickyWallpapersBridge extends BridgeAbstract {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getURI(){
|
public function getURI(){
|
||||||
|
if(!is_null($this->getInput('s')) && !is_null($this->getInput('r')) && !is_null($this->getInput('c'))){
|
||||||
$subcategory = $this->getInput('s');
|
$subcategory = $this->getInput('s');
|
||||||
$link = self::URI
|
$link = self::URI
|
||||||
. $this->getInput('r')
|
. $this->getInput('r')
|
||||||
|
@ -81,7 +82,11 @@ class PickyWallpapersBridge extends BridgeAbstract {
|
||||||
return $link;
|
return $link;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return parent::getURI();
|
||||||
|
}
|
||||||
|
|
||||||
public function getName(){
|
public function getName(){
|
||||||
|
if(!is_null($this->getInput('s'))){
|
||||||
$subcategory = $this->getInput('s');
|
$subcategory = $this->getInput('s');
|
||||||
return 'PickyWallpapers - '
|
return 'PickyWallpapers - '
|
||||||
. $this->getInput('c')
|
. $this->getInput('c')
|
||||||
|
@ -90,4 +95,7 @@ class PickyWallpapersBridge extends BridgeAbstract {
|
||||||
. $this->getInput('r')
|
. $this->getInput('r')
|
||||||
. ']';
|
. ']';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return parent::getName();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,10 +49,18 @@ class RTBFBridge extends BridgeAbstract {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getURI(){
|
public function getURI(){
|
||||||
|
if(!is_null($this->getInput('c'))){
|
||||||
return self::URI . 'detail?id=' . $this->getInput('c');
|
return self::URI . 'detail?id=' . $this->getInput('c');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return parent::getURI();
|
||||||
|
}
|
||||||
|
|
||||||
public function getName(){
|
public function getName(){
|
||||||
|
if(!is_null($this->getInput('c'))){
|
||||||
return $this->getInput('c') .' - RTBF Bridge';
|
return $this->getInput('c') .' - RTBF Bridge';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return parent::getName();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,6 +55,10 @@ class SoundCloudBridge extends BridgeAbstract {
|
||||||
|
|
||||||
}
|
}
|
||||||
public function getName(){
|
public function getName(){
|
||||||
|
if(!is_null($this->getInput('u'))){
|
||||||
return self::NAME . ' - ' . $this->getInput('u');
|
return self::NAME . ' - ' . $this->getInput('u');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return parent::getName();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,6 +61,10 @@ class SuperbWallpapersBridge extends BridgeAbstract {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName(){
|
public function getName(){
|
||||||
|
if(!is_null($this->getInput('c')) && !is_null($this->getInput('r'))){
|
||||||
return self::NAME . '- ' . $this->getInput('c') . ' [' . $this->getInput('r') . ']';
|
return self::NAME . '- ' . $this->getInput('c') . ' [' . $this->getInput('r') . ']';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return parent::getName();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,10 @@ class TagBoardBridge extends BridgeAbstract {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName(){
|
public function getName(){
|
||||||
|
if(!is_null($this->getInput('u'))){
|
||||||
return 'tagboard - ' . $this->getInput('u');
|
return 'tagboard - ' . $this->getInput('u');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return parent::getName();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,9 +81,13 @@ class Torrent9Bridge extends BridgeAbstract {
|
||||||
|
|
||||||
|
|
||||||
public function getName(){
|
public function getName(){
|
||||||
|
if(!is_null($this->getInput('q'))){
|
||||||
return $this->getInput('q') . ' : ' . self::NAME;
|
return $this->getInput('q') . ' : ' . self::NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return parent::getName();
|
||||||
|
}
|
||||||
|
|
||||||
private function getCachedDate($url){
|
private function getCachedDate($url){
|
||||||
debugMessage('getting pubdate from url ' . $url . '');
|
debugMessage('getting pubdate from url ' . $url . '');
|
||||||
// Initialize cache
|
// Initialize cache
|
||||||
|
|
|
@ -46,6 +46,7 @@ class TwitterBridge extends BridgeAbstract {
|
||||||
$specific = '@';
|
$specific = '@';
|
||||||
$param = 'u';
|
$param = 'u';
|
||||||
break;
|
break;
|
||||||
|
default: return parent::getName();
|
||||||
}
|
}
|
||||||
return 'Twitter ' . $specific . $this->getInput($param);
|
return 'Twitter ' . $specific . $this->getInput($param);
|
||||||
}
|
}
|
||||||
|
@ -61,6 +62,7 @@ class TwitterBridge extends BridgeAbstract {
|
||||||
return self::URI
|
return self::URI
|
||||||
. urlencode($this->getInput('u'))
|
. urlencode($this->getInput('u'))
|
||||||
. ($this->getInput('norep') ? '' : '/with_replies');
|
. ($this->getInput('norep') ? '' : '/with_replies');
|
||||||
|
default: return parent::getURI();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,9 +16,13 @@ class VkBridge extends BridgeAbstract {
|
||||||
);
|
);
|
||||||
|
|
||||||
public function getURI(){
|
public function getURI(){
|
||||||
|
if(!is_null($this->getInput('u'))){
|
||||||
return static::URI . urlencode($this->getInput('u'));
|
return static::URI . urlencode($this->getInput('u'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return parent::getURI();
|
||||||
|
}
|
||||||
|
|
||||||
public function collectData(){
|
public function collectData(){
|
||||||
$text_html = getContents($this->getURI())
|
$text_html = getContents($this->getURI())
|
||||||
or returnServerError('No results for group or user name "' . $this->getInput('u') . '".');
|
or returnServerError('No results for group or user name "' . $this->getInput('u') . '".');
|
||||||
|
|
|
@ -92,6 +92,7 @@ class WallpaperStopBridge extends BridgeAbstract {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName(){
|
public function getName(){
|
||||||
|
if(!is_null($this->getInput('s')) && !is_null($this->getInput('c')) && !is_null($this->getInput('r'))){
|
||||||
$subcategory = $this->getInput('s');
|
$subcategory = $this->getInput('s');
|
||||||
return 'WallpaperStop - '
|
return 'WallpaperStop - '
|
||||||
. $this->getInput('c')
|
. $this->getInput('c')
|
||||||
|
@ -100,4 +101,7 @@ class WallpaperStopBridge extends BridgeAbstract {
|
||||||
. $this->getInput('r')
|
. $this->getInput('r')
|
||||||
. ']';
|
. ']';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return parent::getName();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ class WebfailBridge extends BridgeAbstract {
|
||||||
|
|
||||||
public function getURI(){
|
public function getURI(){
|
||||||
if(is_null($this->getInput('language')))
|
if(is_null($this->getInput('language')))
|
||||||
return self::URI;
|
return parent::getURI();
|
||||||
|
|
||||||
// e.g.: https://en.webfail.com
|
// e.g.: https://en.webfail.com
|
||||||
return 'https://' . $this->getInput('language') . '.webfail.com';
|
return 'https://' . $this->getInput('language') . '.webfail.com';
|
||||||
|
|
|
@ -43,11 +43,15 @@ class WikipediaBridge extends BridgeAbstract {
|
||||||
));
|
));
|
||||||
|
|
||||||
public function getURI(){
|
public function getURI(){
|
||||||
|
if(!is_null($this->getInput('language'))){
|
||||||
return 'https://'
|
return 'https://'
|
||||||
. strtolower($this->getInput('language'))
|
. strtolower($this->getInput('language'))
|
||||||
. '.wikipedia.org';
|
. '.wikipedia.org';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return parent::getURI();
|
||||||
|
}
|
||||||
|
|
||||||
public function getName(){
|
public function getName(){
|
||||||
switch($this->getInput('subject')){
|
switch($this->getInput('subject')){
|
||||||
case 'tfa':
|
case 'tfa':
|
||||||
|
@ -56,9 +60,7 @@ class WikipediaBridge extends BridgeAbstract {
|
||||||
case 'dyk':
|
case 'dyk':
|
||||||
$subject = WIKIPEDIA_SUBJECT_DYK;
|
$subject = WIKIPEDIA_SUBJECT_DYK;
|
||||||
break;
|
break;
|
||||||
default:
|
default: return parent::getName();
|
||||||
$subject = WIKIPEDIA_SUBJECT_TFA;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch($subject){
|
switch($subject){
|
||||||
|
|
|
@ -56,7 +56,7 @@ class WordPressBridge extends FeedExpander {
|
||||||
public function getURI(){
|
public function getURI(){
|
||||||
$url = $this->getInput('url');
|
$url = $this->getInput('url');
|
||||||
if(empty($url)){
|
if(empty($url)){
|
||||||
$url = static::URI;
|
$url = parent::getURI();
|
||||||
}
|
}
|
||||||
return $url;
|
return $url;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,8 @@ class WorldOfTanksBridge extends BridgeAbstract {
|
||||||
|
|
||||||
private $title = '';
|
private $title = '';
|
||||||
|
|
||||||
function getURI(){
|
public function getURI(){
|
||||||
|
if(!is_null($this->getInput('lang'))){
|
||||||
$lang = $this->getInput('lang');
|
$lang = $this->getInput('lang');
|
||||||
$uri = self::URI . $lang . '/news/';
|
$uri = self::URI . $lang . '/news/';
|
||||||
if(!empty($this->getInput('category'))) {
|
if(!empty($this->getInput('category'))) {
|
||||||
|
@ -37,8 +38,11 @@ class WorldOfTanksBridge extends BridgeAbstract {
|
||||||
return $uri;
|
return $uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return parent::getURI();
|
||||||
|
}
|
||||||
|
|
||||||
public function getName(){
|
public function getName(){
|
||||||
return $this->title ?: self::NAME;
|
return $this->title ?: parent::getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function collectData(){
|
public function collectData(){
|
||||||
|
|
|
@ -20,7 +20,10 @@ abstract class BridgeAbstract implements BridgeInterface {
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function getCachable(){
|
public function getCachable(){
|
||||||
return array("items" => $this->getItems(), "extraInfos" => $this->getExtraInfos());
|
return array(
|
||||||
|
'items' => $this->getItems(),
|
||||||
|
'extraInfos' => $this->getExtraInfos()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -31,7 +34,13 @@ abstract class BridgeAbstract implements BridgeInterface {
|
||||||
return $this->items;
|
return $this->items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the input values for a given context. Existing values are
|
||||||
|
* overwritten.
|
||||||
|
*
|
||||||
|
* @param array $inputs Associative array of inputs
|
||||||
|
* @param string $context The context name
|
||||||
|
*/
|
||||||
protected function setInputs(array $inputs, $queriedContext){
|
protected function setInputs(array $inputs, $queriedContext){
|
||||||
// Import and assign all inputs to their context
|
// Import and assign all inputs to their context
|
||||||
foreach($inputs as $name => $value){
|
foreach($inputs as $name => $value){
|
||||||
|
@ -106,10 +115,20 @@ abstract class BridgeAbstract implements BridgeInterface {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the name of the context matching the provided inputs
|
||||||
|
*
|
||||||
|
* @param array $inputs Associative array of inputs
|
||||||
|
* @return mixed Returns the context name or null if no match was found
|
||||||
|
*/
|
||||||
protected function getQueriedContext(array $inputs){
|
protected function getQueriedContext(array $inputs){
|
||||||
$queriedContexts = array();
|
$queriedContexts = array();
|
||||||
|
|
||||||
|
// Detect matching context
|
||||||
foreach(static::PARAMETERS as $context => $set){
|
foreach(static::PARAMETERS as $context => $set){
|
||||||
$queriedContexts[$context] = null;
|
$queriedContexts[$context] = null;
|
||||||
|
|
||||||
|
// Check if all parameters of the context are satisfied
|
||||||
foreach($set as $id => $properties){
|
foreach($set as $id => $properties){
|
||||||
if(isset($inputs[$id]) && !empty($inputs[$id])){
|
if(isset($inputs[$id]) && !empty($inputs[$id])){
|
||||||
$queriedContexts[$context] = true;
|
$queriedContexts[$context] = true;
|
||||||
|
@ -119,8 +138,10 @@ abstract class BridgeAbstract implements BridgeInterface {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Abort if one of the globally required parameters is not satisfied
|
||||||
if(array_key_exists('global', static::PARAMETERS)
|
if(array_key_exists('global', static::PARAMETERS)
|
||||||
&& $queriedContexts['global'] === false){
|
&& $queriedContexts['global'] === false){
|
||||||
return null;
|
return null;
|
||||||
|
@ -128,14 +149,15 @@ abstract class BridgeAbstract implements BridgeInterface {
|
||||||
unset($queriedContexts['global']);
|
unset($queriedContexts['global']);
|
||||||
|
|
||||||
switch(array_sum($queriedContexts)){
|
switch(array_sum($queriedContexts)){
|
||||||
case 0:
|
case 0: // Found no match, is there a context without parameters?
|
||||||
foreach($queriedContexts as $context => $queried){
|
foreach($queriedContexts as $context => $queried){
|
||||||
if(is_null($queried)){
|
if(is_null($queried)){
|
||||||
return $context;
|
return $context;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
case 1: return array_search(true, $queriedContexts);
|
case 1: // Found unique match
|
||||||
|
return array_search(true, $queriedContexts);
|
||||||
default: return false;
|
default: return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -193,23 +215,44 @@ abstract class BridgeAbstract implements BridgeInterface {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getInput($input){
|
/**
|
||||||
|
* Returns the value for the provided input
|
||||||
|
*
|
||||||
|
* @param string $input The input name
|
||||||
|
* @return mixed Returns the input value or null if the input is not defined
|
||||||
|
*/
|
||||||
|
protected function getInput($input){
|
||||||
if(!isset($this->inputs[$this->queriedContext][$input]['value'])){
|
if(!isset($this->inputs[$this->queriedContext][$input]['value'])){
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return $this->inputs[$this->queriedContext][$input]['value'];
|
return $this->inputs[$this->queriedContext][$input]['value'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getDescription(){
|
||||||
|
return static::DESCRIPTION;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getMaintainer(){
|
||||||
|
return static::MAINTAINER;
|
||||||
|
}
|
||||||
|
|
||||||
public function getName(){
|
public function getName(){
|
||||||
return static::NAME;
|
return static::NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getParameters(){
|
||||||
|
return static::PARAMETERS;
|
||||||
|
}
|
||||||
|
|
||||||
public function getURI(){
|
public function getURI(){
|
||||||
return static::URI;
|
return static::URI;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getExtraInfos(){
|
public function getExtraInfos(){
|
||||||
return array("name" => $this->getName(), "uri" => $this->getURI());
|
return array(
|
||||||
|
'name' => $this->getName(),
|
||||||
|
'uri' => $this->getURI()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setCache(\CacheInterface $cache){
|
public function setCache(\CacheInterface $cache){
|
||||||
|
|
|
@ -1,6 +1,71 @@
|
||||||
<?php
|
<?php
|
||||||
interface BridgeInterface {
|
interface BridgeInterface {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collects data from the site
|
||||||
|
*/
|
||||||
public function collectData();
|
public function collectData();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an array of cachable elements
|
||||||
|
*
|
||||||
|
* @return array Associative array of cachable elements
|
||||||
|
*/
|
||||||
|
public function getCachable();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the description
|
||||||
|
*
|
||||||
|
* @return string Description
|
||||||
|
*/
|
||||||
|
public function getDescription();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return an array of extra information
|
||||||
|
*
|
||||||
|
* @return array Associative array of extra information
|
||||||
|
*/
|
||||||
|
public function getExtraInfos();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an array of collected items
|
||||||
|
*
|
||||||
|
* @return array Associative array of items
|
||||||
|
*/
|
||||||
|
public function getItems();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the bridge maintainer
|
||||||
|
*
|
||||||
|
* @return string Bridge maintainer
|
||||||
|
*/
|
||||||
|
public function getMaintainer();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the bridge name
|
||||||
|
*
|
||||||
|
* @return string Bridge name
|
||||||
|
*/
|
||||||
public function getName();
|
public function getName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the bridge parameters
|
||||||
|
*
|
||||||
|
* @return array Bridge parameters
|
||||||
|
*/
|
||||||
|
public function getParameters();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the bridge URI
|
||||||
|
*
|
||||||
|
* @return string Bridge URI
|
||||||
|
*/
|
||||||
public function getURI();
|
public function getURI();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the cache instance
|
||||||
|
*
|
||||||
|
* @param object CacheInterface The cache instance
|
||||||
|
*/
|
||||||
|
public function setCache(\CacheInterface $cache);
|
||||||
}
|
}
|
||||||
|
|
|
@ -190,10 +190,10 @@ abstract class FeedExpander extends BridgeAbstract {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getURI(){
|
public function getURI(){
|
||||||
return $this->uri;
|
return $this->uri ?: parent::getURI();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName(){
|
public function getName(){
|
||||||
return $this->name;
|
return $this->name ?: parent::getName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
25
lib/html.php
25
lib/html.php
|
@ -15,22 +15,21 @@ function displayBridgeCard($bridgeName, $formats, $isActive = true){
|
||||||
return $buttons;
|
return $buttons;
|
||||||
};
|
};
|
||||||
|
|
||||||
$getFormHeader = function($bridge){
|
$getFormHeader = function($bridgeName){
|
||||||
return <<<EOD
|
return <<<EOD
|
||||||
<form method="GET" action="?">
|
<form method="GET" action="?">
|
||||||
<input type="hidden" name="action" value="display" />
|
<input type="hidden" name="action" value="display" />
|
||||||
<input type="hidden" name="bridge" value="{$bridge}" />
|
<input type="hidden" name="bridge" value="{$bridgeName}" />
|
||||||
EOD;
|
EOD;
|
||||||
};
|
};
|
||||||
|
|
||||||
$bridgeElement = Bridge::create($bridgeName);
|
$bridge = Bridge::create($bridgeName);
|
||||||
$bridgeClass = $bridgeName . 'Bridge';
|
|
||||||
|
|
||||||
if($bridgeElement == false)
|
if($bridge == false)
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
$name = '<a href="' . $bridgeClass::URI . '">' . $bridgeClass::NAME . '</a>';
|
$name = '<a href="' . $bridge->getURI() . '">' . $bridge->getName() . '</a>';
|
||||||
$description = $bridgeClass::DESCRIPTION;
|
$description = $bridge->getDescription();
|
||||||
|
|
||||||
$card = <<<CARD
|
$card = <<<CARD
|
||||||
<section id="bridge-{$bridgeName}" data-ref="{$bridgeName}">
|
<section id="bridge-{$bridgeName}" data-ref="{$bridgeName}">
|
||||||
|
@ -43,7 +42,7 @@ EOD;
|
||||||
CARD;
|
CARD;
|
||||||
|
|
||||||
// If we don't have any parameter for the bridge, we print a generic form to load it.
|
// If we don't have any parameter for the bridge, we print a generic form to load it.
|
||||||
if(count($bridgeClass::PARAMETERS) == 0){
|
if(count($bridge->getParameters()) == 0){
|
||||||
|
|
||||||
$card .= $getFormHeader($bridgeName);
|
$card .= $getFormHeader($bridgeName);
|
||||||
|
|
||||||
|
@ -77,13 +76,13 @@ CARD;
|
||||||
$card .= '</form>' . PHP_EOL;
|
$card .= '</form>' . PHP_EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
$hasGlobalParameter = array_key_exists('global', $bridgeClass::PARAMETERS);
|
$hasGlobalParameter = array_key_exists('global', $bridge->getParameters());
|
||||||
|
|
||||||
if($hasGlobalParameter){
|
if($hasGlobalParameter){
|
||||||
$globalParameters = $bridgeClass::PARAMETERS['global'];
|
$globalParameters = $bridge->getParameters()['global'];
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($bridgeClass::PARAMETERS as $parameterName => $parameter){
|
foreach($bridge->getParameters() as $parameterName => $parameter){
|
||||||
if(!is_numeric($parameterName) && $parameterName == 'global')
|
if(!is_numeric($parameterName) && $parameterName == 'global')
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -251,7 +250,7 @@ CARD;
|
||||||
}
|
}
|
||||||
|
|
||||||
$card .= '<label class="showless" for="showmore-' . $bridgeName . '">Show less</label>';
|
$card .= '<label class="showless" for="showmore-' . $bridgeName . '">Show less</label>';
|
||||||
$card .= '<p class="maintainer">' . $bridgeClass::MAINTAINER . '</p>';
|
$card .= '<p class="maintainer">' . $bridge->getMaintainer() . '</p>';
|
||||||
$card .= '</section>';
|
$card .= '</section>';
|
||||||
|
|
||||||
return $card;
|
return $card;
|
||||||
|
@ -288,5 +287,3 @@ function defaultImageSrcTo($content, $server){
|
||||||
}
|
}
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
Loading…
Reference in a new issue