diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/BridgeAbstract.php | 12 | ||||
-rw-r--r-- | lib/BridgeCard.php | 11 | ||||
-rw-r--r-- | lib/BridgeInterface.php | 7 | ||||
-rw-r--r-- | lib/Configuration.php | 3 | ||||
-rw-r--r-- | lib/FormatAbstract.php | 2 |
5 files changed, 32 insertions, 3 deletions
diff --git a/lib/BridgeAbstract.php b/lib/BridgeAbstract.php index 6158e3b9..917f5fec 100644 --- a/lib/BridgeAbstract.php +++ b/lib/BridgeAbstract.php @@ -41,6 +41,13 @@ abstract class BridgeAbstract implements BridgeInterface { const URI = ''; /** + * Donation URI to the site the bridge is intended to be used for. + * + * Use {@see BridgeAbstract::getDonationURI()} to read this parameter + */ + const DONATION_URI = ''; + + /** * A brief description of what the bridge can do * * Use {@see BridgeAbstract::getDescription()} to read this parameter @@ -342,6 +349,11 @@ abstract class BridgeAbstract implements BridgeInterface { } /** {@inheritdoc} */ + public function getDonationURI(){ + return static::DONATION_URI; + } + + /** {@inheritdoc} */ public function getCacheTimeout(){ return static::CACHE_TIMEOUT; } diff --git a/lib/BridgeCard.php b/lib/BridgeCard.php index 7bb758d5..9eb4c390 100644 --- a/lib/BridgeCard.php +++ b/lib/BridgeCard.php @@ -301,6 +301,10 @@ This bridge is not fetching its content through a secure connection</div>'; $icon = $bridge->getIcon(); $description = $bridge->getDescription(); $parameters = $bridge->getParameters(); + $donationUri = $bridge->getDonationURI(); + $maintainer = $bridge->getMaintainer(); + + $donationsAllowed = Configuration::getConfig('admin', 'donations'); if(defined('PROXY_URL') && PROXY_BYBRIDGE) { $parameters['global']['_noproxy'] = array( @@ -332,7 +336,6 @@ CARD; // Display form with cache timeout and/or noproxy options (if enabled) when bridge has no parameters } else if (count($parameters) === 1 && array_key_exists('global', $parameters)) { $card .= self::getForm($bridgeName, $formats, $isActive, $isHttps, '', $parameters['global']); - } else { foreach($parameters as $parameterName => $parameter) { @@ -351,7 +354,11 @@ CARD; } $card .= '<label class="showless" for="showmore-' . $bridgeName . '">Show less</label>'; - $card .= '<p class="maintainer">' . $bridge->getMaintainer() . '</p>'; + if($donationUri !== '' && $donationsAllowed) { + $card .= '<p class="maintainer">' . $maintainer . ' ~ <a href="' . $donationUri . '">Donate</a></p>'; + } else { + $card .= '<p class="maintainer">' . $maintainer . '</p>'; + } $card .= '</section>'; return $card; diff --git a/lib/BridgeInterface.php b/lib/BridgeInterface.php index e9309dbf..70625125 100644 --- a/lib/BridgeInterface.php +++ b/lib/BridgeInterface.php @@ -121,6 +121,13 @@ interface BridgeInterface { public function getURI(); /** + * Returns the bridge Donation URI + * + * @return string Bridge Donation URI + */ + public function getDonationURI(); + + /** * Returns the cache timeout * * @return int Cache timeout diff --git a/lib/Configuration.php b/lib/Configuration.php index 613089ab..7ab8294f 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -198,6 +198,9 @@ final class Configuration { && !filter_var(self::getConfig('admin', 'email'), FILTER_VALIDATE_EMAIL)) self::reportConfigurationError('admin', 'email', 'Is not a valid email address'); + if(!is_bool(self::getConfig('admin', 'donations'))) + self::reportConfigurationError('admin', 'donations', 'Is not a valid Boolean'); + if(!is_string(self::getConfig('error', 'output'))) self::reportConfigurationError('error', 'output', 'Is not a valid String'); diff --git a/lib/FormatAbstract.php b/lib/FormatAbstract.php index 5c4b87f9..29e86cb4 100644 --- a/lib/FormatAbstract.php +++ b/lib/FormatAbstract.php @@ -140,7 +140,7 @@ abstract class FormatAbstract implements FormatInterface { * @param array $extraInfos {@inheritdoc} */ public function setExtraInfos(array $extraInfos = array()){ - foreach(array('name', 'uri', 'icon') as $infoName) { + foreach(array('name', 'uri', 'icon', 'donationUri') as $infoName) { if(!isset($extraInfos[$infoName])) { $extraInfos[$infoName] = ''; } |