diff --git a/src/Controller/Action.php b/src/Controller/Action.php index cbfd202..99391a6 100644 --- a/src/Controller/Action.php +++ b/src/Controller/Action.php @@ -101,9 +101,9 @@ class Action /** * Создает представление - * @param $name String - * @param $viewClass String - * @return View_Composite + * @param string + * @param string $viewClass + * @return Composite */ public function getView($name, $viewClass = 'ctiso\\View\\Composite') { @@ -163,7 +163,7 @@ class Action * Т.к действия являются методами класса то * 1. Можно переопределить действия * 2. Использовать наследование чтобы добавить к старому обработчику новое поведение - * @param $request Обьект запроса + * @param HttpRequest $request запроса */ public function preProcess(HttpRequest $request) { diff --git a/src/Controller/Component.php b/src/Controller/Component.php index 630312d..4fb8fba 100644 --- a/src/Controller/Component.php +++ b/src/Controller/Component.php @@ -88,7 +88,7 @@ class Component } } - public function getTemplateName($_registry/*: Settings*/) { + public function getTemplateName($_registry/*: \ctiso\Settings*/) { return (isset($_COOKIE['with_template']) && preg_match('/^[\w\d-]{3,20}$/', $_COOKIE['with_template'])) ? $_COOKIE['with_template'] : ($_registry ? $_registry->get('site', 'template') : 'modern'); } @@ -147,7 +147,7 @@ class Component } public function getTemplatePath($name) { - $registry/*: Settings*/ = $this->config; + $registry/*: \ctiso\Settings*/ = $this->config; // Брать настройки из куков если есть $template = ($this->template) ? $this->template : $this->getTemplateName($registry); foreach ($this->viewPath as $index => $viewPath) { diff --git a/src/Database/PDOStatement.php b/src/Database/PDOStatement.php index d837669..af8c19f 100644 --- a/src/Database/PDOStatement.php +++ b/src/Database/PDOStatement.php @@ -5,6 +5,7 @@ namespace ctiso\Database; use ctiso\Database\StatementIterator, ctiso\Tools\StringUtil, PDO; +use TheSeer\Tokenizer\Exception; class PDOStatement extends \PDOStatement implements \IteratorAggregate { @@ -12,7 +13,7 @@ class PDOStatement extends \PDOStatement implements \IteratorAggregate public $cache = array(); public $fields; - function getIterator(): Iterator { + function getIterator(): \Iterator { return new StatementIterator($this); } @@ -73,7 +74,7 @@ class PDOStatement extends \PDOStatement implements \IteratorAggregate function getInt($name) { if (!$this->fields) { - throw new Error('no fields'); + throw new \Exception('no fields'); } return (int)$this->fields[$name]; } diff --git a/src/Form/OptionFactory.php b/src/Form/OptionFactory.php deleted file mode 100644 index 724b3e6..0000000 --- a/src/Form/OptionFactory.php +++ /dev/null @@ -1,87 +0,0 @@ -db = $db; - $this->registry = $registry; - } - - function create(Form_Select $field, $input) { - if (isset($input['options.resid'])) { - $type = $input['options.resid']; - - $res = new Model_Resources($this->db); - $field->options = $this->optionsArray('id_section', 'title', $res->getSubsections('', $type)); - - } else if (isset($input['options.res'])) { - $type = $input['options.res']; - - $res = new Model_Resources($this->db); - $field->options = $this->optionsArray('path', 'title', $res->getSubsections('', $type)); - - } else if (isset($input['options.all_res'])) { - $type = $input['options.all_res']; - - $res = new Model_Resources($this->db); - $field->options = $this->optionsArray('id_resource', 'subtitle', $res->getAllResource($type)); - - } else if (isset($input['options.db'])) { - list($table, $keyvalue) = explode(":", $input['options.db']); - list($key, $value) = explode(",", $keyvalue); - try { - $query_result = $this->db->executeQuery("SELECT * FROM $table"); - $field->options = $this->optionsDB($key, $value, $query_result); - } catch(Exception $ex) { - $field->options = []; - } - } elseif (isset($input['options.pair'])) { - $field->options = $this->optionsPair($input['options.pair']); - } elseif (isset($input['options.model'])) { - $factory = new Model_Factory($this->db, $this->registry); - $model = $factory->getModel($input['options.model']); - $field->options = $model->getAllAsOptions(); - } else { - $field->options = $input['options']; - } - if (isset($input['default'])) { - array_unshift($field->options, ['value' => 0, 'name' => $input['default']]); - } - - // Ставим корневой каталог в начало списка (скорее всего он будет в конце массива) - if ($field->options) - { - $root_elem = array_pop($field->options); - if ($root_elem['value'] == '/') - array_unshift($field->options, $root_elem); - else - array_push($field->options, $root_elem); - } - } - - public function optionsDB($key, $val, $res) { - $result = array(); - while($res->next()) { - $result[] = array('value' => $res->getInt($key), 'name' => $res->getString($val)); - } - return $result; - } - - public function optionsArray($key, $val, $res) { - $result = array(); - foreach($res as $item) { - $result[] = array('value' => $item->{$key}, 'name' => $item->{$val}); - } - return $result; - } - - public function optionsPair($list, $selected = false) { - $result = array(); - foreach ($list as $key => $value) { - $result [] = array('value' => $key, 'name' => $value, 'selected' => $key == $selected); - } - return $result; - } -} diff --git a/src/Model/BaseMapper.php b/src/Model/BaseMapper.php new file mode 100644 index 0000000..50cad30 --- /dev/null +++ b/src/Model/BaseMapper.php @@ -0,0 +1,6 @@ +namespace[$ns]['data'][$key])) { + return $this->namespace[$ns]['data'][$key]; + } + return null; + } + public function has($ns, $key) { return isset($this->namespace[$ns]['data'][$key]); } diff --git a/src/UserMessageException.php b/src/UserMessageException.php index 1049dc9..226eb75 100644 --- a/src/UserMessageException.php +++ b/src/UserMessageException.php @@ -4,9 +4,8 @@ * @see Controller_Front */ namespace ctiso; -use Exception; -class UserMessageException extends Exception { +class UserMessageException extends \Exception { public $userMessage; public function __construct($message) { parent::__construct($message);