@@ -12,23 +12,23 @@ |
||
12 | 12 | |
13 | 13 | protected function init() { |
14 | 14 | |
15 | - $this->addHandler('active', function (array $data) { |
|
15 | + $this->addHandler('active', function(array $data) { |
|
16 | 16 | |
17 | 17 | return (($data['visibility'] === VISIBILITY_PUBLISHED) && !$data['locked']); |
18 | 18 | }); |
19 | 19 | |
20 | - $this->addHandler('link', function (array $data) { |
|
20 | + $this->addHandler('link', function(array $data) { |
|
21 | 21 | |
22 | 22 | if ('' === $data['slug']) return ''; |
23 | 23 | |
24 | - return (INSTALL_PATH . '/' . $data['slug']); |
|
24 | + return (INSTALL_PATH.'/'.$data['slug']); |
|
25 | 25 | }); |
26 | 26 | |
27 | - $this->addHandler('canonical', function (array $data) { |
|
27 | + $this->addHandler('canonical', function(array $data) { |
|
28 | 28 | |
29 | 29 | if ('' === $data['slug']) return ''; |
30 | 30 | |
31 | - return (Settings::get('system_url') . (($data['id'] !== 1) ? ('/' . $data['slug']) : '')); |
|
31 | + return (Settings::get('system_url').(($data['id'] !== 1) ? ('/'.$data['slug']) : '')); |
|
32 | 32 | }); |
33 | 33 | } |
34 | 34 | } |
@@ -12,9 +12,9 @@ |
||
12 | 12 | |
13 | 13 | protected function init() { |
14 | 14 | |
15 | - $this->addHandler('full_name', function (array $data) { |
|
15 | + $this->addHandler('full_name', function(array $data) { |
|
16 | 16 | |
17 | - return trim($data['first_name'] . ' ' . $data['last_name']); |
|
17 | + return trim($data['first_name'].' '.$data['last_name']); |
|
18 | 18 | }); |
19 | 19 | } |
20 | 20 | } |
@@ -12,13 +12,13 @@ |
||
12 | 12 | |
13 | 13 | protected function init() { |
14 | 14 | |
15 | - $this->addHandler('link', function (array $data) { |
|
15 | + $this->addHandler('link', function(array $data) { |
|
16 | 16 | |
17 | 17 | if ('' === $data['slug']) return ''; |
18 | 18 | |
19 | 19 | if (false !== Validate::url($data['slug'])) return $data['slug']; |
20 | 20 | |
21 | - return (INSTALL_PATH . '/' . $data['slug']); |
|
21 | + return (INSTALL_PATH.'/'.$data['slug']); |
|
22 | 22 | }); |
23 | 23 | } |
24 | 24 | } |
@@ -10,33 +10,31 @@ discard block |
||
10 | 10 | |
11 | 11 | protected function getQueryJoin(int $parent_id) { |
12 | 12 | |
13 | - return (0 !== $parent_id) ? (("JOIN " . static::$table_relations . " rel ") . |
|
13 | + return (0 !== $parent_id) ? (("JOIN ".static::$table_relations." rel "). |
|
14 | 14 | |
15 | - ("ON rel.ancestor = " . $parent_id . " AND rel.descendant = ent.id AND rel.depth >= 1")) : |
|
16 | - |
|
17 | - ("JOIN " . static::$table_relations . " rel ON rel.descendant = ent.id"); |
|
15 | + ("ON rel.ancestor = ".$parent_id." AND rel.descendant = ent.id AND rel.depth >= 1")) : ("JOIN ".static::$table_relations." rel ON rel.descendant = ent.id"); |
|
18 | 16 | } |
19 | 17 | |
20 | 18 | # Get select query |
21 | 19 | |
22 | 20 | private function getSelectQuery(int $parent_id, array $config, array $order_by) { |
23 | 21 | |
24 | - return ("SELECT " . $this->getSelection() . ", COALESCE(par.ancestor, 0) as parent_id ") . |
|
22 | + return ("SELECT ".$this->getSelection().", COALESCE(par.ancestor, 0) as parent_id "). |
|
25 | 23 | |
26 | - ("FROM " . static::$table . " ent " . $this->getQueryJoin($parent_id) . " ") . |
|
24 | + ("FROM ".static::$table." ent ".$this->getQueryJoin($parent_id)." "). |
|
27 | 25 | |
28 | - ("LEFT JOIN " . static::$table_relations . " par ON par.descendant = ent.id AND par.depth = 1 ") . |
|
26 | + ("LEFT JOIN ".static::$table_relations." par ON par.descendant = ent.id AND par.depth = 1 "). |
|
29 | 27 | |
30 | - (('' !== ($condition = $this->getCondition($config))) ? ("WHERE " . $condition . " ") : "") . |
|
28 | + (('' !== ($condition = $this->getCondition($config))) ? ("WHERE ".$condition." ") : ""). |
|
31 | 29 | |
32 | - ("GROUP BY ent.id ORDER BY MAX(rel.depth) ASC, " . $this->getOrderBy($order_by)); |
|
30 | + ("GROUP BY ent.id ORDER BY MAX(rel.depth) ASC, ".$this->getOrderBy($order_by)); |
|
33 | 31 | } |
34 | 32 | |
35 | 33 | # Get count query |
36 | 34 | |
37 | 35 | private function getCountQuery(int $parent_id) { |
38 | 36 | |
39 | - return ("SELECT COUNT(DISTINCT ent.id) as count FROM " . static::$table . " ent ") . |
|
37 | + return ("SELECT COUNT(DISTINCT ent.id) as count FROM ".static::$table." ent "). |
|
40 | 38 | |
41 | 39 | $this->getQueryJoin($parent_id); |
42 | 40 | } |
@@ -45,7 +43,7 @@ discard block |
||
45 | 43 | |
46 | 44 | private function getDepthQuery(int $parent_id) { |
47 | 45 | |
48 | - $query = ("SELECT COUNT(DISTINCT rel.depth) as depth FROM " . static::$table . " ent ") . |
|
46 | + $query = ("SELECT COUNT(DISTINCT rel.depth) as depth FROM ".static::$table." ent "). |
|
49 | 47 | |
50 | 48 | $this->getQueryJoin($parent_id); |
51 | 49 | |
@@ -126,11 +124,11 @@ discard block |
||
126 | 124 | |
127 | 125 | # Process query |
128 | 126 | |
129 | - $query = ("SELECT " . $this->getSelection() . " FROM " . static::$table . " ent ") . |
|
127 | + $query = ("SELECT ".$this->getSelection()." FROM ".static::$table." ent "). |
|
130 | 128 | |
131 | - ("JOIN " . static::$table_relations . " rel ON rel.ancestor = ent.id ") . |
|
129 | + ("JOIN ".static::$table_relations." rel ON rel.ancestor = ent.id "). |
|
132 | 130 | |
133 | - ("WHERE rel.descendant = " . $parent_id . " ORDER BY rel.depth DESC"); |
|
131 | + ("WHERE rel.descendant = ".$parent_id." ORDER BY rel.depth DESC"); |
|
134 | 132 | |
135 | 133 | # Select path |
136 | 134 |
@@ -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::user()->rank . " AND ") . |
|
35 | + ("WHERE ent.visibility = ".VISIBILITY_PUBLISHED." AND ent.access <= ".Auth::user()->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 |