Icons: Allow Bridge-specified icons (#788)

This commit is contained in:
Walter Barrett 2018-08-21 11:46:47 -04:00 committed by LogMANOriginal
parent c4cccfe0f3
commit 704a87ad97
8 changed files with 32 additions and 4 deletions

View file

@ -18,7 +18,11 @@ class AtomFormat extends FormatAbstract{
$uri = !empty($extraInfos['uri']) ? $extraInfos['uri'] : 'https://github.com/RSS-Bridge/rss-bridge';
$uriparts = parse_url($uri);
if(!empty($extraInfos['icon'])) {
$icon = $extraInfos['icon'];
} else {
$icon = $this->xml_encode($uriparts['scheme'] . '://' . $uriparts['host'] .'/favicon.ico');
}
$uri = $this->xml_encode($uri);

View file

@ -126,6 +126,7 @@ try {
'status' => $status,
'uri' => $bridge->getURI(),
'name' => $bridge->getName(),
'icon' => $bridge->getIcon(),
'parameters' => $bridge->getParameters(),
'maintainer' => $bridge->getMaintainer(),
'description' => $bridge->getDescription()

View file

@ -246,6 +246,15 @@ abstract class BridgeAbstract implements BridgeInterface {
return static::NAME;
}
public function getIcon(){
// Return cached icon when bridge is using cached data
if(isset($this->extraInfos)) {
return $this->extraInfos['icon'];
}
return '';
}
public function getParameters(){
return static::PARAMETERS;
}
@ -262,7 +271,8 @@ abstract class BridgeAbstract implements BridgeInterface {
public function getExtraInfos(){
return array(
'name' => $this->getName(),
'uri' => $this->getURI()
'uri' => $this->getURI(),
'icon' => $this->getIcon()
);
}

View file

@ -201,6 +201,7 @@ This bridge is not fetching its content through a secure connection</div>';
$uri = $bridge->getURI();
$name = $bridge->getName();
$icon = $bridge->getIcon();
$description = $bridge->getDescription();
$parameters = $bridge->getParameters();

View file

@ -48,6 +48,13 @@ interface BridgeInterface {
*/
public function getName();
/**
* Returns the bridge icon
*
* @return string Bridge icon
*/
public function getIcon();
/**
* Returns the bridge parameters
*

View file

@ -205,4 +205,8 @@ abstract class FeedExpander extends BridgeAbstract {
public function getName(){
return $this->name ?: parent::getName();
}
public function getIcon(){
return $this->icon ?: parent::getIcon();
}
}

View file

@ -51,12 +51,12 @@ abstract class FormatAbstract implements FormatInterface {
}
/**
* Define common informations can be required by formats and set default value for unknow values
* Define common informations can be required by formats and set default value for unknown values
* @param array $extraInfos array with know informations (there isn't merge !!!)
* @return this
*/
public function setExtraInfos(array $extraInfos = array()){
foreach(array('name', 'uri') as $infoName) {
foreach(array('name', 'uri', 'icon') as $infoName) {
if(!isset($extraInfos[$infoName])) {
$extraInfos[$infoName] = '';
}

View file

@ -62,6 +62,7 @@ require_once $vendorLibPhpUrlJoin;
->setExtraInfos(array(
'name' => $bridge->getName(),
'uri' => $bridge->getURI(),
'icon' => $bridge->getIcon(),
))
->display();