@@ -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 |
@@ -12,13 +12,13 @@ discard block |
||
12 | 12 | |
13 | 13 | return ("SELECT SQL_CALC_FOUND_ROWS " . $this->getSelection() . " ") . |
14 | 14 | |
15 | - ("FROM " . static::$table . " ent ") . |
|
15 | + ("FROM " . static::$table . " ent ") . |
|
16 | 16 | |
17 | 17 | (('' !== ($condition = $this->getCondition($config))) ? ("WHERE " . $condition . " ") : "") . |
18 | 18 | |
19 | 19 | ("ORDER BY " . $this->getOrderBy($order_by) . " ") . |
20 | 20 | |
21 | - (($index > 0) ? ("LIMIT " . ((($index - 1) * $display) . ", " . $display)) : ""); |
|
21 | + (($index > 0) ? ("LIMIT " . ((($index - 1) * $display) . ", " . $display)) : ""); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | # Get nesting select query |
@@ -27,9 +27,9 @@ discard block |
||
27 | 27 | |
28 | 28 | return ("SELECT SQL_CALC_FOUND_ROWS " . $this->getSelection() . ", COUNT(chd.descendant) as children ") . |
29 | 29 | |
30 | - ("FROM " . static::$table . " ent ") . |
|
30 | + ("FROM " . static::$table . " ent ") . |
|
31 | 31 | |
32 | - ("LEFT JOIN " . static::$table_relations . " chd ON chd.ancestor = ent.id AND chd.depth = 1 ") . |
|
32 | + ("LEFT JOIN " . static::$table_relations . " chd ON chd.ancestor = ent.id AND chd.depth = 1 ") . |
|
33 | 33 | |
34 | 34 | ("LEFT JOIN " . static::$table_relations . " rel ON rel.descendant = ent.id AND rel.depth = 1 ") . |
35 | 35 | |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | |
40 | 40 | ("GROUP BY ent.id ORDER BY " . $this->getOrderBy($order_by) . " ") . |
41 | 41 | |
42 | - (($index > 0) ? ("LIMIT " . ((($index - 1) * $display) . ", " . $display)) : ""); |
|
42 | + (($index > 0) ? ("LIMIT " . ((($index - 1) * $display) . ", " . $display)) : ""); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | # Get default count query |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | |
49 | 49 | return ("SELECT COUNT(ent.id) as count FROM " . static::$table . " ent ") . |
50 | 50 | |
51 | - (('' !== ($condition = $this->getCondition($config))) ? ("WHERE " . $condition) : ""); |
|
51 | + (('' !== ($condition = $this->getCondition($config))) ? ("WHERE " . $condition) : ""); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | # Get nesting count query |
@@ -57,11 +57,11 @@ discard block |
||
57 | 57 | |
58 | 58 | return ("SELECT COUNT(ent.id) as count FROM " . static::$table . " ent ") . |
59 | 59 | |
60 | - ("LEFT JOIN " . static::$table_relations . " rel ON rel.descendant = ent.id AND rel.depth = 1 ") . |
|
60 | + ("LEFT JOIN " . static::$table_relations . " rel ON rel.descendant = ent.id AND rel.depth = 1 ") . |
|
61 | 61 | |
62 | - ("WHERE COALESCE(rel.ancestor, 0) = " . $parent_id . " ") . |
|
62 | + ("WHERE COALESCE(rel.ancestor, 0) = " . $parent_id . " ") . |
|
63 | 63 | |
64 | - (('' !== ($condition = $this->getCondition($config))) ? ("AND " . $condition) : ""); |
|
64 | + (('' !== ($condition = $this->getCondition($config))) ? ("AND " . $condition) : ""); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | # Select entries from DB |
@@ -10,58 +10,58 @@ discard block |
||
10 | 10 | |
11 | 11 | private function getDefaultSelectQuery(array $config, array $order_by, int $index, int $display) { |
12 | 12 | |
13 | - return ("SELECT SQL_CALC_FOUND_ROWS " . $this->getSelection() . " ") . |
|
13 | + return ("SELECT SQL_CALC_FOUND_ROWS ".$this->getSelection()." "). |
|
14 | 14 | |
15 | - ("FROM " . static::$table . " ent ") . |
|
15 | + ("FROM ".static::$table." ent "). |
|
16 | 16 | |
17 | - (('' !== ($condition = $this->getCondition($config))) ? ("WHERE " . $condition . " ") : "") . |
|
17 | + (('' !== ($condition = $this->getCondition($config))) ? ("WHERE ".$condition." ") : ""). |
|
18 | 18 | |
19 | - ("ORDER BY " . $this->getOrderBy($order_by) . " ") . |
|
19 | + ("ORDER BY ".$this->getOrderBy($order_by)." "). |
|
20 | 20 | |
21 | - (($index > 0) ? ("LIMIT " . ((($index - 1) * $display) . ", " . $display)) : ""); |
|
21 | + (($index > 0) ? ("LIMIT ".((($index - 1) * $display).", ".$display)) : ""); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | # Get nesting select query |
25 | 25 | |
26 | 26 | private function getNestingSelectQuery(int $parent_id, array $config, array $order_by, int $index, int $display) { |
27 | 27 | |
28 | - return ("SELECT SQL_CALC_FOUND_ROWS " . $this->getSelection() . ", COUNT(chd.descendant) as children ") . |
|
28 | + return ("SELECT SQL_CALC_FOUND_ROWS ".$this->getSelection().", COUNT(chd.descendant) as children "). |
|
29 | 29 | |
30 | - ("FROM " . static::$table . " ent ") . |
|
30 | + ("FROM ".static::$table." ent "). |
|
31 | 31 | |
32 | - ("LEFT JOIN " . static::$table_relations . " chd ON chd.ancestor = ent.id AND chd.depth = 1 ") . |
|
32 | + ("LEFT JOIN ".static::$table_relations." chd ON chd.ancestor = ent.id AND chd.depth = 1 "). |
|
33 | 33 | |
34 | - ("LEFT JOIN " . static::$table_relations . " rel ON rel.descendant = ent.id AND rel.depth = 1 ") . |
|
34 | + ("LEFT JOIN ".static::$table_relations." rel ON rel.descendant = ent.id AND rel.depth = 1 "). |
|
35 | 35 | |
36 | - ("WHERE COALESCE(rel.ancestor, 0) = " . $parent_id . " ") . |
|
36 | + ("WHERE COALESCE(rel.ancestor, 0) = ".$parent_id." "). |
|
37 | 37 | |
38 | - (('' !== ($condition = $this->getCondition($config))) ? ("AND " . $condition . " ") : "") . |
|
38 | + (('' !== ($condition = $this->getCondition($config))) ? ("AND ".$condition." ") : ""). |
|
39 | 39 | |
40 | - ("GROUP BY ent.id ORDER BY " . $this->getOrderBy($order_by) . " ") . |
|
40 | + ("GROUP BY ent.id ORDER BY ".$this->getOrderBy($order_by)." "). |
|
41 | 41 | |
42 | - (($index > 0) ? ("LIMIT " . ((($index - 1) * $display) . ", " . $display)) : ""); |
|
42 | + (($index > 0) ? ("LIMIT ".((($index - 1) * $display).", ".$display)) : ""); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | # Get default count query |
46 | 46 | |
47 | 47 | private function getDefaultCountQuery(array $config) { |
48 | 48 | |
49 | - return ("SELECT COUNT(ent.id) as count FROM " . static::$table . " ent ") . |
|
49 | + return ("SELECT COUNT(ent.id) as count FROM ".static::$table." ent "). |
|
50 | 50 | |
51 | - (('' !== ($condition = $this->getCondition($config))) ? ("WHERE " . $condition) : ""); |
|
51 | + (('' !== ($condition = $this->getCondition($config))) ? ("WHERE ".$condition) : ""); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | # Get nesting count query |
55 | 55 | |
56 | 56 | private function getNestingCountQuery(int $parent_id, array $config) { |
57 | 57 | |
58 | - return ("SELECT COUNT(ent.id) as count FROM " . static::$table . " ent ") . |
|
58 | + return ("SELECT COUNT(ent.id) as count FROM ".static::$table." ent "). |
|
59 | 59 | |
60 | - ("LEFT JOIN " . static::$table_relations . " rel ON rel.descendant = ent.id AND rel.depth = 1 ") . |
|
60 | + ("LEFT JOIN ".static::$table_relations." rel ON rel.descendant = ent.id AND rel.depth = 1 "). |
|
61 | 61 | |
62 | - ("WHERE COALESCE(rel.ancestor, 0) = " . $parent_id . " ") . |
|
62 | + ("WHERE COALESCE(rel.ancestor, 0) = ".$parent_id." "). |
|
63 | 63 | |
64 | - (('' !== ($condition = $this->getCondition($config))) ? ("AND " . $condition) : ""); |
|
64 | + (('' !== ($condition = $this->getCondition($config))) ? ("AND ".$condition) : ""); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | # Select entries from DB |
@@ -74,9 +74,7 @@ discard block |
||
74 | 74 | |
75 | 75 | # Select entities |
76 | 76 | |
77 | - $query = ((null === $parent_id) ? $this->getDefaultSelectQuery($config, $order_by, $index, $display) : |
|
78 | - |
|
79 | - $this->getNestingSelectQuery($parent_id, $config, $order_by, $index, $display)); |
|
77 | + $query = ((null === $parent_id) ? $this->getDefaultSelectQuery($config, $order_by, $index, $display) : $this->getNestingSelectQuery($parent_id, $config, $order_by, $index, $display)); |
|
80 | 78 | |
81 | 79 | if (!(DB::send($query) && DB::last()->status)) return false; |
82 | 80 | |
@@ -113,9 +111,7 @@ discard block |
||
113 | 111 | |
114 | 112 | # Count entities |
115 | 113 | |
116 | - $query = ((null === $parent_id) ? $this->getDefaultCountQuery($config) : |
|
117 | - |
|
118 | - $this->getNestingCountQuery($parent_id, $config)); |
|
114 | + $query = ((null === $parent_id) ? $this->getDefaultCountQuery($config) : $this->getNestingCountQuery($parent_id, $config)); |
|
119 | 115 | |
120 | 116 | if (!(DB::send($query) && DB::last()->status)) return false; |
121 | 117 |
@@ -68,9 +68,13 @@ discard block |
||
68 | 68 | |
69 | 69 | private function select(int $parent_id = null, array $config = [], array $order_by = [], int $index = 0, int $display = 0) { |
70 | 70 | |
71 | - if (!((null === $parent_id) || ($parent_id >= 0))) return false; |
|
71 | + if (!((null === $parent_id) || ($parent_id >= 0))) { |
|
72 | + return false; |
|
73 | + } |
|
72 | 74 | |
73 | - if (!(($index >= 0) && ($display >= 0))) return false; |
|
75 | + if (!(($index >= 0) && ($display >= 0))) { |
|
76 | + return false; |
|
77 | + } |
|
74 | 78 | |
75 | 79 | # Select entities |
76 | 80 | |
@@ -78,7 +82,9 @@ discard block |
||
78 | 82 | |
79 | 83 | $this->getNestingSelectQuery($parent_id, $config, $order_by, $index, $display)); |
80 | 84 | |
81 | - if (!(DB::send($query) && DB::last()->status)) return false; |
|
85 | + if (!(DB::send($query) && DB::last()->status)) { |
|
86 | + return false; |
|
87 | + } |
|
82 | 88 | |
83 | 89 | # Process results |
84 | 90 | |
@@ -90,7 +96,9 @@ discard block |
||
90 | 96 | |
91 | 97 | $items['list'][$entity->id] = ['entity' => $entity]; |
92 | 98 | |
93 | - if (null !== $parent_id) $items['list'][$entity->id]['children'] = intval($data['children']); |
|
99 | + if (null !== $parent_id) { |
|
100 | + $items['list'][$entity->id]['children'] = intval($data['children']); |
|
101 | + } |
|
94 | 102 | } |
95 | 103 | |
96 | 104 | # Count total |
@@ -109,7 +117,9 @@ discard block |
||
109 | 117 | |
110 | 118 | private function count(int $parent_id = null, array $config = []) { |
111 | 119 | |
112 | - if (!((null === $parent_id) || ($parent_id >= 0))) return false; |
|
120 | + if (!((null === $parent_id) || ($parent_id >= 0))) { |
|
121 | + return false; |
|
122 | + } |
|
113 | 123 | |
114 | 124 | # Count entities |
115 | 125 | |
@@ -117,7 +127,9 @@ discard block |
||
117 | 127 | |
118 | 128 | $this->getNestingCountQuery($parent_id, $config)); |
119 | 129 | |
120 | - if (!(DB::send($query) && DB::last()->status)) return false; |
|
130 | + if (!(DB::send($query) && DB::last()->status)) { |
|
131 | + return false; |
|
132 | + } |
|
121 | 133 | |
122 | 134 | # ------------------------ |
123 | 135 | |
@@ -142,7 +154,9 @@ discard block |
||
142 | 154 | |
143 | 155 | public function children(int $parent_id = 0, array $config = [], array $order_by = [], int $index = 0, int $display = 0) { |
144 | 156 | |
145 | - if (!static::$nesting) return false; |
|
157 | + if (!static::$nesting) { |
|
158 | + return false; |
|
159 | + } |
|
146 | 160 | |
147 | 161 | return $this->select(...func_get_args()); |
148 | 162 | } |
@@ -151,7 +165,9 @@ discard block |
||
151 | 165 | |
152 | 166 | public function childrenCount(int $parent_id = 0, array $config = []) { |
153 | 167 | |
154 | - if (!static::$nesting) return false; |
|
168 | + if (!static::$nesting) { |
|
169 | + return false; |
|
170 | + } |
|
155 | 171 | |
156 | 172 | return $this->count(...func_get_args()); |
157 | 173 | } |
@@ -2,7 +2,8 @@ |
||
2 | 2 | |
3 | 3 | namespace Modules\Entitizer\Utils { |
4 | 4 | |
5 | - use Modules\Entitizer, Config; |
|
5 | + use Modules\Entitizer; |
|
6 | + use Config; |
|
6 | 7 | |
7 | 8 | abstract class View { |
8 | 9 |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | |
33 | 33 | $selection = []; |
34 | 34 | |
35 | - foreach ($this->definition->paramsSecure() as $field) $selection[] = ('ent.' . $field); |
|
35 | + foreach ($this->definition->paramsSecure() as $field) $selection[] = ('ent.'.$field); |
|
36 | 36 | |
37 | 37 | # ------------------------ |
38 | 38 | |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | |
46 | 46 | $order_by = []; |
47 | 47 | |
48 | - foreach ($this->castOrderBy($data) as $field => $direction) $order_by[] = ('ent.' . $field . ' ' . $direction); |
|
48 | + foreach ($this->castOrderBy($data) as $field => $direction) $order_by[] = ('ent.'.$field.' '.$direction); |
|
49 | 49 | |
50 | 50 | # ------------------------ |
51 | 51 |
@@ -16,7 +16,9 @@ discard block |
||
16 | 16 | |
17 | 17 | foreach ($data as $field => $direction) { |
18 | 18 | |
19 | - if (false === ($param = $this->definition->param($field))) continue; |
|
19 | + if (false === ($param = $this->definition->param($field))) { |
|
20 | + continue; |
|
21 | + } |
|
20 | 22 | |
21 | 23 | $order_by[$param->name] = ((strtoupper($direction) !== 'DESC') ? 'ASC' : 'DESC'); |
22 | 24 | } |
@@ -32,7 +34,9 @@ discard block |
||
32 | 34 | |
33 | 35 | $selection = []; |
34 | 36 | |
35 | - foreach ($this->definition->paramsSecure() as $field) $selection[] = ('ent.' . $field); |
|
37 | + foreach ($this->definition->paramsSecure() as $field) { |
|
38 | + $selection[] = ('ent.' . $field); |
|
39 | + } |
|
36 | 40 | |
37 | 41 | # ------------------------ |
38 | 42 | |
@@ -45,7 +49,9 @@ discard block |
||
45 | 49 | |
46 | 50 | $order_by = []; |
47 | 51 | |
48 | - foreach ($this->castOrderBy($data) as $field => $direction) $order_by[] = ('ent.' . $field . ' ' . $direction); |
|
52 | + foreach ($this->castOrderBy($data) as $field => $direction) { |
|
53 | + $order_by[] = ('ent.' . $field . ' ' . $direction); |
|
54 | + } |
|
49 | 55 | |
50 | 56 | # ------------------------ |
51 | 57 |
@@ -2,8 +2,15 @@ |
||
2 | 2 | |
3 | 3 | namespace Modules\Filemanager\Handler { |
4 | 4 | |
5 | - use Modules\Filemanager, Utils\Messages, Utils\Pagination, Utils\Uploader, Utils\View; |
|
6 | - use Ajax, Arr, Explorer, Language, Number, Request, Template, Url; |
|
5 | + use Modules\Filemanager; |
|
6 | + use Utils\Pagination; |
|
7 | + use Utils\Uploader; |
|
8 | + use Utils\View; |
|
9 | + use Arr; |
|
10 | + use Number; |
|
11 | + use Request; |
|
12 | + use Template; |
|
13 | + use Url; |
|
7 | 14 | |
8 | 15 | class Listview { |
9 | 16 |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | |
16 | 16 | $dirs = []; $files = []; |
17 | 17 | |
18 | - $prefix = (('' !== $this->parent->path()) ? ($this->parent->path() . '/') : ''); |
|
18 | + $prefix = (('' !== $this->parent->path()) ? ($this->parent->path().'/') : ''); |
|
19 | 19 | |
20 | 20 | # Read parent directory contents |
21 | 21 | |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | |
26 | 26 | if (in_array($name, ['.', '..', '.empty'], true)) continue; |
27 | 27 | |
28 | - $path = ($prefix . $name); $path_full = ($this->parent->pathFull() . $name); |
|
28 | + $path = ($prefix.$name); $path_full = ($this->parent->pathFull().$name); |
|
29 | 29 | |
30 | 30 | $data = ['name' => $name, 'path' => $path, 'path_full' => $path_full]; |
31 | 31 | |
@@ -112,9 +112,9 @@ discard block |
||
112 | 112 | |
113 | 113 | private function getPaginationBlock() { |
114 | 114 | |
115 | - $query = (('' !== $this->parent->path()) ? ('?parent=' . $this->parent->path()) : ''); |
|
115 | + $query = (('' !== $this->parent->path()) ? ('?parent='.$this->parent->path()) : ''); |
|
116 | 116 | |
117 | - $url = new Url(INSTALL_PATH . '/admin/content/filemanager' . $query); |
|
117 | + $url = new Url(INSTALL_PATH.'/admin/content/filemanager'.$query); |
|
118 | 118 | |
119 | 119 | # ------------------------ |
120 | 120 | |
@@ -137,9 +137,9 @@ discard block |
||
137 | 137 | |
138 | 138 | # Set link |
139 | 139 | |
140 | - $query = (('' !== $this->parent->path()) ? ('?parent=' . $this->parent->path()) : ''); |
|
140 | + $query = (('' !== $this->parent->path()) ? ('?parent='.$this->parent->path()) : ''); |
|
141 | 141 | |
142 | - $contents->link = (INSTALL_PATH . '/admin/content/filemanager' . $query); |
|
142 | + $contents->link = (INSTALL_PATH.'/admin/content/filemanager'.$query); |
|
143 | 143 | |
144 | 144 | # Implement form |
145 | 145 | |
@@ -180,9 +180,9 @@ discard block |
||
180 | 180 | |
181 | 181 | if ($upload || $this->form->handle(new Filemanager\Controller\Create($this->parent))) { |
182 | 182 | |
183 | - $query = (('' !== $this->parent->path()) ? ('?parent=' . $this->parent->path()) : ''); |
|
183 | + $query = (('' !== $this->parent->path()) ? ('?parent='.$this->parent->path()) : ''); |
|
184 | 184 | |
185 | - Request::redirect(INSTALL_PATH . '/admin/content/filemanager' . $query); |
|
185 | + Request::redirect(INSTALL_PATH.'/admin/content/filemanager'.$query); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | # Get index |
@@ -23,15 +23,19 @@ discard block |
||
23 | 23 | |
24 | 24 | while (false !== ($name = readdir($handler))) { |
25 | 25 | |
26 | - if (in_array($name, ['.', '..', '.empty'], true)) continue; |
|
26 | + if (in_array($name, ['.', '..', '.empty'], true)) { |
|
27 | + continue; |
|
28 | + } |
|
27 | 29 | |
28 | 30 | $path = ($prefix . $name); $path_full = ($this->parent->pathFull() . $name); |
29 | 31 | |
30 | 32 | $data = ['name' => $name, 'path' => $path, 'path_full' => $path_full]; |
31 | 33 | |
32 | - if (@is_dir($path_full)) $dirs[] = array_merge($data, ['type' => FILEMANAGER_TYPE_DIR]); |
|
33 | - |
|
34 | - else if (@is_file($path_full)) $files[] = array_merge($data, ['type' => FILEMANAGER_TYPE_FILE]); |
|
34 | + if (@is_dir($path_full)) { |
|
35 | + $dirs[] = array_merge($data, ['type' => FILEMANAGER_TYPE_DIR]); |
|
36 | + } else if (@is_file($path_full)) { |
|
37 | + $files[] = array_merge($data, ['type' => FILEMANAGER_TYPE_FILE]); |
|
38 | + } |
|
35 | 39 | } |
36 | 40 | |
37 | 41 | closedir($handler); |
@@ -98,9 +102,11 @@ discard block |
||
98 | 102 | |
99 | 103 | foreach ($this->items['list'] as $item) { |
100 | 104 | |
101 | - if ($item['type'] === FILEMANAGER_TYPE_DIR) $items->add($this->getDirItemBlock($item)); |
|
102 | - |
|
103 | - else if ($item['type'] === FILEMANAGER_TYPE_FILE) $items->add($this->getFileItemBlock($item)); |
|
105 | + if ($item['type'] === FILEMANAGER_TYPE_DIR) { |
|
106 | + $items->add($this->getDirItemBlock($item)); |
|
107 | + } else if ($item['type'] === FILEMANAGER_TYPE_FILE) { |
|
108 | + $items->add($this->getFileItemBlock($item)); |
|
109 | + } |
|
104 | 110 | } |
105 | 111 | |
106 | 112 | # ------------------------ |
@@ -149,7 +155,9 @@ discard block |
||
149 | 155 | |
150 | 156 | $items = $this->getItemsBlock(); |
151 | 157 | |
152 | - if ($items->count() > 0) $contents->items = $items; |
|
158 | + if ($items->count() > 0) { |
|
159 | + $contents->items = $items; |
|
160 | + } |
|
153 | 161 | |
154 | 162 | # Set pagination |
155 | 163 |
@@ -10,7 +10,9 @@ |
||
10 | 10 | |
11 | 11 | protected static function init(string $file_name) { |
12 | 12 | |
13 | - if (is_array($range = Explorer::php($file_name))) static::$range = $range; |
|
13 | + if (is_array($range = Explorer::php($file_name))) { |
|
14 | + static::$range = $range; |
|
15 | + } |
|
14 | 16 | } |
15 | 17 | |
16 | 18 | # Check if item exists |
@@ -10,7 +10,12 @@ discard block |
||
10 | 10 | |
11 | 11 | $value = false; |
12 | 12 | |
13 | - foreach ($path as $item) if (isset($array[$item])) $value = ($array = $array[$item]); else return false; |
|
13 | + foreach ($path as $item) { |
|
14 | + if (isset($array[$item])) $value = ($array = $array[$item]); |
|
15 | + } |
|
16 | + else { |
|
17 | + return false; |
|
18 | + } |
|
14 | 19 | |
15 | 20 | # ------------------------ |
16 | 21 | |
@@ -23,10 +28,12 @@ discard block |
||
23 | 28 | |
24 | 29 | $result = []; |
25 | 30 | |
26 | - foreach ($keys as $key) if (is_scalar($key)) { |
|
31 | + foreach ($keys as $key) { |
|
32 | + if (is_scalar($key)) { |
|
27 | 33 | |
28 | 34 | $result[$key] = ((isset($array[$key]) && is_scalar($array[$key])) ? $array[$key] : false); |
29 | 35 | } |
36 | + } |
|
30 | 37 | |
31 | 38 | # ------------------------ |
32 | 39 | |
@@ -39,7 +46,9 @@ discard block |
||
39 | 46 | |
40 | 47 | $result = []; |
41 | 48 | |
42 | - foreach ($array as $key => $value) $result[] = [$key_name => $key, $value_name => $value]; |
|
49 | + foreach ($array as $key => $value) { |
|
50 | + $result[] = [$key_name => $key, $value_name => $value]; |
|
51 | + } |
|
43 | 52 | |
44 | 53 | # ------------------------ |
45 | 54 | |
@@ -57,9 +66,15 @@ discard block |
||
57 | 66 | |
58 | 67 | $result = []; $column = array_map($select_key, $array); |
59 | 68 | |
60 | - if (!$descending) asort($column); else arsort($column); |
|
69 | + if (!$descending) { |
|
70 | + asort($column); |
|
71 | + } else { |
|
72 | + arsort($column); |
|
73 | + } |
|
61 | 74 | |
62 | - foreach (array_keys($column) as $key) $result[$key] = $array[$key]; |
|
75 | + foreach (array_keys($column) as $key) { |
|
76 | + $result[$key] = $array[$key]; |
|
77 | + } |
|
63 | 78 | |
64 | 79 | # ------------------------ |
65 | 80 |
@@ -10,7 +10,9 @@ |
||
10 | 10 | |
11 | 11 | public function set(string $name, $value) { |
12 | 12 | |
13 | - if (is_scalar($value)) $this->data[$name] = $value; |
|
13 | + if (is_scalar($value)) { |
|
14 | + $this->data[$name] = $value; |
|
15 | + } |
|
14 | 16 | |
15 | 17 | return $this; |
16 | 18 | } |
@@ -2,15 +2,15 @@ |
||
2 | 2 | |
3 | 3 | # Database tables |
4 | 4 | |
5 | -define('TABLE_PAGES', 'pages'); |
|
6 | -define('TABLE_PAGES_RELATIONS', 'pages_relations'); |
|
5 | +define('TABLE_PAGES', 'pages'); |
|
6 | +define('TABLE_PAGES_RELATIONS', 'pages_relations'); |
|
7 | 7 | |
8 | -define('TABLE_MENU', 'menu'); |
|
9 | -define('TABLE_MENU_RELATIONS', 'menu_relations'); |
|
8 | +define('TABLE_MENU', 'menu'); |
|
9 | +define('TABLE_MENU_RELATIONS', 'menu_relations'); |
|
10 | 10 | |
11 | -define('TABLE_VARIABLES', 'variables'); |
|
12 | -define('TABLE_WIDGETS', 'widgets'); |
|
11 | +define('TABLE_VARIABLES', 'variables'); |
|
12 | +define('TABLE_WIDGETS', 'widgets'); |
|
13 | 13 | |
14 | -define('TABLE_USERS', 'users'); |
|
15 | -define('TABLE_USERS_SECRETS', 'users_secrets'); |
|
16 | -define('TABLE_USERS_SESSIONS', 'users_sessions'); |
|
14 | +define('TABLE_USERS', 'users'); |
|
15 | +define('TABLE_USERS_SECRETS', 'users_secrets'); |
|
16 | +define('TABLE_USERS_SESSIONS', 'users_sessions'); |
@@ -2,126 +2,126 @@ |
||
2 | 2 | |
3 | 3 | # Admin ip |
4 | 4 | |
5 | -define('CONFIG_ADMIN_IP', ''); |
|
5 | +define('CONFIG_ADMIN_IP', ''); |
|
6 | 6 | |
7 | 7 | # Session |
8 | 8 | |
9 | -define('CONFIG_SESSION_NAME', '_sessid'); |
|
10 | -define('CONFIG_SESSION_LIFETIME', 2592000); # 30 days |
|
9 | +define('CONFIG_SESSION_NAME', '_sessid'); |
|
10 | +define('CONFIG_SESSION_LIFETIME', 2592000); # 30 days |
|
11 | 11 | |
12 | 12 | # Language |
13 | 13 | |
14 | -define('CONFIG_LANGUAGE_COOKIE_EXPIRES', 30758400); # 356 days |
|
14 | +define('CONFIG_LANGUAGE_COOKIE_EXPIRES', 30758400); # 356 days |
|
15 | 15 | |
16 | 16 | # Template |
17 | 17 | |
18 | -define('CONFIG_TEMPLATE_COOKIE_EXPIRES', 30758400); # 356 days |
|
18 | +define('CONFIG_TEMPLATE_COOKIE_EXPIRES', 30758400); # 356 days |
|
19 | 19 | |
20 | 20 | # Entitizer |
21 | 21 | |
22 | -define('CONFIG_ENTITIZER_MAX_DEPTH', 6); |
|
22 | +define('CONFIG_ENTITIZER_MAX_DEPTH', 6); |
|
23 | 23 | |
24 | 24 | # Page |
25 | 25 | |
26 | -define('CONFIG_PAGE_TITLE_MAX_LENGTH', 255); |
|
27 | -define('CONFIG_PAGE_NAME_MAX_LENGTH', 40); |
|
28 | -define('CONFIG_PAGE_DESCRIPTION_MAX_LENGTH', 512); |
|
29 | -define('CONFIG_PAGE_KEYWORDS_MAX_LENGTH', 512); |
|
26 | +define('CONFIG_PAGE_TITLE_MAX_LENGTH', 255); |
|
27 | +define('CONFIG_PAGE_NAME_MAX_LENGTH', 40); |
|
28 | +define('CONFIG_PAGE_DESCRIPTION_MAX_LENGTH', 512); |
|
29 | +define('CONFIG_PAGE_KEYWORDS_MAX_LENGTH', 512); |
|
30 | 30 | |
31 | 31 | # Menuitem |
32 | 32 | |
33 | -define('CONFIG_MENUITEM_TEXT_MAX_LENGTH', 255); |
|
34 | -define('CONFIG_MENUITEM_SLUG_MAX_LENGTH', 255); |
|
35 | -define('CONFIG_MENUITEM_POSITION_MAX_LENGTH', 2); |
|
33 | +define('CONFIG_MENUITEM_TEXT_MAX_LENGTH', 255); |
|
34 | +define('CONFIG_MENUITEM_SLUG_MAX_LENGTH', 255); |
|
35 | +define('CONFIG_MENUITEM_POSITION_MAX_LENGTH', 2); |
|
36 | 36 | |
37 | 37 | # Variables |
38 | 38 | |
39 | -define('CONFIG_VARIABLE_TITLE_MAX_LENGTH', 64); |
|
40 | -define('CONFIG_VARIABLE_NAME_MAX_LENGTH', 32); |
|
41 | -define('CONFIG_VARIABLE_VALUE_MAX_LENGTH', 255); |
|
39 | +define('CONFIG_VARIABLE_TITLE_MAX_LENGTH', 64); |
|
40 | +define('CONFIG_VARIABLE_NAME_MAX_LENGTH', 32); |
|
41 | +define('CONFIG_VARIABLE_VALUE_MAX_LENGTH', 255); |
|
42 | 42 | |
43 | 43 | # Widgets |
44 | 44 | |
45 | -define('CONFIG_WIDGET_TITLE_MAX_LENGTH', 64); |
|
46 | -define('CONFIG_WIDGET_NAME_MAX_LENGTH', 32); |
|
45 | +define('CONFIG_WIDGET_TITLE_MAX_LENGTH', 64); |
|
46 | +define('CONFIG_WIDGET_NAME_MAX_LENGTH', 32); |
|
47 | 47 | |
48 | 48 | # Filemanager |
49 | 49 | |
50 | -define('CONFIG_FILEMANAGER_NAME_MAX_LENGTH', 128); |
|
50 | +define('CONFIG_FILEMANAGER_NAME_MAX_LENGTH', 128); |
|
51 | 51 | |
52 | 52 | # User |
53 | 53 | |
54 | -define('CONFIG_USER_SESSION_LIFETIME', 604800); # 7 days |
|
55 | -define('CONFIG_USER_SECRET_LIFETIME', 86400); # 1 day |
|
54 | +define('CONFIG_USER_SESSION_LIFETIME', 604800); # 7 days |
|
55 | +define('CONFIG_USER_SECRET_LIFETIME', 86400); # 1 day |
|
56 | 56 | |
57 | -define('CONFIG_USER_NAME_MIN_LENGTH', 4); |
|
58 | -define('CONFIG_USER_NAME_MAX_LENGTH', 16); |
|
57 | +define('CONFIG_USER_NAME_MIN_LENGTH', 4); |
|
58 | +define('CONFIG_USER_NAME_MAX_LENGTH', 16); |
|
59 | 59 | |
60 | -define('CONFIG_USER_PASSWORD_MIN_LENGTH', 4); |
|
61 | -define('CONFIG_USER_PASSWORD_MAX_LENGTH', 32); |
|
60 | +define('CONFIG_USER_PASSWORD_MIN_LENGTH', 4); |
|
61 | +define('CONFIG_USER_PASSWORD_MAX_LENGTH', 32); |
|
62 | 62 | |
63 | -define('CONFIG_USER_EMAIL_MAX_LENGTH', 128); |
|
63 | +define('CONFIG_USER_EMAIL_MAX_LENGTH', 128); |
|
64 | 64 | |
65 | -define('CONFIG_USER_FIRST_NAME_MAX_LENGTH', 32); |
|
66 | -define('CONFIG_USER_LAST_NAME_MAX_LENGTH', 32); |
|
65 | +define('CONFIG_USER_FIRST_NAME_MAX_LENGTH', 32); |
|
66 | +define('CONFIG_USER_LAST_NAME_MAX_LENGTH', 32); |
|
67 | 67 | |
68 | -define('CONFIG_USER_CITY_MAX_LENGTH', 32); |
|
68 | +define('CONFIG_USER_CITY_MAX_LENGTH', 32); |
|
69 | 69 | |
70 | -define('CONFIG_USER_CAPTCHA_MAX_LENGTH', 16); |
|
70 | +define('CONFIG_USER_CAPTCHA_MAX_LENGTH', 16); |
|
71 | 71 | |
72 | 72 | # Captcha |
73 | 73 | |
74 | -define('CONFIG_CAPTCHA_LENGTH', 5); |
|
74 | +define('CONFIG_CAPTCHA_LENGTH', 5); |
|
75 | 75 | |
76 | -define('CONFIG_CAPTCHA_WIDTH', 150); |
|
77 | -define('CONFIG_CAPTCHA_HEIGHT', 40); |
|
76 | +define('CONFIG_CAPTCHA_WIDTH', 150); |
|
77 | +define('CONFIG_CAPTCHA_HEIGHT', 40); |
|
78 | 78 | |
79 | -define('CONFIG_CAPTCHA_FONT', 'Fonts/airstrip.ttf'); |
|
80 | -define('CONFIG_CAPTCHA_FONT_SIZE', 20); |
|
79 | +define('CONFIG_CAPTCHA_FONT', 'Fonts/airstrip.ttf'); |
|
80 | +define('CONFIG_CAPTCHA_FONT_SIZE', 20); |
|
81 | 81 | |
82 | -define('CONFIG_CAPTCHA_TEXT_INDENT', 15); |
|
83 | -define('CONFIG_CAPTCHA_TEXT_STEP', 25); |
|
82 | +define('CONFIG_CAPTCHA_TEXT_INDENT', 15); |
|
83 | +define('CONFIG_CAPTCHA_TEXT_STEP', 25); |
|
84 | 84 | |
85 | 85 | # Admin |
86 | 86 | |
87 | -define('CONFIG_ADMIN_LANGUAGE_DEFAULT', 'en-US'); |
|
88 | -define('CONFIG_ADMIN_TEMPLATE_DEFAULT', 'Default'); |
|
87 | +define('CONFIG_ADMIN_LANGUAGE_DEFAULT', 'en-US'); |
|
88 | +define('CONFIG_ADMIN_TEMPLATE_DEFAULT', 'Default'); |
|
89 | 89 | |
90 | -define('CONFIG_ADMIN_PAGES_DISPLAY', 50); |
|
91 | -define('CONFIG_ADMIN_MENUITEMS_DISPLAY', 50); |
|
92 | -define('CONFIG_ADMIN_VARIABLES_DISPLAY', 50); |
|
93 | -define('CONFIG_ADMIN_WIDGETS_DISPLAY', 50); |
|
94 | -define('CONFIG_ADMIN_USERS_DISPLAY', 50); |
|
90 | +define('CONFIG_ADMIN_PAGES_DISPLAY', 50); |
|
91 | +define('CONFIG_ADMIN_MENUITEMS_DISPLAY', 50); |
|
92 | +define('CONFIG_ADMIN_VARIABLES_DISPLAY', 50); |
|
93 | +define('CONFIG_ADMIN_WIDGETS_DISPLAY', 50); |
|
94 | +define('CONFIG_ADMIN_USERS_DISPLAY', 50); |
|
95 | 95 | |
96 | -define('CONFIG_ADMIN_FILEMANAGER_ITEMS_DISPLAY', 50); |
|
96 | +define('CONFIG_ADMIN_FILEMANAGER_ITEMS_DISPLAY', 50); |
|
97 | 97 | |
98 | 98 | # Site |
99 | 99 | |
100 | -define('CONFIG_SITE_LANGUAGE_DEFAULT', 'en-US'); |
|
101 | -define('CONFIG_SITE_TEMPLATE_DEFAULT', 'Default'); |
|
100 | +define('CONFIG_SITE_LANGUAGE_DEFAULT', 'en-US'); |
|
101 | +define('CONFIG_SITE_TEMPLATE_DEFAULT', 'Default'); |
|
102 | 102 | |
103 | -define('CONFIG_SITE_TITLE_DEFAULT', 'Demo Site'); |
|
104 | -define('CONFIG_SITE_SLOGAN_DEFAULT', 'A place for site slogan'); |
|
103 | +define('CONFIG_SITE_TITLE_DEFAULT', 'Demo Site'); |
|
104 | +define('CONFIG_SITE_SLOGAN_DEFAULT', 'A place for site slogan'); |
|
105 | 105 | |
106 | -define('CONFIG_SITE_TITLE_MAX_LENGTH', 128); |
|
107 | -define('CONFIG_SITE_SLOGAN_MAX_LENGTH', 255); |
|
108 | -define('CONFIG_SITE_DESCRIPTION_MAX_LENGTH', 512); |
|
109 | -define('CONFIG_SITE_KEYWORDS_MAX_LENGTH', 512); |
|
106 | +define('CONFIG_SITE_TITLE_MAX_LENGTH', 128); |
|
107 | +define('CONFIG_SITE_SLOGAN_MAX_LENGTH', 255); |
|
108 | +define('CONFIG_SITE_DESCRIPTION_MAX_LENGTH', 512); |
|
109 | +define('CONFIG_SITE_KEYWORDS_MAX_LENGTH', 512); |
|
110 | 110 | |
111 | 111 | # System |
112 | 112 | |
113 | -define('CONFIG_SYSTEM_URL_MAX_LENGTH', 128); |
|
114 | -define('CONFIG_SYSTEM_EMAIL_MAX_LENGTH', 128); |
|
113 | +define('CONFIG_SYSTEM_URL_MAX_LENGTH', 128); |
|
114 | +define('CONFIG_SYSTEM_EMAIL_MAX_LENGTH', 128); |
|
115 | 115 | |
116 | -define('CONFIG_SYSTEM_TIMEZONE_DEFAULT', 'UTC'); |
|
116 | +define('CONFIG_SYSTEM_TIMEZONE_DEFAULT', 'UTC'); |
|
117 | 117 | |
118 | 118 | # Database |
119 | 119 | |
120 | -define('CONFIG_DATABASE_SERVER_MAX_LENGTH', 128); |
|
121 | -define('CONFIG_DATABASE_USER_MAX_LENGTH', 64); |
|
122 | -define('CONFIG_DATABASE_PASSWORD_MAX_LENGTH', 64); |
|
123 | -define('CONFIG_DATABASE_NAME_MAX_LENGTH', 64); |
|
120 | +define('CONFIG_DATABASE_SERVER_MAX_LENGTH', 128); |
|
121 | +define('CONFIG_DATABASE_USER_MAX_LENGTH', 64); |
|
122 | +define('CONFIG_DATABASE_PASSWORD_MAX_LENGTH', 64); |
|
123 | +define('CONFIG_DATABASE_NAME_MAX_LENGTH', 64); |
|
124 | 124 | |
125 | 125 | # Other |
126 | 126 | |
127 | -define('CONFIG_UPLOADS_MAX_SIZE', 104857600); # 100 MB |
|
127 | +define('CONFIG_UPLOADS_MAX_SIZE', 104857600); # 100 MB |
@@ -20,7 +20,9 @@ discard block |
||
20 | 20 | |
21 | 21 | $item->children = ($children = Template::group()); |
22 | 22 | |
23 | - foreach ($this->menu[$id]['children'] as $child) $children->add($this->parseItem($child)); |
|
23 | + foreach ($this->menu[$id]['children'] as $child) { |
|
24 | + $children->add($this->parseItem($child)); |
|
25 | + } |
|
24 | 26 | |
25 | 27 | } else { |
26 | 28 | |
@@ -44,7 +46,9 @@ discard block |
||
44 | 46 | |
45 | 47 | $menu = Entitizer::treeview(TABLE_MENU)->subtree(0, ['active' => true]); |
46 | 48 | |
47 | - if (false !== $menu) $this->menu = $menu; |
|
49 | + if (false !== $menu) { |
|
50 | + $this->menu = $menu; |
|
51 | + } |
|
48 | 52 | } |
49 | 53 | |
50 | 54 | # Get block |
@@ -53,7 +57,9 @@ discard block |
||
53 | 57 | |
54 | 58 | $menu = Template::group(); |
55 | 59 | |
56 | - foreach ($this->menu[0]['children'] as $id) $menu->add($this->parseItem($id)); |
|
60 | + foreach ($this->menu[0]['children'] as $id) { |
|
61 | + $menu->add($this->parseItem($id)); |
|
62 | + } |
|
57 | 63 | |
58 | 64 | # ------------------------ |
59 | 65 |