From a83f70422c8e25d0364a2e34844253958b612657 Mon Sep 17 00:00:00 2001 From: Anatoly Date: Thu, 18 May 2017 12:23:28 +0300 Subject: [PATCH] =?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);