mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-07-19 16:01:15 +02:00
refactor: general code base refactor (#2950)
* refactor * fix: bug in previous refactor * chore: exclude phpcompat sniff due to bug in phpcompat * fix: do not leak absolute paths * refactor/fix: batch extensions checking, fix DOS issue
This commit is contained in:
@@ -22,6 +22,28 @@
|
||||
*/
|
||||
final class BridgeList
|
||||
{
|
||||
/**
|
||||
* Create the entire home page
|
||||
*
|
||||
* @param bool $showInactive Inactive bridges are displayed on the home page,
|
||||
* if enabled.
|
||||
* @return string The home page
|
||||
*/
|
||||
public static function create($showInactive = true)
|
||||
{
|
||||
$totalBridges = 0;
|
||||
$totalActiveBridges = 0;
|
||||
|
||||
return '<!DOCTYPE html><html lang="en">'
|
||||
. BridgeList::getHead()
|
||||
. '<body onload="search()">'
|
||||
. BridgeList::getHeader()
|
||||
. BridgeList::getSearchbar()
|
||||
. BridgeList::getBridges($showInactive, $totalBridges, $totalActiveBridges)
|
||||
. BridgeList::getFooter($totalBridges, $totalActiveBridges, $showInactive)
|
||||
. '</body></html>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the document head
|
||||
*
|
||||
@@ -65,7 +87,7 @@ EOD;
|
||||
$totalActiveBridges = 0;
|
||||
$inactiveBridges = '';
|
||||
|
||||
$bridgeFactory = new \BridgeFactory();
|
||||
$bridgeFactory = new BridgeFactory();
|
||||
$bridgeClassNames = $bridgeFactory->getBridgeClassNames();
|
||||
|
||||
$formatFactory = new FormatFactory();
|
||||
@@ -126,7 +148,7 @@ EOD;
|
||||
*/
|
||||
private static function getSearchbar()
|
||||
{
|
||||
$query = filter_input(INPUT_GET, 'q', FILTER_SANITIZE_SPECIAL_CHARS);
|
||||
$query = filter_input(INPUT_GET, 'q', \FILTER_SANITIZE_SPECIAL_CHARS);
|
||||
|
||||
return <<<EOD
|
||||
<section class="searchbar">
|
||||
@@ -167,10 +189,10 @@ EOD;
|
||||
$inactive = '';
|
||||
|
||||
if ($totalActiveBridges !== $totalBridges) {
|
||||
if (!$showInactive) {
|
||||
$inactive = '<a href="?show_inactive=1"><button class="small">Show inactive bridges</button></a><br>';
|
||||
} else {
|
||||
if ($showInactive) {
|
||||
$inactive = '<a href="?show_inactive=0"><button class="small">Hide inactive bridges</button></a><br>';
|
||||
} else {
|
||||
$inactive = '<a href="?show_inactive=1"><button class="small">Show inactive bridges</button></a><br>';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,26 +206,4 @@ EOD;
|
||||
</section>
|
||||
EOD;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the entire home page
|
||||
*
|
||||
* @param bool $showInactive Inactive bridges are displayed on the home page,
|
||||
* if enabled.
|
||||
* @return string The home page
|
||||
*/
|
||||
public static function create($showInactive = true)
|
||||
{
|
||||
$totalBridges = 0;
|
||||
$totalActiveBridges = 0;
|
||||
|
||||
return '<!DOCTYPE html><html lang="en">'
|
||||
. BridgeList::getHead()
|
||||
. '<body onload="search()">'
|
||||
. BridgeList::getHeader()
|
||||
. BridgeList::getSearchbar()
|
||||
. BridgeList::getBridges($showInactive, $totalBridges, $totalActiveBridges)
|
||||
. BridgeList::getFooter($totalBridges, $totalActiveBridges, $showInactive)
|
||||
. '</body></html>';
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user