forked from projects/fipamo
78 lines
2 KiB
PHP
78 lines
2 KiB
PHP
<?php
|
|
use Psr\Http\Message\ResponseInterface as Response;
|
|
use Psr\Http\Message\ServerRequestInterface as Request;
|
|
use Slim\Factory\AppFactory;
|
|
use Slim\Views\Twig;
|
|
use Slim\Views\TwigMiddleware;
|
|
|
|
include "brain/controller/IndexControl.inc.php";
|
|
include "brain/controller/DashControl.inc.php";
|
|
|
|
require __DIR__ . "/vendor/autoload.php";
|
|
$app = AppFactory::create();
|
|
$twig = Twig::create("brain/views/default/");
|
|
$app->add(TwigMiddleware::create($app, $twig));
|
|
|
|
//Index
|
|
$app->get("/[{first}[/{second}]]", function (
|
|
Request $request,
|
|
Response $response,
|
|
array $args
|
|
) {
|
|
$view = Twig::fromRequest($request);
|
|
if (isset($args["first"])) {
|
|
$first = $args["first"];
|
|
if (is_numeric($first)) {
|
|
$response->getBody()->write("FIND A PAGE, B!");
|
|
} else {
|
|
//$response->getBody()->write("This is the dash, brah!");
|
|
if (isset($args["second"])) {
|
|
$section = $args["second"];
|
|
} else {
|
|
$section = "front";
|
|
}
|
|
|
|
$dash = new DashControl();
|
|
$pages = $dash->getPages($section);
|
|
|
|
$count = count($pages);
|
|
|
|
//$response->getBody()->write("There are ".$count." pages, champ");
|
|
|
|
return $view->render($response, "dash-index.twig", [
|
|
"title" => "Fipamo Dash",
|
|
"pages" => $pages,
|
|
"totalPages" => $count,
|
|
]);
|
|
}
|
|
} else {
|
|
$response->getBody()->write("No Params, Homie!");
|
|
}
|
|
|
|
if (isset($args["second"])) {
|
|
$year = $args["second"];
|
|
}
|
|
|
|
return $response;
|
|
});
|
|
|
|
//Dashboard Index
|
|
/**
|
|
$app->get('/@/dashboard', function (Request $request, Response $response) {
|
|
$index = new IndexControl();
|
|
$settings = new Settings();
|
|
$folks = $settings->getFolks();
|
|
$secret = $index->getSecret();
|
|
$view = Twig::fromRequest($request);
|
|
|
|
return $view->render($response, 'index.twig', [
|
|
'title' => 'This is Fipamo',
|
|
'name' => 'Ro',
|
|
'occupation'=>'pretty cool... I guess',
|
|
'folks' => $folks[0]['handle'],
|
|
'secret' => $secret
|
|
]);
|
|
});
|
|
**/
|
|
$app->run();
|