Изменен механизм расширения ссылок. Избавление от глобальных переменных
This commit is contained in:
parent
524b27936a
commit
40fad0e75b
11 changed files with 77 additions and 61 deletions
|
|
@ -5,12 +5,12 @@ use ctiso\Shortcut,
|
|||
Exception,
|
||||
ctiso\Path,
|
||||
ctiso\Url,
|
||||
ctiso\View\View,
|
||||
ctiso\Model\Factory,
|
||||
ctiso\HttpRequest,
|
||||
ctiso\Functions,
|
||||
ctiso\Settings,
|
||||
ctiso\View\Composite,
|
||||
ctiso\Filter\ActionAccess,
|
||||
ctiso\View\View,
|
||||
ctiso\Controller\State;
|
||||
|
||||
|
|
@ -43,7 +43,7 @@ class Action
|
|||
|
||||
private $factory = null; // Ссылка на обьект создания модели
|
||||
private $helpers = array(); // Помошники для действий
|
||||
public $param = array(); // Параметры для ссылки
|
||||
public $part = null; // Параметры для ссылки
|
||||
|
||||
public /*.Settings.*/$settings; // Ссылка на настройки
|
||||
public $user; // Обьект пользователя
|
||||
|
|
@ -55,6 +55,7 @@ class Action
|
|||
public $childViews = array();
|
||||
|
||||
function __construct() {
|
||||
$this->part = new Url();
|
||||
}
|
||||
|
||||
public function setUp() {
|
||||
|
|
@ -198,6 +199,10 @@ class Action
|
|||
return "";
|
||||
}
|
||||
|
||||
public function addUrlPart($key, $value) {
|
||||
$this->part->addQueryParam($key, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Генерация ссылки c учетом прав пользователя на ссылки
|
||||
* @param string $name Действие
|
||||
|
|
@ -208,16 +213,20 @@ class Action
|
|||
public function nUrl($name, array $param = array())
|
||||
{
|
||||
/*.ActionAccess.*/$access = $this->access;
|
||||
$url = new Url();
|
||||
|
||||
if ($access == null || $access->checkAction($name)) {
|
||||
$param = array_merge(array(
|
||||
'module' => strtr($this->modulePrefix . strtolower(get_class($this)), array('module_' => '')),
|
||||
"action" => $name
|
||||
|
||||
), $param);
|
||||
|
||||
return new Url($param);
|
||||
$url->setParent($this->part);
|
||||
$url->setQuery($param);
|
||||
}
|
||||
return new Url();
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -318,7 +327,7 @@ class Action
|
|||
*/
|
||||
public function render()
|
||||
{
|
||||
if ($this->view instanceof View_View) {
|
||||
if ($this->view instanceof View) {
|
||||
$this->view->assignValues($this->ctrlValues);
|
||||
|
||||
/*.Composite.*/$node = null;
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ class Front extends Action
|
|||
return $module->access->execute($request);
|
||||
}
|
||||
|
||||
$system = $this->settings['system'];
|
||||
/*.Settings.*/$system = $this->settings['system'];
|
||||
|
||||
$moulesPath = Path::join($this->settings['base'], $system->readKey(['path', 'modules']));
|
||||
$logPath = Path::join($this->settings['site'], $system->readKey(['path', 'access.log']));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue