@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | |
59 | 59 | protected function prepareButtons() |
60 | 60 | { |
61 | - foreach (self::$buttons->sortByDesc(function ($button) { |
|
61 | + foreach (self::$buttons->sortByDesc(function($button) { |
|
62 | 62 | return $button->weight; |
63 | 63 | }) as $button) { |
64 | 64 | $this->add($button); |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | |
83 | 83 | public static function addButtons($buttons) |
84 | 84 | { |
85 | - foreach (is_array($buttons)? $buttons: [$buttons] as $button) { |
|
85 | + foreach (is_array($buttons) ? $buttons : [$buttons] as $button) { |
|
86 | 86 | self::addButton($button); |
87 | 87 | } |
88 | 88 | } |
@@ -7,49 +7,49 @@ |
||
7 | 7 | |
8 | 8 | class ActionButton extends View |
9 | 9 | { |
10 | - public $defaultTemplate = 'action_button.html'; |
|
10 | + public $defaultTemplate = 'action_button.html'; |
|
11 | 11 | |
12 | - public $ui = 'basic inverted action button'; |
|
12 | + public $ui = 'basic inverted action button'; |
|
13 | 13 | |
14 | - /** |
|
15 | - * Icon that will appear on the button (top). |
|
16 | - * |
|
17 | - * @var string|array|Icon |
|
18 | - */ |
|
19 | - public $icon; |
|
14 | + /** |
|
15 | + * Icon that will appear on the button (top). |
|
16 | + * |
|
17 | + * @var string|array|Icon |
|
18 | + */ |
|
19 | + public $icon; |
|
20 | 20 | |
21 | - public $label; |
|
21 | + public $label; |
|
22 | 22 | |
23 | - public $element = 'a'; |
|
23 | + public $element = 'a'; |
|
24 | 24 | |
25 | - public $weight = 10; |
|
25 | + public $weight = 10; |
|
26 | 26 | |
27 | - public function renderView() |
|
28 | - { |
|
29 | - $this->addIcon(); |
|
27 | + public function renderView() |
|
28 | + { |
|
29 | + $this->addIcon(); |
|
30 | 30 | |
31 | - $this->addLabel(); |
|
31 | + $this->addLabel(); |
|
32 | 32 | |
33 | - parent::renderView(); |
|
34 | - } |
|
33 | + parent::renderView(); |
|
34 | + } |
|
35 | 35 | |
36 | - protected function addIcon() |
|
37 | - { |
|
38 | - if (! $icon = $this->getIcon()) return; |
|
36 | + protected function addIcon() |
|
37 | + { |
|
38 | + if (! $icon = $this->getIcon()) return; |
|
39 | 39 | |
40 | - $this->add($icon, 'Icon')->id = null; |
|
40 | + $this->add($icon, 'Icon')->id = null; |
|
41 | 41 | |
42 | - $this->addClass('icon'); |
|
43 | - } |
|
42 | + $this->addClass('icon'); |
|
43 | + } |
|
44 | 44 | |
45 | - protected function addLabel() |
|
46 | - { |
|
47 | - $this->content = $this->label?: $this->content; |
|
48 | - } |
|
49 | - |
|
50 | - public function getIcon() |
|
51 | - { |
|
52 | - return is_object($this->icon)? $this->icon: new Icon($this->icon); |
|
53 | - } |
|
45 | + protected function addLabel() |
|
46 | + { |
|
47 | + $this->content = $this->label?: $this->content; |
|
48 | + } |
|
49 | + |
|
50 | + public function getIcon() |
|
51 | + { |
|
52 | + return is_object($this->icon)? $this->icon: new Icon($this->icon); |
|
53 | + } |
|
54 | 54 | |
55 | 55 | } |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | |
36 | 36 | protected function addIcon() |
37 | 37 | { |
38 | - if (! $icon = $this->getIcon()) return; |
|
38 | + if (!$icon = $this->getIcon()) return; |
|
39 | 39 | |
40 | 40 | $this->add($icon, 'Icon')->id = null; |
41 | 41 | |
@@ -44,12 +44,12 @@ discard block |
||
44 | 44 | |
45 | 45 | protected function addLabel() |
46 | 46 | { |
47 | - $this->content = $this->label?: $this->content; |
|
47 | + $this->content = $this->label ?: $this->content; |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | public function getIcon() |
51 | 51 | { |
52 | - return is_object($this->icon)? $this->icon: new Icon($this->icon); |
|
52 | + return is_object($this->icon) ? $this->icon : new Icon($this->icon); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | } |
@@ -35,7 +35,9 @@ |
||
35 | 35 | |
36 | 36 | protected function addIcon() |
37 | 37 | { |
38 | - if (! $icon = $this->getIcon()) return; |
|
38 | + if (! $icon = $this->getIcon()) { |
|
39 | + return; |
|
40 | + } |
|
39 | 41 | |
40 | 42 | $this->add($icon, 'Icon')->id = null; |
41 | 43 |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | |
14 | 14 | public function __construct($parent) |
15 | 15 | { |
16 | - $this->parent = $parent; |
|
16 | + $this->parent = $parent; |
|
17 | 17 | |
18 | 18 | parent::__construct('$(this).atkCreateModal([arg])', [ |
19 | 19 | 'arg' => [ |
@@ -25,29 +25,29 @@ discard block |
||
25 | 25 | } |
26 | 26 | |
27 | 27 | protected function getURL() |
28 | - { |
|
29 | - return $this->parent->add('VirtualPage')->set(Closure::fromCallable([$this, 'getContents']))->getJSURL('cut'); |
|
30 | - } |
|
28 | + { |
|
29 | + return $this->parent->add('VirtualPage')->set(Closure::fromCallable([$this, 'getContents']))->getJSURL('cut'); |
|
30 | + } |
|
31 | 31 | |
32 | - protected function getContents(VirtualPage $vp) |
|
33 | - { |
|
34 | - $vp->add([ |
|
35 | - new LaunchButton([ |
|
36 | - 'label' => 'Test Button 1', |
|
37 | - 'icon' => 'user' |
|
38 | - ]) |
|
39 | - ])->link(URL::to('/')); |
|
40 | - $vp->add([ |
|
41 | - new LaunchButton([ |
|
42 | - 'label' => 'Test Button 2', |
|
43 | - 'icon' => 'car' |
|
44 | - ]) |
|
45 | - ]); |
|
46 | - $vp->add([ |
|
47 | - new LaunchButton([ |
|
48 | - 'label' => 'Test Button 3', |
|
49 | - 'icon' => 'bus' |
|
50 | - ]) |
|
51 | - ]); |
|
52 | - } |
|
32 | + protected function getContents(VirtualPage $vp) |
|
33 | + { |
|
34 | + $vp->add([ |
|
35 | + new LaunchButton([ |
|
36 | + 'label' => 'Test Button 1', |
|
37 | + 'icon' => 'user' |
|
38 | + ]) |
|
39 | + ])->link(URL::to('/')); |
|
40 | + $vp->add([ |
|
41 | + new LaunchButton([ |
|
42 | + 'label' => 'Test Button 2', |
|
43 | + 'icon' => 'car' |
|
44 | + ]) |
|
45 | + ]); |
|
46 | + $vp->add([ |
|
47 | + new LaunchButton([ |
|
48 | + 'label' => 'Test Button 3', |
|
49 | + 'icon' => 'bus' |
|
50 | + ]) |
|
51 | + ]); |
|
52 | + } |
|
53 | 53 | } |
@@ -6,16 +6,16 @@ |
||
6 | 6 | { |
7 | 7 | public function notify($options, $attachTo = null) |
8 | 8 | { |
9 | - $options = array_merge(['duration'=> 1500], is_array($options)? $options: ['content' => $options]); |
|
9 | + $options = array_merge(['duration'=> 1500], is_array($options) ? $options : ['content' => $options]); |
|
10 | 10 | |
11 | - $attachTo = $attachTo?: $this; |
|
11 | + $attachTo = $attachTo ?: $this; |
|
12 | 12 | |
13 | 13 | return (new \atk4\ui\jsNotify($options, $attachTo)); |
14 | 14 | } |
15 | 15 | |
16 | 16 | public function notifyError($options, $attachTo = null) |
17 | 17 | { |
18 | - $options = array_merge(['color' => 'red'], is_array($options)? $options: ['content' => $options]); |
|
18 | + $options = array_merge(['color' => 'red'], is_array($options) ? $options : ['content' => $options]); |
|
19 | 19 | |
20 | 20 | return $this->notify($options, $attachTo); |
21 | 21 | } |
@@ -10,57 +10,57 @@ |
||
10 | 10 | |
11 | 11 | class EpesiServiceProvider extends ServiceProvider |
12 | 12 | { |
13 | - /** |
|
14 | - * Booting the package. |
|
15 | - */ |
|
16 | - public function boot() |
|
17 | - { |
|
18 | - $this->ensureHttps(); |
|
13 | + /** |
|
14 | + * Booting the package. |
|
15 | + */ |
|
16 | + public function boot() |
|
17 | + { |
|
18 | + $this->ensureHttps(); |
|
19 | 19 | |
20 | - Route::group(['namespace' => 'Epesi\Core\Controllers', 'middleware' => ['web', 'auth']], function() { |
|
21 | - header("Cache-Control: no-cache, no-store, must-revalidate"); //HTTP 1.1 |
|
22 | - header("Pragma: no-cache"); //HTTP 1.0 |
|
23 | - header("Expires: 0"); |
|
20 | + Route::group(['namespace' => 'Epesi\Core\Controllers', 'middleware' => ['web', 'auth']], function() { |
|
21 | + header("Cache-Control: no-cache, no-store, must-revalidate"); //HTTP 1.1 |
|
22 | + header("Pragma: no-cache"); //HTTP 1.0 |
|
23 | + header("Expires: 0"); |
|
24 | 24 | |
25 | - Route::any('view/{alias}/{method?}/{args?}', 'ModuleController@view'); |
|
26 | - }); |
|
25 | + Route::any('view/{alias}/{method?}/{args?}', 'ModuleController@view'); |
|
26 | + }); |
|
27 | 27 | |
28 | 28 | // Register providers declared in modules |
29 | 29 | foreach (Module::collect('providers') as $provider) { |
30 | 30 | $this->app->register($provider); |
31 | 31 | } |
32 | 32 | |
33 | - // Register admin service provider if in admin mode or in console |
|
34 | - // TODO: apply access restriction to admin mode |
|
33 | + // Register admin service provider if in admin mode or in console |
|
34 | + // TODO: apply access restriction to admin mode |
|
35 | 35 | // if ($this->app->runningInConsole() || (request('admin', false) && Auth::user()->can('modify system'))) { |
36 | - if ($this->app->runningInConsole() || request('admin', false)) { |
|
37 | - $this->app->register(AdminServiceProvider::class); |
|
38 | - } |
|
39 | - } |
|
36 | + if ($this->app->runningInConsole() || request('admin', false)) { |
|
37 | + $this->app->register(AdminServiceProvider::class); |
|
38 | + } |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * Register the provider. |
|
43 | - */ |
|
44 | - public function register() |
|
45 | - { |
|
46 | - $this->app->singleton(App::class); |
|
47 | - } |
|
41 | + /** |
|
42 | + * Register the provider. |
|
43 | + */ |
|
44 | + public function register() |
|
45 | + { |
|
46 | + $this->app->singleton(App::class); |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * Force to set https scheme if https enabled. |
|
51 | - * |
|
52 | - * @return void |
|
53 | - */ |
|
54 | - protected function ensureHttps() |
|
55 | - { |
|
56 | - if (config('epesi.https') || config('epesi.secure')) { |
|
57 | - url()->forceScheme('https'); |
|
58 | - $this->app['request']->server->set('HTTPS', true); |
|
59 | - } |
|
60 | - } |
|
49 | + /** |
|
50 | + * Force to set https scheme if https enabled. |
|
51 | + * |
|
52 | + * @return void |
|
53 | + */ |
|
54 | + protected function ensureHttps() |
|
55 | + { |
|
56 | + if (config('epesi.https') || config('epesi.secure')) { |
|
57 | + url()->forceScheme('https'); |
|
58 | + $this->app['request']->server->set('HTTPS', true); |
|
59 | + } |
|
60 | + } |
|
61 | 61 | |
62 | - protected function registerStorageDisk() |
|
63 | - { |
|
64 | - $this->app['config']['filesystems.disks.epesi'] = config('epesi.disk'); |
|
65 | - } |
|
62 | + protected function registerStorageDisk() |
|
63 | + { |
|
64 | + $this->app['config']['filesystems.disks.epesi'] = config('epesi.disk'); |
|
65 | + } |
|
66 | 66 | } |
@@ -11,26 +11,26 @@ |
||
11 | 11 | \Epesi\Core\Console\AdminCommand::class |
12 | 12 | ]; |
13 | 13 | |
14 | - /** |
|
15 | - * Booting the package. |
|
16 | - */ |
|
17 | - public function boot() |
|
18 | - { |
|
19 | - // Register migrations from installed modules |
|
20 | - $this->loadMigrationsFrom(Module::collect('migrations'), 'epesi.module.migrations'); |
|
14 | + /** |
|
15 | + * Booting the package. |
|
16 | + */ |
|
17 | + public function boot() |
|
18 | + { |
|
19 | + // Register migrations from installed modules |
|
20 | + $this->loadMigrationsFrom(Module::collect('migrations'), 'epesi.module.migrations'); |
|
21 | 21 | |
22 | - // Publish files from installed modules |
|
23 | - $this->publishes(Module::collect('public'), 'epesi.module.public'); |
|
22 | + // Publish files from installed modules |
|
23 | + $this->publishes(Module::collect('public'), 'epesi.module.public'); |
|
24 | 24 | |
25 | - // Publish epesi configuration files |
|
26 | - $this->publishes([__DIR__.'/../../config' => config_path()], 'epesi.config'); |
|
27 | - } |
|
25 | + // Publish epesi configuration files |
|
26 | + $this->publishes([__DIR__.'/../../config' => config_path()], 'epesi.config'); |
|
27 | + } |
|
28 | 28 | |
29 | - /** |
|
30 | - * Register the provider. |
|
31 | - */ |
|
32 | - public function register() |
|
33 | - { |
|
34 | - $this->commands($this->commands); |
|
35 | - } |
|
29 | + /** |
|
30 | + * Register the provider. |
|
31 | + */ |
|
32 | + public function register() |
|
33 | + { |
|
34 | + $this->commands($this->commands); |
|
35 | + } |
|
36 | 36 | } |
@@ -23,7 +23,7 @@ |
||
23 | 23 | $this->publishes(Module::collect('public'), 'epesi.module.public'); |
24 | 24 | |
25 | 25 | // Publish epesi configuration files |
26 | - $this->publishes([__DIR__.'/../../config' => config_path()], 'epesi.config'); |
|
26 | + $this->publishes([__DIR__ . '/../../config' => config_path()], 'epesi.config'); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -8,24 +8,24 @@ discard block |
||
8 | 8 | |
9 | 9 | class AdminCommand extends Command |
10 | 10 | { |
11 | - /** |
|
12 | - * The name and signature of the console command. |
|
13 | - * |
|
14 | - * @var string |
|
15 | - */ |
|
16 | - protected $signature = 'epesi'; |
|
17 | - |
|
18 | - /** |
|
19 | - * The console command description. |
|
20 | - * |
|
21 | - * @var string |
|
22 | - */ |
|
23 | - protected $description = 'List all epesi commands'; |
|
24 | - |
|
25 | - /** |
|
26 | - * @var string |
|
27 | - */ |
|
28 | - public static $logo = <<<LOGO |
|
11 | + /** |
|
12 | + * The name and signature of the console command. |
|
13 | + * |
|
14 | + * @var string |
|
15 | + */ |
|
16 | + protected $signature = 'epesi'; |
|
17 | + |
|
18 | + /** |
|
19 | + * The console command description. |
|
20 | + * |
|
21 | + * @var string |
|
22 | + */ |
|
23 | + protected $description = 'List all epesi commands'; |
|
24 | + |
|
25 | + /** |
|
26 | + * @var string |
|
27 | + */ |
|
28 | + public static $logo = <<<LOGO |
|
29 | 29 | ____ ____ ____ ____ __ |
30 | 30 | ( __)( _ \( __)/ ___)( ) |
31 | 31 | ) _) ) __/ ) _) \___ \ )( |
@@ -33,74 +33,74 @@ discard block |
||
33 | 33 | |
34 | 34 | LOGO; |
35 | 35 | |
36 | - /** |
|
37 | - * Execute the console command. |
|
38 | - */ |
|
39 | - public function handle() |
|
40 | - { |
|
41 | - $this->line(static::$logo); |
|
42 | - |
|
43 | - $this->comment(''); |
|
44 | - $this->comment('Available commands:'); |
|
45 | - |
|
46 | - $this->listEpesiCommands(); |
|
47 | - } |
|
48 | - |
|
49 | - /** |
|
50 | - * List all epesi commands. |
|
51 | - * |
|
52 | - * @return void |
|
53 | - */ |
|
54 | - protected function listEpesiCommands() |
|
55 | - { |
|
56 | - $commands = collect(Artisan::all())->mapWithKeys(function ($command, $key) { |
|
57 | - if (Str::startsWith($key, 'epesi:')) { |
|
58 | - return [$key => $command]; |
|
59 | - } |
|
60 | - |
|
61 | - return []; |
|
62 | - })->toArray(); |
|
63 | - |
|
64 | - $width = $this->getColumnWidth($commands); |
|
65 | - |
|
66 | - /** @var Command $command */ |
|
67 | - foreach ($commands as $command) { |
|
68 | - $this->line(sprintf(" %-{$width}s %s", $command->getName(), $command->getDescription())); |
|
69 | - } |
|
70 | - } |
|
71 | - |
|
72 | - /** |
|
73 | - * @param (Command|string)[] $commands |
|
74 | - * |
|
75 | - * @return int |
|
76 | - */ |
|
77 | - private function getColumnWidth(array $commands) |
|
78 | - { |
|
79 | - $widths = []; |
|
80 | - |
|
81 | - foreach ($commands as $command) { |
|
82 | - $widths[] = static::strlen($command->getName()); |
|
83 | - foreach ($command->getAliases() as $alias) { |
|
84 | - $widths[] = static::strlen($alias); |
|
85 | - } |
|
86 | - } |
|
87 | - |
|
88 | - return $widths ? max($widths) + 2 : 0; |
|
89 | - } |
|
90 | - |
|
91 | - /** |
|
92 | - * Returns the length of a string, using mb_strwidth if it is available. |
|
93 | - * |
|
94 | - * @param string $string The string to check its length |
|
95 | - * |
|
96 | - * @return int The length of the string |
|
97 | - */ |
|
98 | - public static function strlen($string) |
|
99 | - { |
|
100 | - if (false === $encoding = mb_detect_encoding($string, null, true)) { |
|
101 | - return strlen($string); |
|
102 | - } |
|
103 | - |
|
104 | - return mb_strwidth($string, $encoding); |
|
105 | - } |
|
36 | + /** |
|
37 | + * Execute the console command. |
|
38 | + */ |
|
39 | + public function handle() |
|
40 | + { |
|
41 | + $this->line(static::$logo); |
|
42 | + |
|
43 | + $this->comment(''); |
|
44 | + $this->comment('Available commands:'); |
|
45 | + |
|
46 | + $this->listEpesiCommands(); |
|
47 | + } |
|
48 | + |
|
49 | + /** |
|
50 | + * List all epesi commands. |
|
51 | + * |
|
52 | + * @return void |
|
53 | + */ |
|
54 | + protected function listEpesiCommands() |
|
55 | + { |
|
56 | + $commands = collect(Artisan::all())->mapWithKeys(function ($command, $key) { |
|
57 | + if (Str::startsWith($key, 'epesi:')) { |
|
58 | + return [$key => $command]; |
|
59 | + } |
|
60 | + |
|
61 | + return []; |
|
62 | + })->toArray(); |
|
63 | + |
|
64 | + $width = $this->getColumnWidth($commands); |
|
65 | + |
|
66 | + /** @var Command $command */ |
|
67 | + foreach ($commands as $command) { |
|
68 | + $this->line(sprintf(" %-{$width}s %s", $command->getName(), $command->getDescription())); |
|
69 | + } |
|
70 | + } |
|
71 | + |
|
72 | + /** |
|
73 | + * @param (Command|string)[] $commands |
|
74 | + * |
|
75 | + * @return int |
|
76 | + */ |
|
77 | + private function getColumnWidth(array $commands) |
|
78 | + { |
|
79 | + $widths = []; |
|
80 | + |
|
81 | + foreach ($commands as $command) { |
|
82 | + $widths[] = static::strlen($command->getName()); |
|
83 | + foreach ($command->getAliases() as $alias) { |
|
84 | + $widths[] = static::strlen($alias); |
|
85 | + } |
|
86 | + } |
|
87 | + |
|
88 | + return $widths ? max($widths) + 2 : 0; |
|
89 | + } |
|
90 | + |
|
91 | + /** |
|
92 | + * Returns the length of a string, using mb_strwidth if it is available. |
|
93 | + * |
|
94 | + * @param string $string The string to check its length |
|
95 | + * |
|
96 | + * @return int The length of the string |
|
97 | + */ |
|
98 | + public static function strlen($string) |
|
99 | + { |
|
100 | + if (false === $encoding = mb_detect_encoding($string, null, true)) { |
|
101 | + return strlen($string); |
|
102 | + } |
|
103 | + |
|
104 | + return mb_strwidth($string, $encoding); |
|
105 | + } |
|
106 | 106 | } |
@@ -53,7 +53,7 @@ |
||
53 | 53 | */ |
54 | 54 | protected function listEpesiCommands() |
55 | 55 | { |
56 | - $commands = collect(Artisan::all())->mapWithKeys(function ($command, $key) { |
|
56 | + $commands = collect(Artisan::all())->mapWithKeys(function($command, $key) { |
|
57 | 57 | if (Str::startsWith($key, 'epesi:')) { |
58 | 58 | return [$key => $command]; |
59 | 59 | } |
@@ -7,13 +7,13 @@ |
||
7 | 7 | |
8 | 8 | class Epesi extends Facade |
9 | 9 | { |
10 | - /** |
|
11 | - * Get the registered name of the component. |
|
12 | - * |
|
13 | - * @return string |
|
14 | - */ |
|
15 | - protected static function getFacadeAccessor() |
|
16 | - { |
|
17 | - return App::class; |
|
18 | - } |
|
10 | + /** |
|
11 | + * Get the registered name of the component. |
|
12 | + * |
|
13 | + * @return string |
|
14 | + */ |
|
15 | + protected static function getFacadeAccessor() |
|
16 | + { |
|
17 | + return App::class; |
|
18 | + } |
|
19 | 19 | } |
@@ -17,9 +17,9 @@ |
||
17 | 17 | { |
18 | 18 | $source = implode(DIRECTORY_SEPARATOR, [static::path(), 'Public']); |
19 | 19 | |
20 | - return is_dir($source)? [ |
|
20 | + return is_dir($source) ? [ |
|
21 | 21 | $source => self::publicPath() |
22 | - ]: []; |
|
22 | + ] : []; |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |