Изменен механизм расширения ссылок. Избавление от глобальных переменных
This commit is contained in:
parent
524b27936a
commit
40fad0e75b
11 changed files with 77 additions and 61 deletions
|
|
@ -8,6 +8,7 @@ use ctiso\HttpRequest,
|
|||
ctiso\File,
|
||||
ctiso\Form\Form,
|
||||
ctiso\Form\OptionFactory,
|
||||
ctiso\View\Composite,
|
||||
ctiso\Database,
|
||||
ctiso\Database\PDOStatement,
|
||||
ctiso\Collection,
|
||||
|
|
@ -38,7 +39,7 @@ class FakeTemplate {
|
|||
}
|
||||
|
||||
function execute() {
|
||||
return $this->_data;
|
||||
return json_encode($this->_data);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -64,6 +65,7 @@ class Component
|
|||
|
||||
public $module;
|
||||
public $item_module;
|
||||
public $site;
|
||||
|
||||
function before() {
|
||||
}
|
||||
|
|
@ -95,7 +97,6 @@ class Component
|
|||
return new FakeTemplate($name);
|
||||
}
|
||||
|
||||
//
|
||||
/*.Settings.*/$registry = $this->registry;
|
||||
$template = ($this->template) ? $this->template : $registry->readKey(array('system', 'template'));
|
||||
|
||||
|
|
@ -195,7 +196,7 @@ class Component
|
|||
/**
|
||||
* Генерация интерфейса для выбора галлереи фотографии
|
||||
*/
|
||||
public function setParameters(/*.Composite.*/$view)
|
||||
public function setParameters(/*.Composite.*/ $view)
|
||||
{
|
||||
$form = new Form();
|
||||
$options = new OptionFactory($this->db, $this->registry);
|
||||
|
|
@ -208,7 +209,7 @@ class Component
|
|||
$view->component_title = $settings['title'];
|
||||
}
|
||||
|
||||
static function loadComponent($expression, Database $db, /*.Settings.*/ $registry)
|
||||
static function loadComponent($expression, /*.Site.*/ $site)
|
||||
{
|
||||
|
||||
$expression = htmlspecialchars_decode($expression);
|
||||
|
|
@ -232,22 +233,16 @@ class Component
|
|||
|
||||
if (file_exists($path)) {
|
||||
require_once ($path);
|
||||
|
||||
$component = new $className();
|
||||
$component->db = $db;
|
||||
$component->registry = $registry;
|
||||
|
||||
$component->viewPath = array(BASE_PATH . '/components/' . $name . '/');
|
||||
$component->webPath = array(SITE_WWW_PATH . '/components/' . $name);
|
||||
|
||||
$component->COMPONENTS_WEB = SITE_WWW_PATH . '/components/';
|
||||
|
||||
} else {
|
||||
$path = Path::join (COMPONENTS, $name, $name . '.php');
|
||||
require_once ($path);
|
||||
$component = new $className();
|
||||
$component->db = $db;
|
||||
$component->registry = $registry;
|
||||
|
||||
$component->viewPath = array(COMPONENTS . '/' . $name . '/', BASE_PATH . '/components/' . $name . '/');
|
||||
if (defined('COMPONENTS_WEB')) {
|
||||
|
|
@ -255,6 +250,12 @@ class Component
|
|||
$component->COMPONENTS_WEB = COMPONENTS_WEB;
|
||||
}
|
||||
}
|
||||
|
||||
$db = $site->db;
|
||||
|
||||
$component->db = $db;
|
||||
$component->registry = $site->registry;
|
||||
$component->site = $site;
|
||||
|
||||
$stmt = $db->prepareStatement("SELECT * FROM component WHERE code = ?");
|
||||
$stmt->setString(1, $expression);
|
||||
|
|
@ -282,18 +283,13 @@ class Component
|
|||
|
||||
$params = new Collection();
|
||||
$params->import($arguments);
|
||||
|
||||
$component->parameter = $params;
|
||||
$component->template = $params->get('template', false);
|
||||
|
||||
$editor = $component->getEditUrl();
|
||||
if ($editor) {
|
||||
if (class_exists("Controller_Site")) { //Если мы в CMS2
|
||||
$instance = Site::getInstance();
|
||||
$instance->componentsConfig[] = $editor;
|
||||
} else {
|
||||
global $componentsConfig;
|
||||
$componentsConfig[] = $editor;
|
||||
}
|
||||
$site->componentsConfig[] = $editor;
|
||||
}
|
||||
|
||||
return $component;
|
||||
|
|
@ -338,12 +334,8 @@ class Component
|
|||
return '?' . http_build_query($arr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated В CMS2 перенесено в контроллер сайта!
|
||||
*/
|
||||
|
||||
function addRequireJsPath($name, $path, $shim = null) {
|
||||
Site::addRequireJsPath($name, $path, $shim);
|
||||
$this->site->addRequireJsPath($name, $path, $shim);
|
||||
}
|
||||
|
||||
function actionIndex(/*.ComponentRequest.*/ $request) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue