@@ -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 |
@@ -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 |
@@ -21,13 +21,13 @@ |
||
| 21 | 21 | ]; |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | - return $ret? [ |
|
| 25 | - __('DASHBOARD') => count($ret) > 1? [ |
|
| 24 | + return $ret ? [ |
|
| 25 | + __('DASHBOARD') => count($ret) > 1 ? [ |
|
| 26 | 26 | 'item' => ['icon' => 'tachometer alternate'], |
| 27 | 27 | 'access' => true, |
| 28 | 28 | 'group' => $ret, |
| 29 | 29 | 'weight' => -10000 |
| 30 | - ]: array_merge(reset($ret), ['weight' => -10000]), |
|
| 31 | - ]: []; |
|
| 30 | + ] : array_merge(reset($ret), ['weight' => -10000]), |
|
| 31 | + ] : []; |
|
| 32 | 32 | } |
| 33 | 33 | } |
| 34 | 34 | \ 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,10 +260,10 @@ 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) |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | |
| 273 | 273 | $grid->setModel($this->userDashboards()->setOrder('position')); |
| 274 | 274 | |
| 275 | - $grid->addDragHandler()->onReorder(function ($order) use ($grid) { |
|
| 275 | + $grid->addDragHandler()->onReorder(function($order) use ($grid) { |
|
| 276 | 276 | foreach ($this->userDashboards() as $dashboard) { |
| 277 | 277 | $dashboard->save(['position' => array_search($dashboard->id, $order)]); |
| 278 | 278 | } |
@@ -354,7 +354,7 @@ discard block |
||
| 354 | 354 | |
| 355 | 355 | public function isLocked() |
| 356 | 356 | { |
| 357 | - return $this->locked || ! Auth::user()->can('edit dashboard'); |
|
| 357 | + return $this->locked || !Auth::user()->can('edit dashboard'); |
|
| 358 | 358 | } |
| 359 | 359 | |
| 360 | 360 | protected function isSingleDashboard() |
@@ -370,18 +370,18 @@ discard block |
||
| 370 | 370 | */ |
| 371 | 371 | protected function dashboard() |
| 372 | 372 | { |
| 373 | - if (! is_object($this->dashboard)) { |
|
| 374 | - $this->dashboard = $this->dashboard? Dashboard::create()->tryLoad($this->dashboard): $this->defaultUserDashboard(); |
|
| 373 | + if (!is_object($this->dashboard)) { |
|
| 374 | + $this->dashboard = $this->dashboard ? Dashboard::create()->tryLoad($this->dashboard) : $this->defaultUserDashboard(); |
|
| 375 | 375 | } |
| 376 | 376 | |
| 377 | - return $this->dashboard?: abort(404); |
|
| 377 | + return $this->dashboard ?: abort(404); |
|
| 378 | 378 | } |
| 379 | 379 | |
| 380 | 380 | protected function defaultUserDashboard() |
| 381 | 381 | { |
| 382 | 382 | $userDashboard = $this->userDashboards()->setOrder('position')->tryLoadAny(); |
| 383 | 383 | |
| 384 | - if (! $userDashboard->loaded()) { |
|
| 384 | + if (!$userDashboard->loaded()) { |
|
| 385 | 385 | $this->lock(); |
| 386 | 386 | |
| 387 | 387 | $userDashboard = $this->defaultSystemDashboard(); |
@@ -405,6 +405,6 @@ discard block |
||
| 405 | 405 | */ |
| 406 | 406 | protected function userId() |
| 407 | 407 | { |
| 408 | - return $this->admin? 0: Auth::id(); |
|
| 408 | + return $this->admin ? 0 : Auth::id(); |
|
| 409 | 409 | } |
| 410 | 410 | } |
@@ -28,7 +28,7 @@ |
||
| 28 | 28 | $this->set($joint->info())->setAttr('searchkey', strtolower($joint->caption() . ';' . $joint->info())); |
| 29 | 29 | } |
| 30 | 30 | else { |
| 31 | - if (! $this->locked) { |
|
| 31 | + if (!$this->locked) { |
|
| 32 | 32 | $this->addControl('close', 'applet-close')->setAttr('title', __('Close applet')); |
| 33 | 33 | } |
| 34 | 34 | |