I will finish this in a little bit
This commit is contained in:
parent
4143a75944
commit
721d9da998
3 changed files with 75 additions and 1 deletions
53
src/Plugins/Admin/Admin.php
Normal file
53
src/Plugins/Admin/Admin.php
Normal 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';
|
||||
}
|
||||
}
|
21
src/Plugins/Admin/Controller.php
Normal file
21
src/Plugins/Admin/Controller.php
Normal 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();
|
||||
});
|
||||
}
|
||||
}
|
|
@ -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';
|
||||
|
|
Loading…
Add table
Reference in a new issue