@@ -12,25 +12,35 @@ |
||
12 | 12 | |
13 | 13 | public function create(array $data) { |
14 | 14 | |
15 | - if (0 !== $this->id) return false; |
|
15 | + if (0 !== $this->id) { |
|
16 | + return false; |
|
17 | + } |
|
16 | 18 | |
17 | 19 | $set = $this->getDataset($data, true); |
18 | 20 | |
19 | - if (isset($set['id']) && !($set['id'] > 0)) return false; |
|
21 | + if (isset($set['id']) && !($set['id'] > 0)) { |
|
22 | + return false; |
|
23 | + } |
|
20 | 24 | |
21 | 25 | # Insert entity |
22 | 26 | |
23 | 27 | DB::insert(static::$table, $set); |
24 | 28 | |
25 | - if (!(DB::last() && DB::last()->status)) return false; |
|
29 | + if (!(DB::last() && DB::last()->status)) { |
|
30 | + return false; |
|
31 | + } |
|
26 | 32 | |
27 | 33 | # Re-init entity |
28 | 34 | |
29 | 35 | $this->error = false; $this->id = DB::last()->id; |
30 | 36 | |
31 | - foreach ($set as $name => $value) if ($name !== 'id') $this->data[$name] = $value; |
|
37 | + foreach ($set as $name => $value) { |
|
38 | + if ($name !== 'id') $this->data[$name] = $value; |
|
39 | + } |
|
32 | 40 | |
33 | - if (static::$nesting) $this->data['path'] = $this->getPath(); |
|
41 | + if (static::$nesting) { |
|
42 | + $this->data['path'] = $this->getPath(); |
|
43 | + } |
|
34 | 44 | |
35 | 45 | # Implement entity |
36 | 46 |
@@ -12,13 +12,19 @@ discard block |
||
12 | 12 | |
13 | 13 | public function remove() { |
14 | 14 | |
15 | - if (0 === $this->id) return false; |
|
15 | + if (0 === $this->id) { |
|
16 | + return false; |
|
17 | + } |
|
16 | 18 | |
17 | 19 | # Check if entity is removable |
18 | 20 | |
19 | - if (static::$super && ($this->id === 1)) return false; |
|
21 | + if (static::$super && ($this->id === 1)) { |
|
22 | + return false; |
|
23 | + } |
|
20 | 24 | |
21 | - if (static::$nesting && (0 !== $this->children())) return false; |
|
25 | + if (static::$nesting && (0 !== $this->children())) { |
|
26 | + return false; |
|
27 | + } |
|
22 | 28 | |
23 | 29 | # Remove extension entries |
24 | 30 | |
@@ -26,18 +32,24 @@ discard block |
||
26 | 32 | |
27 | 33 | $entity = self::get($extension, $this->id); |
28 | 34 | |
29 | - if ($entity->error() || ((0 !== $entity->id) && !$entity->remove())) return false; |
|
35 | + if ($entity->error() || ((0 !== $entity->id) && !$entity->remove())) { |
|
36 | + return false; |
|
37 | + } |
|
30 | 38 | } |
31 | 39 | |
32 | 40 | # Remove entity |
33 | 41 | |
34 | 42 | DB::delete(static::$table, ['id' => $this->id]); |
35 | 43 | |
36 | - if (!(DB::last() && DB::last()->status)) return false; |
|
44 | + if (!(DB::last() && DB::last()->status)) { |
|
45 | + return false; |
|
46 | + } |
|
37 | 47 | |
38 | 48 | # Uncache entity |
39 | 49 | |
40 | - if (self::$cache[static::$type][$this->id] === $this) unset(self::$cache[static::$type][$this->id]); |
|
50 | + if (self::$cache[static::$type][$this->id] === $this) { |
|
51 | + unset(self::$cache[static::$type][$this->id]); |
|
52 | + } |
|
41 | 53 | |
42 | 54 | # Reset id |
43 | 55 | |
@@ -45,11 +57,15 @@ discard block |
||
45 | 57 | |
46 | 58 | # Reset data array |
47 | 59 | |
48 | - foreach ($this->definition->params() as $name => $param) $this->data[$name] = $param->cast(null); |
|
60 | + foreach ($this->definition->params() as $name => $param) { |
|
61 | + $this->data[$name] = $param->cast(null); |
|
62 | + } |
|
49 | 63 | |
50 | 64 | # Reset path |
51 | 65 | |
52 | - if (static::$nesting) $this->data['path'] = []; |
|
66 | + if (static::$nesting) { |
|
67 | + $this->data['path'] = []; |
|
68 | + } |
|
53 | 69 | |
54 | 70 | # Implement entity |
55 | 71 |
@@ -12,13 +12,17 @@ discard block |
||
12 | 12 | |
13 | 13 | public function init($value, string $name = 'id') { |
14 | 14 | |
15 | - if (0 !== $this->id) return false; |
|
15 | + if (0 !== $this->id) { |
|
16 | + return false; |
|
17 | + } |
|
16 | 18 | |
17 | 19 | # Check param name |
18 | 20 | |
19 | - if ($name === 'id') $param = $this->definition->id(); |
|
20 | - |
|
21 | - else if ((false === ($param = $this->definition->get($name))) || !$param->unique()) return false; |
|
21 | + if ($name === 'id') { |
|
22 | + $param = $this->definition->id(); |
|
23 | + } else if ((false === ($param = $this->definition->get($name))) || !$param->unique()) { |
|
24 | + return false; |
|
25 | + } |
|
22 | 26 | |
23 | 27 | # Select entity from DB |
24 | 28 | |
@@ -28,7 +32,9 @@ discard block |
||
28 | 32 | |
29 | 33 | DB::select(static::$table, $selection, [$name => $value], null, 1); |
30 | 34 | |
31 | - if (($this->error = !(DB::last() && DB::last()->status)) || (DB::last()->rows !== 1)) return false; |
|
35 | + if (($this->error = !(DB::last() && DB::last()->status)) || (DB::last()->rows !== 1)) { |
|
36 | + return false; |
|
37 | + } |
|
32 | 38 | |
33 | 39 | $data = DB::last()->row(); |
34 | 40 | |
@@ -36,11 +42,15 @@ discard block |
||
36 | 42 | |
37 | 43 | $this->id = $this->definition->id()->cast($data['id']); |
38 | 44 | |
39 | - foreach ($this->definition->params() as $name => $param) $this->data[$name] = $param->cast($data[$name]); |
|
45 | + foreach ($this->definition->params() as $name => $param) { |
|
46 | + $this->data[$name] = $param->cast($data[$name]); |
|
47 | + } |
|
40 | 48 | |
41 | 49 | # Init path |
42 | 50 | |
43 | - if (static::$nesting) $this->data['path'] = $this->getPath(); |
|
51 | + if (static::$nesting) { |
|
52 | + $this->data['path'] = $this->getPath(); |
|
53 | + } |
|
44 | 54 | |
45 | 55 | # Implement entity |
46 | 56 |
@@ -12,7 +12,9 @@ discard block |
||
12 | 12 | |
13 | 13 | public function edit(array $data) { |
14 | 14 | |
15 | - if (0 === $this->id) return false; |
|
15 | + if (0 === $this->id) { |
|
16 | + return false; |
|
17 | + } |
|
16 | 18 | |
17 | 19 | $set = $this->getDataset($data); |
18 | 20 | |
@@ -20,13 +22,19 @@ discard block |
||
20 | 22 | |
21 | 23 | DB::update(static::$table, $set, ['id' => $this->id]); |
22 | 24 | |
23 | - if (!(DB::last() && DB::last()->status)) return false; |
|
25 | + if (!(DB::last() && DB::last()->status)) { |
|
26 | + return false; |
|
27 | + } |
|
24 | 28 | |
25 | 29 | # Re-init entity |
26 | 30 | |
27 | - foreach ($set as $name => $value) $this->data[$name] = $value; |
|
31 | + foreach ($set as $name => $value) { |
|
32 | + $this->data[$name] = $value; |
|
33 | + } |
|
28 | 34 | |
29 | - if (static::$nesting) $this->data['path'] = $this->getPath(); |
|
35 | + if (static::$nesting) { |
|
36 | + $this->data['path'] = $this->getPath(); |
|
37 | + } |
|
30 | 38 | |
31 | 39 | # Implement entity |
32 | 40 |
@@ -12,19 +12,27 @@ |
||
12 | 12 | |
13 | 13 | public function fill(array $data) { |
14 | 14 | |
15 | - if (0 !== $this->id) return false; |
|
15 | + if (0 !== $this->id) { |
|
16 | + return false; |
|
17 | + } |
|
16 | 18 | |
17 | 19 | $set = $this->getDataset($data, true); |
18 | 20 | |
19 | - if (!isset($set['id']) || !($set['id'] > 0)) return false; |
|
21 | + if (!isset($set['id']) || !($set['id'] > 0)) { |
|
22 | + return false; |
|
23 | + } |
|
20 | 24 | |
21 | 25 | # Re-init entity |
22 | 26 | |
23 | 27 | $this->error = false; $this->id = $set['id']; |
24 | 28 | |
25 | - foreach ($set as $name => $value) if ($name !== 'id') $this->data[$name] = $value; |
|
29 | + foreach ($set as $name => $value) { |
|
30 | + if ($name !== 'id') $this->data[$name] = $value; |
|
31 | + } |
|
26 | 32 | |
27 | - if (static::$nesting) $this->data['path'] = $this->getPath(); |
|
33 | + if (static::$nesting) { |
|
34 | + $this->data['path'] = $this->getPath(); |
|
35 | + } |
|
28 | 36 | |
29 | 37 | # Implement entity |
30 | 38 |
@@ -23,11 +23,15 @@ discard block |
||
23 | 23 | |
24 | 24 | $name = Settings::get(self::$param[$this->section]); $primary = self::$default[$this->section]; |
25 | 25 | |
26 | - if (self::valid($name) && isset($items[$name])) $active = $name; |
|
27 | - |
|
28 | - else if (self::valid($primary) && isset($items[$primary])) $active = $primary; |
|
26 | + if (self::valid($name) && isset($items[$name])) { |
|
27 | + $active = $name; |
|
28 | + } else if (self::valid($primary) && isset($items[$primary])) { |
|
29 | + $active = $primary; |
|
30 | + } |
|
29 | 31 | |
30 | - foreach (array_keys($items) as $name) $items[$name]['active'] = ($name === $active); |
|
32 | + foreach (array_keys($items) as $name) { |
|
33 | + $items[$name]['active'] = ($name === $active); |
|
34 | + } |
|
31 | 35 | |
32 | 36 | # ------------------------ |
33 | 37 | |
@@ -73,12 +77,16 @@ discard block |
||
73 | 77 | |
74 | 78 | $items->add($item = View::get(self::$view_item)); |
75 | 79 | |
76 | - foreach (self::$data as $name) $item->$name = $extension[$name]; |
|
80 | + foreach (self::$data as $name) { |
|
81 | + $item->$name = $extension[$name]; |
|
82 | + } |
|
77 | 83 | |
78 | 84 | $item->class = ($extension['active'] ? 'positive' : 'grey'); |
79 | 85 | } |
80 | 86 | |
81 | - if ($items->count()) $contents->block('items', $items); |
|
87 | + if ($items->count()) { |
|
88 | + $contents->block('items', $items); |
|
89 | + } |
|
82 | 90 | |
83 | 91 | # ------------------------ |
84 | 92 | |
@@ -93,15 +101,21 @@ discard block |
||
93 | 101 | |
94 | 102 | # Check for demo mode |
95 | 103 | |
96 | - if (Informer::isDemoMode()) return $ajax->error(Language::get('DEMO_MODE_RESTRICTION')); |
|
104 | + if (Informer::isDemoMode()) { |
|
105 | + return $ajax->error(Language::get('DEMO_MODE_RESTRICTION')); |
|
106 | + } |
|
97 | 107 | |
98 | 108 | # Save configuration |
99 | 109 | |
100 | 110 | $param = self::$param[$this->section]; $name = Request::post('name'); |
101 | 111 | |
102 | - if (false === Settings::set($param, $name)) return $ajax->error(Language::get(self::$error_name)); |
|
112 | + if (false === Settings::set($param, $name)) { |
|
113 | + return $ajax->error(Language::get(self::$error_name)); |
|
114 | + } |
|
103 | 115 | |
104 | - if (false === Settings::save()) return $ajax->error(Language::get(self::$error_save)); |
|
116 | + if (false === Settings::save()) { |
|
117 | + return $ajax->error(Language::get(self::$error_save)); |
|
118 | + } |
|
105 | 119 | |
106 | 120 | # ------------------------ |
107 | 121 | |
@@ -116,7 +130,9 @@ discard block |
||
116 | 130 | |
117 | 131 | $this->items = $this->getHandlerItems(); |
118 | 132 | |
119 | - if (Request::isAjax()) return $this->handleAjax(); |
|
133 | + if (Request::isAjax()) { |
|
134 | + return $this->handleAjax(); |
|
135 | + } |
|
120 | 136 | |
121 | 137 | # ------------------------ |
122 | 138 |
@@ -32,11 +32,15 @@ discard block |
||
32 | 32 | |
33 | 33 | $file_name = ($dir_name . $name . '/Config.php'); |
34 | 34 | |
35 | - if (!is_array($include = Explorer::php($file_name))) continue; |
|
35 | + if (!is_array($include = Explorer::php($file_name))) { |
|
36 | + continue; |
|
37 | + } |
|
36 | 38 | |
37 | 39 | $config = Arr::select($include, self::$data); |
38 | 40 | |
39 | - if (!(self::valid($config['name']) && ($config['name'] === $name))) continue; |
|
41 | + if (!(self::valid($config['name']) && ($config['name'] === $name))) { |
|
42 | + continue; |
|
43 | + } |
|
40 | 44 | |
41 | 45 | $items[$name] = $config; |
42 | 46 | } |
@@ -52,11 +56,19 @@ discard block |
||
52 | 56 | |
53 | 57 | $name = ''; $param = self::$param[self::$section]; |
54 | 58 | |
55 | - if (self::exists($name_cookie = Cookie::get($param))) $name = $name_cookie; |
|
59 | + if (self::exists($name_cookie = Cookie::get($param))) { |
|
60 | + $name = $name_cookie; |
|
61 | + } |
|
56 | 62 | |
57 | - if (self::exists($name_get = Request::get(self::$name))) $name = $name_get; |
|
63 | + if (self::exists($name_get = Request::get(self::$name))) { |
|
64 | + $name = $name_get; |
|
65 | + } |
|
58 | 66 | |
59 | - if ('' !== $name) Cookie::set($param, $name, self::$cookie_expires); else return false; |
|
67 | + if ('' !== $name) { |
|
68 | + Cookie::set($param, $name, self::$cookie_expires); |
|
69 | + } else { |
|
70 | + return false; |
|
71 | + } |
|
60 | 72 | |
61 | 73 | # ------------------------ |
62 | 74 | |
@@ -90,7 +102,9 @@ discard block |
||
90 | 102 | |
91 | 103 | $section = self::getSection($section); $dir_name = self::getDirName($section); |
92 | 104 | |
93 | - if (!Explorer::isDir($dir_name)) throw new Exception\General(self::$error_directory); |
|
105 | + if (!Explorer::isDir($dir_name)) { |
|
106 | + throw new Exception\General(self::$error_directory); |
|
107 | + } |
|
94 | 108 | |
95 | 109 | self::$section = $section; self::$dir_name = $dir_name; self::$items = self::getItems($dir_name); |
96 | 110 | |
@@ -98,11 +112,15 @@ discard block |
||
98 | 112 | |
99 | 113 | $primary = (self::exists(self::$default[$section]) ? self::$default[$section] : false); |
100 | 114 | |
101 | - if ($selectable && (false !== ($name = self::getUserDefined()))) $name_valid = true; |
|
102 | - |
|
103 | - else $name_valid = (self::exists($name = Settings::get($param)) || (false !== ($name = $primary))); |
|
115 | + if ($selectable && (false !== ($name = self::getUserDefined()))) { |
|
116 | + $name_valid = true; |
|
117 | + } else { |
|
118 | + $name_valid = (self::exists($name = Settings::get($param)) || (false !== ($name = $primary))); |
|
119 | + } |
|
104 | 120 | |
105 | - if (!($name_valid || (null !== ($name = key(self::$items))))) throw new Exception\General(self::$error_select); |
|
121 | + if (!($name_valid || (null !== ($name = key(self::$items))))) { |
|
122 | + throw new Exception\General(self::$error_select); |
|
123 | + } |
|
106 | 124 | |
107 | 125 | # ------------------------ |
108 | 126 | |
@@ -127,7 +145,9 @@ discard block |
||
127 | 145 | |
128 | 146 | public static function items(string $section = null) { |
129 | 147 | |
130 | - if (null === $section) return self::$items; |
|
148 | + if (null === $section) { |
|
149 | + return self::$items; |
|
150 | + } |
|
131 | 151 | |
132 | 152 | $section = self::getSection($section); $dir_name = self::getDirName($section); |
133 | 153 | |
@@ -152,7 +172,9 @@ discard block |
||
152 | 172 | |
153 | 173 | public static function path() { |
154 | 174 | |
155 | - if ('' === self::$active) return false; |
|
175 | + if ('' === self::$active) { |
|
176 | + return false; |
|
177 | + } |
|
156 | 178 | |
157 | 179 | return (self::$dir_name . self::$active . '/'); |
158 | 180 | } |
@@ -161,7 +183,9 @@ discard block |
||
161 | 183 | |
162 | 184 | public static function pathPrimary() { |
163 | 185 | |
164 | - if ('' === self::$primary) return false; |
|
186 | + if ('' === self::$primary) { |
|
187 | + return false; |
|
188 | + } |
|
165 | 189 | |
166 | 190 | return (self::$dir_name . self::$primary . '/'); |
167 | 191 | } |
@@ -170,9 +194,13 @@ discard block |
||
170 | 194 | |
171 | 195 | public static function data(string $name = null) { |
172 | 196 | |
173 | - if ('' === self::$active) return false; |
|
197 | + if ('' === self::$active) { |
|
198 | + return false; |
|
199 | + } |
|
174 | 200 | |
175 | - if (null === $name) return self::$items[self::$active]; |
|
201 | + if (null === $name) { |
|
202 | + return self::$items[self::$active]; |
|
203 | + } |
|
176 | 204 | |
177 | 205 | return (isset(self::$items[self::$active][$name]) ? self::$items[self::$active][$name] : false); |
178 | 206 | } |
@@ -32,10 +32,12 @@ discard block |
||
32 | 32 | |
33 | 33 | $languages = [Extend\Languages::pathPrimary(), Extend\Languages::path()]; |
34 | 34 | |
35 | - foreach (array_unique($languages) as $path) foreach (static::PHRASES as $name) { |
|
35 | + foreach (array_unique($languages) as $path) { |
|
36 | + foreach (static::PHRASES as $name) { |
|
36 | 37 | |
37 | 38 | Language::load($path . 'Phrases/' . $name . '.php'); |
38 | 39 | } |
40 | + } |
|
39 | 41 | |
40 | 42 | # Set template globals |
41 | 43 | |
@@ -57,7 +59,9 @@ discard block |
||
57 | 59 | |
58 | 60 | # Set timezone |
59 | 61 | |
60 | - if (Auth::check() && ('' !== ($timezone = Auth::user()->timezone))) date_default_timezone_set($timezone); |
|
62 | + if (Auth::check() && ('' !== ($timezone = Auth::user()->timezone))) { |
|
63 | + date_default_timezone_set($timezone); |
|
64 | + } |
|
61 | 65 | |
62 | 66 | # ------------------------ |
63 | 67 |
@@ -147,20 +147,29 @@ discard block |
||
147 | 147 | |
148 | 148 | if ($this instanceof Component\Install) { |
149 | 149 | |
150 | - if (Template::isBlock($result = $this->handle())) return $this->displayForm($result, STATUS_CODE_200); |
|
150 | + if (Template::isBlock($result = $this->handle())) { |
|
151 | + return $this->displayForm($result, STATUS_CODE_200); |
|
152 | + } |
|
151 | 153 | } |
152 | 154 | |
153 | 155 | # Handle auth component request |
154 | 156 | |
155 | 157 | else if ($this instanceof Component\Auth) { |
156 | 158 | |
157 | - if (Auth::check()) Request::redirect(INSTALL_PATH . '/admin'); |
|
158 | - |
|
159 | - if ($this instanceof Component\Auth\Initial) { if (!Auth::initial()) Request::redirect(INSTALL_PATH . '/admin/login'); } |
|
159 | + if (Auth::check()) { |
|
160 | + Request::redirect(INSTALL_PATH . '/admin'); |
|
161 | + } |
|
160 | 162 | |
161 | - else if (Auth::initial()) Request::redirect(INSTALL_PATH . '/admin/register'); |
|
163 | + if ($this instanceof Component\Auth\Initial) { if (!Auth::initial()) { |
|
164 | + Request::redirect(INSTALL_PATH . '/admin/login'); |
|
165 | + } |
|
166 | + } else if (Auth::initial()) { |
|
167 | + Request::redirect(INSTALL_PATH . '/admin/register'); |
|
168 | + } |
|
162 | 169 | |
163 | - if (Template::isBlock($result = $this->handle())) return $this->displayForm($result, STATUS_CODE_401); |
|
170 | + if (Template::isBlock($result = $this->handle())) { |
|
171 | + return $this->displayForm($result, STATUS_CODE_401); |
|
172 | + } |
|
164 | 173 | } |
165 | 174 | |
166 | 175 | # Handle panel component request |
@@ -172,9 +181,13 @@ discard block |
||
172 | 181 | Request::redirect(INSTALL_PATH . '/admin/login'); |
173 | 182 | } |
174 | 183 | |
175 | - if (Template::isBlock($result = $this->handle())) return $this->displayPage($result); |
|
184 | + if (Template::isBlock($result = $this->handle())) { |
|
185 | + return $this->displayPage($result); |
|
186 | + } |
|
176 | 187 | |
177 | - if (Ajax::isResponse($result)) return Ajax::output($result); |
|
188 | + if (Ajax::isResponse($result)) { |
|
189 | + return Ajax::output($result); |
|
190 | + } |
|
178 | 191 | } |
179 | 192 | } |
180 | 193 |