@@ -10,7 +10,9 @@ |
||
| 10 | 10 | |
| 11 | 11 | protected static function init(string $file_name) { |
| 12 | 12 | |
| 13 | - if (is_array($range = Explorer::php($file_name))) static::$range = $range; |
|
| 13 | + if (is_array($range = Explorer::php($file_name))) { |
|
| 14 | + static::$range = $range; |
|
| 15 | + } |
|
| 14 | 16 | } |
| 15 | 17 | |
| 16 | 18 | # Check if item exists |
@@ -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 |
@@ -10,7 +10,12 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | $value = false; |
| 12 | 12 | |
| 13 | - foreach ($path as $item) if (isset($array[$item])) $value = ($array = $array[$item]); else return false; |
|
| 13 | + foreach ($path as $item) { |
|
| 14 | + if (isset($array[$item])) $value = ($array = $array[$item]); |
|
| 15 | + } |
|
| 16 | + else { |
|
| 17 | + return false; |
|
| 18 | + } |
|
| 14 | 19 | |
| 15 | 20 | # ------------------------ |
| 16 | 21 | |
@@ -23,10 +28,12 @@ discard block |
||
| 23 | 28 | |
| 24 | 29 | $result = []; |
| 25 | 30 | |
| 26 | - foreach ($keys as $key) if (is_scalar($key)) { |
|
| 31 | + foreach ($keys as $key) { |
|
| 32 | + if (is_scalar($key)) { |
|
| 27 | 33 | |
| 28 | 34 | $result[$key] = ((isset($array[$key]) && is_scalar($array[$key])) ? $array[$key] : false); |
| 29 | 35 | } |
| 36 | + } |
|
| 30 | 37 | |
| 31 | 38 | # ------------------------ |
| 32 | 39 | |
@@ -39,7 +46,9 @@ discard block |
||
| 39 | 46 | |
| 40 | 47 | $result = []; |
| 41 | 48 | |
| 42 | - foreach ($array as $key => $value) $result[] = [$key_name => $key, $value_name => $value]; |
|
| 49 | + foreach ($array as $key => $value) { |
|
| 50 | + $result[] = [$key_name => $key, $value_name => $value]; |
|
| 51 | + } |
|
| 43 | 52 | |
| 44 | 53 | # ------------------------ |
| 45 | 54 | |
@@ -57,9 +66,15 @@ discard block |
||
| 57 | 66 | |
| 58 | 67 | $result = []; $column = array_map($select_key, $array); |
| 59 | 68 | |
| 60 | - if (!$descending) asort($column); else arsort($column); |
|
| 69 | + if (!$descending) { |
|
| 70 | + asort($column); |
|
| 71 | + } else { |
|
| 72 | + arsort($column); |
|
| 73 | + } |
|
| 61 | 74 | |
| 62 | - foreach (array_keys($column) as $key) $result[$key] = $array[$key]; |
|
| 75 | + foreach (array_keys($column) as $key) { |
|
| 76 | + $result[$key] = $array[$key]; |
|
| 77 | + } |
|
| 63 | 78 | |
| 64 | 79 | # ------------------------ |
| 65 | 80 | |
@@ -10,7 +10,9 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | public function add(string $name, $default, callable $handler) { |
| 12 | 12 | |
| 13 | - if ('' === $name) return; |
|
| 13 | + if ('' === $name) { |
|
| 14 | + return; |
|
| 15 | + } |
|
| 14 | 16 | |
| 15 | 17 | $this->config[$name] = $handler; $this->values[$name] = null; |
| 16 | 18 | |
@@ -23,11 +25,11 @@ discard block |
||
| 23 | 25 | |
| 24 | 26 | foreach ($data as $name => $value) { |
| 25 | 27 | |
| 26 | - if (!isset($this->config[$name])) continue; |
|
| 27 | - |
|
| 28 | - try { $this->values[$name] = $this->config[$name]($value); } |
|
| 28 | + if (!isset($this->config[$name])) { |
|
| 29 | + continue; |
|
| 30 | + } |
|
| 29 | 31 | |
| 30 | - catch (\TypeError $e) {} |
|
| 32 | + try { $this->values[$name] = $this->config[$name]($value); } catch (\TypeError $e) {} |
|
| 31 | 33 | } |
| 32 | 34 | } |
| 33 | 35 | |
@@ -39,11 +41,11 @@ discard block |
||
| 39 | 41 | |
| 40 | 42 | foreach ($this->config as $name => $handler) { |
| 41 | 43 | |
| 42 | - if (!($isset = isset($data[$name])) && !$process_all) continue; |
|
| 44 | + if (!($isset = isset($data[$name])) && !$process_all) { |
|
| 45 | + continue; |
|
| 46 | + } |
|
| 43 | 47 | |
| 44 | - try { $cast[$name] = ($isset ? $handler($data[$name]) : $this->values[$name]); } |
|
| 45 | - |
|
| 46 | - catch (\TypeError $e) { $cast[$name] = $this->values[$name]; } |
|
| 48 | + try { $cast[$name] = ($isset ? $handler($data[$name]) : $this->values[$name]); } catch (\TypeError $e) { $cast[$name] = $this->values[$name]; } |
|
| 47 | 49 | } |
| 48 | 50 | |
| 49 | 51 | # ------------------------ |
@@ -55,7 +57,9 @@ discard block |
||
| 55 | 57 | |
| 56 | 58 | public function get(string $name = null) { |
| 57 | 59 | |
| 58 | - if (null === $name) return $this->values; |
|
| 60 | + if (null === $name) { |
|
| 61 | + return $this->values; |
|
| 62 | + } |
|
| 59 | 63 | |
| 60 | 64 | return ($this->values[$name] ?? null); |
| 61 | 65 | } |
@@ -10,7 +10,9 @@ |
||
| 10 | 10 | |
| 11 | 11 | public function set(string $name, $value) { |
| 12 | 12 | |
| 13 | - if (is_scalar($value)) $this->data[$name] = $value; |
|
| 13 | + if (is_scalar($value)) { |
|
| 14 | + $this->data[$name] = $value; |
|
| 15 | + } |
|
| 14 | 16 | |
| 15 | 17 | return $this; |
| 16 | 18 | } |
@@ -24,14 +24,14 @@ |
||
| 24 | 24 | |
| 25 | 25 | if (0 === $key) $names = $this->getString(array_keys($row), '$name', ', '); |
| 26 | 26 | |
| 27 | - $values[] = ('(' . $this->getString(array_values($row), '$value', ', ') . ')'); |
|
| 27 | + $values[] = ('('.$this->getString(array_values($row), '$value', ', ').')'); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | # Build query |
| 31 | 31 | |
| 32 | - $this->query = ('INSERT ' . ($ignore ? 'IGNORE ' : '') . |
|
| 32 | + $this->query = ('INSERT '.($ignore ? 'IGNORE ' : ''). |
|
| 33 | 33 | |
| 34 | - 'INTO ' . $table . ' (' . $names . ') VALUES ' . implode(', ', $values)); |
|
| 34 | + 'INTO '.$table.' ('.$names.') VALUES '.implode(', ', $values)); |
|
| 35 | 35 | } |
| 36 | 36 | } |
| 37 | 37 | } |
@@ -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 | |
@@ -2,15 +2,15 @@ |
||
| 2 | 2 | |
| 3 | 3 | # Database tables |
| 4 | 4 | |
| 5 | -define('TABLE_PAGES', 'pages'); |
|
| 6 | -define('TABLE_PAGES_RELATIONS', 'pages_relations'); |
|
| 5 | +define('TABLE_PAGES', 'pages'); |
|
| 6 | +define('TABLE_PAGES_RELATIONS', 'pages_relations'); |
|
| 7 | 7 | |
| 8 | -define('TABLE_MENU', 'menu'); |
|
| 9 | -define('TABLE_MENU_RELATIONS', 'menu_relations'); |
|
| 8 | +define('TABLE_MENU', 'menu'); |
|
| 9 | +define('TABLE_MENU_RELATIONS', 'menu_relations'); |
|
| 10 | 10 | |
| 11 | -define('TABLE_VARIABLES', 'variables'); |
|
| 12 | -define('TABLE_WIDGETS', 'widgets'); |
|
| 11 | +define('TABLE_VARIABLES', 'variables'); |
|
| 12 | +define('TABLE_WIDGETS', 'widgets'); |
|
| 13 | 13 | |
| 14 | -define('TABLE_USERS', 'users'); |
|
| 15 | -define('TABLE_USERS_SECRETS', 'users_secrets'); |
|
| 16 | -define('TABLE_USERS_SESSIONS', 'users_sessions'); |
|
| 14 | +define('TABLE_USERS', 'users'); |
|
| 15 | +define('TABLE_USERS_SECRETS', 'users_secrets'); |
|
| 16 | +define('TABLE_USERS_SESSIONS', 'users_sessions'); |
|
@@ -2,68 +2,68 @@ |
||
| 2 | 2 | |
| 3 | 3 | # Cadmium |
| 4 | 4 | |
| 5 | -define('CADMIUM_NAME', 'Cadmium CMS'); |
|
| 6 | -define('CADMIUM_HOME', 'http://cadmium-cms.com'); |
|
| 5 | +define('CADMIUM_NAME', 'Cadmium CMS'); |
|
| 6 | +define('CADMIUM_HOME', 'http://cadmium-cms.com'); |
|
| 7 | 7 | |
| 8 | -define('CADMIUM_VERSION', '0.3.0'); |
|
| 9 | -define('CADMIUM_COPY', '2016'); |
|
| 8 | +define('CADMIUM_VERSION', '0.3.0'); |
|
| 9 | +define('CADMIUM_COPY', '2016'); |
|
| 10 | 10 | |
| 11 | 11 | # External |
| 12 | 12 | |
| 13 | -define('JQUERY_VERSION', '2.2.0'); |
|
| 14 | -define('SEMANTIC_UI_VERSION', '2.1.8'); |
|
| 15 | -define('CKEDITOR_VERSION', '4.5.6'); |
|
| 13 | +define('JQUERY_VERSION', '2.2.0'); |
|
| 14 | +define('SEMANTIC_UI_VERSION', '2.1.8'); |
|
| 15 | +define('CKEDITOR_VERSION', '4.5.6'); |
|
| 16 | 16 | |
| 17 | 17 | # Sections |
| 18 | 18 | |
| 19 | -define('SECTION_ADMIN', 'Admin'); |
|
| 20 | -define('SECTION_SITE', 'Site'); |
|
| 19 | +define('SECTION_ADMIN', 'Admin'); |
|
| 20 | +define('SECTION_SITE', 'Site'); |
|
| 21 | 21 | |
| 22 | 22 | # Filemanager types |
| 23 | 23 | |
| 24 | -define('FILEMANAGER_TYPE_DIR', 'dir'); |
|
| 25 | -define('FILEMANAGER_TYPE_FILE', 'file'); |
|
| 24 | +define('FILEMANAGER_TYPE_DIR', 'dir'); |
|
| 25 | +define('FILEMANAGER_TYPE_FILE', 'file'); |
|
| 26 | 26 | |
| 27 | 27 | # Access |
| 28 | 28 | |
| 29 | -define('ACCESS_PUBLIC', 0); |
|
| 30 | -define('ACCESS_REGISTERED', 1); |
|
| 31 | -define('ACCESS_ADMINISTRATOR', 2); |
|
| 29 | +define('ACCESS_PUBLIC', 0); |
|
| 30 | +define('ACCESS_REGISTERED', 1); |
|
| 31 | +define('ACCESS_ADMINISTRATOR', 2); |
|
| 32 | 32 | |
| 33 | 33 | # Frequency |
| 34 | 34 | |
| 35 | -define('FREQUENCY_ALWAYS', 'always'); |
|
| 36 | -define('FREQUENCY_HOURLY', 'hourly'); |
|
| 37 | -define('FREQUENCY_DAILY', 'daily'); |
|
| 38 | -define('FREQUENCY_WEEKLY', 'weekly'); |
|
| 39 | -define('FREQUENCY_MONTHLY', 'monthly'); |
|
| 40 | -define('FREQUENCY_YEARLY', 'yearly'); |
|
| 41 | -define('FREQUENCY_NEVER', 'never'); |
|
| 35 | +define('FREQUENCY_ALWAYS', 'always'); |
|
| 36 | +define('FREQUENCY_HOURLY', 'hourly'); |
|
| 37 | +define('FREQUENCY_DAILY', 'daily'); |
|
| 38 | +define('FREQUENCY_WEEKLY', 'weekly'); |
|
| 39 | +define('FREQUENCY_MONTHLY', 'monthly'); |
|
| 40 | +define('FREQUENCY_YEARLY', 'yearly'); |
|
| 41 | +define('FREQUENCY_NEVER', 'never'); |
|
| 42 | 42 | |
| 43 | 43 | # Rank |
| 44 | 44 | |
| 45 | -define('RANK_GUEST', 0); |
|
| 46 | -define('RANK_USER', 1); |
|
| 47 | -define('RANK_ADMINISTRATOR', 2); |
|
| 45 | +define('RANK_GUEST', 0); |
|
| 46 | +define('RANK_USER', 1); |
|
| 47 | +define('RANK_ADMINISTRATOR', 2); |
|
| 48 | 48 | |
| 49 | 49 | # Sex |
| 50 | 50 | |
| 51 | -define('SEX_NOT_SELECTED', 0); |
|
| 52 | -define('SEX_MALE', 1); |
|
| 53 | -define('SEX_FEMALE', 2); |
|
| 51 | +define('SEX_NOT_SELECTED', 0); |
|
| 52 | +define('SEX_MALE', 1); |
|
| 53 | +define('SEX_FEMALE', 2); |
|
| 54 | 54 | |
| 55 | 55 | # Status |
| 56 | 56 | |
| 57 | -define('STATUS_ONLINE', 0); |
|
| 58 | -define('STATUS_MAINTENANCE', 1); |
|
| 59 | -define('STATUS_UPDATE', 2); |
|
| 57 | +define('STATUS_ONLINE', 0); |
|
| 58 | +define('STATUS_MAINTENANCE', 1); |
|
| 59 | +define('STATUS_UPDATE', 2); |
|
| 60 | 60 | |
| 61 | 61 | # Target |
| 62 | 62 | |
| 63 | -define('TARGET_SELF', 0); |
|
| 64 | -define('TARGET_BLANK', 1); |
|
| 63 | +define('TARGET_SELF', 0); |
|
| 64 | +define('TARGET_BLANK', 1); |
|
| 65 | 65 | |
| 66 | 66 | # Visibility |
| 67 | 67 | |
| 68 | -define('VISIBILITY_DRAFT', 0); |
|
| 69 | -define('VISIBILITY_PUBLISHED', 1); |
|
| 68 | +define('VISIBILITY_DRAFT', 0); |
|
| 69 | +define('VISIBILITY_PUBLISHED', 1); |
|