@@ -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,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 |
@@ -34,14 +34,18 @@ |
||
34 | 34 | |
35 | 35 | $parent->block('browse')->disable(); $parent->block('browse_disabled')->enable(); |
36 | 36 | |
37 | - } else $parent->block('browse')->link = $this->parent->link; |
|
37 | + } else { |
|
38 | + $parent->block('browse')->link = $this->parent->link; |
|
39 | + } |
|
38 | 40 | } |
39 | 41 | |
40 | 42 | # Add additional parent data for specific entity |
41 | 43 | |
42 | 44 | protected function processEntity(Template\Asset\Block $contents) { |
43 | 45 | |
44 | - if (!$this->create && $this->parent->locked) $contents->block('locked')->enable(); |
|
46 | + if (!$this->create && $this->parent->locked) { |
|
47 | + $contents->block('locked')->enable(); |
|
48 | + } |
|
45 | 49 | } |
46 | 50 | } |
47 | 51 | } |
@@ -28,7 +28,9 @@ |
||
28 | 28 | |
29 | 29 | protected function processEntity(Template\Asset\Block $contents) { |
30 | 30 | |
31 | - if ($this->create) $contents->block('info')->disable(); else { |
|
31 | + if ($this->create) { |
|
32 | + $contents->block('info')->disable(); |
|
33 | + } else { |
|
32 | 34 | |
33 | 35 | $contents->block('info')->time_registered = Date::get(DATE_FORMAT_DATETIME, $this->entity->time_registered); |
34 | 36 |