@@ -12,9 +12,13 @@ |
||
12 | 12 | |
13 | 13 | public static function get(string $table) { |
14 | 14 | |
15 | - if (!isset(static::$classes[$table])) throw new Exception\General(static::$error_message); |
|
15 | + if (!isset(static::$classes[$table])) { |
|
16 | + throw new Exception\General(static::$error_message); |
|
17 | + } |
|
16 | 18 | |
17 | - if (!isset(static::$cache[$table])) static::$cache[$table] = new static::$classes[$table]; |
|
19 | + if (!isset(static::$cache[$table])) { |
|
20 | + static::$cache[$table] = new static::$classes[$table]; |
|
21 | + } |
|
18 | 22 | |
19 | 23 | # ------------------------ |
20 | 24 |
@@ -25,9 +25,13 @@ |
||
25 | 25 | |
26 | 26 | public static function get(string $table, int $id = 0) { |
27 | 27 | |
28 | - if (!isset(self::$classes[$table])) throw new Exception\General(self::$error_message); |
|
28 | + if (!isset(self::$classes[$table])) { |
|
29 | + throw new Exception\General(self::$error_message); |
|
30 | + } |
|
29 | 31 | |
30 | - if (isset(self::$cache[$table][$id])) return self::$cache[$table][$id]; |
|
32 | + if (isset(self::$cache[$table][$id])) { |
|
33 | + return self::$cache[$table][$id]; |
|
34 | + } |
|
31 | 35 | |
32 | 36 | $entity = new self::$classes[$table]; $entity->init($id); |
33 | 37 |
@@ -10,7 +10,9 @@ |
||
10 | 10 | |
11 | 11 | public function add(string $name, string $table, string $field, string $delete = null, string $update = null) { |
12 | 12 | |
13 | - if ((false === $this->definition->param($name)) || isset($this->list[$name])) return; |
|
13 | + if ((false === $this->definition->param($name)) || isset($this->list[$name])) { |
|
14 | + return; |
|
15 | + } |
|
14 | 16 | |
15 | 17 | $this->list[$name] = new Definition\Item\Foreign($name, $table, $field, $delete, $update); |
16 | 18 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | /** |
15 | 15 | * Validate a date using a given format |
16 | 16 | * |
17 | - * @return the formatted date or false on failure |
|
17 | + * @return string|null formatted date or false on failure |
|
18 | 18 | */ |
19 | 19 | |
20 | 20 | public static function validate(string $date, string $format) { |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * Get a date from a given timestamp and format it according to a given pattern. |
68 | 68 | * If the timestamp is null, a current time will be used |
69 | 69 | * |
70 | - * @return the formatted date or false if a non-numeric value is used for timestamp |
|
70 | + * @return string formatted date or false if a non-numeric value is used for timestamp |
|
71 | 71 | */ |
72 | 72 | |
73 | 73 | public static function get(string $format = DATE_FORMAT_STANDART, int $time = null) { |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | /** |
79 | 79 | * Get a day from a given timestamp. If the timestamp is null, a current time will be used |
80 | 80 | * |
81 | - * @return the formatted day or false if a non-numeric value is used for timestamp |
|
81 | + * @return string formatted day or false if a non-numeric value is used for timestamp |
|
82 | 82 | */ |
83 | 83 | |
84 | 84 | public static function getDay(int $time = null) { |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | /** |
90 | 90 | * Get a month from a given timestamp. If the timestamp is null, a current time will be used |
91 | 91 | * |
92 | - * @return the formatted month or false if a non-numeric value is used for timestamp |
|
92 | + * @return string formatted month or false if a non-numeric value is used for timestamp |
|
93 | 93 | */ |
94 | 94 | |
95 | 95 | public static function getMonth(int $time = null) { |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | /** |
101 | 101 | * Get a year from a given timestamp. If the timestamp is null, a current time will be used |
102 | 102 | * |
103 | - * @return the formatted year or false if a non-numeric value is used for timestamp |
|
103 | + * @return string formatted year or false if a non-numeric value is used for timestamp |
|
104 | 104 | */ |
105 | 105 | |
106 | 106 | public static function getYear(int $time = null) { |
@@ -19,9 +19,13 @@ discard block |
||
19 | 19 | |
20 | 20 | public static function validate(string $date, string $format) { |
21 | 21 | |
22 | - if (false === ($datetime = date_create_from_format($format, $date))) return false; |
|
22 | + if (false === ($datetime = date_create_from_format($format, $date))) { |
|
23 | + return false; |
|
24 | + } |
|
23 | 25 | |
24 | - if (false === ($formatted = $datetime->format($format))) return false; |
|
26 | + if (false === ($formatted = $datetime->format($format))) { |
|
27 | + return false; |
|
28 | + } |
|
25 | 29 | |
26 | 30 | # ------------------------ |
27 | 31 | |
@@ -58,7 +62,9 @@ discard block |
||
58 | 62 | |
59 | 63 | public static function validateYear(int $year) { |
60 | 64 | |
61 | - if (false === ($year = self::validate($year, 'Y'))) return false; |
|
65 | + if (false === ($year = self::validate($year, 'Y'))) { |
|
66 | + return false; |
|
67 | + } |
|
62 | 68 | |
63 | 69 | return (($year > '1900') ? (($year > self::getYear()) ? self::getYear() : $year) : '1900'); |
64 | 70 | } |
@@ -89,7 +89,7 @@ |
||
89 | 89 | /** |
90 | 90 | * Catch a POST value by the field key |
91 | 91 | * |
92 | - * @return true on success or false on failure |
|
92 | + * @return boolean on success or false on failure |
|
93 | 93 | */ |
94 | 94 | |
95 | 95 | public function post() { |
@@ -31,9 +31,9 @@ |
||
31 | 31 | |
32 | 32 | if (preg_match(REGEX_FORM_FIELD_KEY, $key)) { |
33 | 33 | |
34 | - $prefix = (('' !== $this->form->getName()) ? ($this->form->getName() . '_') : ''); |
|
34 | + $prefix = (('' !== $this->form->getName()) ? ($this->form->getName().'_') : ''); |
|
35 | 35 | |
36 | - $this->key = $key; $this->name = ($prefix . $key); $this->id = str_replace('_', '-', $this->name); |
|
36 | + $this->key = $key; $this->name = ($prefix.$key); $this->id = str_replace('_', '-', $this->name); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | # Set configuration |
@@ -9,7 +9,10 @@ |
||
9 | 9 | |
10 | 10 | namespace Form { |
11 | 11 | |
12 | - use Dataset, Form, Request, Tag; |
|
12 | + use Dataset; |
|
13 | + use Form; |
|
14 | + use Request; |
|
15 | + use Tag; |
|
13 | 16 | |
14 | 17 | abstract class Field { |
15 | 18 |
@@ -57,11 +57,17 @@ discard block |
||
57 | 57 | |
58 | 58 | # Set appearance |
59 | 59 | |
60 | - if ($this->disabled) $data['disabled'] = 'disabled'; |
|
60 | + if ($this->disabled) { |
|
61 | + $data['disabled'] = 'disabled'; |
|
62 | + } |
|
61 | 63 | |
62 | - if ($this->required) $data['data-required'] = 'required'; |
|
64 | + if ($this->required) { |
|
65 | + $data['data-required'] = 'required'; |
|
66 | + } |
|
63 | 67 | |
64 | - if ($this->error) $data['data-error'] = 'error'; |
|
68 | + if ($this->error) { |
|
69 | + $data['data-error'] = 'error'; |
|
70 | + } |
|
65 | 71 | |
66 | 72 | # ------------------------ |
67 | 73 | |
@@ -76,7 +82,9 @@ discard block |
||
76 | 82 | |
77 | 83 | public function post() : bool { |
78 | 84 | |
79 | - if ($this->posted || $this->disabled || ('' === $this->key)) return false; |
|
85 | + if ($this->posted || $this->disabled || ('' === $this->key)) { |
|
86 | + return false; |
|
87 | + } |
|
80 | 88 | |
81 | 89 | $this->error = (!$this->setValue(Request::post($this->name)) && $this->required); |
82 | 90 |
@@ -25,7 +25,7 @@ |
||
25 | 25 | /** |
26 | 26 | * Convert a JSON value to a string |
27 | 27 | * |
28 | - * @return the string or false on failure |
|
28 | + * @return string string or false on failure |
|
29 | 29 | */ |
30 | 30 | |
31 | 31 | public static function stringify($value) { |
@@ -41,7 +41,9 @@ discard block |
||
41 | 41 | |
42 | 42 | public static function load(string $file_name) { |
43 | 43 | |
44 | - if (false === ($contents = Explorer::getContents($file_name))) return null; |
|
44 | + if (false === ($contents = Explorer::getContents($file_name))) { |
|
45 | + return null; |
|
46 | + } |
|
45 | 47 | |
46 | 48 | return self::parse($contents); |
47 | 49 | } |
@@ -54,7 +56,9 @@ discard block |
||
54 | 56 | |
55 | 57 | public static function save(string $file_name, $value) { |
56 | 58 | |
57 | - if (false === ($value = self::stringify($value))) return false; |
|
59 | + if (false === ($value = self::stringify($value))) { |
|
60 | + return false; |
|
61 | + } |
|
58 | 62 | |
59 | 63 | return Explorer::putContents($file_name, $value); |
60 | 64 | } |
@@ -2,7 +2,9 @@ |
||
2 | 2 | |
3 | 3 | namespace { |
4 | 4 | |
5 | - use Modules\Extend, Utils\Map, Utils\Schema; |
|
5 | + use Modules\Extend; |
|
6 | + use Utils\Map; |
|
7 | + use Utils\Schema; |
|
6 | 8 | |
7 | 9 | class Dispatcher { |
8 | 10 |
@@ -14,7 +14,7 @@ |
||
14 | 14 | |
15 | 15 | if (null === ($data = Schema::get('System')->load())) { |
16 | 16 | |
17 | - Request::redirect(INSTALL_PATH . '/install.php'); |
|
17 | + Request::redirect(INSTALL_PATH.'/install.php'); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | # Connect to database |
@@ -2,7 +2,12 @@ |
||
2 | 2 | |
3 | 3 | namespace Frames\Admin\Area { |
4 | 4 | |
5 | - use Frames, Frames\Status, Modules, Ajax, Request, Template; |
|
5 | + use Frames; |
|
6 | + use Frames\Status; |
|
7 | + use Modules; |
|
8 | + use Ajax; |
|
9 | + use Request; |
|
10 | + use Template; |
|
6 | 11 | |
7 | 12 | abstract class Authorized extends Frames\Admin\Section { |
8 | 13 |
@@ -16,7 +16,7 @@ |
||
16 | 16 | |
17 | 17 | if (!Modules\Auth::check() || ((false !== Request::get('logout')) && Modules\Auth::logout())) { |
18 | 18 | |
19 | - Request::redirect(INSTALL_PATH . '/admin/login'); |
|
19 | + Request::redirect(INSTALL_PATH.'/admin/login'); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | # Handle request |
@@ -19,9 +19,13 @@ |
||
19 | 19 | |
20 | 20 | # Handle request |
21 | 21 | |
22 | - if (Template::isBlock($result = $this->handle())) return $this->displayPage($result, STATUS_CODE_200); |
|
22 | + if (Template::isBlock($result = $this->handle())) { |
|
23 | + return $this->displayPage($result, STATUS_CODE_200); |
|
24 | + } |
|
23 | 25 | |
24 | - if (Ajax::isResponse($result)) return Ajax::output($result); |
|
26 | + if (Ajax::isResponse($result)) { |
|
27 | + return Ajax::output($result); |
|
28 | + } |
|
25 | 29 | |
26 | 30 | # ------------------------ |
27 | 31 |
@@ -2,8 +2,17 @@ |
||
2 | 2 | |
3 | 3 | namespace Frames\Admin { |
4 | 4 | |
5 | - use Frames, Frames\Status, Modules\Auth, Modules\Extend, Utils\Messages, Utils\Popup, Utils\View; |
|
6 | - use DB, Debug, Language, Template; |
|
5 | + use Frames; |
|
6 | + use Frames\Status; |
|
7 | + use Modules\Auth; |
|
8 | + use Modules\Extend; |
|
9 | + use Utils\Messages; |
|
10 | + use Utils\Popup; |
|
11 | + use Utils\View; |
|
12 | + use DB; |
|
13 | + use Debug; |
|
14 | + use Language; |
|
15 | + use Template; |
|
7 | 16 | |
8 | 17 | abstract class Section extends Frames\Section { |
9 | 18 |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | |
24 | 24 | private function getLayout(Template\Block $contents) { |
25 | 25 | |
26 | - $layout = View::get('Layouts/' . $this->layout); |
|
26 | + $layout = View::get('Layouts/'.$this->layout); |
|
27 | 27 | |
28 | 28 | # Set menu and user |
29 | 29 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | |
83 | 83 | protected function displayPage(Template\Block $contents, int $status = STATUS_CODE_200) { |
84 | 84 | |
85 | - $page = View::get('Main/' . $this->layout); |
|
85 | + $page = View::get('Main/'.$this->layout); |
|
86 | 86 | |
87 | 87 | # Set language |
88 | 88 | |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | |
91 | 91 | # Set title |
92 | 92 | |
93 | - $page->title = ((('' !== $this->title) ? (Language::get($this->title) . ' | ') : '') . CADMIUM_NAME); |
|
93 | + $page->title = ((('' !== $this->title) ? (Language::get($this->title).' | ') : '').CADMIUM_NAME); |
|
94 | 94 | |
95 | 95 | # Set layout |
96 | 96 |
@@ -111,7 +111,9 @@ |
||
111 | 111 | |
112 | 112 | $ips = preg_split('/ +/', CONFIG_ADMIN_IP, -1, PREG_SPLIT_NO_EMPTY); |
113 | 113 | |
114 | - if (!in_array(REQUEST_CLIENT_IP, $ips, true)) return Status::error404(); |
|
114 | + if (!in_array(REQUEST_CLIENT_IP, $ips, true)) { |
|
115 | + return Status::error404(); |
|
116 | + } |
|
115 | 117 | } |
116 | 118 | |
117 | 119 | # ------------------------ |