@@ -31,9 +31,9 @@ |
||
| 31 | 31 | |
| 32 | 32 | if (preg_match(REGEX_FORM_FIELD_KEY, $key)) { |
| 33 | 33 | |
| 34 | - $prefix = (('' !== $this->form->getName()) ? ($this->form->getName() . '_') : ''); |
|
| 34 | + $prefix = (('' !== $this->form->getName()) ? ($this->form->getName().'_') : ''); |
|
| 35 | 35 | |
| 36 | - $this->key = $key; $this->name = ($prefix . $key); $this->id = str_replace('_', '-', $this->name); |
|
| 36 | + $this->key = $key; $this->name = ($prefix.$key); $this->id = str_replace('_', '-', $this->name); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | # Set configuration |
@@ -57,11 +57,17 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | # Set appearance |
| 59 | 59 | |
| 60 | - if ($this->disabled) $data['disabled'] = 'disabled'; |
|
| 60 | + if ($this->disabled) { |
|
| 61 | + $data['disabled'] = 'disabled'; |
|
| 62 | + } |
|
| 61 | 63 | |
| 62 | - if ($this->required) $data['data-required'] = 'required'; |
|
| 64 | + if ($this->required) { |
|
| 65 | + $data['data-required'] = 'required'; |
|
| 66 | + } |
|
| 63 | 67 | |
| 64 | - if ($this->error) $data['data-error'] = 'error'; |
|
| 68 | + if ($this->error) { |
|
| 69 | + $data['data-error'] = 'error'; |
|
| 70 | + } |
|
| 65 | 71 | |
| 66 | 72 | # ------------------------ |
| 67 | 73 | |
@@ -76,7 +82,9 @@ discard block |
||
| 76 | 82 | |
| 77 | 83 | public function post() : bool { |
| 78 | 84 | |
| 79 | - if ($this->posted || $this->disabled || ('' === $this->key)) return false; |
|
| 85 | + if ($this->posted || $this->disabled || ('' === $this->key)) { |
|
| 86 | + return false; |
|
| 87 | + } |
|
| 80 | 88 | |
| 81 | 89 | $this->error = (!$this->setValue(Request::post($this->name)) && $this->required); |
| 82 | 90 | |
@@ -41,7 +41,9 @@ discard block |
||
| 41 | 41 | |
| 42 | 42 | public static function load(string $file_name) { |
| 43 | 43 | |
| 44 | - if (false === ($contents = Explorer::getContents($file_name))) return null; |
|
| 44 | + if (false === ($contents = Explorer::getContents($file_name))) { |
|
| 45 | + return null; |
|
| 46 | + } |
|
| 45 | 47 | |
| 46 | 48 | return self::parse($contents); |
| 47 | 49 | } |
@@ -54,7 +56,9 @@ discard block |
||
| 54 | 56 | |
| 55 | 57 | public static function save(string $file_name, $value) { |
| 56 | 58 | |
| 57 | - if (false === ($value = self::stringify($value))) return false; |
|
| 59 | + if (false === ($value = self::stringify($value))) { |
|
| 60 | + return false; |
|
| 61 | + } |
|
| 58 | 62 | |
| 59 | 63 | return Explorer::putContents($file_name, $value); |
| 60 | 64 | } |
@@ -2,16 +2,16 @@ |
||
| 2 | 2 | |
| 3 | 3 | # Regular expressions |
| 4 | 4 | |
| 5 | -define('REGEX_MAP_ITEM_PATH', '/^[a-zA-Z0-9_\-\+\.\,\'\*\(\)\[\]:;!$%~]+$/'); |
|
| 6 | -define('REGEX_MAP_ITEM_HANDLER', '/^[A-Z][a-zA-Z0-9]*$/'); |
|
| 5 | +define('REGEX_MAP_ITEM_PATH', '/^[a-zA-Z0-9_\-\+\.\,\'\*\(\)\[\]:;!$%~]+$/'); |
|
| 6 | +define('REGEX_MAP_ITEM_HANDLER', '/^[A-Z][a-zA-Z0-9]*$/'); |
|
| 7 | 7 | |
| 8 | -define('REGEX_ADDON_NAME', '/^[A-Z0-9][a-zA-Z0-9]*$/'); |
|
| 9 | -define('REGEX_LANGUAGE_NAME', '/^[a-z][a-z]-[A-Z][A-Z]$/'); |
|
| 10 | -define('REGEX_TEMPLATE_NAME', '/^[A-Z0-9][a-zA-Z0-9]*$/'); |
|
| 8 | +define('REGEX_ADDON_NAME', '/^[A-Z0-9][a-zA-Z0-9]*$/'); |
|
| 9 | +define('REGEX_LANGUAGE_NAME', '/^[a-z][a-z]-[A-Z][A-Z]$/'); |
|
| 10 | +define('REGEX_TEMPLATE_NAME', '/^[A-Z0-9][a-zA-Z0-9]*$/'); |
|
| 11 | 11 | |
| 12 | -define('REGEX_USER_AUTH_CODE', '/^[a-zA-Z0-9]{40}$/'); |
|
| 12 | +define('REGEX_USER_AUTH_CODE', '/^[a-zA-Z0-9]{40}$/'); |
|
| 13 | 13 | |
| 14 | -define('REGEX_USER_NAME', '/^(?!_)(?!.*_$)(?!.*_{2,})[a-zA-Z0-9_]+$/'); |
|
| 15 | -define('REGEX_USER_PASSWORD', '/^.+$/'); |
|
| 14 | +define('REGEX_USER_NAME', '/^(?!_)(?!.*_$)(?!.*_{2,})[a-zA-Z0-9_]+$/'); |
|
| 15 | +define('REGEX_USER_PASSWORD', '/^.+$/'); |
|
| 16 | 16 | |
| 17 | -define('REGEX_FILE_NAME', '/^[^\/?%*:|"<>\\\]+$/'); |
|
| 17 | +define('REGEX_FILE_NAME', '/^[^\/?%*:|"<>\\\]+$/'); |
|
@@ -35,7 +35,7 @@ |
||
| 35 | 35 | |
| 36 | 36 | # Handle form |
| 37 | 37 | |
| 38 | - if ($this->form->handle(new Controller)) Request::redirect(INSTALL_PATH . '/contact?submitted'); |
|
| 38 | + if ($this->form->handle(new Controller)) Request::redirect(INSTALL_PATH.'/contact?submitted'); |
|
| 39 | 39 | |
| 40 | 40 | # Display success message |
| 41 | 41 | |
@@ -35,11 +35,15 @@ |
||
| 35 | 35 | |
| 36 | 36 | # Handle form |
| 37 | 37 | |
| 38 | - if ($this->form->handle(new Controller)) Request::redirect(INSTALL_PATH . '/contact?submitted'); |
|
| 38 | + if ($this->form->handle(new Controller)) { |
|
| 39 | + Request::redirect(INSTALL_PATH . '/contact?submitted'); |
|
| 40 | + } |
|
| 39 | 41 | |
| 40 | 42 | # Display success message |
| 41 | 43 | |
| 42 | - if (false !== Request::get('submitted')) Messages::set('success', Language::get('CONTACT_SUCCESS_SEND')); |
|
| 44 | + if (false !== Request::get('submitted')) { |
|
| 45 | + Messages::set('success', Language::get('CONTACT_SUCCESS_SEND')); |
|
| 46 | + } |
|
| 43 | 47 | |
| 44 | 48 | # ------------------------ |
| 45 | 49 | |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | |
| 27 | 27 | # Send mail |
| 28 | 28 | |
| 29 | - $to = Settings::get('system_email'); $subject = (Settings::get('site_title') . ' | Contact form message'); |
|
| 29 | + $to = Settings::get('system_email'); $subject = (Settings::get('site_title').' | Contact form message'); |
|
| 30 | 30 | |
| 31 | 31 | if (!Mailer::send($to, $name, $email, $email, $subject, $message)) return 'CONTACT_ERROR_SEND'; |
| 32 | 32 | |
@@ -20,15 +20,21 @@ |
||
| 20 | 20 | |
| 21 | 21 | # Validate values |
| 22 | 22 | |
| 23 | - if (false === ($email = Validate::userEmail($email))) return ['email', 'CONTACT_ERROR_EMAIL_INVALID']; |
|
| 23 | + if (false === ($email = Validate::userEmail($email))) { |
|
| 24 | + return ['email', 'CONTACT_ERROR_EMAIL_INVALID']; |
|
| 25 | + } |
|
| 24 | 26 | |
| 25 | - if (false === Security::checkCaptcha($captcha)) return ['captcha', 'CONTACT_ERROR_CAPTCHA_INCORRECT']; |
|
| 27 | + if (false === Security::checkCaptcha($captcha)) { |
|
| 28 | + return ['captcha', 'CONTACT_ERROR_CAPTCHA_INCORRECT']; |
|
| 29 | + } |
|
| 26 | 30 | |
| 27 | 31 | # Send mail |
| 28 | 32 | |
| 29 | 33 | $to = Settings::get('system_email'); $subject = (Settings::get('site_title') . ' | Contact form message'); |
| 30 | 34 | |
| 31 | - if (!Mailer::send($to, $name, $email, $email, $subject, $message)) return 'CONTACT_ERROR_SEND'; |
|
| 35 | + if (!Mailer::send($to, $name, $email, $email, $subject, $message)) { |
|
| 36 | + return 'CONTACT_ERROR_SEND'; |
|
| 37 | + } |
|
| 32 | 38 | |
| 33 | 39 | # ------------------------ |
| 34 | 40 | |
@@ -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 | |
@@ -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 | |
@@ -21,7 +21,7 @@ |
||
| 21 | 21 | |
| 22 | 22 | if (false === ($path = Extend\Templates::path())) throw new Exception\View; |
| 23 | 23 | |
| 24 | - if (!isset(self::$cache[$file_name = ($path . $name . '.tpl')])) { |
|
| 24 | + if (!isset(self::$cache[$file_name = ($path.$name.'.tpl')])) { |
|
| 25 | 25 | |
| 26 | 26 | if (false === ($contents = Explorer::getContents($file_name))) throw new Exception\ViewFile($file_name); |
| 27 | 27 | |
@@ -30,11 +30,15 @@ |
||
| 30 | 30 | |
| 31 | 31 | public static function get(string $name) : Template\Block { |
| 32 | 32 | |
| 33 | - if (false === ($path = Extend\Templates::path())) throw new Exception\View; |
|
| 33 | + if (false === ($path = Extend\Templates::path())) { |
|
| 34 | + throw new Exception\View; |
|
| 35 | + } |
|
| 34 | 36 | |
| 35 | 37 | if (!isset(self::$cache[$file_name = ($path . $name . '.tpl')])) { |
| 36 | 38 | |
| 37 | - if (false === ($contents = Explorer::getContents($file_name))) throw new Exception\ViewFile($file_name); |
|
| 39 | + if (false === ($contents = Explorer::getContents($file_name))) { |
|
| 40 | + throw new Exception\ViewFile($file_name); |
|
| 41 | + } |
|
| 38 | 42 | |
| 39 | 43 | self::$cache[$file_name] = Template::createBlock($contents); |
| 40 | 44 | } |