1
0
Fork 0
forked from blallo/rss-bridge

Correction de quelques bugs dans les bridges, qui apparaissent à cause du fait qu'ils sont tous instanciés lors du chargement de tout les bridges.

Ré-ajout et ré-utilisation de getName et getURI, qui permettent d'avoir des élements dynamiques.
Changement en public de certaines valeurs.
Changement du nom de certaines constantes, déja utilisés.

Signed-off-by: teromene <teromene@teromene.fr>
This commit is contained in:
teromene 2015-11-03 23:05:10 +00:00
parent 894eadbbda
commit a5a959dced
13 changed files with 75 additions and 17 deletions

View file

@ -30,6 +30,18 @@ class ABCTabsBridge extends BridgeAbstract{
}
}
public function getName() {
return "ABC Tabs Bridge";
}
public function getURI() {
return "http://www.abc-tabs.com/";
}
public function getCacheDuration(){
return 3600; // 1 hour
}

View file

@ -39,6 +39,17 @@ class AcrimedBridge extends BridgeAbstract{
}
public function getName() {
return "Acrimed Bridge";
}
public function getURI() {
return "http://www.acrimed.org/";
}
public function getCacheDuration(){
return 3600*2; // 2 hours

View file

@ -55,6 +55,18 @@ class DemoBridge extends BridgeAbstract{
}
public function getName() {
return "DemoBridge";
}
public function getURI() {
return "http://github.com/sebsauvage/rss-bridge";
}
public function getCacheDuration(){
return 3600; // 1 hour
}

View file

@ -12,7 +12,7 @@
* @use2(n="max number of returned items")
*/
define(GIPHY_LIMIT, 10);
define('GIPHY_LIMIT', 10);
class GiphyBridge extends BridgeAbstract{

View file

@ -1,7 +1,7 @@
<?php
require_once 'bridges/RssExpander.php';
define("SEXE", "http://sexes.blogs.liberation.fr");
define("RSS", "http://sexes.blogs.liberation.fr/feeds/");
define("SEXE_FEED", "http://sexes.blogs.liberation.fr/feeds/");
/**
* As it seems that Les 400 culs currently offer a full feed, we won't change it content here.
* But I'm ready for the day where it will ... again ... provide some truncated content
@ -20,7 +20,7 @@ class Les400Culs extends RssExpander{
public function collectData(array $param){
$param['url'] = RSS;
$param['url'] = SEXE_FEED;
parent::collectData($param);
}

View file

@ -9,9 +9,9 @@
*/
abstract class RssExpander extends HttpCachingBridgeAbstract{
protected $name;
private $uri;
private $description;
public $name;
public $uri;
public $description;
public function collectData(array $param){
if (empty($param['url'])) {
$this->returnError('There is no $param[\'url\'] for this RSS expander', 404);
@ -65,4 +65,4 @@ abstract class RssExpander extends HttpCachingBridgeAbstract{
public function getDescription() {
return $this->description;
}
}
}

View file

@ -14,7 +14,7 @@
class SoundCloudBridge extends BridgeAbstract{
private $request;
private $name;
public $name;
const CLIENT_ID = '0aca19eae3843844e4053c6d8fdb7875';
public function collectData(array $param){

View file

@ -10,11 +10,11 @@
*/
require_once 'bridges/RssExpander.php';
define("THE_OATMEAL", "http://theoatmeal.com/");
define("RSS", "http://feeds.feedburner.com/oatmealfeed");
define("THE_OATMEAL_RSS", "http://feeds.feedburner.com/oatmealfeed");
class TheOatmealBridge extends RssExpander{
public function collectData(array $param){
$param['url'] = RSS;
$param['url'] = THE_OATMEAL_RSS;
parent::collectData($param);
}

View file

@ -14,7 +14,7 @@
class WhydBridge extends BridgeAbstract{
private $request;
private $name;
public $name;
public function collectData(array $param){
$html = '';

View file

@ -14,7 +14,7 @@
class WordPressBridge extends BridgeAbstract {
private $url;
private $name;
public $name;
public function collectData(array $param) {
$this->processParams($param);

View file

@ -10,8 +10,8 @@ define('WORLD_OF_TANKS', 'http://worldoftanks.eu/');
define('NEWS', '/news/');
class WorldOfTanks extends HttpCachingBridgeAbstract{
private $lang = "fr";
private $uri = WORLD_OF_TANKS;
private $name = 'World of tanks news';
public $uri = WORLD_OF_TANKS;
public $name = 'World of tanks news';
public function collectData(array $param){
if (!empty($param['lang'])) {

View file

@ -102,8 +102,8 @@ try{
$format
->setDatas($bridge->getDatas())
->setExtraInfos(array(
'name' => $bridge->name,
'uri' => $bridge->uri,
'name' => $bridge->getName(),
'uri' => $bridge->getURI(),
))
->display();
die;
@ -140,7 +140,11 @@ function getHelperButtonsFormat($formats){
function displayBridgeCard($bridgeName, $formats, $isActive = true)
{
$bridgeElement = Bridge::create($bridgeName);
if($bridgeElement == false) {
return "";
}
$bridgeElement->loadMetadatas();
$name = '<a href="'.$bridgeElement->uri.'">'.$bridgeElement->name.'</a>';

View file

@ -8,6 +8,8 @@ interface BridgeInterface{
public function collectData(array $param);
public function getCacheDuration();
public function loadMetadatas();
public function getName();
public function getURI();
}
abstract class BridgeAbstract implements BridgeInterface{
@ -207,6 +209,19 @@ class Bridge{
throw new \LogicException('Please use ' . __CLASS__ . '::create for new object.');
}
/**
* Checks if a bridge is an instantiable bridge.
* @param string $nameBridge name of the bridge that you want to use
* @return true if it is an instantiable bridge, false otherwise.
*/
static public function isInstantiable($nameBridge) {
$re = new ReflectionClass($nameBridge);
return $re->IsInstantiable();
}
/**
* Create a new bridge object
* @param string $nameBridge Defined bridge name you want use
@ -225,7 +240,11 @@ class Bridge{
require_once $pathBridge;
return new $nameBridge();
if(Bridge::isInstantiable($nameBridge)) {
return new $nameBridge();
} else {
return FALSE;
}
}
static public function setDir($dirBridge){