Commit ae88099eeb9a2ba0e98b48dc2e6221b74949f08d

Authored by OlenaKl
2 parents f0e0b86f e9398092

Merge remote-tracking branch 'origin/master'

backend/components/base/BaseController.php
... ... @@ -85,19 +85,19 @@ class BaseController extends Controller {
85 85  
86 86 if(!empty($old_img) && file_exists($_SERVER['DOCUMENT_ROOT'].$old_img)){
87 87  
88   - $rootDir = explode("/", $old_img);
89   -
90   - $row = $_SERVER['DOCUMENT_ROOT'].'/'.$rootDir[1].'/'.$rootDir[2].'/';
91   -
92   - $allFiles = scandir($row);
93   -
94   - $allFiles = array_slice($allFiles, 2);
95   -
96   - foreach($allFiles as $oldFile){
97   -
98   - unlink($row.$oldFile);
99   -
100   - }
  88 +// $rootDir = explode("/", $old_img);
  89 +//
  90 +// $row = $_SERVER['DOCUMENT_ROOT'].'/'.$rootDir[1].'/'.$rootDir[2].'/';
  91 +//
  92 +// $allFiles = scandir($row);
  93 +//
  94 +// $allFiles = array_slice($allFiles, 2);
  95 +//
  96 +// foreach($allFiles as $oldFile){
  97 +//
  98 +// unlink($row.$oldFile);
  99 +//
  100 +// }
101 101  
102 102 }
103 103 }
... ...
backend/views/page/view.php
... ... @@ -31,7 +31,7 @@ $this->params['breadcrumbs'][] = $this->title;
31 31 'id',
32 32 'name',
33 33 'code',
34   - 'content:ntext',
  34 + 'content:html',
35 35 'sort',
36 36 'title',
37 37 'kwords',
... ...
backend/views/team/_form.php
... ... @@ -19,7 +19,16 @@ use \common\models\TeamGroup;
19 19 <?= $form->field($model, 'group_id')->dropDownList(ArrayHelper::map(TeamGroup::find()->all(), 'id', 'name'), ['prompt' => 'Выберие группу']) ?>
20 20 <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
21 21  
22   - <?= $form->field($model, 'img')->textInput(['maxlength' => true]) ?>
  22 +
  23 + <?= \backend\components\ImageUploader::widget([
  24 + 'model'=> $model,
  25 + 'field'=>'img',
  26 + 'width'=>120,
  27 + 'height'=>120,
  28 + 'multi'=>false,
  29 + 'gallery' =>$model->img,
  30 + 'name' => 'Загрузить картинку'
  31 + ]); ?>
23 32  
24 33 <?= $form->field($model, 'phone')->textInput(['maxlength' => true]) ?>
25 34  
... ...
frontend/config/main.php
... ... @@ -41,9 +41,9 @@ return [
41 41 'enablePrettyUrl' => true,
42 42 'showScriptName' => false,
43 43 'rules' => [
44   - 'news/<page:\d+>' => 'news/index',
  44 + 'news/<translit:\d+>' => 'news/view',
45 45 'news' => 'news/index',
46   - 'page/<translit:[\w-]+>'=>'page/show',
  46 + 'page/<translit:[\w-]+>'=>'page/view',
47 47 'goods/one-item/<translit:[\w-]+>'=>'goods/one-item',
48 48 'goods/view/<translit:[\w-]+>'=>'goods/view',
49 49 'stone/view/<translit:[\w-]+>'=>'stone/view',
... ...
frontend/controllers/PageController.php 0 → 100644
  1 +<?php
  2 +namespace frontend\controllers;
  3 +
  4 +
  5 +use common\models\Page;
  6 +use Yii;
  7 +use yii\data\ActiveDataProvider;
  8 +use yii\web\Controller;
  9 +use yii\web\NotFoundHttpException;
  10 +
  11 +
  12 +/**
  13 + * Site controller
  14 + */
  15 +class PageController extends Controller
  16 +{
  17 + public $layout = '/internal';
  18 +
  19 + public function actionIndex()
  20 + {
  21 + $dataProvider = new ActiveDataProvider([
  22 + 'query' => Page::find()->where(['is_active'=>1]),
  23 + 'pagination' => [
  24 + 'pageSize' => 16,
  25 + ],
  26 +
  27 + ]);
  28 + return $this->render('index',[
  29 + 'dataProvider' => $dataProvider
  30 + ]);
  31 + }
  32 +
  33 + public function actionView($translit)
  34 + {
  35 +
  36 + return $this->render('view', [
  37 + 'model' => $this->findModel($translit),
  38 + ]);
  39 + }
  40 +
  41 + protected function findModel($translit)
  42 + {
  43 +
  44 + if (($model = Page::findOne(["code"=>$translit])) !== null) {
  45 + return $model;
  46 + } else {
  47 + throw new NotFoundHttpException('The requested page does not exist.');
  48 + }
  49 + }
  50 +}
... ...
frontend/views/layouts/main.php
... ... @@ -41,11 +41,11 @@ use yii\captcha\Captcha;
41 41 echo Menu::widget([
42 42 'items' => [
43 43 ['label' => 'О компании', 'url'=>Url::toRoute('/site/about')],
44   - ['label' => 'Каталоги', 'url'=>'/page/FAQ'],
45   - ['label' => 'Оптовикам','url'=>'/site/wholesalers'],
46   - ['label' => 'Поставщикам','url'=>'/site/provider'],
47   - ['label' => 'Оплата и доставка', 'url'=>Url::toRoute('/site/payment-delivery')],
48   - ['label' => 'Контакты', 'url'=>Url::toRoute('/site/contacts')],
  44 + ['label' => 'Каталоги', 'url'=>'#'],//Url::toRoute('/page/FAQ')],
  45 + ['label' => 'Оптовикам','url'=>Url::toRoute(['/page/view','translit'=>'optovikam'])],
  46 + ['label' => 'Поставщикам','url'=>Url::toRoute(['/page/view','translit'=>'suppliers'])],
  47 + ['label' => 'Оплата и доставка', 'url'=>Url::toRoute(['/page/view','translit'=>'pay4delivery'])],
  48 + ['label' => 'Контакты', 'url'=>Url::toRoute(['/page/view','translit'=>'contacts'])],
49 49 ],
50 50 ]);
51 51 ?>
... ...
frontend/views/page/show.php deleted
1   -<?php
2   -$this->registerMetaTag(['description' => $page->descr,'keywords'=>$page->kwords]);
3   -$this->title = $page->title ? $page->title: $page->name;
4   -$this->params['breadcrumbs'][] = $this->title;
5   -echo $page->content;
6 0 \ No newline at end of file
frontend/views/page/view.php 0 → 100644
  1 +<?php
  2 +$this->registerMetaTag(['description' => $model->descr,'keywords'=>$model->kwords]);
  3 +$this->title = $model->title ? $model->title: $model->name;
  4 +$this->params['breadcrumbs'][] = $this->title;
  5 +
  6 +?>
  7 +<div class="main-vin">
  8 +
  9 + <p class="vin_article"><?=$this->title?></p>
  10 +
  11 + <div class="choose_tovar">
  12 + <?= $model->content;?>
  13 + </div>
  14 +
  15 +</div>
0 16 \ No newline at end of file
... ...