Completed
Pull Request — master (#6)
by Anton
03:55
created
www/engine/System/Classes/Modules/Entitizer/Utils/Param/Type/Textual.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@
 block discarded – undo
25 25
 
26 26
 			return ("`" . $this->name . "` " . ($this->short ? ("varchar(" . $this->maxlength . ")") : "text")) .
27 27
 
28
-			       (($this->binary ? " CHARACTER SET utf8 COLLATE utf8_bin" : "") . " NOT NULL");
28
+				   (($this->binary ? " CHARACTER SET utf8 COLLATE utf8_bin" : "") . " NOT NULL");
29 29
 		}
30 30
 
31 31
 		# Cast value
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,9 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
www/engine/System/Classes/Modules/Entitizer/Utils/Param/Type/Integer.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@
 block discarded – undo
25 25
 
26 26
 			return ("`" . $this->name . "` " . ($this->short ? "tiny" : "") . "int(" . $this->maxlength . ") ") .
27 27
 
28
-			       ("unsigned NOT NULL DEFAULT '" . $this->default . "'");
28
+				   ("unsigned NOT NULL DEFAULT '" . $this->default . "'");
29 29
 		}
30 30
 
31 31
 		# Cast value
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,9 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
www/engine/System/Classes/Modules/Entitizer/Utils/Param/Param.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@
 block discarded – undo
40 40
 
41 41
 			return ($this->index ? (($this->unique ? ($this->primary ? "PRIMARY " : "UNIQUE ") : "") .
42 42
 
43
-			       ("KEY `" . $this->name . "` (`" . $this->name . "`)")) : false);
43
+				   ("KEY `" . $this->name . "` (`" . $this->name . "`)")) : false);
44 44
 		}
45 45
 	}
46 46
 }
Please login to merge, or discard this patch.
www/engine/System/Classes/Modules/Entitizer/Utils/Definition.php 1 patch
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -12,7 +12,9 @@  discard block
 block discarded – undo
12 12
 
13 13
 		private function addParam(Param $param) {
14 14
 
15
-			if (('' === $param->name()) || isset($this->params[$param->name()])) return;
15
+			if (('' === $param->name()) || isset($this->params[$param->name()])) {
16
+				return;
17
+			}
16 18
 
17 19
 			$this->params[$param->name()] = $param;
18 20
 		}
@@ -26,7 +28,9 @@  discard block
 block discarded – undo
26 28
 
27 29
 			foreach ($this->params as $param) {
28 30
 
29
-				if (false !== ($statement = $param->$method())) $statements[] = $statement;
31
+				if (false !== ($statement = $param->$method())) {
32
+					$statements[] = $statement;
33
+				}
30 34
 			}
31 35
 
32 36
 			# ------------------------
@@ -63,7 +67,9 @@  discard block
 block discarded – undo
63 67
 
64 68
 		protected function addOrderer(string $name, bool $descending = false) {
65 69
 
66
-			if (!isset($this->params[$name]) || isset($this->orderers[$name])) return;
70
+			if (!isset($this->params[$name]) || isset($this->orderers[$name])) {
71
+				return;
72
+			}
67 73
 
68 74
 			$this->orderers[$name] = $descending;
69 75
 		}
@@ -128,10 +134,12 @@  discard block
 block discarded – undo
128 134
 
129 135
 			$params = [];
130 136
 
131
-			foreach ($data as $name => $value) if (isset($this->params[$name])) {
137
+			foreach ($data as $name => $value) {
138
+				if (isset($this->params[$name])) {
132 139
 
133 140
 				$params[$name] = $this->params[$name]->cast($value);
134 141
 			}
142
+			}
135 143
 
136 144
 			# ------------------------
137 145
 
Please login to merge, or discard this patch.
www/engine/System/Classes/Modules/Entitizer/Utils/Lister.php 2 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -36,17 +36,17 @@
 block discarded – undo
36 36
 
37 37
 			$query = ("SELECT SQL_CALC_FOUND_ROWS ent.id, " . implode(', ', $selection)) .
38 38
 
39
-			         (static::$nesting ? ", COUNT(chd.id) as children " : " ") .
39
+					 (static::$nesting ? ", COUNT(chd.id) as children " : " ") .
40 40
 
41
-			         ("FROM " . static::$table . " ent ") .
41
+					 ("FROM " . static::$table . " ent ") .
42 42
 
43
-			         (static::$nesting ? ("LEFT JOIN " . static::$table . " chd ON chd.parent_id = ent.id ") : "") .
43
+					 (static::$nesting ? ("LEFT JOIN " . static::$table . " chd ON chd.parent_id = ent.id ") : "") .
44 44
 
45
-			         ("WHERE ent.id != " . $disable_id . " ") .
45
+					 ("WHERE ent.id != " . $disable_id . " ") .
46 46
 
47
-			         (static::$nesting ? ("AND ent.parent_id = " . $parent_id . " GROUP BY ent.id ") : "") .
47
+					 (static::$nesting ? ("AND ent.parent_id = " . $parent_id . " GROUP BY ent.id ") : "") .
48 48
 
49
-			         ("ORDER BY " . implode(', ', $order_by) . ", ent.id ASC" . ($limit ? (" LIMIT " . $limit) : ""));
49
+					 ("ORDER BY " . implode(', ', $order_by) . ", ent.id ASC" . ($limit ? (" LIMIT " . $limit) : ""));
50 50
 
51 51
 			# ------------------------
52 52
 
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -66,13 +66,17 @@
 block discarded – undo
66 66
 
67 67
 			$items = ['list' => [], 'total' => 0];
68 68
 
69
-			if (!(($index >= 0) && ($display >= 0) && ($parent_id >= 0) && ($disable_id >= 0))) return $items;
69
+			if (!(($index >= 0) && ($display >= 0) && ($parent_id >= 0) && ($disable_id >= 0))) {
70
+				return $items;
71
+			}
70 72
 
71 73
 			# Select entities
72 74
 
73 75
 			$query = $this->getQuery($index, $display, $parent_id, $disable_id);
74 76
 
75
-			if (!(DB::send($query) && DB::last()->status)) return $items;
77
+			if (!(DB::send($query) && DB::last()->status)) {
78
+				return $items;
79
+			}
76 80
 
77 81
 			# Process results
78 82
 
Please login to merge, or discard this patch.
www/engine/System/Classes/Modules/Entitizer/Utils/Handler.php 2 patches
Braces   +37 added lines, -15 removed lines patch added patch discarded remove patch
@@ -24,7 +24,9 @@  discard block
 block discarded – undo
24 24
 
25 25
 			# Set edit button
26 26
 
27
-			if (0 === $this->parent->id) $parent->block('edit')->disable(); else {
27
+			if (0 === $this->parent->id) {
28
+				$parent->block('edit')->disable();
29
+			} else {
28 30
 
29 31
 				$parent->block('edit')->class = (!$this->create ? 'active item' : 'item');
30 32
 
@@ -36,7 +38,9 @@  discard block
 block discarded – undo
36 38
 
37 39
 		private function processSelector(Template\Asset\Block $selector) {
38 40
 
39
-			if ($this->create) return $selector->disable();
41
+			if ($this->create) {
42
+				return $selector->disable();
43
+			}
40 44
 
41 45
 			$parent = Entitizer::get(static::$type, $this->entity->parent_id);
42 46
 
@@ -55,25 +59,33 @@  discard block
 block discarded – undo
55 59
 
56 60
 			# Set path / title
57 61
 
58
-			if (static::$nesting) $contents->path = $this->parent->path;
59
-
60
-			else $contents->title = ($this->create ? Language::get(static::$naming_new) : $this->entity->__get(static::$naming));
62
+			if (static::$nesting) {
63
+				$contents->path = $this->parent->path;
64
+			} else {
65
+				$contents->title = ($this->create ? Language::get(static::$naming_new) : $this->entity->__get(static::$naming));
66
+			}
61 67
 
62 68
 			# Set link
63 69
 
64 70
 			$link = (INSTALL_PATH . static::$link . '/');
65 71
 
66
-			if (static::$nesting) $contents->link = ($link . ($this->create ? 'create' : 'edit') . '?id=' . $this->parent->id);
67
-
68
-			else $contents->link = ($link . ($this->create ? 'create' : ('edit?id=' . $this->entity->id)));
72
+			if (static::$nesting) {
73
+				$contents->link = ($link . ($this->create ? 'create' : 'edit') . '?id=' . $this->parent->id);
74
+			} else {
75
+				$contents->link = ($link . ($this->create ? 'create' : ('edit?id=' . $this->entity->id)));
76
+			}
69 77
 
70 78
 			# Process parent block
71 79
 
72
-			if (static::$nesting) $this->processParent($contents->block('parent'));
80
+			if (static::$nesting) {
81
+				$this->processParent($contents->block('parent'));
82
+			}
73 83
 
74 84
 			# Process selector block
75 85
 
76
-			if (static::$nesting) $this->processSelector($contents->block('selector'));
86
+			if (static::$nesting) {
87
+				$this->processSelector($contents->block('selector'));
88
+			}
77 89
 
78 90
 			# Implement form
79 91
 
@@ -102,7 +114,9 @@  discard block
 block discarded – undo
102 114
 
103 115
 			if (Request::post('action') === 'remove') {
104 116
 
105
-				if (!$this->entity->remove()) return $ajax->error(Language::get(static::$message_error_remove));
117
+				if (!$this->entity->remove()) {
118
+					return $ajax->error(Language::get(static::$message_error_remove));
119
+				}
106 120
 			}
107 121
 
108 122
 			# ------------------------
@@ -114,23 +128,31 @@  discard block
 block discarded – undo
114 128
 
115 129
 		public function handle(bool $create = false) {
116 130
 
117
-			if (!($this->create = $create) && Request::isAjax()) return $this->handleAjax();
131
+			if (!($this->create = $create) && Request::isAjax()) {
132
+				return $this->handleAjax();
133
+			}
118 134
 
119 135
 			# Create entity
120 136
 
121
-			if (static::$nesting) $this->parent = Entitizer::get(static::$type, Number::format(Request::get('id')));
137
+			if (static::$nesting) {
138
+				$this->parent = Entitizer::get(static::$type, Number::format(Request::get('id')));
139
+			}
122 140
 
123 141
 			$this->entity = Entitizer::get(static::$type, (!$this->create ? Number::format(Request::get('id')) : 0));
124 142
 
125 143
 			# Redirect if entity not found
126 144
 
127
-			if (!$this->create && (0 === $this->entity->id)) return Request::redirect(INSTALL_PATH . static::$link);
145
+			if (!$this->create && (0 === $this->entity->id)) {
146
+				return Request::redirect(INSTALL_PATH . static::$link);
147
+			}
128 148
 
129 149
 			# Create form
130 150
 
131 151
 			$this->form = new static::$form_class($this->entity);
132 152
 
133
-			if (static::$nesting && $this->create) $this->form->get('parent_id')->set($this->parent->id);
153
+			if (static::$nesting && $this->create) {
154
+				$this->form->get('parent_id')->set($this->parent->id);
155
+			}
134 156
 
135 157
 			# Handle form
136 158
 
Please login to merge, or discard this patch.
Unused Use Statements   +8 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,7 +2,14 @@
 block discarded – undo
2 2
 
3 3
 namespace Modules\Entitizer\Utils {
4 4
 
5
-	use Modules\Entitizer, Utils\Messages, Utils\View, Ajax, Language, Number, Request, Template;
5
+	use Modules\Entitizer;
6
+	use Utils\Messages;
7
+	use Utils\View;
8
+	use Ajax;
9
+	use Language;
10
+	use Number;
11
+	use Request;
12
+	use Template;
6 13
 
7 14
 	abstract class Handler {
8 15
 
Please login to merge, or discard this patch.
www/engine/System/Classes/Modules/Entitizer/Utils/Entity/Entity.php 2 patches
Braces   +24 added lines, -8 removed lines patch added patch discarded remove patch
@@ -20,7 +20,9 @@  discard block
 block discarded – undo
20 20
 
21 21
 				$entity = self::get(static::$type, $entity->data['parent_id']);
22 22
 
23
-				if (0 === $entity->id) return [];
23
+				if (0 === $entity->id) {
24
+					return [];
25
+				}
24 26
 
25 27
 				$path[] = array_merge(['id' => $entity->id], $entity->data);
26 28
 			}
@@ -43,7 +45,9 @@  discard block
 block discarded – undo
43 45
 
44 46
 			foreach ($this->definition->params() as $name => $param) {
45 47
 
46
-				if (isset($data[$name])) $set[$name] = $param->cast($data[$name]);
48
+				if (isset($data[$name])) {
49
+					$set[$name] = $param->cast($data[$name]);
50
+				}
47 51
 			}
48 52
 
49 53
 			# ------------------------
@@ -61,11 +65,15 @@  discard block
 block discarded – undo
61 65
 
62 66
 			# Preset data array
63 67
 
64
-			foreach ($this->definition->params() as $name => $param) $this->data[$name] = $param->cast(null);
68
+			foreach ($this->definition->params() as $name => $param) {
69
+				$this->data[$name] = $param->cast(null);
70
+			}
65 71
 
66 72
 			# Preset path
67 73
 
68
-			if (static::$nesting) $this->data['path'] = [];
74
+			if (static::$nesting) {
75
+				$this->data['path'] = [];
76
+			}
69 77
 
70 78
 			# Implement entity
71 79
 
@@ -73,14 +81,18 @@  discard block
 block discarded – undo
73 81
 
74 82
 			# Init entity
75 83
 
76
-			if ($id > 0) $this->init($id);
84
+			if ($id > 0) {
85
+				$this->init($id);
86
+			}
77 87
 		}
78 88
 
79 89
 		# Check if unique param value exists
80 90
 
81 91
 		public function check(string $name, $value) {
82 92
 
83
-			if ((false === ($param = $this->definition->get($name))) || !$param->unique()) return false;
93
+			if ((false === ($param = $this->definition->get($name))) || !$param->unique()) {
94
+				return false;
95
+			}
84 96
 
85 97
 			# Select entity from DB
86 98
 
@@ -101,7 +113,9 @@  discard block
 block discarded – undo
101 113
 
102 114
 			DB::select(static::$table, 'COUNT(id) as count', ['parent_id' => $this->id]);
103 115
 
104
-			if (!(DB::last() && DB::last()->status)) return false;
116
+			if (!(DB::last() && DB::last()->status)) {
117
+				return false;
118
+			}
105 119
 
106 120
 			# ------------------------
107 121
 
@@ -133,7 +147,9 @@  discard block
 block discarded – undo
133 147
 
134 148
 		public function __get(string $name) {
135 149
 
136
-			if ($name === 'id') return $this->id;
150
+			if ($name === 'id') {
151
+				return $this->id;
152
+			}
137 153
 
138 154
 			return (isset($this->data[$name]) ? $this->data[$name] : null);
139 155
 		}
Please login to merge, or discard this patch.
Unused Use Statements   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,7 +2,8 @@
 block discarded – undo
2 2
 
3 3
 namespace Modules\Entitizer\Utils {
4 4
 
5
-	use Modules\Entitizer, DB;
5
+	use Modules\Entitizer;
6
+	use DB;
6 7
 
7 8
 	abstract class Entity extends Entitizer {
8 9
 
Please login to merge, or discard this patch.
www/engine/System/Classes/Modules/Entitizer/Utils/Entity/Action/Create.php 1 patch
Braces   +15 added lines, -5 removed lines patch added patch discarded remove patch
@@ -12,25 +12,35 @@
 block discarded – undo
12 12
 
13 13
 		public function create(array $data) {
14 14
 
15
-			if (0 !== $this->id) return false;
15
+			if (0 !== $this->id) {
16
+				return false;
17
+			}
16 18
 
17 19
 			$set = $this->getDataset($data, true);
18 20
 
19
-			if (isset($set['id']) && !($set['id'] > 0)) return false;
21
+			if (isset($set['id']) && !($set['id'] > 0)) {
22
+				return false;
23
+			}
20 24
 
21 25
 			# Insert entity
22 26
 
23 27
 			DB::insert(static::$table, $set);
24 28
 
25
-			if (!(DB::last() && DB::last()->status)) return false;
29
+			if (!(DB::last() && DB::last()->status)) {
30
+				return false;
31
+			}
26 32
 
27 33
 			# Re-init entity
28 34
 
29 35
 			$this->error = false; $this->id = DB::last()->id;
30 36
 
31
-			foreach ($set as $name => $value) if ($name !== 'id') $this->data[$name] = $value;
37
+			foreach ($set as $name => $value) {
38
+				if ($name !== 'id') $this->data[$name] = $value;
39
+			}
32 40
 
33
-			if (static::$nesting) $this->data['path'] = $this->getPath();
41
+			if (static::$nesting) {
42
+				$this->data['path'] = $this->getPath();
43
+			}
34 44
 
35 45
 			# Implement entity
36 46
 
Please login to merge, or discard this patch.
www/engine/System/Classes/Modules/Entitizer/Utils/Entity/Action/Remove.php 1 patch
Braces   +24 added lines, -8 removed lines patch added patch discarded remove patch
@@ -12,13 +12,19 @@  discard block
 block discarded – undo
12 12
 
13 13
 		public function remove() {
14 14
 
15
-			if (0 === $this->id) return false;
15
+			if (0 === $this->id) {
16
+				return false;
17
+			}
16 18
 
17 19
 			# Check if entity is removable
18 20
 
19
-			if (static::$super && ($this->id === 1)) return false;
21
+			if (static::$super && ($this->id === 1)) {
22
+				return false;
23
+			}
20 24
 
21
-			if (static::$nesting && (0 !== $this->children())) return false;
25
+			if (static::$nesting && (0 !== $this->children())) {
26
+				return false;
27
+			}
22 28
 
23 29
 			# Remove extension entries
24 30
 
@@ -26,18 +32,24 @@  discard block
 block discarded – undo
26 32
 
27 33
 				$entity = self::get($extension, $this->id);
28 34
 
29
-				if ($entity->error() || ((0 !== $entity->id) && !$entity->remove())) return false;
35
+				if ($entity->error() || ((0 !== $entity->id) && !$entity->remove())) {
36
+					return false;
37
+				}
30 38
 			}
31 39
 
32 40
 			# Remove entity
33 41
 
34 42
 			DB::delete(static::$table, ['id' => $this->id]);
35 43
 
36
-			if (!(DB::last() && DB::last()->status)) return false;
44
+			if (!(DB::last() && DB::last()->status)) {
45
+				return false;
46
+			}
37 47
 
38 48
 			# Uncache entity
39 49
 
40
-			if (self::$cache[static::$type][$this->id] === $this) unset(self::$cache[static::$type][$this->id]);
50
+			if (self::$cache[static::$type][$this->id] === $this) {
51
+				unset(self::$cache[static::$type][$this->id]);
52
+			}
41 53
 
42 54
 			# Reset id
43 55
 
@@ -45,11 +57,15 @@  discard block
 block discarded – undo
45 57
 
46 58
 			# Reset data array
47 59
 
48
-			foreach ($this->definition->params() as $name => $param) $this->data[$name] = $param->cast(null);
60
+			foreach ($this->definition->params() as $name => $param) {
61
+				$this->data[$name] = $param->cast(null);
62
+			}
49 63
 
50 64
 			# Reset path
51 65
 
52
-			if (static::$nesting) $this->data['path'] = [];
66
+			if (static::$nesting) {
67
+				$this->data['path'] = [];
68
+			}
53 69
 
54 70
 			# Implement entity
55 71
 
Please login to merge, or discard this patch.