Commit b427543e93b4f42705b7808d939916e8585d2ca5

Authored by andryeyev
1 parent b507d689

Итерация 2 (рекурсия):

Вставка терминов
.htaccess
... ... @@ -17,12 +17,7 @@
17 17 # the main rewrite rule for the frontend application
18 18 RewriteCond %{REQUEST_URI} !^/(backend/web|admin)
19 19 RewriteRule !^frontend/web /frontend/web%{REQUEST_URI} [L]
20   -
21   - RewriteRule ^admin$ /admin/$1 [R=301,L]
22   -
23   - RewriteCond %{REQUEST_URI} ^/admin/
24   - RewriteRule ^admin(.*) /backend/web/$1 [L,QSA]
25   -
  20 +
26 21 RewriteCond %{REQUEST_URI} ^/frontend/web
27 22 RewriteCond %{REQUEST_FILENAME} !-f
28 23 RewriteCond %{REQUEST_FILENAME} !-d
... ...
backend/config/main.php
... ... @@ -26,14 +26,7 @@ return [
26 26 ],
27 27 'urlManager' => [
28 28 'enablePrettyUrl' => true,
29   - 'showScriptName' => false,
30   - 'rules' => [
31   - '<controller:\w+>/<id:\d+>' => '<controller>/view',
32   - '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
33   - '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
34   - //ïåðåäàåì ïàðàìåòð ñëóã êàê get.
35   - '<controller:\w+>/<action:\w+>/<slug:\w+>' => '<controller>/<action>',
36   - ]
  29 + 'showScriptName' => false,
37 30 ],
38 31 'log' => [
39 32 'traceLevel' => YII_DEBUG ? 3 : 0,
... ...
backend/controllers/Termin_langController.php 0 → 100644
  1 +<?php
  2 +
  3 +namespace backend\controllers;
  4 +
  5 +use Yii;
  6 +use common\models\TerminLang;
  7 +use backend\models\TerminLangSearch;
  8 +use yii\web\Controller;
  9 +use yii\web\NotFoundHttpException;
  10 +use yii\filters\VerbFilter;
  11 +use common\models\Termin;
  12 +use common\models\TerminOption;
  13 +
  14 +/**
  15 + * Termin_langController implements the CRUD actions for TerminLang model.
  16 + */
  17 +class Termin_langController extends Controller
  18 +{
  19 + public function behaviors()
  20 + {
  21 + return [
  22 + 'verbs' => [
  23 + 'class' => VerbFilter::className(),
  24 + 'actions' => [
  25 + 'delete' => ['post'],
  26 + ],
  27 + ],
  28 + ];
  29 + }
  30 +
  31 + /**
  32 + * Lists all TerminLang models.
  33 + * @return mixed
  34 + */
  35 + public function actionIndex()
  36 + {
  37 + $searchModel = new TerminLangSearch();
  38 + $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
  39 +
  40 + return $this->render('index', [
  41 + 'searchModel' => $searchModel,
  42 + 'dataProvider' => $dataProvider,
  43 + ]);
  44 + }
  45 +
  46 + /**
  47 + * Displays a single TerminLang model.
  48 + * @param integer $termin_id
  49 + * @param integer $lang_id
  50 + * @return mixed
  51 + */
  52 + public function actionView($termin_id)
  53 + {
  54 + return $this->render('view', [
  55 + 'model' => $this->findModel($termin_id, $lang_id),
  56 + ]);
  57 + }
  58 +
  59 + /**
  60 + * Creates a new TerminLang model.
  61 + * If creation is successful, the browser will be redirected to the 'view' page.
  62 + * @return mixed
  63 + */
  64 + public function actionCreate()
  65 + {
  66 + $termin = new Termin();
  67 + $termin_lang = new TerminLang();
  68 +
  69 + if ($termin_lang->load(Yii::$app->request->post())) {
  70 +
  71 + $termin->termin_id = '';
  72 + $termin->save();
  73 + $termin_lang->termin_id = $termin->termin_id;
  74 + $termin_lang->save();
  75 +
  76 + return $this->redirect(['index']);
  77 + } else {
  78 + return $this->render('create', [
  79 + 'termin_lang' => $termin_lang,
  80 + 'termin' => $termin,
  81 + ]);
  82 + }
  83 + }
  84 +
  85 + public function actionCreate_parent($termin_id)
  86 + {
  87 + $termin = new Termin();
  88 + $termin_lang = new TerminLang();
  89 + $termin_option = new TerminOption();
  90 +
  91 + if ($termin_lang->load(Yii::$app->request->post())) {
  92 +
  93 + $termin->termin_id = '';
  94 + $termin->save();
  95 + // var_dump($termin->termin_id);die();
  96 + $termin_lang->termin_id = $termin->termin_id;
  97 + $termin_lang->save();
  98 +
  99 + $termin_option->termin_id = $termin->termin_id;
  100 + $termin_option->termin_pid = $termin_id;
  101 + $termin_option->save();
  102 +
  103 +
  104 + return $this->redirect(['index']);
  105 + } else {
  106 + return $this->render('create', [
  107 + 'termin_lang' => $termin_lang,
  108 + 'termin' => $termin,
  109 + ]);
  110 + }
  111 + }
  112 +
  113 + /**
  114 + * Updates an existing TerminLang model.
  115 + * If update is successful, the browser will be redirected to the 'view' page.
  116 + * @param integer $termin_id
  117 + * @param integer $lang_id
  118 + * @return mixed
  119 + */
  120 + public function actionUpdate($termin_id, $lang_id)
  121 + {
  122 + $model = $this->findModel($termin_id, $lang_id);
  123 +
  124 + if ($model->load(Yii::$app->request->post()) && $model->save()) {
  125 + return $this->redirect(['view', 'termin_id' => $model->termin_id, 'lang_id' => $model->lang_id]);
  126 + } else {
  127 + return $this->render('update', [
  128 + 'model' => $model,
  129 + ]);
  130 + }
  131 + }
  132 +
  133 + /**
  134 + * Deletes an existing TerminLang model.
  135 + * If deletion is successful, the browser will be redirected to the 'index' page.
  136 + * @param integer $termin_id
  137 + * @param integer $lang_id
  138 + * @return mixed
  139 + */
  140 + public function actionDelete($termin_id, $lang_id)
  141 + {
  142 + $this->findModel($termin_id, $lang_id)->delete();
  143 +
  144 + return $this->redirect(['index']);
  145 + }
  146 +
  147 + /**
  148 + * Finds the TerminLang model based on its primary key value.
  149 + * If the model is not found, a 404 HTTP exception will be thrown.
  150 + * @param integer $termin_id
  151 + * @param integer $lang_id
  152 + * @return TerminLang the loaded model
  153 + * @throws NotFoundHttpException if the model cannot be found
  154 + */
  155 + protected function findModel($termin_id, $lang_id)
  156 + {
  157 + if (($model = TerminLang::findOne(['termin_id' => $termin_id, 'lang_id' => $lang_id])) !== null) {
  158 + return $model;
  159 + } else {
  160 + throw new NotFoundHttpException('The requested page does not exist.');
  161 + }
  162 + }
  163 +}
... ...
backend/models/TerminLangSearch.php 0 → 100644
  1 +<?php
  2 +
  3 +namespace backend\models;
  4 +
  5 +use Yii;
  6 +use yii\base\Model;
  7 +use yii\data\ActiveDataProvider;
  8 +use common\models\TerminLang;
  9 +
  10 +/**
  11 + * TerminLangSearch represents the model behind the search form about `common\models\TerminLang`.
  12 + */
  13 +class TerminLangSearch extends TerminLang
  14 +{
  15 + /**
  16 + * @inheritdoc
  17 + */
  18 + public function rules()
  19 + {
  20 + return [
  21 + [['termin_id', 'lang_id'], 'integer'],
  22 + [['termin_title'], 'safe'],
  23 + ];
  24 + }
  25 +
  26 + /**
  27 + * @inheritdoc
  28 + */
  29 + public function scenarios()
  30 + {
  31 + // bypass scenarios() implementation in the parent class
  32 + return Model::scenarios();
  33 + }
  34 +
  35 + /**
  36 + * Creates data provider instance with search query applied
  37 + *
  38 + * @param array $params
  39 + *
  40 + * @return ActiveDataProvider
  41 + */
  42 + public function search($params)
  43 + {
  44 + $query = TerminLang::find();
  45 +
  46 + $dataProvider = new ActiveDataProvider([
  47 + 'query' => $query,
  48 + ]);
  49 +
  50 + $this->load($params);
  51 +
  52 + if (!$this->validate()) {
  53 + // uncomment the following line if you do not want to return any records when validation fails
  54 + // $query->where('0=1');
  55 + return $dataProvider;
  56 + }
  57 +
  58 + $query->andFilterWhere([
  59 + 'termin_id' => $this->termin_id,
  60 + 'lang_id' => $this->lang_id,
  61 + ]);
  62 +
  63 + $query->andFilterWhere(['like', 'termin_title', $this->termin_title]);
  64 +
  65 + return $dataProvider;
  66 + }
  67 +}
... ...
backend/views/page/index.php
... ... @@ -20,13 +20,17 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
20 20  
21 21 <?= GridView::widget([
22 22 'dataProvider' => $dataProvider,
23   - 'filterModel' => ['title' => 1],
  23 + 'filterModel' => $searchModel,
  24 + //'filterModel' => ['title' => 1],
24 25 'columns' => [
25   - ['class' => 'yii\grid\SerialColumn'],
  26 +
  27 + ['class' => 'yii\grid\SerialColumn'],
  28 +
26 29 'page_id' ,
27 30 'date_add',
28   - 'title',
  31 + //'title',
29 32 'show',
  33 +
30 34 ['class' => 'yii\grid\ActionColumn'],
31 35 ],
32 36 ]); ?>
... ...
backend/views/termin_lang/_form.php 0 → 100644
  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\TerminLang */
  8 +/* @var $form yii\widgets\ActiveForm */
  9 +?>
  10 +
  11 +<div class="termin-lang-form">
  12 +
  13 + <?php $form = ActiveForm::begin(); ?>
  14 +
  15 + <?= $form->field($termin_lang, 'termin_title')->textInput(['maxlength' => true]) ?>
  16 +
  17 + <div class="form-group">
  18 + <?= Html::submitButton($termin_lang->isNewRecord ? 'Create' : 'Update', ['class' => $termin_lang->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
  19 + </div>
  20 +
  21 + <?php ActiveForm::end(); ?>
  22 +
  23 +</div>
... ...
backend/views/termin_lang/_search.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\helpers\Html;
  4 +use yii\widgets\ActiveForm;
  5 +
  6 +/* @var $this yii\web\View */
  7 +/* @var $model backend\models\TerminLangSearch */
  8 +/* @var $form yii\widgets\ActiveForm */
  9 +?>
  10 +
  11 +<div class="termin-lang-search">
  12 +
  13 + <?php $form = ActiveForm::begin([
  14 + 'action' => ['index'],
  15 + 'method' => 'get',
  16 + ]); ?>
  17 +
  18 + <?= $form->field($model, 'termin_id') ?>
  19 +
  20 + <?= $form->field($model, 'termin_title') ?>
  21 +
  22 + <?= $form->field($model, 'lang_id') ?>
  23 +
  24 + <div class="form-group">
  25 + <?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?>
  26 + <?= Html::resetButton('Reset', ['class' => 'btn btn-default']) ?>
  27 + </div>
  28 +
  29 + <?php ActiveForm::end(); ?>
  30 +
  31 +</div>
... ...
backend/views/termin_lang/create.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\helpers\Html;
  4 +
  5 +
  6 +/* @var $this yii\web\View */
  7 +/* @var $model common\models\TerminLang */
  8 +
  9 +$this->title = 'Create Termin Lang';
  10 +$this->params['breadcrumbs'][] = ['label' => 'Termin Langs', 'url' => ['index']];
  11 +$this->params['breadcrumbs'][] = $this->title;
  12 +?>
  13 +<div class="termin-lang-create">
  14 +
  15 + <h1><?= Html::encode($this->title) ?></h1>
  16 +
  17 + <?= $this->render('_form', [
  18 + 'termin_lang' => $termin_lang,
  19 + 'termin' => $termin,
  20 + ]) ?>
  21 +
  22 +</div>
... ...
backend/views/termin_lang/index.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\helpers\Html;
  4 +use yii\grid\GridView;
  5 +
  6 +/* @var $this yii\web\View */
  7 +/* @var $searchModel backend\models\TerminLangSearch */
  8 +/* @var $dataProvider yii\data\ActiveDataProvider */
  9 +
  10 +$this->title = 'Termin Langs';
  11 +$this->params['breadcrumbs'][] = $this->title;
  12 +?>
  13 +<div class="termin-lang-index">
  14 +
  15 + <h1><?= Html::encode($this->title) ?></h1>
  16 + <?php // echo $this->render('_search', ['model' => $searchModel]); ?>
  17 +
  18 + <p>
  19 + <?= Html::a('Create Termin Lang', ['create'], ['class' => 'btn btn-success']) ?>
  20 + </p>
  21 +
  22 + <?= GridView::widget([
  23 + 'dataProvider' => $dataProvider,
  24 + 'filterModel' => $searchModel,
  25 + 'columns' => [
  26 + ['class' => 'yii\grid\SerialColumn'],
  27 +
  28 + 'termin_id',
  29 + 'termin_title',
  30 + 'lang_id',
  31 +
  32 + [
  33 + 'class' => 'yii\grid\ActionColumn',
  34 + 'template' => '{create} {view} {update} {delete} {create_parent}',
  35 + 'buttons' => [
  36 + 'create_parent' => function ($url, $model, $key) {
  37 + return Html::a('<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>', $url);
  38 + }
  39 + ],
  40 + ],
  41 + ],
  42 + ]); ?>
  43 +
  44 +</div>
... ...
backend/views/termin_lang/update.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\helpers\Html;
  4 +
  5 +/* @var $this yii\web\View */
  6 +/* @var $model common\models\TerminLang */
  7 +
  8 +$this->title = 'Update Termin Lang: ' . ' ' . $model->termin_id;
  9 +$this->params['breadcrumbs'][] = ['label' => 'Termin Langs', 'url' => ['index']];
  10 +$this->params['breadcrumbs'][] = ['label' => $model->termin_id, 'url' => ['view', 'termin_id' => $model->termin_id, 'lang_id' => $model->lang_id]];
  11 +$this->params['breadcrumbs'][] = 'Update';
  12 +?>
  13 +<div class="termin-lang-update">
  14 +
  15 + <h1><?= Html::encode($this->title) ?></h1>
  16 +
  17 + <?= $this->render('_form', [
  18 + 'model' => $model,
  19 + ]) ?>
  20 +
  21 +</div>
... ...
backend/views/termin_lang/view.php 0 → 100644
  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\TerminLang */
  8 +
  9 +$this->title = $model->termin_id;
  10 +$this->params['breadcrumbs'][] = ['label' => 'Termin Langs', 'url' => ['index']];
  11 +$this->params['breadcrumbs'][] = $this->title;
  12 +?>
  13 +<div class="termin-lang-view">
  14 +
  15 + <h1><?= Html::encode($this->title) ?></h1>
  16 +
  17 + <p>
  18 + <?= Html::a('Update', ['update', 'termin_id' => $model->termin_id, 'lang_id' => $model->lang_id], ['class' => 'btn btn-primary']) ?>
  19 + <?= Html::a('Delete', ['delete', 'termin_id' => $model->termin_id, 'lang_id' => $model->lang_id], [
  20 + 'class' => 'btn btn-danger',
  21 + 'data' => [
  22 + 'confirm' => '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 + 'termin_id',
  32 + 'termin_title',
  33 + 'lang_id',
  34 + ],
  35 + ]) ?>
  36 +
  37 +</div>
... ...
common/config/.gitignore deleted
1   -main-local.php
2   -params-local.php
common/config/main-local.php 0 → 100644
  1 +<?php
  2 +return [
  3 + 'components' => [
  4 + 'db' => [
  5 + 'class' => 'yii\db\Connection',
  6 + 'dsn' => 'mysql:host=localhost;dbname=artbox_db',
  7 + 'username' => 'root',
  8 + 'password' => '',
  9 + 'charset' => 'utf8',
  10 + ],
  11 + 'mailer' => [
  12 + 'class' => 'yii\swiftmailer\Mailer',
  13 + 'viewPath' => '@common/mail',
  14 + // send all mails to a file by default. You have to set
  15 + // 'useFileTransport' to false and configure a transport
  16 + // for the mailer to send real emails.
  17 + 'useFileTransport' => true,
  18 + ],
  19 + ],
  20 +];
... ...
common/config/params-local.php 0 → 100644
  1 +<?php
  2 +return [
  3 +];
... ...
common/models/Termin.php
... ... @@ -8,9 +8,6 @@ use Yii;
8 8 * This is the model class for table "termin".
9 9 *
10 10 * @property integer $termin_id
11   - * @property integer $termin_pid
12   - * @property integer $lfr
13   - * @property integer $rgt
14 11 * @property integer $termin_type_id
15 12 * @property integer $page_id
16 13 */
... ... @@ -30,8 +27,7 @@ class Termin extends \yii\db\ActiveRecord
30 27 public function rules()
31 28 {
32 29 return [
33   - [['termin_pid', 'lfr', 'rgt', 'termin_type_id', 'page_id'], 'integer'],
34   - [['lfr', 'rgt', 'termin_type_id'], 'required']
  30 + [['termin_type_id', 'page_id'], 'integer']
35 31 ];
36 32 }
37 33  
... ... @@ -42,9 +38,6 @@ class Termin extends \yii\db\ActiveRecord
42 38 {
43 39 return [
44 40 'termin_id' => 'Termin ID',
45   - 'termin_pid' => 'Termin Pid',
46   - 'lfr' => 'Lfr',
47   - 'rgt' => 'Rgt',
48 41 'termin_type_id' => 'Termin Type ID',
49 42 'page_id' => 'Page ID',
50 43 ];
... ...
common/models/TerminLang.php 0 → 100644
  1 +<?php
  2 +
  3 +namespace common\models;
  4 +
  5 +use Yii;
  6 +
  7 +/**
  8 + * This is the model class for table "termin_lang".
  9 + *
  10 + * @property integer $termin_id
  11 + * @property string $termin_title
  12 + * @property integer $lang_id
  13 + */
  14 +class TerminLang extends \yii\db\ActiveRecord
  15 +{
  16 + /**
  17 + * @inheritdoc
  18 + */
  19 + public static function tableName()
  20 + {
  21 + return 'termin_lang';
  22 + }
  23 +
  24 + /**
  25 + * @inheritdoc
  26 + */
  27 + public function rules()
  28 + {
  29 + return [
  30 + //[['termin_id', 'lang_id'], 'required'],
  31 + //[['termin_id', 'lang_id'], 'integer'],
  32 + [['termin_title'], 'string', 'max' => 256]
  33 + ];
  34 + }
  35 +
  36 + /**
  37 + * @inheritdoc
  38 + */
  39 + public function attributeLabels()
  40 + {
  41 + return [
  42 + 'termin_id' => 'Termin ID',
  43 + 'termin_title' => 'Termin Title',
  44 + 'lang_id' => 'Lang ID',
  45 + ];
  46 + }
  47 +}
... ...
common/models/TerminOption.php 0 → 100644
  1 +<?php
  2 +
  3 +namespace common\models;
  4 +
  5 +use Yii;
  6 +
  7 +/**
  8 + * This is the model class for table "termin_option".
  9 + *
  10 + * @property integer $termin_id
  11 + * @property integer $termin_pid
  12 + * @property integer $sortorder
  13 + */
  14 +class TerminOption extends \yii\db\ActiveRecord
  15 +{
  16 + /**
  17 + * @inheritdoc
  18 + */
  19 + public static function tableName()
  20 + {
  21 + return 'termin_option';
  22 + }
  23 +
  24 + /**
  25 + * @inheritdoc
  26 + */
  27 + public function rules()
  28 + {
  29 + return [
  30 + //[['termin_id', 'termin_pid', 'sortorder'], 'required'],
  31 + [['termin_id', 'termin_pid', 'sortorder'], 'integer']
  32 + ];
  33 + }
  34 +
  35 + /**
  36 + * @inheritdoc
  37 + */
  38 + public function attributeLabels()
  39 + {
  40 + return [
  41 + 'termin_id' => 'Termin ID',
  42 + 'termin_pid' => 'Termin Pid',
  43 + 'sortorder' => 'Sortorder',
  44 + ];
  45 + }
  46 +}
... ...
vendor/dmstr/yii2-adminlte-asset/example-views/yiisoft/yii2-app/layouts/header.php
... ... @@ -264,7 +264,7 @@ $username = Yii::$app-&gt;user-&gt;identity-&gt;firstname.&#39; &#39;.Yii::$app-&gt;user-&gt;identity-&gt;
264 264 <!-- Menu Footer-->
265 265 <li class="user-footer">
266 266 <div class="pull-left">
267   - <a href="<?=Url::toRoute('profile'); ?>" class="btn btn-default btn-flat">Profile</a>
  267 + <a href="<?=Url::toRoute('site/profile'); ?>" class="btn btn-default btn-flat">Profile</a>
268 268 </div>
269 269 <div class="pull-right">
270 270 <?= Html::a(
... ...
vendor/dmstr/yii2-adminlte-asset/example-views/yiisoft/yii2-app/layouts/left.php
... ... @@ -32,6 +32,7 @@
32 32 'items' => [
33 33 ['label' => 'Page', 'icon' => 'fa fa-file-code-o', 'url' => ['/page/']],
34 34 ['label' => 'Termin', 'icon' => 'fa fa-file-code-o', 'url' => ['/termin/']],
  35 + ['label' => 'Termin Lang', 'icon' => 'fa fa-file-code-o', 'url' => ['/termin_lang/']],
35 36 ['label' => 'Menu', 'icon' => 'fa fa-file-code-o', 'url' => ['/menu/']],
36 37 ['label' => 'Gii', 'icon' => 'fa fa-file-code-o', 'url' => ['/gii']],
37 38 ['label' => 'Debug', 'icon' => 'fa fa-dashboard', 'url' => ['/debug']],
... ...