Оптимизации и исправления топов.

This commit is contained in:
CORP\phedor 2018-03-23 12:35:10 +03:00
parent 77fa3dbd5e
commit 0f4b2fb722
25 changed files with 109 additions and 53 deletions

View file

@ -38,6 +38,23 @@ class ComponentRequest {
}
}
class FakeTemplate {
public $_data = [];
public $_name = '';
function __construct($name) {
$this->_name = $name;
}
function __set($key, $value) {
$this->_data[$key] = $value;
}
function execute() {
return $this->_data;
}
}
/**
* Класс компонента
*/
@ -56,6 +73,7 @@ class Controller_Component
public /*.Settings.*/$registry;
public /*.Database.*/$db;
public /*.Collection.*/$parameter;
public $output = 'html';
public $module;
public $item_module;
@ -86,6 +104,10 @@ class Controller_Component
public function getView($name)
{
if ($this->output == 'json') {
return new FakeTemplate($name);
}
//
/*.Settings.*/$registry = $this->registry;
$template = ($this->template) ? $this->template : $registry->readKey(array('system', 'template'));
@ -164,8 +186,18 @@ class Controller_Component
return $result;
}
function findFile($pathList, $name) {
foreach($pathList as $item) {
$filename = Path::join($item, $name);
if (file_exists($filename)) {
return $filename;
}
}
return null;
}
function getInfo() {
$filename = Path::join($this->viewPath[0], 'install.json');
$filename = $this->findFile($this->viewPath, 'install.json');
if (file_exists($filename)) {
$settings = json_decode(File::getContents($filename), true);
return $settings;
@ -262,13 +294,13 @@ class Controller_Component
}
$params = new Collection();
$params->import(array_merge($_GET, $arguments));
$params->import($arguments);
$component->parameter = $params;
$component->template = $params->get('template', false);
$editor = $component->getEditUrl();
if ($editor) {
if(class_exists("Controller_Site")){ //Если мы в CMS2
if(class_exists("Controller_Site")) { //Если мы в CMS2
$instance = Controller_Site::getInstance();
$instance->componentsConfig[] = $editor;
} else {