-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathPlugin.php
More file actions
78 lines (65 loc) · 2.03 KB
/
Plugin.php
File metadata and controls
78 lines (65 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php namespace Uxms\Backendstyle;
use App;
use File;
use Lang;
use Event;
use Flash;
use Config;
use Backend;
use Request;
use Redirect;
use Backend\Classes\Controller;
use Backend\Models\BrandSetting;
use System\Classes\PluginBase;
class Plugin extends PluginBase
{
public function pluginDetails()
{
return [
'name' => 'uxms.backendstyle::lang.app.name',
'description' => 'uxms.backendstyle::lang.app.desc',
'author' => 'uXMs Devs',
'icon' => 'icon-object-group',
'homepage' => 'https://uxms.net/'
];
}
public function boot()
{
if (!App::runningInBackend())
return;
Event::listen('backend.page.beforeDisplay', function($controller, $action, $params) {
$appUrl = Config::get('app.url');
if (Request::secure()) {
$appUrl = preg_replace(
"/^http:/i",
"https:",
Config::get('app.url')
);
}
$controller->addJs($appUrl.'/plugins/uxms/backendstyle/assets/changer.js');
$controller->addCss($appUrl.'/plugins/uxms/backendstyle/assets/changer.css');
});
Controller::extend(function($controller) {
$controller->addDynamicMethod('onChangeSkin', function() {
return $this->onChangeSkin();
});
});
}
/**
* Changes backend skin with predefined stylesheets
*
* @return [type] [description]
*/
public function onChangeSkin()
{
$whichSkinSelected = post('skin');
$style = '';
if ($whichSkinSelected <> 'default') {
$selectedSkinfile = plugins_path()."/uxms/backendstyle/assets/stylesheets/$whichSkinSelected.css";
$style = File::get($selectedSkinfile);
}
BrandSetting::set('custom_css', $style);
Flash::success(Lang::get('uxms.backendstyle::lang.app.success'));
return Redirect::refresh();
}
}