@@ -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 | |
@@ -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 | |
@@ -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,9 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | # Check PHP version |
| 4 | 4 | |
| 5 | -if (version_compare(PHP_VERSION, '7.0.0') < 0) exit('PHP version 7 or higher is required.'); |
|
| 5 | +if (version_compare(PHP_VERSION, '7.0.0') < 0) { |
|
| 6 | + exit('PHP version 7 or higher is required.'); |
|
| 7 | +} |
|
| 6 | 8 | |
| 7 | 9 | # Set error reporting |
| 8 | 10 | |
@@ -37,9 +39,11 @@ discard block |
||
| 37 | 39 | |
| 38 | 40 | # Require class file |
| 39 | 41 | |
| 40 | - if (@file_exists($file_name = ($path . '.php')) && @is_file($file_name)) require_once $file_name; |
|
| 41 | - |
|
| 42 | - else if (@file_exists($file_name = ($path . '/' . $last . '.php')) && @is_file($file_name)) require_once $file_name; |
|
| 42 | + if (@file_exists($file_name = ($path . '.php')) && @is_file($file_name)) { |
|
| 43 | + require_once $file_name; |
|
| 44 | + } else if (@file_exists($file_name = ($path . '/' . $last . '.php')) && @is_file($file_name)) { |
|
| 45 | + require_once $file_name; |
|
| 46 | + } |
|
| 43 | 47 | |
| 44 | 48 | # Check if class exists |
| 45 | 49 | |
@@ -50,5 +54,7 @@ discard block |
||
| 50 | 54 | |
| 51 | 55 | # Call autoload method |
| 52 | 56 | |
| 53 | - if (method_exists($class_name, '__autoload')) $class_name::__autoload(); |
|
| 54 | -}); |
|
| 57 | + if (method_exists($class_name, '__autoload')) { |
|
| 58 | + $class_name::__autoload(); |
|
| 59 | + } |
|
| 60 | + }); |
|
@@ -10,18 +10,18 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | # Define constants |
| 12 | 12 | |
| 13 | -define('DIR_ENGINE', (dirname(__FILE__) . '/')); |
|
| 13 | +define('DIR_ENGINE', (dirname(__FILE__).'/')); |
|
| 14 | 14 | |
| 15 | -define('DIR_WWW', (DIR_ENGINE . '../')); |
|
| 16 | -define('DIR_UPLOADS', (DIR_ENGINE . '../uploads/')); |
|
| 15 | +define('DIR_WWW', (DIR_ENGINE.'../')); |
|
| 16 | +define('DIR_UPLOADS', (DIR_ENGINE.'../uploads/')); |
|
| 17 | 17 | |
| 18 | 18 | # Require framework main file |
| 19 | 19 | |
| 20 | -require_once(DIR_ENGINE . 'Framework/Main.php'); |
|
| 20 | +require_once(DIR_ENGINE.'Framework/Main.php'); |
|
| 21 | 21 | |
| 22 | 22 | # Require system main file |
| 23 | 23 | |
| 24 | -require_once(DIR_ENGINE . 'System/Main.php'); |
|
| 24 | +require_once(DIR_ENGINE.'System/Main.php'); |
|
| 25 | 25 | |
| 26 | 26 | # Register classes autoloader |
| 27 | 27 | |
@@ -33,13 +33,13 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | $system_classes = ['Frames', 'Handlers', 'Modules', 'Utils', 'Views', 'Dispatcher', 'Installer']; |
| 35 | 35 | |
| 36 | - $path = ((in_array($path[0], $system_classes, true) ? DIR_SYSTEM_CLASSES : DIR_CLASSES) . implode('/', $path)); |
|
| 36 | + $path = ((in_array($path[0], $system_classes, true) ? DIR_SYSTEM_CLASSES : DIR_CLASSES).implode('/', $path)); |
|
| 37 | 37 | |
| 38 | 38 | # Require class file |
| 39 | 39 | |
| 40 | - if (@file_exists($file_name = ($path . '.php')) && @is_file($file_name)) require_once $file_name; |
|
| 40 | + if (@file_exists($file_name = ($path.'.php')) && @is_file($file_name)) require_once $file_name; |
|
| 41 | 41 | |
| 42 | - else if (@file_exists($file_name = ($path . '/' . $last . '.php')) && @is_file($file_name)) require_once $file_name; |
|
| 42 | + else if (@file_exists($file_name = ($path.'/'.$last.'.php')) && @is_file($file_name)) require_once $file_name; |
|
| 43 | 43 | |
| 44 | 44 | # Check if class exists |
| 45 | 45 | |
@@ -49,9 +49,13 @@ |
||
| 49 | 49 | |
| 50 | 50 | public static function url(string $value) { |
| 51 | 51 | |
| 52 | - if (false === ($value = parent::url($value))) return false; |
|
| 52 | + if (false === ($value = parent::url($value))) { |
|
| 53 | + return false; |
|
| 54 | + } |
|
| 53 | 55 | |
| 54 | - if (!preg_match('/^https?:\/\//', $value)) return false; |
|
| 56 | + if (!preg_match('/^https?:\/\//', $value)) { |
|
| 57 | + return false; |
|
| 58 | + } |
|
| 55 | 59 | |
| 56 | 60 | # ------------------------ |
| 57 | 61 | |