1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace hiqdev\thememanager\debug; |
4
|
|
|
|
5
|
|
|
use Yii; |
6
|
|
|
use yii\base\ViewContextInterface; |
7
|
|
|
use yii\helpers\ArrayHelper; |
8
|
|
|
|
9
|
|
|
class Panel extends \yii\debug\Panel implements ViewContextInterface |
10
|
|
|
{ |
11
|
|
|
use \hiqdev\thememanager\GetManagerTrait; |
12
|
|
|
|
13
|
|
|
protected $_viewPath; |
14
|
|
|
|
15
|
|
|
public function setViewPath($value) |
16
|
|
|
{ |
17
|
|
|
$this->_viewPath = $value; |
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
public function getViewPath() |
21
|
|
|
{ |
22
|
|
|
if ($this->_viewPath === null) { |
23
|
|
|
$this->_viewPath = dirname(__DIR__) . '/views/debug'; |
24
|
|
|
} |
25
|
|
|
return $this->_viewPath; |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @inheritdoc |
30
|
|
|
*/ |
31
|
|
|
public function getName() |
32
|
|
|
{ |
33
|
|
|
return 'Themes'; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @inheritdoc |
38
|
|
|
*/ |
39
|
|
|
public function getSummary() |
40
|
|
|
{ |
41
|
|
|
return Yii::$app->view->render('summary', ['panel' => $this], $this); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @inheritdoc |
46
|
|
|
*/ |
47
|
|
|
public function getDetail() |
48
|
|
|
{ |
49
|
|
|
return Yii::$app->view->render('detail', ['panel' => $this], $this); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
public function getThemes() |
53
|
|
|
{ |
54
|
|
|
return isset($this->data['themes']) ? $this->data['themes'] : []; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public function getCount() |
58
|
|
|
{ |
59
|
|
|
return count($this->getThemes()); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function getCurrent() |
63
|
|
|
{ |
64
|
|
|
return isset($this->data['current']) ? $this->data['current'] : ''; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
public function getDefault() |
68
|
|
|
{ |
69
|
|
|
return isset($this->data['default']) ? $this->data['default'] : ''; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @inheritdoc |
74
|
|
|
*/ |
75
|
|
|
public function save() |
76
|
|
|
{ |
77
|
|
|
$raw = $this->getManager()->getItems(); |
78
|
|
|
$themes = ArrayHelper::toArray($raw); |
79
|
|
|
foreach ($raw as $name => $theme) { |
80
|
|
|
$themes[$name]['class'] = get_class($theme); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
return [ |
84
|
|
|
'themes' => $themes, |
85
|
|
|
'current' => $this->getManager()->getTheme()->name, |
86
|
|
|
'default' => $this->getManager()->getDefaultTheme(), |
87
|
|
|
]; |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
|