@@ -58,7 +58,7 @@ |
||
58 | 58 | |
59 | 59 | list ($extremum, $index) = $data; $block = $pagination->block($class); |
60 | 60 | |
61 | - if ($active === $extremum) { $block->disable(); $pagination->block($class . '_disabled')->enable(); } |
|
61 | + if ($active === $extremum) { $block->disable(); $pagination->block($class.'_disabled')->enable(); } |
|
62 | 62 | |
63 | 63 | else $block->link = $url->set('index', $index)->get(); |
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->set('index', $index)->string(); $block->index = $index; |
43 | 45 | |
44 | - if ($closest) $block->block('ellipsis')->disable(); |
|
46 | + if ($closest) { |
|
47 | + $block->block('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->block($class); |
60 | 64 | |
61 | - if ($active === $extremum) { $block->disable(); $pagination->block($class . '_disabled')->enable(); } |
|
62 | - |
|
63 | - else $block->link = $url->set('index', $index)->string(); |
|
65 | + if ($active === $extremum) { $block->disable(); $pagination->block($class . '_disabled')->enable(); } else { |
|
66 | + $block->link = $url->set('index', $index)->string(); |
|
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 |
@@ -20,7 +20,7 @@ |
||
20 | 20 | |
21 | 21 | if ($this->form->handle(new Auth\Controller\Register())) { |
22 | 22 | |
23 | - Request::redirect(INSTALL_PATH . (Auth::admin() ? '/admin' : '/profile') . '/login?submitted=register'); |
|
23 | + Request::redirect(INSTALL_PATH.(Auth::admin() ? '/admin' : '/profile').'/login?submitted=register'); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | # ------------------------ |
@@ -20,7 +20,7 @@ |
||
20 | 20 | |
21 | 21 | if ($this->form->handle(new Auth\Controller\Reset())) { |
22 | 22 | |
23 | - Request::redirect(INSTALL_PATH . (Auth::admin() ? '/admin' : '/profile') . '/login?submitted=reset'); |
|
23 | + Request::redirect(INSTALL_PATH.(Auth::admin() ? '/admin' : '/profile').'/login?submitted=reset'); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | # ------------------------ |
@@ -20,7 +20,7 @@ |
||
20 | 20 | |
21 | 21 | if ($this->form->handle(new Auth\Controller\Login())) { |
22 | 22 | |
23 | - Request::redirect(INSTALL_PATH . (Auth::admin() ? '/admin' : '/profile')); |
|
23 | + Request::redirect(INSTALL_PATH.(Auth::admin() ? '/admin' : '/profile')); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | # Display success message |
@@ -88,9 +88,9 @@ discard block |
||
88 | 88 | |
89 | 89 | if (!$this->entity->init(Request::get('name'))) { |
90 | 90 | |
91 | - $query = (('' !== $this->parent->path()) ? ('?parent=' . $this->parent->path()) : ''); |
|
91 | + $query = (('' !== $this->parent->path()) ? ('?parent='.$this->parent->path()) : ''); |
|
92 | 92 | |
93 | - Request::redirect(INSTALL_PATH . '/admin/content/filemanager' . $query); |
|
93 | + Request::redirect(INSTALL_PATH.'/admin/content/filemanager'.$query); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | # Create form |
@@ -101,9 +101,9 @@ discard block |
||
101 | 101 | |
102 | 102 | if ($this->form->handle(new Filemanager\Controller\Rename($this->entity))) { |
103 | 103 | |
104 | - $query = ('?parent=' . $this->parent->path() . '&name=' . $this->entity->name() . '&submitted'); |
|
104 | + $query = ('?parent='.$this->parent->path().'&name='.$this->entity->name().'&submitted'); |
|
105 | 105 | |
106 | - Request::redirect(INSTALL_PATH . '/admin/content/filemanager/' . static::$type . $query); |
|
106 | + Request::redirect(INSTALL_PATH.'/admin/content/filemanager/'.static::$type.$query); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | # Display success message |
@@ -47,7 +47,9 @@ discard block |
||
47 | 47 | |
48 | 48 | # Check for demo mode |
49 | 49 | |
50 | - if (Informer::isDemoMode()) return $ajax->error(Language::get('DEMO_MODE_RESTRICTION')); |
|
50 | + if (Informer::isDemoMode()) { |
|
51 | + return $ajax->error(Language::get('DEMO_MODE_RESTRICTION')); |
|
52 | + } |
|
51 | 53 | |
52 | 54 | # Init entity |
53 | 55 | |
@@ -60,7 +62,9 @@ discard block |
||
60 | 62 | |
61 | 63 | if (Request::post('action') === 'remove') { |
62 | 64 | |
63 | - if (!$this->entity->remove()) return $ajax->error(Language::get(static::$message_error_remove)); |
|
65 | + if (!$this->entity->remove()) { |
|
66 | + return $ajax->error(Language::get(static::$message_error_remove)); |
|
67 | + } |
|
64 | 68 | } |
65 | 69 | |
66 | 70 | # ------------------------ |
@@ -82,7 +86,9 @@ discard block |
||
82 | 86 | |
83 | 87 | # Handle ajax request |
84 | 88 | |
85 | - if (Request::isAjax()) return $this->handleAjax(); |
|
89 | + if (Request::isAjax()) { |
|
90 | + return $this->handleAjax(); |
|
91 | + } |
|
86 | 92 | |
87 | 93 | # Init entity |
88 | 94 | |
@@ -108,7 +114,9 @@ discard block |
||
108 | 114 | |
109 | 115 | # Display success message |
110 | 116 | |
111 | - if (false !== Request::get('submitted')) Popup::set('positive', Language::get(static::$message_success_rename)); |
|
117 | + if (false !== Request::get('submitted')) { |
|
118 | + Popup::set('positive', Language::get(static::$message_success_rename)); |
|
119 | + } |
|
112 | 120 | |
113 | 121 | # ------------------------ |
114 | 122 |
@@ -61,11 +61,11 @@ discard block |
||
61 | 61 | |
62 | 62 | # Set link |
63 | 63 | |
64 | - $link = (INSTALL_PATH . static::$link . '/'); |
|
64 | + $link = (INSTALL_PATH.static::$link.'/'); |
|
65 | 65 | |
66 | - if (static::$nesting) $contents->link = ($link . ($this->create ? 'create' : 'edit') . '?id=' . $this->parent->id); |
|
66 | + if (static::$nesting) $contents->link = ($link.($this->create ? 'create' : 'edit').'?id='.$this->parent->id); |
|
67 | 67 | |
68 | - else $contents->link = ($link . ($this->create ? 'create' : ('edit?id=' . $this->entity->id))); |
|
68 | + else $contents->link = ($link.($this->create ? 'create' : ('edit?id='.$this->entity->id))); |
|
69 | 69 | |
70 | 70 | # Process parent block |
71 | 71 | |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | |
125 | 125 | # Redirect if entity not found |
126 | 126 | |
127 | - if (!$this->create && (0 === $this->entity->id)) return Request::redirect(INSTALL_PATH . static::$link); |
|
127 | + if (!$this->create && (0 === $this->entity->id)) return Request::redirect(INSTALL_PATH.static::$link); |
|
128 | 128 | |
129 | 129 | # Create form |
130 | 130 | |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | |
137 | 137 | if ($this->form->handle(new static::$controller($this->entity))) { |
138 | 138 | |
139 | - Request::redirect(INSTALL_PATH . static::$link . '/edit?id=' . $this->entity->id . '&submitted'); |
|
139 | + Request::redirect(INSTALL_PATH.static::$link.'/edit?id='.$this->entity->id.'&submitted'); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | # Display success message |
@@ -2,7 +2,14 @@ |
||
2 | 2 | |
3 | 3 | namespace Modules\Entitizer\Utils { |
4 | 4 | |
5 | - use Modules\Entitizer, Utils\Popup, Utils\View, Ajax, Language, Number, Request, Template; |
|
5 | + use Modules\Entitizer; |
|
6 | + use Utils\Popup; |
|
7 | + use Utils\View; |
|
8 | + use Ajax; |
|
9 | + use Language; |
|
10 | + use Number; |
|
11 | + use Request; |
|
12 | + use Template; |
|
6 | 13 | |
7 | 14 | abstract class Handler { |
8 | 15 |
@@ -45,7 +45,9 @@ discard block |
||
45 | 45 | |
46 | 46 | private function processSelector(Template\Asset\Block $selector) { |
47 | 47 | |
48 | - if ($this->create) return $selector->disable(); |
|
48 | + if ($this->create) { |
|
49 | + return $selector->disable(); |
|
50 | + } |
|
49 | 51 | |
50 | 52 | $selector->parent_id = $this->entity->parent_id; |
51 | 53 | |
@@ -68,25 +70,33 @@ discard block |
||
68 | 70 | |
69 | 71 | # Set path / title |
70 | 72 | |
71 | - if (static::$nesting) $contents->path = $this->path; |
|
72 | - |
|
73 | - else $contents->title = ($this->create ? Language::get(static::$naming_new) : $this->entity->get(static::$naming)); |
|
73 | + if (static::$nesting) { |
|
74 | + $contents->path = $this->path; |
|
75 | + } else { |
|
76 | + $contents->title = ($this->create ? Language::get(static::$naming_new) : $this->entity->get(static::$naming)); |
|
77 | + } |
|
74 | 78 | |
75 | 79 | # Process parent block |
76 | 80 | |
77 | - if (static::$nesting) $this->processParent($contents->block('parent')); |
|
81 | + if (static::$nesting) { |
|
82 | + $this->processParent($contents->block('parent')); |
|
83 | + } |
|
78 | 84 | |
79 | 85 | # Set link |
80 | 86 | |
81 | 87 | $link = (INSTALL_PATH . static::$link . '/'); |
82 | 88 | |
83 | - if (static::$nesting) $contents->link = ($link . ($this->create ? 'create' : 'edit') . '?id=' . $this->parent->id); |
|
84 | - |
|
85 | - else $contents->link = ($link . ($this->create ? 'create' : ('edit?id=' . $this->entity->id))); |
|
89 | + if (static::$nesting) { |
|
90 | + $contents->link = ($link . ($this->create ? 'create' : 'edit') . '?id=' . $this->parent->id); |
|
91 | + } else { |
|
92 | + $contents->link = ($link . ($this->create ? 'create' : ('edit?id=' . $this->entity->id))); |
|
93 | + } |
|
86 | 94 | |
87 | 95 | # Process selector block |
88 | 96 | |
89 | - if (static::$nesting) $this->processSelector($contents->block('selector')); |
|
97 | + if (static::$nesting) { |
|
98 | + $this->processSelector($contents->block('selector')); |
|
99 | + } |
|
90 | 100 | |
91 | 101 | # Implement form |
92 | 102 | |
@@ -119,11 +129,15 @@ discard block |
||
119 | 129 | |
120 | 130 | $parent_id = Number::format(Request::post('parent_id')); |
121 | 131 | |
122 | - if (!$this->entity->move($parent_id)) return $ajax->error(Language::get(static::$message_error_move)); |
|
132 | + if (!$this->entity->move($parent_id)) { |
|
133 | + return $ajax->error(Language::get(static::$message_error_move)); |
|
134 | + } |
|
123 | 135 | |
124 | 136 | } else if (Request::post('action') === 'remove') { |
125 | 137 | |
126 | - if (!$this->entity->remove()) return $ajax->error(Language::get(static::$message_error_remove)); |
|
138 | + if (!$this->entity->remove()) { |
|
139 | + return $ajax->error(Language::get(static::$message_error_remove)); |
|
140 | + } |
|
127 | 141 | } |
128 | 142 | |
129 | 143 | # ------------------------ |
@@ -135,7 +149,9 @@ discard block |
||
135 | 149 | |
136 | 150 | public function handle(bool $create = false) { |
137 | 151 | |
138 | - if (!($this->create = $create) && Request::isAjax()) return $this->handleAjax(); |
|
152 | + if (!($this->create = $create) && Request::isAjax()) { |
|
153 | + return $this->handleAjax(); |
|
154 | + } |
|
139 | 155 | |
140 | 156 | # Create entity |
141 | 157 | |
@@ -143,7 +159,9 @@ discard block |
||
143 | 159 | |
144 | 160 | $this->entity = Entitizer::get(static::$table, (!$this->create ? $id : 0)); |
145 | 161 | |
146 | - if (!$this->create && (0 === $this->entity->id)) return Request::redirect(INSTALL_PATH . static::$link); |
|
162 | + if (!$this->create && (0 === $this->entity->id)) { |
|
163 | + return Request::redirect(INSTALL_PATH . static::$link); |
|
164 | + } |
|
147 | 165 | |
148 | 166 | # Create parent entity |
149 | 167 | |
@@ -151,7 +169,9 @@ discard block |
||
151 | 169 | |
152 | 170 | # Get path |
153 | 171 | |
154 | - if (false !== ($path = $this->parent->path())) $this->path = $path; |
|
172 | + if (false !== ($path = $this->parent->path())) { |
|
173 | + $this->path = $path; |
|
174 | + } |
|
155 | 175 | |
156 | 176 | # Create form |
157 | 177 | |
@@ -161,7 +181,9 @@ discard block |
||
161 | 181 | |
162 | 182 | if ($this->form->handle(new static::$controller($this->entity), true)) { |
163 | 183 | |
164 | - if ($this->create && (0 !== $this->parent->id)) $this->entity->move($this->parent->id); |
|
184 | + if ($this->create && (0 !== $this->parent->id)) { |
|
185 | + $this->entity->move($this->parent->id); |
|
186 | + } |
|
165 | 187 | |
166 | 188 | Request::redirect(INSTALL_PATH . static::$link . '/edit?id=' . $this->entity->id . '&submitted'); |
167 | 189 | } |
@@ -39,16 +39,16 @@ discard block |
||
39 | 39 | |
40 | 40 | if (self::$loaded || empty($host = getenv('HTTP_HOST'))) return; |
41 | 41 | |
42 | - self::$settings['system_url'] = ((Request::isSecure() ? 'https://' : 'http://') . $host); |
|
42 | + self::$settings['system_url'] = ((Request::isSecure() ? 'https://' : 'http://').$host); |
|
43 | 43 | |
44 | - self::$settings['system_email'] = ('admin@' . $host); |
|
44 | + self::$settings['system_email'] = ('admin@'.$host); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | # Init settings |
48 | 48 | |
49 | 49 | public static function init() { |
50 | 50 | |
51 | - $settings_file = (DIR_SYSTEM_DATA . 'Settings.json'); |
|
51 | + $settings_file = (DIR_SYSTEM_DATA.'Settings.json'); |
|
52 | 52 | |
53 | 53 | self::$loaded = (false !== ($settings = Explorer::json($settings_file))); |
54 | 54 | |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | |
64 | 64 | public static function save() { |
65 | 65 | |
66 | - $settings_file = (DIR_SYSTEM_DATA . 'Settings.json'); |
|
66 | + $settings_file = (DIR_SYSTEM_DATA.'Settings.json'); |
|
67 | 67 | |
68 | 68 | if (false === ($settings = json_encode(self::$settings, JSON_PRETTY_PRINT))) return false; |
69 | 69 |
@@ -37,7 +37,9 @@ discard block |
||
37 | 37 | |
38 | 38 | public static function __autoload() { |
39 | 39 | |
40 | - if (self::$loaded || empty($host = getenv('HTTP_HOST'))) return; |
|
40 | + if (self::$loaded || empty($host = getenv('HTTP_HOST'))) { |
|
41 | + return; |
|
42 | + } |
|
41 | 43 | |
42 | 44 | self::$settings['system_url'] = ((Request::isSecure() ? 'https://' : 'http://') . $host); |
43 | 45 | |
@@ -52,7 +54,9 @@ discard block |
||
52 | 54 | |
53 | 55 | self::$loaded = (false !== ($settings = Explorer::json($settings_file))); |
54 | 56 | |
55 | - if (self::$loaded) foreach ($settings as $name => $value) self::set($name, $value); |
|
57 | + if (self::$loaded) { |
|
58 | + foreach ($settings as $name => $value) self::set($name, $value); |
|
59 | + } |
|
56 | 60 | |
57 | 61 | # ------------------------ |
58 | 62 | |
@@ -65,9 +69,13 @@ discard block |
||
65 | 69 | |
66 | 70 | $settings_file = (DIR_SYSTEM_DATA . 'Settings.json'); |
67 | 71 | |
68 | - if (false === ($settings = json_encode(self::$settings, JSON_PRETTY_PRINT))) return false; |
|
72 | + if (false === ($settings = json_encode(self::$settings, JSON_PRETTY_PRINT))) { |
|
73 | + return false; |
|
74 | + } |
|
69 | 75 | |
70 | - if (false === Explorer::save($settings_file, $settings, true)) return false; |
|
76 | + if (false === Explorer::save($settings_file, $settings, true)) { |
|
77 | + return false; |
|
78 | + } |
|
71 | 79 | |
72 | 80 | # ------------------------ |
73 | 81 | |
@@ -85,34 +93,44 @@ discard block |
||
85 | 93 | |
86 | 94 | public static function set(string $name, $value) { |
87 | 95 | |
88 | - if (!isset(self::$settings[$name]) || !is_scalar($value)) return false; |
|
96 | + if (!isset(self::$settings[$name]) || !is_scalar($value)) { |
|
97 | + return false; |
|
98 | + } |
|
89 | 99 | |
90 | 100 | # Validate language |
91 | 101 | |
92 | 102 | if (($name === 'admin_language') || ($name === 'site_language')) { |
93 | 103 | |
94 | - if (false === ($value = Extend\Languages::validate($value))) return false; |
|
104 | + if (false === ($value = Extend\Languages::validate($value))) { |
|
105 | + return false; |
|
106 | + } |
|
95 | 107 | } |
96 | 108 | |
97 | 109 | # Validate template |
98 | 110 | |
99 | 111 | else if (($name === 'admin_template') || ($name === 'site_template')) { |
100 | 112 | |
101 | - if (false === ($value = Extend\Templates::validate($value))) return false; |
|
113 | + if (false === ($value = Extend\Templates::validate($value))) { |
|
114 | + return false; |
|
115 | + } |
|
102 | 116 | } |
103 | 117 | |
104 | 118 | # Validate site title |
105 | 119 | |
106 | 120 | else if ($name === 'site_title') { |
107 | 121 | |
108 | - if ('' === ($value = strval($value))) return false; |
|
122 | + if ('' === ($value = strval($value))) { |
|
123 | + return false; |
|
124 | + } |
|
109 | 125 | } |
110 | 126 | |
111 | 127 | # Validate site status |
112 | 128 | |
113 | 129 | else if ($name === 'site_status') { |
114 | 130 | |
115 | - if (false === ($value = Range\Status::validate($value))) return false; |
|
131 | + if (false === ($value = Range\Status::validate($value))) { |
|
132 | + return false; |
|
133 | + } |
|
116 | 134 | } |
117 | 135 | |
118 | 136 | # Validate site slogan/description/keywords |
@@ -126,21 +144,27 @@ discard block |
||
126 | 144 | |
127 | 145 | else if ($name === 'system_url') { |
128 | 146 | |
129 | - if (false === ($value = Validate::url($value))) return false; |
|
147 | + if (false === ($value = Validate::url($value))) { |
|
148 | + return false; |
|
149 | + } |
|
130 | 150 | } |
131 | 151 | |
132 | 152 | # Validate system email |
133 | 153 | |
134 | 154 | else if ($name === 'system_email') { |
135 | 155 | |
136 | - if (false === ($value = Validate::email($value))) return false; |
|
156 | + if (false === ($value = Validate::email($value))) { |
|
157 | + return false; |
|
158 | + } |
|
137 | 159 | } |
138 | 160 | |
139 | 161 | # Validate system timezone |
140 | 162 | |
141 | 163 | else if ($name === 'system_timezone') { |
142 | 164 | |
143 | - if (false === ($value = Timezone::validate($value))) return false; |
|
165 | + if (false === ($value = Timezone::validate($value))) { |
|
166 | + return false; |
|
167 | + } |
|
144 | 168 | } |
145 | 169 | |
146 | 170 | # Validate users registration |
@@ -163,7 +187,9 @@ discard block |
||
163 | 187 | |
164 | 188 | public static function get(string $name = null) { |
165 | 189 | |
166 | - if (null === $name) return self::$settings; |
|
190 | + if (null === $name) { |
|
191 | + return self::$settings; |
|
192 | + } |
|
167 | 193 | |
168 | 194 | return (isset(self::$settings[$name]) ? self::$settings[$name] : null); |
169 | 195 | } |
@@ -35,7 +35,7 @@ |
||
35 | 35 | |
36 | 36 | if ($this->form->handle(new Settings\Controller\General())) { |
37 | 37 | |
38 | - Request::redirect(INSTALL_PATH . '/admin/system/settings?submitted'); |
|
38 | + Request::redirect(INSTALL_PATH.'/admin/system/settings?submitted'); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | # Display success message |
@@ -40,7 +40,9 @@ |
||
40 | 40 | |
41 | 41 | # Display success message |
42 | 42 | |
43 | - if (false !== Request::get('submitted')) Popup::set('positive', Language::get('SETTINGS_SUCCESS')); |
|
43 | + if (false !== Request::get('submitted')) { |
|
44 | + Popup::set('positive', Language::get('SETTINGS_SUCCESS')); |
|
45 | + } |
|
44 | 46 | |
45 | 47 | # ------------------------ |
46 | 48 |
@@ -45,7 +45,7 @@ |
||
45 | 45 | |
46 | 46 | if ($this->form_personal->handle($controller_personal) || $this->form_password->handle($controller_password)) { |
47 | 47 | |
48 | - Request::redirect(INSTALL_PATH . '/profile/edit?submitted'); |
|
48 | + Request::redirect(INSTALL_PATH.'/profile/edit?submitted'); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | # Display success message |
@@ -50,7 +50,9 @@ |
||
50 | 50 | |
51 | 51 | # Display success message |
52 | 52 | |
53 | - if (false !== Request::get('submitted')) Messages::set('success', Language::get('USER_SUCCESS_EDIT')); |
|
53 | + if (false !== Request::get('submitted')) { |
|
54 | + Messages::set('success', Language::get('USER_SUCCESS_EDIT')); |
|
55 | + } |
|
54 | 56 | |
55 | 57 | # ------------------------ |
56 | 58 |