From a09fc396d8d56c932a998a07f75ba84d46e30295 Mon Sep 17 00:00:00 2001 From: "origami11@yandex.ru" Date: Tue, 22 Nov 2022 12:46:15 +0300 Subject: [PATCH] fix --- src/Collection.php | 1 - src/ComponentRequest.php | 4 ++-- src/Controller/Action.php | 3 +-- src/Controller/Component.php | 10 ++++------ src/Filter/Authorization.php | 8 ++++---- src/Functions.php | 23 ++++++++++++----------- src/Role/User.php | 5 +++++ src/Role/UserInterface.php | 3 ++- src/View/View.php | 5 ----- 9 files changed, 30 insertions(+), 32 deletions(-) diff --git a/src/Collection.php b/src/Collection.php index d2f662d..4eea3d1 100644 --- a/src/Collection.php +++ b/src/Collection.php @@ -1,6 +1,5 @@ r->getAction(); } -} \ No newline at end of file +} diff --git a/src/Controller/Action.php b/src/Controller/Action.php index 4db58c5..cbfd202 100644 --- a/src/Controller/Action.php +++ b/src/Controller/Action.php @@ -1,8 +1,7 @@ set('common', Path::join($this->config->get('system', 'web'), '../', 'common')); $tpl->set('script', Path::join($this->config->get('system', 'web'), 'js')); - $tpl->set('media', Path::join($this->config->get('system', 'templates_web'), $template)); + $tpl->set('media', Path::join($this->config->get('system', 'web'), 'templates', $template)); if ($default) { $tpl->set('site_template', $this->config->get('site', 'web') . '/templates/' . $default); @@ -244,13 +244,13 @@ class Component } $name = $path; - $path = Path::join ($site->config->get('site', 'path'), 'components', $name, $name . '.php'); - $className = 'Component_' . $name; + $path = Path::join ($site->config->get('site', 'components'), $name, $name . '.php'); + $className = 'Components\\'. ucfirst($name). '\\' . $name; $component/*: Component*/ = null; if (file_exists($path)) { - require_once ($path); + // require_once ($path); $component = new $className(); $component->viewPath = array($site->config->get('site', 'path') . '/components/' . $name . '/'); @@ -258,8 +258,6 @@ class Component $component->COMPONENTS_WEB = $site->config->get('site', 'web') . '/components/'; } else { - $path = Path::join ($site->config->get('system', 'components'), $name, $name . '.php'); - require_once ($path); $component = new $className(); $template = $component->getTemplateName($registry); diff --git a/src/Filter/Authorization.php b/src/Filter/Authorization.php index 0538eb2..0df3e6f 100644 --- a/src/Filter/Authorization.php +++ b/src/Filter/Authorization.php @@ -11,14 +11,14 @@ class Authorization { $this->group = $group; } - function isLogged() { + static function isLogged($group = 'access') { // echo session_status(); if (session_status() == PHP_SESSION_NONE) { session_start(); } $hash = self::getBrowserSign(); // Если $hash не совпадает $_SESSION['hash'] то удаляем сессию - if (isset($_SESSION[$this->group]) && isset($_SESSION[self::SESSION_BROWSER_SIGN_KEYNAME])) { + if (isset($_SESSION[$group]) && isset($_SESSION[self::SESSION_BROWSER_SIGN_KEYNAME])) { if ($hash == $_SESSION[self::SESSION_BROWSER_SIGN_KEYNAME]) { // UserAccess::getUserById($_SESSION ['access']); // Поиск по идентификатору return true; @@ -29,12 +29,12 @@ class Authorization { return false; } - function enter($id) { + static function enter($id, $group = 'access') { // $db->executeQuery("UPDATE visitor SET sid = '' WHERE id_visitor = " . $result->getInt('id_user')); // session_register("access"); // session_register("time"); - $_SESSION [$this->group] = $id; + $_SESSION [$group] = $id; $_SESSION [self::SESSION_BROWSER_SIGN_KEYNAME] = self::getBrowserSign(); $_SESSION ["time"] = time(); } diff --git a/src/Functions.php b/src/Functions.php index be161bc..ec3032a 100644 --- a/src/Functions.php +++ b/src/Functions.php @@ -101,7 +101,7 @@ class Functions { * @param mixed $a * @param mixed $b * - * @return array[int]mixed + * @return mixed */ static function compose($_rest) { $closure = new compose(func_get_args()); @@ -111,7 +111,7 @@ class Functions { /** * Карирование справа * - * @return array[int]mixed + * @return mixed */ static function rcurry($_rest) { $closure = new right(func_get_args ()); @@ -121,7 +121,7 @@ class Functions { /** * Карирование слева * - * @return array[int]mixed + * @return mixed */ static function lcurry($_rest) { $closure = new left(func_get_args ()); @@ -133,7 +133,7 @@ class Functions { * @param mixed $pred Условие по которому разделяется массив * @param array $lst * - * @return array[int]mixed + * @return mixed */ static function partition($pred, $lst) { $left = array (); @@ -329,19 +329,20 @@ class Functions { /** * Поиск элемента в массиве - * @param function $cb сравнение с элементом массива - * @param array $hs массив в котором ищется значение + * @param mixed $cb сравнение с элементом массива + * @param Array $hs массив в котором ищется значение * * @return int|string ключ найденого элемента в массиве */ static function array_usearch($cb, array $hs, $strict = false) { foreach($hs as $key => $value) if (call_user_func_array($cb, array($value, $key, $strict))) return $key; + return null; } /** * Выбирает все сроки из таблицы с уникальными значениями ключа - * @param $name Имя ключа - * @param $table Двухмерный массив + * @param string $name Имя ключа + * @param Array $table Двухмерный массив * @example * key_unique_values ('name', array (array ('name' => 1), array ('name' => 2), array ('name' => 1))) => array (1, 2) @@ -359,9 +360,9 @@ class Functions { /** * Сортировка двумерного массива по заданному ключу - * @param $array Массив - * @param $key Имя ключа по значению которого будет идти сравнение - * @return Отсортированный массив + * @param Array $array Массив + * @param string $key Имя ключа по значению которого будет идти сравнение + * @return Array Отсортированный массив */ static function sortOn($array, $key, $fn = 'Functions::__cmp') { usort ($array, Functions::rcurry($fn, $key)); diff --git a/src/Role/User.php b/src/Role/User.php index d6b6671..a22cb13 100644 --- a/src/Role/User.php +++ b/src/Role/User.php @@ -30,6 +30,11 @@ class User implements UserInterface return $this->name; } + function isLogged() { + return \ctiso\Filter\Authorization::isLogged(); + } + + public function getUserByQuery(Statement $stmt) { $result = $stmt->executeQuery(); diff --git a/src/Role/UserInterface.php b/src/Role/UserInterface.php index 778394d..295e4ca 100644 --- a/src/Role/UserInterface.php +++ b/src/Role/UserInterface.php @@ -1,11 +1,12 @@ _values["suggestions"] = $this->suggestions; } - public function jGrowl($message, $args) - { - $this->addScriptRaw('$.jGrowl("' . $message . '", ' . json_encode($args) . ");\n", true); - } - public function setGlobal($name, $args) { $this->addScriptRaw("var " . $name . " = " . json_encode($args) . ";\n", false);