From 82749229a7f37c2554b2967c216ce02fec511ba3 Mon Sep 17 00:00:00 2001 From: Grummfy Date: Sun, 20 Jul 2014 17:11:11 +0200 Subject: [PATCH] Display the lsit of bridges --- index.php | 148 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 86 insertions(+), 62 deletions(-) diff --git a/index.php b/index.php index 423f7283..ff38ac32 100644 --- a/index.php +++ b/index.php @@ -15,7 +15,6 @@ date_default_timezone_set('UTC'); error_reporting(0); //ini_set('display_errors','1'); error_reporting(E_ALL); // For debugging only. - // extensions check if (!extension_loaded('openssl')) die('"openssl" extension not loaded. Please check "php.ini"'); @@ -24,8 +23,6 @@ if (!extension_loaded('openssl')) ini_set('user_agent', 'Mozilla/5.0 (X11; Linux x86_64; rv:30.0) Gecko/20121202 Firefox/30.0 (rss-bridge/0.1; +https://github.com/sebsauvage/rss-bridge)'); // ------- - - // default whitelist $whitelist_file = './whitelist.txt'; $whitelist_default = array( @@ -122,6 +119,74 @@ function getHelperButtonFormat($value, $name){ return ''; } +function displayBridgeCard($bridgeReference, $bridgeInformations, $formats, $isActive = true) +{ + $name = isset($bridgeInformations['homepage']) ? ''.$bridgeInformations['name'].'' : $bridgeInformations['name']; + $description = isset($bridgeInformations['description']) ? $bridgeInformations['description'] : 'No description provided'; + $card = << +

{$name}

+

+ {$description} +

+CARD; + if( isset($bridgeInformations['use']) && count($bridgeInformations['use']) > 0 ) + { + $card .= '
    ' . PHP_EOL; + foreach($bridgeInformations['use'] as $anUseNum => $anUse) + { + $card .= '
  1. ' . PHP_EOL; + $card .= '
    + + ' . PHP_EOL; + + foreach($anUse as $argName => $argDescription) + { + $idArg = 'arg-' . $bridgeReference . '-' . $anUseNum . '-' . $argName; + $card .= '' . PHP_EOL; + } + + if ($isActive) + { + foreach( $formats as $name => $infos ) + { + if ( isset($infos['name']) ) + { + $card .= getHelperButtonFormat($name, $infos['name']) . PHP_EOL; + } + } + } + else + { + $card .= 'Inactive'; + } + + $card .= '
  2. ' . PHP_EOL; + } + $card .= '
' . PHP_EOL; + } + else + { + $card .= '
+ + ' . PHP_EOL; + foreach ($formats as $name => $infos) + { + if (isset($infos['name']) ) + { + $card .= getHelperButtonFormat($name, $infos['name']) . PHP_EOL; + } + } + $card .= '
' . PHP_EOL; + } + + + $card .= isset($bridgeInformations['maintainer']) ? ''.$bridgeInformations['maintainer'].'' : ''; + $card .= ''; + + return $card; +} + $bridges = Bridge::searchInformation(); $formats = Format::searchInformation(); ?> @@ -145,67 +210,26 @@ $formats = Format::searchInformation();

·Reconnecting the Web·

$bridgeInformations): - - if(BridgeWhitelist($whitelist_selection, $bridgeReference)): - ?> -
-

'.$bridgeInformations['name'].'' : $bridgeInformations['name'] ?>

-

- -

- - 0 ): ?> -
    - $anUse): ?> -
  1. -
    - - - $argDescription) - { - $idArg = 'arg-' . $bridgeReference . '-' . $anUseNum . '-' . $argName; - echo ''; - } - - foreach( $formats as $name => $infos ) - { - if ( isset($infos['name']) ) - { - echo getHelperButtonFormat($name, $infos['name']); - } - } - ?> -
    -
  2. - -
- -
- - - $infos ) - { - if( isset($infos['name']) ) - { - echo getHelperButtonFormat($name, $infos['name']); - } - } - ?> -
- - '.$bridgeInformations['maintainer'].'' : '' ?> -
- $bridgeInformations) + { + if(BridgeWhitelist($whitelist_selection, $bridgeReference)) + { + echo displayBridgeCard($bridgeReference, $bridgeInformations, $formats); + $activeFoundBridgeCount++; + } + elseif ($showInactive) + { + // inactive bridges + $inactiveBridges .= displayBridgeCard($bridgeReference, $bridgeInformations, $formats, false) . PHP_EOL; + } + } + echo '
' . $inactiveBridges; ?>