core: Use methods to access bridge information
Bridge information were exposed and accessed via public constants which doesn't work if you want to generate bridges dynamically as discussed in #402
This commit is contained in:
parent
c44fb25845
commit
d93d491d8e
3 changed files with 47 additions and 17 deletions
|
@ -228,10 +228,22 @@ abstract class BridgeAbstract implements BridgeInterface {
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,13 @@ interface BridgeInterface {
|
||||||
*/
|
*/
|
||||||
public function getCachable();
|
public function getCachable();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the description
|
||||||
|
*
|
||||||
|
* @return string Description
|
||||||
|
*/
|
||||||
|
public function getDescription();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return an array of extra information
|
* Return an array of extra information
|
||||||
*
|
*
|
||||||
|
@ -27,6 +34,13 @@ interface BridgeInterface {
|
||||||
*/
|
*/
|
||||||
public function getItems();
|
public function getItems();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the bridge maintainer
|
||||||
|
*
|
||||||
|
* @return string Bridge maintainer
|
||||||
|
*/
|
||||||
|
public function getMaintainer();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the bridge name
|
* Returns the bridge name
|
||||||
*
|
*
|
||||||
|
@ -34,6 +48,13 @@ interface BridgeInterface {
|
||||||
*/
|
*/
|
||||||
public function getName();
|
public function getName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the bridge parameters
|
||||||
|
*
|
||||||
|
* @return array Bridge parameters
|
||||||
|
*/
|
||||||
|
public function getParameters();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the bridge URI
|
* Returns the bridge URI
|
||||||
*
|
*
|
||||||
|
|
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