Поправил инициализацию модулей
This commit is contained in:
parent
0b66a72484
commit
bef7165777
4 changed files with 40 additions and 32 deletions
|
|
@ -28,15 +28,14 @@ class Action
|
||||||
const TEMPLATE_EXTENSION = ".html"; // Расширение для шаблонов
|
const TEMPLATE_EXTENSION = ".html"; // Расширение для шаблонов
|
||||||
const ACTION_PREFIX = "action"; // Префикс для функций действий
|
const ACTION_PREFIX = "action"; // Префикс для функций действий
|
||||||
|
|
||||||
public $jsPath; // Глобальный путь к скриптам
|
|
||||||
public $themePath; // Глобальный путь к текущей теме
|
|
||||||
|
|
||||||
// Параметры устанавливаются при создании контроллера
|
// Параметры устанавливаются при создании контроллера
|
||||||
public $name = ''; // Имя модуля
|
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 $factory = null; // Ссылка на обьект создания модели
|
||||||
private $helpers = array(); // Помошники для действий
|
private $helpers = array(); // Помошники для действий
|
||||||
public $param = array(); // Параметры для ссылки
|
public $param = array(); // Параметры для ссылки
|
||||||
|
|
||||||
public /*.Registry.*/$_registry; // Ссылка на реестр
|
public /*.Settings.*/$settings; // Ссылка на настройки
|
||||||
public $modulePrefix = '';
|
public $user; // Обьект пользователя
|
||||||
public $iconPath = '';
|
|
||||||
|
|
||||||
// Для Widgets
|
// Для Widgets
|
||||||
public $view = null;
|
public $view = null;
|
||||||
|
|
@ -94,7 +92,7 @@ class Action
|
||||||
public function addSuggest(View $view, $name)
|
public function addSuggest(View $view, $name)
|
||||||
{
|
{
|
||||||
$suggest = array();
|
$suggest = array();
|
||||||
$file = Path::join($this->viewPath, 'help', $name . '.suggest');
|
$file = Path::join($this->modulePath, 'help', $name . '.suggest');
|
||||||
if (file_exists($file)) {
|
if (file_exists($file)) {
|
||||||
include($file);
|
include($file);
|
||||||
$view->suggestions = $suggest;
|
$view->suggestions = $suggest;
|
||||||
|
|
@ -103,7 +101,8 @@ class Action
|
||||||
|
|
||||||
function findIcon($icon, $size)
|
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'];
|
$webPath = $this->settings['web'];
|
||||||
|
|
||||||
$list = array(
|
$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")
|
Path::join($basePath, "templates") => Path::join($webPath, "templates")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -132,17 +131,19 @@ class Action
|
||||||
|
|
||||||
/*.View_Composite.*/$tpl = new $viewClass($template);
|
/*.View_Composite.*/$tpl = new $viewClass($template);
|
||||||
|
|
||||||
$assets = Path::join($webPath, "assets", "css");
|
$stylePath = Path::join($webPath, "assets", "css");
|
||||||
$tpl->set('icons', $this->iconPath); // Путь к файлам текущей темы
|
$iconsPath = Path::join($webPath, 'icons');
|
||||||
$tpl->set('media', $this->themePath); // Путь к файлам текущей темы
|
$scriptPath = Path::join($webPath, 'assets');
|
||||||
$tpl->set('assets', $assets);
|
|
||||||
$tpl->set('script', $this->jsPath); // Путь к файлам скриптов
|
$tpl->set('icons', $iconsPath); // Путь к файлам текущей темы
|
||||||
|
$tpl->set('assets', $stylePath);
|
||||||
|
$tpl->set('script', $scriptPath); // Путь к файлам скриптов
|
||||||
$tpl->set('template', $path); // Путь к файлам текущего шаблона
|
$tpl->set('template', $path); // Путь к файлам текущего шаблона
|
||||||
|
|
||||||
$tpl->setAlias(array(
|
$tpl->setAlias(array(
|
||||||
'assets' => $assets,
|
'assets' => $stylePath,
|
||||||
'icons' => $this->iconPath,
|
'icons' => $iconsPath,
|
||||||
'script' => $this->jsPath,
|
'script' => $scriptPath,
|
||||||
// Для media и template поиск происходит как для файлов шаблонов
|
// Для media и template поиск происходит как для файлов шаблонов
|
||||||
'media' => $list,
|
'media' => $list,
|
||||||
'template' => $list
|
'template' => $list
|
||||||
|
|
|
||||||
|
|
@ -53,9 +53,9 @@ class Front extends Action
|
||||||
|
|
||||||
$system = $this->settings['system'];
|
$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']));
|
$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);
|
$ucname = ucfirst($name);
|
||||||
$moduleClass = "Modules\\$ucname\\$ucname";
|
$moduleClass = "Modules\\$ucname\\$ucname";
|
||||||
|
|
@ -63,11 +63,12 @@ class Front extends Action
|
||||||
if ($module) {
|
if ($module) {
|
||||||
// Инициализация модуля
|
// Инициализация модуля
|
||||||
$modPath = Path::join($moulesPath, $name);
|
$modPath = Path::join($moulesPath, $name);
|
||||||
$module->viewPath = $modPath;
|
$module->modulePath = $modPath;
|
||||||
$module->name = $name;
|
$module->name = $name;
|
||||||
//
|
//
|
||||||
$module->settings = $this->settings;
|
$module->settings = $this->settings;
|
||||||
$module->db = $this->db;
|
$module->db = $this->db;
|
||||||
|
$module->user = $this->user;
|
||||||
// Ведение лога
|
// Ведение лога
|
||||||
$logger = new ActionLogger($module, $logPath, $this->user);
|
$logger = new ActionLogger($module, $logPath, $this->user);
|
||||||
$logger->before = $this->loadSettings(Path::join($modPath, 'filter', 'logger.php'));
|
$logger->before = $this->loadSettings(Path::join($modPath, 'filter', 'logger.php'));
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,6 @@ class Login extends Filter
|
||||||
$login = $request->get('login');
|
$login = $request->get('login');
|
||||||
$password = $request->get('password');
|
$password = $request->get('password');
|
||||||
|
|
||||||
|
|
||||||
$result = $this->role->getUserByLogin($login); // Поиск по логину
|
$result = $this->role->getUserByLogin($login); // Поиск по логину
|
||||||
if ($result) {
|
if ($result) {
|
||||||
$userPassword = $this->role->getUserPassword($result);
|
$userPassword = $this->role->getUserPassword($result);
|
||||||
|
|
|
||||||
|
|
@ -43,31 +43,38 @@ class User
|
||||||
return null;
|
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);
|
$stmt->setString(1, $login);
|
||||||
$result = $this->getUserByQuery($stmt);
|
$result = $this->getUserByQuery($stmt);
|
||||||
if ($result) {
|
if ($result) {
|
||||||
$time = time();
|
$time = time();
|
||||||
$id = $this->id;
|
$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;
|
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']);
|
$stmt->setInt(1, $_SESSION ['access']);
|
||||||
$result = $this->getUserByQuery($stmt);
|
$result = $this->getUserByQuery($stmt);
|
||||||
if ($result) {
|
if ($result) {
|
||||||
$lasttime = $result->getInt('lasttime');
|
$lasttime = $result->getInt('lasttime');
|
||||||
$time = time();
|
$time = time();
|
||||||
if ($time - $lasttime > $this->LIFE_TIME) return null; // Вышло время сессии
|
if ($time - $lasttime > self::LIFE_TIME) return null; // Вышло время сессии
|
||||||
$id = $this->$id;
|
$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;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setSID() {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue