Обьединение с namespace

This commit is contained in:
CORP\phedor 2018-03-28 11:15:16 +03:00
commit 8b38b2a3cc
90 changed files with 601 additions and 222 deletions

View file

@ -1,7 +1,20 @@
<?php
namespace ctiso\Controller;
use ctiso\HttpRequest,
ctiso\Arr,
ctiso\Path,
PHPTAL,
PHPTAL_PreFilter_Normalize,
ctiso\File,
ctiso\Form\Form,
ctiso\Form\OptionFactory,
ctiso\Database,
ctiso\Collection,
ctiso\Controller\Site;
function replaceContent($match) {
$result = phptal_component(htmlspecialchars_decode($match[3]));
$result = Tales\Component::phptal_component(htmlspecialchars_decode($match[3]));
return $result;
}
@ -38,10 +51,27 @@ 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;
}
}
/**
* Класс компонента
*/
class Controller_Component
class Component
{
public $viewPath = array();
public $webPath = array();
@ -56,6 +86,7 @@ class Controller_Component
public /*.Settings.*/$registry;
public /*.Database.*/$db;
public /*.Collection.*/$parameter;
public $output = 'html';
public $module;
public $item_module;
@ -86,6 +117,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 +199,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;
@ -178,8 +223,8 @@ class Controller_Component
*/
public function setParameters(/*.View_Composite.*/$view)
{
$form = new Form_Form();
$options = new Form_OptionFactory($this->db, $this->registry);
$form = new Form();
$options = new OptionFactory($this->db, $this->registry);
$settings = $this->getInfo();
$form->addFieldList($settings['parameter'], $options);
@ -262,14 +307,14 @@ 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
$instance = Controller_Site::getInstance();
if(class_exists("Controller_Site")) { //Если мы в CMS2
$instance = Site::getInstance();
$instance->componentsConfig[] = $editor;
} else {
global $componentsConfig;
@ -324,10 +369,9 @@ class Controller_Component
*/
function addRequireJsPath($name, $path, $shim = null) {
Controller_Site::addRequireJsPath($name, $path, $shim);
Site::addRequireJsPath($name, $path, $shim);
}
function actionIndex(/*.ComponentRequest.*/ $request) {
}
}