From 0f4b2fb722662a897d8fc48e4d775740f3507402 Mon Sep 17 00:00:00 2001 From: "CORP\\phedor" Date: Fri, 23 Mar 2018 12:35:10 +0300 Subject: [PATCH 1/4] =?UTF-8?q?=D0=9E=D0=BF=D1=82=D0=B8=D0=BC=D0=B8=D0=B7?= =?UTF-8?q?=D0=B0=D1=86=D0=B8=D0=B8=20=D0=B8=20=D0=B8=D1=81=D0=BF=D1=80?= =?UTF-8?q?=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=20=D1=82=D0=BE=D0=BF?= =?UTF-8?q?=D0=BE=D0=B2.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Collection.php | 6 ++--- src/Connection/HttpResponse.php | 10 ++++---- src/Controller/Component.php | 38 ++++++++++++++++++++++++++--- src/Controller/Front.php | 6 ++--- src/Controller/Request.php | 8 ++++-- src/Controller/Service.php | 5 +++- src/Database/IdGenerator.php | 2 +- src/Database/PDOStatement.php | 2 +- src/Excel/DataTime.php | 2 +- src/Excel/Number.php | 2 +- src/Excel/Table.php | 4 +-- src/Filter/Login.php | 1 + src/Functions.php | 9 ++++--- src/Numbers.php | 3 ++- src/Path.php | 19 +++++++++------ src/Primitive.php | 6 ++--- src/Tools/Drawing.php | 3 ++- src/Tools/SQLStatementExtractor.php | 4 +-- src/Tools/String.php | 4 +-- src/Tools/TemplateImage.php | 19 +++++++++------ src/Validator/Rule/Code.php | 3 ++- src/Validator/Rule/Count.php | 2 +- src/Validator/Rule/Date.php | 1 + src/Validator/Rule/Time.php | 2 +- src/config.php | 1 + 25 files changed, 109 insertions(+), 53 deletions(-) diff --git a/src/Collection.php b/src/Collection.php index 467175e..e56b2d1 100644 --- a/src/Collection.php +++ b/src/Collection.php @@ -58,17 +58,17 @@ class Collection implements ArrayAccess public function getInt($key, $default = 0) { - return intval($this->get($key, $default)); + return (int)$this->get($key, $default); } public function getString($key, $default = '') { - return ((string) $this->get($key, $default)); + return (string)$this->get($key, $default); } public function getNat($key, $default = 1) { - $result = intval($this->get($key, $default)); + $result = (int)$this->get($key, $default); return (($result > 0) ? $result : $default); } diff --git a/src/Connection/HttpResponse.php b/src/Connection/HttpResponse.php index 9e94c9f..df08cbc 100644 --- a/src/Connection/HttpResponse.php +++ b/src/Connection/HttpResponse.php @@ -36,12 +36,12 @@ class Connection_HttpResponse if (isset($this->param['Transfer-Encoding']) && $this->param['Transfer-Encoding'] == 'chunked') { //$this->data = substr($this->response, $this->offset); - $line = hexdec($this->getLine()); + $index = hexdec($this->getLine()); $chunk = array(); - while ($line > 0) { - $chunk [] = substr($this->response, $this->offset, $line); - $this->offset += $line; - $line = hexdec($this->getLine()); + while ($index > 0) { + $chunk [] = substr($this->response, $this->offset, $index); + $this->offset += $index; + $index = hexdec($this->getLine()); } $this->data = implode("", $chunk); diff --git a/src/Controller/Component.php b/src/Controller/Component.php index efc3cdf..dce2076 100644 --- a/src/Controller/Component.php +++ b/src/Controller/Component.php @@ -38,6 +38,23 @@ 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; + } +} + /** * Класс компонента */ @@ -56,6 +73,7 @@ class Controller_Component public /*.Settings.*/$registry; public /*.Database.*/$db; public /*.Collection.*/$parameter; + public $output = 'html'; public $module; public $item_module; @@ -86,6 +104,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 +186,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; @@ -262,13 +294,13 @@ 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 + if(class_exists("Controller_Site")) { //Если мы в CMS2 $instance = Controller_Site::getInstance(); $instance->componentsConfig[] = $editor; } else { diff --git a/src/Controller/Front.php b/src/Controller/Front.php index af064ad..772d177 100644 --- a/src/Controller/Front.php +++ b/src/Controller/Front.php @@ -40,7 +40,7 @@ class Controller_Front extends Controller_Action * @param request $request Имя модуля * @return string */ - public function loadModule($name, Collection $request, $controller = false) + public function loadModule($name, Collection $request, $controller = null) { if ($this->isLoaded($name)) { $module = $this->modules[$name]; @@ -93,13 +93,13 @@ class Controller_Front extends Controller_Action $this->default = $name; } - public function execute(HTTPRequest $request) + public function execute(HttpRequest $request) { $name = explode("_", $request->get($this->_param, $this->default)); if (count($name) >= 2) { $controller = $name[1]; } else { - $controller = false; + $controller = null; } try{ return $this->loadModule($name[0], $request, $controller); diff --git a/src/Controller/Request.php b/src/Controller/Request.php index 01822e1..1ac7be4 100644 --- a/src/Controller/Request.php +++ b/src/Controller/Request.php @@ -1,13 +1,17 @@ r = $request; $this->id = $id; } - function get($name) { + function get($name, $def) { $v = $this->r->get($name); + $id = $this->id; if ($id && is_array($v)) { return isset($v[$id]) ? $v[$id] : $def; } diff --git a/src/Controller/Service.php b/src/Controller/Service.php index 46f96aa..64b8a59 100644 --- a/src/Controller/Service.php +++ b/src/Controller/Service.php @@ -5,12 +5,15 @@ */ class Controller_Service { - public $viewPath = array(); + public $viewPath = []; + public $webPath = []; public $registry; // Registry->getInstance public $template; public $templatePath; public $COMPONENTS_WEB; + public $db; + public function getTemplatePath($name) { return Path::join($this->viewPath[0], 'templates', 'modern', $name); diff --git a/src/Database/IdGenerator.php b/src/Database/IdGenerator.php index 045ec86..41ee235 100644 --- a/src/Database/IdGenerator.php +++ b/src/Database/IdGenerator.php @@ -21,6 +21,6 @@ class Database_IdGenerator { } else { $result = $this->db->fetchOneArray("SELECT last_insert_rowid() AS nextval"); } - return intval($result['nextval']); + return (int)$result['nextval']; } } diff --git a/src/Database/PDOStatement.php b/src/Database/PDOStatement.php index 1274e6e..e74a244 100644 --- a/src/Database/PDOStatement.php +++ b/src/Database/PDOStatement.php @@ -66,7 +66,7 @@ class Database_PDOStatement extends PDOStatement implements IteratorAggregate } function getInt($name) { - return intval($this->fields[$name]); + return (int)$this->fields[$name]; } function getBlob($name) { diff --git a/src/Excel/DataTime.php b/src/Excel/DataTime.php index 0536cbd..8e590d0 100644 --- a/src/Excel/DataTime.php +++ b/src/Excel/DataTime.php @@ -6,7 +6,7 @@ class Excel_DateTime function __construct($value) { - $this->value = intval($value); + $this->value = (int)$value; } function getString() diff --git a/src/Excel/Number.php b/src/Excel/Number.php index 66dd6b6..5d212fe 100644 --- a/src/Excel/Number.php +++ b/src/Excel/Number.php @@ -6,7 +6,7 @@ class Excel_Number function __construct($value) { - $this->value = intval($value); + $this->value = (int)$value; } function getString() diff --git a/src/Excel/Table.php b/src/Excel/Table.php index 162c823..63e2f80 100644 --- a/src/Excel/Table.php +++ b/src/Excel/Table.php @@ -50,7 +50,7 @@ class Excel_Table function __construct() { - $this->name = "Page " . intval(self::$index ++); + $this->name = "Page " . ((int)self::$index ++); } /** @@ -230,7 +230,7 @@ class Excel_Table } else { $doc->writeAttribute('ss:Type', "Number"); } - $doc->writeCData($this->encode($value)); + $doc->writeCdata($this->encode($value)); } $doc->endElement(); $doc->endElement(); diff --git a/src/Filter/Login.php b/src/Filter/Login.php index 70ad01d..df3476d 100644 --- a/src/Filter/Login.php +++ b/src/Filter/Login.php @@ -13,6 +13,7 @@ class Filter_Login extends Filter_Filter const SESSION_BROWSER_SIGN_SECRET = '@w3dsju45Msk#'; const SESSION_BROWSER_SIGN_KEYNAME = 'session.app.browser.sign'; public $mode = 'ajax'; + public $user; //AJAX-Реквесты для которых не требуется авторизация, потребовалось для сбора статистики public $whiteRequestList = [['module' => "requiredcontent", "action" => "getcount"], diff --git a/src/Functions.php b/src/Functions.php index 3f888e7..61b9123 100644 --- a/src/Functions.php +++ b/src/Functions.php @@ -53,7 +53,8 @@ class __partial { function apply() { $params = func_get_args(); $result = array(); - for($i = 0, $j = 0; $i < count($this->params); $i++) { + $count = count($this->params); + for($i = 0, $j = 0; $i < $count; $i++) { if ($this->params[$i] == __) { $result [] = $params[$j]; $j++; @@ -77,7 +78,8 @@ class __compose { function apply () { $params = func_get_args (); $result = call_user_func_array($this->fns[0], $params); - for ($i = 1; $i < count($this->fns); $i++) { + $count = count($this->fns); + for ($i = 1; $i < $count; $i++) { $result = call_user_func($this->fns[$i], $result); } return $result; @@ -306,7 +308,8 @@ class Functions { assert(is_int($length)); $result = array(); - for($i = 0; $i < count($array); $i += $length) { + $count = count($array); + for($i = 0; $i < $count; $i += $length) { $result [] = array_slice($array, $i, $length); } return $result; diff --git a/src/Numbers.php b/src/Numbers.php index c0a39c7..9001e4a 100644 --- a/src/Numbers.php +++ b/src/Numbers.php @@ -15,7 +15,8 @@ class Numbers static function prefix($prefix, array $array, $key = false) { $result = array(); - for ($i = 0; $i < count($array); $i++) { + $count = count($array); + for ($i = 0; $i < $count; $i++) { $result [] = call_user_func($prefix, $i + 1) . '. ' . $array[$i]; } return $result; diff --git a/src/Path.php b/src/Path.php index ba78789..1116448 100644 --- a/src/Path.php +++ b/src/Path.php @@ -160,8 +160,9 @@ class Path // Сравнение двух путей на равентство public function equal(/*.Path.*/ $path) { - if (count($this->path) == count($path->path)) { - for ($i = 0; $i < count($this->path); $i++) { + $count = count($this->path); + if ($count == count($path->path)) { + for ($i = 0; $i < $count; $i++) { if ($this->path[$i] != $path->path[$i]) { return false; } @@ -207,8 +208,9 @@ class Path if (isset($this->url['host']) && isset($path->url['host']) && ($this->url['host'] != $path->url['host'])) return false; - if (count($path->path) > count($this->path)) { - for ($i = 0; $i < count($this->path); $i++) { + $count = count($this->path); + if (count($path->path) > $count) { + for ($i = 0; $i < $count; $i++) { if ($path->path[$i] != $this->path[$i]) { return false; } @@ -252,15 +254,18 @@ class Path $list_path = $list->getParts(); $result = array(); - for ($i = 0; $i < count($list_path); $i++) { + $count = count($list_path); + for ($i = 0; $i < $count; $i++) { if (($i >= count($self_path)) || $list_path[$i] != $self_path[$i]) { break; } } - for($j = $i; $j < count($list_path); $j++) { + $list_count = count($list_path); + for($j = $i; $j < $list_count; $j++) { array_push($result, '..'); } - for($j = $i; $j < count($self_path); $j++) { + $self_count = count($self_path); + for($j = $i; $j < $self_count; $j++) { array_push($result, $self_path[$j]); } return implode("/", $result); diff --git a/src/Primitive.php b/src/Primitive.php index aec45fd..e911916 100644 --- a/src/Primitive.php +++ b/src/Primitive.php @@ -48,9 +48,9 @@ class Primitive { if (!empty($tmp)) { if (count($tmp) != 3) return $result; - $year = intval($tmp[2]); - $month = intval($tmp[1]); - $day = intval($tmp[0]); + $year = (int)$tmp[2]; + $month = (int)$tmp[1]; + $day = (int)$tmp[0]; if ($month != 0 && $day != 0 && $year != 0) { if (checkdate($month, $day, $year)) { diff --git a/src/Tools/Drawing.php b/src/Tools/Drawing.php index e13a323..e3dc6b0 100644 --- a/src/Tools/Drawing.php +++ b/src/Tools/Drawing.php @@ -40,7 +40,8 @@ class Tools_Drawing $first_word = true; $last_width = 0; - for ($i = 0; $i < count($words); $i++) { + $count = count($words); + for ($i = 0; $i < $count; $i++) { $item = $words[$i]; $dimensions = imagettfbbox($size, $angle, $font, $current_line . ($first_word ? '' : ' ') . $item); $line_width = $dimensions[2] - $dimensions[0]; diff --git a/src/Tools/SQLStatementExtractor.php b/src/Tools/SQLStatementExtractor.php index 739f6c7..61a54a3 100644 --- a/src/Tools/SQLStatementExtractor.php +++ b/src/Tools/SQLStatementExtractor.php @@ -111,7 +111,7 @@ class Tools_SQLStatementExtractor { if ($check === "" || $check === $string) { return true; } else { - return (strpos($string, $check) === 0) ? true : false; + return (strpos($string, $check) === 0); } } @@ -125,7 +125,7 @@ class Tools_SQLStatementExtractor { if ($check === "" || $check === $string) { return true; } else { - return (strpos(strrev($string), strrev($check)) === 0) ? true : false; + return (strpos(strrev($string), strrev($check)) === 0); } } diff --git a/src/Tools/String.php b/src/Tools/String.php index bd6c2de..ab3bab5 100644 --- a/src/Tools/String.php +++ b/src/Tools/String.php @@ -15,7 +15,7 @@ class Tools_String { if ($in_subarr > 0) { // already in sub-array? $subarr[$in_subarr][] = $tok; if ('}' === substr($tok, -1, 1)) { // check to see if we just added last component - $res[] = strToArray(implode(',', $subarr[$in_subarr])); + $res[] = self::strToArray(implode(',', $subarr[$in_subarr])); $in_subarr--; } } elseif ($tok{0} === '{') { // we're inside a new sub-array @@ -25,7 +25,7 @@ class Tools_String { $subarr[$in_subarr] = array(); $subarr[$in_subarr][] = $tok; } else { - $res[] = strToArray($tok); + $res[] = self::strToArray($tok); } } else { // not sub-array $val = trim($tok, '"'); // remove " (surrounding strings) diff --git a/src/Tools/TemplateImage.php b/src/Tools/TemplateImage.php index 6ce9a33..f6509ca 100644 --- a/src/Tools/TemplateImage.php +++ b/src/Tools/TemplateImage.php @@ -33,13 +33,16 @@ class Tools_TemplateImage protected $data = array(); protected $base = "c:\\windows\\fonts\\"; protected $image; - protected $prepare = true; + protected $_prepare = true; public $debug = false; - function __construct ($template = false) + public $resource; + public $filename; + + function __construct ($template = null) { // assert(is_string($src)); - if($template) { + if ($template) { $this->data = $template; } } @@ -116,7 +119,7 @@ class Tools_TemplateImage return ""; } - function imageText($text, $value) + function imageText($text, /*.stdClass.*/$value) { assert(is_string($text)); @@ -134,7 +137,7 @@ class Tools_TemplateImage } if ($value->valign[0]) { - $valign = Drawing::ALIGN_TOP; + $valign = Tools_Drawing::ALIGN_TOP; } elseif ($value->valign[1]) { $valign = Tools_Drawing::ALIGN_CENTER; } else { @@ -159,7 +162,7 @@ class Tools_TemplateImage { $width = imagesx($this->image); $height = imagesy($this->image); - if($new_height == false) { + if ($new_height == null) { $new_height = ceil($height * $new_width / $width); } @@ -171,8 +174,8 @@ class Tools_TemplateImage } function prepare() { - if($this->prepare) { - $this->prepare = false; + if($this->_prepare) { + $this->_prepare = false; foreach ($this->data as $value) { $this->imageText($value->text, $value); // break; } diff --git a/src/Validator/Rule/Code.php b/src/Validator/Rule/Code.php index 2bcfbf8..1928685 100644 --- a/src/Validator/Rule/Code.php +++ b/src/Validator/Rule/Code.php @@ -25,7 +25,8 @@ class Validator_Rule_Code extends Validator_Rule_Abstract $name = $this->field; if (is_array($_POST[$name . '_code_genre'])) { - for($n = 0; $n < count($_POST[$name . '_code_genre']); $n++) { + $count = count($_POST[$name . '_code_genre']); + for($n = 0; $n < $count; $n++) { $code = array( $_POST[$name . '_code_genre'][$n], $_POST[$name . '_code_f'][$n], diff --git a/src/Validator/Rule/Count.php b/src/Validator/Rule/Count.php index 2afd612..47686b8 100644 --- a/src/Validator/Rule/Count.php +++ b/src/Validator/Rule/Count.php @@ -6,7 +6,7 @@ class Validator_Rule_Count extends Validator_Rule_Abstract { public $size = 1; - public $max = false; + public $max = null; public function getErrorMsg() { diff --git a/src/Validator/Rule/Date.php b/src/Validator/Rule/Date.php index be8e17e..166907a 100644 --- a/src/Validator/Rule/Date.php +++ b/src/Validator/Rule/Date.php @@ -15,6 +15,7 @@ class Validator_Rule_Date extends Validator_Rule_Abstract public function isValid(Collection $container, $status = null) { $pattern = "/^([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{4})$/"; + $matches = []; return (preg_match($pattern, $container->get($this->field), $matches) && checkdate($matches[2], $matches[1], $matches[3])); } diff --git a/src/Validator/Rule/Time.php b/src/Validator/Rule/Time.php index 05a7a46..a64655c 100644 --- a/src/Validator/Rule/Time.php +++ b/src/Validator/Rule/Time.php @@ -23,7 +23,7 @@ class Validator_Rule_Time extends Validator_Rule_Abstract { $tmp = explode($this->split, $container->get($this->field), 2); if ($tmp) { - if (self::checktime ($tmp[0], $tmp[1])) { + if (self::checktime ((int)$tmp[0], (int)$tmp[1])) { return true; } } diff --git a/src/config.php b/src/config.php index 3bbc19a..86c7dfb 100644 --- a/src/config.php +++ b/src/config.php @@ -1,6 +1,7 @@ Date: Tue, 27 Mar 2018 17:31:49 +0300 Subject: [PATCH 2/4] =?UTF-8?q?=D0=9C=D0=BE=D0=B4=D1=83=D0=BB=D0=B8=20c=20?= =?UTF-8?q?namespace?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Adapter.php | 2 + src/Arr.php | 2 + src/Collection.php | 2 + src/Controller/Front.php | 4 +- src/Controller/Service.php | 2 +- src/Database.php | 2 +- src/Database/PDOStatement.php | 7 +++- src/Functions.php | 4 +- src/Layout/Manager.php | 4 +- src/Tales.php | 72 +++++++++++++++++++++++++++++++++++ src/tales.php | 71 ---------------------------------- 11 files changed, 92 insertions(+), 80 deletions(-) create mode 100644 src/Tales.php delete mode 100644 src/tales.php diff --git a/src/Adapter.php b/src/Adapter.php index 42bd4ab..5af0d7b 100644 --- a/src/Adapter.php +++ b/src/Adapter.php @@ -1,5 +1,7 @@ shortcut, $name, $name); // ModuleLoader (2) } - $module = $this->loadClass($moduleFile, null, 'Module_'); + $ucname = ucfirst($name); + $moduleClass = "Module\\$ucname\\$ucname"; + $module = new $moduleClass();//$this->loadClass($moduleFile, null, 'Module\\'); if ($module) { // Инициализация модуля $module->viewPath = Shortcut::getUrl('modulepath', $name); diff --git a/src/Controller/Service.php b/src/Controller/Service.php index 64b8a59..43f0802 100644 --- a/src/Controller/Service.php +++ b/src/Controller/Service.php @@ -46,7 +46,7 @@ class Controller_Service return $model; } - public function options($key, $val, $res) { + public function options($key, $val, /*.Database_PDOStatement.*/$res) { $result = array(); while($res->next()) { $result[] = array('value' => $res->getInt($key), 'name' => $res->getString($val)); diff --git a/src/Database.php b/src/Database.php index 415619d..2d5e8ad 100644 --- a/src/Database.php +++ b/src/Database.php @@ -1,6 +1,6 @@ -require_once "Database/PDOStatement.php"; +namespace ctiso; /** * Класс оболочка для PDO для замены Creole diff --git a/src/Database/PDOStatement.php b/src/Database/PDOStatement.php index e74a244..b780ae3 100644 --- a/src/Database/PDOStatement.php +++ b/src/Database/PDOStatement.php @@ -1,13 +1,16 @@ addCondition(Functions::rcurry(array($this, 'checkXHR'), $get), $layout); } - public function checkGet($request, $get) + public function checkGet(/*.HttpRequest.*/$request, $get) { if (is_array($get)) { foreach ($get as $key => $value) { @@ -42,7 +42,7 @@ class Layout_Manager extends Filter_Filter return true; } - public function checkXHR($request, $get) + public function checkXHR(/*.HttpRequest.*/$request, $get) { return $request->isAjax() && $this->checkGet($request, $get); } diff --git a/src/Tales.php b/src/Tales.php new file mode 100644 index 0000000..fb919b6 --- /dev/null +++ b/src/Tales.php @@ -0,0 +1,72 @@ +execute($req); + + echo ""; + return $result; + } + + + static function register() { + /* Регистрация нового префикса для подключения компонента */ + $tales = PHPTAL_TalesRegistry::getInstance(); + $tales->registerPrefix('component', array('Component_Tales', 'component')); + $tales->registerPrefix('date', array('DateTime_Tales', 'date')); + $tales->registerPrefix('time', array('DateTime_Tales', 'time')); + } +} diff --git a/src/tales.php b/src/tales.php deleted file mode 100644 index 2c9bc91..0000000 --- a/src/tales.php +++ /dev/null @@ -1,71 +0,0 @@ -execute($req); - - echo ""; - return $result; -} - - -/* Регистрация нового префикса для подключения компонента */ -$tales = PHPTAL_TalesRegistry::getInstance(); -$tales->registerPrefix('component', array('Component_Tales', 'component')); -$tales->registerPrefix('date', array('DateTime_Tales', 'date')); -$tales->registerPrefix('time', array('DateTime_Tales', 'time')); - From 32ec09a66ae5c3c84cb216347712f39ae46e1ca2 Mon Sep 17 00:00:00 2001 From: "CORP\\phedor" Date: Tue, 27 Mar 2018 17:40:33 +0300 Subject: [PATCH 3/4] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB?= =?UTF-8?q?=20namespace=20=D0=B8=20=D0=B7=D0=B0=D0=B2=D0=B8=D1=81=D0=B8?= =?UTF-8?q?=D0=BC=D0=BE=D1=81=D1=82=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Adapter.php | 1 + src/Arr.php | 1 + src/Collection.php | 3 ++- src/Connection/HttpRequest.php | 5 ++++- src/Connection/HttpResponse.php | 4 +++- src/Controller/Action.php | 19 +++++++++++++++---- src/Controller/Component.php | 23 ++++++++++++++++++----- src/Controller/Front.php | 10 +++++++++- src/Controller/Installer.php | 13 +++++++++---- src/Controller/Request.php | 4 +++- src/Controller/Service.php | 5 ++++- src/Controller/State.php | 11 +++++++---- src/Database.php | 8 ++++++-- src/Database/IdGenerator.php | 5 ++++- src/Database/JsonInstall.php | 7 +++++-- src/Database/Manager.php | 10 ++++++++-- src/Database/PDOStatement.php | 4 ++++ src/Database/Statement.php | 5 ++++- src/Database/StatementIterator.php | 5 ++++- src/Excel/DataTime.php | 4 +++- src/Excel/Document.php | 6 +++++- src/Excel/Number.php | 4 +++- src/Excel/Table.php | 4 +++- src/File.php | 3 +++ src/Filter/ActionAccess.php | 8 ++++++-- src/Filter/ActionLogger.php | 9 +++++++-- src/Filter/Authorization.php | 4 +++- src/Filter/Filter.php | 5 ++++- src/Filter/Login.php | 20 ++++++++++++++------ src/Filter/UserAccess.php | 8 ++++++-- src/Form/Color.php | 5 ++++- src/Form/Date.php | 5 ++++- src/Form/Field.php | 4 +++- src/Form/Form.php | 26 +++++++++++++++++--------- src/Form/Input.php | 5 ++++- src/Form/OptionFactory.php | 17 +++++++++++------ src/Form/Select.php | 5 ++++- src/Form/SelectMany.php | 5 ++++- src/Form/SelectOne.php | 5 ++++- src/Form/TextArea.php | 5 ++++- src/Form/ViewState.php | 4 +++- src/Functions.php | 18 ++++++++++-------- src/HttpRequest.php | 5 +++++ src/Layout/Empty.php | 6 +++++- src/Layout/Manager.php | 13 +++++++++---- src/Mail.php | 4 ++++ src/MailAlt.php | 3 +++ src/Model/Factory.php | 5 ++++- src/Numbers.php | 2 ++ src/Path.php | 2 ++ src/Primitive.php | 2 ++ src/Registry.php | 3 +++ src/Security.php | 2 ++ src/Session.php | 2 ++ src/Settings.php | 5 +++++ src/Setup.php | 8 ++++++-- src/Shortcut.php | 2 ++ src/SortRecord.php | 2 ++ src/Tales.php | 11 +++++++++-- src/Tools/Drawing.php | 4 +++- src/Tools/Image.php | 4 +++- src/Tools/SQLStatementExtractor.php | 5 ++++- src/Tools/String.php | 4 +++- src/Tools/TemplateImage.php | 19 +++++++++++-------- src/UTF8.php | 2 ++ src/UserMessageException.php | 3 +++ src/Validator/Rule/Abstract.php | 5 ++++- src/Validator/Rule/Alpha.php | 6 +++++- src/Validator/Rule/Code.php | 6 +++++- src/Validator/Rule/Count.php | 6 +++++- src/Validator/Rule/Date.php | 6 +++++- src/Validator/Rule/Email.php | 6 +++++- src/Validator/Rule/EmailList.php | 6 +++++- src/Validator/Rule/FileName.php | 7 ++++++- src/Validator/Rule/IsFile.php | 6 +++++- src/Validator/Rule/Match.php | 6 +++++- src/Validator/Rule/Notnull.php | 6 +++++- src/Validator/Rule/Numeric.php | 6 +++++- src/Validator/Rule/Time.php | 6 +++++- src/Validator/Rule/Unique.php | 6 +++++- src/Validator/Validator.php | 6 +++++- src/View/Composite.php | 6 +++++- src/View/List.php | 5 ++++- src/View/Page.php | 12 +++++++++--- src/View/Pages.php | 4 +++- src/View/Plain.php | 4 +++- src/View/Top.php | 5 ++++- src/View/View.php | 5 ++++- src/ZipFile.php | 3 +++ src/config.php | 3 +++ src/process.php | 2 ++ src/tabletree.php | 3 +++ 92 files changed, 454 insertions(+), 128 deletions(-) diff --git a/src/Adapter.php b/src/Adapter.php index 5af0d7b..2ba68f9 100644 --- a/src/Adapter.php +++ b/src/Adapter.php @@ -1,5 +1,6 @@ viewPath, 'help', $name . '.suggest'); @@ -141,7 +152,7 @@ class Controller_Action public function getModel($name) { if (!$this->factory) { - $this->factory = new Model_Factory($this->db, $this->_registry); + $this->factory = new Factory($this->db, $this->_registry); } return $this->factory->getModel($name); } @@ -364,7 +375,7 @@ class Controller_Action function _getActionPath() { - return new Controller_State('index'); + return new State('index'); } // Тоже убрать в метод Controller_Model diff --git a/src/Controller/Component.php b/src/Controller/Component.php index dce2076..830cd59 100644 --- a/src/Controller/Component.php +++ b/src/Controller/Component.php @@ -1,5 +1,18 @@ db, $this->registry); + $form = new Form(); + $options = new OptionFactory($this->db, $this->registry); $settings = $this->getInfo(); $form->addFieldList($settings['parameter'], $options); @@ -301,7 +314,7 @@ class Controller_Component $editor = $component->getEditUrl(); if ($editor) { if(class_exists("Controller_Site")) { //Если мы в CMS2 - $instance = Controller_Site::getInstance(); + $instance = Site::getInstance(); $instance->componentsConfig[] = $editor; } else { global $componentsConfig; @@ -356,7 +369,7 @@ class Controller_Component */ function addRequireJsPath($name, $path, $shim = null) { - Controller_Site::addRequireJsPath($name, $path, $shim); + Site::addRequireJsPath($name, $path, $shim); } function actionIndex(/*.ComponentRequest.*/ $request) { diff --git a/src/Controller/Front.php b/src/Controller/Front.php index 8c4ee74..7d805a8 100644 --- a/src/Controller/Front.php +++ b/src/Controller/Front.php @@ -4,7 +4,15 @@ * Первичный контроллер контроллер страниц * @package system.controller */ -class Controller_Front extends Controller_Action +namespace ctiso\Controller; +use ctiso\Controller\Action, + ctiso\Settings, + ctiso\Database, + ctiso\Collection, + ctiso\Shortcut, + ctiso\HttpRequest; + +class Front extends Action { /** @var Shortcut */ diff --git a/src/Controller/Installer.php b/src/Controller/Installer.php index d20a93d..a5a55fa 100644 --- a/src/Controller/Installer.php +++ b/src/Controller/Installer.php @@ -1,6 +1,11 @@ db_manager); + $json_installer = new JsonInstall($this->db_manager); foreach ($sql as $version => $install) { if (version_compare($version, $version_new, "<=") && version_compare($version, $version_old, ">")) { $file = Path::join(call_user_func($this->installPath, $name), "sql", $install); @@ -58,7 +63,7 @@ class Controller_Installer function uninstall($name){ $uninstall = $this->getUninstallFile($name); if (file_exists($uninstall)) { - $json_installer = new Database_JsonInstall($this->db_manager); + $json_installer = new JsonInstall($this->db_manager); $json_installer->install($uninstall,null); } $this->_registry->removeKey($name); @@ -108,7 +113,7 @@ class Controller_Installer } function install($dbinit_path, $dbfill_path = null) { - $json_installer = new Database_JsonInstall($this->db_manager); + $json_installer = new JsonInstall($this->db_manager); $json_installer->install($dbinit_path, $dbfill_path); } } diff --git a/src/Controller/Request.php b/src/Controller/Request.php index 1ac7be4..50a3039 100644 --- a/src/Controller/Request.php +++ b/src/Controller/Request.php @@ -1,6 +1,8 @@ states [$state->getAction()] = $state; return $this; @@ -49,7 +52,7 @@ class Controller_State return false; } - function makeTitle(Controller_Action $module) + function makeTitle(Action $module) { foreach ($this->titles as $item) { $module->path->addMenuItem($module->nUrl($this->action, $item[1]), $item[0]); diff --git a/src/Database.php b/src/Database.php index 2d5e8ad..f3d0800 100644 --- a/src/Database.php +++ b/src/Database.php @@ -1,6 +1,10 @@ + namespace ctiso; +use PDO, + ctiso\Database\Statement, + ctiso\Database\IdGenerator; /** * Класс оболочка для PDO для замены Creole @@ -64,7 +68,7 @@ class Database extends PDO public function prepareStatement($query) { - return new Database_Statement($query, $this); + return new Statement($query, $this); } // Для совместимости со старым представлением баз данных CIS @@ -161,7 +165,7 @@ class Database extends PDO } function getIdGenerator() { - return new Database_IdGenerator($this); + return new IdGenerator($this); } /** diff --git a/src/Database/IdGenerator.php b/src/Database/IdGenerator.php index 41ee235..5ae4664 100644 --- a/src/Database/IdGenerator.php +++ b/src/Database/IdGenerator.php @@ -1,6 +1,9 @@ db_manager = $db_manager; } diff --git a/src/Database/Manager.php b/src/Database/Manager.php index ec354c7..a0e46a5 100644 --- a/src/Database/Manager.php +++ b/src/Database/Manager.php @@ -1,6 +1,12 @@ db->executeQuery($stmt); } diff --git a/src/Database/PDOStatement.php b/src/Database/PDOStatement.php index b780ae3..c284683 100644 --- a/src/Database/PDOStatement.php +++ b/src/Database/PDOStatement.php @@ -1,6 +1,10 @@ access[$action]) || in_array(Filter_UserAccess::$access, $this->access[$action])); + return (!isset($this->access[$action]) || in_array(UserAccess::$access, $this->access[$action])); } function execute(HttpRequest $request) { diff --git a/src/Filter/ActionLogger.php b/src/Filter/ActionLogger.php index a71d5f5..b6da23c 100644 --- a/src/Filter/ActionLogger.php +++ b/src/Filter/ActionLogger.php @@ -1,6 +1,11 @@ getAction(); if(in_array($action, $this->before)) { - fwrite($this->file, "time: " . date("r", time()) . " query: ". json_encode(array_merge($_POST, $_GET)) . " by: " . Filter_UserAccess::$name . "\n"); + fwrite($this->file, "time: " . date("r", time()) . " query: ". json_encode(array_merge($_POST, $_GET)) . " by: " . UserAccess::$name . "\n"); } return $this->processor->execute($request); } diff --git a/src/Filter/Authorization.php b/src/Filter/Authorization.php index 5afd556..56ebc4d 100644 --- a/src/Filter/Authorization.php +++ b/src/Filter/Authorization.php @@ -1,6 +1,8 @@ getConnection(); - Filter_UserAccess::setUp($db); // Соединение + UserAccess::setUp($db); // Соединение switch ($request->getAction()) { // Авторизация по постоянному паролю case 'login': $login = $request->get('login'); $password = $request->get('password'); - $result = Filter_UserAccess::getUserByLogin($login); // Поиск по логину + $result = UserAccess::getUserByLogin($login); // Поиск по логину if ($result) { $userPassword = $result->getString('password'); - if (Filter_UserAccess::$access == 'site_root' && defined('PARENT_PATH')) { + if (UserAccess::$access == 'site_root' && defined('PARENT_PATH')) { $s = new Settings(PARENT_PATH . '/settings.json'); $s->read(); $dsn = $s->readKey(array('system', 'dsn')); @@ -63,7 +71,7 @@ class Filter_Login extends Filter_Filter case 'enter': $login = $request->get('login'); $password = $request->get('sid'); - $result = Filter_UserAccess::getUserByLogin($login); // Поиск по логину + $result = UserAccess::getUserByLogin($login); // Поиск по логину if ($result) { $temp = md5($result->getString('password') . $result->getString('login') . $result->getString('sid')); if ($password == $temp) { @@ -77,7 +85,7 @@ class Filter_Login extends Filter_Filter // Если $hash не совпадает $_SESSION['hash'] то удаляем сессию if (isset($_SESSION ['access']) && isset($_SESSION[self::SESSION_BROWSER_SIGN_KEYNAME])) { if ($hash == $_SESSION[self::SESSION_BROWSER_SIGN_KEYNAME]) { - $this->user = $user = Filter_UserAccess::getUserById($_SESSION['access']); // Поиск по идентификатору + $this->user = $user = UserAccess::getUserById($_SESSION['access']); // Поиск по идентификатору if ($user && isset($_SESSION['random']) && ($user->get('sid') == $_SESSION['random'])) { return true; } diff --git a/src/Filter/UserAccess.php b/src/Filter/UserAccess.php index ce27a66..509b9b6 100644 --- a/src/Filter/UserAccess.php +++ b/src/Filter/UserAccess.php @@ -1,7 +1,11 @@ executeQuery(); diff --git a/src/Form/Color.php b/src/Form/Color.php index c7c0d2d..17a9caf 100644 --- a/src/Form/Color.php +++ b/src/Form/Color.php @@ -3,6 +3,9 @@ /** * Поле с цветом */ -class Form_Color extends Form_Field +namespace ctiso\Form; +use ctiso\Form\Field; + +class Color extends Field { } \ No newline at end of file diff --git a/src/Form/Date.php b/src/Form/Date.php index 42f8b00..3b1c526 100644 --- a/src/Form/Date.php +++ b/src/Form/Date.php @@ -2,5 +2,8 @@ /** * Поле с датой */ -class Form_Date extends Form_Field { +namespace ctiso\Form; +use ctiso\Form\Field; + +class Date extends Field { } \ No newline at end of file diff --git a/src/Form/Field.php b/src/Form/Field.php index bb756cb..1e1dd47 100644 --- a/src/Form/Field.php +++ b/src/Form/Field.php @@ -2,7 +2,9 @@ /** * Элемент формы */ -class Form_Field +namespace ctiso\Form; + +class Field { public $hidden = false; public $name; diff --git a/src/Form/Form.php b/src/Form/Form.php index 47a1854..02e6e7e 100644 --- a/src/Form/Form.php +++ b/src/Form/Form.php @@ -4,7 +4,15 @@ * При рендеринге каждому классу соответствует шаблон (см. themes/maxim/templates/macros.html) */ -class TCheckbox extends Form_Field +namespace ctiso\Form; +use ctiso\Form\Field, + ctiso\Form\Select, + ctiso\Form\Input, + ctiso\View\View, + ctiso\Validator\Validator, + ctiso\HttpRequest; + +class TCheckbox extends Field { public $checked = false; function setValue($value) @@ -14,7 +22,7 @@ class TCheckbox extends Form_Field } } -class TQuestionType extends Form_Select +class TQuestionType extends Select { function setValue($value) { @@ -26,29 +34,29 @@ class TQuestionType extends Form_Select } } -class TDateTime extends Form_Input { +class TDateTime extends Input { } /** * Поле для ввода пароля */ -class TSecret extends Form_Field { +class TSecret extends Field { } -class TUpload extends Form_Field { +class TUpload extends Field { } -class THidden extends Form_Input { +class THidden extends Input { public $hidden = true; } -class TComponentBrowserInput extends Form_Input { +class TComponentBrowserInput extends Input { } /** * Форма для ввода */ -class Form_Form extends View_View { +class Form extends View { public $field = array(); //Поля формы public $fieldsets = array(); //Группы полей (fieldset). Некоторые поля могут не принадлежать никаким группам @@ -163,7 +171,7 @@ class Form_Form extends View_View { /** * Устанавливает ошибки после проверки */ - function setError(Validator_Validator $validator) + function setError(Validator $validator) { foreach ($validator->getErrorMsg() as $name => $error) { diff --git a/src/Form/Input.php b/src/Form/Input.php index 855bec2..b2d4e68 100644 --- a/src/Form/Input.php +++ b/src/Form/Input.php @@ -3,5 +3,8 @@ /** * Поле ввода Input */ -class Form_Input extends Form_Field { +namespace ctiso\Form; +use ctiso\Form\Field; + +class Input extends Field { } \ No newline at end of file diff --git a/src/Form/OptionFactory.php b/src/Form/OptionFactory.php index 41a8447..70904bb 100644 --- a/src/Form/OptionFactory.php +++ b/src/Form/OptionFactory.php @@ -1,6 +1,11 @@ registry = $registry; } - function create(Form_Select $field, $input) { + function create(Select $field, $input) { if (isset($input['options.resid'])) { $type = $input['options.resid']; - $res = new Model_Resources($this->db); + $res = new 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); + $res = new 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); + $res = new Resources($this->db); $field->options = $this->optionsArray('id_resource', 'subtitle', $res->getAllResource($type)); } else if (isset($input['options.db'])) { @@ -39,7 +44,7 @@ class Form_OptionFactory { } 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); + $factory = new Factory($this->db, $this->registry); $model = $factory->getModel($input['options.model']); $field->options = $model->getAllAsOptions(); } else { diff --git a/src/Form/Select.php b/src/Form/Select.php index 6a3f7a1..3a4ec2c 100644 --- a/src/Form/Select.php +++ b/src/Form/Select.php @@ -1,6 +1,9 @@ value = $value; diff --git a/src/Form/ViewState.php b/src/Form/ViewState.php index 777618b..c9c6831 100644 --- a/src/Form/ViewState.php +++ b/src/Form/ViewState.php @@ -4,7 +4,9 @@ * http://www.alternateinterior.com/2006/09/a-viewstate-for-php.html * Управление состоянием между страницами */ -class Form_ViewState // extends Collection +namespace ctiso\Form; + +class ViewState // extends Collection { private $values = array(); diff --git a/src/Functions.php b/src/Functions.php index 63c131e..fc1d5a8 100644 --- a/src/Functions.php +++ b/src/Functions.php @@ -8,7 +8,9 @@ /** * Эмуляция каррированой функции */ -class __right { +namespace ctiso; + +class right { protected $params; protected $fn; @@ -24,7 +26,7 @@ class __right { } } -class __left { +class left { protected $params; protected $fn; @@ -41,7 +43,7 @@ class __left { } define('__', '_ARGUMENT_PLACE_'); -class __partial { +class partial { protected $params; protected $fn; @@ -69,7 +71,7 @@ class __partial { /** * Композиция функций */ -class __compose { +class compose { protected $fns; function __construct($list) { $this->fns = array_reverse($list); @@ -89,7 +91,7 @@ class __compose { class Functions { static function partial($_rest) { - $closure = new __partial(func_get_args()); + $closure = new partial(func_get_args()); return array($closure, 'apply'); } @@ -102,7 +104,7 @@ class Functions { * @return array[int]mixed */ static function compose($_rest) { - $closure = new __compose(func_get_args()); + $closure = new compose(func_get_args()); return array($closure, 'apply'); } @@ -112,7 +114,7 @@ class Functions { * @return array[int]mixed */ static function rcurry($_rest) { - $closure = new __right(func_get_args ()); + $closure = new right(func_get_args ()); return array($closure, 'apply'); } @@ -122,7 +124,7 @@ class Functions { * @return array[int]mixed */ static function lcurry($_rest) { - $closure = new __left(func_get_args ()); + $closure = new left(func_get_args ()); return array($closure, 'apply'); } diff --git a/src/HttpRequest.php b/src/HttpRequest.php index 7693177..21efe01 100644 --- a/src/HttpRequest.php +++ b/src/HttpRequest.php @@ -3,6 +3,11 @@ /** * Неверный запрос */ +namespace ctiso; +use Exception, + ctiso\Collection, + ctiso\Session; + class WrongRequestException extends Exception { } diff --git a/src/Layout/Empty.php b/src/Layout/Empty.php index a7f99b8..202f0d2 100644 --- a/src/Layout/Empty.php +++ b/src/Layout/Empty.php @@ -3,7 +3,11 @@ /** * Самый простой макет */ -class Layout_Empty extends Filter_Filter +namespace ctiso\Layout; +use ctiso\Filter\Filter, + ctiso\HttpRequest; + +class Empty extends Filter { function execute(HttpRequest $request) { diff --git a/src/Layout/Manager.php b/src/Layout/Manager.php index 33b934a..63ccb0a 100644 --- a/src/Layout/Manager.php +++ b/src/Layout/Manager.php @@ -4,7 +4,12 @@ * Выбор макета страницы. * Выбор оформления страницы осуществляется если было совпадение с каким либо условием */ -class Layout_Manager extends Filter_Filter +namespace ctiso\Layout; +use ctiso\Filter\Filter, + ctiso\Functions, + ctiso\HttpRequest; + +class Manager extends Filter { // Массив условий с их макетами protected $condition = array(); @@ -17,7 +22,7 @@ class Layout_Manager extends Filter_Filter * addConditionGet(array('module' => 'personal'), 'personal') * addConditionGet(array('module' => 'login'), 'login') */ - public function addConditionGet($get, Filter_Filter $layout) + public function addConditionGet($get, Filter $layout) { $this->addCondition(Functions::rcurry(array($this, 'checkGet'), $get), $layout); } @@ -25,7 +30,7 @@ class Layout_Manager extends Filter_Filter /** * Условие для аякс запросов. Тоже самое что и addConditionGet но еще проверяется является ли запрос ajax */ - public function addConditionXHR($get, Filter_Filter $layout) + public function addConditionXHR($get, Filter $layout) { $this->addCondition(Functions::rcurry(array($this, 'checkXHR'), $get), $layout); } @@ -52,7 +57,7 @@ class Layout_Manager extends Filter_Filter * @parma $get function(HttpRequest) Функция * @parma $layout Layout Макет */ - public function addCondition($get, Filter_Filter $layout) + public function addCondition($get, Filter $layout) { $this->condition [] = array($get, $layout); } diff --git a/src/Mail.php b/src/Mail.php index 1f4eda4..20cdb7c 100644 --- a/src/Mail.php +++ b/src/Mail.php @@ -4,6 +4,10 @@ * Класс для работы с почтой * http://en.wikipedia.org/wiki/MIME */ +namespace ctiso; +use ctiso\Path, + Exception; + class Mail { public $_from; diff --git a/src/MailAlt.php b/src/MailAlt.php index 99b296d..138ae94 100644 --- a/src/MailAlt.php +++ b/src/MailAlt.php @@ -1,5 +1,8 @@ executeActions('install'); * */ +namespace ctiso; +use ZipArchive, + ctiso\Tools\SQLStatementExtractor; + class Setup { protected $actions = array(); @@ -198,7 +202,7 @@ class Setup */ function batchSQLZip(/*.Database.*/ $conn, $file) { - $stmtList = Tools_SQLStatementExtractor::extract($this->zip->getFromName($file)); + $stmtList = SQLStatementExtractor::extract($this->zip->getFromName($file)); foreach ($stmtList as $stmt) { $conn->executeQuery ($stmt); } @@ -206,7 +210,7 @@ class Setup static function batchSQL(/*.Database.*/ $conn, $file) { - $stmtList = Tools_SQLStatementExtractor::extractFile($file); + $stmtList = SQLStatementExtractor::extractFile($file); foreach ($stmtList as $stmt) { $conn->executeQuery ($stmt); } diff --git a/src/Shortcut.php b/src/Shortcut.php index 4e24046..09da63f 100644 --- a/src/Shortcut.php +++ b/src/Shortcut.php @@ -3,6 +3,8 @@ /** * Класс для короткого доступа к файлам / папкам */ +namespace ctiso; + class Shortcut { static $instance = null; diff --git a/src/SortRecord.php b/src/SortRecord.php index 24c054b..030bb52 100644 --- a/src/SortRecord.php +++ b/src/SortRecord.php @@ -1,5 +1,7 @@ 'jpeg', 'gif' => 'gif', 'png' => 'png', 'bmp' => 'wbmp'); static $listfonts = array( @@ -129,22 +132,22 @@ class Tools_TemplateImage $color = intval(substr($value->color, 1), 16); if ($value->align[0]) { - $align = Tools_Drawing::ALIGN_LEFT; + $align = Drawing::ALIGN_LEFT; } elseif ($value->align[2]) { - $align = Tools_Drawing::ALIGN_RIGHT; + $align = Drawing::ALIGN_RIGHT; } else { - $align = Tools_Drawing::ALIGN_CENTER; + $align = Drawing::ALIGN_CENTER; } if ($value->valign[0]) { - $valign = Tools_Drawing::ALIGN_TOP; + $valign = Drawing::ALIGN_TOP; } elseif ($value->valign[1]) { - $valign = Tools_Drawing::ALIGN_CENTER; + $valign = Drawing::ALIGN_CENTER; } else { - $valign = Tools_Drawing::ALIGN_BOTTOM; + $valign = Drawing::ALIGN_BOTTOM; } - Tools_Drawing::imagettftextbox($this->image, $size, 0, $value->left, $value->top, $color, $fontfile, $text, + Drawing::imagettftextbox($this->image, $size, 0, $value->left, $value->top, $color, $fontfile, $text, $value->width, $value->height, $align, $valign); } diff --git a/src/UTF8.php b/src/UTF8.php index 3cc68b8..fe97742 100644 --- a/src/UTF8.php +++ b/src/UTF8.php @@ -1,5 +1,7 @@ Date: Tue, 27 Mar 2018 18:10:46 +0300 Subject: [PATCH 4/4] =?UTF-8?q?=D0=9D=D0=B0=D1=81=D1=82=D1=80=D0=BE=D0=B9?= =?UTF-8?q?=D0=BA=D0=B0=20=D0=B4=D0=BB=D1=8F=20composer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composer.json | 4 ++-- src/Controller/Front.php | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index de9a023..4c325c2 100644 --- a/composer.json +++ b/composer.json @@ -8,8 +8,8 @@ } ], "autoload": { - "psr-0": { - "": "src/" + "psr-4": { + "ctiso\\": "src/" } } } diff --git a/src/Controller/Front.php b/src/Controller/Front.php index 7d805a8..9b5e718 100644 --- a/src/Controller/Front.php +++ b/src/Controller/Front.php @@ -111,11 +111,12 @@ class Front extends Action } else { $controller = null; } + try{ 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;