@@ -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 |
@@ -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 |
@@ -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 |
@@ -67,7 +67,7 @@ |
||
67 | 67 | |
68 | 68 | if (false === ($handler = self::parseString($route['handler'], REGEX_MAP_ITEM_HANDLER))) return; |
69 | 69 | |
70 | - self::$routes['/' . implode('/', $path)] = ('Addons\\' . $name . '\\' . implode('\\', $handler)); |
|
70 | + self::$routes['/'.implode('/', $path)] = ('Addons\\'.$name.'\\'.implode('\\', $handler)); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | # Parse item |
@@ -52,7 +52,9 @@ discard block |
||
52 | 52 | |
53 | 53 | $parts = preg_split('/\//', $string, 0, PREG_SPLIT_NO_EMPTY); |
54 | 54 | |
55 | - foreach ($parts as $name) if (!preg_match($regex, $name)) return false; |
|
55 | + foreach ($parts as $name) { |
|
56 | + if (!preg_match($regex, $name)) return false; |
|
57 | + } |
|
56 | 58 | |
57 | 59 | # ------------------------ |
58 | 60 | |
@@ -63,9 +65,13 @@ discard block |
||
63 | 65 | |
64 | 66 | private static function parseRoute(string $name, array $route) { |
65 | 67 | |
66 | - if (false === ($path = self::parseString($route['path'], REGEX_MAP_ITEM_PATH))) return; |
|
68 | + if (false === ($path = self::parseString($route['path'], REGEX_MAP_ITEM_PATH))) { |
|
69 | + return; |
|
70 | + } |
|
67 | 71 | |
68 | - if (false === ($handler = self::parseString($route['handler'], REGEX_MAP_ITEM_HANDLER))) return; |
|
72 | + if (false === ($handler = self::parseString($route['handler'], REGEX_MAP_ITEM_HANDLER))) { |
|
73 | + return; |
|
74 | + } |
|
69 | 75 | |
70 | 76 | self::$routes['/' . implode('/', $path)] = ('Addons\\' . $name . '\\' . implode('\\', $handler)); |
71 | 77 | } |
@@ -74,14 +80,18 @@ discard block |
||
74 | 80 | |
75 | 81 | private static function parseItem(array $item) { |
76 | 82 | |
77 | - foreach ($item['routes'] as $route) self::parseRoute($item['name'], $route); |
|
83 | + foreach ($item['routes'] as $route) { |
|
84 | + self::parseRoute($item['name'], $route); |
|
85 | + } |
|
78 | 86 | } |
79 | 87 | |
80 | 88 | # Autoloader |
81 | 89 | |
82 | 90 | public static function __autoload() { |
83 | 91 | |
84 | - foreach (Extend\Addons::items() as $item) self::parseItem($item); |
|
92 | + foreach (Extend\Addons::items() as $item) { |
|
93 | + self::parseItem($item); |
|
94 | + } |
|
85 | 95 | } |
86 | 96 | |
87 | 97 | # Get handler by url |
@@ -2,32 +2,32 @@ |
||
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('DEBUG_MODE', @file_exists(DIR_SYSTEM_DATA . '.debug')); |
|
30 | +define('DEBUG_MODE', @file_exists(DIR_SYSTEM_DATA.'.debug')); |
|
31 | 31 | |
32 | 32 | # Set error reporting |
33 | 33 |
@@ -31,4 +31,6 @@ |
||
31 | 31 | |
32 | 32 | # Set error reporting |
33 | 33 | |
34 | -if (DEBUG_MODE) error_reporting(E_ALL); |
|
34 | +if (DEBUG_MODE) { |
|
35 | + error_reporting(E_ALL); |
|
36 | +} |
@@ -32,9 +32,13 @@ discard block |
||
32 | 32 | |
33 | 33 | $param = static::$param[$this->loader->section()]; $name = Request::post('name'); |
34 | 34 | |
35 | - if (false === Settings::set($param, $name)) return $ajax->setError(Language::get(static::$error_activate)); |
|
35 | + if (false === Settings::set($param, $name)) { |
|
36 | + return $ajax->setError(Language::get(static::$error_activate)); |
|
37 | + } |
|
36 | 38 | |
37 | - if (false === Settings::save()) return $ajax->setError(Language::get(static::$error_save)); |
|
39 | + if (false === Settings::save()) { |
|
40 | + return $ajax->setError(Language::get(static::$error_save)); |
|
41 | + } |
|
38 | 42 | |
39 | 43 | } else if (Request::post('action') === 'list') { |
40 | 44 | |
@@ -52,7 +56,9 @@ discard block |
||
52 | 56 | |
53 | 57 | $this->loader = new static::$loader_class(Request::get('list')); |
54 | 58 | |
55 | - if (Request::isAjax()) return $this->handleAjax(); |
|
59 | + if (Request::isAjax()) { |
|
60 | + return $this->handleAjax(); |
|
61 | + } |
|
56 | 62 | |
57 | 63 | # ------------------------ |
58 | 64 |
@@ -42,7 +42,7 @@ |
||
42 | 42 | |
43 | 43 | # Set system entries |
44 | 44 | |
45 | - $contents->system_version = CADMIUM_VERSION; |
|
45 | + $contents->system_version = CADMIUM_VERSION; |
|
46 | 46 | |
47 | 47 | # Set external entries |
48 | 48 |
@@ -20,21 +20,19 @@ discard block |
||
20 | 20 | |
21 | 21 | # Connect to DB |
22 | 22 | |
23 | - try { DB::connect($server, $user, $password, $name); } |
|
24 | - |
|
25 | - catch (Exception\DBConnect $error) { return 'INSTALL_ERROR_DATABASE_CONNECT'; } |
|
26 | - |
|
27 | - catch (Exception\DBSelect $error) { return 'INSTALL_ERROR_DATABASE_SELECT'; } |
|
28 | - |
|
29 | - catch (Exception\DBCharset $error) { return 'INSTALL_ERROR_DATABASE_CHARSET'; } |
|
23 | + try { DB::connect($server, $user, $password, $name); } catch (Exception\DBConnect $error) { return 'INSTALL_ERROR_DATABASE_CONNECT'; } catch (Exception\DBSelect $error) { return 'INSTALL_ERROR_DATABASE_SELECT'; } catch (Exception\DBCharset $error) { return 'INSTALL_ERROR_DATABASE_CHARSET'; } |
|
30 | 24 | |
31 | 25 | # Create tables |
32 | 26 | |
33 | - if (!Install\Utils\Tables::create()) return 'INSTALL_ERROR_DATABASE_TABLES_CREATE'; |
|
27 | + if (!Install\Utils\Tables::create()) { |
|
28 | + return 'INSTALL_ERROR_DATABASE_TABLES_CREATE'; |
|
29 | + } |
|
34 | 30 | |
35 | 31 | # Fill tables |
36 | 32 | |
37 | - if (!Install\Utils\Tables::fill()) return 'INSTALL_ERROR_DATABASE_TABLES_FILL'; |
|
33 | + if (!Install\Utils\Tables::fill()) { |
|
34 | + return 'INSTALL_ERROR_DATABASE_TABLES_FILL'; |
|
35 | + } |
|
38 | 36 | |
39 | 37 | # Save system file |
40 | 38 | |
@@ -47,7 +45,9 @@ discard block |
||
47 | 45 | |
48 | 46 | $system['time'] = REQUEST_TIME; |
49 | 47 | |
50 | - if (!Schema::get('System')->save($system)) return 'INSTALL_ERROR_SYSTEM'; |
|
48 | + if (!Schema::get('System')->save($system)) { |
|
49 | + return 'INSTALL_ERROR_SYSTEM'; |
|
50 | + } |
|
51 | 51 | |
52 | 52 | # ------------------------ |
53 | 53 |
@@ -10,14 +10,14 @@ discard block |
||
10 | 10 | |
11 | 11 | private function getSystemUrl() { |
12 | 12 | |
13 | - if (!empty($_SERVER['HTTP_HOST'])) return ((Request::isSecure() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST']); |
|
13 | + if (!empty($_SERVER['HTTP_HOST'])) return ((Request::isSecure() ? 'https://' : 'http://').$_SERVER['HTTP_HOST']); |
|
14 | 14 | } |
15 | 15 | |
16 | 16 | # Get system email |
17 | 17 | |
18 | 18 | private function getSystemEmail() { |
19 | 19 | |
20 | - if (!empty($_SERVER['HTTP_HOST'])) return ('admin@' . $_SERVER['HTTP_HOST']); |
|
20 | + if (!empty($_SERVER['HTTP_HOST'])) return ('admin@'.$_SERVER['HTTP_HOST']); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | # Constructor |
@@ -26,84 +26,84 @@ discard block |
||
26 | 26 | |
27 | 27 | # Admin language |
28 | 28 | |
29 | - $this->addParam('admin_language', CONFIG_ADMIN_LANGUAGE_DEFAULT, function (string $name) { |
|
29 | + $this->addParam('admin_language', CONFIG_ADMIN_LANGUAGE_DEFAULT, function(string $name) { |
|
30 | 30 | |
31 | 31 | return ((false !== ($name = Extend\Languages::validate($name))) ? $name : null); |
32 | 32 | }); |
33 | 33 | |
34 | 34 | # Admin template |
35 | 35 | |
36 | - $this->addParam('admin_template', CONFIG_ADMIN_TEMPLATE_DEFAULT, function (string $name) { |
|
36 | + $this->addParam('admin_template', CONFIG_ADMIN_TEMPLATE_DEFAULT, function(string $name) { |
|
37 | 37 | |
38 | 38 | return ((false !== ($name = Extend\Templates::validate($name))) ? $name : null); |
39 | 39 | }); |
40 | 40 | |
41 | 41 | # Site language |
42 | 42 | |
43 | - $this->addParam('site_language', CONFIG_SITE_LANGUAGE_DEFAULT, function (string $name) { |
|
43 | + $this->addParam('site_language', CONFIG_SITE_LANGUAGE_DEFAULT, function(string $name) { |
|
44 | 44 | |
45 | 45 | return ((false !== ($name = Extend\Languages::validate($name))) ? $name : null); |
46 | 46 | }); |
47 | 47 | |
48 | 48 | # Site template |
49 | 49 | |
50 | - $this->addParam('site_template', CONFIG_SITE_TEMPLATE_DEFAULT, function (string $name) { |
|
50 | + $this->addParam('site_template', CONFIG_SITE_TEMPLATE_DEFAULT, function(string $name) { |
|
51 | 51 | |
52 | 52 | return ((false !== ($name = Extend\Templates::validate($name))) ? $name : null); |
53 | 53 | }); |
54 | 54 | |
55 | 55 | # Site title |
56 | 56 | |
57 | - $this->addParam('site_title', CONFIG_SITE_TITLE_DEFAULT, function (string $title) { |
|
57 | + $this->addParam('site_title', CONFIG_SITE_TITLE_DEFAULT, function(string $title) { |
|
58 | 58 | |
59 | 59 | return (('' !== $title) ? $title : null); |
60 | 60 | }); |
61 | 61 | |
62 | 62 | # Site slogan |
63 | 63 | |
64 | - $this->addParam('site_slogan', CONFIG_SITE_SLOGAN_DEFAULT, function (string $slogan) { |
|
64 | + $this->addParam('site_slogan', CONFIG_SITE_SLOGAN_DEFAULT, function(string $slogan) { |
|
65 | 65 | |
66 | 66 | return $slogan; |
67 | 67 | }); |
68 | 68 | |
69 | 69 | # Site status |
70 | 70 | |
71 | - $this->addParam('site_status', STATUS_ONLINE, function (string $status) { |
|
71 | + $this->addParam('site_status', STATUS_ONLINE, function(string $status) { |
|
72 | 72 | |
73 | 73 | return ((false !== ($status = Range\Status::validate($status))) ? $status : null); |
74 | 74 | }); |
75 | 75 | |
76 | 76 | # Site description |
77 | 77 | |
78 | - $this->addParam('site_description', '', function (string $description) { |
|
78 | + $this->addParam('site_description', '', function(string $description) { |
|
79 | 79 | |
80 | 80 | return $description; |
81 | 81 | }); |
82 | 82 | |
83 | 83 | # Site keywords |
84 | 84 | |
85 | - $this->addParam('site_keywords', '', function (string $keywords) { |
|
85 | + $this->addParam('site_keywords', '', function(string $keywords) { |
|
86 | 86 | |
87 | 87 | return $keywords; |
88 | 88 | }); |
89 | 89 | |
90 | 90 | # System url |
91 | 91 | |
92 | - $this->addParam('system_url', $this->getSystemUrl(), function (string $url) { |
|
92 | + $this->addParam('system_url', $this->getSystemUrl(), function(string $url) { |
|
93 | 93 | |
94 | 94 | return ((false !== ($url = Validate::url($url))) ? $url : null); |
95 | 95 | }); |
96 | 96 | |
97 | 97 | # System email |
98 | 98 | |
99 | - $this->addParam('system_email', $this->getSystemEmail(), function (string $email) { |
|
99 | + $this->addParam('system_email', $this->getSystemEmail(), function(string $email) { |
|
100 | 100 | |
101 | 101 | return ((false !== ($email = Validate::email($email))) ? $email : null); |
102 | 102 | }); |
103 | 103 | |
104 | 104 | # System timezone |
105 | 105 | |
106 | - $this->addParam('system_timezone', CONFIG_SYSTEM_TIMEZONE_DEFAULT, function (string $timezone) { |
|
106 | + $this->addParam('system_timezone', CONFIG_SYSTEM_TIMEZONE_DEFAULT, function(string $timezone) { |
|
107 | 107 | |
108 | 108 | return ((false !== ($timezone = Timezone::validate($timezone))) ? $timezone : null); |
109 | 109 | }); |
@@ -10,14 +10,18 @@ |
||
10 | 10 | |
11 | 11 | private function getSystemUrl() { |
12 | 12 | |
13 | - if (!empty($_SERVER['HTTP_HOST'])) return ((Request::isSecure() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST']); |
|
13 | + if (!empty($_SERVER['HTTP_HOST'])) { |
|
14 | + return ((Request::isSecure() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST']); |
|
15 | + } |
|
14 | 16 | } |
15 | 17 | |
16 | 18 | # Get system email |
17 | 19 | |
18 | 20 | private function getSystemEmail() { |
19 | 21 | |
20 | - if (!empty($_SERVER['HTTP_HOST'])) return ('admin@' . $_SERVER['HTTP_HOST']); |
|
22 | + if (!empty($_SERVER['HTTP_HOST'])) { |
|
23 | + return ('admin@' . $_SERVER['HTTP_HOST']); |
|
24 | + } |
|
21 | 25 | } |
22 | 26 | |
23 | 27 | # Constructor |