static function load() { $routes = new Routing\RouteCollection(); $routesConfig = Config::load('ext'); foreach ($routesConfig as $routesConfigItem) { if ($routesConfigItem['extType'] === 'component') { $routes->add($routesConfigItem['extKey'], new Routing\Route($routesConfigItem['extSlug'] . '/{extAction}', ['extAction' => 'index'], ['extAction' => '^[a-z0-9-]+'])); } } return $routes; }
static function in($login, $password) { $cred = Config::load('admin'); if ($login === $cred['login'] && password_verify($password, $cred['password'])) { $_SESSION["is_auth"] = true; $_SESSION["login"] = $login; return true; } else { $_SESSION["is_auth"] = false; return false; } }
public function render($menuContent, $pageContent, $extKey) { $mainConfig = Config::load('app'); if ($mainConfig['mode'] === 'development') { $debugbar = new StandardDebugBar(); $debugbarRenderer = $debugbar->getJavascriptRenderer(); $debugbarHead = $debugbarRenderer->renderHead(); $debugbarFoot = $debugbarRenderer->render(); } else { $debugbarHead = ''; $debugbarFoot = ''; } $templates = new Twig_Loader_Filesystem(APP . 'design/themes' . DS . $mainConfig['theme'] . DS . 'templates/ext'); $skeletons = new Twig_Loader_Filesystem(APP . 'design/skeletons/' . $mainConfig['skeleton']); $twigTemplate = new Twig_Environment($templates); $twigSkeleton = new Twig_Environment($skeletons); $skeleton = $twigSkeleton->loadTemplate($mainConfig['skeleton'] . '.twig'); $renderedPage = $twigTemplate->render($extKey . '.twig', ['debugbarHead' => $debugbarHead, 'debugbarFoot' => $debugbarFoot, 'menuContent' => $menuContent, 'pageContent' => $pageContent, 'skeleton' => $skeleton]); return $renderedPage; }