VENOM: Hardcode WIP (versustunez)
This commit is contained in:
parent
7b90160c48
commit
32a78ed1b9
21 changed files with 285 additions and 158 deletions
|
@ -40,6 +40,8 @@ create table if not exists users
|
||||||
(
|
(
|
||||||
id int(255) auto_increment not null unique primary key,
|
id int(255) auto_increment not null unique primary key,
|
||||||
username varchar(255) not null unique,
|
username varchar(255) not null unique,
|
||||||
|
firstname varchar(255) not null,
|
||||||
|
lastname varchar(255) not null,
|
||||||
email varchar(255) not null,
|
email varchar(255) not null,
|
||||||
password varchar(255) not null,
|
password varchar(255) not null,
|
||||||
token varchar(255) not null,
|
token varchar(255) not null,
|
||||||
|
@ -48,3 +50,11 @@ create table if not exists users
|
||||||
isActive tinyint(1) default 1 null
|
isActive tinyint(1) default 1 null
|
||||||
)
|
)
|
||||||
comment 'User File';
|
comment 'User File';
|
||||||
|
|
||||||
|
create table if not exists roles
|
||||||
|
(
|
||||||
|
id int(255) auto_increment not null unique primary key,
|
||||||
|
name varchar(255) not null unique,
|
||||||
|
content JSON not null,
|
||||||
|
isActive tinyint(1) default 1 null
|
||||||
|
)
|
|
@ -1 +1 @@
|
||||||
main{display:flex;height:100vh;overflow:hidden}main h1{margin-top:30px;margin-bottom:20px}main h2{margin-top:35px;margin-bottom:25px}main h3{margin-top:20px;margin-bottom:15px}main h4{margin-top:15px;margin-bottom:10px}main.nav-open .menu{transform:translateX(0)}main.nav-open .app{transform:translateX(220px)}main.nav-open .app .nav-toggle span{transition:width .3s;width:0}main.nav-open .app .nav-toggle span:before{transform:translateY(8px) rotate(-135deg)}main.nav-open .app .nav-toggle span:after{transform:translateY(-8px) rotate(135deg)}.app{transform:translateX(0);transition:transform .4s;flex-grow:1;overflow-y:auto;margin:.6rem .8rem;width:100%;max-height:100%;background:rgba(27,27,27,.5);position:relative}.app .nav-toggle{position:absolute;top:1rem;left:1rem;margin-top:10px;height:25px}.app .nav-toggle span,.app .nav-toggle span:after,.app .nav-toggle span:before{cursor:pointer;border-radius:1px;height:2px;width:25px;background:#fff;position:absolute;content:'';transition:transform .5s,width .4s ease-in}.app .nav-toggle span:before{top:-8px}.app .nav-toggle span:after{bottom:-8px}.menu{width:220px;background-color:#1b1b1b;box-shadow:0 3px 6px rgba(0,0,0,.16),0 3px 6px rgba(0,0,0,.23);height:100%;position:fixed;z-index:1;top:0;left:0;overflow-x:hidden;transition:.4s;transform:translateX(-220px);display:flex;flex-direction:column}.menu .logo{text-align:center;font-family:monospace}.menu div[data-link]{padding:.75rem .5rem;position:relative}.menu div[data-link]:after{background-color:#3949ab;content:"";position:absolute;left:0;bottom:0;height:3px;width:100%;transform:scaleX(0);transition:transform .4s;transform-origin:left}.menu div[data-link]:hover:after{transform:scaleX(1)}.menu div[data-link]:last-child{margin-top:auto}.menu div[data-link].active{font-weight:700}.content-area{width:calc(100% - 20px);padding-top:30px;margin:0 auto;display:block}.content-area header{display:block;text-align:center}.content-area header h2{margin:25px 0}.content-area .back-arrow{width:36px;height:36px}.content-area textarea{background:rgba(27,27,27,.5);color:#fff;margin:15px 0 0 0;font-family:sans-serif;font-size:1.1rem;min-width:100%}.content-area .modules div{padding:6px 20px 6px 0}.content-area .add-new,.content-area .overview{width:100%}.content-area .overview div[data-link]{margin-right:10px;padding:10px;background-color:rgba(0,0,0,.3)}.content-area .overview div[data-link]:hover{background-color:rgba(0,0,0,.5)}.content-area .overview .icon{display:inline-block}.content-area .add-new{padding-top:25px}@media only screen and (min-width:768px){.content-area{width:calc(100% - 40px)}.content-area .flexbox{display:flex}.content-area .overview{flex-grow:1;width:60%}.content-area .add-new{padding-top:0;flex-grow:1;width:40%}}@media only screen and (min-width:1024px){.content-area{max-width:860px;padding-top:0;margin:0 0 0 20px}}@media only screen and (min-width:1024px){main,main.nav-open{display:flex}main .app,main.nav-open .app{transform:translateX(0)}main .menu,main.nav-open .menu{position:relative;transform:translateX(0)}main .nav-toggle,main.nav-open .nav-toggle{display:none}}.role-edit .privileges .name{font-size:1.15rem}
|
main{display:flex;height:100vh;overflow:hidden}main h1{margin-top:30px;margin-bottom:20px}main h2{margin-top:35px;margin-bottom:25px}main h3{margin-top:20px;margin-bottom:15px}main h4{margin-top:15px;margin-bottom:10px}main.nav-open .menu{transform:translateX(0)}main.nav-open .app{transform:translateX(220px)}main.nav-open .app .nav-toggle span{transition:width .3s;width:0}main.nav-open .app .nav-toggle span:before{transform:translateY(8px) rotate(-135deg)}main.nav-open .app .nav-toggle span:after{transform:translateY(-8px) rotate(135deg)}.app{transform:translateX(0);transition:transform .4s;flex-grow:1;overflow-y:auto;margin:.6rem .8rem;width:100%;max-height:100%;background:rgba(27,27,27,.5);position:relative}.app .nav-toggle{position:absolute;cursor:pointer;left:1rem;height:25px;width:25px}.app .nav-toggle span{transform:translateY(21px)}.app .nav-toggle span,.app .nav-toggle span:after,.app .nav-toggle span:before{border-radius:1px;height:2px;width:25px;background:#fff;position:absolute;content:'';transition:transform .5s,width .4s ease-in}.app .nav-toggle span:before{top:-8px}.app .nav-toggle span:after{bottom:-8px}.menu{width:220px;background-color:#1b1b1b;box-shadow:0 3px 6px rgba(0,0,0,.16),0 3px 6px rgba(0,0,0,.23);height:100%;position:fixed;z-index:1;top:0;left:0;overflow-x:hidden;transition:.4s;transform:translateX(-220px);display:flex;flex-direction:column}.menu .logo{text-align:center;font-family:monospace}.menu div[data-link]{padding:.75rem .5rem;position:relative}.menu div[data-link]:after{background-color:#3949ab;content:"";position:absolute;left:0;bottom:0;height:3px;width:100%;transform:scaleX(0);transition:transform .4s;transform-origin:left}.menu div[data-link]:hover:after{transform:scaleX(1)}.menu div[data-link]:last-child{margin-top:auto}.menu div[data-link].active{font-weight:700}.content-area{width:calc(100% - 20px);padding-top:30px;margin:0 auto;display:block}.content-area header{display:block;text-align:center}.content-area header h2{margin:25px 0}.content-area .back-arrow{width:36px;height:36px}.content-area textarea{background:rgba(27,27,27,.5);color:#fff;margin:15px 0 0 0;font-family:sans-serif;font-size:1.1rem;min-width:100%}.content-area .modules div{padding:6px 20px 6px 0}.content-area .add-new,.content-area .overview{width:100%}.content-area .overview div[data-link]{margin-right:10px;padding:10px;background-color:rgba(0,0,0,.3)}.content-area .overview div[data-link]:hover{background-color:rgba(0,0,0,.5)}.content-area .overview .icon{display:inline-block}.content-area .add-new{padding-top:25px}@media only screen and (min-width:768px){.content-area{width:calc(100% - 40px)}.content-area .flexbox{display:flex}.content-area .overview{flex-grow:1;width:60%}.content-area .add-new{padding-top:0;flex-grow:1;width:40%}}@media only screen and (min-width:1024px){.content-area{max-width:860px;padding-top:0;margin:0 0 0 20px}}@media only screen and (min-width:1024px){main,main.nav-open{display:flex}main .app,main.nav-open .app{transform:translateX(0)}main .menu,main.nav-open .menu{position:relative;transform:translateX(0)}main .nav-toggle,main.nav-open .nav-toggle{display:none}}.role-edit .privileges .name{font-size:1.15rem}
|
|
@ -3,18 +3,24 @@
|
||||||
|
|
||||||
namespace Venom\Admin;
|
namespace Venom\Admin;
|
||||||
|
|
||||||
|
use Modules\Meta\MetaDataModule;
|
||||||
|
use Modules\PageModule;
|
||||||
|
use Modules\RoleModule;
|
||||||
|
use Modules\SeoUrlModule;
|
||||||
|
use Modules\User\UserModule;
|
||||||
|
use Modules\VenomStatusModule;
|
||||||
|
|
||||||
class AdminModulesLoader
|
class AdminModulesLoader
|
||||||
{
|
{
|
||||||
public static function getModules(): array
|
public static function getModules(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'metaData' => \Modules\MetaDataModule::class,
|
'metaData' => MetaDataModule::class,
|
||||||
'overview' => \Modules\OverviewModule::class,
|
'pages' => PageModule::class,
|
||||||
'pages' => \Modules\PageModule::class,
|
'role' => RoleModule::class,
|
||||||
'role' => \Modules\RoleModule::class,
|
'seoUrl' => SeoUrlModule::class,
|
||||||
'seoUrl' => \Modules\SeoUrlModule::class,
|
'users' => UserModule::class,
|
||||||
'users' => \Modules\UserModule::class,
|
'venomStatus' => VenomStatusModule::class,
|
||||||
'venomStatus' => \Modules\VenomStatusModule::class,
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -71,4 +71,22 @@ class DatabaseHandler
|
||||||
$stmt = $this->db->prepare($query);
|
$stmt = $this->db->prepare($query);
|
||||||
return $stmt->execute($args);
|
return $stmt->execute($args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns a Select like this: SELECT id, name, ... FROM table || do what you want
|
||||||
|
public static function createEasySelect(array $fields, string $table): string
|
||||||
|
{
|
||||||
|
return "SELECT " . implode(",", $fields) . " FROM " . $table;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getUpdateString(array $data, string $table, string $where): array
|
||||||
|
{
|
||||||
|
$string = [];
|
||||||
|
$save = [];
|
||||||
|
foreach ($data as $key => $value) {
|
||||||
|
$k = ":" . strtolower($key);
|
||||||
|
$string[] = $key . "= " . $k;
|
||||||
|
$save[$k] = $value;
|
||||||
|
}
|
||||||
|
return ["UPDATE " . $table . " SET " . implode(",", $string) . " " . $where, $save];
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -8,6 +8,12 @@ use Venom\Venom;
|
||||||
|
|
||||||
interface Module
|
interface Module
|
||||||
{
|
{
|
||||||
|
const NAME = "name";
|
||||||
|
const AUTHOR = "author";
|
||||||
|
const SECURE = "secure";
|
||||||
|
const ROUTE = "routes";
|
||||||
|
const DESC = "description";
|
||||||
|
|
||||||
public function register(Venom $venom): bool;
|
public function register(Venom $venom): bool;
|
||||||
|
|
||||||
public function init(): void;
|
public function init(): void;
|
||||||
|
|
|
@ -22,4 +22,16 @@ class AdminHelper
|
||||||
echo json_encode($response);
|
echo json_encode($response);
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function sendStatus(bool $isSuccess, string $message = "")
|
||||||
|
{
|
||||||
|
if ($message == "") {
|
||||||
|
$message = $isSuccess ? "Operation Success" : "Operation failed";
|
||||||
|
}
|
||||||
|
echo json_encode([
|
||||||
|
"status" => $isSuccess ? 'success' : 'failed',
|
||||||
|
"message" => $message
|
||||||
|
]);
|
||||||
|
die();
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -4,6 +4,7 @@
|
||||||
namespace Venom\Helper;
|
namespace Venom\Helper;
|
||||||
|
|
||||||
|
|
||||||
|
use http\Exception\RuntimeException;
|
||||||
use Venom\Core\ArgumentHandler;
|
use Venom\Core\ArgumentHandler;
|
||||||
|
|
||||||
class ErrorHandler
|
class ErrorHandler
|
||||||
|
|
|
@ -9,23 +9,15 @@ class DataModel
|
||||||
public const TYPE_CONTENT = 'content';
|
public const TYPE_CONTENT = 'content';
|
||||||
public const TYPE_FORM = 'form';
|
public const TYPE_FORM = 'form';
|
||||||
|
|
||||||
public string $id;
|
|
||||||
public string $raw;
|
|
||||||
public string $generated;
|
|
||||||
public string $type;
|
|
||||||
public int $active = 1;
|
public int $active = 1;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
string $id,
|
public string $id,
|
||||||
string $type = self::TYPE_CONTENT,
|
public string $type = self::TYPE_CONTENT,
|
||||||
string $raw = '',
|
public string $raw = '',
|
||||||
string $generated = ''
|
public string $generated = ''
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
$this->id = $id;
|
|
||||||
$this->type = $type;
|
|
||||||
$this->raw = $raw;
|
|
||||||
$this->generated = $generated;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getId(): string
|
public function getId(): string
|
||||||
|
|
|
@ -4,12 +4,14 @@
|
||||||
namespace Venom\Models;
|
namespace Venom\Models;
|
||||||
|
|
||||||
|
|
||||||
|
use JsonSerializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Database Object to use queries like this $obj->id, $obj->value
|
* Database Object to use queries like this $obj->id, $obj->value
|
||||||
* also the option to print it in csv format ; as delimiter
|
* also the option to print it in csv format ; as delimiter
|
||||||
* @package Venom\Database
|
* @package Venom\Database
|
||||||
*/
|
*/
|
||||||
class DatabaseObject
|
class DatabaseObject implements JsonSerializable
|
||||||
{
|
{
|
||||||
private array $data = [];
|
private array $data = [];
|
||||||
|
|
||||||
|
@ -26,19 +28,29 @@ class DatabaseObject
|
||||||
$this->data[$name] = $value;
|
$this->data[$name] = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __isset($name)
|
public function __isset($name): bool
|
||||||
{
|
{
|
||||||
return isset($this->data[$name]);
|
return isset($this->data[$name]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function toString()
|
public function toString(): string
|
||||||
{
|
{
|
||||||
return implode(';', $this->data);
|
return implode(';', $this->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getHead()
|
public function getHead(): string
|
||||||
{
|
{
|
||||||
$keys = array_keys($this->data);
|
$keys = array_keys($this->data);
|
||||||
return implode(';', $keys);
|
return implode(';', $keys);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getData(): array
|
||||||
|
{
|
||||||
|
return $this->data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function jsonSerialize(): array
|
||||||
|
{
|
||||||
|
return $this->data;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -12,9 +12,11 @@ class User
|
||||||
public const GUEST_ROLE = 'ROLE_GUEST';
|
public const GUEST_ROLE = 'ROLE_GUEST';
|
||||||
private string $username = 'GUEST';
|
private string $username = 'GUEST';
|
||||||
private string $email = 'GUEST';
|
private string $email = 'GUEST';
|
||||||
private string $password = '---';
|
private string $firstname = '';
|
||||||
private string $salt = '---';
|
private string $lastname = '';
|
||||||
private string $token = '---';
|
private string $password = '';
|
||||||
|
private string $salt = '';
|
||||||
|
private string $token = '';
|
||||||
private string $id = '-1';
|
private string $id = '-1';
|
||||||
private array $roles = [];
|
private array $roles = [];
|
||||||
private bool $isLoaded = false;
|
private bool $isLoaded = false;
|
||||||
|
|
|
@ -6,6 +6,7 @@ namespace Venom\Routing;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Venom\Core\Config;
|
use Venom\Core\Config;
|
||||||
|
use Venom\Exceptions\ExceptionHandler;
|
||||||
use Venom\Models\User;
|
use Venom\Models\User;
|
||||||
use Venom\Security\Security;
|
use Venom\Security\Security;
|
||||||
|
|
||||||
|
@ -122,6 +123,7 @@ class Router
|
||||||
$route->$fnc(...$params);
|
$route->$fnc(...$params);
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception $ex) {
|
} catch (Exception $ex) {
|
||||||
|
ExceptionHandler::handleException($ex);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
36
src/modules/Meta/Controller/MetaAPIController.php
Normal file
36
src/modules/Meta/Controller/MetaAPIController.php
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
namespace Modules\Meta\Controller;
|
||||||
|
|
||||||
|
|
||||||
|
use Venom\Core\DatabaseHandler;
|
||||||
|
use Venom\Helper\AdminHelper;
|
||||||
|
|
||||||
|
class MetaAPIController
|
||||||
|
{
|
||||||
|
public function get()
|
||||||
|
{
|
||||||
|
AdminHelper::sendResponse([]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getById($id)
|
||||||
|
{
|
||||||
|
AdminHelper::sendResponse(MetaController::getById($id));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update($id)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function delete($id)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create($id)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
18
src/modules/Meta/Controller/MetaController.php
Normal file
18
src/modules/Meta/Controller/MetaController.php
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
namespace Modules\Meta\Controller;
|
||||||
|
|
||||||
|
|
||||||
|
class MetaController
|
||||||
|
{
|
||||||
|
public static function get(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getById($id): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,9 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
namespace Modules;
|
namespace Modules\Meta;
|
||||||
|
|
||||||
|
|
||||||
|
use Modules\Meta\Controller\MetaAPIController;
|
||||||
use Venom\Core\Config;
|
use Venom\Core\Config;
|
||||||
use Venom\Core\Module;
|
use Venom\Core\Module;
|
||||||
use Venom\Helper\AdminHelper;
|
use Venom\Helper\AdminHelper;
|
||||||
|
@ -30,7 +30,7 @@ class MetaDataModule implements Module, Route
|
||||||
{
|
{
|
||||||
$venom->getRouter(Router::ADMIN_ROUTER)->addRoutes([
|
$venom->getRouter(Router::ADMIN_ROUTER)->addRoutes([
|
||||||
'/metaData' => [
|
'/metaData' => [
|
||||||
'cl' => MetaDataModule::class,
|
'cl' => MetaAPIController::class,
|
||||||
'roles' => ['ROLE_ADMIN'],
|
'roles' => ['ROLE_ADMIN'],
|
||||||
'routes' => [
|
'routes' => [
|
||||||
'*' => [
|
'*' => [
|
||||||
|
@ -40,6 +40,7 @@ class MetaDataModule implements Module, Route
|
||||||
"GET" => 'getById',
|
"GET" => 'getById',
|
||||||
"POST" => 'update',
|
"POST" => 'update',
|
||||||
"PUT" => 'insert',
|
"PUT" => 'insert',
|
||||||
|
"DELETE" => 'delete'
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
]
|
]
|
22
src/modules/Meta/module.php
Normal file
22
src/modules/Meta/module.php
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Venom\Core\Module;
|
||||||
|
|
||||||
|
/*$module = [
|
||||||
|
Module::NAME => 'MetaModule',
|
||||||
|
Module::DESC => 'Meta Data Module for SEO',
|
||||||
|
Module::AUTHOR => 'VstZ dev',
|
||||||
|
Module::SECURE => true,
|
||||||
|
MODULE::ROUTE => [
|
||||||
|
'/'
|
||||||
|
],
|
||||||
|
MODULE::TEMPLATES => [
|
||||||
|
// Include Templates with shorter names! $render->include("meta_roles")
|
||||||
|
'meta_roles' => 'PATH_TO_TEMPLATE'
|
||||||
|
],
|
||||||
|
MODULE::ADMIN_TEMPLATES => [
|
||||||
|
//
|
||||||
|
]
|
||||||
|
];
|
||||||
|
$venom = $venom ?? die();
|
||||||
|
$venom->registerModule($module);*/
|
|
@ -1,81 +0,0 @@
|
||||||
<?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',
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
64
src/modules/User/Controller/UserAPIController.php
Normal file
64
src/modules/User/Controller/UserAPIController.php
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
namespace Modules\User\Controller;
|
||||||
|
|
||||||
|
use Venom\Core\ArgumentHandler;
|
||||||
|
use Venom\Core\DatabaseHandler;
|
||||||
|
use Venom\Helper\AdminHelper;
|
||||||
|
|
||||||
|
class UserAPIController
|
||||||
|
{
|
||||||
|
public function get()
|
||||||
|
{
|
||||||
|
//['id' => 1, 'name' => 'engineertrooper', 'icon' => 'vt-edit'],
|
||||||
|
$data = UserController::get(["id", "username", "firstname", "lastname", "email", "isActive"]);
|
||||||
|
AdminHelper::sendResponse(["users" => $data]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getById($id)
|
||||||
|
{
|
||||||
|
$d = UserController::getById($id, ["id", "username", "firstname", "lastname", "email", "isActive"]);
|
||||||
|
AdminHelper::sendResponse($d);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update($id)
|
||||||
|
{
|
||||||
|
$original = UserController::getById($id);
|
||||||
|
if ($original == null) {
|
||||||
|
AdminHelper::sendStatus(false, "User not Found");
|
||||||
|
}
|
||||||
|
$args = ArgumentHandler::get();
|
||||||
|
$data = [];
|
||||||
|
$d = $original->getData();
|
||||||
|
foreach ($d as $key => $item) {
|
||||||
|
if ($args->hasPostItem($key)) {
|
||||||
|
$val = $args->getPostItem($key);
|
||||||
|
if ($val != $item) {
|
||||||
|
$data[$key] = $val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
parse_str(file_get_contents('php://input'), $_PUT);
|
||||||
|
var_dump(array_keys($_PUT));
|
||||||
|
//var_dump($data, $d, $_POST);
|
||||||
|
// $args->getPostItem("username")//UPDATE users SET lastname='Doe', firstname='' WHERE id=2
|
||||||
|
AdminHelper::sendStatus(UserController::update($id, $data));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function delete($id)
|
||||||
|
{
|
||||||
|
AdminHelper::sendStatus(DatabaseHandler::get()->execute(
|
||||||
|
"DELETE FROM users WHERE id=:id",
|
||||||
|
[
|
||||||
|
':id' => $id
|
||||||
|
]
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create($id)
|
||||||
|
{
|
||||||
|
// INSERT INTO
|
||||||
|
AdminHelper::sendStatus(true);
|
||||||
|
}
|
||||||
|
}
|
36
src/modules/User/Controller/UserController.php
Normal file
36
src/modules/User/Controller/UserController.php
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
namespace Modules\User\Controller;
|
||||||
|
|
||||||
|
|
||||||
|
use Venom\Core\DatabaseHandler;
|
||||||
|
use Venom\Models\DatabaseObject;
|
||||||
|
|
||||||
|
class UserController
|
||||||
|
{
|
||||||
|
|
||||||
|
public static function getById($id, array $fields = ["*"]): ?DatabaseObject
|
||||||
|
{
|
||||||
|
if (empty($id)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
$sel = DatabaseHandler::createEasySelect($fields, "users") . " WHERE id = :id";
|
||||||
|
return DatabaseHandler::get()->getOne($sel, [
|
||||||
|
':id' => $id
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function get(array $fields = ["*"]): array
|
||||||
|
{
|
||||||
|
return DatabaseHandler::get()->getAll(DatabaseHandler::createEasySelect($fields, "users"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function update($id, array $values = []): bool
|
||||||
|
{
|
||||||
|
if (count($values) === 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return DatabaseHandler::get()->execute(...DatabaseHandler::getUpdateString($values, "users", "WHERE id = :id"));
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,9 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
namespace Modules;
|
namespace Modules\User;
|
||||||
|
|
||||||
|
|
||||||
|
use Modules\User\Controller\UserAPIController;
|
||||||
use Venom\Core\Config;
|
use Venom\Core\Config;
|
||||||
use Venom\Core\Module;
|
use Venom\Core\Module;
|
||||||
use Venom\Helper\AdminHelper;
|
use Venom\Helper\AdminHelper;
|
||||||
|
@ -30,7 +31,7 @@ class UserModule implements Module, Route
|
||||||
{
|
{
|
||||||
$venom->getRouter(Router::ADMIN_ROUTER)->addRoutes([
|
$venom->getRouter(Router::ADMIN_ROUTER)->addRoutes([
|
||||||
'/users' => [
|
'/users' => [
|
||||||
'cl' => UserModule::class,
|
'cl' => UserAPIController::class,
|
||||||
'roles' => ['ROLE_ADMIN'],
|
'roles' => ['ROLE_ADMIN'],
|
||||||
'routes' => [
|
'routes' => [
|
||||||
'*' => [
|
'*' => [
|
||||||
|
@ -38,41 +39,11 @@ class UserModule implements Module, Route
|
||||||
],
|
],
|
||||||
'1' => [
|
'1' => [
|
||||||
"GET" => 'getById',
|
"GET" => 'getById',
|
||||||
"POST" => 'update',
|
"POST" => 'insert',
|
||||||
"PUT" => 'insert',
|
"PUT" => 'update',
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get()
|
|
||||||
{
|
|
||||||
AdminHelper::sendResponse([
|
|
||||||
'users' => [
|
|
||||||
['id' => 1, 'name' => 'engineertrooper', 'icon' => 'vt-edit'],
|
|
||||||
['id' => 2, 'name' => 'versustunez', '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',
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -2,7 +2,6 @@
|
||||||
<nav class="menu">
|
<nav class="menu">
|
||||||
<h1 class="logo">Venom</h1>
|
<h1 class="logo">Venom</h1>
|
||||||
<div data-link="/metaData">Meta Data</div>
|
<div data-link="/metaData">Meta Data</div>
|
||||||
<div data-link="/overview" class="active">Overview</div>
|
|
||||||
<div data-link="/pages">Pages</div>
|
<div data-link="/pages">Pages</div>
|
||||||
<div data-link="/roles">Roles</div>
|
<div data-link="/roles">Roles</div>
|
||||||
<div data-link="/seoUrl">SEO-URL</div>
|
<div data-link="/seoUrl">SEO-URL</div>
|
||||||
|
|
|
@ -7,12 +7,12 @@
|
||||||
<div class="flexbox">
|
<div class="flexbox">
|
||||||
<div class="overview">
|
<div class="overview">
|
||||||
<h3>Overview</h3>
|
<h3>Overview</h3>
|
||||||
{foreach(users as user,key)}
|
{foreach(users as user)}
|
||||||
<div data-link="/users" data-id="${user.id}">
|
<div data-link="/users" data-id="${user.id}">
|
||||||
<span class="icon-text">
|
<span class="icon-text">
|
||||||
{include(includes/svg;icon=$user.icon)}
|
{include(includes/svg;icon=vt-edit)}
|
||||||
</span>
|
</span>
|
||||||
<span>${user.name}</span>
|
<span>${user.username} (${user.firstname} ${user.lastname})</span>
|
||||||
</div>
|
</div>
|
||||||
{/for}
|
{/for}
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue