@@ -2,7 +2,8 @@ |
||
2 | 2 | |
3 | 3 | namespace Modules\Entitizer\Utils { |
4 | 4 | |
5 | - use Modules\Entitizer, DB; |
|
5 | + use Modules\Entitizer; |
|
6 | + use DB; |
|
6 | 7 | |
7 | 8 | abstract class Entity extends Entitizer { |
8 | 9 |
@@ -86,7 +86,7 @@ |
||
86 | 86 | |
87 | 87 | $name = $param->name(); $value = $param->cast($value); |
88 | 88 | |
89 | - $condition = ($name . " = '" . addslashes($value) . "' AND id != " . $this->id); |
|
89 | + $condition = ($name." = '".addslashes($value)."' AND id != ".$this->id); |
|
90 | 90 | |
91 | 91 | DB::select(static::$table, 'id', $condition, null, 1); |
92 | 92 |
@@ -20,7 +20,9 @@ discard block |
||
20 | 20 | |
21 | 21 | $entity = self::get(static::$type, $entity->data['parent_id']); |
22 | 22 | |
23 | - if (0 === $entity->id) return []; |
|
23 | + if (0 === $entity->id) { |
|
24 | + return []; |
|
25 | + } |
|
24 | 26 | |
25 | 27 | $path[] = array_merge(['id' => $entity->id], $entity->data); |
26 | 28 | } |
@@ -44,7 +46,9 @@ discard block |
||
44 | 46 | |
45 | 47 | # Preset path |
46 | 48 | |
47 | - if (static::$nesting) $this->data['path'] = []; |
|
49 | + if (static::$nesting) { |
|
50 | + $this->data['path'] = []; |
|
51 | + } |
|
48 | 52 | |
49 | 53 | # Implement entity |
50 | 54 | |
@@ -52,14 +56,18 @@ discard block |
||
52 | 56 | |
53 | 57 | # Init entity |
54 | 58 | |
55 | - if ($id > 0) $this->init($id); |
|
59 | + if ($id > 0) { |
|
60 | + $this->init($id); |
|
61 | + } |
|
56 | 62 | } |
57 | 63 | |
58 | 64 | # Check if unique param value exists |
59 | 65 | |
60 | 66 | public function check(string $name, $value) { |
61 | 67 | |
62 | - if ((false === ($param = $this->definition->get($name))) || !$param->unique()) return false; |
|
68 | + if ((false === ($param = $this->definition->get($name))) || !$param->unique()) { |
|
69 | + return false; |
|
70 | + } |
|
63 | 71 | |
64 | 72 | # Select entity from DB |
65 | 73 | |
@@ -80,7 +88,9 @@ discard block |
||
80 | 88 | |
81 | 89 | DB::select(static::$table, 'COUNT(id) as count', ['parent_id' => $this->id]); |
82 | 90 | |
83 | - if (!(DB::last() && DB::last()->status)) return false; |
|
91 | + if (!(DB::last() && DB::last()->status)) { |
|
92 | + return false; |
|
93 | + } |
|
84 | 94 | |
85 | 95 | # ------------------------ |
86 | 96 | |
@@ -112,7 +122,9 @@ discard block |
||
112 | 122 | |
113 | 123 | public function __get(string $name) { |
114 | 124 | |
115 | - if ($name === 'id') return $this->id; |
|
125 | + if ($name === 'id') { |
|
126 | + return $this->id; |
|
127 | + } |
|
116 | 128 | |
117 | 129 | return (isset($this->data[$name]) ? $this->data[$name] : null); |
118 | 130 | } |
@@ -2,7 +2,9 @@ |
||
2 | 2 | |
3 | 3 | namespace Modules\Filemanager\Handler { |
4 | 4 | |
5 | - use Modules\Filemanager, Date, Template; |
|
5 | + use Modules\Filemanager; |
|
6 | + use Date; |
|
7 | + use Template; |
|
6 | 8 | |
7 | 9 | class Dir extends Filemanager\Utils\Handler { |
8 | 10 |
@@ -2,7 +2,12 @@ |
||
2 | 2 | |
3 | 3 | namespace Modules\Filemanager\Handler { |
4 | 4 | |
5 | - use Modules\Filemanager, Date, Explorer, Mime, Number, Template; |
|
5 | + use Modules\Filemanager; |
|
6 | + use Date; |
|
7 | + use Explorer; |
|
8 | + use Mime; |
|
9 | + use Number; |
|
10 | + use Template; |
|
6 | 11 | |
7 | 12 | class File extends Filemanager\Utils\Handler { |
8 | 13 |
@@ -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) ? DIR_SYSTEM_CLASSES : DIR_CLASSES) . implode('/', $path)); |
|
36 | + $path = ((in_array($path[0], $system_classes) ? 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,7 +2,9 @@ |
||
2 | 2 | |
3 | 3 | namespace Modules\Entitizer\Form { |
4 | 4 | |
5 | - use Modules\Entitizer, Utils\Form, Utils\Lister; |
|
5 | + use Modules\Entitizer; |
|
6 | + use Utils\Form; |
|
7 | + use Utils\Lister; |
|
6 | 8 | |
7 | 9 | class Page extends Form { |
8 | 10 |
@@ -2,7 +2,8 @@ |
||
2 | 2 | |
3 | 3 | namespace Modules\Entitizer\Form { |
4 | 4 | |
5 | - use Modules\Entitizer, Utils\Form; |
|
5 | + use Modules\Entitizer; |
|
6 | + use Utils\Form; |
|
6 | 7 | |
7 | 8 | class Widget extends Form { |
8 | 9 |
@@ -23,11 +23,15 @@ |
||
23 | 23 | |
24 | 24 | $selection = ['name', 'value']; $order = ['name' => 'ASC']; |
25 | 25 | |
26 | - if (!(DB::select(TABLE_VARIABLES, $selection, null, $order) && DB::last()->status)) return; |
|
26 | + if (!(DB::select(TABLE_VARIABLES, $selection, null, $order) && DB::last()->status)) { |
|
27 | + return; |
|
28 | + } |
|
27 | 29 | |
28 | 30 | # Process results |
29 | 31 | |
30 | - while (null !== ($variable = DB::last()->row())) $this->addItem($variable['name'], $variable['value']); |
|
32 | + while (null !== ($variable = DB::last()->row())) { |
|
33 | + $this->addItem($variable['name'], $variable['value']); |
|
34 | + } |
|
31 | 35 | } |
32 | 36 | |
33 | 37 | # Return items |
@@ -23,11 +23,15 @@ |
||
23 | 23 | |
24 | 24 | $selection = ['name', 'contents']; $condition = ['display' => 1]; $order = ['name' => 'ASC']; |
25 | 25 | |
26 | - if (!(DB::select(TABLE_WIDGETS, $selection, $condition, $order) && DB::last()->status)) return; |
|
26 | + if (!(DB::select(TABLE_WIDGETS, $selection, $condition, $order) && DB::last()->status)) { |
|
27 | + return; |
|
28 | + } |
|
27 | 29 | |
28 | 30 | # Process results |
29 | 31 | |
30 | - while (null !== ($widget = DB::last()->row())) $this->addItem($widget['name'], $widget['contents']); |
|
32 | + while (null !== ($widget = DB::last()->row())) { |
|
33 | + $this->addItem($widget['name'], $widget['contents']); |
|
34 | + } |
|
31 | 35 | } |
32 | 36 | |
33 | 37 | # Return items |
@@ -2,7 +2,9 @@ |
||
2 | 2 | |
3 | 3 | namespace Modules\Entitizer\Controller { |
4 | 4 | |
5 | - use Modules\Auth, Modules\Entitizer, Utils\Validate, Str; |
|
5 | + use Modules\Entitizer; |
|
6 | + use Utils\Validate; |
|
7 | + use Str; |
|
6 | 8 | |
7 | 9 | class User { |
8 | 10 |
@@ -31,30 +31,46 @@ discard block |
||
31 | 31 | |
32 | 32 | # Validate name & email |
33 | 33 | |
34 | - if (false === ($name = Validate::userName($name))) return 'USER_ERROR_NAME_INVALID'; |
|
34 | + if (false === ($name = Validate::userName($name))) { |
|
35 | + return 'USER_ERROR_NAME_INVALID'; |
|
36 | + } |
|
35 | 37 | |
36 | - if (false === ($email = Validate::userEmail($email))) return 'USER_ERROR_EMAIL_INVALID'; |
|
38 | + if (false === ($email = Validate::userEmail($email))) { |
|
39 | + return 'USER_ERROR_EMAIL_INVALID'; |
|
40 | + } |
|
37 | 41 | |
38 | 42 | # Validate password |
39 | 43 | |
40 | 44 | if ((0 === $this->user->id) || ('' !== $password)) { |
41 | 45 | |
42 | - if (false === ($password = Validate::userPassword($password))) return 'USER_ERROR_PASSWORD_INVALID'; |
|
46 | + if (false === ($password = Validate::userPassword($password))) { |
|
47 | + return 'USER_ERROR_PASSWORD_INVALID'; |
|
48 | + } |
|
43 | 49 | |
44 | - if (0 !== strcmp($password, $password_retype)) return 'USER_ERROR_PASSWORD_MISMATCH'; |
|
50 | + if (0 !== strcmp($password, $password_retype)) { |
|
51 | + return 'USER_ERROR_PASSWORD_MISMATCH'; |
|
52 | + } |
|
45 | 53 | } |
46 | 54 | |
47 | 55 | # Check name exists |
48 | 56 | |
49 | - if (false === ($check_name = $this->user->check('name', $name))) return 'USER_ERROR_MODIFY'; |
|
57 | + if (false === ($check_name = $this->user->check('name', $name))) { |
|
58 | + return 'USER_ERROR_MODIFY'; |
|
59 | + } |
|
50 | 60 | |
51 | - if ($check_name === 1) return 'USER_ERROR_NAME_DUPLICATE'; |
|
61 | + if ($check_name === 1) { |
|
62 | + return 'USER_ERROR_NAME_DUPLICATE'; |
|
63 | + } |
|
52 | 64 | |
53 | 65 | # Check email exists |
54 | 66 | |
55 | - if (false === ($check_email = $this->user->check('email', $email))) return 'USER_ERROR_MODIFY'; |
|
67 | + if (false === ($check_email = $this->user->check('email', $email))) { |
|
68 | + return 'USER_ERROR_MODIFY'; |
|
69 | + } |
|
56 | 70 | |
57 | - if ($check_email === 1) return 'USER_ERROR_EMAIL_DUPLICATE'; |
|
71 | + if ($check_email === 1) { |
|
72 | + return 'USER_ERROR_EMAIL_DUPLICATE'; |
|
73 | + } |
|
58 | 74 | |
59 | 75 | # Modify user |
60 | 76 | |
@@ -84,7 +100,9 @@ discard block |
||
84 | 100 | |
85 | 101 | $modifier = ((0 === $this->user->id) ? 'create' : 'edit'); |
86 | 102 | |
87 | - if (!$this->user->$modifier($data)) return 'USER_ERROR_MODIFY'; |
|
103 | + if (!$this->user->$modifier($data)) { |
|
104 | + return 'USER_ERROR_MODIFY'; |
|
105 | + } |
|
88 | 106 | |
89 | 107 | # ------------------------ |
90 | 108 |