@@ -30,7 +30,9 @@ discard block |
||
30 | 30 | |
31 | 31 | public function set(string $name, $value) : Response { |
32 | 32 | |
33 | - if (!in_array($name, ['error', 'status'], true)) $this->data[$name] = $value; |
|
33 | + if (!in_array($name, ['error', 'status'], true)) { |
|
34 | + $this->data[$name] = $value; |
|
35 | + } |
|
34 | 36 | |
35 | 37 | return $this; |
36 | 38 | } |
@@ -43,7 +45,9 @@ discard block |
||
43 | 45 | |
44 | 46 | public function setArray(array $data) : Response { |
45 | 47 | |
46 | - foreach ($data as $name => $value) $this->set($name, $value); |
|
48 | + foreach ($data as $name => $value) { |
|
49 | + $this->set($name, $value); |
|
50 | + } |
|
47 | 51 | |
48 | 52 | return $this; |
49 | 53 | } |
@@ -104,7 +108,9 @@ discard block |
||
104 | 108 | |
105 | 109 | $data = ['status' => $this->status]; |
106 | 110 | |
107 | - if (null !== $this->error) $data['error'] = $this->error; |
|
111 | + if (null !== $this->error) { |
|
112 | + $data['error'] = $this->error; |
|
113 | + } |
|
108 | 114 | |
109 | 115 | # ------------------------ |
110 | 116 |
@@ -23,7 +23,9 @@ discard block |
||
23 | 23 | |
24 | 24 | private function registerWidget(string $name) { |
25 | 25 | |
26 | - if (false === Template::getWidget($name)) Template::setWidget($name, new Block); |
|
26 | + if (false === Template::getWidget($name)) { |
|
27 | + Template::setWidget($name, new Block); |
|
28 | + } |
|
27 | 29 | } |
28 | 30 | |
29 | 31 | /** |
@@ -40,15 +42,19 @@ discard block |
||
40 | 42 | |
41 | 43 | $type = $matches[2][$key]; $name = $matches[3][$key]; $contents = ($matches[4][$key] ?? ''); |
42 | 44 | |
43 | - if (!preg_match(REGEX_TEMPLATE_COMPONENT_NAME, $name)) continue; |
|
45 | + if (!preg_match(REGEX_TEMPLATE_COMPONENT_NAME, $name)) { |
|
46 | + continue; |
|
47 | + } |
|
44 | 48 | |
45 | 49 | $this->contents = str_replace($match, ('{ ' . $type . ':' . $name . ' / }'), $this->contents); |
46 | 50 | |
47 | - if ($type === 'block') $this->blocks[$name] = (new Block($contents))->$toggle(); |
|
48 | - |
|
49 | - else if ($type === 'for') $this->loops[$name] = new Loop($contents); |
|
50 | - |
|
51 | - else if ($type === 'widget') $this->registerWidget($this->widgets[] = $name); |
|
51 | + if ($type === 'block') { |
|
52 | + $this->blocks[$name] = (new Block($contents))->$toggle(); |
|
53 | + } else if ($type === 'for') { |
|
54 | + $this->loops[$name] = new Loop($contents); |
|
55 | + } else if ($type === 'widget') { |
|
56 | + $this->registerWidget($this->widgets[] = $name); |
|
57 | + } |
|
52 | 58 | } |
53 | 59 | } |
54 | 60 | |
@@ -68,7 +74,9 @@ discard block |
||
68 | 74 | |
69 | 75 | foreach ($matches[1] as $index => $name) { |
70 | 76 | |
71 | - if (!preg_match(REGEX_TEMPLATE_COMPONENT_NAME, $name)) continue; |
|
77 | + if (!preg_match(REGEX_TEMPLATE_COMPONENT_NAME, $name)) { |
|
78 | + continue; |
|
79 | + } |
|
72 | 80 | |
73 | 81 | $elementaries['stack'][$name] = false; |
74 | 82 | } |
@@ -152,11 +160,17 @@ discard block |
||
152 | 160 | |
153 | 161 | public function __clone() { |
154 | 162 | |
155 | - foreach ($this->blocks as $name => $block) $this->blocks[$name] = clone $block; |
|
163 | + foreach ($this->blocks as $name => $block) { |
|
164 | + $this->blocks[$name] = clone $block; |
|
165 | + } |
|
156 | 166 | |
157 | - foreach ($this->loops as $name => $loop) $this->loops[$name] = clone $loop; |
|
167 | + foreach ($this->loops as $name => $loop) { |
|
168 | + $this->loops[$name] = clone $loop; |
|
169 | + } |
|
158 | 170 | |
159 | - foreach ($this->items as $name => $item) $this->items[$name] = clone $item; |
|
171 | + foreach ($this->items as $name => $item) { |
|
172 | + $this->items[$name] = clone $item; |
|
173 | + } |
|
160 | 174 | } |
161 | 175 | |
162 | 176 | /** |
@@ -167,11 +181,13 @@ discard block |
||
167 | 181 | |
168 | 182 | public function set(string $name, $value) : Block { |
169 | 183 | |
170 | - if ($value instanceof Block) $this->setBlock($name, $value); |
|
171 | - |
|
172 | - else if (is_array($value)) $this->setLoop($name, $value); |
|
173 | - |
|
174 | - else if (is_scalar($value)) $this->setVar($name, $value); |
|
184 | + if ($value instanceof Block) { |
|
185 | + $this->setBlock($name, $value); |
|
186 | + } else if (is_array($value)) { |
|
187 | + $this->setLoop($name, $value); |
|
188 | + } else if (is_scalar($value)) { |
|
189 | + $this->setVar($name, $value); |
|
190 | + } |
|
175 | 191 | |
176 | 192 | # ------------------------ |
177 | 193 | |
@@ -186,7 +202,9 @@ discard block |
||
186 | 202 | |
187 | 203 | public function setArray(array $components) : Block { |
188 | 204 | |
189 | - foreach ($components as $name => $component) $this->set($name, $component); |
|
205 | + foreach ($components as $name => $component) { |
|
206 | + $this->set($name, $component); |
|
207 | + } |
|
190 | 208 | |
191 | 209 | return $this; |
192 | 210 | } |
@@ -199,7 +217,9 @@ discard block |
||
199 | 217 | |
200 | 218 | public function setBlock(string $name, Block $block) : Block { |
201 | 219 | |
202 | - if (isset($this->blocks[$name])) $this->blocks[$name] = $block; |
|
220 | + if (isset($this->blocks[$name])) { |
|
221 | + $this->blocks[$name] = $block; |
|
222 | + } |
|
203 | 223 | |
204 | 224 | return $this; |
205 | 225 | } |
@@ -212,7 +232,9 @@ discard block |
||
212 | 232 | |
213 | 233 | public function setLoop(string $name, array $items) : Block { |
214 | 234 | |
215 | - if (isset($this->loops[$name])) $this->loops[$name]->setItems($items); |
|
235 | + if (isset($this->loops[$name])) { |
|
236 | + $this->loops[$name]->setItems($items); |
|
237 | + } |
|
216 | 238 | |
217 | 239 | return $this; |
218 | 240 | } |
@@ -225,7 +247,9 @@ discard block |
||
225 | 247 | |
226 | 248 | public function setVar(string $name, string $value) : Block { |
227 | 249 | |
228 | - if (isset($this->variables[$name])) $this->variables[$name] = $value; |
|
250 | + if (isset($this->variables[$name])) { |
|
251 | + $this->variables[$name] = $value; |
|
252 | + } |
|
229 | 253 | |
230 | 254 | return $this; |
231 | 255 | } |
@@ -307,7 +331,9 @@ discard block |
||
307 | 331 | |
308 | 332 | public function getContents() : string { |
309 | 333 | |
310 | - if (!$this->enabled) return ''; |
|
334 | + if (!$this->enabled) { |
|
335 | + return ''; |
|
336 | + } |
|
311 | 337 | |
312 | 338 | # Lock the block |
313 | 339 |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | |
29 | 29 | protected function getValue(string $value) : string { |
30 | 30 | |
31 | - return ('\'' . addslashes($value) . '\''); |
|
31 | + return ('\''.addslashes($value).'\''); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | |
42 | 42 | $parser = function($value) { if (is_scalar($value)) return $this->getValue($value); }; |
43 | 43 | |
44 | - return ('(' . implode(', ', array_filter(array_map($parser, $value))) . ')'); |
|
44 | + return ('('.implode(', ', array_filter(array_map($parser, $value))).')'); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | /** |
@@ -37,9 +37,14 @@ discard block |
||
37 | 37 | |
38 | 38 | protected function getList($value) : string { |
39 | 39 | |
40 | - if (!is_array($value)) $value = [$value]; |
|
40 | + if (!is_array($value)) { |
|
41 | + $value = [$value]; |
|
42 | + } |
|
41 | 43 | |
42 | - $parser = function($value) { if (is_scalar($value)) return $this->getValue($value); }; |
|
44 | + $parser = function($value) { if (is_scalar($value)) { |
|
45 | + return $this->getValue($value); |
|
46 | + } |
|
47 | + }; |
|
43 | 48 | |
44 | 49 | return ('(' . implode(', ', array_filter(array_map($parser, $value))) . ')'); |
45 | 50 | } |
@@ -59,7 +64,9 @@ discard block |
||
59 | 64 | |
60 | 65 | protected function getString($source = null, string $pattern = '', string $separator = '') : string { |
61 | 66 | |
62 | - if (!is_array($source)) return (is_scalar($source) ? strval($source) : ''); |
|
67 | + if (!is_array($source)) { |
|
68 | + return (is_scalar($source) ? strval($source) : ''); |
|
69 | + } |
|
63 | 70 | |
64 | 71 | $regexs = ['key' => '/\^([a-z]+)/', 'value' => '/\$([a-z]+)/']; $matches = ['key' => [], 'value' => []]; |
65 | 72 | |
@@ -69,7 +76,9 @@ discard block |
||
69 | 76 | |
70 | 77 | # Parse pattern |
71 | 78 | |
72 | - foreach ($regexs as $name => $regex) preg_match($regex, $pattern, $matches[$name]); |
|
79 | + foreach ($regexs as $name => $regex) { |
|
80 | + preg_match($regex, $pattern, $matches[$name]); |
|
81 | + } |
|
73 | 82 | |
74 | 83 | # Process replacements |
75 | 84 | |
@@ -77,9 +86,12 @@ discard block |
||
77 | 86 | |
78 | 87 | $output[$count] = $pattern; $item = &$output[$count++]; |
79 | 88 | |
80 | - foreach ($matches as $name => $match) if (isset($match[1]) && isset($parsers[$match[1]])) { |
|
89 | + foreach ($matches as $name => $match) { |
|
90 | + if (isset($match[1]) && isset($parsers[$match[1]])) { |
|
81 | 91 | |
82 | - try { $replace = [$this, $parsers[$match[1]]]($$name); } catch (\TypeError $e) { $replace = ''; } |
|
92 | + try { $replace = [$this, $parsers[$match[1]]]($$name); |
|
93 | + } |
|
94 | + } catch (\TypeError $e) { $replace = ''; } |
|
83 | 95 | |
84 | 96 | $item = str_replace($match[0], $replace, $item); |
85 | 97 | } |
@@ -23,15 +23,15 @@ |
||
23 | 23 | |
24 | 24 | $table = $this->getName($table); |
25 | 25 | |
26 | - if ($column !== '*') $column = (($distinct ? 'DISTINCT ' : '') . $this->getName($column)); |
|
26 | + if ($column !== '*') $column = (($distinct ? 'DISTINCT ' : '').$this->getName($column)); |
|
27 | 27 | |
28 | 28 | $condition = $this->getString($condition, '^name IN $list', ' AND '); |
29 | 29 | |
30 | 30 | # Build query |
31 | 31 | |
32 | - $this->query = ('SELECT COUNT(' . $column . ') as count ' . |
|
32 | + $this->query = ('SELECT COUNT('.$column.') as count '. |
|
33 | 33 | |
34 | - 'FROM ' . $table . ($condition ? (' WHERE (' . $condition . ')') : '')); |
|
34 | + 'FROM '.$table.($condition ? (' WHERE ('.$condition.')') : '')); |
|
35 | 35 | } |
36 | 36 | } |
37 | 37 | } |
@@ -23,7 +23,9 @@ |
||
23 | 23 | |
24 | 24 | $table = $this->getName($table); |
25 | 25 | |
26 | - if ($column !== '*') $column = (($distinct ? 'DISTINCT ' : '') . $this->getName($column)); |
|
26 | + if ($column !== '*') { |
|
27 | + $column = (($distinct ? 'DISTINCT ' : '') . $this->getName($column)); |
|
28 | + } |
|
27 | 29 | |
28 | 30 | $condition = $this->getString($condition, '^name IN $list', ' AND '); |
29 | 31 |
@@ -19,32 +19,32 @@ |
||
19 | 19 | |
20 | 20 | # Check basic types |
21 | 21 | |
22 | - if (is_string ($default)) return function (string $value) { return $value; }; |
|
22 | + if (is_string($default)) return function(string $value) { return $value; }; |
|
23 | 23 | |
24 | - if (is_bool ($default)) return function (bool $value) { return $value; }; |
|
24 | + if (is_bool($default)) return function(bool $value) { return $value; }; |
|
25 | 25 | |
26 | - if (is_int ($default)) return function (int $value) { return $value; }; |
|
26 | + if (is_int($default)) return function(int $value) { return $value; }; |
|
27 | 27 | |
28 | - if (is_float ($default)) return function (float $value) { return $value; }; |
|
28 | + if (is_float($default)) return function(float $value) { return $value; }; |
|
29 | 29 | |
30 | - if (is_array ($default)) return function (array $value) { return $value; }; |
|
30 | + if (is_array($default)) return function(array $value) { return $value; }; |
|
31 | 31 | |
32 | - if (is_callable ($default)) return function (callable $value) { return $value; }; |
|
32 | + if (is_callable($default)) return function(callable $value) { return $value; }; |
|
33 | 33 | |
34 | 34 | # Check object type |
35 | 35 | |
36 | - if (is_object($default)) return function ($value) use ($default) { |
|
36 | + if (is_object($default)) return function($value) use ($default) { |
|
37 | 37 | |
38 | 38 | return (is_a($value, get_class($default)) ? $value : null); |
39 | 39 | }; |
40 | 40 | |
41 | 41 | # Check resource type |
42 | 42 | |
43 | - if (is_resource($default)) return function ($value) { return (is_resource($value) ? $value : null); }; |
|
43 | + if (is_resource($default)) return function($value) { return (is_resource($value) ? $value : null); }; |
|
44 | 44 | |
45 | 45 | # ------------------------ |
46 | 46 | |
47 | - return function () { return null; }; |
|
47 | + return function() { return null; }; |
|
48 | 48 | } |
49 | 49 | } |
50 | 50 | } |
@@ -19,28 +19,51 @@ |
||
19 | 19 | |
20 | 20 | # Check basic types |
21 | 21 | |
22 | - if (is_string ($default)) return function (string $value) { return $value; }; |
|
22 | + if (is_string ($default)) { |
|
23 | + return function (string $value) { return $value; |
|
24 | + } |
|
25 | + }; |
|
23 | 26 | |
24 | - if (is_bool ($default)) return function (bool $value) { return $value; }; |
|
27 | + if (is_bool ($default)) { |
|
28 | + return function (bool $value) { return $value; |
|
29 | + } |
|
30 | + }; |
|
25 | 31 | |
26 | - if (is_int ($default)) return function (int $value) { return $value; }; |
|
32 | + if (is_int ($default)) { |
|
33 | + return function (int $value) { return $value; |
|
34 | + } |
|
35 | + }; |
|
27 | 36 | |
28 | - if (is_float ($default)) return function (float $value) { return $value; }; |
|
37 | + if (is_float ($default)) { |
|
38 | + return function (float $value) { return $value; |
|
39 | + } |
|
40 | + }; |
|
29 | 41 | |
30 | - if (is_array ($default)) return function (array $value) { return $value; }; |
|
42 | + if (is_array ($default)) { |
|
43 | + return function (array $value) { return $value; |
|
44 | + } |
|
45 | + }; |
|
31 | 46 | |
32 | - if (is_callable ($default)) return function (callable $value) { return $value; }; |
|
47 | + if (is_callable ($default)) { |
|
48 | + return function (callable $value) { return $value; |
|
49 | + } |
|
50 | + }; |
|
33 | 51 | |
34 | 52 | # Check object type |
35 | 53 | |
36 | - if (is_object($default)) return function ($value) use ($default) { |
|
54 | + if (is_object($default)) { |
|
55 | + return function ($value) use ($default) { |
|
37 | 56 | |
38 | 57 | return (is_a($value, get_class($default)) ? $value : null); |
58 | + } |
|
39 | 59 | }; |
40 | 60 | |
41 | 61 | # Check resource type |
42 | 62 | |
43 | - if (is_resource($default)) return function ($value) { return (is_resource($value) ? $value : null); }; |
|
63 | + if (is_resource($default)) { |
|
64 | + return function ($value) { return (is_resource($value) ? $value : null); |
|
65 | + } |
|
66 | + }; |
|
44 | 67 | |
45 | 68 | # ------------------------ |
46 | 69 |
@@ -67,7 +67,7 @@ |
||
67 | 67 | |
68 | 68 | public static function sortby(array $array, $sub_key, bool $descending = false) : array { |
69 | 69 | |
70 | - $select_key = function ($element) use ($sub_key) { return ($element[$sub_key] ?? false); }; |
|
70 | + $select_key = function($element) use ($sub_key) { return ($element[$sub_key] ?? false); }; |
|
71 | 71 | |
72 | 72 | $sorted = []; $column = array_map($select_key, $array); |
73 | 73 |
@@ -10,7 +10,7 @@ |
||
10 | 10 | |
11 | 11 | protected static $loader_class = 'Modules\Extend\Loader\Templates', $exception_class = 'Exception\Template'; |
12 | 12 | |
13 | - protected static $root_dir = [SECTION_SITE => DIR_SYSTEM_TEMPLATES . 'Site/', SECTION_ADMIN => DIR_SYSTEM_TEMPLATES . 'Admin/']; |
|
13 | + protected static $root_dir = [SECTION_SITE => DIR_SYSTEM_TEMPLATES.'Site/', SECTION_ADMIN => DIR_SYSTEM_TEMPLATES.'Admin/']; |
|
14 | 14 | |
15 | 15 | protected static $schema_prototype = 'Prototype\Template', $regex_name = REGEX_TEMPLATE_NAME; |
16 | 16 |
@@ -32,9 +32,13 @@ discard block |
||
32 | 32 | |
33 | 33 | $param = static::$param[$this->loader->section()]; $name = Request::post('name'); |
34 | 34 | |
35 | - if (false === Settings::set($param, $name)) return $ajax->setError(Language::get(static::$error_activate)); |
|
35 | + if (false === Settings::set($param, $name)) { |
|
36 | + return $ajax->setError(Language::get(static::$error_activate)); |
|
37 | + } |
|
36 | 38 | |
37 | - if (false === Settings::save()) return $ajax->setError(Language::get(static::$error_save)); |
|
39 | + if (false === Settings::save()) { |
|
40 | + return $ajax->setError(Language::get(static::$error_save)); |
|
41 | + } |
|
38 | 42 | |
39 | 43 | } else if (Request::post('action') === 'list') { |
40 | 44 | |
@@ -52,7 +56,9 @@ discard block |
||
52 | 56 | |
53 | 57 | $this->loader = new static::$loader_class(Request::get('list')); |
54 | 58 | |
55 | - if ($ajax) return $this->handleAjax(); |
|
59 | + if ($ajax) { |
|
60 | + return $this->handleAjax(); |
|
61 | + } |
|
56 | 62 | |
57 | 63 | # ------------------------ |
58 | 64 |
@@ -35,13 +35,17 @@ discard block |
||
35 | 35 | |
36 | 36 | $name = Request::post('name'); |
37 | 37 | |
38 | - if (!$this->loader->install($name, true)) return $ajax->setError(Language::get(static::$error_install)); |
|
38 | + if (!$this->loader->install($name, true)) { |
|
39 | + return $ajax->setError(Language::get(static::$error_install)); |
|
40 | + } |
|
39 | 41 | |
40 | 42 | } else if (Request::post('action') === 'uninstall') { |
41 | 43 | |
42 | 44 | $name = Request::post('name'); |
43 | 45 | |
44 | - if (!$this->loader->install($name, false)) return $ajax->setError(Language::get(static::$error_uninstall)); |
|
46 | + if (!$this->loader->install($name, false)) { |
|
47 | + return $ajax->setError(Language::get(static::$error_uninstall)); |
|
48 | + } |
|
45 | 49 | } |
46 | 50 | |
47 | 51 | # ------------------------ |
@@ -55,7 +59,9 @@ discard block |
||
55 | 59 | |
56 | 60 | $this->loader = new static::$loader_class; |
57 | 61 | |
58 | - if ($ajax) return $this->handleAjax(); |
|
62 | + if ($ajax) { |
|
63 | + return $this->handleAjax(); |
|
64 | + } |
|
59 | 65 | |
60 | 66 | # ------------------------ |
61 | 67 |