VENOM-10: added files x.tpl, x.php Modules
This commit is contained in:
parent
3d92f5347a
commit
f9dd03193e
33 changed files with 975 additions and 35 deletions
|
|
@ -4,6 +4,7 @@
|
|||
namespace Venom\Admin\Routes;
|
||||
|
||||
use Venom\Core\ArgumentHandler;
|
||||
use Venom\Core\Config;
|
||||
use Venom\Helper\TemplateUtil;
|
||||
use Venom\Routing\Route;
|
||||
|
||||
|
|
@ -11,8 +12,10 @@ class TemplateLoader implements Route
|
|||
{
|
||||
public function handle(): bool
|
||||
{
|
||||
header('Expires: ' . gmdate('D, d M Y H:i:s \G\M\T', time() + (60 * 60 * 60 * 30)));
|
||||
header('Cache-Control: public');
|
||||
if (!Config::getInstance()->isDevMode()) {
|
||||
header('Expires: ' . gmdate('D, d M Y H:i:s \G\M\T', time() + (60 * 60 * 60 * 30)));
|
||||
header('Cache-Control: public');
|
||||
}
|
||||
$id = ArgumentHandler::get()->getItem('tpl', '..');
|
||||
if (strpos($id, '..')) {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ class DatabaseHandler
|
|||
}
|
||||
}
|
||||
|
||||
public function getOne(string $query, array $args): ?DatabaseObject
|
||||
public function getOne(string $query, array $args = []): ?DatabaseObject
|
||||
{
|
||||
$data = $this->getAll($query, $args);
|
||||
if (count($data) > 0) {
|
||||
|
|
@ -58,7 +58,7 @@ class DatabaseHandler
|
|||
return null;
|
||||
}
|
||||
|
||||
public function getAll(string $query, array $args): array
|
||||
public function getAll(string $query, array $args = []): array
|
||||
{
|
||||
$stmt = $this->db->prepare($query);
|
||||
$stmt->setFetchMode(PDO::FETCH_CLASS, DatabaseObject::class);
|
||||
|
|
@ -66,7 +66,7 @@ class DatabaseHandler
|
|||
return $stmt->fetchAll();
|
||||
}
|
||||
|
||||
public function execute(string $query, array $args): bool
|
||||
public function execute(string $query, array $args = []): bool
|
||||
{
|
||||
$stmt = $this->db->prepare($query);
|
||||
return $stmt->execute($args);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ namespace Venom\Helper;
|
|||
|
||||
class AdminHelper
|
||||
{
|
||||
public static function getResponse($content, bool $shouldReload = false, string $component = '', $extra = false)
|
||||
public static function sendResponse($content, string $component = '', bool $shouldReload = false, $extra = false)
|
||||
{
|
||||
$response = [
|
||||
'content' => $content,
|
||||
|
|
|
|||
78
src/modules/MetaDataModule.php
Normal file
78
src/modules/MetaDataModule.php
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace Modules;
|
||||
|
||||
|
||||
use Venom\Core\Config;
|
||||
use Venom\Core\Module;
|
||||
use Venom\Helper\AdminHelper;
|
||||
use Venom\Routing\Route;
|
||||
use Venom\Routing\Router;
|
||||
use Venom\Venom;
|
||||
|
||||
class MetaDataModule implements Module, Route
|
||||
{
|
||||
|
||||
public function register(Venom $venom): bool
|
||||
{
|
||||
if (Config::getInstance()->isAdmin()) {
|
||||
$this->registerAdminRoutes($venom);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function init(): void
|
||||
{
|
||||
}
|
||||
|
||||
private function registerAdminRoutes(Venom $venom)
|
||||
{
|
||||
$venom->getRouter(Router::ADMIN_ROUTER)->addRoutes([
|
||||
'/metaData' => [
|
||||
'cl' => MetaDataModule::class,
|
||||
'roles' => ['ROLE_ADMIN'],
|
||||
'routes' => [
|
||||
'*' => [
|
||||
"GET" => 'get',
|
||||
],
|
||||
'1' => [
|
||||
"GET" => 'getById',
|
||||
"POST" => 'update',
|
||||
"PUT" => 'insert',
|
||||
]
|
||||
]
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
public function get()
|
||||
{
|
||||
AdminHelper::sendResponse([
|
||||
'metaData' => [
|
||||
['id' => 1, 'name' => 'engineertrooper', 'icon' => 'vt-edit'],
|
||||
['id' => 2, 'name' => 'versustunze', 'icon' => 'vt-edit']
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function insert(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getById($id)
|
||||
{
|
||||
AdminHelper::sendResponse([
|
||||
'caseName' => 'ROLE_ADMIN',
|
||||
'id' => $id,
|
||||
'name' => 'Admin',
|
||||
'icon' => 'vt-visibility',
|
||||
]);
|
||||
}
|
||||
}
|
||||
81
src/modules/OverviewModule.php
Normal file
81
src/modules/OverviewModule.php
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace Modules;
|
||||
|
||||
|
||||
use Venom\Core\Config;
|
||||
use Venom\Core\Module;
|
||||
use Venom\Helper\AdminHelper;
|
||||
use Venom\Routing\Route;
|
||||
use Venom\Routing\Router;
|
||||
use Venom\Venom;
|
||||
|
||||
class OverviewModule implements Module, Route
|
||||
{
|
||||
|
||||
public function register(Venom $venom): bool
|
||||
{
|
||||
if (Config::getInstance()->isAdmin()) {
|
||||
$this->registerAdminRoutes($venom);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function init(): void
|
||||
{
|
||||
}
|
||||
|
||||
private function registerAdminRoutes(Venom $venom)
|
||||
{
|
||||
$venom->getRouter(Router::ADMIN_ROUTER)->addRoutes([
|
||||
'/overview' => [
|
||||
'cl' => OverviewModule::class,
|
||||
'roles' => ['ROLE_ADMIN'],
|
||||
'routes' => [
|
||||
'*' => [
|
||||
"GET" => 'get',
|
||||
],
|
||||
'1' => [
|
||||
"GET" => 'getById',
|
||||
"POST" => 'update',
|
||||
"PUT" => 'insert',
|
||||
]
|
||||
]
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
public function get()
|
||||
{
|
||||
AdminHelper::sendResponse([
|
||||
'pages' => [
|
||||
['id' => 1, 'name' => 'Flamingos going wild!', 'icon' => 'vt-edit'],
|
||||
['id' => 2, 'name' => 'Turbinen sind geil.', 'icon' => 'vt-edit'],
|
||||
['id' => 3, 'name' => 'Aufbau und Umbau des neuen VENOMs Plugins', 'icon' => 'vt-edit'],
|
||||
['id' => 4, 'name' => 'Aber Mama hat gesagt!', 'icon' => 'vt-edit'],
|
||||
['id' => 5, 'name' => 'Frische Fische nur heute!', 'icon' => 'vt-edit']
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function insert(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getById($id)
|
||||
{
|
||||
AdminHelper::sendResponse([
|
||||
'caseName' => 'ROLE_ADMIN',
|
||||
'id' => $id,
|
||||
'name' => 'Admin',
|
||||
'icon' => 'vt-visibility',
|
||||
]);
|
||||
}
|
||||
}
|
||||
81
src/modules/PageModule.php
Normal file
81
src/modules/PageModule.php
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace Modules;
|
||||
|
||||
|
||||
use Venom\Core\Config;
|
||||
use Venom\Core\Module;
|
||||
use Venom\Helper\AdminHelper;
|
||||
use Venom\Routing\Route;
|
||||
use Venom\Routing\Router;
|
||||
use Venom\Venom;
|
||||
|
||||
class PageModule implements Module, Route
|
||||
{
|
||||
|
||||
public function register(Venom $venom): bool
|
||||
{
|
||||
if (Config::getInstance()->isAdmin()) {
|
||||
$this->registerAdminRoutes($venom);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function init(): void
|
||||
{
|
||||
}
|
||||
|
||||
private function registerAdminRoutes(Venom $venom)
|
||||
{
|
||||
$venom->getRouter(Router::ADMIN_ROUTER)->addRoutes([
|
||||
'/pages' => [
|
||||
'cl' => PageModule::class,
|
||||
'roles' => ['ROLE_ADMIN'],
|
||||
'routes' => [
|
||||
'*' => [
|
||||
"GET" => 'get',
|
||||
],
|
||||
'1' => [
|
||||
"GET" => 'getById',
|
||||
"POST" => 'update',
|
||||
"PUT" => 'insert',
|
||||
]
|
||||
]
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
public function get()
|
||||
{
|
||||
AdminHelper::sendResponse([
|
||||
'pages' => [
|
||||
['id' => 1, 'name' => 'Flamingos going wild!', 'icon' => 'vt-edit'],
|
||||
['id' => 2, 'name' => 'Turbinen sind geil.', 'icon' => 'vt-edit'],
|
||||
['id' => 3, 'name' => 'Aufbau und Umbau des neuen VENOMs Plugins', 'icon' => 'vt-edit'],
|
||||
['id' => 4, 'name' => 'Aber Mama hat gesagt!', 'icon' => 'vt-edit'],
|
||||
['id' => 5, 'name' => 'Frische Fische nur heute!', 'icon' => 'vt-edit']
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function insert(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getById($id)
|
||||
{
|
||||
AdminHelper::sendResponse([
|
||||
'caseName' => 'ROLE_ADMIN',
|
||||
'id' => $id,
|
||||
'name' => 'Admin',
|
||||
'icon' => 'vt-visibility',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@ namespace Modules;
|
|||
|
||||
|
||||
use Venom\Core\Config;
|
||||
use Venom\Core\DatabaseHandler;
|
||||
use Venom\Core\Module;
|
||||
use Venom\Helper\AdminHelper;
|
||||
use Venom\Routing\Route;
|
||||
|
|
@ -48,7 +49,8 @@ class RoleModule implements Module, Route
|
|||
|
||||
public function get()
|
||||
{
|
||||
AdminHelper::getResponse([
|
||||
//$req = DatabaseHandler::get()->getAll("SELECT * FROM roles");
|
||||
AdminHelper::sendResponse([
|
||||
'roles' => [
|
||||
['id' => 1, 'name' => 'Admin', 'icon' => 'vt-visibility'],
|
||||
['id' => 2, 'name' => 'Moderator', 'icon' => 'vt-edit'],
|
||||
|
|
@ -69,7 +71,7 @@ class RoleModule implements Module, Route
|
|||
|
||||
public function getById($id)
|
||||
{
|
||||
AdminHelper::getResponse([
|
||||
AdminHelper::sendResponse([
|
||||
'caseName' => 'ROLE_ADMIN',
|
||||
'id' => $id,
|
||||
'name' => 'Admin',
|
||||
|
|
|
|||
81
src/modules/SeoUrlModule.php
Normal file
81
src/modules/SeoUrlModule.php
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace Modules;
|
||||
|
||||
|
||||
use Venom\Core\Config;
|
||||
use Venom\Core\Module;
|
||||
use Venom\Helper\AdminHelper;
|
||||
use Venom\Routing\Route;
|
||||
use Venom\Routing\Router;
|
||||
use Venom\Venom;
|
||||
|
||||
class SeoUrlModule implements Module, Route
|
||||
{
|
||||
|
||||
public function register(Venom $venom): bool
|
||||
{
|
||||
if (Config::getInstance()->isAdmin()) {
|
||||
$this->registerAdminRoutes($venom);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function init(): void
|
||||
{
|
||||
}
|
||||
|
||||
private function registerAdminRoutes(Venom $venom)
|
||||
{
|
||||
$venom->getRouter(Router::ADMIN_ROUTER)->addRoutes([
|
||||
'/seoUrl' => [
|
||||
'cl' => SeoUrlModule::class,
|
||||
'roles' => ['ROLE_ADMIN'],
|
||||
'routes' => [
|
||||
'*' => [
|
||||
"GET" => 'get',
|
||||
],
|
||||
'1' => [
|
||||
"GET" => 'getById',
|
||||
"POST" => 'update',
|
||||
"PUT" => 'insert',
|
||||
]
|
||||
]
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
public function get()
|
||||
{
|
||||
AdminHelper::sendResponse([
|
||||
'pages' => [
|
||||
['id' => 1, 'name' => 'Flamingos going wild!', 'icon' => 'vt-edit'],
|
||||
['id' => 2, 'name' => 'Turbinen sind geil.', 'icon' => 'vt-edit'],
|
||||
['id' => 3, 'name' => 'Aufbau und Umbau des neuen VENOMs Plugins', 'icon' => 'vt-edit'],
|
||||
['id' => 4, 'name' => 'Aber Mama hat gesagt!', 'icon' => 'vt-edit'],
|
||||
['id' => 5, 'name' => 'Frische Fische nur heute!', 'icon' => 'vt-edit']
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function insert(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getById($id)
|
||||
{
|
||||
AdminHelper::sendResponse([
|
||||
'caseName' => 'ROLE_ADMIN',
|
||||
'id' => $id,
|
||||
'name' => 'Admin',
|
||||
'icon' => 'vt-visibility',
|
||||
]);
|
||||
}
|
||||
}
|
||||
78
src/modules/UserModule.php
Normal file
78
src/modules/UserModule.php
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace Modules;
|
||||
|
||||
|
||||
use Venom\Core\Config;
|
||||
use Venom\Core\Module;
|
||||
use Venom\Helper\AdminHelper;
|
||||
use Venom\Routing\Route;
|
||||
use Venom\Routing\Router;
|
||||
use Venom\Venom;
|
||||
|
||||
class UserModule implements Module, Route
|
||||
{
|
||||
|
||||
public function register(Venom $venom): bool
|
||||
{
|
||||
if (Config::getInstance()->isAdmin()) {
|
||||
$this->registerAdminRoutes($venom);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function init(): void
|
||||
{
|
||||
}
|
||||
|
||||
private function registerAdminRoutes(Venom $venom)
|
||||
{
|
||||
$venom->getRouter(Router::ADMIN_ROUTER)->addRoutes([
|
||||
'/users' => [
|
||||
'cl' => UserModule::class,
|
||||
'roles' => ['ROLE_ADMIN'],
|
||||
'routes' => [
|
||||
'*' => [
|
||||
"GET" => 'get',
|
||||
],
|
||||
'1' => [
|
||||
"GET" => 'getById',
|
||||
"POST" => 'update',
|
||||
"PUT" => 'insert',
|
||||
]
|
||||
]
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
public function get()
|
||||
{
|
||||
AdminHelper::sendResponse([
|
||||
'users' => [
|
||||
['id' => 1, 'name' => 'engineertrooper', 'icon' => 'vt-edit'],
|
||||
['id' => 2, 'name' => 'versustunze', 'icon' => 'vt-edit']
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function insert(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getById($id)
|
||||
{
|
||||
AdminHelper::sendResponse([
|
||||
'caseName' => 'ROLE_ADMIN',
|
||||
'id' => $id,
|
||||
'name' => 'Admin',
|
||||
'icon' => 'vt-visibility',
|
||||
]);
|
||||
}
|
||||
}
|
||||
78
src/modules/VenomStatusModule.php
Normal file
78
src/modules/VenomStatusModule.php
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace Modules;
|
||||
|
||||
|
||||
use Venom\Core\Config;
|
||||
use Venom\Core\Module;
|
||||
use Venom\Helper\AdminHelper;
|
||||
use Venom\Routing\Route;
|
||||
use Venom\Routing\Router;
|
||||
use Venom\Venom;
|
||||
|
||||
class VenomStatusModule implements Module, Route
|
||||
{
|
||||
|
||||
public function register(Venom $venom): bool
|
||||
{
|
||||
if (Config::getInstance()->isAdmin()) {
|
||||
$this->registerAdminRoutes($venom);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function init(): void
|
||||
{
|
||||
}
|
||||
|
||||
private function registerAdminRoutes(Venom $venom)
|
||||
{
|
||||
$venom->getRouter(Router::ADMIN_ROUTER)->addRoutes([
|
||||
'/venomStatus' => [
|
||||
'cl' => VenomStatusModule::class,
|
||||
'roles' => ['ROLE_ADMIN'],
|
||||
'routes' => [
|
||||
'*' => [
|
||||
"GET" => 'get',
|
||||
],
|
||||
'1' => [
|
||||
"GET" => 'getById',
|
||||
"POST" => 'update',
|
||||
"PUT" => 'insert',
|
||||
]
|
||||
]
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
public function get()
|
||||
{
|
||||
AdminHelper::sendResponse([
|
||||
'users' => [
|
||||
['id' => 1, 'name' => 'engineertrooper', 'icon' => 'vt-edit'],
|
||||
['id' => 2, 'name' => 'versustunze', 'icon' => 'vt-edit']
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function insert(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getById($id)
|
||||
{
|
||||
AdminHelper::sendResponse([
|
||||
'caseName' => 'ROLE_ADMIN',
|
||||
'id' => $id,
|
||||
'name' => 'Admin',
|
||||
'icon' => 'vt-visibility',
|
||||
]);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue