@@ -20,23 +20,28 @@ discard block |
||
20 | 20 | |
21 | 21 | # Validate values |
22 | 22 | |
23 | - if (false === ($password = Validate::userPassword($password))) |
|
24 | - |
|
23 | + if (false === ($password = Validate::userPassword($password))) { |
|
24 | + |
|
25 | 25 | return ['password', 'USER_ERROR_PASSWORD_INVALID']; |
26 | + } |
|
26 | 27 | |
27 | - if (false === ($password_new = Validate::userPassword($password_new))) |
|
28 | - |
|
28 | + if (false === ($password_new = Validate::userPassword($password_new))) { |
|
29 | + |
|
29 | 30 | return ['password_new', 'USER_ERROR_PASSWORD_NEW_INVALID']; |
31 | + } |
|
30 | 32 | |
31 | - if (0 !== strcmp($password_new, $password_retype)) |
|
32 | - |
|
33 | + if (0 !== strcmp($password_new, $password_retype)) { |
|
34 | + |
|
33 | 35 | return ['password_retype', 'USER_ERROR_PASSWORD_MISMATCH']; |
36 | + } |
|
34 | 37 | |
35 | 38 | # Check password |
36 | 39 | |
37 | 40 | $password = Str::encode(Auth::user()->auth_key, $password); |
38 | 41 | |
39 | - if (0 !== strcmp(Auth::user()->password, $password)) return ['password', 'USER_ERROR_PASSWORD_INCORRECT']; |
|
42 | + if (0 !== strcmp(Auth::user()->password, $password)) { |
|
43 | + return ['password', 'USER_ERROR_PASSWORD_INCORRECT']; |
|
44 | + } |
|
40 | 45 | |
41 | 46 | # Encode password |
42 | 47 | |
@@ -49,7 +54,9 @@ discard block |
||
49 | 54 | $data['auth_key'] = $auth_key; |
50 | 55 | $data['password'] = $password; |
51 | 56 | |
52 | - if (!Auth::user()->edit($data)) return 'USER_ERROR_EDIT_PASSWORD'; |
|
57 | + if (!Auth::user()->edit($data)) { |
|
58 | + return 'USER_ERROR_EDIT_PASSWORD'; |
|
59 | + } |
|
53 | 60 | |
54 | 61 | # ------------------------ |
55 | 62 |
@@ -20,13 +20,19 @@ discard block |
||
20 | 20 | |
21 | 21 | # Validate values |
22 | 22 | |
23 | - if (false === ($email = Validate::userEmail($email))) return ['email', 'USER_ERROR_EMAIL_INVALID']; |
|
23 | + if (false === ($email = Validate::userEmail($email))) { |
|
24 | + return ['email', 'USER_ERROR_EMAIL_INVALID']; |
|
25 | + } |
|
24 | 26 | |
25 | 27 | # Check email exists |
26 | 28 | |
27 | - if (false === ($check_email = Auth::user()->check($email, 'email'))) return 'USER_ERROR_EDIT_PERSONAL'; |
|
29 | + if (false === ($check_email = Auth::user()->check($email, 'email'))) { |
|
30 | + return 'USER_ERROR_EDIT_PERSONAL'; |
|
31 | + } |
|
28 | 32 | |
29 | - if ($check_email === 1) return ['email', 'USER_ERROR_EMAIL_DUPLICATE']; |
|
33 | + if ($check_email === 1) { |
|
34 | + return ['email', 'USER_ERROR_EMAIL_DUPLICATE']; |
|
35 | + } |
|
30 | 36 | |
31 | 37 | # Update user |
32 | 38 | |
@@ -40,7 +46,9 @@ discard block |
||
40 | 46 | $data['country'] = $country; |
41 | 47 | $data['timezone'] = $timezone; |
42 | 48 | |
43 | - if (!Auth::user()->edit($data)) return 'USER_ERROR_EDIT_PERSONAL'; |
|
49 | + if (!Auth::user()->edit($data)) { |
|
50 | + return 'USER_ERROR_EDIT_PERSONAL'; |
|
51 | + } |
|
44 | 52 | |
45 | 53 | # ------------------------ |
46 | 54 |
@@ -46,9 +46,9 @@ discard block |
||
46 | 46 | |
47 | 47 | for ($id = 2; $id <= 4; $id++) $pages[] = ['id' => $id, 'visibility' => VISIBILITY_PUBLISHED, |
48 | 48 | |
49 | - 'locked' => false, 'slug' => ('page-' . ($id - 1)), 'name' => ('page-' . ($id - 1)), |
|
49 | + 'locked' => false, 'slug' => ('page-'.($id - 1)), 'name' => ('page-'.($id - 1)), |
|
50 | 50 | |
51 | - 'title' => (Language::get('INSTALL_PAGE_DEMO_TITLE') . ' ' . ($id - 1)), |
|
51 | + 'title' => (Language::get('INSTALL_PAGE_DEMO_TITLE').' '.($id - 1)), |
|
52 | 52 | |
53 | 53 | 'contents' => Template::block(Language::get('INSTALL_PAGE_DEMO_CONTENTS'))->contents(), |
54 | 54 | |
@@ -81,9 +81,9 @@ discard block |
||
81 | 81 | |
82 | 82 | for ($id = 1; $id <= 3; $id++) $menu[] = [ |
83 | 83 | |
84 | - 'id' => $id, 'active' => true, 'position' => ($id - 1), 'slug' => ('page-' . $id), |
|
84 | + 'id' => $id, 'active' => true, 'position' => ($id - 1), 'slug' => ('page-'.$id), |
|
85 | 85 | |
86 | - 'text' => (Language::get('INSTALL_PAGE_DEMO_TITLE') . ' ' . $id)]; |
|
86 | + 'text' => (Language::get('INSTALL_PAGE_DEMO_TITLE').' '.$id)]; |
|
87 | 87 | |
88 | 88 | # Process insertion |
89 | 89 |
@@ -30,7 +30,11 @@ discard block |
||
30 | 30 | |
31 | 31 | $count = Informer::countEntries(TABLE_PAGES, true); |
32 | 32 | |
33 | - if (false === $count) return false; else if ($count > 0) return true; |
|
33 | + if (false === $count) { |
|
34 | + return false; |
|
35 | + } else if ($count > 0) { |
|
36 | + return true; |
|
37 | + } |
|
34 | 38 | |
35 | 39 | # Process dataset |
36 | 40 | |
@@ -44,7 +48,8 @@ discard block |
||
44 | 48 | |
45 | 49 | 'time_created' => REQUEST_TIME, 'time_modified' => REQUEST_TIME]]; |
46 | 50 | |
47 | - for ($id = 2; $id <= 4; $id++) $pages[] = ['id' => $id, 'visibility' => VISIBILITY_PUBLISHED, |
|
51 | + for ($id = 2; $id <= 4; $id++) { |
|
52 | + $pages[] = ['id' => $id, 'visibility' => VISIBILITY_PUBLISHED, |
|
48 | 53 | |
49 | 54 | 'locked' => false, 'slug' => ('page-' . ($id - 1)), 'name' => ('page-' . ($id - 1)), |
50 | 55 | |
@@ -53,10 +58,13 @@ discard block |
||
53 | 58 | 'contents' => Template::createBlock(Language::get('INSTALL_PAGE_DEMO_CONTENTS'))->getContents(), |
54 | 59 | |
55 | 60 | 'time_created' => REQUEST_TIME, 'time_modified' => REQUEST_TIME]; |
61 | + } |
|
56 | 62 | |
57 | 63 | # Process insertion |
58 | 64 | |
59 | - if (!(DB::insert(TABLE_PAGES, $pages, true) && DB::getLast()->status)) return false; |
|
65 | + if (!(DB::insert(TABLE_PAGES, $pages, true) && DB::getLast()->status)) { |
|
66 | + return false; |
|
67 | + } |
|
60 | 68 | |
61 | 69 | self::fillRelationsTable(TABLE_PAGES_RELATIONS, 4); |
62 | 70 | |
@@ -73,21 +81,29 @@ discard block |
||
73 | 81 | |
74 | 82 | $count = Informer::countEntries(TABLE_MENU, true); |
75 | 83 | |
76 | - if (false === $count) return false; else if ($count > 0) return true; |
|
84 | + if (false === $count) { |
|
85 | + return false; |
|
86 | + } else if ($count > 0) { |
|
87 | + return true; |
|
88 | + } |
|
77 | 89 | |
78 | 90 | # Process dataset |
79 | 91 | |
80 | 92 | $menu = []; |
81 | 93 | |
82 | - for ($id = 1; $id <= 3; $id++) $menu[] = [ |
|
94 | + for ($id = 1; $id <= 3; $id++) { |
|
95 | + $menu[] = [ |
|
83 | 96 | |
84 | 97 | 'id' => $id, 'active' => true, 'position' => ($id - 1), 'slug' => ('page-' . $id), |
85 | 98 | |
86 | 99 | 'text' => (Language::get('INSTALL_PAGE_DEMO_TITLE') . ' ' . $id)]; |
100 | + } |
|
87 | 101 | |
88 | 102 | # Process insertion |
89 | 103 | |
90 | - if (!(DB::insert(TABLE_MENU, $menu, true) && DB::getLast()->status)) return false; |
|
104 | + if (!(DB::insert(TABLE_MENU, $menu, true) && DB::getLast()->status)) { |
|
105 | + return false; |
|
106 | + } |
|
91 | 107 | |
92 | 108 | self::fillRelationsTable(TABLE_MENU_RELATIONS, 3); |
93 | 109 | |
@@ -116,7 +132,9 @@ discard block |
||
116 | 132 | |
117 | 133 | $definitions[] = Entitizer::definition(TABLE_USERS_SESSIONS); |
118 | 134 | |
119 | - foreach ($definitions as $definition) if (!$definition->createTable()) return false; |
|
135 | + foreach ($definitions as $definition) { |
|
136 | + if (!$definition->createTable()) return false; |
|
137 | + } |
|
120 | 138 | |
121 | 139 | # ------------------------ |
122 | 140 |
@@ -2,7 +2,11 @@ |
||
2 | 2 | |
3 | 3 | namespace Modules\Install\Utils { |
4 | 4 | |
5 | - use Modules\Entitizer, Modules\Informer, DB, Language, Template; |
|
5 | + use Modules\Entitizer; |
|
6 | + use Modules\Informer; |
|
7 | + use DB; |
|
8 | + use Language; |
|
9 | + use Template; |
|
6 | 10 | |
7 | 11 | abstract class Tables { |
8 | 12 |
@@ -2,7 +2,9 @@ |
||
2 | 2 | |
3 | 3 | namespace Modules\Entitizer\Form { |
4 | 4 | |
5 | - use Modules\Entitizer, Utils\Form, Utils\Range; |
|
5 | + use Modules\Entitizer; |
|
6 | + use Utils\Form; |
|
7 | + use Utils\Range; |
|
6 | 8 | |
7 | 9 | class Page extends Form { |
8 | 10 |
@@ -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 | } |
@@ -19,14 +19,18 @@ |
||
19 | 19 | |
20 | 20 | $this->addHandler('link', function (array $data) { |
21 | 21 | |
22 | - if ('' === $data['slug']) return ''; |
|
22 | + if ('' === $data['slug']) { |
|
23 | + return ''; |
|
24 | + } |
|
23 | 25 | |
24 | 26 | return (INSTALL_PATH . '/' . $data['slug']); |
25 | 27 | }); |
26 | 28 | |
27 | 29 | $this->addHandler('canonical', function (array $data) { |
28 | 30 | |
29 | - if ('' === $data['slug']) return ''; |
|
31 | + if ('' === $data['slug']) { |
|
32 | + return ''; |
|
33 | + } |
|
30 | 34 | |
31 | 35 | return (Settings::get('system_url') . (($data['id'] !== 1) ? ('/' . $data['slug']) : '')); |
32 | 36 | }); |
@@ -12,23 +12,23 @@ |
||
12 | 12 | |
13 | 13 | protected function init() { |
14 | 14 | |
15 | - $this->addWorker('active', function (array $data) { |
|
15 | + $this->addWorker('active', function(array $data) { |
|
16 | 16 | |
17 | 17 | return (($data['visibility'] === VISIBILITY_PUBLISHED) && !$data['locked']); |
18 | 18 | }); |
19 | 19 | |
20 | - $this->addWorker('link', function (array $data) { |
|
20 | + $this->addWorker('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->addWorker('canonical', function (array $data) { |
|
27 | + $this->addWorker('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 | } |
@@ -14,9 +14,13 @@ |
||
14 | 14 | |
15 | 15 | $this->addHandler('link', function (array $data) { |
16 | 16 | |
17 | - if ('' === $data['slug']) return ''; |
|
17 | + if ('' === $data['slug']) { |
|
18 | + return ''; |
|
19 | + } |
|
18 | 20 | |
19 | - if (false !== Validate::url($data['slug'])) return $data['slug']; |
|
21 | + if (false !== Validate::url($data['slug'])) { |
|
22 | + return $data['slug']; |
|
23 | + } |
|
20 | 24 | |
21 | 25 | return (INSTALL_PATH . '/' . $data['slug']); |
22 | 26 | }); |
@@ -12,13 +12,13 @@ |
||
12 | 12 | |
13 | 13 | protected function init() { |
14 | 14 | |
15 | - $this->addWorker('link', function (array $data) { |
|
15 | + $this->addWorker('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 | } |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | |
33 | 33 | $selection = []; |
34 | 34 | |
35 | - foreach ($this->definition->paramsSecure() as $field) $selection[] = ('ent.' . $field); |
|
35 | + foreach ($this->definition->paramsSecure() as $field) $selection[] = ('ent.'.$field); |
|
36 | 36 | |
37 | 37 | # ------------------------ |
38 | 38 | |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | |
46 | 46 | $order_by = []; |
47 | 47 | |
48 | - foreach ($this->castOrderBy($data) as $field => $direction) $order_by[] = ('ent.' . $field . ' ' . $direction); |
|
48 | + foreach ($this->castOrderBy($data) as $field => $direction) $order_by[] = ('ent.'.$field.' '.$direction); |
|
49 | 49 | |
50 | 50 | # ------------------------ |
51 | 51 |
@@ -16,7 +16,9 @@ discard block |
||
16 | 16 | |
17 | 17 | foreach ($data as $field => $direction) { |
18 | 18 | |
19 | - if (false === ($param = $this->definition->param($field))) continue; |
|
19 | + if (false === ($param = $this->definition->param($field))) { |
|
20 | + continue; |
|
21 | + } |
|
20 | 22 | |
21 | 23 | $order_by[$param->name] = ((strtoupper($direction) !== 'DESC') ? 'ASC' : 'DESC'); |
22 | 24 | } |
@@ -32,7 +34,9 @@ discard block |
||
32 | 34 | |
33 | 35 | $selection = []; |
34 | 36 | |
35 | - foreach ($this->definition->paramsSecure() as $field) $selection[] = ('ent.' . $field); |
|
37 | + foreach ($this->definition->paramsSecure() as $field) { |
|
38 | + $selection[] = ('ent.' . $field); |
|
39 | + } |
|
36 | 40 | |
37 | 41 | # ------------------------ |
38 | 42 | |
@@ -45,7 +49,9 @@ discard block |
||
45 | 49 | |
46 | 50 | $order_by = []; |
47 | 51 | |
48 | - foreach ($this->castOrderBy($data) as $field => $direction) $order_by[] = ('ent.' . $field . ' ' . $direction); |
|
52 | + foreach ($this->castOrderBy($data) as $field => $direction) { |
|
53 | + $order_by[] = ('ent.' . $field . ' ' . $direction); |
|
54 | + } |
|
49 | 55 | |
50 | 56 | # ------------------------ |
51 | 57 |
@@ -2,7 +2,8 @@ |
||
2 | 2 | |
3 | 3 | namespace Modules\Entitizer\Utils { |
4 | 4 | |
5 | - use Modules\Entitizer, Dataset as Config; |
|
5 | + use Modules\Entitizer; |
|
6 | + use Dataset as Config; |
|
6 | 7 | |
7 | 8 | abstract class Collection { |
8 | 9 |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | |
13 | 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")) : |
|
15 | + ("ON rel.ancestor = " . $parent_id . " AND rel.descendant = ent.id AND rel.depth >= 1")) : |
|
16 | 16 | |
17 | 17 | ("JOIN " . static::$table_relations . " rel ON rel.descendant = ent.id"); |
18 | 18 | } |
@@ -23,13 +23,13 @@ discard block |
||
23 | 23 | |
24 | 24 | return ("SELECT " . $this->getSelection() . ", COALESCE(par.ancestor, 0) as parent_id ") . |
25 | 25 | |
26 | - ("FROM " . static::$table . " ent " . $this->getQueryJoin($parent_id) . " ") . |
|
26 | + ("FROM " . static::$table . " ent " . $this->getQueryJoin($parent_id) . " ") . |
|
27 | 27 | |
28 | - ("LEFT JOIN " . static::$table_relations . " par ON par.descendant = ent.id AND par.depth = 1 ") . |
|
28 | + ("LEFT JOIN " . static::$table_relations . " par ON par.descendant = ent.id AND par.depth = 1 ") . |
|
29 | 29 | |
30 | - (('' !== ($condition = $this->getCondition($config))) ? ("WHERE " . $condition . " ") : "") . |
|
30 | + (('' !== ($condition = $this->getCondition($config))) ? ("WHERE " . $condition . " ") : "") . |
|
31 | 31 | |
32 | - ("GROUP BY ent.id ORDER BY MAX(rel.depth) ASC, " . $this->getOrderBy($order_by)); |
|
32 | + ("GROUP BY ent.id ORDER BY MAX(rel.depth) ASC, " . $this->getOrderBy($order_by)); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | # Get count query |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | |
39 | 39 | return ("SELECT COUNT(DISTINCT ent.id) as count FROM " . static::$table . " ent ") . |
40 | 40 | |
41 | - $this->getQueryJoin($parent_id); |
|
41 | + $this->getQueryJoin($parent_id); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | # Get depth query |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | |
48 | 48 | $query = ("SELECT COUNT(DISTINCT rel.depth) as depth FROM " . static::$table . " ent ") . |
49 | 49 | |
50 | - $this->getQueryJoin($parent_id); |
|
50 | + $this->getQueryJoin($parent_id); |
|
51 | 51 | |
52 | 52 | # ------------------------ |
53 | 53 | |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | |
129 | 129 | $query = ("SELECT " . $this->getSelection() . " FROM " . static::$table . " ent ") . |
130 | 130 | |
131 | - ("JOIN " . static::$table_relations . " rel ON rel.ancestor = ent.id ") . |
|
131 | + ("JOIN " . static::$table_relations . " rel ON rel.ancestor = ent.id ") . |
|
132 | 132 | |
133 | 133 | ("WHERE rel.descendant = " . $parent_id . " ORDER BY rel.depth DESC"); |
134 | 134 |
@@ -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 |
@@ -58,13 +58,17 @@ discard block |
||
58 | 58 | |
59 | 59 | public function subtree(int $parent_id = 0, array $config = [], array $order_by = []) { |
60 | 60 | |
61 | - if (!(static::$nesting && ($parent_id >= 0))) return false; |
|
61 | + if (!(static::$nesting && ($parent_id >= 0))) { |
|
62 | + return false; |
|
63 | + } |
|
62 | 64 | |
63 | 65 | # Select entities |
64 | 66 | |
65 | 67 | $query = $this->getSelectQuery($parent_id, $config, $order_by); |
66 | 68 | |
67 | - if (!(DB::send($query) && DB::getLast()->status)) return false; |
|
69 | + if (!(DB::send($query) && DB::getLast()->status)) { |
|
70 | + return false; |
|
71 | + } |
|
68 | 72 | |
69 | 73 | # Process results |
70 | 74 | |
@@ -88,13 +92,17 @@ discard block |
||
88 | 92 | |
89 | 93 | public function subtreeCount(int $parent_id = 0) { |
90 | 94 | |
91 | - if (!(static::$nesting && ($parent_id >= 0))) return false; |
|
95 | + if (!(static::$nesting && ($parent_id >= 0))) { |
|
96 | + return false; |
|
97 | + } |
|
92 | 98 | |
93 | 99 | # Get count |
94 | 100 | |
95 | 101 | $query = $this->getCountQuery($parent_id); |
96 | 102 | |
97 | - if (!(DB::send($query) && DB::getLast()->status)) return false; |
|
103 | + if (!(DB::send($query) && DB::getLast()->status)) { |
|
104 | + return false; |
|
105 | + } |
|
98 | 106 | |
99 | 107 | # ------------------------ |
100 | 108 | |
@@ -105,13 +113,17 @@ discard block |
||
105 | 113 | |
106 | 114 | public function subtreeDepth(int $parent_id = 0) { |
107 | 115 | |
108 | - if (!(static::$nesting && ($parent_id >= 0))) return false; |
|
116 | + if (!(static::$nesting && ($parent_id >= 0))) { |
|
117 | + return false; |
|
118 | + } |
|
109 | 119 | |
110 | 120 | # Get depth |
111 | 121 | |
112 | 122 | $query = $this->getDepthQuery($parent_id); |
113 | 123 | |
114 | - if (!(DB::send($query) && DB::getLast()->status)) return false; |
|
124 | + if (!(DB::send($query) && DB::getLast()->status)) { |
|
125 | + return false; |
|
126 | + } |
|
115 | 127 | |
116 | 128 | # ------------------------ |
117 | 129 | |
@@ -122,7 +134,9 @@ discard block |
||
122 | 134 | |
123 | 135 | public function path(int $parent_id = 0) { |
124 | 136 | |
125 | - if (!(static::$nesting && ($parent_id >= 0))) return false; |
|
137 | + if (!(static::$nesting && ($parent_id >= 0))) { |
|
138 | + return false; |
|
139 | + } |
|
126 | 140 | |
127 | 141 | # Process query |
128 | 142 | |
@@ -134,13 +148,17 @@ discard block |
||
134 | 148 | |
135 | 149 | # Select path |
136 | 150 | |
137 | - if (!(DB::send($query) && DB::getLast()->status)) return false; |
|
151 | + if (!(DB::send($query) && DB::getLast()->status)) { |
|
152 | + return false; |
|
153 | + } |
|
138 | 154 | |
139 | 155 | # Process results |
140 | 156 | |
141 | 157 | $path = []; |
142 | 158 | |
143 | - while (null !== ($data = DB::getLast()->getRow())) $path[] = Entitizer::dataset(static::$table, $data)->data(); |
|
159 | + while (null !== ($data = DB::getLast()->getRow())) { |
|
160 | + $path[] = Entitizer::dataset(static::$table, $data)->data(); |
|
161 | + } |
|
144 | 162 | |
145 | 163 | # ------------------------ |
146 | 164 |