@@ -56,7 +56,9 @@ discard block |
||
56 | 56 | |
57 | 57 | private function processSelector(Template\Block $selector) { |
58 | 58 | |
59 | - if ($this->create) return $selector->disable(); |
|
59 | + if ($this->create) { |
|
60 | + return $selector->disable(); |
|
61 | + } |
|
60 | 62 | |
61 | 63 | $selector->parent_id = $this->entity->parent_id; |
62 | 64 | |
@@ -81,25 +83,33 @@ discard block |
||
81 | 83 | |
82 | 84 | # Set path / title |
83 | 85 | |
84 | - if (static::$nesting) $contents->path = $this->path; |
|
85 | - |
|
86 | - else $contents->title = ($this->create ? Language::get(static::$naming_new) : $this->entity->get(static::$naming)); |
|
86 | + if (static::$nesting) { |
|
87 | + $contents->path = $this->path; |
|
88 | + } else { |
|
89 | + $contents->title = ($this->create ? Language::get(static::$naming_new) : $this->entity->get(static::$naming)); |
|
90 | + } |
|
87 | 91 | |
88 | 92 | # Process parent block |
89 | 93 | |
90 | - if (static::$nesting) $this->processParent($contents->getBlock('parent')); |
|
94 | + if (static::$nesting) { |
|
95 | + $this->processParent($contents->getBlock('parent')); |
|
96 | + } |
|
91 | 97 | |
92 | 98 | # Set link |
93 | 99 | |
94 | 100 | $link = (INSTALL_PATH . static::$link . '/'); |
95 | 101 | |
96 | - if (static::$nesting) $contents->link = ($link . ($this->create ? 'create' : 'edit') . '?id=' . $this->parent->id); |
|
97 | - |
|
98 | - else $contents->link = ($link . ($this->create ? 'create' : ('edit?id=' . $this->entity->id))); |
|
102 | + if (static::$nesting) { |
|
103 | + $contents->link = ($link . ($this->create ? 'create' : 'edit') . '?id=' . $this->parent->id); |
|
104 | + } else { |
|
105 | + $contents->link = ($link . ($this->create ? 'create' : ('edit?id=' . $this->entity->id))); |
|
106 | + } |
|
99 | 107 | |
100 | 108 | # Process selector block |
101 | 109 | |
102 | - if (static::$nesting) $this->processSelector($contents->getBlock('selector')); |
|
110 | + if (static::$nesting) { |
|
111 | + $this->processSelector($contents->getBlock('selector')); |
|
112 | + } |
|
103 | 113 | |
104 | 114 | # Implement form |
105 | 115 | |
@@ -134,11 +144,15 @@ discard block |
||
134 | 144 | |
135 | 145 | $parent_id = Number::forceInt(Request::post('parent_id')); |
136 | 146 | |
137 | - if (!$this->entity->move($parent_id)) return $ajax->setError(Language::get(static::$message_error_move)); |
|
147 | + if (!$this->entity->move($parent_id)) { |
|
148 | + return $ajax->setError(Language::get(static::$message_error_move)); |
|
149 | + } |
|
138 | 150 | |
139 | 151 | } else if (Request::post('action') === 'remove') { |
140 | 152 | |
141 | - if (!$this->entity->remove()) return $ajax->setError(Language::get(static::$message_error_remove)); |
|
153 | + if (!$this->entity->remove()) { |
|
154 | + return $ajax->setError(Language::get(static::$message_error_remove)); |
|
155 | + } |
|
142 | 156 | } |
143 | 157 | |
144 | 158 | # ------------------------ |
@@ -154,7 +168,9 @@ discard block |
||
154 | 168 | |
155 | 169 | protected function handle(bool $ajax = false) { |
156 | 170 | |
157 | - if (!$this->create && $ajax) return $this->handleAjax(); |
|
171 | + if (!$this->create && $ajax) { |
|
172 | + return $this->handleAjax(); |
|
173 | + } |
|
158 | 174 | |
159 | 175 | # Create entity |
160 | 176 | |
@@ -162,7 +178,9 @@ discard block |
||
162 | 178 | |
163 | 179 | $this->entity = Entitizer::get(static::$table, (!$this->create ? $id : 0)); |
164 | 180 | |
165 | - if (!$this->create && (0 === $this->entity->id)) return Request::redirect(INSTALL_PATH . static::$link); |
|
181 | + if (!$this->create && (0 === $this->entity->id)) { |
|
182 | + return Request::redirect(INSTALL_PATH . static::$link); |
|
183 | + } |
|
166 | 184 | |
167 | 185 | # Create parent entity |
168 | 186 | |
@@ -170,7 +188,9 @@ discard block |
||
170 | 188 | |
171 | 189 | # Get path |
172 | 190 | |
173 | - if (false !== ($path = $this->parent->getPath())) $this->path = $path; |
|
191 | + if (false !== ($path = $this->parent->getPath())) { |
|
192 | + $this->path = $path; |
|
193 | + } |
|
174 | 194 | |
175 | 195 | # Create form |
176 | 196 | |
@@ -180,7 +200,9 @@ discard block |
||
180 | 200 | |
181 | 201 | if ($this->form->handle(new static::$controller_class($this->entity), true)) { |
182 | 202 | |
183 | - if ($this->create && (0 !== $this->parent->id)) $this->entity->move($this->parent->id); |
|
203 | + if ($this->create && (0 !== $this->parent->id)) { |
|
204 | + $this->entity->move($this->parent->id); |
|
205 | + } |
|
184 | 206 | |
185 | 207 | Request::redirect(INSTALL_PATH . static::$link . '/edit?id=' . $this->entity->id . '&submitted'); |
186 | 208 | } |
@@ -29,15 +29,15 @@ discard block |
||
29 | 29 | |
30 | 30 | # Set create button |
31 | 31 | |
32 | - if (count($this->path) < CONFIG_ENTITIZER_MAX_DEPTH) $parent->getBlock('create')->id = $this->parent->id; |
|
33 | - |
|
34 | - else { $parent->getBlock('create')->disable(); $parent->getBlock('create_disabled')->enable(); } |
|
32 | + if (count($this->path) < CONFIG_ENTITIZER_MAX_DEPTH) { |
|
33 | + $parent->getBlock('create')->id = $this->parent->id; |
|
34 | + } else { $parent->getBlock('create')->disable(); $parent->getBlock('create_disabled')->enable(); } |
|
35 | 35 | |
36 | 36 | # Set edit button |
37 | 37 | |
38 | - if (0 !== $this->parent->id) $parent->getBlock('edit')->id = $this->parent->id; |
|
39 | - |
|
40 | - else { $parent->getBlock('edit')->disable(); $parent->getBlock('edit_disabled')->enable(); } |
|
38 | + if (0 !== $this->parent->id) { |
|
39 | + $parent->getBlock('edit')->id = $this->parent->id; |
|
40 | + } else { $parent->getBlock('edit')->disable(); $parent->getBlock('edit_disabled')->enable(); } |
|
41 | 41 | |
42 | 42 | # Add parent additional data |
43 | 43 | |
@@ -52,7 +52,9 @@ discard block |
||
52 | 52 | |
53 | 53 | foreach ($this->items['list'] as $item) { |
54 | 54 | |
55 | - if ((null !== $this->entity) && ($item['dataset']->id === $this->entity->id)) continue; |
|
55 | + if ((null !== $this->entity) && ($item['dataset']->id === $this->entity->id)) { |
|
56 | + continue; |
|
57 | + } |
|
56 | 58 | |
57 | 59 | $items->addItem($view = View::get(!$ajax ? static::$view_item : static::$view_ajax_item)); |
58 | 60 | |
@@ -121,11 +123,15 @@ discard block |
||
121 | 123 | |
122 | 124 | # Set path |
123 | 125 | |
124 | - if (static::$nesting) $contents->path = $this->path; |
|
126 | + if (static::$nesting) { |
|
127 | + $contents->path = $this->path; |
|
128 | + } |
|
125 | 129 | |
126 | 130 | # Process parent block |
127 | 131 | |
128 | - if (static::$nesting && !$ajax) $this->processParent($contents->getBlock('parent')); |
|
132 | + if (static::$nesting && !$ajax) { |
|
133 | + $this->processParent($contents->getBlock('parent')); |
|
134 | + } |
|
129 | 135 | |
130 | 136 | # Process items block |
131 | 137 | |
@@ -133,7 +139,9 @@ discard block |
||
133 | 139 | |
134 | 140 | # Set pagination |
135 | 141 | |
136 | - if (!$ajax) $contents->pagination = $this->getPaginationBlock(); |
|
142 | + if (!$ajax) { |
|
143 | + $contents->pagination = $this->getPaginationBlock(); |
|
144 | + } |
|
137 | 145 | |
138 | 146 | # ------------------------ |
139 | 147 | |
@@ -160,15 +168,21 @@ discard block |
||
160 | 168 | |
161 | 169 | # Get path and depth |
162 | 170 | |
163 | - if (false !== ($path = $this->parent->getPath())) $this->path = $path; |
|
171 | + if (false !== ($path = $this->parent->getPath())) { |
|
172 | + $this->path = $path; |
|
173 | + } |
|
164 | 174 | |
165 | - if ((0 !== $this->entity->id) && (false !== ($depth = $this->entity->getSubtreeDepth()))) $this->depth = $depth; |
|
175 | + if ((0 !== $this->entity->id) && (false !== ($depth = $this->entity->getSubtreeDepth()))) { |
|
176 | + $this->depth = $depth; |
|
177 | + } |
|
166 | 178 | |
167 | 179 | # Get items list |
168 | 180 | |
169 | 181 | $lister = (static::$nesting ? 'getChildren' : 'getItems'); |
170 | 182 | |
171 | - if (false !== ($items = $this->parent->$lister())) $this->items = $items; |
|
183 | + if (false !== ($items = $this->parent->$lister())) { |
|
184 | + $this->items = $items; |
|
185 | + } |
|
172 | 186 | |
173 | 187 | # ------------------------ |
174 | 188 | |
@@ -183,7 +197,9 @@ discard block |
||
183 | 197 | |
184 | 198 | protected function handle(bool $ajax = false) { |
185 | 199 | |
186 | - if ($ajax) return $this->handleAjax(); |
|
200 | + if ($ajax) { |
|
201 | + return $this->handleAjax(); |
|
202 | + } |
|
187 | 203 | |
188 | 204 | $this->index = Number::forceInt(Request::get('index'), 1, 999999); |
189 | 205 | |
@@ -195,13 +211,17 @@ discard block |
||
195 | 211 | |
196 | 212 | # Get path |
197 | 213 | |
198 | - if (false !== ($path = $this->parent->getPath())) $this->path = $path; |
|
214 | + if (false !== ($path = $this->parent->getPath())) { |
|
215 | + $this->path = $path; |
|
216 | + } |
|
199 | 217 | |
200 | 218 | # Get items list |
201 | 219 | |
202 | 220 | $lister = (static::$nesting ? 'getChildren' : 'getItems'); $display = Settings::get('admin_display_entities'); |
203 | 221 | |
204 | - if (false !== ($items = $this->parent->$lister([], [], $this->index, $display))) $this->items = $items; |
|
222 | + if (false !== ($items = $this->parent->$lister([], [], $this->index, $display))) { |
|
223 | + $this->items = $items; |
|
224 | + } |
|
205 | 225 | |
206 | 226 | # ------------------------ |
207 | 227 |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | |
22 | 22 | return (0 !== $parent_id) ? (("JOIN " . static::$table_relations . " rel ") . |
23 | 23 | |
24 | - ("ON rel.ancestor = " . $parent_id . " AND rel.descendant = ent.id AND rel.depth >= 1")) : |
|
24 | + ("ON rel.ancestor = " . $parent_id . " AND rel.descendant = ent.id AND rel.depth >= 1")) : |
|
25 | 25 | |
26 | 26 | ("JOIN " . static::$table_relations . " rel ON rel.descendant = ent.id"); |
27 | 27 | } |
@@ -34,13 +34,13 @@ discard block |
||
34 | 34 | |
35 | 35 | return ("SELECT " . $this->getSelection() . ", COALESCE(par.ancestor, 0) as parent_id ") . |
36 | 36 | |
37 | - ("FROM " . static::$table . " ent " . $this->getQueryJoin($parent_id) . " ") . |
|
37 | + ("FROM " . static::$table . " ent " . $this->getQueryJoin($parent_id) . " ") . |
|
38 | 38 | |
39 | - ("LEFT JOIN " . static::$table_relations . " par ON par.descendant = ent.id AND par.depth = 1 ") . |
|
39 | + ("LEFT JOIN " . static::$table_relations . " par ON par.descendant = ent.id AND par.depth = 1 ") . |
|
40 | 40 | |
41 | - (('' !== ($condition = $this->getCondition($config))) ? ("WHERE " . $condition . " ") : "") . |
|
41 | + (('' !== ($condition = $this->getCondition($config))) ? ("WHERE " . $condition . " ") : "") . |
|
42 | 42 | |
43 | - ("GROUP BY ent.id ORDER BY MAX(rel.depth) ASC, " . $this->getOrderBy($order_by)); |
|
43 | + ("GROUP BY ent.id ORDER BY MAX(rel.depth) ASC, " . $this->getOrderBy($order_by)); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | |
52 | 52 | return ("SELECT COUNT(DISTINCT ent.id) as count FROM " . static::$table . " ent ") . |
53 | 53 | |
54 | - $this->getQueryJoin($parent_id); |
|
54 | + $this->getQueryJoin($parent_id); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | |
63 | 63 | $query = ("SELECT COUNT(DISTINCT rel.depth) as depth FROM " . static::$table . " ent ") . |
64 | 64 | |
65 | - $this->getQueryJoin($parent_id); |
|
65 | + $this->getQueryJoin($parent_id); |
|
66 | 66 | |
67 | 67 | # ------------------------ |
68 | 68 | |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | |
170 | 170 | $query = ("SELECT " . $this->getSelection() . " FROM " . static::$table . " ent ") . |
171 | 171 | |
172 | - ("JOIN " . static::$table_relations . " rel ON rel.ancestor = ent.id ") . |
|
172 | + ("JOIN " . static::$table_relations . " rel ON rel.ancestor = ent.id ") . |
|
173 | 173 | |
174 | 174 | ("WHERE rel.descendant = " . $parent_id . " ORDER BY rel.depth DESC"); |
175 | 175 |
@@ -19,11 +19,9 @@ discard block |
||
19 | 19 | |
20 | 20 | protected function getQueryJoin(int $parent_id) : string { |
21 | 21 | |
22 | - return (0 !== $parent_id) ? (("JOIN " . static::$table_relations . " rel ") . |
|
22 | + return (0 !== $parent_id) ? (("JOIN ".static::$table_relations." rel "). |
|
23 | 23 | |
24 | - ("ON rel.ancestor = " . $parent_id . " AND rel.descendant = ent.id AND rel.depth >= 1")) : |
|
25 | - |
|
26 | - ("JOIN " . static::$table_relations . " rel ON rel.descendant = ent.id"); |
|
24 | + ("ON rel.ancestor = ".$parent_id." AND rel.descendant = ent.id AND rel.depth >= 1")) : ("JOIN ".static::$table_relations." rel ON rel.descendant = ent.id"); |
|
27 | 25 | } |
28 | 26 | |
29 | 27 | /** |
@@ -32,15 +30,15 @@ discard block |
||
32 | 30 | |
33 | 31 | private function getSelectQuery(int $parent_id, array $config, array $order_by) : string { |
34 | 32 | |
35 | - return ("SELECT " . $this->getSelection() . ", COALESCE(par.ancestor, 0) as parent_id ") . |
|
33 | + return ("SELECT ".$this->getSelection().", COALESCE(par.ancestor, 0) as parent_id "). |
|
36 | 34 | |
37 | - ("FROM " . static::$table . " ent " . $this->getQueryJoin($parent_id) . " ") . |
|
35 | + ("FROM ".static::$table." ent ".$this->getQueryJoin($parent_id)." "). |
|
38 | 36 | |
39 | - ("LEFT JOIN " . static::$table_relations . " par ON par.descendant = ent.id AND par.depth = 1 ") . |
|
37 | + ("LEFT JOIN ".static::$table_relations." par ON par.descendant = ent.id AND par.depth = 1 "). |
|
40 | 38 | |
41 | - (('' !== ($condition = $this->getCondition($config))) ? ("WHERE " . $condition . " ") : "") . |
|
39 | + (('' !== ($condition = $this->getCondition($config))) ? ("WHERE ".$condition." ") : ""). |
|
42 | 40 | |
43 | - ("GROUP BY ent.id ORDER BY MAX(rel.depth) ASC, " . $this->getOrderBy($order_by)); |
|
41 | + ("GROUP BY ent.id ORDER BY MAX(rel.depth) ASC, ".$this->getOrderBy($order_by)); |
|
44 | 42 | } |
45 | 43 | |
46 | 44 | /** |
@@ -49,7 +47,7 @@ discard block |
||
49 | 47 | |
50 | 48 | private function getCountQuery(int $parent_id) : string { |
51 | 49 | |
52 | - return ("SELECT COUNT(DISTINCT ent.id) as count FROM " . static::$table . " ent ") . |
|
50 | + return ("SELECT COUNT(DISTINCT ent.id) as count FROM ".static::$table." ent "). |
|
53 | 51 | |
54 | 52 | $this->getQueryJoin($parent_id); |
55 | 53 | } |
@@ -60,7 +58,7 @@ discard block |
||
60 | 58 | |
61 | 59 | private function getDepthQuery(int $parent_id) : string { |
62 | 60 | |
63 | - $query = ("SELECT COUNT(DISTINCT rel.depth) as depth FROM " . static::$table . " ent ") . |
|
61 | + $query = ("SELECT COUNT(DISTINCT rel.depth) as depth FROM ".static::$table." ent "). |
|
64 | 62 | |
65 | 63 | $this->getQueryJoin($parent_id); |
66 | 64 | |
@@ -167,11 +165,11 @@ discard block |
||
167 | 165 | |
168 | 166 | # Process query |
169 | 167 | |
170 | - $query = ("SELECT " . $this->getSelection() . " FROM " . static::$table . " ent ") . |
|
168 | + $query = ("SELECT ".$this->getSelection()." FROM ".static::$table." ent "). |
|
171 | 169 | |
172 | - ("JOIN " . static::$table_relations . " rel ON rel.ancestor = ent.id ") . |
|
170 | + ("JOIN ".static::$table_relations." rel ON rel.ancestor = ent.id "). |
|
173 | 171 | |
174 | - ("WHERE rel.descendant = " . $parent_id . " ORDER BY rel.depth DESC"); |
|
172 | + ("WHERE rel.descendant = ".$parent_id." ORDER BY rel.depth DESC"); |
|
175 | 173 | |
176 | 174 | # Select path |
177 | 175 |
@@ -81,13 +81,17 @@ discard block |
||
81 | 81 | |
82 | 82 | public function getSubtree(int $parent_id = 0, array $config = [], array $order_by = []) { |
83 | 83 | |
84 | - if (!(static::$nesting && ($parent_id >= 0))) return false; |
|
84 | + if (!(static::$nesting && ($parent_id >= 0))) { |
|
85 | + return false; |
|
86 | + } |
|
85 | 87 | |
86 | 88 | # Select entities |
87 | 89 | |
88 | 90 | $query = $this->getSelectQuery($parent_id, $config, $order_by); |
89 | 91 | |
90 | - if (!(DB::send($query) && DB::getLast()->status)) return false; |
|
92 | + if (!(DB::send($query) && DB::getLast()->status)) { |
|
93 | + return false; |
|
94 | + } |
|
91 | 95 | |
92 | 96 | # Process results |
93 | 97 | |
@@ -117,13 +121,17 @@ discard block |
||
117 | 121 | |
118 | 122 | public function getSubtreeCount(int $parent_id = 0) { |
119 | 123 | |
120 | - if (!(static::$nesting && ($parent_id >= 0))) return false; |
|
124 | + if (!(static::$nesting && ($parent_id >= 0))) { |
|
125 | + return false; |
|
126 | + } |
|
121 | 127 | |
122 | 128 | # Get count |
123 | 129 | |
124 | 130 | $query = $this->getCountQuery($parent_id); |
125 | 131 | |
126 | - if (!(DB::send($query) && DB::getLast()->status)) return false; |
|
132 | + if (!(DB::send($query) && DB::getLast()->status)) { |
|
133 | + return false; |
|
134 | + } |
|
127 | 135 | |
128 | 136 | # ------------------------ |
129 | 137 | |
@@ -140,13 +148,17 @@ discard block |
||
140 | 148 | |
141 | 149 | public function getSubtreeDepth(int $parent_id = 0) { |
142 | 150 | |
143 | - if (!(static::$nesting && ($parent_id >= 0))) return false; |
|
151 | + if (!(static::$nesting && ($parent_id >= 0))) { |
|
152 | + return false; |
|
153 | + } |
|
144 | 154 | |
145 | 155 | # Get depth |
146 | 156 | |
147 | 157 | $query = $this->getDepthQuery($parent_id); |
148 | 158 | |
149 | - if (!(DB::send($query) && DB::getLast()->status)) return false; |
|
159 | + if (!(DB::send($query) && DB::getLast()->status)) { |
|
160 | + return false; |
|
161 | + } |
|
150 | 162 | |
151 | 163 | # ------------------------ |
152 | 164 | |
@@ -163,7 +175,9 @@ discard block |
||
163 | 175 | |
164 | 176 | public function getPath(int $parent_id = 0) { |
165 | 177 | |
166 | - if (!(static::$nesting && ($parent_id >= 0))) return false; |
|
178 | + if (!(static::$nesting && ($parent_id >= 0))) { |
|
179 | + return false; |
|
180 | + } |
|
167 | 181 | |
168 | 182 | # Process query |
169 | 183 | |
@@ -175,13 +189,17 @@ discard block |
||
175 | 189 | |
176 | 190 | # Select path |
177 | 191 | |
178 | - if (!(DB::send($query) && DB::getLast()->status)) return false; |
|
192 | + if (!(DB::send($query) && DB::getLast()->status)) { |
|
193 | + return false; |
|
194 | + } |
|
179 | 195 | |
180 | 196 | # Process results |
181 | 197 | |
182 | 198 | $path = []; |
183 | 199 | |
184 | - while (null !== ($data = DB::getLast()->getRow())) $path[] = Entitizer::getDataset(static::$table, $data)->getData(); |
|
200 | + while (null !== ($data = DB::getLast()->getRow())) { |
|
201 | + $path[] = Entitizer::getDataset(static::$table, $data)->getData(); |
|
202 | + } |
|
185 | 203 | |
186 | 204 | # ------------------------ |
187 | 205 |
@@ -40,15 +40,15 @@ discard block |
||
40 | 40 | |
41 | 41 | private function disconnectSubtree() : bool { |
42 | 42 | |
43 | - $query = ("DELETE rla FROM " . static::$table_relations . " rla ") . |
|
43 | + $query = ("DELETE rla FROM ".static::$table_relations." rla "). |
|
44 | 44 | |
45 | - ("JOIN " . static::$table_relations . " rlb ON rlb.descendant = rla.descendant ") . |
|
45 | + ("JOIN ".static::$table_relations." rlb ON rlb.descendant = rla.descendant "). |
|
46 | 46 | |
47 | - ("LEFT JOIN " . static::$table_relations . " rlx ") . |
|
47 | + ("LEFT JOIN ".static::$table_relations." rlx "). |
|
48 | 48 | |
49 | - ("ON rlx.ancestor = rlb.ancestor AND rlx.descendant = rla.ancestor ") . |
|
49 | + ("ON rlx.ancestor = rlb.ancestor AND rlx.descendant = rla.ancestor "). |
|
50 | 50 | |
51 | - ("WHERE rlb.ancestor = " . $this->id . " AND rlx.ancestor IS NULL"); |
|
51 | + ("WHERE rlb.ancestor = ".$this->id." AND rlx.ancestor IS NULL"); |
|
52 | 52 | |
53 | 53 | if (!(DB::send($query) && DB::getLast()->status)) return false; |
54 | 54 | |
@@ -69,15 +69,15 @@ discard block |
||
69 | 69 | |
70 | 70 | private function connectSubtree(int $parent_id) : bool { |
71 | 71 | |
72 | - $query = ("INSERT INTO " . static::$table_relations . " (ancestor, descendant, depth) ") . |
|
72 | + $query = ("INSERT INTO ".static::$table_relations." (ancestor, descendant, depth) "). |
|
73 | 73 | |
74 | - ("SELECT sup.ancestor, sub.descendant, sup.depth + sub.depth + 1 ") . |
|
74 | + ("SELECT sup.ancestor, sub.descendant, sup.depth + sub.depth + 1 "). |
|
75 | 75 | |
76 | - ("FROM " . static::$table_relations . " sup ") . |
|
76 | + ("FROM ".static::$table_relations." sup "). |
|
77 | 77 | |
78 | - ("JOIN " . static::$table_relations . " sub ") . |
|
78 | + ("JOIN ".static::$table_relations." sub "). |
|
79 | 79 | |
80 | - ("WHERE sub.ancestor = " . $this->id . " AND sup.descendant = " . $parent_id); |
|
80 | + ("WHERE sub.ancestor = ".$this->id." AND sup.descendant = ".$parent_id); |
|
81 | 81 | |
82 | 82 | if (!(DB::send($query) && (DB::getLast()->rows > 0))) return false; |
83 | 83 |
@@ -50,7 +50,9 @@ discard block |
||
50 | 50 | |
51 | 51 | ("WHERE rlb.ancestor = " . $this->id . " AND rlx.ancestor IS NULL"); |
52 | 52 | |
53 | - if (!(DB::send($query) && DB::getLast()->status)) return false; |
|
53 | + if (!(DB::send($query) && DB::getLast()->status)) { |
|
54 | + return false; |
|
55 | + } |
|
54 | 56 | |
55 | 57 | # Set path |
56 | 58 | |
@@ -79,7 +81,9 @@ discard block |
||
79 | 81 | |
80 | 82 | ("WHERE sub.ancestor = " . $this->id . " AND sup.descendant = " . $parent_id); |
81 | 83 | |
82 | - if (!(DB::send($query) && (DB::getLast()->rows > 0))) return false; |
|
84 | + if (!(DB::send($query) && (DB::getLast()->rows > 0))) { |
|
85 | + return false; |
|
86 | + } |
|
83 | 87 | |
84 | 88 | # Set path |
85 | 89 | |
@@ -98,27 +102,37 @@ discard block |
||
98 | 102 | |
99 | 103 | public function create(array $data) : bool { |
100 | 104 | |
101 | - if (0 !== $this->id) return false; |
|
105 | + if (0 !== $this->id) { |
|
106 | + return false; |
|
107 | + } |
|
102 | 108 | |
103 | 109 | $data = $this->dataset->cast($data); |
104 | 110 | |
105 | - if (static::$auto_increment && isset($data['id'])) $data['id'] = 0; |
|
111 | + if (static::$auto_increment && isset($data['id'])) { |
|
112 | + $data['id'] = 0; |
|
113 | + } |
|
106 | 114 | |
107 | 115 | # Insert entity |
108 | 116 | |
109 | 117 | DB::insert(static::$table, $data); |
110 | 118 | |
111 | - if (!(DB::getLast() && DB::getLast()->status)) return false; |
|
119 | + if (!(DB::getLast() && DB::getLast()->status)) { |
|
120 | + return false; |
|
121 | + } |
|
112 | 122 | |
113 | 123 | # Update data |
114 | 124 | |
115 | - if (static::$auto_increment) $data['id'] = DB::getLast()->id; |
|
125 | + if (static::$auto_increment) { |
|
126 | + $data['id'] = DB::getLast()->id; |
|
127 | + } |
|
116 | 128 | |
117 | 129 | $this->dataset->update($data); |
118 | 130 | |
119 | 131 | # Init subtreee |
120 | 132 | |
121 | - if (static::$nesting) $this->initSubtree(); |
|
133 | + if (static::$nesting) { |
|
134 | + $this->initSubtree(); |
|
135 | + } |
|
122 | 136 | |
123 | 137 | # Cache entity |
124 | 138 | |
@@ -137,17 +151,23 @@ discard block |
||
137 | 151 | |
138 | 152 | public function edit(array $data) : bool { |
139 | 153 | |
140 | - if (0 === $this->id) return false; |
|
154 | + if (0 === $this->id) { |
|
155 | + return false; |
|
156 | + } |
|
141 | 157 | |
142 | 158 | $data = $this->dataset->cast($data); |
143 | 159 | |
144 | - if (isset($data['id'])) unset($data['id']); |
|
160 | + if (isset($data['id'])) { |
|
161 | + unset($data['id']); |
|
162 | + } |
|
145 | 163 | |
146 | 164 | # Update entity |
147 | 165 | |
148 | 166 | DB::update(static::$table, $data, ['id' => $this->id]); |
149 | 167 | |
150 | - if (!(DB::getLast() && DB::getLast()->status)) return false; |
|
168 | + if (!(DB::getLast() && DB::getLast()->status)) { |
|
169 | + return false; |
|
170 | + } |
|
151 | 171 | |
152 | 172 | # Update data |
153 | 173 | |
@@ -155,7 +175,9 @@ discard block |
||
155 | 175 | |
156 | 176 | # Init subtreee |
157 | 177 | |
158 | - if (static::$nesting) $this->initSubtree(); |
|
178 | + if (static::$nesting) { |
|
179 | + $this->initSubtree(); |
|
180 | + } |
|
159 | 181 | |
160 | 182 | # ------------------------ |
161 | 183 | |
@@ -170,30 +192,44 @@ discard block |
||
170 | 192 | |
171 | 193 | public function move(int $parent_id) : bool { |
172 | 194 | |
173 | - if (0 === $this->id) return false; |
|
195 | + if (0 === $this->id) { |
|
196 | + return false; |
|
197 | + } |
|
174 | 198 | |
175 | 199 | # Re-connect entity if not in tree |
176 | 200 | |
177 | - if (!$this->initSubtree()) return false; |
|
201 | + if (!$this->initSubtree()) { |
|
202 | + return false; |
|
203 | + } |
|
178 | 204 | |
179 | 205 | # Get parent entity |
180 | 206 | |
181 | 207 | if (0 !== ($parent = Entitizer::get(static::$table, $parent_id))->id) { |
182 | 208 | |
183 | - if (false === ($path = $parent->getPath())) return false; |
|
209 | + if (false === ($path = $parent->getPath())) { |
|
210 | + return false; |
|
211 | + } |
|
184 | 212 | |
185 | - if (false === ($depth = $this->getSubtreeDepth())) return false; |
|
213 | + if (false === ($depth = $this->getSubtreeDepth())) { |
|
214 | + return false; |
|
215 | + } |
|
186 | 216 | |
187 | - if ((count($path) + $depth + 1) > CONFIG_ENTITIZER_MAX_DEPTH) return false; |
|
217 | + if ((count($path) + $depth + 1) > CONFIG_ENTITIZER_MAX_DEPTH) { |
|
218 | + return false; |
|
219 | + } |
|
188 | 220 | } |
189 | 221 | |
190 | 222 | # Disconnect subtree from current position |
191 | 223 | |
192 | - if (!$this->disconnectSubtree()) return false; |
|
224 | + if (!$this->disconnectSubtree()) { |
|
225 | + return false; |
|
226 | + } |
|
193 | 227 | |
194 | 228 | # Connect subtree under new position |
195 | 229 | |
196 | - if (0 !== $parent->id) $this->connectSubtree($parent->id); |
|
230 | + if (0 !== $parent->id) { |
|
231 | + $this->connectSubtree($parent->id); |
|
232 | + } |
|
197 | 233 | |
198 | 234 | # ------------------------ |
199 | 235 | |
@@ -208,19 +244,27 @@ discard block |
||
208 | 244 | |
209 | 245 | public function remove() : bool { |
210 | 246 | |
211 | - if (0 === $this->id) return false; |
|
247 | + if (0 === $this->id) { |
|
248 | + return false; |
|
249 | + } |
|
212 | 250 | |
213 | 251 | # Check if entity is removable |
214 | 252 | |
215 | - if (static::$super && ($this->id === 1)) return false; |
|
253 | + if (static::$super && ($this->id === 1)) { |
|
254 | + return false; |
|
255 | + } |
|
216 | 256 | |
217 | - if (static::$nesting && (0 !== $this->getSubtreeCount())) return false; |
|
257 | + if (static::$nesting && (0 !== $this->getSubtreeCount())) { |
|
258 | + return false; |
|
259 | + } |
|
218 | 260 | |
219 | 261 | # Remove entity |
220 | 262 | |
221 | 263 | DB::delete(static::$table, ['id' => $this->id]); |
222 | 264 | |
223 | - if (!(DB::getLast() && DB::getLast()->status)) return false; |
|
265 | + if (!(DB::getLast() && DB::getLast()->status)) { |
|
266 | + return false; |
|
267 | + } |
|
224 | 268 | |
225 | 269 | # Uncache entity |
226 | 270 |
@@ -21,13 +21,13 @@ discard block |
||
21 | 21 | |
22 | 22 | return ("SELECT SQL_CALC_FOUND_ROWS " . $this->getSelection() . " ") . |
23 | 23 | |
24 | - ("FROM " . static::$table . " ent ") . |
|
24 | + ("FROM " . static::$table . " ent ") . |
|
25 | 25 | |
26 | 26 | (('' !== ($condition = $this->getCondition($config))) ? ("WHERE " . $condition . " ") : "") . |
27 | 27 | |
28 | 28 | ("ORDER BY " . $this->getOrderBy($order_by) . " ") . |
29 | 29 | |
30 | - (($index > 0) ? ("LIMIT " . ((($index - 1) * $display) . ", " . $display)) : ""); |
|
30 | + (($index > 0) ? ("LIMIT " . ((($index - 1) * $display) . ", " . $display)) : ""); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -38,9 +38,9 @@ discard block |
||
38 | 38 | |
39 | 39 | return ("SELECT SQL_CALC_FOUND_ROWS " . $this->getSelection() . ", COUNT(chd.descendant) as children ") . |
40 | 40 | |
41 | - ("FROM " . static::$table . " ent ") . |
|
41 | + ("FROM " . static::$table . " ent ") . |
|
42 | 42 | |
43 | - ("LEFT JOIN " . static::$table_relations . " chd ON chd.ancestor = ent.id AND chd.depth = 1 ") . |
|
43 | + ("LEFT JOIN " . static::$table_relations . " chd ON chd.ancestor = ent.id AND chd.depth = 1 ") . |
|
44 | 44 | |
45 | 45 | ("LEFT JOIN " . static::$table_relations . " rel ON rel.descendant = ent.id AND rel.depth = 1 ") . |
46 | 46 | |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | |
51 | 51 | ("GROUP BY ent.id ORDER BY " . $this->getOrderBy($order_by) . " ") . |
52 | 52 | |
53 | - (($index > 0) ? ("LIMIT " . ((($index - 1) * $display) . ", " . $display)) : ""); |
|
53 | + (($index > 0) ? ("LIMIT " . ((($index - 1) * $display) . ", " . $display)) : ""); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | |
62 | 62 | return ("SELECT COUNT(ent.id) as count FROM " . static::$table . " ent ") . |
63 | 63 | |
64 | - (('' !== ($condition = $this->getCondition($config))) ? ("WHERE " . $condition) : ""); |
|
64 | + (('' !== ($condition = $this->getCondition($config))) ? ("WHERE " . $condition) : ""); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
@@ -72,11 +72,11 @@ discard block |
||
72 | 72 | |
73 | 73 | return ("SELECT COUNT(ent.id) as count FROM " . static::$table . " ent ") . |
74 | 74 | |
75 | - ("LEFT JOIN " . static::$table_relations . " rel ON rel.descendant = ent.id AND rel.depth = 1 ") . |
|
75 | + ("LEFT JOIN " . static::$table_relations . " rel ON rel.descendant = ent.id AND rel.depth = 1 ") . |
|
76 | 76 | |
77 | - ("WHERE COALESCE(rel.ancestor, 0) = " . $parent_id . " ") . |
|
77 | + ("WHERE COALESCE(rel.ancestor, 0) = " . $parent_id . " ") . |
|
78 | 78 | |
79 | - (('' !== ($condition = $this->getCondition($config))) ? ("AND " . $condition) : ""); |
|
79 | + (('' !== ($condition = $this->getCondition($config))) ? ("AND " . $condition) : ""); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -19,15 +19,15 @@ discard block |
||
19 | 19 | |
20 | 20 | private function getBasicSelectQuery(array $config, array $order_by, int $index, int $display) : string { |
21 | 21 | |
22 | - return ("SELECT SQL_CALC_FOUND_ROWS " . $this->getSelection() . " ") . |
|
22 | + return ("SELECT SQL_CALC_FOUND_ROWS ".$this->getSelection()." "). |
|
23 | 23 | |
24 | - ("FROM " . static::$table . " ent ") . |
|
24 | + ("FROM ".static::$table." ent "). |
|
25 | 25 | |
26 | - (('' !== ($condition = $this->getCondition($config))) ? ("WHERE " . $condition . " ") : "") . |
|
26 | + (('' !== ($condition = $this->getCondition($config))) ? ("WHERE ".$condition." ") : ""). |
|
27 | 27 | |
28 | - ("ORDER BY " . $this->getOrderBy($order_by) . " ") . |
|
28 | + ("ORDER BY ".$this->getOrderBy($order_by)." "). |
|
29 | 29 | |
30 | - (($index > 0) ? ("LIMIT " . ((($index - 1) * $display) . ", " . $display)) : ""); |
|
30 | + (($index > 0) ? ("LIMIT ".((($index - 1) * $display).", ".$display)) : ""); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -36,21 +36,21 @@ discard block |
||
36 | 36 | |
37 | 37 | private function getNestingSelectQuery(int $parent_id, array $config, array $order_by, int $index, int $display) : string { |
38 | 38 | |
39 | - return ("SELECT SQL_CALC_FOUND_ROWS " . $this->getSelection() . ", COUNT(chd.descendant) as children ") . |
|
39 | + return ("SELECT SQL_CALC_FOUND_ROWS ".$this->getSelection().", COUNT(chd.descendant) as children "). |
|
40 | 40 | |
41 | - ("FROM " . static::$table . " ent ") . |
|
41 | + ("FROM ".static::$table." ent "). |
|
42 | 42 | |
43 | - ("LEFT JOIN " . static::$table_relations . " chd ON chd.ancestor = ent.id AND chd.depth = 1 ") . |
|
43 | + ("LEFT JOIN ".static::$table_relations." chd ON chd.ancestor = ent.id AND chd.depth = 1 "). |
|
44 | 44 | |
45 | - ("LEFT JOIN " . static::$table_relations . " rel ON rel.descendant = ent.id AND rel.depth = 1 ") . |
|
45 | + ("LEFT JOIN ".static::$table_relations." rel ON rel.descendant = ent.id AND rel.depth = 1 "). |
|
46 | 46 | |
47 | - ("WHERE COALESCE(rel.ancestor, 0) = " . $parent_id . " ") . |
|
47 | + ("WHERE COALESCE(rel.ancestor, 0) = ".$parent_id." "). |
|
48 | 48 | |
49 | - (('' !== ($condition = $this->getCondition($config))) ? ("AND " . $condition . " ") : "") . |
|
49 | + (('' !== ($condition = $this->getCondition($config))) ? ("AND ".$condition." ") : ""). |
|
50 | 50 | |
51 | - ("GROUP BY ent.id ORDER BY " . $this->getOrderBy($order_by) . " ") . |
|
51 | + ("GROUP BY ent.id ORDER BY ".$this->getOrderBy($order_by)." "). |
|
52 | 52 | |
53 | - (($index > 0) ? ("LIMIT " . ((($index - 1) * $display) . ", " . $display)) : ""); |
|
53 | + (($index > 0) ? ("LIMIT ".((($index - 1) * $display).", ".$display)) : ""); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -59,9 +59,9 @@ discard block |
||
59 | 59 | |
60 | 60 | private function getBasicCountQuery(array $config) : string { |
61 | 61 | |
62 | - return ("SELECT COUNT(ent.id) as count FROM " . static::$table . " ent ") . |
|
62 | + return ("SELECT COUNT(ent.id) as count FROM ".static::$table." ent "). |
|
63 | 63 | |
64 | - (('' !== ($condition = $this->getCondition($config))) ? ("WHERE " . $condition) : ""); |
|
64 | + (('' !== ($condition = $this->getCondition($config))) ? ("WHERE ".$condition) : ""); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
@@ -70,13 +70,13 @@ discard block |
||
70 | 70 | |
71 | 71 | private function getNestingCountQuery(int $parent_id, array $config) : string { |
72 | 72 | |
73 | - return ("SELECT COUNT(ent.id) as count FROM " . static::$table . " ent ") . |
|
73 | + return ("SELECT COUNT(ent.id) as count FROM ".static::$table." ent "). |
|
74 | 74 | |
75 | - ("LEFT JOIN " . static::$table_relations . " rel ON rel.descendant = ent.id AND rel.depth = 1 ") . |
|
75 | + ("LEFT JOIN ".static::$table_relations." rel ON rel.descendant = ent.id AND rel.depth = 1 "). |
|
76 | 76 | |
77 | - ("WHERE COALESCE(rel.ancestor, 0) = " . $parent_id . " ") . |
|
77 | + ("WHERE COALESCE(rel.ancestor, 0) = ".$parent_id." "). |
|
78 | 78 | |
79 | - (('' !== ($condition = $this->getCondition($config))) ? ("AND " . $condition) : ""); |
|
79 | + (('' !== ($condition = $this->getCondition($config))) ? ("AND ".$condition) : ""); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -93,9 +93,7 @@ discard block |
||
93 | 93 | |
94 | 94 | # Select entities |
95 | 95 | |
96 | - $query = ((null === $parent_id) ? $this->getBasicSelectQuery($config, $order_by, $index, $display) : |
|
97 | - |
|
98 | - $this->getNestingSelectQuery($parent_id, $config, $order_by, $index, $display)); |
|
96 | + $query = ((null === $parent_id) ? $this->getBasicSelectQuery($config, $order_by, $index, $display) : $this->getNestingSelectQuery($parent_id, $config, $order_by, $index, $display)); |
|
99 | 97 | |
100 | 98 | if (!(DB::send($query) && DB::getLast()->status)) return false; |
101 | 99 | |
@@ -136,9 +134,7 @@ discard block |
||
136 | 134 | |
137 | 135 | # Count entities |
138 | 136 | |
139 | - $query = ((null === $parent_id) ? $this->getBasicCountQuery($config) : |
|
140 | - |
|
141 | - $this->getNestingCountQuery($parent_id, $config)); |
|
137 | + $query = ((null === $parent_id) ? $this->getBasicCountQuery($config) : $this->getNestingCountQuery($parent_id, $config)); |
|
142 | 138 | |
143 | 139 | if (!(DB::send($query) && DB::getLast()->status)) return false; |
144 | 140 |
@@ -87,9 +87,13 @@ discard block |
||
87 | 87 | |
88 | 88 | private function select(int $parent_id = null, array $config = [], array $order_by = [], int $index = 0, int $display = 0) { |
89 | 89 | |
90 | - if (!((null === $parent_id) || ($parent_id >= 0))) return false; |
|
90 | + if (!((null === $parent_id) || ($parent_id >= 0))) { |
|
91 | + return false; |
|
92 | + } |
|
91 | 93 | |
92 | - if (!(($index >= 0) && ($display >= 0))) return false; |
|
94 | + if (!(($index >= 0) && ($display >= 0))) { |
|
95 | + return false; |
|
96 | + } |
|
93 | 97 | |
94 | 98 | # Select entities |
95 | 99 | |
@@ -97,7 +101,9 @@ discard block |
||
97 | 101 | |
98 | 102 | $this->getNestingSelectQuery($parent_id, $config, $order_by, $index, $display)); |
99 | 103 | |
100 | - if (!(DB::send($query) && DB::getLast()->status)) return false; |
|
104 | + if (!(DB::send($query) && DB::getLast()->status)) { |
|
105 | + return false; |
|
106 | + } |
|
101 | 107 | |
102 | 108 | # Process results |
103 | 109 | |
@@ -109,7 +115,9 @@ discard block |
||
109 | 115 | |
110 | 116 | $items['list'][$dataset->id]['dataset'] = $dataset; |
111 | 117 | |
112 | - if (null !== $parent_id) $items['list'][$dataset->id]['children'] = intval($data['children']); |
|
118 | + if (null !== $parent_id) { |
|
119 | + $items['list'][$dataset->id]['children'] = intval($data['children']); |
|
120 | + } |
|
113 | 121 | } |
114 | 122 | |
115 | 123 | # Count total |
@@ -132,7 +140,9 @@ discard block |
||
132 | 140 | |
133 | 141 | private function count(int $parent_id = null, array $config = []) { |
134 | 142 | |
135 | - if (!((null === $parent_id) || ($parent_id >= 0))) return false; |
|
143 | + if (!((null === $parent_id) || ($parent_id >= 0))) { |
|
144 | + return false; |
|
145 | + } |
|
136 | 146 | |
137 | 147 | # Count entities |
138 | 148 | |
@@ -140,7 +150,9 @@ discard block |
||
140 | 150 | |
141 | 151 | $this->getNestingCountQuery($parent_id, $config)); |
142 | 152 | |
143 | - if (!(DB::send($query) && DB::getLast()->status)) return false; |
|
153 | + if (!(DB::send($query) && DB::getLast()->status)) { |
|
154 | + return false; |
|
155 | + } |
|
144 | 156 | |
145 | 157 | # ------------------------ |
146 | 158 | |
@@ -190,7 +202,9 @@ discard block |
||
190 | 202 | |
191 | 203 | public function getChildren(int $parent_id = 0, array $config = [], array $order_by = [], int $index = 0, int $display = 0) { |
192 | 204 | |
193 | - if (!static::$nesting) return false; |
|
205 | + if (!static::$nesting) { |
|
206 | + return false; |
|
207 | + } |
|
194 | 208 | |
195 | 209 | return $this->select($parent_id, $config, $order_by, $index, $display); |
196 | 210 | } |
@@ -206,7 +220,9 @@ discard block |
||
206 | 220 | |
207 | 221 | public function getChildrenCount(int $parent_id = 0, array $config = []) { |
208 | 222 | |
209 | - if (!static::$nesting) return false; |
|
223 | + if (!static::$nesting) { |
|
224 | + return false; |
|
225 | + } |
|
210 | 226 | |
211 | 227 | return $this->count($parent_id, $config); |
212 | 228 | } |
@@ -37,9 +37,9 @@ |
||
37 | 37 | |
38 | 38 | protected function processEntityParent(Template\Block $parent) { |
39 | 39 | |
40 | - if ((0 !== $this->parent->id) && $this->parent->active) $parent->getBlock('browse')->link = $this->parent->link; |
|
41 | - |
|
42 | - else { $parent->getBlock('browse')->disable(); $parent->getBlock('browse_disabled')->enable(); } |
|
40 | + if ((0 !== $this->parent->id) && $this->parent->active) { |
|
41 | + $parent->getBlock('browse')->link = $this->parent->link; |
|
42 | + } else { $parent->getBlock('browse')->disable(); $parent->getBlock('browse_disabled')->enable(); } |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -37,9 +37,9 @@ |
||
37 | 37 | |
38 | 38 | protected function processEntityParent(Template\Block $parent) { |
39 | 39 | |
40 | - if (0 !== $this->parent->id) $parent->getBlock('browse')->link = $this->parent->link; |
|
41 | - |
|
42 | - else { $parent->getBlock('browse')->disable(); $parent->getBlock('browse_disabled')->enable(); } |
|
40 | + if (0 !== $this->parent->id) { |
|
41 | + $parent->getBlock('browse')->link = $this->parent->link; |
|
42 | + } else { $parent->getBlock('browse')->disable(); $parent->getBlock('browse_disabled')->enable(); } |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -41,9 +41,9 @@ discard block |
||
41 | 41 | |
42 | 42 | protected function processEntityParent(Template\Block $parent) { |
43 | 43 | |
44 | - if ((0 !== $this->parent->id) && $this->parent->active) $parent->getBlock('browse')->link = $this->parent->link; |
|
45 | - |
|
46 | - else { $parent->getBlock('browse')->disable(); $parent->getBlock('browse_disabled')->enable(); } |
|
44 | + if ((0 !== $this->parent->id) && $this->parent->active) { |
|
45 | + $parent->getBlock('browse')->link = $this->parent->link; |
|
46 | + } else { $parent->getBlock('browse')->disable(); $parent->getBlock('browse_disabled')->enable(); } |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -52,7 +52,9 @@ discard block |
||
52 | 52 | |
53 | 53 | protected function processEntity(Template\Block $contents) { |
54 | 54 | |
55 | - if (!$this->create && $this->parent->locked) $contents->getBlock('locked')->enable(); |
|
55 | + if (!$this->create && $this->parent->locked) { |
|
56 | + $contents->getBlock('locked')->enable(); |
|
57 | + } |
|
56 | 58 | } |
57 | 59 | } |
58 | 60 | } |
@@ -41,9 +41,9 @@ |
||
41 | 41 | |
42 | 42 | protected function processEntityParent(Template\Block $parent) { |
43 | 43 | |
44 | - if (0 !== $this->parent->id) $parent->getBlock('browse')->link = $this->parent->link; |
|
45 | - |
|
46 | - else { $parent->getBlock('browse')->disable(); $parent->getBlock('browse_disabled')->enable(); } |
|
44 | + if (0 !== $this->parent->id) { |
|
45 | + $parent->getBlock('browse')->link = $this->parent->link; |
|
46 | + } else { $parent->getBlock('browse')->disable(); $parent->getBlock('browse_disabled')->enable(); } |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |