@@ -44,7 +44,7 @@ |
||
44 | 44 | |
45 | 45 | public function __construct(Form $form, string $key, string $value = '', |
46 | 46 | |
47 | - array $options = [], string $default = null, array $config = []) { |
|
47 | + array $options = [], string $default = null, array $config = []) { |
|
48 | 48 | |
49 | 49 | # Init field |
50 | 50 |
@@ -148,7 +148,7 @@ |
||
148 | 148 | /** |
149 | 149 | * Set a value |
150 | 150 | * |
151 | - * @return true if the result value is not empty, otherwise false |
|
151 | + * @return boolean if the result value is not empty, otherwise false |
|
152 | 152 | */ |
153 | 153 | |
154 | 154 | public function setValue(string $value) { |
@@ -9,7 +9,9 @@ |
||
9 | 9 | |
10 | 10 | namespace Form\Field { |
11 | 11 | |
12 | - use Form, Tag, Template; |
|
12 | + use Form; |
|
13 | + use Tag; |
|
14 | + use Template; |
|
13 | 15 | |
14 | 16 | class Select extends Form\Field { |
15 | 17 |
@@ -77,9 +77,13 @@ discard block |
||
77 | 77 | |
78 | 78 | # Set appearance |
79 | 79 | |
80 | - if ($this->search) $tag->setAttribute('data-search', 'search'); |
|
80 | + if ($this->search) { |
|
81 | + $tag->setAttribute('data-search', 'search'); |
|
82 | + } |
|
81 | 83 | |
82 | - if ($this->auto) $tag->setAttribute('data-auto', 'auto'); |
|
84 | + if ($this->auto) { |
|
85 | + $tag->setAttribute('data-auto', 'auto'); |
|
86 | + } |
|
83 | 87 | |
84 | 88 | # Set options |
85 | 89 | |
@@ -87,7 +91,9 @@ discard block |
||
87 | 91 | |
88 | 92 | $option = (new Tag('option', [], $text))->setAttribute('value', $value); |
89 | 93 | |
90 | - if ($this->value === $value) $option->setAttribute('selected', ''); |
|
94 | + if ($this->value === $value) { |
|
95 | + $option->setAttribute('selected', ''); |
|
96 | + } |
|
91 | 97 | |
92 | 98 | $options->addItem($option->getBlock()); |
93 | 99 | } |
@@ -105,7 +105,7 @@ |
||
105 | 105 | |
106 | 106 | public function __construct(Form $form, string $key, string $value = '', |
107 | 107 | |
108 | - string $type = FORM_FIELD_TEXT, int $maxlength = 0, array $config = []) { |
|
108 | + string $type = FORM_FIELD_TEXT, int $maxlength = 0, array $config = []) { |
|
109 | 109 | |
110 | 110 | # Init field |
111 | 111 |
@@ -148,7 +148,7 @@ |
||
148 | 148 | /** |
149 | 149 | * Set a value |
150 | 150 | * |
151 | - * @return true if the result value is not empty, otherwise false |
|
151 | + * @return boolean if the result value is not empty, otherwise false |
|
152 | 152 | */ |
153 | 153 | |
154 | 154 | public function setValue(string $value) { |
@@ -9,7 +9,10 @@ |
||
9 | 9 | |
10 | 10 | namespace Form\Field { |
11 | 11 | |
12 | - use Form, Str, Tag, Template; |
|
12 | + use Form; |
|
13 | + use Str; |
|
14 | + use Tag; |
|
15 | + use Template; |
|
13 | 16 | |
14 | 17 | class Text extends Form\Field { |
15 | 18 |
@@ -82,9 +82,13 @@ discard block |
||
82 | 82 | |
83 | 83 | $tag = $this->getTag('textarea', [], $this->value); |
84 | 84 | |
85 | - if ($this->rows > 0) $tag->setAttribute('rows', $this->rows); |
|
85 | + if ($this->rows > 0) { |
|
86 | + $tag->setAttribute('rows', $this->rows); |
|
87 | + } |
|
86 | 88 | |
87 | - if ($this->cols > 0) $tag->setAttribute('cols', $this->cols); |
|
89 | + if ($this->cols > 0) { |
|
90 | + $tag->setAttribute('cols', $this->cols); |
|
91 | + } |
|
88 | 92 | |
89 | 93 | # ------------------------ |
90 | 94 | |
@@ -97,9 +101,11 @@ discard block |
||
97 | 101 | |
98 | 102 | private function processSpaces() { |
99 | 103 | |
100 | - if ($this->spaces === 'strip') $this->value = Str::stripSpaces($this->value); |
|
101 | - |
|
102 | - else if ($this->spaces === 'single') $this->value = Str::singleSpaces($this->value); |
|
104 | + if ($this->spaces === 'strip') { |
|
105 | + $this->value = Str::stripSpaces($this->value); |
|
106 | + } else if ($this->spaces === 'single') { |
|
107 | + $this->value = Str::singleSpaces($this->value); |
|
108 | + } |
|
103 | 109 | } |
104 | 110 | |
105 | 111 | /** |
@@ -108,9 +114,11 @@ discard block |
||
108 | 114 | |
109 | 115 | private function processConvert() { |
110 | 116 | |
111 | - if ($this->convert === 'url') $this->value = Str::toUrl($this->value, $this->maxlength); |
|
112 | - |
|
113 | - else if ($this->convert === 'var') $this->value = Str::toVar($this->value, $this->maxlength); |
|
117 | + if ($this->convert === 'url') { |
|
118 | + $this->value = Str::toUrl($this->value, $this->maxlength); |
|
119 | + } else if ($this->convert === 'var') { |
|
120 | + $this->value = Str::toVar($this->value, $this->maxlength); |
|
121 | + } |
|
114 | 122 | } |
115 | 123 | |
116 | 124 | /** |
@@ -119,9 +127,11 @@ discard block |
||
119 | 127 | |
120 | 128 | private function processTransform() { |
121 | 129 | |
122 | - if ($this->transform === 'lower') $this->value = Str::toLower($this->value); |
|
123 | - |
|
124 | - else if ($this->transform === 'upper') $this->value = Str::toUpper($this->value); |
|
130 | + if ($this->transform === 'lower') { |
|
131 | + $this->value = Str::toLower($this->value); |
|
132 | + } else if ($this->transform === 'upper') { |
|
133 | + $this->value = Str::toUpper($this->value); |
|
134 | + } |
|
125 | 135 | } |
126 | 136 | |
127 | 137 | /** |
@@ -183,27 +193,39 @@ discard block |
||
183 | 193 | |
184 | 194 | # Process hidden field |
185 | 195 | |
186 | - if ($this->type === FORM_FIELD_HIDDEN) return $this->getHidden()->getBlock(); |
|
196 | + if ($this->type === FORM_FIELD_HIDDEN) { |
|
197 | + return $this->getHidden()->getBlock(); |
|
198 | + } |
|
187 | 199 | |
188 | 200 | # Process visible field |
189 | 201 | |
190 | - else if ($this->type === FORM_FIELD_PASSWORD) $tag = $this->getPassword(); |
|
191 | - |
|
192 | - else if ($this->type === FORM_FIELD_CAPTCHA) $tag = $this->getCaptcha(); |
|
193 | - |
|
194 | - else if ($this->type === FORM_FIELD_TEXTAREA) $tag = $this->getTextarea(); |
|
195 | - |
|
196 | - else $tag = $this->getText(); |
|
202 | + else if ($this->type === FORM_FIELD_PASSWORD) { |
|
203 | + $tag = $this->getPassword(); |
|
204 | + } else if ($this->type === FORM_FIELD_CAPTCHA) { |
|
205 | + $tag = $this->getCaptcha(); |
|
206 | + } else if ($this->type === FORM_FIELD_TEXTAREA) { |
|
207 | + $tag = $this->getTextarea(); |
|
208 | + } else { |
|
209 | + $tag = $this->getText(); |
|
210 | + } |
|
197 | 211 | |
198 | 212 | # Set appearance |
199 | 213 | |
200 | - if ($this->maxlength > 0) $tag->setAttribute('maxlength', $this->maxlength); |
|
214 | + if ($this->maxlength > 0) { |
|
215 | + $tag->setAttribute('maxlength', $this->maxlength); |
|
216 | + } |
|
201 | 217 | |
202 | - if ('' !== $this->placeholder) $tag->setAttribute('placeholder', $this->placeholder); |
|
218 | + if ('' !== $this->placeholder) { |
|
219 | + $tag->setAttribute('placeholder', $this->placeholder); |
|
220 | + } |
|
203 | 221 | |
204 | - if ($this->readonly) $tag->setAttribute('readonly', 'readonly'); |
|
222 | + if ($this->readonly) { |
|
223 | + $tag->setAttribute('readonly', 'readonly'); |
|
224 | + } |
|
205 | 225 | |
206 | - if ($this->autofocus) $tag->setAttribute('autofocus', 'autofocus'); |
|
226 | + if ($this->autofocus) { |
|
227 | + $tag->setAttribute('autofocus', 'autofocus'); |
|
228 | + } |
|
207 | 229 | |
208 | 230 | # ------------------------ |
209 | 231 |
@@ -31,7 +31,9 @@ |
||
31 | 31 | |
32 | 32 | public static function delete(string $name) { |
33 | 33 | |
34 | - if (isset($_COOKIE[$name])) unset($_COOKIE[$name]); |
|
34 | + if (isset($_COOKIE[$name])) { |
|
35 | + unset($_COOKIE[$name]); |
|
36 | + } |
|
35 | 37 | } |
36 | 38 | } |
37 | 39 | } |
@@ -10,7 +10,9 @@ |
||
10 | 10 | |
11 | 11 | private static function checkType(string $extension, string $type) { |
12 | 12 | |
13 | - if (false === ($mime = self::get($extension))) return false; |
|
13 | + if (false === ($mime = self::get($extension))) { |
|
14 | + return false; |
|
15 | + } |
|
14 | 16 | |
15 | 17 | return (preg_match('/^' . $type . '\//', $mime) ? true : false); |
16 | 18 | } |
@@ -12,14 +12,14 @@ |
||
12 | 12 | |
13 | 13 | if (false === ($mime = self::get($extension))) return false; |
14 | 14 | |
15 | - return (preg_match(('/^' . $type . '\//'), $mime) ? true : false); |
|
15 | + return (preg_match(('/^'.$type.'\//'), $mime) ? true : false); |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | # Autoloader |
19 | 19 | |
20 | 20 | public static function __autoload() { |
21 | 21 | |
22 | - self::init(DIR_DATA . 'Mime.php'); |
|
22 | + self::init(DIR_DATA.'Mime.php'); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | # Check if extension is image |
@@ -8,7 +8,9 @@ |
||
8 | 8 | |
9 | 9 | private static function output($image, string $mime, callable $outputter, array $params = []) { |
10 | 10 | |
11 | - if (!is_resource($image)) return false; |
|
11 | + if (!is_resource($image)) { |
|
12 | + return false; |
|
13 | + } |
|
12 | 14 | |
13 | 15 | Headers::nocache(); Headers::content($mime); |
14 | 16 |
@@ -2,10 +2,10 @@ |
||
2 | 2 | |
3 | 3 | # Mime types |
4 | 4 | |
5 | -define('MIME_TYPE_HTML', 'html'); |
|
6 | -define('MIME_TYPE_XML', 'xml'); |
|
7 | -define('MIME_TYPE_JSON', 'json'); |
|
5 | +define('MIME_TYPE_HTML', 'html'); |
|
6 | +define('MIME_TYPE_XML', 'xml'); |
|
7 | +define('MIME_TYPE_JSON', 'json'); |
|
8 | 8 | |
9 | -define('MIME_TYPE_JPEG', 'jpeg'); |
|
10 | -define('MIME_TYPE_PNG', 'png'); |
|
11 | -define('MIME_TYPE_GIF', 'gif'); |
|
9 | +define('MIME_TYPE_JPEG', 'jpeg'); |
|
10 | +define('MIME_TYPE_PNG', 'png'); |
|
11 | +define('MIME_TYPE_GIF', 'gif'); |
@@ -32,28 +32,28 @@ |
||
32 | 32 | |
33 | 33 | # Class load exception |
34 | 34 | |
35 | - class ClassLoad extends Exception { |
|
35 | + class ClassLoad extends Exception { |
|
36 | 36 | |
37 | 37 | protected $message = 'Class \'$value$\' not found'; |
38 | 38 | } |
39 | 39 | |
40 | 40 | # Database connect exception |
41 | 41 | |
42 | - class DBConnect extends Exception { |
|
42 | + class DBConnect extends Exception { |
|
43 | 43 | |
44 | 44 | protected $message = 'Unable to connect to database'; |
45 | 45 | } |
46 | 46 | |
47 | 47 | # Database select exception |
48 | 48 | |
49 | - class DBSelect extends Exception { |
|
49 | + class DBSelect extends Exception { |
|
50 | 50 | |
51 | 51 | protected $message = 'Unable to select database'; |
52 | 52 | } |
53 | 53 | |
54 | 54 | # Database charset exception |
55 | 55 | |
56 | - class DBCharset extends Exception { |
|
56 | + class DBCharset extends Exception { |
|
57 | 57 | |
58 | 58 | protected $message = 'Unable to set database charset'; |
59 | 59 | } |
@@ -26,7 +26,9 @@ |
||
26 | 26 | |
27 | 27 | public function __construct(string $message = '') { |
28 | 28 | |
29 | - if ('' !== $message) $this->message = $message; |
|
29 | + if ('' !== $message) { |
|
30 | + $this->message = $message; |
|
31 | + } |
|
30 | 32 | } |
31 | 33 | } |
32 | 34 |
@@ -2,7 +2,13 @@ |
||
2 | 2 | |
3 | 3 | namespace Modules\Auth\Utils { |
4 | 4 | |
5 | - use Modules\Auth, Modules\Entitizer, Modules\Settings, Utils\View, Date, Language, Mailer; |
|
5 | + use Modules\Auth; |
|
6 | + use Modules\Entitizer; |
|
7 | + use Modules\Settings; |
|
8 | + use Utils\View; |
|
9 | + use Date; |
|
10 | + use Language; |
|
11 | + use Mailer; |
|
6 | 12 | |
7 | 13 | abstract class Mail { |
8 | 14 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | |
11 | 11 | private static function send(Entitizer\Entity\User $user, string $view, string $subject, string $link) { |
12 | 12 | |
13 | - $message = View::get((Auth::admin() ? 'Blocks/Auth/Mail/' : 'Blocks/Profile/Auth/Mail/') . $view); |
|
13 | + $message = View::get((Auth::admin() ? 'Blocks/Auth/Mail/' : 'Blocks/Profile/Auth/Mail/').$view); |
|
14 | 14 | |
15 | 15 | $message->name = $user->name; $message->link = $link; $message->copyright = Date::getYear(); |
16 | 16 | |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | |
19 | 19 | $to = $user->email; $sender = Settings::get('site_title'); $reply_to = Settings::get('system_email'); |
20 | 20 | |
21 | - $from = ((false !== ($host = parse_url(Settings::get('system_url'), PHP_URL_HOST))) ? ('noreply@' . $host) : ''); |
|
21 | + $from = ((false !== ($host = parse_url(Settings::get('system_url'), PHP_URL_HOST))) ? ('noreply@'.$host) : ''); |
|
22 | 22 | |
23 | 23 | return Mailer::send($to, $sender, $from, $reply_to, $subject, $message->getContents(), true); |
24 | 24 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | |
28 | 28 | public static function reset(Entitizer\Entity\User $user, string $code) { |
29 | 29 | |
30 | - $link = (Settings::get('system_url') . (Auth::admin() ? '/admin' : '/profile') . '/recover?code=' . $code); |
|
30 | + $link = (Settings::get('system_url').(Auth::admin() ? '/admin' : '/profile').'/recover?code='.$code); |
|
31 | 31 | |
32 | 32 | return self::send($user, 'Reset', Language::get('MAIL_SUBJECT_RESET'), $link); |
33 | 33 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | |
37 | 37 | public static function register(Entitizer\Entity\User $user) { |
38 | 38 | |
39 | - $link = (Settings::get('system_url') . (Auth::admin() ? '/admin' : '/profile')); |
|
39 | + $link = (Settings::get('system_url').(Auth::admin() ? '/admin' : '/profile')); |
|
40 | 40 | |
41 | 41 | return self::send($user, 'Register', Language::get('MAIL_SUBJECT_REGISTER'), $link); |
42 | 42 | } |
@@ -2,7 +2,8 @@ |
||
2 | 2 | |
3 | 3 | namespace Modules\Entitizer\Form { |
4 | 4 | |
5 | - use Modules\Entitizer, Utils\Form; |
|
5 | + use Modules\Entitizer; |
|
6 | + use Utils\Form; |
|
6 | 7 | |
7 | 8 | class Widget extends Form { |
8 | 9 |