Skip to content

Commit 696fcc9

Browse files
init
1 parent 37fd355 commit 696fcc9

File tree

9 files changed

+299
-0
lines changed

9 files changed

+299
-0
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CHANGELOG
2+
==============
3+
4+
1.0.0-alpha
5+
-----------------
6+
* Can be used

README.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
Agents for SkeekS CMS
2+
===================================
3+
4+
Installation
5+
------------
6+
7+
The preferred way to install this extension is through [composer](http://getcomposer.org/download/).
8+
9+
Either run
10+
11+
```
12+
php composer.phar require --prefer-dist skeeks/cms-view "*"
13+
```
14+
15+
or add
16+
17+
```
18+
"skeeks/cms-view": "*"
19+
```
20+
21+
Configuration app
22+
----------
23+
24+
```php
25+
26+
'components' =>
27+
[
28+
'view' =>
29+
[
30+
'class' => 'skeeks\cms\view\ViewComponent'
31+
],
32+
33+
'viewSettings' =>
34+
[
35+
'class' => 'skeeks\cms\view\ViewComponentSettings'
36+
],
37+
38+
'i18n' => [
39+
'translations' =>
40+
[
41+
'skeeks/view' => [
42+
'class' => 'yii\i18n\PhpMessageSource',
43+
'basePath' => '@skeeks/cms/view/messages',
44+
'fileMap' => [
45+
'skeeks/view' => 'main.php',
46+
],
47+
]
48+
]
49+
],
50+
]
51+
52+
```
53+
54+
___
55+
56+
> [![skeeks!](https://gravatar.com/userimage/74431132/13d04d83218593564422770b616e5622.jpg)](http://skeeks.com)
57+
<i>SkeekS CMS (Yii2) — quickly, easily and effectively!</i>
58+
[skeeks.com](http://skeeks.com) | [en.cms.skeeks.com](http://en.cms.skeeks.com) | [cms.skeeks.com](http://cms.skeeks.com) | [marketplace.cms.skeeks.com](http://marketplace.cms.skeeks.com)
59+
60+

ThemeComponent.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
/**
3+
* @author Semenov Alexander <semenov@skeeks.com>
4+
* @link http://skeeks.com/
5+
* @copyright 2010 SkeekS (СкикС)
6+
* @date 17.04.2016
7+
*/
8+
namespace skeeks\cms\view;
9+
10+
use yii\base\Theme;
11+
/**
12+
* Class ThemeComponent
13+
* @package skeeks\cms\view
14+
*/
15+
class ThemeComponent extends Theme
16+
{
17+
public $name = "Theme name";
18+
}

ViewComponent.php

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php
2+
/**
3+
* @author Semenov Alexander <semenov@skeeks.com>
4+
* @link http://skeeks.com/
5+
* @copyright 2010 SkeekS (СкикС)
6+
* @date 17.04.2016
7+
*/
8+
namespace skeeks\cms\view;
9+
10+
use yii\helpers\ArrayHelper;
11+
use yii\web\View;
12+
13+
/**
14+
* Class ViewComponent
15+
* @package skeeks\cms\view
16+
*/
17+
class ViewComponent extends View
18+
{
19+
/**
20+
* @var array Availables app themes
21+
*/
22+
public $themes = [
23+
/*'one' =>
24+
[
25+
'class' => 'skeeks\cms\view\ThemeComponent',
26+
'name' => 'Default',
27+
'pathMap' =>
28+
[
29+
'@app/views' =>
30+
[
31+
'@app/templates/one',
32+
'@app/templates/default',
33+
],
34+
]
35+
]*/
36+
];
37+
38+
public function init()
39+
{
40+
if (!$this->themes)
41+
{
42+
return parent::init();
43+
}
44+
45+
if (!\Yii::$app->viewSettings->theme)
46+
{
47+
return parent::init();
48+
}
49+
50+
if (!$themeData = ArrayHelper::getValue($this->themes, \Yii::$app->viewSettings->theme))
51+
{
52+
return parent::init();
53+
}
54+
55+
if (!isset($themeData['class']))
56+
{
57+
$themeData['class'] = 'skeeks\cms\view\ThemeComponent';
58+
}
59+
60+
$this->theme = $themeData;
61+
62+
return parent::init();
63+
}
64+
}

ViewComponentSettings.php

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?php
2+
/**
3+
* @author Semenov Alexander <semenov@skeeks.com>
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+
}

_ide/YiiApplication.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
/**
3+
*
4+
* The pseudo-only IDE tips
5+
*
6+
* @author Semenov Alexander <semenov@skeeks.com>
7+
* @link http://skeeks.com/
8+
* @copyright 2010 SkeekS (СкикС)
9+
* @date 10.09.2015
10+
*/
11+
namespace yii\web;
12+
use skeeks\cms\view\ViewComponent;
13+
use skeeks\cms\view\ViewComponentSettings;
14+
15+
/**
16+
* @property ViewComponent|View $view
17+
* @property ViewComponentSettings $viewSettings
18+
19+
* Class Application
20+
* @package yii\web
21+
*/
22+
class Application
23+
{}

composer.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"name": "skeeks/cms-view",
3+
"description": "View for SkeekS CMS",
4+
"keywords": ["yii", "skeeks", "framework", "component", "view"],
5+
"homepage": "http://cms.skeeks.com/",
6+
"type": "yii2-extension",
7+
"license": "BSD-3-Clause",
8+
"support": {
9+
"issues": "http://skeeks.com/",
10+
"wiki": "http://en.cms.skeeks.com/docs/",
11+
"source": "https://github.com/skeeks-cms/cms-view"
12+
},
13+
"authors": [
14+
{
15+
"name": "Semenov Alexander",
16+
"email": "semenov@skeeks.com"
17+
}
18+
],
19+
"require": {
20+
"skeeks/cms": "*"
21+
},
22+
"autoload": {
23+
"psr-4": {
24+
"skeeks\\cms\\view\\": ""
25+
}
26+
}
27+
}

config/main.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
return [
3+
'components' =>
4+
[
5+
'view' =>
6+
[
7+
'class' => 'skeeks\cms\view\ViewComponent'
8+
],
9+
10+
'viewSettings' =>
11+
[
12+
'class' => 'skeeks\cms\view\ViewComponentSettings'
13+
],
14+
15+
'i18n' => [
16+
'translations' =>
17+
[
18+
'skeeks/view' => [
19+
'class' => 'yii\i18n\PhpMessageSource',
20+
'basePath' => '@skeeks/cms/view/messages',
21+
'fileMap' => [
22+
'skeeks/view' => 'main.php',
23+
],
24+
]
25+
]
26+
],
27+
]
28+
];

messages/ru/main.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
return [
3+
'Template' => 'Шаблон',
4+
'There are no customizable themes in the project' => 'Нет доступных настраиваемых тем в проекте',
5+
];

0 commit comments

Comments
 (0)