diff --git a/src/Controller/Action.php b/src/Controller/Action.php index b1f7db2..d209a46 100644 --- a/src/Controller/Action.php +++ b/src/Controller/Action.php @@ -203,17 +203,18 @@ class Action /** * Генерация ссылки c учетом прав пользователя на ссылки - * @param string $name Действие + * @param string $actionName Действие * @param array $param Дополнительные параметры * 'mode' означает что элемент до отправки обрабатывается javascript * @return Url|null */ - public function nUrl($name, array $param = []) + public function nUrl($actionName, array $param = []) { $access/*: ActionAccess*/ = $this->access; $url = new Url(); - if ($access == null || $access->checkAction($name)) { + //print_r([$name, $param]); + if ($access == null || $access->checkAction($actionName)) { $moduleName = explode("\\", strtolower(get_class($this))); if (count($moduleName) > 2) { array_shift($moduleName); @@ -221,7 +222,7 @@ class Action array_shift($moduleName); } } - $param = array_merge(['module' => implode("\\", $moduleName), "action" => $name], $param); + $param = array_merge(['module' => implode("\\", $moduleName), "action" => $actionName], $param); $url->setParent($this->part); $url->setQuery($param); diff --git a/src/Controller/Component.php b/src/Controller/Component.php index 386d6ac..2dc5ffc 100644 --- a/src/Controller/Component.php +++ b/src/Controller/Component.php @@ -231,6 +231,9 @@ class Component $view->component_title = $settings['title']; } + /** + * Обьеденить с ComponentFactory + */ static function loadComponent($expression, $site/*: SiteInterface*/) { @@ -289,6 +292,7 @@ class Component } } + // Вынести в отдельную функцию $db = $site->getDatabase(); $component->db = $db; diff --git a/src/Form/CheckBox.php b/src/Form/CheckBox.php index ea5f880..6eb1619 100644 --- a/src/Form/CheckBox.php +++ b/src/Form/CheckBox.php @@ -3,7 +3,7 @@ namespace ctiso\Form; use ctiso\Form\Field; -class Checkbox extends Field +class CheckBox extends Field { public $checked = false; function setValue($value) diff --git a/src/Form/Field.php b/src/Form/Field.php index d4e8a34..c3df594 100644 --- a/src/Form/Field.php +++ b/src/Form/Field.php @@ -16,6 +16,7 @@ class Field public $error = false; public $require = false; public $hint = null; + public $maxlength = null; public $fieldset = null; // Блоки (Убрать в отдельный класс!!!) public $_title = array(); @@ -33,7 +34,7 @@ class Field $this->fieldset = $input['fieldset']; } // Инициализация свойст обьетка - foreach (['label', 'name', 'type', 'description'] as $name) { + foreach (['label', 'name', 'type', 'description', 'maxlength'] as $name) { if (isset($input[$name])) { $this->$name = $input[$name]; } diff --git a/src/Form/Form.php b/src/Form/Form.php index 7cc74f8..6906ee5 100644 --- a/src/Form/Form.php +++ b/src/Form/Form.php @@ -29,41 +29,41 @@ class Form extends View { public $_title = array(); public $alias = array(); public $constructor = array(); - + /** * Строим форму по ее структуре. Каждому типу соответствует определенный класс. */ public function __construct() { $this->constructor = [ - 'input' => 'ctiso\\Form\\Input', + 'input' => Input::class, // input с проверкой на заполненность - 'inputreq' => 'ctiso\\Form\\Input', + 'inputreq' => Input::class, - 'date' => 'ctiso\\Form\\Date', - 'datereq' => 'ctiso\\Form\\Date', - 'datetime' => 'ctiso\\Form\\DateTime', + 'date' => Date::class, + 'datereq' => Date::class, + 'datetime' => DateTime::class, - 'color' => 'ctiso\\Form\\Color', - 'textarea' => 'ctiso\\Form\\TextArea', - 'text' => 'ctiso\\Form\\TextArea', - 'multiselect' => 'ctiso\\Form\\SelectMany', - 'select1' => 'ctiso\\Form\\SelectOne', - 'select' => 'ctiso\\Form\\SelectOne', - - 'questiontype'=> 'ctiso\\Form\\QuestionType', - 'secret' => 'ctiso\\Form\\Secret', - 'upload' => 'ctiso\\Form\\Upload', - 'image' => 'ctiso\\Form\\Upload', - 'checkbox' => 'ctiso\\Form\\CheckBox', - 'checkmany' => 'ctiso\\Form\\SelectMany', - 'hidden' => 'ctiso\\Form\\Hidden', - 'radio' => 'ctiso\\Form\\SelectOne', - 'filebrowser' => 'ctiso\\Form\\BrowserInput', - 'documents' => 'ctiso\\Form\\BrowserInput', - 'chooser' => 'ctiso\\Form\\Input', - 'select_chooser' => 'ctiso\\Form\\SelectOne', - 'html_text' => 'ctiso\\Form\\HtmlText' + 'color' => Color::class, + 'textarea' => TextArea::class, + 'text' => TextArea::class, + 'multiselect' => SelectMany::class, + 'select1' => SelectOne::class, + 'select' => SelectOne::class, + + 'questiontype'=> QuestionType::class, + 'secret' => Secret::class, + 'upload' => Upload::class, + 'image' => Upload::class, + 'checkbox' => CheckBox::class, + 'checkmany' => SelectMany::class, + 'hidden' => Hidden::class, + 'radio' => SelectOne::class, + 'filebrowser' => BrowserInput::class, + 'documents' => BrowserInput::class, + 'chooser' => Input::class, + 'select_chooser' => SelectOne::class, + 'html_text' => HtmlText::class ]; } @@ -77,7 +77,7 @@ class Form extends View { { $this->constructor [$name] = $class; } - + /** * Добавляет одно поле ввода на форму */ @@ -95,7 +95,7 @@ class Form extends View { if(isset($init['hint'])) { $el->hint = $init['hint']; } - + $this->field[$init['name']] = $el; return $el; } @@ -112,7 +112,7 @@ class Form extends View { /** * Добавление массива fieldset на форму */ - + public function addFieldSetList(array $list) { foreach ($list as $fieldset) { @@ -122,7 +122,7 @@ class Form extends View { /** * Добавляет список полей для формы - * @param array $list + * @param array $list */ public function addFieldList(array $list, $factory = null) { @@ -151,7 +151,7 @@ class Form extends View { /** * Устанавливает значения из масива - */ + */ function setValues(HttpRequest $request) { foreach ($this->field as $key => $_) { $value = $request->getRawData($this->method, $key); @@ -160,9 +160,9 @@ class Form extends View { } /** - * Заполняет форму данными из обьекта + * Заполняет форму данными из обьекта * @param object $data - * @param array $schema Связь между элементами формы и свойствами обьекта + * @param array $schema Связь между элементами формы и свойствами обьекта */ public function fill($data, array $schema) { @@ -177,7 +177,17 @@ class Form extends View { $this->field[$name]->setValue($value); } - function execute() + public function getSchema() { + return [ + 'field' => $this->field, + 'fieldset' => $this->fieldsets, + 'method' => $this->method, + 'action' => $this->action, + 'header' => $this->header + ]; + } + + function execute() { return $this; }