@@ -2,7 +2,8 @@ |
||
2 | 2 | |
3 | 3 | namespace Modules\Entitizer\Controller { |
4 | 4 | |
5 | - use Modules\Entitizer, Utils\Validate; |
|
5 | + use Modules\Entitizer; |
|
6 | + use Utils\Validate; |
|
6 | 7 | |
7 | 8 | class Variable { |
8 | 9 |
@@ -29,13 +29,19 @@ discard block |
||
29 | 29 | |
30 | 30 | # Validate name |
31 | 31 | |
32 | - if (false === ($name = Validate::templateComponentName($name))) return ['name', 'VARIABLE_ERROR_NAME_INVALID']; |
|
32 | + if (false === ($name = Validate::templateComponentName($name))) { |
|
33 | + return ['name', 'VARIABLE_ERROR_NAME_INVALID']; |
|
34 | + } |
|
33 | 35 | |
34 | 36 | # Check name exists |
35 | 37 | |
36 | - if (false === ($check_name = $this->variable->check($name, 'name'))) return 'VARIABLE_ERROR_MODIFY'; |
|
38 | + if (false === ($check_name = $this->variable->check($name, 'name'))) { |
|
39 | + return 'VARIABLE_ERROR_MODIFY'; |
|
40 | + } |
|
37 | 41 | |
38 | - if ($check_name === 1) return ['name', 'VARIABLE_ERROR_NAME_DUPLICATE']; |
|
42 | + if ($check_name === 1) { |
|
43 | + return ['name', 'VARIABLE_ERROR_NAME_DUPLICATE']; |
|
44 | + } |
|
39 | 45 | |
40 | 46 | # Modify variable |
41 | 47 | |
@@ -47,7 +53,9 @@ discard block |
||
47 | 53 | |
48 | 54 | $modifier = ((0 === $this->variable->id) ? 'create' : 'edit'); |
49 | 55 | |
50 | - if (!$this->variable->$modifier($data)) return 'VARIABLE_ERROR_MODIFY'; |
|
56 | + if (!$this->variable->$modifier($data)) { |
|
57 | + return 'VARIABLE_ERROR_MODIFY'; |
|
58 | + } |
|
51 | 59 | |
52 | 60 | # ------------------------ |
53 | 61 |
@@ -2,7 +2,8 @@ |
||
2 | 2 | |
3 | 3 | namespace Modules\Entitizer\Controller { |
4 | 4 | |
5 | - use Modules\Entitizer, Utils\Validate; |
|
5 | + use Modules\Entitizer; |
|
6 | + use Utils\Validate; |
|
6 | 7 | |
7 | 8 | class Widget { |
8 | 9 |
@@ -29,13 +29,19 @@ discard block |
||
29 | 29 | |
30 | 30 | # Validate name |
31 | 31 | |
32 | - if (false === ($name = Validate::templateComponentName($name))) return ['name', 'WIDGET_ERROR_NAME_INVALID']; |
|
32 | + if (false === ($name = Validate::templateComponentName($name))) { |
|
33 | + return ['name', 'WIDGET_ERROR_NAME_INVALID']; |
|
34 | + } |
|
33 | 35 | |
34 | 36 | # Check name exists |
35 | 37 | |
36 | - if (false === ($check_name = $this->widget->check($name, 'name'))) return 'WIDGET_ERROR_MODIFY'; |
|
38 | + if (false === ($check_name = $this->widget->check($name, 'name'))) { |
|
39 | + return 'WIDGET_ERROR_MODIFY'; |
|
40 | + } |
|
37 | 41 | |
38 | - if ($check_name === 1) return ['name', 'WIDGET_ERROR_NAME_DUPLICATE']; |
|
42 | + if ($check_name === 1) { |
|
43 | + return ['name', 'WIDGET_ERROR_NAME_DUPLICATE']; |
|
44 | + } |
|
39 | 45 | |
40 | 46 | # Modify widget |
41 | 47 | |
@@ -48,7 +54,9 @@ discard block |
||
48 | 54 | |
49 | 55 | $modifier = ((0 === $this->widget->id) ? 'create' : 'edit'); |
50 | 56 | |
51 | - if (!$this->widget->$modifier($data)) return 'WIDGET_ERROR_MODIFY'; |
|
57 | + if (!$this->widget->$modifier($data)) { |
|
58 | + return 'WIDGET_ERROR_MODIFY'; |
|
59 | + } |
|
52 | 60 | |
53 | 61 | # ------------------------ |
54 | 62 |
@@ -2,7 +2,12 @@ |
||
2 | 2 | |
3 | 3 | namespace Modules\Extend\Utils\Handler { |
4 | 4 | |
5 | - use Modules\Extend, Modules\Settings, Ajax, Arr, Language, Request, Template, JSON; |
|
5 | + use Modules\Extend; |
|
6 | + use Modules\Settings; |
|
7 | + use Ajax; |
|
8 | + use Language; |
|
9 | + use Request; |
|
10 | + use Template; |
|
6 | 11 | |
7 | 12 | abstract class Basic extends Extend\Utils\Handler { |
8 | 13 |
@@ -30,13 +30,19 @@ discard block |
||
30 | 30 | |
31 | 31 | if (Request::post('action') === 'activate') { |
32 | 32 | |
33 | - if (MODE_DEMO) return $ajax->setError(Language::get('DEMO_MODE_RESTRICTION')); |
|
33 | + if (MODE_DEMO) { |
|
34 | + return $ajax->setError(Language::get('DEMO_MODE_RESTRICTION')); |
|
35 | + } |
|
34 | 36 | |
35 | 37 | $param = static::$param[$this->loader->section()]; $name = Request::post('name'); |
36 | 38 | |
37 | - if (false === Settings::set($param, $name)) return $ajax->setError(Language::get(static::$error_activate)); |
|
39 | + if (false === Settings::set($param, $name)) { |
|
40 | + return $ajax->setError(Language::get(static::$error_activate)); |
|
41 | + } |
|
38 | 42 | |
39 | - if (false === Settings::save()) return $ajax->setError(Language::get(static::$error_save)); |
|
43 | + if (false === Settings::save()) { |
|
44 | + return $ajax->setError(Language::get(static::$error_save)); |
|
45 | + } |
|
40 | 46 | |
41 | 47 | } else if (Request::post('action') === 'list') { |
42 | 48 | |
@@ -54,7 +60,9 @@ discard block |
||
54 | 60 | |
55 | 61 | $this->loader = new static::$loader_class(Request::get('list')); |
56 | 62 | |
57 | - if (Request::isAjax()) return $this->handleAjax(); |
|
63 | + if (Request::isAjax()) { |
|
64 | + return $this->handleAjax(); |
|
65 | + } |
|
58 | 66 | |
59 | 67 | # ------------------------ |
60 | 68 |
@@ -2,7 +2,10 @@ |
||
2 | 2 | |
3 | 3 | namespace Utils { |
4 | 4 | |
5 | - use Utils\Messages, Explorer, Language, Request; |
|
5 | + use Utils\Messages; |
|
6 | + use Explorer; |
|
7 | + use Language; |
|
8 | + use Request; |
|
6 | 9 | |
7 | 10 | abstract class Uploader { |
8 | 11 |
@@ -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 |
@@ -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 |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | |
73 | 73 | public function getPath() : string { |
74 | 74 | |
75 | - return ('/' . implode('/', array_map('urlencode', $this->path))); |
|
75 | + return ('/'.implode('/', array_map('urlencode', $this->path))); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | |
82 | 82 | public function getQuery() : string { |
83 | 83 | |
84 | - return (($query = http_build_query($this->query)) ? ('?' . $query) : ''); |
|
84 | + return (($query = http_build_query($this->query)) ? ('?'.$query) : ''); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | |
109 | 109 | public function getString(bool $include_query = true) : string { |
110 | 110 | |
111 | - return ($this->getPath() . ($include_query ? $this->getQuery() : '')); |
|
111 | + return ($this->getPath().($include_query ? $this->getQuery() : '')); |
|
112 | 112 | } |
113 | 113 | } |
114 | 114 | } |
@@ -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. |
@@ -24,7 +24,7 @@ |
||
24 | 24 | |
25 | 25 | public static function checkInstallFile() { |
26 | 26 | |
27 | - return Explorer::isFile(DIR_WWW . 'install.php'); |
|
27 | + return Explorer::isFile(DIR_WWW.'install.php'); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | # Get MySQL version |
@@ -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 |