@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | |
8 | 8 | class ActionBar extends Menu |
9 | 9 | { |
10 | - public $ui = 'actionbar menu'; |
|
10 | + public $ui = 'actionbar menu'; |
|
11 | 11 | |
12 | 12 | protected static $buttons = []; |
13 | 13 | |
@@ -46,12 +46,12 @@ discard block |
||
46 | 46 | } |
47 | 47 | |
48 | 48 | public function renderView() |
49 | - { |
|
50 | - $this->elements = collect($this->elements)->sortByDesc(function ($element) { |
|
51 | - return $element->weight ?? 10; |
|
52 | - })->toArray(); |
|
49 | + { |
|
50 | + $this->elements = collect($this->elements)->sortByDesc(function ($element) { |
|
51 | + return $element->weight ?? 10; |
|
52 | + })->toArray(); |
|
53 | 53 | |
54 | - return parent::renderView(); |
|
54 | + return parent::renderView(); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | |
82 | 82 | public static function addMenuButton($menu) |
83 | 83 | { |
84 | - return self::instance()->addMenu($menu); |
|
84 | + return self::instance()->addMenu($menu); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | public static function clear() |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | |
48 | 48 | public function renderView() |
49 | 49 | { |
50 | - $this->elements = collect($this->elements)->sortByDesc(function ($element) { |
|
50 | + $this->elements = collect($this->elements)->sortByDesc(function($element) { |
|
51 | 51 | return $element->weight ?? 10; |
52 | 52 | })->toArray(); |
53 | 53 | |
@@ -63,9 +63,9 @@ discard block |
||
63 | 63 | */ |
64 | 64 | public static function addItemButton($button, $defaults = []) |
65 | 65 | { |
66 | - $button = is_string($button)? self::getPredefined($button): $button; |
|
66 | + $button = is_string($button) ? self::getPredefined($button) : $button; |
|
67 | 67 | |
68 | - $button = is_array($button)? new ActionBarItem($button): $button; |
|
68 | + $button = is_array($button) ? new ActionBarItem($button) : $button; |
|
69 | 69 | |
70 | 70 | $actionBar = self::instance(); |
71 | 71 |
@@ -7,40 +7,40 @@ |
||
7 | 7 | |
8 | 8 | class ActionBarItem extends Item |
9 | 9 | { |
10 | - public $weight = 10; |
|
10 | + public $weight = 10; |
|
11 | 11 | |
12 | - public $callback; |
|
12 | + public $callback; |
|
13 | 13 | |
14 | - public $hint; |
|
14 | + public $hint; |
|
15 | 15 | |
16 | - public function renderView() |
|
17 | - { |
|
18 | - $this->addCallback(); |
|
16 | + public function renderView() |
|
17 | + { |
|
18 | + $this->addCallback(); |
|
19 | 19 | |
20 | - if ($this->hint) { |
|
21 | - $this->attr['title'] = $this->hint; |
|
22 | - } |
|
20 | + if ($this->hint) { |
|
21 | + $this->attr['title'] = $this->hint; |
|
22 | + } |
|
23 | 23 | |
24 | - parent::renderView(); |
|
25 | - } |
|
24 | + parent::renderView(); |
|
25 | + } |
|
26 | 26 | |
27 | - public function callback($callable) |
|
28 | - { |
|
29 | - $this->callback = $callable; |
|
27 | + public function callback($callable) |
|
28 | + { |
|
29 | + $this->callback = $callable; |
|
30 | 30 | |
31 | - return $this; |
|
32 | - } |
|
31 | + return $this; |
|
32 | + } |
|
33 | 33 | |
34 | - public function addCallback() |
|
35 | - { |
|
36 | - if (is_callable($callable = $this->callback)) { |
|
37 | - $callable = $this->add('jsCallback')->set($callable); |
|
38 | - } |
|
34 | + public function addCallback() |
|
35 | + { |
|
36 | + if (is_callable($callable = $this->callback)) { |
|
37 | + $callable = $this->add('jsCallback')->set($callable); |
|
38 | + } |
|
39 | 39 | |
40 | - if ($callable instanceof jsCallback) { |
|
41 | - $this->on('click', $callable); |
|
42 | - } |
|
40 | + if ($callable instanceof jsCallback) { |
|
41 | + $this->on('click', $callable); |
|
42 | + } |
|
43 | 43 | |
44 | - return $this; |
|
45 | - } |
|
44 | + return $this; |
|
45 | + } |
|
46 | 46 | } |
@@ -30,36 +30,36 @@ discard block |
||
30 | 30 | */ |
31 | 31 | class LayoutView extends ModuleView |
32 | 32 | { |
33 | - public $menuLeft; // vertical menu |
|
34 | - public $menu; // horizontal menu |
|
35 | - public $menuRight; // vertical pull-down |
|
36 | - public $actionBar; |
|
37 | - public $locationBar; |
|
33 | + public $menuLeft; // vertical menu |
|
34 | + public $menu; // horizontal menu |
|
35 | + public $menuRight; // vertical pull-down |
|
36 | + public $actionBar; |
|
37 | + public $locationBar; |
|
38 | 38 | |
39 | - public $burger = true; // burger menu item |
|
39 | + public $burger = true; // burger menu item |
|
40 | 40 | |
41 | - /* |
|
41 | + /* |
|
42 | 42 | * Whether or not left Menu is visible on Page load. |
43 | 43 | */ |
44 | - public $isMenuLeftVisible = true; |
|
44 | + public $isMenuLeftVisible = true; |
|
45 | 45 | |
46 | - public $defaultTemplate = 'layout/admin.html'; |
|
46 | + public $defaultTemplate = 'layout/admin.html'; |
|
47 | 47 | |
48 | - protected $location; |
|
48 | + protected $location; |
|
49 | 49 | |
50 | - public function init() |
|
51 | - { |
|
52 | - parent::init(); |
|
50 | + public function init() |
|
51 | + { |
|
52 | + parent::init(); |
|
53 | 53 | |
54 | - $this->setMenu(); |
|
55 | - $this->setActionBar(); |
|
54 | + $this->setMenu(); |
|
55 | + $this->setActionBar(); |
|
56 | 56 | |
57 | 57 | // if (request()->pjax()) return; |
58 | 58 | |
59 | - $this->setMenuLeft(); |
|
60 | - $this->setMenuRight(); |
|
59 | + $this->setMenuLeft(); |
|
60 | + $this->setMenuRight(); |
|
61 | 61 | |
62 | - $this->setVersion(); |
|
62 | + $this->setVersion(); |
|
63 | 63 | |
64 | 64 | // $this->js(true, null, 'body')->niceScroll(); |
65 | 65 | |
@@ -68,26 +68,26 @@ discard block |
||
68 | 68 | // if (event.originalEvent.persisted) { |
69 | 69 | // window.location.reload(); |
70 | 70 | // }')])); |
71 | - } |
|
71 | + } |
|
72 | 72 | |
73 | - public function setMenu() |
|
74 | - { |
|
75 | - if ($this->menu) return; |
|
73 | + public function setMenu() |
|
74 | + { |
|
75 | + if ($this->menu) return; |
|
76 | 76 | |
77 | - $this->menu = $this->add(['Menu', 'atk-topMenu fixed horizontal', 'element' => 'header'], 'TopMenu'); |
|
77 | + $this->menu = $this->add(['Menu', 'atk-topMenu fixed horizontal', 'element' => 'header'], 'TopMenu'); |
|
78 | 78 | |
79 | - // company logo |
|
80 | - // see Epesi\Core\Controllers\SystemController::logo |
|
81 | - $this->menu->add(['class' => ['epesi-logo'], 'style' => ['width' => '167px']])->add(['Image', url('logo')])->setStyle(['max-height' => '32px']); |
|
79 | + // company logo |
|
80 | + // see Epesi\Core\Controllers\SystemController::logo |
|
81 | + $this->menu->add(['class' => ['epesi-logo'], 'style' => ['width' => '167px']])->add(['Image', url('logo')])->setStyle(['max-height' => '32px']); |
|
82 | 82 | |
83 | - if ($this->burger) { |
|
84 | - /** @scrutinizer ignore-call */ |
|
85 | - $this->burger = $this->menu->addItem(['class' => ['icon atk-leftMenuTrigger']]); |
|
86 | - } |
|
83 | + if ($this->burger) { |
|
84 | + /** @scrutinizer ignore-call */ |
|
85 | + $this->burger = $this->menu->addItem(['class' => ['icon atk-leftMenuTrigger']]); |
|
86 | + } |
|
87 | 87 | |
88 | 88 | // home icon redirects to /home path |
89 | 89 | // see Epesi\Core\Controllers\SystemController::home |
90 | - $this->menu->addItem(['class' => ['icon epesi-home']], url('home'))->add(['Icon', 'home']); |
|
90 | + $this->menu->addItem(['class' => ['icon epesi-home']], url('home'))->add(['Icon', 'home']); |
|
91 | 91 | |
92 | 92 | // location bar |
93 | 93 | $this->locationBar = $this->menu->add(['View', ['ui' => 'epesi-location']]); |
@@ -130,50 +130,50 @@ discard block |
||
130 | 130 | ]), 'RightMenu')->addClass('right menu')->removeClass('item'); |
131 | 131 | } |
132 | 132 | |
133 | - public function setMenuLeft() |
|
134 | - { |
|
135 | - if ($this->menuLeft) return; |
|
133 | + public function setMenuLeft() |
|
134 | + { |
|
135 | + if ($this->menuLeft) return; |
|
136 | 136 | |
137 | - $this->menuLeft = $this->add(new Seeds\NavMenu('left vertical labeled sidebar'), 'LeftMenu'); |
|
137 | + $this->menuLeft = $this->add(new Seeds\NavMenu('left vertical labeled sidebar'), 'LeftMenu'); |
|
138 | 138 | |
139 | - if (! $this->burger) return; |
|
139 | + if (! $this->burger) return; |
|
140 | 140 | |
141 | - if (! session()->get('menu', 1)) { |
|
142 | - $this->isMenuLeftVisible = false; |
|
143 | - } |
|
141 | + if (! session()->get('menu', 1)) { |
|
142 | + $this->isMenuLeftVisible = false; |
|
143 | + } |
|
144 | 144 | |
145 | - $this->burger->add(['Icon', 'content'])->on('click', [ |
|
146 | - (new jQuery('.ui.left.sidebar'))->toggleClass('visible'), |
|
147 | - (new jQuery('.epesi-logo'))->toggleClass('expanded'), |
|
148 | - (new jQuery('body'))->toggleClass('atk-leftMenu-visible'), |
|
149 | - $this->burger->add('jsCallback')->set(function($j, $visible) { |
|
150 | - session()->put('menu', $visible? 1: 0); |
|
151 | - session()->save(); |
|
152 | - }, [new \atk4\ui\jsExpression( '$("#' . $this->menuLeft->id . '").hasClass("visible")? 1: 0' )]) |
|
153 | - ]); |
|
154 | - } |
|
145 | + $this->burger->add(['Icon', 'content'])->on('click', [ |
|
146 | + (new jQuery('.ui.left.sidebar'))->toggleClass('visible'), |
|
147 | + (new jQuery('.epesi-logo'))->toggleClass('expanded'), |
|
148 | + (new jQuery('body'))->toggleClass('atk-leftMenu-visible'), |
|
149 | + $this->burger->add('jsCallback')->set(function($j, $visible) { |
|
150 | + session()->put('menu', $visible? 1: 0); |
|
151 | + session()->save(); |
|
152 | + }, [new \atk4\ui\jsExpression( '$("#' . $this->menuLeft->id . '").hasClass("visible")? 1: 0' )]) |
|
153 | + ]); |
|
154 | + } |
|
155 | 155 | |
156 | - public function setActionBar() |
|
157 | - { |
|
158 | - if ($this->actionBar) return; |
|
156 | + public function setActionBar() |
|
157 | + { |
|
158 | + if ($this->actionBar) return; |
|
159 | 159 | |
160 | - $this->actionBar = $this->add(Seeds\ActionBar::class, 'ActionBar'); |
|
161 | - } |
|
160 | + $this->actionBar = $this->add(Seeds\ActionBar::class, 'ActionBar'); |
|
161 | + } |
|
162 | 162 | |
163 | - public function setVersion() |
|
164 | - { |
|
165 | - $this->template->trySet('version', $this->app->version); |
|
166 | - } |
|
163 | + public function setVersion() |
|
164 | + { |
|
165 | + $this->template->trySet('version', $this->app->version); |
|
166 | + } |
|
167 | 167 | |
168 | - /** |
|
169 | - * {@inheritdoc} |
|
170 | - */ |
|
168 | + /** |
|
169 | + * {@inheritdoc} |
|
170 | + */ |
|
171 | 171 | |
172 | - public function renderView() |
|
173 | - { |
|
174 | - if ($this->menuLeft && $this->isMenuLeftVisible) { |
|
175 | - $this->menuLeft->addClass('visible'); |
|
176 | - } |
|
177 | - parent::renderView(); |
|
178 | - } |
|
172 | + public function renderView() |
|
173 | + { |
|
174 | + if ($this->menuLeft && $this->isMenuLeftVisible) { |
|
175 | + $this->menuLeft->addClass('visible'); |
|
176 | + } |
|
177 | + parent::renderView(); |
|
178 | + } |
|
179 | 179 | } |
@@ -72,7 +72,9 @@ discard block |
||
72 | 72 | |
73 | 73 | public function setMenu() |
74 | 74 | { |
75 | - if ($this->menu) return; |
|
75 | + if ($this->menu) { |
|
76 | + return; |
|
77 | + } |
|
76 | 78 | |
77 | 79 | $this->menu = $this->add(['Menu', 'atk-topMenu fixed horizontal', 'element' => 'header'], 'TopMenu'); |
78 | 80 | |
@@ -123,7 +125,9 @@ discard block |
||
123 | 125 | |
124 | 126 | public function setMenuRight() |
125 | 127 | { |
126 | - if ($this->menuRight) return; |
|
128 | + if ($this->menuRight) { |
|
129 | + return; |
|
130 | + } |
|
127 | 131 | |
128 | 132 | $this->menuRight = $this->menu->add(new Seeds\RightMenu([ |
129 | 133 | 'ui' => false |
@@ -132,11 +136,15 @@ discard block |
||
132 | 136 | |
133 | 137 | public function setMenuLeft() |
134 | 138 | { |
135 | - if ($this->menuLeft) return; |
|
139 | + if ($this->menuLeft) { |
|
140 | + return; |
|
141 | + } |
|
136 | 142 | |
137 | 143 | $this->menuLeft = $this->add(new Seeds\NavMenu('left vertical labeled sidebar'), 'LeftMenu'); |
138 | 144 | |
139 | - if (! $this->burger) return; |
|
145 | + if (! $this->burger) { |
|
146 | + return; |
|
147 | + } |
|
140 | 148 | |
141 | 149 | if (! session()->get('menu', 1)) { |
142 | 150 | $this->isMenuLeftVisible = false; |
@@ -155,7 +163,9 @@ discard block |
||
155 | 163 | |
156 | 164 | public function setActionBar() |
157 | 165 | { |
158 | - if ($this->actionBar) return; |
|
166 | + if ($this->actionBar) { |
|
167 | + return; |
|
168 | + } |
|
159 | 169 | |
160 | 170 | $this->actionBar = $this->add(Seeds\ActionBar::class, 'ActionBar'); |
161 | 171 | } |
@@ -34,8 +34,8 @@ discard block |
||
34 | 34 | $form->addField('custom_logo', ['CheckBox', 'caption' => __('Use custom logo')]); |
35 | 35 | |
36 | 36 | $form->model->set([ |
37 | - 'title' => Variable::recall('system.title'), |
|
38 | - 'custom_logo' => (bool) Variable::recall('system.logo') |
|
37 | + 'title' => Variable::recall('system.title'), |
|
38 | + 'custom_logo' => (bool) Variable::recall('system.logo') |
|
39 | 39 | ]); |
40 | 40 | |
41 | 41 | $logo = $form->addField('logo', [ |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | $storage->move($from, $to); |
77 | 77 | } |
78 | 78 | |
79 | - Variable::memorize('system.logo', $logo); |
|
79 | + Variable::memorize('system.logo', $logo); |
|
80 | 80 | |
81 | 81 | Variable::memorize('system.title', $form->model['title']); |
82 | 82 |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | $logo->setThumbnailSrc(asset('storage/' . self::alias() . '/' . self::$defaultLogo)); |
54 | 54 | }); |
55 | 55 | |
56 | - $logo->onUpload(function ($files) use ($form, $logo) { |
|
56 | + $logo->onUpload(function($files) use ($form, $logo) { |
|
57 | 57 | if ($files === 'error') return $form->error('logo', __('Error uploading image')); |
58 | 58 | |
59 | 59 | $tmpPath = self::alias() . '/tmp/' . $files['name']; |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | }); |
65 | 65 | |
66 | 66 | $form->onSubmit(function($form) { |
67 | - if ($logo = $form->model['custom_logo']? $form->model['logo']: null) { |
|
67 | + if ($logo = $form->model['custom_logo'] ? $form->model['logo'] : null) { |
|
68 | 68 | $storage = $this->storage(); |
69 | 69 | $from = self::alias() . '/tmp/' . $logo; |
70 | 70 | $to = self::alias() . '/' . $logo; |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | $accordion = $container->add(['Accordion', 'type' => ['styled', 'fluid'], 'settings' => ['animateChildren' => false]])->setStyle(['max-width' => '800px', 'margin-left' => 'auto', 'margin-right' => 'auto']); |
44 | 44 | |
45 | 45 | if ($container == $this) { |
46 | - $this->accordion = $accordion; |
|
46 | + $this->accordion = $accordion; |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | foreach ($modules as $moduleClass) { |
@@ -92,17 +92,17 @@ discard block |
||
92 | 92 | |
93 | 93 | public function addInstallButton($container, $moduleClass) |
94 | 94 | { |
95 | - $button = $container->add(['Button', __('Install'), 'class' => ['green']]); |
|
95 | + $button = $container->add(['Button', __('Install'), 'class' => ['green']]); |
|
96 | 96 | |
97 | - $callback = $installCallback = $this->add('jsCallback')->set(function() use ($moduleClass, $container) { |
|
97 | + $callback = $installCallback = $this->add('jsCallback')->set(function() use ($moduleClass, $container) { |
|
98 | 98 | ob_start(); |
99 | 99 | ModuleManager::install($moduleClass); |
100 | 100 | |
101 | 101 | $message = ob_get_clean(); |
102 | 102 | |
103 | 103 | return [ |
104 | - $this->notifySuccess($message), |
|
105 | - new jsReload($this->accordion), |
|
104 | + $this->notifySuccess($message), |
|
105 | + new jsReload($this->accordion), |
|
106 | 106 | ]; |
107 | 107 | }); |
108 | 108 | |
@@ -150,17 +150,17 @@ discard block |
||
150 | 150 | |
151 | 151 | public function addUninstallButton($container, $moduleClass) |
152 | 152 | { |
153 | - $button = $container->add(['Button', __('Uninstall'), 'class' => ['red']]); |
|
153 | + $button = $container->add(['Button', __('Uninstall'), 'class' => ['red']]); |
|
154 | 154 | |
155 | - $callback = $uninstallCallback = $button->add(['jsCallback', 'confirm' => __('Are you sure you want to uninstall :module', ['module' => $moduleClass::label()])])->set(function() use ($moduleClass) { |
|
156 | - ob_start(); |
|
155 | + $callback = $uninstallCallback = $button->add(['jsCallback', 'confirm' => __('Are you sure you want to uninstall :module', ['module' => $moduleClass::label()])])->set(function() use ($moduleClass) { |
|
156 | + ob_start(); |
|
157 | 157 | ModuleManager::uninstall($moduleClass); |
158 | 158 | |
159 | 159 | $message = ob_get_clean(); |
160 | 160 | |
161 | 161 | return [ |
162 | - $this->notifySuccess($message), |
|
163 | - new jsReload($this->accordion), |
|
162 | + $this->notifySuccess($message), |
|
163 | + new jsReload($this->accordion), |
|
164 | 164 | ]; |
165 | 165 | }); |
166 | 166 | |
@@ -195,12 +195,12 @@ discard block |
||
195 | 195 | |
196 | 196 | public function addClearCacheButton() |
197 | 197 | { |
198 | - ActionBar::addItemButton([__('Clear Cache'), 'icon' => 'refresh', 'hint' => __('Clears module cache and re-discovers all available modules')])->callback(function($callback) { |
|
198 | + ActionBar::addItemButton([__('Clear Cache'), 'icon' => 'refresh', 'hint' => __('Clears module cache and re-discovers all available modules')])->callback(function($callback) { |
|
199 | 199 | ModuleManager::clearCache(); |
200 | 200 | |
201 | 201 | return [ |
202 | - new jsReload($this->accordion), |
|
203 | - $this->notifySuccess(__('Cache cleared!')) |
|
202 | + new jsReload($this->accordion), |
|
203 | + $this->notifySuccess(__('Cache cleared!')) |
|
204 | 204 | ]; |
205 | 205 | }); |
206 | 206 | } |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | |
9 | 9 | class Variable extends Model |
10 | 10 | { |
11 | - use HasEpesiConnection; |
|
11 | + use HasEpesiConnection; |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * @var Collection |
@@ -26,12 +26,12 @@ discard block |
||
26 | 26 | } |
27 | 27 | |
28 | 28 | public function init() { |
29 | - parent::init(); |
|
29 | + parent::init(); |
|
30 | 30 | |
31 | - $this->addFields([ |
|
32 | - 'name', |
|
33 | - 'value' => ['type' => 'text', 'serialize' => 'base64'] |
|
34 | - ]); |
|
31 | + $this->addFields([ |
|
32 | + 'name', |
|
33 | + 'value' => ['type' => 'text', 'serialize' => 'base64'] |
|
34 | + ]); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | public static function recall($name, $default = null) { |
@@ -56,10 +56,10 @@ discard block |
||
56 | 56 | $variable = self::create()->addCondition('name', $name)->tryLoadAny(); |
57 | 57 | |
58 | 58 | if ($variable->loaded()) { |
59 | - $variable->save(compact('value')); |
|
59 | + $variable->save(compact('value')); |
|
60 | 60 | } |
61 | 61 | else { |
62 | - $variable->insert(compact('name', 'value')); |
|
62 | + $variable->insert(compact('name', 'value')); |
|
63 | 63 | } |
64 | 64 | } |
65 | 65 |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | public $strict_types = false; |
21 | 21 | |
22 | 22 | private static function cache() { |
23 | - if(isset(self::$variables)) return; |
|
23 | + if (isset(self::$variables)) return; |
|
24 | 24 | |
25 | 25 | self::$variables = self::pluck('value', 'name'); |
26 | 26 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | public static function recall($name, $default = null) { |
38 | 38 | self::cache(); |
39 | 39 | |
40 | - if (! self::$variables->has($name)) return $default; |
|
40 | + if (!self::$variables->has($name)) return $default; |
|
41 | 41 | |
42 | 42 | return self::$variables->get($name, $default)?? $default; |
43 | 43 | } |
@@ -63,10 +63,10 @@ discard block |
||
63 | 63 | } |
64 | 64 | } |
65 | 65 | |
66 | - public static function forget($name, $throwError=true) { |
|
66 | + public static function forget($name, $throwError = true) { |
|
67 | 67 | self::cache(); |
68 | 68 | |
69 | - if (! self::$variables->has($name) && $throwError) { |
|
69 | + if (!self::$variables->has($name) && $throwError) { |
|
70 | 70 | throw new \Exception('No such variable in database: ' . $name); |
71 | 71 | } |
72 | 72 |