@@ -14,27 +14,27 @@ |
||
14 | 14 | |
15 | 15 | # Add params |
16 | 16 | |
17 | - $this->params->integer ('rank', true, 1, true, RANK_GUEST); |
|
18 | - $this->params->textual ('name', true, 16, false, ''); |
|
19 | - $this->params->textual ('email', true, 128, false, ''); |
|
20 | - $this->params->textual ('auth_key', true, 40, true, ''); |
|
21 | - $this->params->textual ('password', true, 40, true, ''); |
|
22 | - $this->params->textual ('first_name', true, 255, false, ''); |
|
23 | - $this->params->textual ('last_name', true, 255, false, ''); |
|
24 | - $this->params->integer ('sex', true, 1, true, SEX_NOT_SELECTED); |
|
25 | - $this->params->textual ('city', true, 255, false, ''); |
|
26 | - $this->params->textual ('country', true, 2, false, ''); |
|
27 | - $this->params->textual ('timezone', true, 40, false, ''); |
|
28 | - $this->params->integer ('time_registered', false, 10, true, 0); |
|
29 | - $this->params->integer ('time_logged', false, 10, true, 0); |
|
17 | + $this->params->integer('rank', true, 1, true, RANK_GUEST); |
|
18 | + $this->params->textual('name', true, 16, false, ''); |
|
19 | + $this->params->textual('email', true, 128, false, ''); |
|
20 | + $this->params->textual('auth_key', true, 40, true, ''); |
|
21 | + $this->params->textual('password', true, 40, true, ''); |
|
22 | + $this->params->textual('first_name', true, 255, false, ''); |
|
23 | + $this->params->textual('last_name', true, 255, false, ''); |
|
24 | + $this->params->integer('sex', true, 1, true, SEX_NOT_SELECTED); |
|
25 | + $this->params->textual('city', true, 255, false, ''); |
|
26 | + $this->params->textual('country', true, 2, false, ''); |
|
27 | + $this->params->textual('timezone', true, 40, false, ''); |
|
28 | + $this->params->integer('time_registered', false, 10, true, 0); |
|
29 | + $this->params->integer('time_logged', false, 10, true, 0); |
|
30 | 30 | |
31 | 31 | # Add indexes |
32 | 32 | |
33 | - $this->indexes->add ('rank'); |
|
34 | - $this->indexes->add ('name', 'UNIQUE'); |
|
35 | - $this->indexes->add ('email', 'UNIQUE'); |
|
36 | - $this->indexes->add ('time_registered'); |
|
37 | - $this->indexes->add ('time_logged'); |
|
33 | + $this->indexes->add('rank'); |
|
34 | + $this->indexes->add('name', 'UNIQUE'); |
|
35 | + $this->indexes->add('email', 'UNIQUE'); |
|
36 | + $this->indexes->add('time_registered'); |
|
37 | + $this->indexes->add('time_logged'); |
|
38 | 38 | } |
39 | 39 | } |
40 | 40 | } |
@@ -25,9 +25,13 @@ discard block |
||
25 | 25 | |
26 | 26 | public static function get(string $table, int $id = 0) { |
27 | 27 | |
28 | - if (!isset(self::$classes[$table])) throw new Exception\General(self::$error_message); |
|
28 | + if (!isset(self::$classes[$table])) { |
|
29 | + throw new Exception\General(self::$error_message); |
|
30 | + } |
|
29 | 31 | |
30 | - if (isset(self::$cache[$table][$id])) return self::$cache[$table][$id]; |
|
32 | + if (isset(self::$cache[$table][$id])) { |
|
33 | + return self::$cache[$table][$id]; |
|
34 | + } |
|
31 | 35 | |
32 | 36 | $entity = new self::$classes[$table]; $entity->init($id); |
33 | 37 | |
@@ -40,7 +44,9 @@ discard block |
||
40 | 44 | |
41 | 45 | public static function create(string $table, array $data = []) { |
42 | 46 | |
43 | - if (!isset(self::$classes[$table])) throw new Exception\General(self::$error_message); |
|
47 | + if (!isset(self::$classes[$table])) { |
|
48 | + throw new Exception\General(self::$error_message); |
|
49 | + } |
|
44 | 50 | |
45 | 51 | $entity = new self::$classes[$table]($data); |
46 | 52 |
@@ -12,44 +12,44 @@ |
||
12 | 12 | |
13 | 13 | protected function init() { |
14 | 14 | |
15 | - $this->config->add('active', false, function (bool $active) { |
|
15 | + $this->config->add('active', false, function(bool $active) { |
|
16 | 16 | |
17 | - return ($active ? ("ent.visibility = " . VISIBILITY_PUBLISHED . " AND ent.locked = 0") : ''); |
|
17 | + return ($active ? ("ent.visibility = ".VISIBILITY_PUBLISHED." AND ent.locked = 0") : ''); |
|
18 | 18 | }); |
19 | 19 | |
20 | - $this->config->add('rank', null, function (int $rank = null) { |
|
20 | + $this->config->add('rank', null, function(int $rank = null) { |
|
21 | 21 | |
22 | - return ((null !== $rank) ? ("ent.access <= " . $rank) : ''); |
|
22 | + return ((null !== $rank) ? ("ent.access <= ".$rank) : ''); |
|
23 | 23 | }); |
24 | 24 | |
25 | - $this->config->add('slug', '', function (string $slug) { |
|
25 | + $this->config->add('slug', '', function(string $slug) { |
|
26 | 26 | |
27 | - return (('' !== $slug) ? ("ent.slug = '" . addslashes($slug) . "'") : ''); |
|
27 | + return (('' !== $slug) ? ("ent.slug = '".addslashes($slug)."'") : ''); |
|
28 | 28 | }); |
29 | 29 | |
30 | - $this->config->add('name', '', function (string $name) { |
|
30 | + $this->config->add('name', '', function(string $name) { |
|
31 | 31 | |
32 | - return (('' !== $name) ? ("ent.name = '" . addslashes($name) . "'") : ''); |
|
32 | + return (('' !== $name) ? ("ent.name = '".addslashes($name)."'") : ''); |
|
33 | 33 | }); |
34 | 34 | |
35 | - $this->config->add('time_created >=', 0, function (int $time) { |
|
35 | + $this->config->add('time_created >=', 0, function(int $time) { |
|
36 | 36 | |
37 | - return ((0 < $time) ? ("ent.time_created >= " . $time) : ''); |
|
37 | + return ((0 < $time) ? ("ent.time_created >= ".$time) : ''); |
|
38 | 38 | }); |
39 | 39 | |
40 | - $this->config->add('time_created <=', 0, function (int $time) { |
|
40 | + $this->config->add('time_created <=', 0, function(int $time) { |
|
41 | 41 | |
42 | - return ((0 < $time) ? ("ent.time_created <= " . $time) : ''); |
|
42 | + return ((0 < $time) ? ("ent.time_created <= ".$time) : ''); |
|
43 | 43 | }); |
44 | 44 | |
45 | - $this->config->add('time_modified >=', 0, function (int $time) { |
|
45 | + $this->config->add('time_modified >=', 0, function(int $time) { |
|
46 | 46 | |
47 | - return ((0 < $time) ? ("ent.time_modified >= " . $time) : ''); |
|
47 | + return ((0 < $time) ? ("ent.time_modified >= ".$time) : ''); |
|
48 | 48 | }); |
49 | 49 | |
50 | - $this->config->add('time_modified <=', 0, function (int $time) { |
|
50 | + $this->config->add('time_modified <=', 0, function(int $time) { |
|
51 | 51 | |
52 | - return ((0 < $time) ? ("ent.time_modified <= " . $time) : ''); |
|
52 | + return ((0 < $time) ? ("ent.time_modified <= ".$time) : ''); |
|
53 | 53 | }); |
54 | 54 | } |
55 | 55 | } |
@@ -12,7 +12,7 @@ |
||
12 | 12 | |
13 | 13 | protected function init() { |
14 | 14 | |
15 | - $this->config->add('active', false, function (bool $active) { |
|
15 | + $this->config->add('active', false, function(bool $active) { |
|
16 | 16 | |
17 | 17 | return ($active ? "ent.active = 1" : ''); |
18 | 18 | }); |
@@ -12,29 +12,29 @@ |
||
12 | 12 | |
13 | 13 | protected function init() { |
14 | 14 | |
15 | - $this->config->add('rank', null, function (int $rank = null) { |
|
15 | + $this->config->add('rank', null, function(int $rank = null) { |
|
16 | 16 | |
17 | - return ((null !== $rank) ? ("ent.rank >= " . $rank) : ''); |
|
17 | + return ((null !== $rank) ? ("ent.rank >= ".$rank) : ''); |
|
18 | 18 | }); |
19 | 19 | |
20 | - $this->config->add('time_registered >=', 0, function (int $time) { |
|
20 | + $this->config->add('time_registered >=', 0, function(int $time) { |
|
21 | 21 | |
22 | - return ((0 < $time) ? ("ent.time_registered >= " . $time) : ''); |
|
22 | + return ((0 < $time) ? ("ent.time_registered >= ".$time) : ''); |
|
23 | 23 | }); |
24 | 24 | |
25 | - $this->config->add('time_registered <=', 0, function (int $time) { |
|
25 | + $this->config->add('time_registered <=', 0, function(int $time) { |
|
26 | 26 | |
27 | - return ((0 < $time) ? ("ent.time_registered <= " . $time) : ''); |
|
27 | + return ((0 < $time) ? ("ent.time_registered <= ".$time) : ''); |
|
28 | 28 | }); |
29 | 29 | |
30 | - $this->config->add('time_logged >=', 0, function (int $time) { |
|
30 | + $this->config->add('time_logged >=', 0, function(int $time) { |
|
31 | 31 | |
32 | - return ((0 < $time) ? ("ent.time_logged >= " . $time) : ''); |
|
32 | + return ((0 < $time) ? ("ent.time_logged >= ".$time) : ''); |
|
33 | 33 | }); |
34 | 34 | |
35 | - $this->config->add('time_logged <=', 0, function (int $time) { |
|
35 | + $this->config->add('time_logged <=', 0, function(int $time) { |
|
36 | 36 | |
37 | - return ((0 < $time) ? ("ent.time_logged <= " . $time) : ''); |
|
37 | + return ((0 < $time) ? ("ent.time_logged <= ".$time) : ''); |
|
38 | 38 | }); |
39 | 39 | } |
40 | 40 | } |
@@ -12,7 +12,7 @@ |
||
12 | 12 | |
13 | 13 | protected function init() { |
14 | 14 | |
15 | - $this->config->add('active', false, function (bool $active) { |
|
15 | + $this->config->add('active', false, function(bool $active) { |
|
16 | 16 | |
17 | 17 | return ($active ? "ent.active = 1" : ''); |
18 | 18 | }); |
@@ -44,11 +44,15 @@ |
||
44 | 44 | $data['contents'] = $contents; |
45 | 45 | $data['time_modified'] = REQUEST_TIME; |
46 | 46 | |
47 | - if (0 === $this->page->id) $data['time_created'] = REQUEST_TIME; |
|
47 | + if (0 === $this->page->id) { |
|
48 | + $data['time_created'] = REQUEST_TIME; |
|
49 | + } |
|
48 | 50 | |
49 | 51 | $modifier = ((0 === $this->page->id) ? 'create' : 'edit'); |
50 | 52 | |
51 | - if (!$this->page->$modifier($data)) return 'PAGE_ERROR_MODIFY'; |
|
53 | + if (!$this->page->$modifier($data)) { |
|
54 | + return 'PAGE_ERROR_MODIFY'; |
|
55 | + } |
|
52 | 56 | |
53 | 57 | # ------------------------ |
54 | 58 |
@@ -29,9 +29,13 @@ discard block |
||
29 | 29 | |
30 | 30 | # Check name exists |
31 | 31 | |
32 | - if (false === ($check_name = $this->widget->check($name, 'name'))) return 'WIDGET_ERROR_MODIFY'; |
|
32 | + if (false === ($check_name = $this->widget->check($name, 'name'))) { |
|
33 | + return 'WIDGET_ERROR_MODIFY'; |
|
34 | + } |
|
33 | 35 | |
34 | - if ($check_name === 1) return ['name', 'WIDGET_ERROR_NAME_DUPLICATE']; |
|
36 | + if ($check_name === 1) { |
|
37 | + return ['name', 'WIDGET_ERROR_NAME_DUPLICATE']; |
|
38 | + } |
|
35 | 39 | |
36 | 40 | # Modify widget |
37 | 41 | |
@@ -44,7 +48,9 @@ discard block |
||
44 | 48 | |
45 | 49 | $modifier = ((0 === $this->widget->id) ? 'create' : 'edit'); |
46 | 50 | |
47 | - if (!$this->widget->$modifier($data)) return 'WIDGET_ERROR_MODIFY'; |
|
51 | + if (!$this->widget->$modifier($data)) { |
|
52 | + return 'WIDGET_ERROR_MODIFY'; |
|
53 | + } |
|
48 | 54 | |
49 | 55 | # ------------------------ |
50 | 56 |
@@ -29,9 +29,13 @@ discard block |
||
29 | 29 | |
30 | 30 | # Check name exists |
31 | 31 | |
32 | - if (false === ($check_name = $this->variable->check($name, 'name'))) return 'VARIABLE_ERROR_MODIFY'; |
|
32 | + if (false === ($check_name = $this->variable->check($name, 'name'))) { |
|
33 | + return 'VARIABLE_ERROR_MODIFY'; |
|
34 | + } |
|
33 | 35 | |
34 | - if ($check_name === 1) return ['name', 'VARIABLE_ERROR_NAME_DUPLICATE']; |
|
36 | + if ($check_name === 1) { |
|
37 | + return ['name', 'VARIABLE_ERROR_NAME_DUPLICATE']; |
|
38 | + } |
|
35 | 39 | |
36 | 40 | # Modify variable |
37 | 41 | |
@@ -43,7 +47,9 @@ discard block |
||
43 | 47 | |
44 | 48 | $modifier = ((0 === $this->variable->id) ? 'create' : 'edit'); |
45 | 49 | |
46 | - if (!$this->variable->$modifier($data)) return 'VARIABLE_ERROR_MODIFY'; |
|
50 | + if (!$this->variable->$modifier($data)) { |
|
51 | + return 'VARIABLE_ERROR_MODIFY'; |
|
52 | + } |
|
47 | 53 | |
48 | 54 | # ------------------------ |
49 | 55 |