forked from seblucas/cops
-
Notifications
You must be signed in to change notification settings - Fork 7
/
tables.php
34 lines (30 loc) · 1.02 KB
/
tables.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
/**
* COPS (Calibre OPDS PHP Server) endpoint for datatables (TODO)
* URL format: tables.php
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Sébastien Lucas <sebastien@slucas.fr>
* @author mikespub
*/
use SebLucas\Cops\Framework;
use SebLucas\Cops\Input\Route;
use SebLucas\Cops\Output\Format;
use SebLucas\Cops\Output\Response;
use SebLucas\Cops\Output\RestApi;
require_once __DIR__ . '/config/config.php';
Framework::init();
$data = ['link' => Route::link(RestApi::$handler)];
$data['thead'] = '<tr><th>Route</th><th>Description</th></tr>';
$data['tbody'] = '';
foreach (Route::getRoutes() as $route => $queryParams) {
if (str_contains($route, '{')) {
continue;
}
$data['tbody'] .= '<tr><td><a href="#" class="route">' . $route . '</a></td><td></td></tr>';
}
$data['tfoot'] = $data['thead'];
$template = __DIR__ . '/templates/tables.html';
$response = new Response('text/html;charset=utf-8');
$response->setContent(Format::template($data, $template));
$response->send();