diff --git a/lib/BridgeAbstract.php b/lib/BridgeAbstract.php index cc13044..2b1c763 100644 --- a/lib/BridgeAbstract.php +++ b/lib/BridgeAbstract.php @@ -21,7 +21,7 @@ abstract class BridgeAbstract implements BridgeInterface { */ public function getCachable(){ return array( - 'items' => $this->getItems(), + 'items' => $this->getItems(), 'extraInfos' => $this->getExtraInfos() ); } @@ -35,7 +35,7 @@ abstract class BridgeAbstract implements BridgeInterface { } /** - * Sets the input values for a given context. Existing values are + * Sets the input values for a given context. Existing values are * overwritten. * * @param array $inputs Associative array of inputs @@ -228,17 +228,29 @@ abstract class BridgeAbstract implements BridgeInterface { return $this->inputs[$this->queriedContext][$input]['value']; } + public function getDescription(){ + return static::DESCRIPTION; + } + + public function getMaintainer(){ + return static::MAINTAINER; + } + public function getName(){ return static::NAME; } + public function getParameters(){ + return static::PARAMETERS; + } + public function getURI(){ return static::URI; } public function getExtraInfos(){ return array( - 'name' => $this->getName(), + 'name' => $this->getName(), 'uri' => $this->getURI() ); } diff --git a/lib/BridgeInterface.php b/lib/BridgeInterface.php index fbb7a0f..a4add2c 100644 --- a/lib/BridgeInterface.php +++ b/lib/BridgeInterface.php @@ -13,6 +13,13 @@ interface BridgeInterface { */ public function getCachable(); + /** + * Returns the description + * + * @return string Description + */ + public function getDescription(); + /** * Return an array of extra information * @@ -27,6 +34,13 @@ interface BridgeInterface { */ public function getItems(); + /** + * Returns the bridge maintainer + * + * @return string Bridge maintainer + */ + public function getMaintainer(); + /** * Returns the bridge name * @@ -34,6 +48,13 @@ interface BridgeInterface { */ public function getName(); + /** + * Returns the bridge parameters + * + * @return array Bridge parameters + */ + public function getParameters(); + /** * Returns the bridge URI * diff --git a/lib/html.php b/lib/html.php index b13818b..1b9b5ab 100644 --- a/lib/html.php +++ b/lib/html.php @@ -15,22 +15,21 @@ function displayBridgeCard($bridgeName, $formats, $isActive = true){ return $buttons; }; - $getFormHeader = function($bridge){ + $getFormHeader = function($bridgeName){ return << - + EOD; }; - $bridgeElement = Bridge::create($bridgeName); - $bridgeClass = $bridgeName . 'Bridge'; + $bridge = Bridge::create($bridgeName); - if($bridgeElement == false) + if($bridge == false) return ""; - $name = '' . $bridgeClass::NAME . ''; - $description = $bridgeClass::DESCRIPTION; + $name = '' . $bridge->getName() . ''; + $description = $bridge->getDescription(); $card = << @@ -43,7 +42,7 @@ EOD; CARD; // 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); @@ -77,13 +76,13 @@ CARD; $card .= '' . PHP_EOL; } - $hasGlobalParameter = array_key_exists('global', $bridgeClass::PARAMETERS); + $hasGlobalParameter = array_key_exists('global', $bridge->getParameters()); 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') continue; @@ -251,7 +250,7 @@ CARD; } $card .= ''; - $card .= '

' . $bridgeClass::MAINTAINER . '

'; + $card .= '

' . $bridge->getMaintainer() . '

'; $card .= ''; return $card; @@ -288,5 +287,3 @@ function defaultImageSrcTo($content, $server){ } return $content; } - -?>