From bef71657770712200f364775aab62f083efdfc9f Mon Sep 17 00:00:00 2001 From: "CORP\\phedor" Date: Wed, 28 Mar 2018 19:06:30 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=B8=D0=BD=D0=B8=D1=86=D0=B8=D0=B0=D0=BB=D0=B8=D0=B7?= =?UTF-8?q?=D0=B0=D1=86=D0=B8=D1=8E=20=D0=BC=D0=BE=D0=B4=D1=83=D0=BB=D0=B5?= =?UTF-8?q?=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Controller/Action.php | 43 ++++++++++++++++++++------------------- src/Controller/Front.php | 7 ++++--- src/Filter/Login.php | 1 - src/Role/User.php | 21 ++++++++++++------- 4 files changed, 40 insertions(+), 32 deletions(-) diff --git a/src/Controller/Action.php b/src/Controller/Action.php index d833f55..e549f9a 100644 --- a/src/Controller/Action.php +++ b/src/Controller/Action.php @@ -28,15 +28,14 @@ class Action const TEMPLATE_EXTENSION = ".html"; // Расширение для шаблонов const ACTION_PREFIX = "action"; // Префикс для функций действий - public $jsPath; // Глобальный путь к скриптам - public $themePath; // Глобальный путь к текущей теме - // Параметры устанавливаются при создании контроллера public $name = ''; // Имя модуля - public $viewPath = null; // Путь к шаблонам контроллера - public $viewPathPrefix = null; // Путь к шаблонам контроллера - public $moduleTitle = ""; + public $modulePath = null; // Путь к модулю + public $moduleTitle = ''; + public $modulePrefix = ''; + + public $viewPathPrefix = null; // Путь к шаблонам контроллера /** * Соединение с базой данных @@ -49,11 +48,10 @@ class Action private $factory = null; // Ссылка на обьект создания модели private $helpers = array(); // Помошники для действий - public $param = array(); // Параметры для ссылки + public $param = array(); // Параметры для ссылки - public /*.Registry.*/$_registry; // Ссылка на реестр - public $modulePrefix = ''; - public $iconPath = ''; + public /*.Settings.*/$settings; // Ссылка на настройки + public $user; // Обьект пользователя // Для Widgets public $view = null; @@ -94,7 +92,7 @@ class Action public function addSuggest(View $view, $name) { $suggest = array(); - $file = Path::join($this->viewPath, 'help', $name . '.suggest'); + $file = Path::join($this->modulePath, 'help', $name . '.suggest'); if (file_exists($file)) { include($file); $view->suggestions = $suggest; @@ -103,7 +101,8 @@ class Action function findIcon($icon, $size) { - return Path::join($this->iconPath, $size . 'x' . $size, $icon . '.png'); + $webPath = $this->settings['web']; + return Path::join($webPath, 'icons', $size . 'x' . $size, $icon . '.png'); } /** @@ -120,7 +119,7 @@ class Action $webPath = $this->settings['web']; $list = array( - Path::join($this->viewPath, 'templates', $this->viewPathPrefix) => Path::join($webPath, "modules", $this->name, 'templates', $this->viewPathPrefix), + Path::join($this->modulePath, 'templates', $this->viewPathPrefix) => Path::join($webPath, "modules", $this->name, 'templates', $this->viewPathPrefix), Path::join($basePath, "templates") => Path::join($webPath, "templates") ); @@ -132,17 +131,19 @@ class Action /*.View_Composite.*/$tpl = new $viewClass($template); - $assets = Path::join($webPath, "assets", "css"); - $tpl->set('icons', $this->iconPath); // Путь к файлам текущей темы - $tpl->set('media', $this->themePath); // Путь к файлам текущей темы - $tpl->set('assets', $assets); - $tpl->set('script', $this->jsPath); // Путь к файлам скриптов + $stylePath = Path::join($webPath, "assets", "css"); + $iconsPath = Path::join($webPath, 'icons'); + $scriptPath = Path::join($webPath, 'assets'); + + $tpl->set('icons', $iconsPath); // Путь к файлам текущей темы + $tpl->set('assets', $stylePath); + $tpl->set('script', $scriptPath); // Путь к файлам скриптов $tpl->set('template', $path); // Путь к файлам текущего шаблона $tpl->setAlias(array( - 'assets' => $assets, - 'icons' => $this->iconPath, - 'script' => $this->jsPath, + 'assets' => $stylePath, + 'icons' => $iconsPath, + 'script' => $scriptPath, // Для media и template поиск происходит как для файлов шаблонов 'media' => $list, 'template' => $list diff --git a/src/Controller/Front.php b/src/Controller/Front.php index 5453892..b9fa014 100644 --- a/src/Controller/Front.php +++ b/src/Controller/Front.php @@ -53,9 +53,9 @@ class Front extends Action $system = $this->settings['system']; - $moulesPath = $system->readKey(['path', 'modules']); + $moulesPath = Path::join($this->settings['base'], $system->readKey(['path', 'modules'])); $logPath = Path::join($this->settings['site'], $system->readKey(['path', 'access.log'])); - $moduleFile = Path::join($this->settings['base'], $moulesPath, $name, 'classes', $controller ? $controller : $name); + $moduleFile = Path::join($moulesPath, $name, 'classes', $controller ? $controller : $name); $ucname = ucfirst($name); $moduleClass = "Modules\\$ucname\\$ucname"; @@ -63,11 +63,12 @@ class Front extends Action if ($module) { // Инициализация модуля $modPath = Path::join($moulesPath, $name); - $module->viewPath = $modPath; + $module->modulePath = $modPath; $module->name = $name; // $module->settings = $this->settings; $module->db = $this->db; + $module->user = $this->user; // Ведение лога $logger = new ActionLogger($module, $logPath, $this->user); $logger->before = $this->loadSettings(Path::join($modPath, 'filter', 'logger.php')); diff --git a/src/Filter/Login.php b/src/Filter/Login.php index 6e5f242..eb94070 100644 --- a/src/Filter/Login.php +++ b/src/Filter/Login.php @@ -41,7 +41,6 @@ class Login extends Filter $login = $request->get('login'); $password = $request->get('password'); - $result = $this->role->getUserByLogin($login); // Поиск по логину if ($result) { $userPassword = $this->role->getUserPassword($result); diff --git a/src/Role/User.php b/src/Role/User.php index d287543..f199363 100644 --- a/src/Role/User.php +++ b/src/Role/User.php @@ -43,31 +43,38 @@ class User return null; } - public static function getUserByLogin($login) + function getUserPassword($result) { + return $result->get('password'); + } + + public function getUserByLogin($login) { - $stmt = $this->$db->prepareStatement("SELECT * FROM users WHERE login = ?"); + $stmt = $this->db->prepareStatement("SELECT * FROM users WHERE login = ?"); $stmt->setString(1, $login); $result = $this->getUserByQuery($stmt); if ($result) { $time = time(); $id = $this->id; - $this->$db->executeQuery("UPDATE users SET lasttime = $time WHERE id_user = $id"); // Время входа + $this->db->executeQuery("UPDATE users SET lasttime = $time WHERE id_user = $id"); // Время входа } return $result; } - public static function getUserById($id) + public function getUserById($id) { - $stmt = $this->$db->prepareStatement("SELECT * FROM users WHERE id_user = ?"); + $stmt = $this->db->prepareStatement("SELECT * FROM users WHERE id_user = ?"); $stmt->setInt(1, $_SESSION ['access']); $result = $this->getUserByQuery($stmt); if ($result) { $lasttime = $result->getInt('lasttime'); $time = time(); - if ($time - $lasttime > $this->LIFE_TIME) return null; // Вышло время сессии - $id = $this->$id; + if ($time - $lasttime > self::LIFE_TIME) return null; // Вышло время сессии + $id = $this->id; $this->db->executeQuery("UPDATE users SET lasttime = $time WHERE id_user = $id"); // Время последнего обращения входа } return $result; } + + function setSID() { + } }