@@ -117,7 +117,7 @@ |
||
117 | 117 | |
118 | 118 | $block = clone (self::$block ?? (self::$block = Template::createBlock( |
119 | 119 | |
120 | - '<$name${ for:attributes } $name$="$value$"{ / for:attributes }>' . |
|
120 | + '<$name${ for:attributes } $name$="$value$"{ / for:attributes }>'. |
|
121 | 121 | |
122 | 122 | '{ block:contents / }$contents${ ! block:closing }</$name$>{ / block:closing }' |
123 | 123 | ))); |
@@ -58,7 +58,9 @@ discard block |
||
58 | 58 | |
59 | 59 | public function setAttributes(array $attributes) : Tag { |
60 | 60 | |
61 | - foreach ($attributes as $name => $value) if (is_scalar($value)) $this->setAttribute($name, $value); |
|
61 | + foreach ($attributes as $name => $value) { |
|
62 | + if (is_scalar($value)) $this->setAttribute($name, $value); |
|
63 | + } |
|
62 | 64 | |
63 | 65 | return $this; |
64 | 66 | } |
@@ -71,7 +73,9 @@ discard block |
||
71 | 73 | |
72 | 74 | public function setContents($contents) : Tag { |
73 | 75 | |
74 | - if (Template::isBlock($contents) || is_scalar($contents) || is_null($contents)) $this->contents = $contents; |
|
76 | + if (Template::isBlock($contents) || is_scalar($contents) || is_null($contents)) { |
|
77 | + $this->contents = $contents; |
|
78 | + } |
|
75 | 79 | |
76 | 80 | return $this; |
77 | 81 | } |
@@ -28,7 +28,9 @@ discard block |
||
28 | 28 | |
29 | 29 | public function __clone() { |
30 | 30 | |
31 | - foreach ($this->items as $name => $item) $this->items[$name] = clone $item; |
|
31 | + foreach ($this->items as $name => $item) { |
|
32 | + $this->items[$name] = clone $item; |
|
33 | + } |
|
32 | 34 | } |
33 | 35 | |
34 | 36 | /** |
@@ -52,7 +54,9 @@ discard block |
||
52 | 54 | |
53 | 55 | public function addItems(array $items) : Group { |
54 | 56 | |
55 | - foreach ($items as $item) if ($item instanceof Block) $this->addItem($item); |
|
57 | + foreach ($items as $item) { |
|
58 | + if ($item instanceof Block) $this->addItem($item); |
|
59 | + } |
|
56 | 60 | |
57 | 61 | return $this; |
58 | 62 | } |
@@ -111,7 +115,9 @@ discard block |
||
111 | 115 | |
112 | 116 | # Process items |
113 | 117 | |
114 | - foreach ($this->items as $block) $contents .= $block->getContents(); |
|
118 | + foreach ($this->items as $block) { |
|
119 | + $contents .= $block->getContents(); |
|
120 | + } |
|
115 | 121 | |
116 | 122 | # ------------------------ |
117 | 123 |
@@ -2,24 +2,24 @@ discard block |
||
2 | 2 | |
3 | 3 | # Define constants |
4 | 4 | |
5 | -define('DIR_FRAMEWORK', (dirname(__FILE__) . '/')); |
|
5 | +define('DIR_FRAMEWORK', (dirname(__FILE__).'/')); |
|
6 | 6 | |
7 | -define('DIR_CLASSES', (DIR_FRAMEWORK . 'Classes/')); |
|
8 | -define('DIR_DATA', (DIR_FRAMEWORK . 'Data/')); |
|
9 | -define('DIR_INCLUDES', (DIR_FRAMEWORK . 'Includes/')); |
|
10 | -define('DIR_TEMPLATES', (DIR_FRAMEWORK . 'Templates/')); |
|
7 | +define('DIR_CLASSES', (DIR_FRAMEWORK.'Classes/')); |
|
8 | +define('DIR_DATA', (DIR_FRAMEWORK.'Data/')); |
|
9 | +define('DIR_INCLUDES', (DIR_FRAMEWORK.'Includes/')); |
|
10 | +define('DIR_TEMPLATES', (DIR_FRAMEWORK.'Templates/')); |
|
11 | 11 | |
12 | 12 | # Require classes |
13 | 13 | |
14 | -require_once (DIR_FRAMEWORK . 'Engine.php'); |
|
15 | -require_once (DIR_FRAMEWORK . 'Exception.php'); |
|
14 | +require_once (DIR_FRAMEWORK.'Engine.php'); |
|
15 | +require_once (DIR_FRAMEWORK.'Exception.php'); |
|
16 | 16 | |
17 | 17 | # Require configuration |
18 | 18 | |
19 | -require_once (DIR_INCLUDES . 'Constants.php'); |
|
20 | -require_once (DIR_INCLUDES . 'Regex.php'); |
|
21 | -require_once (DIR_INCLUDES . 'Headers/Mime.php'); |
|
22 | -require_once (DIR_INCLUDES . 'Headers/Status.php'); |
|
19 | +require_once (DIR_INCLUDES.'Constants.php'); |
|
20 | +require_once (DIR_INCLUDES.'Regex.php'); |
|
21 | +require_once (DIR_INCLUDES.'Headers/Mime.php'); |
|
22 | +require_once (DIR_INCLUDES.'Headers/Status.php'); |
|
23 | 23 | |
24 | 24 | # Set defaults |
25 | 25 | |
@@ -29,10 +29,10 @@ discard block |
||
29 | 29 | |
30 | 30 | # Set request constants |
31 | 31 | |
32 | -define('REQUEST_CLIENT_IP', Engine::getIP()); |
|
32 | +define('REQUEST_CLIENT_IP', Engine::getIP()); |
|
33 | 33 | |
34 | -define('REQUEST_TIME', $_SERVER['REQUEST_TIME']); |
|
35 | -define('REQUEST_TIME_FLOAT', $_SERVER['REQUEST_TIME_FLOAT']); |
|
34 | +define('REQUEST_TIME', $_SERVER['REQUEST_TIME']); |
|
35 | +define('REQUEST_TIME_FLOAT', $_SERVER['REQUEST_TIME_FLOAT']); |
|
36 | 36 | |
37 | 37 | # Set exception handler |
38 | 38 |
@@ -2,33 +2,33 @@ |
||
2 | 2 | |
3 | 3 | # Define constants |
4 | 4 | |
5 | -define('DIR_SYSTEM', (dirname(__FILE__) . '/')); |
|
5 | +define('DIR_SYSTEM', (dirname(__FILE__).'/')); |
|
6 | 6 | |
7 | -define('DIR_SYSTEM_CLASSES', (DIR_SYSTEM . 'Classes/')); |
|
8 | -define('DIR_SYSTEM_DATA', (DIR_SYSTEM . 'Data/')); |
|
9 | -define('DIR_SYSTEM_INCLUDES', (DIR_SYSTEM . 'Includes/')); |
|
10 | -define('DIR_SYSTEM_LANGUAGES', (DIR_SYSTEM . 'Languages/')); |
|
11 | -define('DIR_SYSTEM_TEMPLATES', (DIR_SYSTEM . 'Templates/')); |
|
7 | +define('DIR_SYSTEM_CLASSES', (DIR_SYSTEM.'Classes/')); |
|
8 | +define('DIR_SYSTEM_DATA', (DIR_SYSTEM.'Data/')); |
|
9 | +define('DIR_SYSTEM_INCLUDES', (DIR_SYSTEM.'Includes/')); |
|
10 | +define('DIR_SYSTEM_LANGUAGES', (DIR_SYSTEM.'Languages/')); |
|
11 | +define('DIR_SYSTEM_TEMPLATES', (DIR_SYSTEM.'Templates/')); |
|
12 | 12 | |
13 | 13 | # Require classes |
14 | 14 | |
15 | -require_once (DIR_SYSTEM . 'Exception.php'); |
|
15 | +require_once (DIR_SYSTEM.'Exception.php'); |
|
16 | 16 | |
17 | 17 | # Require configuration |
18 | 18 | |
19 | -require_once (DIR_SYSTEM_INCLUDES . 'Config.php'); |
|
20 | -require_once (DIR_SYSTEM_INCLUDES . 'Constants.php'); |
|
21 | -require_once (DIR_SYSTEM_INCLUDES . 'Regex.php'); |
|
22 | -require_once (DIR_SYSTEM_INCLUDES . 'Tables.php'); |
|
19 | +require_once (DIR_SYSTEM_INCLUDES.'Config.php'); |
|
20 | +require_once (DIR_SYSTEM_INCLUDES.'Constants.php'); |
|
21 | +require_once (DIR_SYSTEM_INCLUDES.'Regex.php'); |
|
22 | +require_once (DIR_SYSTEM_INCLUDES.'Tables.php'); |
|
23 | 23 | |
24 | 24 | # Process environment variables |
25 | 25 | |
26 | -define('HTTP_MOD_REWRITE', (getenv('HTTP_MOD_REWRITE') === 'on')); |
|
26 | +define('HTTP_MOD_REWRITE', (getenv('HTTP_MOD_REWRITE') === 'on')); |
|
27 | 27 | |
28 | -define('INSTALL_PATH', rtrim(getenv('INSTALL_PATH'), '/')); |
|
28 | +define('INSTALL_PATH', rtrim(getenv('INSTALL_PATH'), '/')); |
|
29 | 29 | |
30 | -define('MODE_DEBUG', @file_exists(DIR_SYSTEM_DATA . '.debug')); |
|
31 | -define('MODE_DEMO', @file_exists(DIR_SYSTEM_DATA . '.demo')); |
|
30 | +define('MODE_DEBUG', @file_exists(DIR_SYSTEM_DATA.'.debug')); |
|
31 | +define('MODE_DEMO', @file_exists(DIR_SYSTEM_DATA.'.demo')); |
|
32 | 32 | |
33 | 33 | // Add here a check for a debug mode and if enabled then set an error reporting to E_ALL (previously should be set to 0). |
34 | 34 | // Till the CMS is in a beta stage an error reporting should be set to E_ALL by default. |
@@ -10,19 +10,33 @@ discard block |
||
10 | 10 | |
11 | 11 | private static function translateError(int $error) { |
12 | 12 | |
13 | - if ($error === UPLOAD_ERR_INI_SIZE) return 'UPLOADER_ERROR_INI_SIZE'; |
|
13 | + if ($error === UPLOAD_ERR_INI_SIZE) { |
|
14 | + return 'UPLOADER_ERROR_INI_SIZE'; |
|
15 | + } |
|
14 | 16 | |
15 | - if ($error === UPLOAD_ERR_FORM_SIZE) return 'UPLOADER_ERROR_FORM_SIZE'; |
|
17 | + if ($error === UPLOAD_ERR_FORM_SIZE) { |
|
18 | + return 'UPLOADER_ERROR_FORM_SIZE'; |
|
19 | + } |
|
16 | 20 | |
17 | - if ($error === UPLOAD_ERR_PARTIAL) return 'UPLOADER_ERROR_PARTIAL'; |
|
21 | + if ($error === UPLOAD_ERR_PARTIAL) { |
|
22 | + return 'UPLOADER_ERROR_PARTIAL'; |
|
23 | + } |
|
18 | 24 | |
19 | - if ($error === UPLOAD_ERR_NO_FILE) return 'UPLOADER_ERROR_NO_FILE'; |
|
25 | + if ($error === UPLOAD_ERR_NO_FILE) { |
|
26 | + return 'UPLOADER_ERROR_NO_FILE'; |
|
27 | + } |
|
20 | 28 | |
21 | - if ($error === UPLOAD_ERR_NO_TMP_DIR) return 'UPLOADER_ERROR_NO_TMP_DIR'; |
|
29 | + if ($error === UPLOAD_ERR_NO_TMP_DIR) { |
|
30 | + return 'UPLOADER_ERROR_NO_TMP_DIR'; |
|
31 | + } |
|
22 | 32 | |
23 | - if ($error === UPLOAD_ERR_CANT_WRITE) return 'UPLOADER_ERROR_CANT_WRITE'; |
|
33 | + if ($error === UPLOAD_ERR_CANT_WRITE) { |
|
34 | + return 'UPLOADER_ERROR_CANT_WRITE'; |
|
35 | + } |
|
24 | 36 | |
25 | - if ($error === UPLOAD_ERR_EXTENSION) return 'UPLOADER_ERROR_EXTENSION'; |
|
37 | + if ($error === UPLOAD_ERR_EXTENSION) { |
|
38 | + return 'UPLOADER_ERROR_EXTENSION'; |
|
39 | + } |
|
26 | 40 | |
27 | 41 | # ------------------------ |
28 | 42 | |
@@ -33,19 +47,27 @@ discard block |
||
33 | 47 | |
34 | 48 | public static function save(string $name, string $dir_name) { |
35 | 49 | |
36 | - if ((false === ($file = Request::file($name))) || !is_uploaded_file($file['tmp_name'])) return false; |
|
50 | + if ((false === ($file = Request::file($name))) || !is_uploaded_file($file['tmp_name'])) { |
|
51 | + return false; |
|
52 | + } |
|
37 | 53 | |
38 | 54 | # Check for demo mode |
39 | 55 | |
40 | - if (MODE_DEMO) return 'DEMO_MODE_RESTRICTION'; |
|
56 | + if (MODE_DEMO) { |
|
57 | + return 'DEMO_MODE_RESTRICTION'; |
|
58 | + } |
|
41 | 59 | |
42 | 60 | # Check for upload errors |
43 | 61 | |
44 | - if ($file['error'] !== UPLOAD_ERR_OK) return self::translateError($file['error']); |
|
62 | + if ($file['error'] !== UPLOAD_ERR_OK) { |
|
63 | + return self::translateError($file['error']); |
|
64 | + } |
|
45 | 65 | |
46 | 66 | # Check size |
47 | 67 | |
48 | - if ($file['size'] > CONFIG_UPLOADS_MAX_SIZE) return 'UPLOADER_ERROR_SIZE'; |
|
68 | + if ($file['size'] > CONFIG_UPLOADS_MAX_SIZE) { |
|
69 | + return 'UPLOADER_ERROR_SIZE'; |
|
70 | + } |
|
49 | 71 | |
50 | 72 | # Check file extension |
51 | 73 | |
@@ -53,21 +75,29 @@ discard block |
||
53 | 75 | |
54 | 76 | $extension = strtolower(Explorer::getExtension($file['name'], false)); |
55 | 77 | |
56 | - if (in_array($extension, $extensions, true)) return 'UPLOADER_ERROR_TYPE'; |
|
78 | + if (in_array($extension, $extensions, true)) { |
|
79 | + return 'UPLOADER_ERROR_TYPE'; |
|
80 | + } |
|
57 | 81 | |
58 | 82 | # Check target directory |
59 | 83 | |
60 | - if (!Explorer::isDir($dir_name)) return 'UPLOADER_ERROR_DIR'; |
|
84 | + if (!Explorer::isDir($dir_name)) { |
|
85 | + return 'UPLOADER_ERROR_DIR'; |
|
86 | + } |
|
61 | 87 | |
62 | 88 | # Check target file |
63 | 89 | |
64 | 90 | $file_name = ($dir_name . '/' . basename($file['name'])); |
65 | 91 | |
66 | - if (Explorer::isDir($file_name) || Explorer::isFile($file_name)) return 'UPLOADER_ERROR_EXISTS'; |
|
92 | + if (Explorer::isDir($file_name) || Explorer::isFile($file_name)) { |
|
93 | + return 'UPLOADER_ERROR_EXISTS'; |
|
94 | + } |
|
67 | 95 | |
68 | 96 | # Save uploaded file |
69 | 97 | |
70 | - if (!@move_uploaded_file($file['tmp_name'], $file_name)) return 'UPLOADER_ERROR_SAVE'; |
|
98 | + if (!@move_uploaded_file($file['tmp_name'], $file_name)) { |
|
99 | + return 'UPLOADER_ERROR_SAVE'; |
|
100 | + } |
|
71 | 101 | |
72 | 102 | # ------------------------ |
73 | 103 |
@@ -47,7 +47,9 @@ discard block |
||
47 | 47 | |
48 | 48 | # Check for demo mode |
49 | 49 | |
50 | - if (MODE_DEMO) return $ajax->setError(Language::get('DEMO_MODE_RESTRICTION')); |
|
50 | + if (MODE_DEMO) { |
|
51 | + return $ajax->setError(Language::get('DEMO_MODE_RESTRICTION')); |
|
52 | + } |
|
51 | 53 | |
52 | 54 | # Init entity |
53 | 55 | |
@@ -60,7 +62,9 @@ discard block |
||
60 | 62 | |
61 | 63 | if (Request::post('action') === 'remove') { |
62 | 64 | |
63 | - if (!$this->entity->remove()) return $ajax->setError(Language::get(static::$message_error_remove)); |
|
65 | + if (!$this->entity->remove()) { |
|
66 | + return $ajax->setError(Language::get(static::$message_error_remove)); |
|
67 | + } |
|
64 | 68 | } |
65 | 69 | |
66 | 70 | # ------------------------ |
@@ -82,7 +86,9 @@ discard block |
||
82 | 86 | |
83 | 87 | # Handle ajax request |
84 | 88 | |
85 | - if (Request::isAjax()) return $this->handleAjax(); |
|
89 | + if (Request::isAjax()) { |
|
90 | + return $this->handleAjax(); |
|
91 | + } |
|
86 | 92 | |
87 | 93 | # Init entity |
88 | 94 | |
@@ -108,7 +114,9 @@ discard block |
||
108 | 114 | |
109 | 115 | # Display success message |
110 | 116 | |
111 | - if (false !== Request::get('submitted')) Popup::set('positive', Language::get(static::$message_success_rename)); |
|
117 | + if (false !== Request::get('submitted')) { |
|
118 | + Popup::set('positive', Language::get(static::$message_success_rename)); |
|
119 | + } |
|
112 | 120 | |
113 | 121 | # ------------------------ |
114 | 122 |
@@ -29,23 +29,31 @@ |
||
29 | 29 | |
30 | 30 | # Check for demo mode |
31 | 31 | |
32 | - if (MODE_DEMO) return 'DEMO_MODE_RESTRICTION'; |
|
32 | + if (MODE_DEMO) { |
|
33 | + return 'DEMO_MODE_RESTRICTION'; |
|
34 | + } |
|
33 | 35 | |
34 | 36 | # Validate name |
35 | 37 | |
36 | - if (false === ($name = Validate::fileName($name))) return ['name', 'FILEMANAGER_ERROR_NAME_INVALID']; |
|
38 | + if (false === ($name = Validate::fileName($name))) { |
|
39 | + return ['name', 'FILEMANAGER_ERROR_NAME_INVALID']; |
|
40 | + } |
|
37 | 41 | |
38 | 42 | # Check if item exists |
39 | 43 | |
40 | - if (@file_exists($this->parent->pathFull() . $name)) return ['name', 'FILEMANAGER_ERROR_EXISTS']; |
|
44 | + if (@file_exists($this->parent->pathFull() . $name)) { |
|
45 | + return ['name', 'FILEMANAGER_ERROR_EXISTS']; |
|
46 | + } |
|
41 | 47 | |
42 | 48 | # Create item |
43 | 49 | |
44 | 50 | $entity = Filemanager::get($type, $this->parent); |
45 | 51 | |
46 | - if (!$entity->create($name)) return (($entity->type() === FILEMANAGER_TYPE_DIR) ? |
|
52 | + if (!$entity->create($name)) { |
|
53 | + return (($entity->type() === FILEMANAGER_TYPE_DIR) ? |
|
47 | 54 | |
48 | 55 | 'FILEMANAGER_ERROR_DIR_CREATE' : 'FILEMANAGER_ERROR_FILE_CREATE'); |
56 | + } |
|
49 | 57 | |
50 | 58 | # ------------------------ |
51 | 59 |
@@ -29,23 +29,31 @@ |
||
29 | 29 | |
30 | 30 | # Check for demo mode |
31 | 31 | |
32 | - if (MODE_DEMO) return 'DEMO_MODE_RESTRICTION'; |
|
32 | + if (MODE_DEMO) { |
|
33 | + return 'DEMO_MODE_RESTRICTION'; |
|
34 | + } |
|
33 | 35 | |
34 | 36 | # Validate name |
35 | 37 | |
36 | - if (false === ($name = Validate::fileName($name))) return ['name', 'FILEMANAGER_ERROR_NAME_INVALID']; |
|
38 | + if (false === ($name = Validate::fileName($name))) { |
|
39 | + return ['name', 'FILEMANAGER_ERROR_NAME_INVALID']; |
|
40 | + } |
|
37 | 41 | |
38 | 42 | # Check if item exists |
39 | 43 | |
40 | 44 | if ((0 !== strcasecmp($this->entity->name(), $name)) && |
41 | 45 | |
42 | - @file_exists($this->entity->parent()->pathFull() . $name)) return ['name', 'FILEMANAGER_ERROR_EXISTS']; |
|
46 | + @file_exists($this->entity->parent()->pathFull() . $name)) { |
|
47 | + return ['name', 'FILEMANAGER_ERROR_EXISTS']; |
|
48 | + } |
|
43 | 49 | |
44 | 50 | # Rename item |
45 | 51 | |
46 | - if (!$this->entity->rename($name)) return (($this->entity->type() === FILEMANAGER_TYPE_DIR) ? |
|
52 | + if (!$this->entity->rename($name)) { |
|
53 | + return (($this->entity->type() === FILEMANAGER_TYPE_DIR) ? |
|
47 | 54 | |
48 | 55 | 'FILEMANAGER_ERROR_DIR_RENAME' : 'FILEMANAGER_ERROR_FILE_RENAME'); |
56 | + } |
|
49 | 57 | |
50 | 58 | # ------------------------ |
51 | 59 |
@@ -12,7 +12,9 @@ discard block |
||
12 | 12 | |
13 | 13 | # Check for demo mode |
14 | 14 | |
15 | - if (MODE_DEMO) return 'DEMO_MODE_RESTRICTION'; |
|
15 | + if (MODE_DEMO) { |
|
16 | + return 'DEMO_MODE_RESTRICTION'; |
|
17 | + } |
|
16 | 18 | |
17 | 19 | # Define errors list |
18 | 20 | |
@@ -25,12 +27,16 @@ discard block |
||
25 | 27 | |
26 | 28 | foreach (Settings::setArray($post) as $name => $result) { |
27 | 29 | |
28 | - if (!$result) return (isset($errors[$name]) ? [$name, $errors[$name]] : false); |
|
30 | + if (!$result) { |
|
31 | + return (isset($errors[$name]) ? [$name, $errors[$name]] : false); |
|
32 | + } |
|
29 | 33 | } |
30 | 34 | |
31 | 35 | # Save settings |
32 | 36 | |
33 | - if (!Settings::save()) return 'SETTINGS_ERROR_SAVE'; |
|
37 | + if (!Settings::save()) { |
|
38 | + return 'SETTINGS_ERROR_SAVE'; |
|
39 | + } |
|
34 | 40 | |
35 | 41 | # ------------------------ |
36 | 42 |