@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | $parent = $this->stickyGet('parent'); |
40 | 40 | |
41 | 41 | if (isset($parent)) { |
42 | - $this->memorize('parent', $parent?: null); |
|
42 | + $this->memorize('parent', $parent ?: null); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | $this->ancestors = Models\CommonData::ancestorsAndSelf($this->recall('parent')); |
@@ -82,13 +82,13 @@ discard block |
||
82 | 82 | [$this->grid->jsRow()->data('id')] |
83 | 83 | )); |
84 | 84 | |
85 | - $this->grid->addDragHandler()->onReorder(function ($order) { |
|
85 | + $this->grid->addDragHandler()->onReorder(function($order) { |
|
86 | 86 | $result = true; |
87 | 87 | foreach ($this->nodes() as $node) { |
88 | 88 | $result &= $node->save(['position' => array_search($node->id, $order)]); |
89 | 89 | } |
90 | 90 | |
91 | - $notifier = $result? $this->notifySuccess(__('Items reordered!')): $this->notifyError(__('Error saving order!')); |
|
91 | + $notifier = $result ? $this->notifySuccess(__('Items reordered!')) : $this->notifyError(__('Error saving order!')); |
|
92 | 92 | |
93 | 93 | return $this->grid->jsSave($notifier); |
94 | 94 | }); |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | public static function getId($path, $clearCache = false) |
48 | 48 | { |
49 | 49 | $id = null; |
50 | - foreach(explode('/', trim($path,'/')) as $nodeKey) { |
|
50 | + foreach (explode('/', trim($path, '/')) as $nodeKey) { |
|
51 | 51 | $parentId = $id; |
52 | 52 | |
53 | 53 | if ($nodeKey === '') continue; //ignore empty paths |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | if ($clearCache || empty(self::$cache['id'][$parentId][$nodeKey])) { |
56 | 56 | $node = self::siblings($parentId)->addCondition('key', $nodeKey)->tryLoadAny(); |
57 | 57 | |
58 | - if (! $node->loaded()) return false; |
|
58 | + if (!$node->loaded()) return false; |
|
59 | 59 | |
60 | 60 | self::$cache['id'][$parentId][$nodeKey] = $node->id; |
61 | 61 | } |
@@ -68,10 +68,10 @@ discard block |
||
68 | 68 | |
69 | 69 | public static function newId($path, $readonly = false) |
70 | 70 | { |
71 | - if (! $path = trim($path,'/')) return false; |
|
71 | + if (!$path = trim($path, '/')) return false; |
|
72 | 72 | |
73 | 73 | $id = null; |
74 | - foreach(explode('/', $path) as $nodeKey) { |
|
74 | + foreach (explode('/', $path) as $nodeKey) { |
|
75 | 75 | if ($nodeKey === '') continue; |
76 | 76 | |
77 | 77 | $parentId = $id; |
@@ -95,10 +95,10 @@ discard block |
||
95 | 95 | |
96 | 96 | public static function setValue($path, $value, $overwrite = true, $readonly = false) |
97 | 97 | { |
98 | - if (! $id = self::getId($path)) { |
|
99 | - if (! $id = self::newId($path, $readonly)) return false; |
|
98 | + if (!$id = self::getId($path)) { |
|
99 | + if (!$id = self::newId($path, $readonly)) return false; |
|
100 | 100 | } else { |
101 | - if (! $overwrite) return false; |
|
101 | + if (!$overwrite) return false; |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | self::create()->tryLoad($id)->save(compact('value', 'readonly')); |
@@ -117,13 +117,13 @@ discard block |
||
117 | 117 | { |
118 | 118 | $key = md5(serialize($path)); |
119 | 119 | |
120 | - if (! isset(self::$cache['value'][$key])) { |
|
121 | - if(! $id = self::getId($path)) return false; |
|
120 | + if (!isset(self::$cache['value'][$key])) { |
|
121 | + if (!$id = self::getId($path)) return false; |
|
122 | 122 | |
123 | 123 | self::$cache['value'][$key] = self::create()->tryLoad($id)->get('value'); |
124 | 124 | } |
125 | 125 | |
126 | - return $translate? __(self::$cache['value'][$key]): self::$cache['value'][$key]; |
|
126 | + return $translate ? __(self::$cache['value'][$key]) : self::$cache['value'][$key]; |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | /** |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | $path = trim($path, '/'); |
142 | 142 | |
143 | 143 | if ($id = self::getId($path)) { |
144 | - if (! $overwrite) { |
|
144 | + if (!$overwrite) { |
|
145 | 145 | self::extendArray($path, $array); |
146 | 146 | return true; |
147 | 147 | } |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | self::create()->delete($id); |
150 | 150 | } |
151 | 151 | |
152 | - if(! $id = self::newId($path, $readonly)) return false; |
|
152 | + if (!$id = self::newId($path, $readonly)) return false; |
|
153 | 153 | |
154 | 154 | if ($overwrite) { |
155 | 155 | self::create()->tryLoad($id)->save(compact('readonly')); |
@@ -169,13 +169,13 @@ discard block |
||
169 | 169 | * @param $array array values to insert |
170 | 170 | * @param $overwrite bool whether method should overwrite data if array key already exists, otherwise the data will be preserved |
171 | 171 | */ |
172 | - public static function extendArray($path, $array, $overwrite=false, $readonly=false) |
|
172 | + public static function extendArray($path, $array, $overwrite = false, $readonly = false) |
|
173 | 173 | { |
174 | 174 | self::validateArrayKeys($array); |
175 | 175 | |
176 | 176 | $path = trim($path, '/'); |
177 | 177 | |
178 | - if (! self::getId($path)){ |
|
178 | + if (!self::getId($path)) { |
|
179 | 179 | return self::newArray($path, $array, $overwrite, $readonly); |
180 | 180 | } |
181 | 181 | |
@@ -201,8 +201,8 @@ discard block |
||
201 | 201 | * @param $path string |
202 | 202 | * @return true on success, false otherwise |
203 | 203 | */ |
204 | - public static function deleteArray($path){ |
|
205 | - if (! $id = self::getId($path, true)) return false; |
|
204 | + public static function deleteArray($path) { |
|
205 | + if (!$id = self::getId($path, true)) return false; |
|
206 | 206 | |
207 | 207 | self::create()->delete($id); |
208 | 208 | |
@@ -211,26 +211,26 @@ discard block |
||
211 | 211 | |
212 | 212 | public static function siblings($parent = null) |
213 | 213 | { |
214 | - $parentId = is_numeric($parent)? $parent: self::getId($parent); |
|
214 | + $parentId = is_numeric($parent) ? $parent : self::getId($parent); |
|
215 | 215 | |
216 | 216 | $model = self::create(); |
217 | 217 | |
218 | 218 | //@TODO: remove below when adding null condition fixed |
219 | - return $parentId? $model->addCondition('parent', $parentId): $model->addCondition($model->expr('parent is NULL')); |
|
219 | + return $parentId ? $model->addCondition('parent', $parentId) : $model->addCondition($model->expr('parent is NULL')); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | public static function ancestors($node) |
223 | 223 | { |
224 | - $node = is_numeric($node)? self::create()->tryLoad($node): $node; |
|
224 | + $node = is_numeric($node) ? self::create()->tryLoad($node) : $node; |
|
225 | 225 | |
226 | - if (! $node['parent']) return []; |
|
226 | + if (!$node['parent']) return []; |
|
227 | 227 | |
228 | 228 | return array_filter(array_merge([$node['parent']], self::ancestors($node['parent']))); |
229 | 229 | } |
230 | 230 | |
231 | 231 | public static function ancestorsAndSelf($node) |
232 | 232 | { |
233 | - $node = is_numeric($node)? self::create()->tryLoad($node): $node; |
|
233 | + $node = is_numeric($node) ? self::create()->tryLoad($node) : $node; |
|
234 | 234 | |
235 | 235 | return array_filter(array_merge([$node['id']], self::ancestors($node))); |
236 | 236 | } |
@@ -243,11 +243,11 @@ discard block |
||
243 | 243 | */ |
244 | 244 | public static function getCollection($path, $silent = false) |
245 | 245 | { |
246 | - if(isset(self::$cache['array'][$path])) { |
|
246 | + if (isset(self::$cache['array'][$path])) { |
|
247 | 247 | return self::$cache['array'][$path]; |
248 | 248 | } |
249 | 249 | |
250 | - if (! $id = self::getId($path)) { |
|
250 | + if (!$id = self::getId($path)) { |
|
251 | 251 | if ($silent) return collect(); |
252 | 252 | |
253 | 253 | throw new CommonDataNotFound('Invalid CommonData::getArray() request: ' . $path); |
@@ -258,10 +258,10 @@ discard block |
||
258 | 258 | |
259 | 259 | protected static function validateArrayKeys($array) |
260 | 260 | { |
261 | - foreach($array as $key => $value) { |
|
261 | + foreach ($array as $key => $value) { |
|
262 | 262 | if (strpos($key, '/') === false) continue; |
263 | 263 | |
264 | - \Exception('Invalid common data key: '. $key); |
|
264 | + \Exception('Invalid common data key: ' . $key); |
|
265 | 265 | } |
266 | 266 | } |
267 | 267 | } |
268 | 268 | \ No newline at end of file |
@@ -63,12 +63,12 @@ discard block |
||
63 | 63 | |
64 | 64 | $path = array_shift($fields); |
65 | 65 | |
66 | - return $fields? compact('path', 'fields'): false; |
|
66 | + return $fields ? compact('path', 'fields') : false; |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | public function getDependencyPath($data) |
70 | 70 | { |
71 | - if (! $dependency = $this->getDependency()) return false; |
|
71 | + if (!$dependency = $this->getDependency()) return false; |
|
72 | 72 | |
73 | 73 | return implode('/', array_merge([$dependency['path']], array_intersect_key($data, array_flip($dependency['fields'])))); |
74 | 74 | } |
@@ -82,12 +82,12 @@ discard block |
||
82 | 82 | |
83 | 83 | public static function serialize($field, $value, $persistence) |
84 | 84 | { |
85 | - return $field->multiple? implode(',', (array) $value): $value; |
|
85 | + return $field->multiple ? implode(',', (array) $value) : $value; |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | public static function unserialize($field, $value, $persistence) |
89 | 89 | { |
90 | - return $field->multiple? explode(',', $value): $value; |
|
90 | + return $field->multiple ? explode(',', $value) : $value; |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | public function format($row, $field) |
@@ -102,6 +102,6 @@ discard block |
||
102 | 102 | |
103 | 103 | public function normalize($value) |
104 | 104 | { |
105 | - return $this->multiple? parent::normalize($value): $value; |
|
105 | + return $this->multiple ? parent::normalize($value) : $value; |
|
106 | 106 | } |
107 | 107 | } |
108 | 108 | \ No newline at end of file |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | |
26 | 26 | public function body() |
27 | 27 | { |
28 | - if (! $this->isSingleDashboard()) { |
|
28 | + if (!$this->isSingleDashboard()) { |
|
29 | 29 | $this->location($this->dashboard()['name']); |
30 | 30 | } |
31 | 31 | |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | |
46 | 46 | $applets = $dashboard->ref('applets')->setOrder(['column', 'row']); |
47 | 47 | |
48 | - $columns = $this->add(['Columns', 'id' => 'dashboard', 'ui' => 'three stackable grid' . ($this->isLocked()? ' locked': '')]); |
|
48 | + $columns = $this->add(['Columns', 'id' => 'dashboard', 'ui' => 'three stackable grid' . ($this->isLocked() ? ' locked' : '')]); |
|
49 | 49 | |
50 | 50 | foreach ([1, 2, 3] as $columnId) { |
51 | 51 | $columnApplets = clone $applets; |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | } |
72 | 72 | } |
73 | 73 | |
74 | - if (! $this->isLocked()) { |
|
74 | + if (!$this->isLocked()) { |
|
75 | 75 | $columns->js(true)->find('.sortable')->sortable([ |
76 | 76 | 'cursor' => 'move', |
77 | 77 | 'handle' => '.panel-sortable-handle', |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | ]) |
90 | 90 | ])); |
91 | 91 | |
92 | - $columns->js(true)->find('.applet-close')->click(new jsFunction(['e'], [new jsExpression('if (confirm("' . __('Delete this applet?') . '")) {$(e.target).closest(".applet").fadeOut(400, function(){var col = $(this).closest(".column.sortable");this.remove();col.trigger("sortupdate");})}')])); |
|
92 | + $columns->js(true)->find('.applet-close')->click(new jsFunction(['e'], [new jsExpression('if (confirm("' . __('Delete this applet?') . '")) {$(e.target).closest(".applet").fadeOut(400, function(){var col = $(this).closest(".column.sortable");this.remove();col.trigger("sortupdate");})}')])); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | $this->columns = $columns; |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | ] |
137 | 137 | ]); |
138 | 138 | |
139 | - foreach ( AppletJoint::collect() as $applet ) { |
|
139 | + foreach (AppletJoint::collect() as $applet) { |
|
140 | 140 | $col->add([ |
141 | 141 | new Applet(), |
142 | 142 | 'appletId' => 'new_' . str_ireplace('\\', '-', get_class($applet)), |
@@ -260,17 +260,17 @@ discard block |
||
260 | 260 | |
261 | 261 | $name = $dashboard['name']; |
262 | 262 | |
263 | - return $dashboard->delete()? [ |
|
263 | + return $dashboard->delete() ? [ |
|
264 | 264 | $this->notifySuccess(__('Dashboard ":name" deleted, redirecting ...', compact('name'))), |
265 | 265 | new jsExpression('window.setTimeout(function() {window.location.replace([])}, 1200)', [$this->selfLink()]) |
266 | - ]: $this->notifyError(__('Error deleting dashboard')); |
|
266 | + ] : $this->notifyError(__('Error deleting dashboard')); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | public function reorderDashboards($view) |
270 | 270 | { |
271 | 271 | $grid = $view->add(['Grid', 'paginator' => false, 'menu' => false, 'model' => $this->userDashboards()->setOrder('position')]); |
272 | 272 | |
273 | - $grid->addDragHandler()->onReorder(function ($order) use ($grid) { |
|
273 | + $grid->addDragHandler()->onReorder(function($order) use ($grid) { |
|
274 | 274 | foreach ($this->userDashboards() as $dashboard) { |
275 | 275 | $dashboard->save(['position' => array_search($dashboard->id, $order)]); |
276 | 276 | } |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | |
353 | 353 | public function isLocked() |
354 | 354 | { |
355 | - return $this->locked || ! Auth::user()->can('edit dashboard'); |
|
355 | + return $this->locked || !Auth::user()->can('edit dashboard'); |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | protected function isSingleDashboard() |
@@ -368,18 +368,18 @@ discard block |
||
368 | 368 | */ |
369 | 369 | protected function dashboard() |
370 | 370 | { |
371 | - if (! is_object($this->dashboard)) { |
|
372 | - $this->dashboard = $this->dashboard? Dashboard::create()->tryLoad($this->dashboard): $this->defaultUserDashboard(); |
|
371 | + if (!is_object($this->dashboard)) { |
|
372 | + $this->dashboard = $this->dashboard ? Dashboard::create()->tryLoad($this->dashboard) : $this->defaultUserDashboard(); |
|
373 | 373 | } |
374 | 374 | |
375 | - return $this->dashboard?: abort(404); |
|
375 | + return $this->dashboard ?: abort(404); |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | protected function defaultUserDashboard() |
379 | 379 | { |
380 | 380 | $userDashboard = $this->userDashboards()->setOrder('position')->tryLoadAny(); |
381 | 381 | |
382 | - if (! $userDashboard->loaded()) { |
|
382 | + if (!$userDashboard->loaded()) { |
|
383 | 383 | $this->lock(); |
384 | 384 | |
385 | 385 | $userDashboard = $this->defaultSystemDashboard(); |
@@ -403,6 +403,6 @@ discard block |
||
403 | 403 | */ |
404 | 404 | protected function userId() |
405 | 405 | { |
406 | - return $this->admin? 0: Auth::id(); |
|
406 | + return $this->admin ? 0 : Auth::id(); |
|
407 | 407 | } |
408 | 408 | } |
@@ -51,7 +51,7 @@ |
||
51 | 51 | { |
52 | 52 | // create user default dashboard as copy of the system default |
53 | 53 | User::created(function(User $user) { |
54 | - if (! $defaultDashboard = Models\Dashboard::create()->addCondition('user_id', 0)->tryLoadAny()) return; |
|
54 | + if (!$defaultDashboard = Models\Dashboard::create()->addCondition('user_id', 0)->tryLoadAny()) return; |
|
55 | 55 | $userDefaultDashboard = (clone $defaultDashboard)->duplicate()->save([ |
56 | 56 | 'name' => __('Default'), |
57 | 57 | 'user_id' => $user->id |