rss-bridge/actions/ListAction.php

56 lines
1.6 KiB
PHP
Raw Normal View History

2019-02-06 18:34:51 +01:00
<?php
2019-02-06 18:34:51 +01:00
/**
* This file is part of RSS-Bridge, a PHP project capable of generating RSS and
* Atom feeds for websites that don't have one.
*
* For the full license information, please view the UNLICENSE file distributed
* with this source code.
*
* @package Core
* @license http://unlicense.org/ UNLICENSE
* @link https://github.com/rss-bridge/rss-bridge
2019-02-06 18:34:51 +01:00
*/
2022-06-22 18:30:37 +02:00
class ListAction implements ActionInterface
{
public function execute()
{
$list = new StdClass();
$list->bridges = [];
$list->total = 0;
2022-07-06 12:14:04 +02:00
$bridgeFactory = new \BridgeFactory();
2022-07-06 12:14:04 +02:00
foreach ($bridgeFactory->getBridgeNames() as $bridgeName) {
$bridge = $bridgeFactory->create($bridgeName);
if ($bridge === false) { // Broken bridge, show as inactive
$list->bridges[$bridgeName] = [
'status' => 'inactive'
];
continue;
}
2022-07-06 12:14:04 +02:00
$status = $bridgeFactory->isWhitelisted($bridgeName) ? 'active' : 'inactive';
$list->bridges[$bridgeName] = [
'status' => $status,
'uri' => $bridge->getURI(),
'donationUri' => $bridge->getDonationURI(),
'name' => $bridge->getName(),
'icon' => $bridge->getIcon(),
'parameters' => $bridge->getParameters(),
'maintainer' => $bridge->getMaintainer(),
'description' => $bridge->getDescription()
];
}
$list->total = count($list->bridges);
header('Content-Type: application/json');
echo json_encode($list, JSON_PRETTY_PRINT);
}
2019-02-06 18:34:51 +01:00
}