Правки namespace
This commit is contained in:
parent
ee06f1febb
commit
524b27936a
39 changed files with 141 additions and 120 deletions
|
|
@ -10,6 +10,8 @@ use ctiso\Shortcut,
|
|||
ctiso\HttpRequest,
|
||||
ctiso\Functions,
|
||||
ctiso\Settings,
|
||||
ctiso\View\Composite,
|
||||
ctiso\View\View,
|
||||
ctiso\Controller\State;
|
||||
|
||||
/**
|
||||
|
|
@ -82,18 +84,15 @@ class Action
|
|||
return Path::join($basePath, "modules", $name);
|
||||
}
|
||||
|
||||
public function addSuggest(View $view, $name)
|
||||
{
|
||||
public function addSuggest(View $view, $name) {
|
||||
$suggest = array();
|
||||
$file = Path::join($this->modulePath, 'help', $name . '.suggest');
|
||||
if (file_exists($file)) {
|
||||
include($file);
|
||||
$view->suggestions = $suggest;
|
||||
$view->suggestions = include($file);
|
||||
}
|
||||
}
|
||||
|
||||
function findIcon($icon, $size)
|
||||
{
|
||||
function findIcon($icon, $size) {
|
||||
$webPath = $this->settings['web'];
|
||||
return Path::join($webPath, 'icons', $size . 'x' . $size, $icon . '.png');
|
||||
}
|
||||
|
|
@ -122,7 +121,7 @@ class Action
|
|||
if(file_exists($template)) { break; }
|
||||
}
|
||||
|
||||
/*.View_Composite.*/$tpl = new $viewClass($template);
|
||||
/*.Composite.*/$tpl = new $viewClass($template);
|
||||
|
||||
$stylePath = Path::join($webPath, "assets", "css");
|
||||
$iconsPath = Path::join($webPath, 'icons');
|
||||
|
|
@ -170,7 +169,7 @@ class Action
|
|||
$action = "actionIndex";
|
||||
}
|
||||
$view = $this->forward($action, $request);
|
||||
if ($view instanceof View_View) {
|
||||
if ($view instanceof View) {
|
||||
$view->active_module = get_class($this);
|
||||
$view->module_action = $action;
|
||||
}
|
||||
|
|
@ -208,7 +207,7 @@ class Action
|
|||
*/
|
||||
public function nUrl($name, array $param = array())
|
||||
{
|
||||
/*.Filter_ActionAccess.*/$access = $this->access;
|
||||
/*.ActionAccess.*/$access = $this->access;
|
||||
|
||||
if ($access == null || $access->checkAction($name)) {
|
||||
$param = array_merge(array(
|
||||
|
|
@ -295,12 +294,12 @@ class Action
|
|||
/**
|
||||
* Добавление widget к отображению
|
||||
*/
|
||||
public function addChild(/*Widgets_Widget*/ $section, $node)
|
||||
public function addChild($section, $node)
|
||||
{
|
||||
$this->childNodes[$section] = $node;
|
||||
}
|
||||
|
||||
public function setValue(/*Widgets_Widget*/ $name, $value)
|
||||
public function setValue($name, $value)
|
||||
{
|
||||
$this->ctrlValues[$name] = $value;
|
||||
}
|
||||
|
|
@ -308,7 +307,7 @@ class Action
|
|||
/**
|
||||
* Добавление дочернего отображения к текущему отображению
|
||||
*/
|
||||
public function addView(/*CompositeView*/ $section, $node)
|
||||
public function addView($section, $node)
|
||||
{
|
||||
$this->childViews[$section] = $node;
|
||||
}
|
||||
|
|
@ -322,7 +321,7 @@ class Action
|
|||
if ($this->view instanceof View_View) {
|
||||
$this->view->assignValues($this->ctrlValues);
|
||||
|
||||
/*.Widgets_Widget.*/$node = null;
|
||||
/*.Composite.*/$node = null;
|
||||
foreach ($this->childNodes as $name => $node) {
|
||||
$node->make($this);
|
||||
$this->view->setView($name, $node->view);
|
||||
|
|
@ -335,8 +334,7 @@ class Action
|
|||
return $this->view;
|
||||
}
|
||||
|
||||
function getPageId(HttpRequest $request)
|
||||
{
|
||||
function getPageId(HttpRequest $request) {
|
||||
$pageId = time();
|
||||
$request->session()->set('page', $pageId);
|
||||
return $pageId;
|
||||
|
|
@ -353,19 +351,17 @@ class Action
|
|||
return $result;
|
||||
}
|
||||
|
||||
function _getActionPath()
|
||||
{
|
||||
function _getActionPath() {
|
||||
return new State('index');
|
||||
}
|
||||
|
||||
// Тоже убрать в метод Controller_Model
|
||||
function getActionPath(HttpRequest $request, $action = null)
|
||||
{
|
||||
function getActionPath(HttpRequest $request, $action = null) {
|
||||
$this->_getActionPath()->getPath($this, ($action) ? $action : $request->getAction());
|
||||
}
|
||||
|
||||
function redirect($action) {
|
||||
header('location: ' . $this->fUrl($action));
|
||||
header('location: ' . $action->toString());
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,16 +2,19 @@
|
|||
|
||||
namespace ctiso\Controller;
|
||||
use ctiso\HttpRequest,
|
||||
ctiso\ComponentRequest,
|
||||
ctiso\Arr,
|
||||
ctiso\Path,
|
||||
PHPTAL,
|
||||
PHPTAL_PreFilter_Normalize,
|
||||
ctiso\File,
|
||||
ctiso\Form\Form,
|
||||
ctiso\Form\OptionFactory,
|
||||
ctiso\Database,
|
||||
ctiso\Database\PDOStatement,
|
||||
ctiso\Collection,
|
||||
ctiso\Controller\Site;
|
||||
ctiso\Settings,
|
||||
App\Controller\Site,
|
||||
PHPTAL,
|
||||
PHPTAL_PreFilter_Normalize;
|
||||
|
||||
function replaceContent($match) {
|
||||
$result = Tales\Component::phptal_component(htmlspecialchars_decode($match[3]));
|
||||
|
|
@ -22,35 +25,6 @@ function applyComponents($text) {
|
|||
return preg_replace_callback('/<(\w+)(\s+[a-zA-Z\-]+=\"[^\"]*\")*\s+tal:replace="structure\s+component:([^\"]*)"[^>]*>/u', 'replaceContent', $text);
|
||||
}
|
||||
|
||||
class ComponentRequest {
|
||||
public $component_id;
|
||||
public $component_title;
|
||||
public $r;
|
||||
|
||||
function __construct($c, HttpRequest $r) {
|
||||
$this->component_id = $c;
|
||||
$this->r = $r;
|
||||
}
|
||||
|
||||
function get($key, $default = null) {
|
||||
if ($key == 'active_page') {
|
||||
return $this->r->get($key);
|
||||
}
|
||||
if ($arr = $this->r->get($key)) {
|
||||
if (is_array($arr)) {
|
||||
return Arr::get($arr, $this->component_id, $default);
|
||||
} else {
|
||||
return $arr;
|
||||
}
|
||||
}
|
||||
return $default;
|
||||
}
|
||||
|
||||
function getAction() {
|
||||
return $this->r->getAction();
|
||||
}
|
||||
}
|
||||
|
||||
class FakeTemplate {
|
||||
public $_data = [];
|
||||
public $_name = '';
|
||||
|
|
@ -183,7 +157,7 @@ class Component
|
|||
return $model;
|
||||
}
|
||||
|
||||
public function options($key, $val, /*.Database_PDOStatement.*/$res) {
|
||||
public function options($key, $val, /*.PDOStatement.*/$res) {
|
||||
$result = array();
|
||||
while($res->next()) {
|
||||
$result[] = array('value' => $res->getString($key), 'name' => $res->getString($val));
|
||||
|
|
@ -221,7 +195,7 @@ class Component
|
|||
/**
|
||||
* Генерация интерфейса для выбора галлереи фотографии
|
||||
*/
|
||||
public function setParameters(/*.View_Composite.*/$view)
|
||||
public function setParameters(/*.Composite.*/$view)
|
||||
{
|
||||
$form = new Form();
|
||||
$options = new OptionFactory($this->db, $this->registry);
|
||||
|
|
@ -234,7 +208,7 @@ class Component
|
|||
$view->component_title = $settings['title'];
|
||||
}
|
||||
|
||||
static function loadComponent($expression, Database $db, /*.Registry.*/ $registry)
|
||||
static function loadComponent($expression, Database $db, /*.Settings.*/ $registry)
|
||||
{
|
||||
|
||||
$expression = htmlspecialchars_decode($expression);
|
||||
|
|
@ -254,7 +228,7 @@ class Component
|
|||
$path = Path::join (BASE_PATH, 'components', $name, $name . '.php');
|
||||
$className = 'Component_' . $name;
|
||||
|
||||
/*.Controller_Component.*/$component = null;
|
||||
/*.Component.*/$component = null;
|
||||
|
||||
if (file_exists($path)) {
|
||||
require_once ($path);
|
||||
|
|
@ -313,7 +287,7 @@ class Component
|
|||
|
||||
$editor = $component->getEditUrl();
|
||||
if ($editor) {
|
||||
if(class_exists("Controller_Site")) { //Если мы в CMS2
|
||||
if (class_exists("Controller_Site")) { //Если мы в CMS2
|
||||
$instance = Site::getInstance();
|
||||
$instance->componentsConfig[] = $editor;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ class Front extends Action
|
|||
return $this->loadModule($name[0], $request, $controller);
|
||||
} catch (UserMessageException $ex) { //Исключение с понятным пользователю сообщением
|
||||
$mode = $request->get('mode');
|
||||
if($mode == 'ajax' || $mode == 'json') {
|
||||
if ($mode == 'ajax' || $mode == 'json') {
|
||||
return json_encode(['result'=>'fail', 'message'=> $ex->userMessage]);
|
||||
} else {
|
||||
return $ex->userMessage;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace ctiso\Controller;
|
||||
use ctiso\HttpRequest;
|
||||
|
||||
class Request {
|
||||
public $r;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@
|
|||
* Класс сервиса = Упрощенный компонент
|
||||
*/
|
||||
namespace ctiso\Controller;
|
||||
use ctiso\Path;
|
||||
use ctiso\Path,
|
||||
ctiso\Database\PDOStatement;
|
||||
|
||||
class Service
|
||||
{
|
||||
|
|
@ -49,7 +50,7 @@ class Service
|
|||
return $model;
|
||||
}
|
||||
|
||||
public function options($key, $val, /*.Database_PDOStatement.*/$res) {
|
||||
public function options($key, $val, /*.PDOStatement.*/$res) {
|
||||
$result = array();
|
||||
while($res->next()) {
|
||||
$result[] = array('value' => $res->getInt($key), 'name' => $res->getString($val));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue