1+ <?php
2+ /**
3+ * @author Semenov Alexander <[email protected] > 4+ * @link http://skeeks.com/
5+ * @copyright 2010 SkeekS (СкикС)
6+ * @date 17.04.2016
7+ */
8+ namespace skeeks \cms \view ;
9+ use skeeks \cms \base \Component ;
10+ use yii \helpers \ArrayHelper ;
11+ use yii \widgets \ActiveForm ;
12+
13+ /**
14+ * Class ViewComponentSettings
15+ * @package skeeks\cms\view
16+ */
17+ class ViewComponentSettings extends Component
18+ {
19+ public $ theme = '' ;
20+
21+ static public function descriptorConfig ()
22+ {
23+ return ArrayHelper::merge (parent ::descriptorConfig (), [
24+ 'name ' => \Yii::t ('skeeks/view ' , 'Template ' )
25+ ]);
26+ }
27+
28+ public function rules ()
29+ {
30+ return ArrayHelper::merge (parent ::rules (), [
31+ [['theme ' ], 'string ' ],
32+ ]);
33+ }
34+
35+ public function attributeLabels ()
36+ {
37+ return ArrayHelper::merge (parent ::attributeLabels (), [
38+ 'theme ' => \Yii::t ('skeeks/view ' , 'Theme ' ),
39+ ]);
40+ }
41+
42+ public function renderConfigForm (ActiveForm $ form )
43+ {
44+ $ themes = [];
45+ if (\Yii::$ app ->view instanceof ViewComponent && \Yii::$ app ->view ->themes )
46+ {
47+ foreach (\Yii::$ app ->view ->themes as $ code => $ data )
48+ {
49+ if (!$ code || !is_string ($ code ))
50+ {
51+ continue ;
52+ }
53+
54+ $ name = ArrayHelper::getValue ((array ) $ data , 'name ' );
55+ $ themes [$ code ] = $ name ? $ name : $ code ;
56+ }
57+ }
58+
59+ if ($ themes )
60+ {
61+ echo $ form ->field ($ this , 'theme ' )->listBox ($ themes );
62+ } else
63+ {
64+ echo \Yii::t ('skeeks/view ' , 'There are no customizable themes in the project ' );
65+ }
66+ }
67+
68+ }
0 commit comments