Commit 5fb518d523f332bf9d6c84bc036d92bf965ee4aa

Authored by Volodymyr
1 parent 7dea09c7

tiles ready

backend/controllers/TileController.php
@@ -3,12 +3,29 @@ @@ -3,12 +3,29 @@
3 namespace backend\controllers; 3 namespace backend\controllers;
4 4
5 use common\models\Tile; 5 use common\models\Tile;
  6 +use common\models\TileSearch;
  7 +use Yii;
6 use yii\web\Controller; 8 use yii\web\Controller;
7 use yii\web\NotFoundHttpException; 9 use yii\web\NotFoundHttpException;
8 10
9 class TileController extends Controller 11 class TileController extends Controller
10 { 12 {
11 /** 13 /**
  14 + * Lists all Tile models.
  15 + * @return mixed
  16 + */
  17 + public function actionIndex()
  18 + {
  19 + $searchModel = new TileSearch();
  20 + $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
  21 +
  22 + return $this->render('index', [
  23 + 'searchModel' => $searchModel,
  24 + 'dataProvider' => $dataProvider,
  25 + ]);
  26 + }
  27 +
  28 + /**
12 * Creates a new Tile model. 29 * Creates a new Tile model.
13 * If creation is successful, the browser will be redirected to the 'view' page. 30 * If creation is successful, the browser will be redirected to the 'view' page.
14 * @return mixed 31 * @return mixed
backend/views/layouts/menu_items.php
@@ -111,6 +111,11 @@ @@ -111,6 +111,11 @@
111 'icon' => 'sun-o', 111 'icon' => 'sun-o',
112 ], 112 ],
113 [ 113 [
  114 + 'label' => \Yii::t('core', 'Тайлы'),
  115 + 'url' => ['/tile/index'],
  116 + 'icon' => 'sun-o',
  117 + ],
  118 + [
114 'label' => \Yii::t('core', 'Комментарии'), 119 'label' => \Yii::t('core', 'Комментарии'),
115 'url' => ['/comment/index'], 120 'url' => ['/comment/index'],
116 'icon' => 'sun-o', 121 'icon' => 'sun-o',
backend/views/tile/_form.php 0 → 100755
  1 +<?php
  2 +
  3 + use yii\helpers\Html;
  4 + use yii\widgets\ActiveForm;
  5 + use artbox\core\components\imagemanager\components\ImageManagerInputWidget;
  6 + use artbox\core\widgets\LanguageForm;
  7 +
  8 + /**
  9 + * @var \yii\web\View $this
  10 + * @var \common\models\Objectkb $model
  11 + * @var \common\models\ObjectkbLang[] $modelLangs
  12 + * @var \common\models\Slider[] $sliders
  13 + */
  14 +?>
  15 +
  16 +<div class="objectkb-form">
  17 +
  18 + <?php
  19 + $form = ActiveForm::begin();
  20 + ?>
  21 +
  22 + <?= LanguageForm::widget(
  23 + [
  24 + 'modelLangs' => $modelLangs,
  25 + 'formView' => '@backend/views/tile/_form_language',
  26 + 'form' => $form,
  27 + ]
  28 + ) ?>
  29 +
  30 + <?= $form->field($model, 'sort')
  31 + ->textInput() ?>
  32 +
  33 +
  34 + <?= $form->field($model, 'image_id')
  35 + ->widget(
  36 + ImageManagerInputWidget::className(),
  37 + [
  38 + 'aspectRatio' => ( 16 / 9 ),
  39 + //set the aspect ratio
  40 + 'showPreview' => true,
  41 + //false to hide the preview
  42 + 'showDeletePickedImageConfirm' => false,
  43 + //on true show warning before detach image
  44 + ]
  45 + )
  46 + ?>
  47 +
  48 + <?= $form->field($model, 'status')
  49 + ->checkbox() ?>
  50 +
  51 + <div class="form-group">
  52 + <?= Html::submitButton(
  53 + $model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'),
  54 + [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ]
  55 + ) ?>
  56 + </div>
  57 +
  58 + <?php ActiveForm::end(); ?>
  59 +
  60 +</div>
backend/views/tile/_form_language.php 0 → 100755
  1 +<?php
  2 +
  3 +use artbox\core\models\Language;
  4 +use yii\web\View;
  5 +use yii\widgets\ActiveForm;
  6 +
  7 +/**
  8 + * @var \artbox\core\models\SlideLang $model_lang
  9 + * @var Language $language
  10 + * @var ActiveForm $form
  11 + * @var View $this
  12 + */
  13 +
  14 +$attributeField = $form->field($model_lang, '[' . $language->id . ']title')
  15 + ->textInput(['maxlength' => true]);
  16 +
  17 +echo $attributeField;
  18 +$attributeField2 = $form->field($model_lang, '[' . $language->id . ']link')
  19 + ->textInput(['maxlength' => true]);
  20 +
  21 +echo $attributeField2;
  22 +
  23 +?>
0 \ No newline at end of file 24 \ No newline at end of file
backend/views/tile/_search.php 0 → 100755
  1 +<?php
  2 +
  3 +use yii\helpers\Html;
  4 +use yii\widgets\ActiveForm;
  5 +
  6 +/* @var $this yii\web\View */
  7 +/* @var $model common\models\ObjectkbSearch */
  8 +/* @var $form yii\widgets\ActiveForm */
  9 +?>
  10 +
  11 +<div class="objectkb-search">
  12 +
  13 + <?php $form = ActiveForm::begin([
  14 + 'action' => ['index'],
  15 + 'method' => 'get',
  16 + ]); ?>
  17 +
  18 + <?= $form->field($model, 'id') ?>
  19 +
  20 + <?= $form->field($model, 'slider_id') ?>
  21 +
  22 + <?= $form->field($model, 'status')->checkbox() ?>
  23 +
  24 + <?= $form->field($model, 'sort') ?>
  25 +
  26 + <?= $form->field($model, 'image_mini_id') ?>
  27 +
  28 + <div class="form-group">
  29 + <?= Html::submitButton(Yii::t('app', 'Search'), ['class' => 'btn btn-primary']) ?>
  30 + <?= Html::resetButton(Yii::t('app', 'Reset'), ['class' => 'btn btn-default']) ?>
  31 + </div>
  32 +
  33 + <?php ActiveForm::end(); ?>
  34 +
  35 +</div>
backend/views/tile/create.php 0 → 100755
  1 +<?php
  2 +
  3 +use yii\helpers\Html;
  4 +
  5 + /**
  6 + * @var \yii\web\View $this
  7 + * @var \common\models\Objectkb $model
  8 + * @var \common\models\ObjectkbLang $modelLangs
  9 + * @var \common\models\Slider[] $sliders
  10 + */
  11 +$this->title = Yii::t('app', 'Create Tile');
  12 +$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Tiles'), 'url' => ['index']];
  13 +$this->params['breadcrumbs'][] = $this->title;
  14 +?>
  15 +<div class="objectkb-create">
  16 +
  17 + <h1><?= Html::encode($this->title) ?></h1>
  18 +
  19 + <?= $this->render('_form', [
  20 + 'model' => $model,
  21 + 'modelLangs' => $modelLangs,
  22 + //'sliders' => $sliders,
  23 + ]) ?>
  24 +
  25 +</div>
backend/views/tile/index.php 0 → 100755
  1 +<?php
  2 +
  3 +use yii\helpers\Html;
  4 +use yii\grid\GridView;
  5 +use yii\widgets\Pjax;
  6 +/* @var $this yii\web\View */
  7 +/* @var $searchModel common\models\Tile */
  8 +/* @var $dataProvider yii\data\ActiveDataProvider */
  9 +
  10 +$this->title = Yii::t('app', 'Tiles');
  11 +$this->params['breadcrumbs'][] = $this->title;
  12 +?>
  13 +<div class="objectkb-index">
  14 +
  15 + <h1><?= Html::encode($this->title) ?></h1>
  16 + <?php // echo $this->render('_search', ['model' => $searchModel]); ?>
  17 +
  18 + <p>
  19 + <?= Html::a(Yii::t('app', 'Create Tile'), ['create'], ['class' => 'btn btn-success']) ?>
  20 + </p>
  21 +<?php Pjax::begin(); ?> <?= GridView::widget([
  22 + 'dataProvider' => $dataProvider,
  23 + 'filterModel' => $searchModel,
  24 + 'columns' => [
  25 + ['class' => 'yii\grid\SerialColumn'],
  26 +
  27 + 'id',
  28 + 'status:boolean',
  29 + 'sort',
  30 + 'image_id',
  31 +
  32 + ['class' => 'yii\grid\ActionColumn'],
  33 + ],
  34 + ]); ?>
  35 +<?php Pjax::end(); ?></div>
backend/views/tile/update.php 0 → 100755
  1 +<?php
  2 +
  3 +use yii\helpers\Html;
  4 +
  5 +/**
  6 + * @var $this yii\web\View
  7 + * @var $model common\models\Objectkb
  8 + * @var \common\models\ObjectkbLang $modelLangs
  9 + * @var \common\models\Slider[] $sliders
  10 + */
  11 +
  12 +$this->title = Yii::t('app', 'Update {modelClass}: ', [
  13 + 'modelClass' => 'Objectkb',
  14 +]) . $model->id;
  15 +$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Objectkbs'), 'url' => ['index']];
  16 +$this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]];
  17 +$this->params['breadcrumbs'][] = Yii::t('app', 'Update');
  18 +?>
  19 +<div class="objectkb-update">
  20 +
  21 + <h1><?= Html::encode($this->title) ?></h1>
  22 +
  23 + <?= $this->render('_form', [
  24 + 'model' => $model,
  25 + 'modelLangs' => $modelLangs,
  26 + 'sliders' => $sliders,
  27 + ]) ?>
  28 +
  29 +</div>
backend/views/tile/view.php 0 → 100755
  1 +<?php
  2 +
  3 +use yii\helpers\Html;
  4 +use yii\widgets\DetailView;
  5 +
  6 +/* @var $this yii\web\View */
  7 +/* @var $model common\models\Objectkb */
  8 +
  9 +$this->title = $model->id;
  10 +$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Objectkbs'), 'url' => ['index']];
  11 +$this->params['breadcrumbs'][] = $this->title;
  12 +?>
  13 +<div class="objectkb-view">
  14 +
  15 + <h1><?= Html::encode($this->title) ?></h1>
  16 +
  17 + <p>
  18 + <?= Html::a(Yii::t('app', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
  19 + <?= Html::a(Yii::t('app', 'Delete'), ['delete', 'id' => $model->id], [
  20 + 'class' => 'btn btn-danger',
  21 + 'data' => [
  22 + 'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'),
  23 + 'method' => 'post',
  24 + ],
  25 + ]) ?>
  26 + </p>
  27 +
  28 + <?= DetailView::widget([
  29 + 'model' => $model,
  30 + 'attributes' => [
  31 + 'id',
  32 + 'slider_id',
  33 + 'status:boolean',
  34 + 'sort',
  35 + 'image_mini_id',
  36 + ],
  37 + ]) ?>
  38 +
  39 +</div>
common/models/Tile.php
@@ -28,12 +28,12 @@ class Tile extends ActiveRecord @@ -28,12 +28,12 @@ class Tile extends ActiveRecord
28 public function rules() 28 public function rules()
29 { 29 {
30 return [ 30 return [
31 - [  
32 - [  
33 - 'image',  
34 - ],  
35 - 'required',  
36 - ], 31 +// [
  32 +// [
  33 +// 'image',
  34 +// ],
  35 +// 'required',
  36 +// ],
37 [ 37 [
38 [ 38 [
39 'status', 39 'status',
common/models/TileSearch.php 0 → 100755
  1 +<?php
  2 +
  3 +namespace common\models;
  4 +
  5 +use yii\base\Model;
  6 +use yii\data\ActiveDataProvider;
  7 +
  8 +/**
  9 + * ObjectkbSearch represents the model behind the search form about `common\models\Objectkb`.
  10 + */
  11 +class TileSearch extends Tile
  12 +{
  13 + /**
  14 + * @inheritdoc
  15 + */
  16 + public function rules()
  17 + {
  18 + return [
  19 + [['id', 'sort', 'image_id'], 'integer'],
  20 + [['status'], 'boolean'],
  21 + ];
  22 + }
  23 +
  24 + /**
  25 + * @inheritdoc
  26 + */
  27 + public function scenarios()
  28 + {
  29 + // bypass scenarios() implementation in the parent class
  30 + return Model::scenarios();
  31 + }
  32 +
  33 + public function behaviors()
  34 + {
  35 + return [];
  36 + }
  37 +
  38 + /**
  39 + * Creates data provider instance with search query applied
  40 + *
  41 + * @param array $params
  42 + *
  43 + * @return ActiveDataProvider
  44 + */
  45 + public function search($params)
  46 + {
  47 + $query = Tile::find();
  48 +
  49 + // add conditions that should always apply here
  50 +
  51 + $dataProvider = new ActiveDataProvider([
  52 + 'query' => $query,
  53 + ]);
  54 +
  55 + $this->load($params);
  56 +
  57 + if (!$this->validate()) {
  58 + // uncomment the following line if you do not want to return any records when validation fails
  59 + // $query->where('0=1');
  60 + return $dataProvider;
  61 + }
  62 +
  63 + // grid filtering conditions
  64 + $query->andFilterWhere(
  65 + [
  66 + 'id' => $this->id,
  67 + 'status' => $this->status,
  68 + 'sort' => $this->sort,
  69 + 'image_id' => $this->image_id,
  70 + ]
  71 + );
  72 +
  73 + return $dataProvider;
  74 + }
  75 +}
frontend/controllers/SiteController.php
@@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
6 use common\models\Feedback; 6 use common\models\Feedback;
7 use common\models\Settings; 7 use common\models\Settings;
8 use common\models\Slider; 8 use common\models\Slider;
  9 + use common\models\Tile;
9 use Yii; 10 use Yii;
10 use yii\filters\VerbFilter; 11 use yii\filters\VerbFilter;
11 use yii\swiftmailer\Mailer; 12 use yii\swiftmailer\Mailer;
@@ -55,10 +56,10 @@ @@ -55,10 +56,10 @@
55 public function actionIndex() 56 public function actionIndex()
56 { 57 {
57 58
58 - $slider = Slider::find()  
59 - ->with("slides.lang.image")  
60 - ->where([ 'on_home_page' => true ])  
61 - ->one(); 59 +// $slider = Slider::find()
  60 +// ->with("slides.lang.image")
  61 +// ->where([ 'on_home_page' => true ])
  62 +// ->one();
62 63
63 // $objects = Objectkb::find() 64 // $objects = Objectkb::find()
64 // ->with('lang.alias') 65 // ->with('lang.alias')
@@ -74,6 +75,11 @@ @@ -74,6 +75,11 @@
74 // ) 75 // )
75 // ->orderBy('id') 76 // ->orderBy('id')
76 // ->all(); 77 // ->all();
  78 + $tiles = Tile::find()
  79 + ->with(['lang', 'image'])
  80 + ->limit(4)
  81 + ->all();
  82 +
77 $forCompanies = Objectkb::find() 83 $forCompanies = Objectkb::find()
78 ->with('lang.alias') 84 ->with('lang.alias')
79 ->where( 85 ->where(
@@ -99,10 +105,11 @@ @@ -99,10 +105,11 @@
99 return $this->render( 105 return $this->render(
100 'index', 106 'index',
101 [ 107 [
102 - 'slider' => $slider, 108 + //'slider' => $slider,
103 //'objects' => $objects, 109 //'objects' => $objects,
104 'forCompanies'=>$forCompanies, 110 'forCompanies'=>$forCompanies,
105 - 'forPrivate'=>$forPrivate 111 + 'forPrivate'=>$forPrivate,
  112 + 'tiles'=>$tiles,
106 ] 113 ]
107 ); 114 );
108 } 115 }
frontend/views/site/index.php
@@ -65,44 +65,24 @@ @@ -65,44 +65,24 @@
65 </div> 65 </div>
66 </div> 66 </div>
67 </section> 67 </section>
  68 + <?php if(!empty($tiles)) { ?>
68 <section class="second-about"> 69 <section class="second-about">
69 <div class="container"> 70 <div class="container">
70 <div class="row"> 71 <div class="row">
  72 + <?php foreach ($tiles as $tile) { ?>
71 <div class="col-xs-6 col-sm-6 col-md-3 second-about__col"> 73 <div class="col-xs-6 col-sm-6 col-md-3 second-about__col">
72 <div class="second-about__item"> 74 <div class="second-about__item">
73 - <a href="#">  
74 - <img src="/img/new-index/second-about/second-about-1.jpg" alt="">  
75 - <span><?= \Yii::t('app', 'second-about__item-1') ?></span>  
76 - </a>  
77 - </div>  
78 - </div>  
79 - <div class="col-xs-6 col-sm-6 col-md-3 second-about__col">  
80 - <div class="second-about__item">  
81 - <a href="#">  
82 - <img src="/img/new-index/second-about/second-about-2.jpg" alt="">  
83 - <span><?= \Yii::t('app', 'second-about__item-2') ?></span>  
84 - </a>  
85 - </div>  
86 - </div>  
87 - <div class="col-xs-6 col-sm-6 col-md-3 second-about__col">  
88 - <div class="second-about__item">  
89 - <a href="#">  
90 - <img src="/img/new-index/second-about/second-about-3.jpg" alt="">  
91 - <span><?= \Yii::t('app', 'second-about__item-3') ?></span>  
92 - </a>  
93 - </div>  
94 - </div>  
95 - <div class="col-xs-6 col-sm-6 col-md-3 second-about__col">  
96 - <div class="second-about__item">  
97 - <a href="#">  
98 - <img src="/img/new-index/second-about/second-about-4.jpg" alt="">  
99 - <span><?= \Yii::t('app', 'second-about__item-4') ?></span> 75 + <a href="<?=$tile->lang->link ?>">
  76 + <img src="<?= $tile->image->getImg([]) ?>" alt="">
  77 + <span><?= $tile->lang->title ?></span>
100 </a> 78 </a>
101 </div> 79 </div>
102 </div> 80 </div>
  81 + <?php } ?>
103 </div> 82 </div>
104 </div> 83 </div>
105 </section> 84 </section>
  85 + <?php } ?>
106 <section class="index-solution"> 86 <section class="index-solution">
107 <div class="container"> 87 <div class="container">
108 <div class="row"> 88 <div class="row">
@@ -133,7 +113,7 @@ @@ -133,7 +113,7 @@
133 <table> 113 <table>
134 <tr> 114 <tr>
135 <td>5,0 кВт</td> 115 <td>5,0 кВт</td>
136 - <td> Номінальна потужність мережевого інвертора</td> 116 + <td>Номінальна потужність мережевого інвертора</td>
137 </tr> 117 </tr>
138 <tr> 118 <tr>
139 <td>7,4 кВт</td> 119 <td>7,4 кВт</td>