public static function get() { if (self::$init == null) { self::$init = new self($_SERVER['REQUEST_URI']); } return self::$init; }
public function start() { $this->autoLoader(); //инициализация всего что надо $this->initHelpers(); if (Libs_URL::get()->checkPath('admin')) { $this->initAdmin(); } else { $this->initMain(); } }
/** * Admin constructor. */ public function __construct() { if (Libs_Session::start()->isAdmin()) { parent::__construct(true); } else { if (Libs_URL::get()->checkPath('login', 2)) { parent::__construct(true); } else { die('You not Admin'); } } }
/** * Admin_Controllers_Main constructor. */ public function __construct() { $this->model = new Admin_Models_Main(); if (Libs_Session::start()->isAdmin()) { $langM = new Modules_Controllers_Lang(); $langM->setConfigs(); $result = $this->model->routers(Libs_URL::get()->getPath()); //TODO - как оно будет работать /** * если есть такой контролер мы вызываем его метод * если путджсон или аджакс то дальше в главном ниче не выполнится иначе * в главном контролере подключаем лейаут и возвращаем все */ $center = false; if ($result) { $cnt = count($result); for ($i = 0; $i < $cnt; $i++) { $this->blocks[] = $result[$i]; } } else { if ($controller = $this->model->correctAddr()) { $ajax = Libs_URL::get()->getPiceURL(3) === 'ajax'; $link = Libs_URL::get()->getPiceURL(2); if (isset($link) && !empty($link)) { $center = new $controller($ajax); $center = $center->{$link}(); } else { ob_start(); new $controller($ajax); $center = ob_get_clean(); ob_end_clean(); } } else { header('HTTP/1.0 404 Not Found'); header('Location: /404'); } } $layout = $this->getLayoutWithStyle(); $toReplace = array('{header}', '{left}', '{center}', '{right}', '{footer}'); $replace = $this->model->getBlocks($this->blocks); if ($center !== false) { $replace[2] = $center; } $replace = array($replace[0], $replace[1], $replace[2], $replace[3], $replace[4]); $layout = str_replace($toReplace, $replace, $layout); $this->render($layout); } else { $this->render($this->getTPL('login')); } }
public function correctAddr() { $link = Libs_URL::get()->getPiceURL(1); if (class_exists('Admin_Controllers_' . $link)) { return 'Admin_Controllers_' . $link; } else { if (class_exists('Admin_Controllers_Types_' . $link)) { return 'Admin_Controllers_Types_' . $link; } else { if (class_exists('Admin_Controllers_Blocks_' . $link)) { return 'Admin_Controllers_Blocks_' . $link; } } } return false; }
/** * Controllers_Main constructor. */ public function __construct() { $this->model = new Models_Main(); $link = Libs_URL::get()->getPath(); if ($link === '/404') { $this->notFoundPage(); } else { $routing = $this->model->routers($link); if ($routing) { $page = $routing; } else { $page = $link; } $page = $this->model->getBlocks($page); if (empty($page)) { $this->notFoundPage(); } else { $this->blocks = $this->model->getBlocksHTML($page); } } $tpl = $this->getTPL('mainview'); $html = str_replace(array('{left}', '{center}', '{right}'), array($this->blocks['left'], $this->blocks['center'], $this->blocks['right']), $tpl); $this->render($html); }
<?php /** * Created by PhpStorm. * User: CrazyBobik * Date: 04.10.2015 * Time: 2:17 */ defined('ROOT') || define('ROOT', realpath(dirname(__FILE__) . '/..')); require_once ROOT . '/engine/bootstrap.php'; require_once ROOT . '/config/config.php'; Bootstrap::init()->autoLoader(); $path = Libs_URL::get()->getParseURL(); $file = ROOT . '/system/ajax/' . $path[1] . '.php'; if (file_exists($file)) { require_once $file; $controller = new $path[1](); $controller->{$path}[2](); } else { header('Location: /404'); }