@@ -12,7 +12,11 @@ discard block |
||
12 | 12 | |
13 | 13 | $text = Language::get($code); |
14 | 14 | |
15 | - if (!$popup) Messages::set('error', $text); else Popup::set('negative', $text); |
|
15 | + if (!$popup) { |
|
16 | + Messages::set('error', $text); |
|
17 | + } else { |
|
18 | + Popup::set('negative', $text); |
|
19 | + } |
|
16 | 20 | |
17 | 21 | # ------------------------ |
18 | 22 | |
@@ -23,15 +27,21 @@ discard block |
||
23 | 27 | |
24 | 28 | public function handle(callable $callback, bool $popup = false) { |
25 | 29 | |
26 | - if (false === ($post = $this->post())) return false; |
|
30 | + if (false === ($post = $this->post())) { |
|
31 | + return false; |
|
32 | + } |
|
27 | 33 | |
28 | 34 | # Check form for errors |
29 | 35 | |
30 | - if ($this->hasErrors()) return $this->displayError('FORM_ERROR_REQUIRED', $popup); |
|
36 | + if ($this->hasErrors()) { |
|
37 | + return $this->displayError('FORM_ERROR_REQUIRED', $popup); |
|
38 | + } |
|
31 | 39 | |
32 | 40 | # Call controller method |
33 | 41 | |
34 | - if (is_string($result = $callback($post))) return $this->displayError($result, $popup); |
|
42 | + if (is_string($result = $callback($post))) { |
|
43 | + return $this->displayError($result, $popup); |
|
44 | + } |
|
35 | 45 | |
36 | 46 | if (is_array($result)) { $this->getField($result[0])->error = true; return $this->displayError($result[1], $popup); } |
37 | 47 |
@@ -10,7 +10,7 @@ |
||
10 | 10 | |
11 | 11 | public static function get(string $name) { |
12 | 12 | |
13 | - $class_name = ('Schemas\\' . $name); |
|
13 | + $class_name = ('Schemas\\'.$name); |
|
14 | 14 | |
15 | 15 | if (!isset(self::$cache[$class_name])) self::$cache[$class_name] = new $class_name; |
16 | 16 |
@@ -12,7 +12,9 @@ |
||
12 | 12 | |
13 | 13 | $class_name = ('Schemas\\' . $name); |
14 | 14 | |
15 | - if (!isset(self::$cache[$class_name])) self::$cache[$class_name] = new $class_name; |
|
15 | + if (!isset(self::$cache[$class_name])) { |
|
16 | + self::$cache[$class_name] = new $class_name; |
|
17 | + } |
|
16 | 18 | |
17 | 19 | # ------------------------ |
18 | 20 |
@@ -14,7 +14,9 @@ |
||
14 | 14 | |
15 | 15 | $selection = ['name', 'value']; $order = ['name' => 'ASC']; |
16 | 16 | |
17 | - if (!(DB::select(TABLE_VARIABLES, $selection, null, $order) && DB::getLast()->status)) return; |
|
17 | + if (!(DB::select(TABLE_VARIABLES, $selection, null, $order) && DB::getLast()->status)) { |
|
18 | + return; |
|
19 | + } |
|
18 | 20 | |
19 | 21 | # Process results |
20 | 22 |
@@ -14,7 +14,9 @@ |
||
14 | 14 | |
15 | 15 | $selection = ['name', 'contents']; $condition = ['active' => 1]; $order = ['name' => 'ASC']; |
16 | 16 | |
17 | - if (!(DB::select(TABLE_WIDGETS, $selection, $condition, $order) && DB::getLast()->status)) return; |
|
17 | + if (!(DB::select(TABLE_WIDGETS, $selection, $condition, $order) && DB::getLast()->status)) { |
|
18 | + return; |
|
19 | + } |
|
18 | 20 | |
19 | 21 | # Process results |
20 | 22 |
@@ -20,7 +20,9 @@ discard block |
||
20 | 20 | |
21 | 21 | $item->children = ($children = Template::createBlock()); |
22 | 22 | |
23 | - foreach ($this->menu[$id]['children'] as $child) $children->addItem($this->parseItem($child)); |
|
23 | + foreach ($this->menu[$id]['children'] as $child) { |
|
24 | + $children->addItem($this->parseItem($child)); |
|
25 | + } |
|
24 | 26 | |
25 | 27 | } else { |
26 | 28 | |
@@ -44,7 +46,9 @@ discard block |
||
44 | 46 | |
45 | 47 | $menu = Entitizer::treeview(TABLE_MENU)->subtree(0, ['active' => true]); |
46 | 48 | |
47 | - if (false !== $menu) $this->menu = $menu; |
|
49 | + if (false !== $menu) { |
|
50 | + $this->menu = $menu; |
|
51 | + } |
|
48 | 52 | } |
49 | 53 | |
50 | 54 | # Get block |
@@ -53,7 +57,9 @@ discard block |
||
53 | 57 | |
54 | 58 | $menu = Template::createBlock(); |
55 | 59 | |
56 | - foreach ($this->menu[0]['children'] as $id) $menu->addItem($this->parseItem($id)); |
|
60 | + foreach ($this->menu[0]['children'] as $id) { |
|
61 | + $menu->addItem($this->parseItem($id)); |
|
62 | + } |
|
57 | 63 | |
58 | 64 | # ------------------------ |
59 | 65 |
@@ -58,7 +58,7 @@ |
||
58 | 58 | |
59 | 59 | list ($extremum, $index) = $data; $block = $pagination->getBlock($class); |
60 | 60 | |
61 | - if ($active === $extremum) { $block->disable(); $pagination->getBlock($class . '_disabled')->enable(); } |
|
61 | + if ($active === $extremum) { $block->disable(); $pagination->getBlock($class.'_disabled')->enable(); } |
|
62 | 62 | |
63 | 63 | else $block->link = $url->setAttribute('index', $index)->getString(); |
64 | 64 | } |
@@ -14,7 +14,9 @@ discard block |
||
14 | 14 | |
15 | 15 | for ($index = ($active - 2); $index <= ($active + 2); $index++) { |
16 | 16 | |
17 | - if (!($index > 0 && $index <= $count)) continue; |
|
17 | + if (!($index > 0 && $index <= $count)) { |
|
18 | + continue; |
|
19 | + } |
|
18 | 20 | |
19 | 21 | $class = (($index === $active) ? 'active item' : 'item'); |
20 | 22 | |
@@ -41,7 +43,9 @@ discard block |
||
41 | 43 | |
42 | 44 | $block->link = $url->setAttribute('index', $index)->getString(); $block->index = $index; |
43 | 45 | |
44 | - if ($closest) $block->getBlock('ellipsis')->disable(); |
|
46 | + if ($closest) { |
|
47 | + $block->getBlock('ellipsis')->disable(); |
|
48 | + } |
|
45 | 49 | } |
46 | 50 | } |
47 | 51 | |
@@ -58,9 +62,9 @@ discard block |
||
58 | 62 | |
59 | 63 | list ($extremum, $index) = $data; $block = $pagination->getBlock($class); |
60 | 64 | |
61 | - if ($active === $extremum) { $block->disable(); $pagination->getBlock($class . '_disabled')->enable(); } |
|
62 | - |
|
63 | - else $block->link = $url->setAttribute('index', $index)->getString(); |
|
65 | + if ($active === $extremum) { $block->disable(); $pagination->getBlock($class . '_disabled')->enable(); } else { |
|
66 | + $block->link = $url->setAttribute('index', $index)->getString(); |
|
67 | + } |
|
64 | 68 | } |
65 | 69 | } |
66 | 70 | |
@@ -68,9 +72,13 @@ discard block |
||
68 | 72 | |
69 | 73 | public static function block(int $index, int $display, int $total, Url $url) { |
70 | 74 | |
71 | - if (($index <= 0) || ($display <= 0) || ($total <= 0)) return false; |
|
75 | + if (($index <= 0) || ($display <= 0) || ($total <= 0)) { |
|
76 | + return false; |
|
77 | + } |
|
72 | 78 | |
73 | - if (($display >= $total) || ($index > ($count = ceil($total / $display)))) return false; |
|
79 | + if (($display >= $total) || ($index > ($count = ceil($total / $display)))) { |
|
80 | + return false; |
|
81 | + } |
|
74 | 82 | |
75 | 83 | # Create block |
76 | 84 |
@@ -2,7 +2,8 @@ |
||
2 | 2 | |
3 | 3 | namespace Utils { |
4 | 4 | |
5 | - use Template, Url; |
|
5 | + use Template; |
|
6 | + use Url; |
|
6 | 7 | |
7 | 8 | abstract class Pagination { |
8 | 9 |
@@ -21,7 +21,9 @@ discard block |
||
21 | 21 | |
22 | 22 | public static function set(string $type, string $text, string $title = null) { |
23 | 23 | |
24 | - if (!in_array($type, static::$types, true) || isset(static::$items[$type]) || ('' === $text)) return; |
|
24 | + if (!in_array($type, static::$types, true) || isset(static::$items[$type]) || ('' === $text)) { |
|
25 | + return; |
|
26 | + } |
|
25 | 27 | |
26 | 28 | static::$items[$type] = ['text' => $text, 'title' => (('' !== $title) ? $title : null)]; |
27 | 29 | } |
@@ -45,7 +47,9 @@ discard block |
||
45 | 47 | |
46 | 48 | $block->type = $type; $block->text = Template::createBlock($item['text']); |
47 | 49 | |
48 | - if (isset($item['title'])) $block->getBlock('title')->set('text', $item['title'])->enable(); |
|
50 | + if (isset($item['title'])) { |
|
51 | + $block->getBlock('title')->set('text', $item['title'])->enable(); |
|
52 | + } |
|
49 | 53 | } |
50 | 54 | |
51 | 55 | # ------------------------ |
@@ -8,13 +8,17 @@ |
||
8 | 8 | |
9 | 9 | public function validate($data) { |
10 | 10 | |
11 | - if (!is_array($data)) return null; |
|
11 | + if (!is_array($data)) { |
|
12 | + return null; |
|
13 | + } |
|
12 | 14 | |
13 | 15 | $result = []; |
14 | 16 | |
15 | 17 | foreach ($data as $item) { |
16 | 18 | |
17 | - if (!is_array($item) || (null === ($item = parent::validate($item)))) return null; |
|
19 | + if (!is_array($item) || (null === ($item = parent::validate($item)))) { |
|
20 | + return null; |
|
21 | + } |
|
18 | 22 | |
19 | 23 | $result[] = $item; |
20 | 24 | } |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | |
76 | 76 | if ('' === static::$file_name) return null; |
77 | 77 | |
78 | - $file_name = (DIR_SYSTEM_DATA . static::$file_name); |
|
78 | + $file_name = (DIR_SYSTEM_DATA.static::$file_name); |
|
79 | 79 | |
80 | 80 | if (null === ($data = JSON::load($file_name))) return null; |
81 | 81 | |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | |
93 | 93 | if ('' === static::$file_name) return false; |
94 | 94 | |
95 | - $file_name = (DIR_SYSTEM_DATA . static::$file_name); |
|
95 | + $file_name = (DIR_SYSTEM_DATA.static::$file_name); |
|
96 | 96 | |
97 | 97 | if (null === ($data = $this->validate($data))) return false; |
98 | 98 |
@@ -18,48 +18,62 @@ discard block |
||
18 | 18 | |
19 | 19 | protected function addArray(string $name) { |
20 | 20 | |
21 | - if ('' !== $name) return $this->properties[$name] = new _Array; |
|
21 | + if ('' !== $name) { |
|
22 | + return $this->properties[$name] = new _Array; |
|
23 | + } |
|
22 | 24 | } |
23 | 25 | |
24 | 26 | # Add boolean property |
25 | 27 | |
26 | 28 | protected function addBoolean(string $name) { |
27 | 29 | |
28 | - if ('' !== $name) return $this->properties[$name] = new _Boolean; |
|
30 | + if ('' !== $name) { |
|
31 | + return $this->properties[$name] = new _Boolean; |
|
32 | + } |
|
29 | 33 | } |
30 | 34 | |
31 | 35 | # Add integer property |
32 | 36 | |
33 | 37 | protected function addInteger(string $name) { |
34 | 38 | |
35 | - if ('' !== $name) return $this->properties[$name] = new _Integer; |
|
39 | + if ('' !== $name) { |
|
40 | + return $this->properties[$name] = new _Integer; |
|
41 | + } |
|
36 | 42 | } |
37 | 43 | |
38 | 44 | # Add object property |
39 | 45 | |
40 | 46 | protected function addObject(string $name) { |
41 | 47 | |
42 | - if ('' !== $name) return $this->properties[$name] = new _Object; |
|
48 | + if ('' !== $name) { |
|
49 | + return $this->properties[$name] = new _Object; |
|
50 | + } |
|
43 | 51 | } |
44 | 52 | |
45 | 53 | # Add string property |
46 | 54 | |
47 | 55 | protected function addString(string $name) { |
48 | 56 | |
49 | - if ('' !== $name) return $this->properties[$name] = new _String; |
|
57 | + if ('' !== $name) { |
|
58 | + return $this->properties[$name] = new _String; |
|
59 | + } |
|
50 | 60 | } |
51 | 61 | |
52 | 62 | # Validate data |
53 | 63 | |
54 | 64 | public function validate($data) { |
55 | 65 | |
56 | - if (!is_array($data)) return null; |
|
66 | + if (!is_array($data)) { |
|
67 | + return null; |
|
68 | + } |
|
57 | 69 | |
58 | 70 | $result = []; |
59 | 71 | |
60 | 72 | foreach ($this->properties as $name => $property) { |
61 | 73 | |
62 | - if (!isset($data[$name]) || (null === ($value = $property->validate($data[$name])))) return null; |
|
74 | + if (!isset($data[$name]) || (null === ($value = $property->validate($data[$name])))) { |
|
75 | + return null; |
|
76 | + } |
|
63 | 77 | |
64 | 78 | $result[$name] = $value; |
65 | 79 | } |
@@ -73,13 +87,19 @@ discard block |
||
73 | 87 | |
74 | 88 | public function load() { |
75 | 89 | |
76 | - if ('' === static::$file_name) return null; |
|
90 | + if ('' === static::$file_name) { |
|
91 | + return null; |
|
92 | + } |
|
77 | 93 | |
78 | 94 | $file_name = (DIR_SYSTEM_DATA . static::$file_name); |
79 | 95 | |
80 | - if (null === ($data = JSON::load($file_name))) return null; |
|
96 | + if (null === ($data = JSON::load($file_name))) { |
|
97 | + return null; |
|
98 | + } |
|
81 | 99 | |
82 | - if (null === ($data = $this->validate($data))) return null; |
|
100 | + if (null === ($data = $this->validate($data))) { |
|
101 | + return null; |
|
102 | + } |
|
83 | 103 | |
84 | 104 | # ------------------------ |
85 | 105 | |
@@ -90,13 +110,19 @@ discard block |
||
90 | 110 | |
91 | 111 | public function save(array $data) { |
92 | 112 | |
93 | - if ('' === static::$file_name) return false; |
|
113 | + if ('' === static::$file_name) { |
|
114 | + return false; |
|
115 | + } |
|
94 | 116 | |
95 | 117 | $file_name = (DIR_SYSTEM_DATA . static::$file_name); |
96 | 118 | |
97 | - if (null === ($data = $this->validate($data))) return false; |
|
119 | + if (null === ($data = $this->validate($data))) { |
|
120 | + return false; |
|
121 | + } |
|
98 | 122 | |
99 | - if (false === JSON::save($file_name, $data)) return false; |
|
123 | + if (false === JSON::save($file_name, $data)) { |
|
124 | + return false; |
|
125 | + } |
|
100 | 126 | |
101 | 127 | # ------------------------ |
102 | 128 |