I will finish this in a little bit

This commit is contained in:
Belle Aerni 2023-11-10 06:42:16 -08:00
parent 4143a75944
commit 721d9da998
3 changed files with 75 additions and 1 deletions

View file

@ -0,0 +1,53 @@
<?php
namespace Plugins\Admin;
use AntCMS\AntPlugin;
use AntCMS\AntConfig;
use AntCMS\AntTools;
use AntCMS\AntCMS;
use AntCMS\AntTwig;
use AntCMS\AntAuth;
use AntCMS\AntUsers;
class Admin extends AntPlugin
{
protected AntAuth $antAuth;
protected AntTwig $antTwig;
protected array $params = [
'AntCMSTitle' => 'AntCMS Admin Dashboard',
'AntCMSDescription' => 'The AntCMS admin dashboard',
'AntCMSAuthor' => 'AntCMS',
'AntCMSKeywords' => '',
];
public function __construct()
{
$this->antAuth = new AntAuth;
$this->antTwig = new AntTwig;
$this->antAuth->checkAuth();
}
public function renderIndex()
{
$this->params['user'] = AntUsers::getUserPublicalKeys($this->antAuth->getUsername());
$response = $this->response;
$response->getBody()->write($this->antTwig->renderWithSubLayout('admin_landing', $this->params));
return $response;
}
public function getName(): string
{
return 'Admin';
}
/**
* @return string
*/
private function boolToWord(bool $value)
{
return $value ? 'true' : 'false';
}
}

View file

@ -0,0 +1,21 @@
<?php
namespace Plugins\Admin;
use \Slim\App;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
class Controller
{
public function registerRoutes(App $app)
{
$profilePlugin = new Admin;
$app->get('/admin', function (Request $request, Response $response) use ($profilePlugin) {
$profilePlugin->setRequest($request);
$profilePlugin->SetResponse($response);
return $profilePlugin->renderIndex();
});
}
}

View file

@ -2,4 +2,4 @@
$basedir = dirname(__DIR__, 2);
$srcdir = $basedir . DIRECTORY_SEPARATOR . 'src';
include_once $srcdir . DIRECTORY_SEPARATOR . 'Bootstrap.php';
include_once $srcdir . DIRECTORY_SEPARATOR . 'bootstrap.php';