@@ -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 | |
@@ -14,7 +14,7 @@ |
||
| 14 | 14 | |
| 15 | 15 | if (null === ($data = Schema::get('System')->load())) { |
| 16 | 16 | |
| 17 | - Request::redirect(INSTALL_PATH . '/install.php'); |
|
| 17 | + Request::redirect(INSTALL_PATH.'/install.php'); |
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | # Connect to database |
@@ -34,10 +34,12 @@ discard block |
||
| 34 | 34 | |
| 35 | 35 | $phrases = array_merge(static::PHRASES, array_keys(Extend\Addons::items() ?? [])); |
| 36 | 36 | |
| 37 | - foreach (array_unique($languages) as $path) foreach ($phrases as $name) { |
|
| 37 | + foreach (array_unique($languages) as $path) { |
|
| 38 | + foreach ($phrases as $name) { |
|
| 38 | 39 | |
| 39 | 40 | Language::load($path . 'Phrases/' . $name . '.php'); |
| 40 | 41 | } |
| 42 | + } |
|
| 41 | 43 | |
| 42 | 44 | # Set template globals |
| 43 | 45 | |
@@ -59,7 +61,9 @@ discard block |
||
| 59 | 61 | |
| 60 | 62 | # Set timezone |
| 61 | 63 | |
| 62 | - if (Auth::check() && ('' !== ($timezone = Auth::user()->timezone))) date_default_timezone_set($timezone); |
|
| 64 | + if (Auth::check() && ('' !== ($timezone = Auth::user()->timezone))) { |
|
| 65 | + date_default_timezone_set($timezone); |
|
| 66 | + } |
|
| 63 | 67 | |
| 64 | 68 | # ------------------------ |
| 65 | 69 | |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | |
| 35 | 35 | foreach (array_unique($languages) as $path) foreach ($phrases as $name) { |
| 36 | 36 | |
| 37 | - Language::load($path . 'Phrases/' . $name . '.php'); |
|
| 37 | + Language::load($path.'Phrases/'.$name.'.php'); |
|
| 38 | 38 | } |
| 39 | 39 | } |
| 40 | 40 | |
@@ -44,24 +44,24 @@ discard block |
||
| 44 | 44 | |
| 45 | 45 | private function setGlobals() { |
| 46 | 46 | |
| 47 | - Template::setGlobal('cadmium_home', CADMIUM_HOME); |
|
| 48 | - Template::setGlobal('cadmium_copy', CADMIUM_COPY); |
|
| 49 | - Template::setGlobal('cadmium_name', CADMIUM_NAME); |
|
| 50 | - Template::setGlobal('cadmium_version', CADMIUM_VERSION); |
|
| 47 | + Template::setGlobal('cadmium_home', CADMIUM_HOME); |
|
| 48 | + Template::setGlobal('cadmium_copy', CADMIUM_COPY); |
|
| 49 | + Template::setGlobal('cadmium_name', CADMIUM_NAME); |
|
| 50 | + Template::setGlobal('cadmium_version', CADMIUM_VERSION); |
|
| 51 | 51 | |
| 52 | - Template::setGlobal('template_name', strtolower(Extend\Templates::active())); |
|
| 52 | + Template::setGlobal('template_name', strtolower(Extend\Templates::active())); |
|
| 53 | 53 | |
| 54 | - Template::setGlobal('site_title', Settings::get('site_title')); |
|
| 55 | - Template::setGlobal('site_slogan', Settings::get('site_slogan')); |
|
| 54 | + Template::setGlobal('site_title', Settings::get('site_title')); |
|
| 55 | + Template::setGlobal('site_slogan', Settings::get('site_slogan')); |
|
| 56 | 56 | |
| 57 | - Template::setGlobal('system_url', Settings::get('system_url')); |
|
| 58 | - Template::setGlobal('system_email', Settings::get('system_email')); |
|
| 57 | + Template::setGlobal('system_url', Settings::get('system_url')); |
|
| 58 | + Template::setGlobal('system_email', Settings::get('system_email')); |
|
| 59 | 59 | |
| 60 | - Template::setGlobal('install_path', INSTALL_PATH); |
|
| 60 | + Template::setGlobal('install_path', INSTALL_PATH); |
|
| 61 | 61 | |
| 62 | - Template::setGlobal('index_page', (('' !== INSTALL_PATH) ? INSTALL_PATH : '/')); |
|
| 62 | + Template::setGlobal('index_page', (('' !== INSTALL_PATH) ? INSTALL_PATH : '/')); |
|
| 63 | 63 | |
| 64 | - Template::setGlobal('current_year', Date::getYear()); |
|
| 64 | + Template::setGlobal('current_year', Date::getYear()); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** |
@@ -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 | |
@@ -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 | |