From 538239a6c4c9c460266e81ebc5663582b554b26d Mon Sep 17 00:00:00 2001 From: Anatoly Date: Thu, 11 May 2017 16:24:18 +0300 Subject: [PATCH 1/6] redirect --- src/Filter/ActionAccess.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Filter/ActionAccess.php b/src/Filter/ActionAccess.php index dc39ba0..7d4936f 100644 --- a/src/Filter/ActionAccess.php +++ b/src/Filter/ActionAccess.php @@ -26,7 +26,8 @@ class Filter_ActionAccess $action = $request->getAction(); if(! $this->checkAction($action)) { $request->set('action', 'index'); - } + $request->setAction('index'); + } return $this->processor->execute($request); } } From a83f70422c8e25d0364a2e34844253958b612657 Mon Sep 17 00:00:00 2001 From: Anatoly Date: Thu, 18 May 2017 12:23:28 +0300 Subject: [PATCH 2/6] =?UTF-8?q?=D0=92=20=D0=A1MS2=20=D0=BD=D0=B5=D1=82=20?= =?UTF-8?q?=D1=8D=D1=82=D0=B8=D1=85=20=D0=B3=D0=BB=D0=BE=D0=B1=D0=B0=D0=BB?= =?UTF-8?q?=D1=8C=D0=BD=D1=8B=D1=85=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=D0=BD=D1=8B=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Controller/Component.php | 14 ++++++++++++-- src/View/Page.php | 12 ++++++++---- src/tales.php | 10 +++++++--- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/src/Controller/Component.php b/src/Controller/Component.php index 0a8220c..0c95af2 100644 --- a/src/Controller/Component.php +++ b/src/Controller/Component.php @@ -263,10 +263,16 @@ class Controller_Component $component->parameter = $params; $component->template = $params->get('template', false); - global $componentsConfig; $editor = $component->getEditUrl(); if ($editor) { - $componentsConfig[] = $editor; + if(class_exists("Controller_Site")){ //Если мы в CMS2 + $instance = Controller_Site::getInstance(); + $instance->componentsConfig[] = $editor; + }else{ + global $componentsConfig; + $componentsConfig[] = $editor; + + } } return $component; @@ -311,6 +317,10 @@ class Controller_Component return '?' . http_build_query($arr); } + /** + * @deprecated В CMS2 перенесено в контроллер сайта! + */ + function addRequireJsPath($name, $path, $shim = null) { global $requireJsConfig; $requireJsConfig['paths'][$name] = $path; diff --git a/src/View/Page.php b/src/View/Page.php index acddc60..847061c 100644 --- a/src/View/Page.php +++ b/src/View/Page.php @@ -49,10 +49,14 @@ class View_Page extends View_View { //$result = phptal_component($match, $offset); - //* - global $db, $registry; // Нужно как-то передавать параметры - - $component = Controller_Component::loadComponent($match, $db, $registry); + + if(class_exists("Controller_Site")){ //Если мы в CMS2 + $component = Controller_Site::loadComponent($match); + }else{ + global $db, $registry; // + $component = Controller_Component::loadComponent($match, $db, $registry); + } + $req = new HttpRequest(); unset($req['active_page']); diff --git a/src/tales.php b/src/tales.php index 416263b..5f226a2 100644 --- a/src/tales.php +++ b/src/tales.php @@ -45,10 +45,14 @@ function phptal_time ($e) * Функция подключения компонента */ function phptal_component ($expression) { - global $db, $registry; // Нужно как-то передавать параметры - $begin = microtime(true); - $component = Controller_Component::loadComponent($expression, $db, $registry); + + if(class_exists("Controller_Site")){ //Если мы в CMS2 + $component = Controller_Site::loadComponent($match); + }else{ + global $db, $registry; // Иначе обращаемся к глобальным переменным + $component = Controller_Component::loadComponent($expression, $db, $registry); + } $req = new HttpRequest(); $result = $component->execute($req); From 3a02221172154a2daf1850eb39e9ee925e22ca80 Mon Sep 17 00:00:00 2001 From: Anatoly Date: Thu, 18 May 2017 12:33:21 +0300 Subject: [PATCH 3/6] fix --- src/tales.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tales.php b/src/tales.php index 5f226a2..5739bef 100644 --- a/src/tales.php +++ b/src/tales.php @@ -48,7 +48,7 @@ function phptal_component ($expression) { $begin = microtime(true); if(class_exists("Controller_Site")){ //Если мы в CMS2 - $component = Controller_Site::loadComponent($match); + $component = Controller_Site::loadComponent($expression); }else{ global $db, $registry; // Иначе обращаемся к глобальным переменным $component = Controller_Component::loadComponent($expression, $db, $registry); From 6573c07d09994aa2b1cddd74de14e33c0e000c8c Mon Sep 17 00:00:00 2001 From: Anatoly Date: Thu, 30 Nov 2017 10:58:50 +0300 Subject: [PATCH 4/6] =?UTF-8?q?=D0=92=D0=BE=D0=B7=D0=BC=D0=BE=D0=B6=D0=BD?= =?UTF-8?q?=D0=BE=D1=81=D1=82=D1=8C=20=D0=BF=D0=BE=D0=BB=D1=83=D1=87=D0=B8?= =?UTF-8?q?=D1=82=D1=8C=20=D1=81=D0=BF=D0=B8=D1=81=D0=BE=D0=BA=20=D0=BE?= =?UTF-8?q?=D0=BF=D1=86=D0=B8=D0=B9=20=D1=87=D0=B5=D1=80=D0=B5=D0=B7=20?= =?UTF-8?q?=D0=BC=D1=8D=D0=BF=D0=BF=D0=B5=D1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Controller/Component.php | 2 +- src/Form/Form.php | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Controller/Component.php b/src/Controller/Component.php index 99ca77c..d6886f8 100644 --- a/src/Controller/Component.php +++ b/src/Controller/Component.php @@ -175,7 +175,7 @@ class Controller_Component public function setParameters(/*.View_Composite.*/$view) { $form = new Form_Form(); - $options = new OptionFactory($this->db); + $options = new OptionFactory($this->db, $this->registry); $settings = $this->getInfo(); $form->addFieldList($settings['parameter'], $options); diff --git a/src/Form/Form.php b/src/Form/Form.php index f0e6922..c4caafe 100644 --- a/src/Form/Form.php +++ b/src/Form/Form.php @@ -190,9 +190,10 @@ class TDateTime extends TInput { class OptionFactory { public $db; - - function __construct($db) { + public $registry; + function __construct($db, $registry = null) { $this->db = $db; + $this->registry = $registry; } function create(TSelect $field, $input) { @@ -225,6 +226,10 @@ class OptionFactory { $field->options = $this->optionsDB($key, $value, $query_result); } elseif (isset($input['options.pair'])) { $field->options = $this->optionsPair($input['options.pair']); + } elseif (isset($input['options.model'])) { + $factory = new Model_Factory($this->db, $this->registry); + $model = $factory->getModel($input['options.model']); + $field->options = $model->getAllAsOptions(); } else { $field->options = $input['options']; } From 0d152a689a3cb5bc1a00aea73a9bd3fb2f52cf79 Mon Sep 17 00:00:00 2001 From: Anatoly Date: Mon, 15 Jan 2018 16:38:18 +0300 Subject: [PATCH 5/6] =?UTF-8?q?=D0=9D=D0=B5=D0=BA=D0=BE=D1=82=D0=BE=D1=80?= =?UTF-8?q?=D1=8B=D0=B5=20=D0=B8=D1=81=D0=BA=D0=BB=D1=8E=D1=87=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Controller/Front.php | 11 ++++++++++- src/UserMessageException.php | 17 +++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 src/UserMessageException.php diff --git a/src/Controller/Front.php b/src/Controller/Front.php index d317e2a..af064ad 100644 --- a/src/Controller/Front.php +++ b/src/Controller/Front.php @@ -101,6 +101,15 @@ class Controller_Front extends Controller_Action } else { $controller = false; } - return $this->loadModule($name[0], $request, $controller); + try{ + return $this->loadModule($name[0], $request, $controller); + } catch (UserMessageException $ex) { //Исключение с понятным пользователю сообщением + $mode = $request->get('mode'); + if($mode == 'ajax' || $mode == 'json'){ + return json_encode(['result'=>'fail', 'message'=> $ex->userMessage]); + } else { + return $ex->userMessage; + } + } } } diff --git a/src/UserMessageException.php b/src/UserMessageException.php new file mode 100644 index 0000000..88286de --- /dev/null +++ b/src/UserMessageException.php @@ -0,0 +1,17 @@ +userMessage = $message; + } +} \ No newline at end of file From bc8a549c51a2f199004ec845df297d7b5367c6a0 Mon Sep 17 00:00:00 2001 From: Anatoly Date: Mon, 15 Jan 2018 16:40:27 +0300 Subject: [PATCH 6/6] +whitelist --- src/Filter/Login.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Filter/Login.php b/src/Filter/Login.php index 4ce7302..82e53d8 100644 --- a/src/Filter/Login.php +++ b/src/Filter/Login.php @@ -15,7 +15,8 @@ class Filter_Login extends Filter_Filter public $mode = 'ajax'; //AJAX-Реквесты для которых не требуется авторизация, потребовалось для сбора статистики - public $whiteRequestList = array(array('module' => "requiredcontent", "action" => "getcount")); + public $whiteRequestList = [['module' => "requiredcontent", "action" => "getcount"], + ['module' => "requiredcontent", "action" => "teststructure"]]; /** * Проверка авторизации * @return Boolean Авторизовани пользователь или нет