mirror of
https://github.com/Aviortheking/DeltaCMS.git
synced 2025-04-23 11:22:11 +00:00
Updated to respect PHPmd
This commit is contained in:
parent
3102855c98
commit
f7001060ea
@ -34,16 +34,16 @@ class AdminPanel
|
|||||||
*/
|
*/
|
||||||
public static function getInstance()
|
public static function getInstance()
|
||||||
{
|
{
|
||||||
if (!isset(AdminPanel::$instance)) {
|
if (!isset(self::$instance)) {
|
||||||
define("ROOT", dirname(dirname(__DIR__)));
|
define("ROOT", dirname(dirname(__DIR__)));
|
||||||
$ap = AdminPanel::$instance = new self();
|
$ap = self::$instance = new self();
|
||||||
$ap->root = dirname(__DIR__);
|
$ap->root = dirname(__DIR__);
|
||||||
$ap->settings = jsonc_decode(dirname($ap->root) . "/config.jsonc", false);
|
$ap->settings = jsonc_decode(dirname($ap->root) . "/config.jsonc", false);
|
||||||
$ap->loader = new FilesystemLoader();
|
$ap->loader = new FilesystemLoader();
|
||||||
$ap->addLoaderFolder($ap->root . "/AdminPanel/Twig");
|
$ap->addLoaderFolder($ap->root . "/AdminPanel/Twig");
|
||||||
// $ap->setLoader(new FilesystemLoader());
|
// $ap->setLoader(new FilesystemLoader());
|
||||||
}
|
}
|
||||||
return AdminPanel::$instance;
|
return self::$instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var Logger $logger */
|
/** @var Logger $logger */
|
||||||
|
@ -9,10 +9,10 @@ class Authentificator
|
|||||||
private static $instance = null;
|
private static $instance = null;
|
||||||
public static function getInstance()
|
public static function getInstance()
|
||||||
{
|
{
|
||||||
if (!isset(Authentificator::$instance)) {
|
if (!isset(self::$instance)) {
|
||||||
Authentificator::$instance = new self();
|
self::$instance = new self();
|
||||||
}
|
}
|
||||||
return Authentificator::$instance;
|
return self::$instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
private $isLoggedIn = false;
|
private $isLoggedIn = false;
|
||||||
|
@ -41,12 +41,14 @@ class Controller
|
|||||||
|
|
||||||
protected function getHTTPGet(string $element, $default = null, $emptyAllowed = false)
|
protected function getHTTPGet(string $element, $default = null, $emptyAllowed = false)
|
||||||
{
|
{
|
||||||
return isset($_GET[$element]) && (!empty($_GET[$element]) || $emptyAllowed) ? $_GET[$element] : $default;
|
$input = filter_input(INPUT_GET, $element);
|
||||||
|
return isset($input) && (!empty($input) || $emptyAllowed) ? $input : $default;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getHTTPPost(string $element, $default = null, $emptyAllowed = false)
|
protected function getHTTPPost(string $element, $default = null, $emptyAllowed = false)
|
||||||
{
|
{
|
||||||
return isset($_POST[$element]) && (!empty($_POST[$element]) || $emptyAllowed) ? $_POST[$element] : $default;
|
$input = filter_input(INPUT_POST, $element);
|
||||||
|
return isset($input) && (!empty($input) || $emptyAllowed) ? $input : $default;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function render($template, $args)
|
protected function render($template, $args)
|
||||||
|
@ -58,7 +58,7 @@ function slugEqualToURI($slug, $uri, $options)
|
|||||||
|
|
||||||
function getModulesJSON()
|
function getModulesJSON()
|
||||||
{
|
{
|
||||||
$t = array();
|
$temp = array();
|
||||||
$modulesDIR = "./Modules";
|
$modulesDIR = "./Modules";
|
||||||
$modules = array_diff(scandir($modulesDIR), array('..', '.'));
|
$modules = array_diff(scandir($modulesDIR), array('..', '.'));
|
||||||
foreach ($modules as $module) {
|
foreach ($modules as $module) {
|
||||||
@ -67,11 +67,11 @@ function getModulesJSON()
|
|||||||
if (is_dir($moduleDIR) && is_file($file)) {
|
if (is_dir($moduleDIR) && is_file($file)) {
|
||||||
$json = json_decode(file_get_contents($file), true);
|
$json = json_decode(file_get_contents($file), true);
|
||||||
if ($json) {
|
if ($json) {
|
||||||
$t[$module] = $json;
|
$temp[$module] = $json;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $t;
|
return $temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
function jsonc_decode($filename, $assoc = false, $depth = 512, $options = 0)
|
function jsonc_decode($filename, $assoc = false, $depth = 512, $options = 0)
|
||||||
|
@ -23,7 +23,8 @@ $caches = $cache->getMultiple(array(
|
|||||||
));
|
));
|
||||||
|
|
||||||
//if cache don't exist create it!
|
//if cache don't exist create it!
|
||||||
if (!($ap->isCacheEnabled()) || $caches["routes"] === null || $caches['templates'] === null || $caches['forms'] === null) {
|
$cachesBool = $caches["routes"] === null || $caches['templates'] === null || $caches['forms'] === null;
|
||||||
|
if (!($ap->isCacheEnabled()) || $cachesBool ) {
|
||||||
$modulesDIR = __DIR__ . "/Modules";
|
$modulesDIR = __DIR__ . "/Modules";
|
||||||
$modules = array_diff(scandir($modulesDIR), array('..', '.'));
|
$modules = array_diff(scandir($modulesDIR), array('..', '.'));
|
||||||
/** @var string $module */
|
/** @var string $module */
|
||||||
@ -73,7 +74,7 @@ foreach ($caches['templates'] as $key => $value) {
|
|||||||
}
|
}
|
||||||
foreach ($caches['routes'] as $key => $value) {
|
foreach ($caches['routes'] as $key => $value) {
|
||||||
$args = isset($value->args) ? $value->args : new stdClass();
|
$args = isset($value->args) ? $value->args : new stdClass();
|
||||||
$composants = slugEqualToURI($value->path, $_SERVER["REQUEST_URI"], $args);
|
$composants = slugEqualToURI($value->path, filter_input(INPUT_SERVER, "REQUEST_URI"), $args);
|
||||||
// dump($composants !== false);
|
// dump($composants !== false);
|
||||||
if ($composants !== false) {
|
if ($composants !== false) {
|
||||||
if (isset($value->file)) {
|
if (isset($value->file)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user