diff --git a/bridges/ABCTabsBridge.php b/bridges/ABCTabsBridge.php index ac0772de..7481f3a1 100644 --- a/bridges/ABCTabsBridge.php +++ b/bridges/ABCTabsBridge.php @@ -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 } diff --git a/bridges/AcrimedBridge.php b/bridges/AcrimedBridge.php index ae573f86..d0f5abfc 100644 --- a/bridges/AcrimedBridge.php +++ b/bridges/AcrimedBridge.php @@ -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 diff --git a/bridges/DemoBridge.php b/bridges/DemoBridge.php index 7c87675c..24cd3891 100644 --- a/bridges/DemoBridge.php +++ b/bridges/DemoBridge.php @@ -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 } diff --git a/bridges/GiphyBridge.php b/bridges/GiphyBridge.php index b0a4f899..f3c0d99b 100644 --- a/bridges/GiphyBridge.php +++ b/bridges/GiphyBridge.php @@ -12,7 +12,7 @@ * @use2(n="max number of returned items") */ -define(GIPHY_LIMIT, 10); +define('GIPHY_LIMIT', 10); class GiphyBridge extends BridgeAbstract{ diff --git a/bridges/Les400Culs.php b/bridges/Les400Culs.php index dcb17ae8..4694f406 100644 --- a/bridges/Les400Culs.php +++ b/bridges/Les400Culs.php @@ -1,7 +1,7 @@ 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; } -} \ No newline at end of file +} diff --git a/bridges/SoundcloudBridge.php b/bridges/SoundcloudBridge.php index 05c807bc..7bcc6d0a 100644 --- a/bridges/SoundcloudBridge.php +++ b/bridges/SoundcloudBridge.php @@ -14,7 +14,7 @@ class SoundCloudBridge extends BridgeAbstract{ private $request; - private $name; + public $name; const CLIENT_ID = '0aca19eae3843844e4053c6d8fdb7875'; public function collectData(array $param){ diff --git a/bridges/TheOatMealBridge.php b/bridges/TheOatMealBridge.php index 84b6954b..7342ec2b 100644 --- a/bridges/TheOatMealBridge.php +++ b/bridges/TheOatMealBridge.php @@ -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); } diff --git a/bridges/WhydBridge.php b/bridges/WhydBridge.php index 9bac7a05..060a7b62 100644 --- a/bridges/WhydBridge.php +++ b/bridges/WhydBridge.php @@ -14,7 +14,7 @@ class WhydBridge extends BridgeAbstract{ private $request; - private $name; + public $name; public function collectData(array $param){ $html = ''; diff --git a/bridges/WordPressBridge.php b/bridges/WordPressBridge.php index a2eee25b..2a182df3 100644 --- a/bridges/WordPressBridge.php +++ b/bridges/WordPressBridge.php @@ -14,7 +14,7 @@ class WordPressBridge extends BridgeAbstract { private $url; - private $name; + public $name; public function collectData(array $param) { $this->processParams($param); diff --git a/bridges/WorldOfTanks.php b/bridges/WorldOfTanks.php index ccc80bf5..f4de4773 100644 --- a/bridges/WorldOfTanks.php +++ b/bridges/WorldOfTanks.php @@ -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'])) { diff --git a/index.php b/index.php index 5a4dea80..30dee333 100644 --- a/index.php +++ b/index.php @@ -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 = ''.$bridgeElement->name.''; diff --git a/lib/Bridge.php b/lib/Bridge.php index 29ac6d2a..b4945202 100644 --- a/lib/Bridge.php +++ b/lib/Bridge.php @@ -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){