@@ -24,7 +24,9 @@ |
||
24 | 24 | |
25 | 25 | public static function __callStatic($name, $arguments) { |
26 | 26 | |
27 | - if (null !== static::$loader) return static::$loader->$name(...$arguments); |
|
27 | + if (null !== static::$loader) { |
|
28 | + return static::$loader->$name(...$arguments); |
|
29 | + } |
|
28 | 30 | } |
29 | 31 | } |
30 | 32 | } |
@@ -21,7 +21,9 @@ discard block |
||
21 | 21 | |
22 | 22 | # Throw error if no extensions found |
23 | 23 | |
24 | - if (false === static::$loader->active()) throw new static::$exception_class; |
|
24 | + if (false === static::$loader->active()) { |
|
25 | + throw new static::$exception_class; |
|
26 | + } |
|
25 | 27 | |
26 | 28 | # Activate user defined extension |
27 | 29 | |
@@ -29,9 +31,10 @@ discard block |
||
29 | 31 | |
30 | 32 | $name = static::$name; $param = static::$param[static::$loader->section()]; |
31 | 33 | |
32 | - if (static::$loader->activate(Request::get($name)) || static::$loader->activate(Cookie::get($param))) |
|
33 | - |
|
34 | + if (static::$loader->activate(Request::get($name)) || static::$loader->activate(Cookie::get($param))) { |
|
35 | + |
|
34 | 36 | Cookie::set($param, static::$loader->data('name'), static::$cookie_expires); |
37 | + } |
|
35 | 38 | } |
36 | 39 | } |
37 | 40 | } |
@@ -12,7 +12,7 @@ |
||
12 | 12 | |
13 | 13 | protected function getItem(string $name) { |
14 | 14 | |
15 | - $file_name = ($this->dir_name . $name . '/Config.json'); |
|
15 | + $file_name = ($this->dir_name.$name.'/Config.json'); |
|
16 | 16 | |
17 | 17 | if (null === ($data = JSON::load($file_name))) return null; |
18 | 18 |
@@ -14,11 +14,17 @@ |
||
14 | 14 | |
15 | 15 | $file_name = ($this->dir_name . $name . '/Config.json'); |
16 | 16 | |
17 | - if (null === ($data = JSON::load($file_name))) return null; |
|
17 | + if (null === ($data = JSON::load($file_name))) { |
|
18 | + return null; |
|
19 | + } |
|
18 | 20 | |
19 | - if (null === ($data = Schema::get(static::$schema_prototype)->validate($data))) return null; |
|
21 | + if (null === ($data = Schema::get(static::$schema_prototype)->validate($data))) { |
|
22 | + return null; |
|
23 | + } |
|
20 | 24 | |
21 | - if (!(static::$extension_class::valid($data['name']) && ($data['name'] === $name))) return null; |
|
25 | + if (!(static::$extension_class::valid($data['name']) && ($data['name'] === $name))) { |
|
26 | + return null; |
|
27 | + } |
|
22 | 28 | |
23 | 29 | # ------------------------ |
24 | 30 |
@@ -12,7 +12,9 @@ discard block |
||
12 | 12 | |
13 | 13 | public function initBySlug(string $slug) { |
14 | 14 | |
15 | - if (0 !== $this->id) return false; |
|
15 | + if (0 !== $this->id) { |
|
16 | + return false; |
|
17 | + } |
|
16 | 18 | |
17 | 19 | # Process value |
18 | 20 | |
@@ -22,7 +24,9 @@ discard block |
||
22 | 24 | |
23 | 25 | $selection = array_keys($this->definition->params()); |
24 | 26 | |
25 | - foreach ($selection as $key => $field) $selection[$key] = ('ent.' . $field); |
|
27 | + foreach ($selection as $key => $field) { |
|
28 | + $selection[$key] = ('ent.' . $field); |
|
29 | + } |
|
26 | 30 | |
27 | 31 | # Process query |
28 | 32 | |
@@ -38,7 +42,9 @@ discard block |
||
38 | 42 | |
39 | 43 | # Select entity from DB |
40 | 44 | |
41 | - if (!(DB::send($query) && (DB::getLast()->rows === 1))) return false; |
|
45 | + if (!(DB::send($query) && (DB::getLast()->rows === 1))) { |
|
46 | + return false; |
|
47 | + } |
|
42 | 48 | |
43 | 49 | # ------------------------ |
44 | 50 | |
@@ -49,7 +55,9 @@ discard block |
||
49 | 55 | |
50 | 56 | public function updateSlugs() { |
51 | 57 | |
52 | - if (0 === $this->id) return false; |
|
58 | + if (0 === $this->id) { |
|
59 | + return false; |
|
60 | + } |
|
53 | 61 | |
54 | 62 | # Send lock/update request |
55 | 63 | |
@@ -67,7 +75,9 @@ discard block |
||
67 | 75 | |
68 | 76 | (") slg ON slg.id = ent.id SET ent.locked = 1, ent.slug = slg.slug"); |
69 | 77 | |
70 | - if (!(DB::send($query) && DB::getLast()->status)) return false; |
|
78 | + if (!(DB::send($query) && DB::getLast()->status)) { |
|
79 | + return false; |
|
80 | + } |
|
71 | 81 | |
72 | 82 | # Send unlock request |
73 | 83 | |
@@ -83,7 +93,9 @@ discard block |
||
83 | 93 | |
84 | 94 | (") chk ON chk.id = ent.id SET ent.locked = 0"); |
85 | 95 | |
86 | - if (!(DB::send($query) && DB::getLast()->status)) return false; |
|
96 | + if (!(DB::send($query) && DB::getLast()->status)) { |
|
97 | + return false; |
|
98 | + } |
|
87 | 99 | |
88 | 100 | # ------------------------ |
89 | 101 | |
@@ -94,7 +106,9 @@ discard block |
||
94 | 106 | |
95 | 107 | public function create(array $data) { |
96 | 108 | |
97 | - if (!parent::create($data)) return false; |
|
109 | + if (!parent::create($data)) { |
|
110 | + return false; |
|
111 | + } |
|
98 | 112 | |
99 | 113 | $this->updateSlugs(); |
100 | 114 | |
@@ -107,7 +121,9 @@ discard block |
||
107 | 121 | |
108 | 122 | public function edit(array $data) { |
109 | 123 | |
110 | - if (!parent::edit($data)) return false; |
|
124 | + if (!parent::edit($data)) { |
|
125 | + return false; |
|
126 | + } |
|
111 | 127 | |
112 | 128 | $this->updateSlugs(); |
113 | 129 | |
@@ -120,7 +136,9 @@ discard block |
||
120 | 136 | |
121 | 137 | public function move(int $parent_id) { |
122 | 138 | |
123 | - if (!parent::move($parent_id)) return false; |
|
139 | + if (!parent::move($parent_id)) { |
|
140 | + return false; |
|
141 | + } |
|
124 | 142 | |
125 | 143 | $this->updateSlugs(); |
126 | 144 |
@@ -28,13 +28,13 @@ discard block |
||
28 | 28 | |
29 | 29 | $query = ("SELECT " . implode(', ', $selection) .", rel.ancestor as parent_id ") . |
30 | 30 | |
31 | - ("FROM " . static::$table . " ent ") . |
|
31 | + ("FROM " . static::$table . " ent ") . |
|
32 | 32 | |
33 | - ("LEFT JOIN " . static::$table_relations . " rel ON rel.descendant = ent.id AND rel.depth = 1 ") . |
|
33 | + ("LEFT JOIN " . static::$table_relations . " rel ON rel.descendant = ent.id AND rel.depth = 1 ") . |
|
34 | 34 | |
35 | - ("WHERE ent.visibility = " . VISIBILITY_PUBLISHED . " AND ent.access <= " . Auth::get('rank') . " AND ") . |
|
35 | + ("WHERE ent.visibility = " . VISIBILITY_PUBLISHED . " AND ent.access <= " . Auth::get('rank') . " AND ") . |
|
36 | 36 | |
37 | - ("ent.locked = 0 AND ent.slug = '" . addslashes($slug) . "' LIMIT 1"); |
|
37 | + ("ent.locked = 0 AND ent.slug = '" . addslashes($slug) . "' LIMIT 1"); |
|
38 | 38 | |
39 | 39 | # Select entity from DB |
40 | 40 | |
@@ -55,17 +55,17 @@ discard block |
||
55 | 55 | |
56 | 56 | $query = ("UPDATE " . static::$table . " ent JOIN (") . |
57 | 57 | |
58 | - ("SELECT rel.descendant as id, GROUP_CONCAT(ens.name ORDER BY rls.depth DESC SEPARATOR '/') slug ") . |
|
58 | + ("SELECT rel.descendant as id, GROUP_CONCAT(ens.name ORDER BY rls.depth DESC SEPARATOR '/') slug ") . |
|
59 | 59 | |
60 | - ("FROM " . static::$table_relations . " rel ") . |
|
60 | + ("FROM " . static::$table_relations . " rel ") . |
|
61 | 61 | |
62 | - ("JOIN " . static::$table_relations . " rls ON rls.descendant = rel.descendant ") . |
|
62 | + ("JOIN " . static::$table_relations . " rls ON rls.descendant = rel.descendant ") . |
|
63 | 63 | |
64 | - ("JOIN " . static::$table . " ens ON ens.id = rls.ancestor ") . |
|
64 | + ("JOIN " . static::$table . " ens ON ens.id = rls.ancestor ") . |
|
65 | 65 | |
66 | - ("WHERE rel.ancestor = " . $this->id . " GROUP BY rel.descendant") . |
|
66 | + ("WHERE rel.ancestor = " . $this->id . " GROUP BY rel.descendant") . |
|
67 | 67 | |
68 | - (") slg ON slg.id = ent.id SET ent.locked = 1, ent.slug = slg.slug"); |
|
68 | + (") slg ON slg.id = ent.id SET ent.locked = 1, ent.slug = slg.slug"); |
|
69 | 69 | |
70 | 70 | if (!(DB::send($query) && DB::getLast()->status)) return false; |
71 | 71 | |
@@ -73,15 +73,15 @@ discard block |
||
73 | 73 | |
74 | 74 | $query = ("UPDATE " . static::$table . " ent JOIN (") . |
75 | 75 | |
76 | - ("SELECT rel.descendant as id FROM " . static::$table_relations . " rel ") . |
|
76 | + ("SELECT rel.descendant as id FROM " . static::$table_relations . " rel ") . |
|
77 | 77 | |
78 | - ("JOIN " . static::$table . " enc ON enc.id = rel.descendant AND enc.locked = 1 ") . |
|
78 | + ("JOIN " . static::$table . " enc ON enc.id = rel.descendant AND enc.locked = 1 ") . |
|
79 | 79 | |
80 | - ("LEFT JOIN " . static::$table . " end ON end.id != enc.id AND end.slug = enc.slug ") . |
|
80 | + ("LEFT JOIN " . static::$table . " end ON end.id != enc.id AND end.slug = enc.slug ") . |
|
81 | 81 | |
82 | - ("WHERE end.id IS NULL GROUP BY rel.descendant") . |
|
82 | + ("WHERE end.id IS NULL GROUP BY rel.descendant") . |
|
83 | 83 | |
84 | - (") chk ON chk.id = ent.id SET ent.locked = 0"); |
|
84 | + (") chk ON chk.id = ent.id SET ent.locked = 0"); |
|
85 | 85 | |
86 | 86 | if (!(DB::send($query) && DB::getLast()->status)) return false; |
87 | 87 |
@@ -22,19 +22,19 @@ discard block |
||
22 | 22 | |
23 | 23 | $selection = array_keys($this->definition->params()); |
24 | 24 | |
25 | - foreach ($selection as $key => $field) $selection[$key] = ('ent.' . $field); |
|
25 | + foreach ($selection as $key => $field) $selection[$key] = ('ent.'.$field); |
|
26 | 26 | |
27 | 27 | # Process query |
28 | 28 | |
29 | - $query = ("SELECT " . implode(', ', $selection) .", rel.ancestor as parent_id ") . |
|
29 | + $query = ("SELECT ".implode(', ', $selection).", rel.ancestor as parent_id "). |
|
30 | 30 | |
31 | - ("FROM " . static::$table . " ent ") . |
|
31 | + ("FROM ".static::$table." ent "). |
|
32 | 32 | |
33 | - ("LEFT JOIN " . static::$table_relations . " rel ON rel.descendant = ent.id AND rel.depth = 1 ") . |
|
33 | + ("LEFT JOIN ".static::$table_relations." rel ON rel.descendant = ent.id AND rel.depth = 1 "). |
|
34 | 34 | |
35 | - ("WHERE ent.visibility = " . VISIBILITY_PUBLISHED . " AND ent.access <= " . Auth::get('rank') . " AND ") . |
|
35 | + ("WHERE ent.visibility = ".VISIBILITY_PUBLISHED." AND ent.access <= ".Auth::get('rank')." AND "). |
|
36 | 36 | |
37 | - ("ent.locked = 0 AND ent.slug = '" . addslashes($slug) . "' LIMIT 1"); |
|
37 | + ("ent.locked = 0 AND ent.slug = '".addslashes($slug)."' LIMIT 1"); |
|
38 | 38 | |
39 | 39 | # Select entity from DB |
40 | 40 | |
@@ -53,17 +53,17 @@ discard block |
||
53 | 53 | |
54 | 54 | # Send lock/update request |
55 | 55 | |
56 | - $query = ("UPDATE " . static::$table . " ent JOIN (") . |
|
56 | + $query = ("UPDATE ".static::$table." ent JOIN ("). |
|
57 | 57 | |
58 | - ("SELECT rel.descendant as id, GROUP_CONCAT(ens.name ORDER BY rls.depth DESC SEPARATOR '/') slug ") . |
|
58 | + ("SELECT rel.descendant as id, GROUP_CONCAT(ens.name ORDER BY rls.depth DESC SEPARATOR '/') slug "). |
|
59 | 59 | |
60 | - ("FROM " . static::$table_relations . " rel ") . |
|
60 | + ("FROM ".static::$table_relations." rel "). |
|
61 | 61 | |
62 | - ("JOIN " . static::$table_relations . " rls ON rls.descendant = rel.descendant ") . |
|
62 | + ("JOIN ".static::$table_relations." rls ON rls.descendant = rel.descendant "). |
|
63 | 63 | |
64 | - ("JOIN " . static::$table . " ens ON ens.id = rls.ancestor ") . |
|
64 | + ("JOIN ".static::$table." ens ON ens.id = rls.ancestor "). |
|
65 | 65 | |
66 | - ("WHERE rel.ancestor = " . $this->id . " GROUP BY rel.descendant") . |
|
66 | + ("WHERE rel.ancestor = ".$this->id." GROUP BY rel.descendant"). |
|
67 | 67 | |
68 | 68 | (") slg ON slg.id = ent.id SET ent.locked = 1, ent.slug = slg.slug"); |
69 | 69 | |
@@ -71,15 +71,15 @@ discard block |
||
71 | 71 | |
72 | 72 | # Send unlock request |
73 | 73 | |
74 | - $query = ("UPDATE " . static::$table . " ent JOIN (") . |
|
74 | + $query = ("UPDATE ".static::$table." ent JOIN ("). |
|
75 | 75 | |
76 | - ("SELECT rel.descendant as id FROM " . static::$table_relations . " rel ") . |
|
76 | + ("SELECT rel.descendant as id FROM ".static::$table_relations." rel "). |
|
77 | 77 | |
78 | - ("JOIN " . static::$table . " enc ON enc.id = rel.descendant AND enc.locked = 1 ") . |
|
78 | + ("JOIN ".static::$table." enc ON enc.id = rel.descendant AND enc.locked = 1 "). |
|
79 | 79 | |
80 | - ("LEFT JOIN " . static::$table . " end ON end.id != enc.id AND end.slug = enc.slug ") . |
|
80 | + ("LEFT JOIN ".static::$table." end ON end.id != enc.id AND end.slug = enc.slug "). |
|
81 | 81 | |
82 | - ("WHERE end.id IS NULL GROUP BY rel.descendant") . |
|
82 | + ("WHERE end.id IS NULL GROUP BY rel.descendant"). |
|
83 | 83 | |
84 | 84 | (") chk ON chk.id = ent.id SET ent.locked = 0"); |
85 | 85 |
@@ -12,7 +12,7 @@ |
||
12 | 12 | |
13 | 13 | protected function init() { |
14 | 14 | |
15 | - $this->config->addParam('active', '', function (bool $active) { |
|
15 | + $this->config->addParam('active', '', function(bool $active) { |
|
16 | 16 | |
17 | 17 | return ($active ? "ent.active = 1" : ''); |
18 | 18 | }); |
@@ -12,44 +12,44 @@ |
||
12 | 12 | |
13 | 13 | protected function init() { |
14 | 14 | |
15 | - $this->config->addParam('active', '', function (bool $active) { |
|
15 | + $this->config->addParam('active', '', function(bool $active) { |
|
16 | 16 | |
17 | - return ($active ? ("ent.visibility = " . VISIBILITY_PUBLISHED . " AND ent.locked = 0") : ''); |
|
17 | + return ($active ? ("ent.visibility = ".VISIBILITY_PUBLISHED." AND ent.locked = 0") : ''); |
|
18 | 18 | }); |
19 | 19 | |
20 | - $this->config->addParam('rank', '', function (int $rank = null) { |
|
20 | + $this->config->addParam('rank', '', function(int $rank = null) { |
|
21 | 21 | |
22 | - return ((null !== $rank) ? ("ent.access <= " . $rank) : ''); |
|
22 | + return ((null !== $rank) ? ("ent.access <= ".$rank) : ''); |
|
23 | 23 | }); |
24 | 24 | |
25 | - $this->config->addParam('slug', '', function (string $slug) { |
|
25 | + $this->config->addParam('slug', '', function(string $slug) { |
|
26 | 26 | |
27 | - return (('' !== $slug) ? ("ent.slug = '" . addslashes($slug) . "'") : ''); |
|
27 | + return (('' !== $slug) ? ("ent.slug = '".addslashes($slug)."'") : ''); |
|
28 | 28 | }); |
29 | 29 | |
30 | - $this->config->addParam('name', '', function (string $name) { |
|
30 | + $this->config->addParam('name', '', function(string $name) { |
|
31 | 31 | |
32 | - return (('' !== $name) ? ("ent.name = '" . addslashes($name) . "'") : ''); |
|
32 | + return (('' !== $name) ? ("ent.name = '".addslashes($name)."'") : ''); |
|
33 | 33 | }); |
34 | 34 | |
35 | - $this->config->addParam('time_created >=', '', function (int $time) { |
|
35 | + $this->config->addParam('time_created >=', '', function(int $time) { |
|
36 | 36 | |
37 | - return ((0 < $time) ? ("ent.time_created >= " . $time) : ''); |
|
37 | + return ((0 < $time) ? ("ent.time_created >= ".$time) : ''); |
|
38 | 38 | }); |
39 | 39 | |
40 | - $this->config->addParam('time_created <=', '', function (int $time) { |
|
40 | + $this->config->addParam('time_created <=', '', function(int $time) { |
|
41 | 41 | |
42 | - return ((0 < $time) ? ("ent.time_created <= " . $time) : ''); |
|
42 | + return ((0 < $time) ? ("ent.time_created <= ".$time) : ''); |
|
43 | 43 | }); |
44 | 44 | |
45 | - $this->config->addParam('time_modified >=', '', function (int $time) { |
|
45 | + $this->config->addParam('time_modified >=', '', function(int $time) { |
|
46 | 46 | |
47 | - return ((0 < $time) ? ("ent.time_modified >= " . $time) : ''); |
|
47 | + return ((0 < $time) ? ("ent.time_modified >= ".$time) : ''); |
|
48 | 48 | }); |
49 | 49 | |
50 | - $this->config->addParam('time_modified <=', '', function (int $time) { |
|
50 | + $this->config->addParam('time_modified <=', '', function(int $time) { |
|
51 | 51 | |
52 | - return ((0 < $time) ? ("ent.time_modified <= " . $time) : ''); |
|
52 | + return ((0 < $time) ? ("ent.time_modified <= ".$time) : ''); |
|
53 | 53 | }); |
54 | 54 | } |
55 | 55 | } |
@@ -12,29 +12,29 @@ |
||
12 | 12 | |
13 | 13 | protected function init() { |
14 | 14 | |
15 | - $this->config->addParam('rank', '', function (int $rank = null) { |
|
15 | + $this->config->addParam('rank', '', function(int $rank = null) { |
|
16 | 16 | |
17 | - return ((null !== $rank) ? ("ent.rank >= " . $rank) : ''); |
|
17 | + return ((null !== $rank) ? ("ent.rank >= ".$rank) : ''); |
|
18 | 18 | }); |
19 | 19 | |
20 | - $this->config->addParam('time_registered >=', '', function (int $time) { |
|
20 | + $this->config->addParam('time_registered >=', '', function(int $time) { |
|
21 | 21 | |
22 | - return ((0 < $time) ? ("ent.time_registered >= " . $time) : ''); |
|
22 | + return ((0 < $time) ? ("ent.time_registered >= ".$time) : ''); |
|
23 | 23 | }); |
24 | 24 | |
25 | - $this->config->addParam('time_registered <=', '', function (int $time) { |
|
25 | + $this->config->addParam('time_registered <=', '', function(int $time) { |
|
26 | 26 | |
27 | - return ((0 < $time) ? ("ent.time_registered <= " . $time) : ''); |
|
27 | + return ((0 < $time) ? ("ent.time_registered <= ".$time) : ''); |
|
28 | 28 | }); |
29 | 29 | |
30 | - $this->config->addParam('time_logged >=', '', function (int $time) { |
|
30 | + $this->config->addParam('time_logged >=', '', function(int $time) { |
|
31 | 31 | |
32 | - return ((0 < $time) ? ("ent.time_logged >= " . $time) : ''); |
|
32 | + return ((0 < $time) ? ("ent.time_logged >= ".$time) : ''); |
|
33 | 33 | }); |
34 | 34 | |
35 | - $this->config->addParam('time_logged <=', '', function (int $time) { |
|
35 | + $this->config->addParam('time_logged <=', '', function(int $time) { |
|
36 | 36 | |
37 | - return ((0 < $time) ? ("ent.time_logged <= " . $time) : ''); |
|
37 | + return ((0 < $time) ? ("ent.time_logged <= ".$time) : ''); |
|
38 | 38 | }); |
39 | 39 | } |
40 | 40 | } |
@@ -30,7 +30,9 @@ |
||
30 | 30 | |
31 | 31 | protected function processEntity(Template\Block $contents) { |
32 | 32 | |
33 | - if ($this->create) $contents->getBlock('info')->disable(); else { |
|
33 | + if ($this->create) { |
|
34 | + $contents->getBlock('info')->disable(); |
|
35 | + } else { |
|
34 | 36 | |
35 | 37 | $contents->getBlock('info')->time_registered = Date::get(DATE_FORMAT_DATETIME, $this->entity->time_registered); |
36 | 38 |
@@ -32,16 +32,18 @@ |
||
32 | 32 | |
33 | 33 | protected function processEntityParent(Template\Block $parent) { |
34 | 34 | |
35 | - if ((0 !== $this->parent->id) && $this->parent->active) $parent->getBlock('browse')->link = $this->parent->link; |
|
36 | - |
|
37 | - else { $parent->getBlock('browse')->disable(); $parent->getBlock('browse_disabled')->enable(); } |
|
35 | + if ((0 !== $this->parent->id) && $this->parent->active) { |
|
36 | + $parent->getBlock('browse')->link = $this->parent->link; |
|
37 | + } else { $parent->getBlock('browse')->disable(); $parent->getBlock('browse_disabled')->enable(); } |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | # Add additional parent data for specific entity |
41 | 41 | |
42 | 42 | protected function processEntity(Template\Block $contents) { |
43 | 43 | |
44 | - if (!$this->create && $this->parent->locked) $contents->getBlock('locked')->enable(); |
|
44 | + if (!$this->create && $this->parent->locked) { |
|
45 | + $contents->getBlock('locked')->enable(); |
|
46 | + } |
|
45 | 47 | } |
46 | 48 | } |
47 | 49 | } |