@@ -23,7 +23,7 @@ |
||
23 | 23 | |
24 | 24 | return ("`" . $this->name . "` " . ($this->short ? ("varchar(" . $this->length . ")") : "text")) . |
25 | 25 | |
26 | - (($this->binary ? " BINARY" : "") . " NOT NULL DEFAULT '" . $this->default . "'"); |
|
26 | + (($this->binary ? " BINARY" : "") . " NOT NULL DEFAULT '" . $this->default . "'"); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | # Cast value |
@@ -21,9 +21,9 @@ |
||
21 | 21 | |
22 | 22 | public function statement() { |
23 | 23 | |
24 | - return ("`" . $this->name . "` " . ($this->short ? ("varchar(" . $this->length . ")") : "text")) . |
|
24 | + return ("`".$this->name."` ".($this->short ? ("varchar(".$this->length.")") : "text")). |
|
25 | 25 | |
26 | - (($this->binary ? " BINARY" : "") . " NOT NULL DEFAULT '" . $this->default . "'"); |
|
26 | + (($this->binary ? " BINARY" : "")." NOT NULL DEFAULT '".$this->default."'"); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | # Cast value |
@@ -16,7 +16,9 @@ |
||
16 | 16 | |
17 | 17 | # Set field configuration |
18 | 18 | |
19 | - foreach (get_defined_vars() as $name => $value) $this->$name = $value; |
|
19 | + foreach (get_defined_vars() as $name => $value) { |
|
20 | + $this->$name = $value; |
|
21 | + } |
|
20 | 22 | } |
21 | 23 | |
22 | 24 | # Get field statement |
@@ -21,7 +21,7 @@ |
||
21 | 21 | |
22 | 22 | public function statement() { |
23 | 23 | |
24 | - return ("`" . $this->name . "` tinyint(1) UNSIGNED NOT NULL DEFAULT '" . intval($this->default) . "'"); |
|
24 | + return ("`".$this->name."` tinyint(1) UNSIGNED NOT NULL DEFAULT '".intval($this->default)."'"); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | # Cast value |
@@ -16,7 +16,9 @@ |
||
16 | 16 | |
17 | 17 | # Set field configuration |
18 | 18 | |
19 | - foreach (get_defined_vars() as $name => $value) $this->$name = $value; |
|
19 | + foreach (get_defined_vars() as $name => $value) { |
|
20 | + $this->$name = $value; |
|
21 | + } |
|
20 | 22 | } |
21 | 23 | |
22 | 24 | # Get field statement |
@@ -30,9 +30,9 @@ |
||
30 | 30 | |
31 | 31 | $query = ("CREATE TABLE IF NOT EXISTS `" . static::$table . "` (") . |
32 | 32 | |
33 | - implode(", ", $this->getStatements()) . |
|
33 | + implode(", ", $this->getStatements()) . |
|
34 | 34 | |
35 | - (") ENGINE=InnoDB DEFAULT CHARSET=utf8"); |
|
35 | + (") ENGINE=InnoDB DEFAULT CHARSET=utf8"); |
|
36 | 36 | |
37 | 37 | # ------------------------ |
38 | 38 |
@@ -16,7 +16,9 @@ |
||
16 | 16 | |
17 | 17 | foreach ([$this->params, $this->indexes, $this->foreigns] as $group) { |
18 | 18 | |
19 | - foreach ($group->list() as $item) $statements[] = $item->statement(); |
|
19 | + foreach ($group->list() as $item) { |
|
20 | + $statements[] = $item->statement(); |
|
21 | + } |
|
20 | 22 | } |
21 | 23 | |
22 | 24 | # ------------------------ |
@@ -28,9 +28,9 @@ discard block |
||
28 | 28 | |
29 | 29 | private function createMainTable() { |
30 | 30 | |
31 | - $query = ("CREATE TABLE IF NOT EXISTS `" . static::$table . "` (") . |
|
31 | + $query = ("CREATE TABLE IF NOT EXISTS `".static::$table."` ("). |
|
32 | 32 | |
33 | - implode(", ", $this->getStatements()) . |
|
33 | + implode(", ", $this->getStatements()). |
|
34 | 34 | |
35 | 35 | (") ENGINE=InnoDB DEFAULT CHARSET=utf8"); |
36 | 36 | |
@@ -43,17 +43,17 @@ discard block |
||
43 | 43 | |
44 | 44 | private function createRelationsTable() { |
45 | 45 | |
46 | - $query = ("CREATE TABLE IF NOT EXISTS `" . static::$table_relations . "` (") . |
|
46 | + $query = ("CREATE TABLE IF NOT EXISTS `".static::$table_relations."` ("). |
|
47 | 47 | |
48 | - ("`ancestor` int(10) UNSIGNED NOT NULL, `descendant` int(10) UNSIGNED NOT NULL, ") . |
|
48 | + ("`ancestor` int(10) UNSIGNED NOT NULL, `descendant` int(10) UNSIGNED NOT NULL, "). |
|
49 | 49 | |
50 | - ("`depth` int(10) UNSIGNED NOT NULL, ") . |
|
50 | + ("`depth` int(10) UNSIGNED NOT NULL, "). |
|
51 | 51 | |
52 | - ("PRIMARY KEY (`ancestor`, `descendant`), KEY (`ancestor`), KEY (`descendant`), KEY (`depth`), ") . |
|
52 | + ("PRIMARY KEY (`ancestor`, `descendant`), KEY (`ancestor`), KEY (`descendant`), KEY (`depth`), "). |
|
53 | 53 | |
54 | - ("FOREIGN KEY (`ancestor`) REFERENCES `" . static::$table . "` (`id`) ON DELETE CASCADE, ") . |
|
54 | + ("FOREIGN KEY (`ancestor`) REFERENCES `".static::$table."` (`id`) ON DELETE CASCADE, "). |
|
55 | 55 | |
56 | - ("FOREIGN KEY (`descendant`) REFERENCES `" . static::$table . "` (`id`) ON DELETE CASCADE ") . |
|
56 | + ("FOREIGN KEY (`descendant`) REFERENCES `".static::$table."` (`id`) ON DELETE CASCADE "). |
|
57 | 57 | |
58 | 58 | (") ENGINE=InnoDB DEFAULT CHARSET=utf8"); |
59 | 59 | |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | |
67 | 67 | private function removeMainTable() { |
68 | 68 | |
69 | - $query = ("DROP TABLE IF EXISTS `" . static::$table . "`"); |
|
69 | + $query = ("DROP TABLE IF EXISTS `".static::$table."`"); |
|
70 | 70 | |
71 | 71 | return (DB::send($query) && DB::getLast()->status); |
72 | 72 | } |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | |
76 | 76 | private function removeRelationsTable() { |
77 | 77 | |
78 | - $query = ("DROP TABLE IF EXISTS `" . static::$table_relations . "`"); |
|
78 | + $query = ("DROP TABLE IF EXISTS `".static::$table_relations."`"); |
|
79 | 79 | |
80 | 80 | return (DB::send($query) && DB::getLast()->status); |
81 | 81 | } |
@@ -24,11 +24,11 @@ |
||
24 | 24 | |
25 | 25 | $query = ("SELECT " . implode(', ', $selection) .", rel.ancestor as parent_id ") . |
26 | 26 | |
27 | - ("FROM " . static::$table . " ent ") . |
|
27 | + ("FROM " . static::$table . " ent ") . |
|
28 | 28 | |
29 | - ("LEFT JOIN " . static::$table_relations . " rel ON rel.descendant = ent.id AND rel.depth = 1 ") . |
|
29 | + ("LEFT JOIN " . static::$table_relations . " rel ON rel.descendant = ent.id AND rel.depth = 1 ") . |
|
30 | 30 | |
31 | - ("WHERE ent." . $name . " = '" . addslashes($value) . "' LIMIT 1"); |
|
31 | + ("WHERE ent." . $name . " = '" . addslashes($value) . "' LIMIT 1"); |
|
32 | 32 | |
33 | 33 | # ------------------------ |
34 | 34 |
@@ -18,17 +18,17 @@ discard block |
||
18 | 18 | |
19 | 19 | $selection = array_keys($this->definition->params()); |
20 | 20 | |
21 | - foreach ($selection as $key => $field) $selection[$key] = ('ent.' . $field); |
|
21 | + foreach ($selection as $key => $field) $selection[$key] = ('ent.'.$field); |
|
22 | 22 | |
23 | 23 | # Process query |
24 | 24 | |
25 | - $query = ("SELECT " . implode(', ', $selection) .", rel.ancestor as parent_id ") . |
|
25 | + $query = ("SELECT ".implode(', ', $selection).", rel.ancestor as parent_id "). |
|
26 | 26 | |
27 | - ("FROM " . static::$table . " ent ") . |
|
27 | + ("FROM ".static::$table." ent "). |
|
28 | 28 | |
29 | - ("LEFT JOIN " . static::$table_relations . " rel ON rel.descendant = ent.id AND rel.depth = 1 ") . |
|
29 | + ("LEFT JOIN ".static::$table_relations." rel ON rel.descendant = ent.id AND rel.depth = 1 "). |
|
30 | 30 | |
31 | - ("WHERE ent." . $name . " = '" . addslashes($value) . "' LIMIT 1"); |
|
31 | + ("WHERE ent.".$name." = '".addslashes($value)."' LIMIT 1"); |
|
32 | 32 | |
33 | 33 | # ------------------------ |
34 | 34 | |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | |
134 | 134 | # Select entity from DB |
135 | 135 | |
136 | - $condition = ($name . " = '" . addslashes($value) . "' AND id != " . $this->id); |
|
136 | + $condition = ($name." = '".addslashes($value)."' AND id != ".$this->id); |
|
137 | 137 | |
138 | 138 | DB::select(static::$table, 'id', $condition, null, 1); |
139 | 139 |
@@ -27,7 +27,9 @@ discard block |
||
27 | 27 | |
28 | 28 | $selection = array_keys($this->definition->params()); |
29 | 29 | |
30 | - foreach ($selection as $key => $field) $selection[$key] = ('ent.' . $field); |
|
30 | + foreach ($selection as $key => $field) { |
|
31 | + $selection[$key] = ('ent.' . $field); |
|
32 | + } |
|
31 | 33 | |
32 | 34 | # Process query |
33 | 35 | |
@@ -87,13 +89,19 @@ discard block |
||
87 | 89 | |
88 | 90 | public function init($value, string $name = 'id') { |
89 | 91 | |
90 | - if (0 !== $this->id) return false; |
|
92 | + if (0 !== $this->id) { |
|
93 | + return false; |
|
94 | + } |
|
91 | 95 | |
92 | 96 | # Get initiation index |
93 | 97 | |
94 | - if (false === ($index = $this->definition->index($name))) return false; |
|
98 | + if (false === ($index = $this->definition->index($name))) { |
|
99 | + return false; |
|
100 | + } |
|
95 | 101 | |
96 | - if (($index->type !== 'PRIMARY') && ($index->type !== 'UNIQUE')) return false; |
|
102 | + if (($index->type !== 'PRIMARY') && ($index->type !== 'UNIQUE')) { |
|
103 | + return false; |
|
104 | + } |
|
97 | 105 | |
98 | 106 | # Process name & value |
99 | 107 | |
@@ -101,7 +109,11 @@ discard block |
||
101 | 109 | |
102 | 110 | # Select entity from DB |
103 | 111 | |
104 | - if (!static::$nesting) $this->selectDefault($name, $value); else $this->selectNesting($name, $value); |
|
112 | + if (!static::$nesting) { |
|
113 | + $this->selectDefault($name, $value); |
|
114 | + } else { |
|
115 | + $this->selectNesting($name, $value); |
|
116 | + } |
|
105 | 117 | |
106 | 118 | # ------------------------ |
107 | 119 | |
@@ -114,9 +126,13 @@ discard block |
||
114 | 126 | |
115 | 127 | # Get initiation index |
116 | 128 | |
117 | - if (false === ($index = $this->definition->index($name))) return false; |
|
129 | + if (false === ($index = $this->definition->index($name))) { |
|
130 | + return false; |
|
131 | + } |
|
118 | 132 | |
119 | - if ($index->type !== 'UNIQUE') return false; |
|
133 | + if ($index->type !== 'UNIQUE') { |
|
134 | + return false; |
|
135 | + } |
|
120 | 136 | |
121 | 137 | # Process name & value |
122 | 138 |
@@ -110,6 +110,9 @@ |
||
110 | 110 | |
111 | 111 | # Check if unique param value exists |
112 | 112 | |
113 | + /** |
|
114 | + * @param string $value |
|
115 | + */ |
|
113 | 116 | public function check($value, string $name) { |
114 | 117 | |
115 | 118 | # Get initiation index |
@@ -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::getLast()->status)) return false; |
|
85 | + if (!(DB::send($query) && DB::getLast()->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'][$dataset->id]['dataset'] = $dataset; |
92 | 98 | |
93 | - if (null !== $parent_id) $items['list'][$dataset->id]['children'] = intval($data['children']); |
|
99 | + if (null !== $parent_id) { |
|
100 | + $items['list'][$dataset->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::getLast()->status)) return false; |
|
130 | + if (!(DB::send($query) && DB::getLast()->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($parent_id, $config, $order_by, $index, $display); |
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($parent_id, $config); |
157 | 173 | } |
@@ -65,9 +65,9 @@ |
||
65 | 65 | |
66 | 66 | private function getPaginationBlock() { |
67 | 67 | |
68 | - $query = (static::$nesting ? ('?parent_id=' . $this->parent->id) : ''); |
|
68 | + $query = (static::$nesting ? ('?parent_id='.$this->parent->id) : ''); |
|
69 | 69 | |
70 | - $url = new Url(INSTALL_PATH . static::$link . $query); |
|
70 | + $url = new Url(INSTALL_PATH.static::$link.$query); |
|
71 | 71 | |
72 | 72 | # ------------------------ |
73 | 73 |
@@ -20,15 +20,15 @@ discard block |
||
20 | 20 | |
21 | 21 | # Set create button |
22 | 22 | |
23 | - if (count($this->path) < CONFIG_ENTITIZER_MAX_DEPTH) $parent->getBlock('create')->id = $this->parent->id; |
|
24 | - |
|
25 | - else { $parent->getBlock('create')->disable(); $parent->getBlock('create_disabled')->enable(); } |
|
23 | + if (count($this->path) < CONFIG_ENTITIZER_MAX_DEPTH) { |
|
24 | + $parent->getBlock('create')->id = $this->parent->id; |
|
25 | + } else { $parent->getBlock('create')->disable(); $parent->getBlock('create_disabled')->enable(); } |
|
26 | 26 | |
27 | 27 | # Set edit button |
28 | 28 | |
29 | - if (0 !== $this->parent->id) $parent->getBlock('edit')->id = $this->parent->id; |
|
30 | - |
|
31 | - else { $parent->getBlock('edit')->disable(); $parent->getBlock('edit_disabled')->enable(); } |
|
29 | + if (0 !== $this->parent->id) { |
|
30 | + $parent->getBlock('edit')->id = $this->parent->id; |
|
31 | + } else { $parent->getBlock('edit')->disable(); $parent->getBlock('edit_disabled')->enable(); } |
|
32 | 32 | |
33 | 33 | # Add parent additional data |
34 | 34 | |
@@ -41,7 +41,9 @@ discard block |
||
41 | 41 | |
42 | 42 | foreach ($this->items['list'] as $item) { |
43 | 43 | |
44 | - if ((null !== $this->entity) && ($item['dataset']->id === $this->entity->id)) continue; |
|
44 | + if ((null !== $this->entity) && ($item['dataset']->id === $this->entity->id)) { |
|
45 | + continue; |
|
46 | + } |
|
45 | 47 | |
46 | 48 | $items->addItem($view = View::get(!$ajax ? static::$view_item : static::$view_ajax_item)); |
47 | 49 | |
@@ -104,11 +106,15 @@ discard block |
||
104 | 106 | |
105 | 107 | # Set path |
106 | 108 | |
107 | - if (static::$nesting) $contents->path = $this->path; |
|
109 | + if (static::$nesting) { |
|
110 | + $contents->path = $this->path; |
|
111 | + } |
|
108 | 112 | |
109 | 113 | # Process parent block |
110 | 114 | |
111 | - if (static::$nesting && !$ajax) $this->processParent($contents->getBlock('parent')); |
|
115 | + if (static::$nesting && !$ajax) { |
|
116 | + $this->processParent($contents->getBlock('parent')); |
|
117 | + } |
|
112 | 118 | |
113 | 119 | # Process items block |
114 | 120 | |
@@ -116,7 +122,9 @@ discard block |
||
116 | 122 | |
117 | 123 | # Set pagination |
118 | 124 | |
119 | - if (!$ajax) $contents->pagination = $this->getPaginationBlock(); |
|
125 | + if (!$ajax) { |
|
126 | + $contents->pagination = $this->getPaginationBlock(); |
|
127 | + } |
|
120 | 128 | |
121 | 129 | # ------------------------ |
122 | 130 | |
@@ -141,15 +149,21 @@ discard block |
||
141 | 149 | |
142 | 150 | # Get path and depth |
143 | 151 | |
144 | - if (false !== ($path = $this->parent->path())) $this->path = $path; |
|
152 | + if (false !== ($path = $this->parent->path())) { |
|
153 | + $this->path = $path; |
|
154 | + } |
|
145 | 155 | |
146 | - if ((0 !== $this->entity->id) && (false !== ($depth = $this->entity->subtreeDepth()))) $this->depth = $depth; |
|
156 | + if ((0 !== $this->entity->id) && (false !== ($depth = $this->entity->subtreeDepth()))) { |
|
157 | + $this->depth = $depth; |
|
158 | + } |
|
147 | 159 | |
148 | 160 | # Get items list |
149 | 161 | |
150 | 162 | $lister = (static::$nesting ? 'children' : 'items'); |
151 | 163 | |
152 | - if (false !== ($items = $this->parent->$lister())) $this->items = $items; |
|
164 | + if (false !== ($items = $this->parent->$lister())) { |
|
165 | + $this->items = $items; |
|
166 | + } |
|
153 | 167 | |
154 | 168 | # ------------------------ |
155 | 169 | |
@@ -160,7 +174,9 @@ discard block |
||
160 | 174 | |
161 | 175 | protected function handle() { |
162 | 176 | |
163 | - if (Request::isAjax()) return $this->handleAjax(); |
|
177 | + if (Request::isAjax()) { |
|
178 | + return $this->handleAjax(); |
|
179 | + } |
|
164 | 180 | |
165 | 181 | $this->index = Number::forceInt(Request::get('index'), 1, 999999); |
166 | 182 | |
@@ -172,13 +188,17 @@ discard block |
||
172 | 188 | |
173 | 189 | # Get path |
174 | 190 | |
175 | - if (false !== ($path = $this->parent->path())) $this->path = $path; |
|
191 | + if (false !== ($path = $this->parent->path())) { |
|
192 | + $this->path = $path; |
|
193 | + } |
|
176 | 194 | |
177 | 195 | # Get items list |
178 | 196 | |
179 | 197 | $lister = (static::$nesting ? 'children' : 'items'); $index = $this->index; $display = static::$display; |
180 | 198 | |
181 | - if (false !== ($items = $this->parent->$lister([], [], $index, $display))) $this->items = $items; |
|
199 | + if (false !== ($items = $this->parent->$lister([], [], $index, $display))) { |
|
200 | + $this->items = $items; |
|
201 | + } |
|
182 | 202 | |
183 | 203 | # ------------------------ |
184 | 204 |
@@ -14,19 +14,19 @@ |
||
14 | 14 | |
15 | 15 | # Add params |
16 | 16 | |
17 | - $this->params->textual ('code', true, 40, true, ''); |
|
18 | - $this->params->textual ('ip', true, 255, false, ''); |
|
19 | - $this->params->integer ('time', false, 10, true, 0); |
|
17 | + $this->params->textual('code', true, 40, true, ''); |
|
18 | + $this->params->textual('ip', true, 255, false, ''); |
|
19 | + $this->params->integer('time', false, 10, true, 0); |
|
20 | 20 | |
21 | 21 | # Add indexes |
22 | 22 | |
23 | - $this->indexes->add ('code', 'UNIQUE'); |
|
24 | - $this->indexes->add ('ip'); |
|
25 | - $this->indexes->add ('time'); |
|
23 | + $this->indexes->add('code', 'UNIQUE'); |
|
24 | + $this->indexes->add('ip'); |
|
25 | + $this->indexes->add('time'); |
|
26 | 26 | |
27 | 27 | # Add foreign keys |
28 | 28 | |
29 | - $this->foreigns->add ('id', TABLE_USERS, 'id', 'CASCADE', 'RESTRICT'); |
|
29 | + $this->foreigns->add('id', TABLE_USERS, 'id', 'CASCADE', 'RESTRICT'); |
|
30 | 30 | } |
31 | 31 | } |
32 | 32 | } |
@@ -14,29 +14,29 @@ |
||
14 | 14 | |
15 | 15 | # Add params |
16 | 16 | |
17 | - $this->params->integer ('visibility', true, 1, true, VISIBILITY_DRAFT); |
|
18 | - $this->params->integer ('access', true, 1, true, ACCESS_PUBLIC); |
|
19 | - $this->params->boolean ('locked', true); |
|
20 | - $this->params->textual ('slug', true, 255, false, ''); |
|
21 | - $this->params->textual ('name', true, 255, false, ''); |
|
22 | - $this->params->textual ('title', true, 255, false, ''); |
|
23 | - $this->params->textual ('contents', false, 0, false, ''); |
|
24 | - $this->params->textual ('description', false, 0, false, ''); |
|
25 | - $this->params->textual ('keywords', false, 0, false, ''); |
|
26 | - $this->params->boolean ('robots_index', false); |
|
27 | - $this->params->boolean ('robots_follow', false); |
|
28 | - $this->params->integer ('time_created', false, 10, true, 0); |
|
29 | - $this->params->integer ('time_modified', false, 10, true, 0); |
|
17 | + $this->params->integer('visibility', true, 1, true, VISIBILITY_DRAFT); |
|
18 | + $this->params->integer('access', true, 1, true, ACCESS_PUBLIC); |
|
19 | + $this->params->boolean('locked', true); |
|
20 | + $this->params->textual('slug', true, 255, false, ''); |
|
21 | + $this->params->textual('name', true, 255, false, ''); |
|
22 | + $this->params->textual('title', true, 255, false, ''); |
|
23 | + $this->params->textual('contents', false, 0, false, ''); |
|
24 | + $this->params->textual('description', false, 0, false, ''); |
|
25 | + $this->params->textual('keywords', false, 0, false, ''); |
|
26 | + $this->params->boolean('robots_index', false); |
|
27 | + $this->params->boolean('robots_follow', false); |
|
28 | + $this->params->integer('time_created', false, 10, true, 0); |
|
29 | + $this->params->integer('time_modified', false, 10, true, 0); |
|
30 | 30 | |
31 | 31 | # Add indexes |
32 | 32 | |
33 | - $this->indexes->add ('visibility'); |
|
34 | - $this->indexes->add ('access'); |
|
35 | - $this->indexes->add ('slug'); |
|
36 | - $this->indexes->add ('name'); |
|
37 | - $this->indexes->add ('title'); |
|
38 | - $this->indexes->add ('time_created'); |
|
39 | - $this->indexes->add ('time_modified'); |
|
33 | + $this->indexes->add('visibility'); |
|
34 | + $this->indexes->add('access'); |
|
35 | + $this->indexes->add('slug'); |
|
36 | + $this->indexes->add('name'); |
|
37 | + $this->indexes->add('title'); |
|
38 | + $this->indexes->add('time_created'); |
|
39 | + $this->indexes->add('time_modified'); |
|
40 | 40 | } |
41 | 41 | } |
42 | 42 | } |
@@ -14,16 +14,16 @@ |
||
14 | 14 | |
15 | 15 | # Add params |
16 | 16 | |
17 | - $this->params->boolean ('active', false); |
|
18 | - $this->params->textual ('name', true, 255, false, ''); |
|
19 | - $this->params->textual ('title', true, 255, false, ''); |
|
20 | - $this->params->textual ('contents', false, 0, false, ''); |
|
17 | + $this->params->boolean('active', false); |
|
18 | + $this->params->textual('name', true, 255, false, ''); |
|
19 | + $this->params->textual('title', true, 255, false, ''); |
|
20 | + $this->params->textual('contents', false, 0, false, ''); |
|
21 | 21 | |
22 | 22 | # Add indexes |
23 | 23 | |
24 | - $this->indexes->add ('active'); |
|
25 | - $this->indexes->add ('name', 'UNIQUE'); |
|
26 | - $this->indexes->add ('title'); |
|
24 | + $this->indexes->add('active'); |
|
25 | + $this->indexes->add('name', 'UNIQUE'); |
|
26 | + $this->indexes->add('title'); |
|
27 | 27 | } |
28 | 28 | } |
29 | 29 | } |