Commit ac4eea2ed47b80860e600a18b7659c22658e6d2b

Authored by Anastasia
1 parent c89a0fd9

- frontend events

frontend/controllers/EventController.php 0 → 100755
  1 +<?php
  2 +
  3 + namespace frontend\controllers;
  4 +
  5 + use common\models\event\Event;
  6 + use common\models\event\Tag;
  7 + use yii\data\ActiveDataProvider;
  8 + use yii\web\Controller;
  9 + use yii\web\NotFoundHttpException;
  10 +
  11 + /**
  12 + * Class BlogController
  13 + *
  14 + * @package frontend\controllers
  15 + */
  16 + class EventController extends Controller
  17 + {
  18 + public function actionIndex($q = '')
  19 + {
  20 + $tags = Tag::find()
  21 + ->with(
  22 + [
  23 + 'language',
  24 + ]
  25 + )
  26 + ->orderBy([ 'sort' => SORT_ASC ])
  27 + ->all();
  28 +
  29 +
  30 + $dataProvider = new ActiveDataProvider(
  31 + [
  32 + 'query' => Event::find()
  33 + ->orderBy(
  34 + [
  35 + 'created_at' => SORT_DESC,
  36 + ]
  37 + )
  38 + ->joinWith('language')
  39 + ->where([ 'event.status' => true ])
  40 + ->andFilterWhere(
  41 + [
  42 + 'ilike',
  43 + 'event_lang.title',
  44 + $q,
  45 + ]
  46 + )
  47 + ->distinct(),
  48 + 'pagination' => [
  49 + 'pageSize' => 3,
  50 + ],
  51 + ]
  52 + );
  53 +
  54 + return $this->render(
  55 + 'index',
  56 + [
  57 + 'tags' => $tags,
  58 + 'dataProvider' => $dataProvider,
  59 + ]
  60 + );
  61 + }
  62 +
  63 + public function actionView($id)
  64 + {
  65 + $model = $this->findModel($id);
  66 +
  67 + $tags = Tag::find()
  68 + ->with([ 'language' ])
  69 + ->orderBy([ 'sort' => SORT_ASC ])
  70 + ->all();
  71 +
  72 + return $this->render(
  73 + 'view',
  74 + [
  75 + 'tags' => $tags,
  76 + 'model' => $model,
  77 + ]
  78 + );
  79 + }
  80 +
  81 +
  82 + public function actionTag($id)
  83 + {
  84 + $tags = Tag::find()
  85 + ->with(
  86 + [
  87 + 'language',
  88 + ]
  89 + )
  90 + ->orderBy([ 'sort' => SORT_ASC ])
  91 + ->all();
  92 +
  93 + $model = Tag::find()
  94 + ->where(
  95 + [
  96 + 'id' => $id,
  97 + ]
  98 + )
  99 + ->with(
  100 + [
  101 + 'articles',
  102 + ]
  103 + )
  104 + ->one();
  105 +
  106 + $dataProvider = new ActiveDataProvider(
  107 + [
  108 + 'query' => $model->getEvents()
  109 + ->with(
  110 + [
  111 + 'language',
  112 + ]
  113 + )
  114 + ->where(['event.status' => true])
  115 + ->orderBy(
  116 + [
  117 + 'created_at' => SORT_DESC,
  118 + ]
  119 + ),
  120 + 'pagination' => [
  121 + 'pageSize' => 3,
  122 + ],
  123 + ]
  124 + );
  125 +
  126 + return $this->render(
  127 + 'tag',
  128 + [
  129 + 'tags' => $tags,
  130 + 'dataProvider' => $dataProvider,
  131 + 'model' => $model,
  132 + ]
  133 + );
  134 + }
  135 +
  136 + /**
  137 + * @param $id
  138 + *
  139 + * @return Event
  140 + * @throws \yii\web\NotFoundHttpException
  141 + */
  142 + protected function findModel($id)
  143 + {
  144 + /**
  145 + * @var Event | null $model
  146 + */
  147 + $model = Event::find()
  148 + ->where([ 'id' => $id ])
  149 + ->with(
  150 + [
  151 + 'language',
  152 + 'tags.language',
  153 + ]
  154 + )
  155 + ->andWhere([ 'status' => true ])
  156 + ->one();
  157 +
  158 + if (empty($model)) {
  159 + throw new NotFoundHttpException(\Yii::t('app', 'Article not found'));
  160 + } else {
  161 + return $model;
  162 + }
  163 + }
  164 + }
0 165 \ No newline at end of file
... ...
frontend/views/event/_event.php 0 → 100755
  1 +<?php
  2 +
  3 + use artbox\core\helpers\ImageHelper;
  4 + use yii\bootstrap\Html;
  5 + use artbox\core\helpers\Url;
  6 +
  7 + /**
  8 + * @var \common\models\blog\Article $model
  9 + */
  10 +
  11 +?>
  12 +
  13 +<section class="post">
  14 + <div class="row">
  15 + <div class="col-xs-4 col-sm-4 col-md-4">
  16 + <div class="image">
  17 + <a href="<?= Url::to(
  18 + [
  19 + 'alias' => $model->alias
  20 + ]
  21 + ) ?>">
  22 + <?= ImageHelper::set($model->image ? $model->image->getPath() : '@frontend/web/img/no-image.png')
  23 + ->cropResize(263, 197)
  24 + ->renderImage(
  25 + [
  26 + 'class' => 'img-responsive',
  27 + 'alt' => $model->title,
  28 + ]
  29 + ) ?>
  30 + </a>
  31 + </div>
  32 + </div>
  33 + <div class="col-xs-8 col-sm-8 col-md-8">
  34 + <h2><a href="<?= Url::to(
  35 + [
  36 + 'alias' => $model->alias
  37 + ]
  38 + ) ?>"><?= $model->title; ?></a></h2>
  39 + <div class="clearfix">
  40 + <?php if (empty($model->categories)) { ?>
  41 + <p class="author-category">Без категории </p>
  42 + <?php } else {
  43 + $i = 0;
  44 + foreach ($model->categories as $category) {
  45 + $i++;
  46 + ?>
  47 + <p class="author-category">
  48 + <a href="<?=Url::to(['alias' => $category->alias])?>"><?=$category->title?></a>
  49 + <?php
  50 +
  51 + if ($i === count($model->categories)) {
  52 + echo '&#160';
  53 + } else {
  54 + echo '&#44&#160';
  55 + }
  56 + ?></p>
  57 + <?php
  58 + }
  59 + } ?>
  60 + <p class="date-comments">
  61 + <i class="fa fa-calendar-o"></i> <?= \Yii::$app->formatter->asDate($model->created_at); ?>
  62 + <!-- <a href="blog-post.html"><i class="fa fa-comment-o"></i> 8 комментариев</a>-->
  63 + </p>
  64 + </div>
  65 + <p class="intro"><?= $model->body_preview; ?></p>
  66 + <p class="read-more">
  67 + <?= Html::a(
  68 + 'Продолжить чтение',
  69 + [
  70 + '', 'alias' => $model->alias
  71 + ],
  72 + [
  73 + 'class' => 'btn btn-template-main',
  74 + ]
  75 + ) ?>
  76 + </p>
  77 + </div>
  78 + </div>
  79 +</section>
... ...
frontend/views/event/index.php 0 → 100755
  1 +<?php
  2 +
  3 + use artbox\core\components\SeoComponent;
  4 + use yii\data\ActiveDataProvider;
  5 + use artbox\core\helpers\Url;
  6 + use yii\web\View;
  7 + use yii\widgets\ListView;
  8 +
  9 + /**
  10 + * @var View $this
  11 + * @var ActiveDataProvider $dataProvider
  12 + * @var SeoComponent $seo
  13 + * @var \common\models\event\Tag[] $tags
  14 + */
  15 + $seo = \Yii::$app->get('seo');
  16 +
  17 + $this->params[ 'breadcrumbs' ][] = \Yii::t('app', 'Events');
  18 +
  19 +?>
  20 +
  21 +<div id="content">
  22 + <div class="container">
  23 + <div class="row">
  24 + <!-- *** LEFT COLUMN ***
  25 +_________________________________________________________ -->
  26 +
  27 +
  28 + <?= ListView::widget(
  29 + [
  30 + 'dataProvider' => $dataProvider,
  31 + 'itemView' => '_event',
  32 + 'options' => [
  33 + 'class' => 'col-md-9',
  34 + 'id' => 'blog-listing-medium',
  35 + ],
  36 + 'layout' => '{items}{pager}',
  37 + ]
  38 + ); ?>
  39 +
  40 +
  41 + <!-- *** LEFT COLUMN END *** -->
  42 +
  43 + <!-- *** RIGHT COLUMN ***
  44 +_________________________________________________________ -->
  45 +
  46 + <div class="col-md-3 blog-sidebar">
  47 +
  48 + <!-- *** MENUS AND WIDGETS ***
  49 +_________________________________________________________ -->
  50 +
  51 +<!-- --><?//= BlogSearch::widget(); ?>
  52 + <?php if(!empty($tags)){
  53 + ?>
  54 + <div class="panel sidebar-menu">
  55 + <div class="panel-heading">
  56 + <h3 class="panel-title"><?=\Yii::t('app', 'Поиск по тегам')?></h3>
  57 + </div>
  58 +
  59 + <div class="panel-body">
  60 + <ul class="tag-cloud">
  61 + <?php foreach ($tags as $tag) { ?>
  62 + <li><a href="<?= Url::to(
  63 + [
  64 + 'alias' => $tag->alias
  65 + ]
  66 + ) ?>"><i class="fa fa-tag"></i>&#160<?= $tag->title; ?></a>
  67 + </li>
  68 + <?php } ?>
  69 + </ul>
  70 + </div>
  71 + </div>
  72 + <?php
  73 + }
  74 + ?>
  75 +
  76 +
  77 + <!-- *** MENUS AND FILTERS END *** -->
  78 +
  79 + </div>
  80 + <!-- /.col-md-3 -->
  81 +
  82 + <!-- *** RIGHT COLUMN END *** -->
  83 +
  84 + </div>
  85 + <!-- /.row -->
  86 + </div>
  87 + <!-- /.container -->
  88 +</div>
  89 +<!-- /#content -->
0 90 \ No newline at end of file
... ...
frontend/views/event/tag.php 0 → 100755
  1 +<?php
  2 +
  3 + use artbox\core\components\SeoComponent;
  4 + use common\models\event\Tag;
  5 + use yii\data\ActiveDataProvider;
  6 + use artbox\core\helpers\Url;
  7 + use yii\web\View;
  8 + use yii\widgets\ListView;
  9 +
  10 + /**
  11 + * @var View $this
  12 + * @var ActiveDataProvider $dataProvider
  13 + * @var SeoComponent $seo
  14 + * @var Tag[] $tags
  15 + * @var Tag $model
  16 + */
  17 + $seo = \Yii::$app->get('seo');
  18 +
  19 + $this->params[ 'breadcrumbs' ][] = [
  20 + 'label' => \Yii::t('app', 'Events'),
  21 + 'url' => [ 'blog/index' ],
  22 + ];
  23 +
  24 + $this->params[ 'breadcrumbs' ][] = $seo->title;
  25 +
  26 +?>
  27 +
  28 +<div id="content">
  29 + <div class="container">
  30 + <div class="row">
  31 + <!-- *** LEFT COLUMN ***
  32 +_________________________________________________________ -->
  33 +
  34 +
  35 + <!-- <ul class="pager">-->
  36 + <!-- <li class="previous"><a href="#">&larr; Назад</a>-->
  37 + <!-- </li>-->
  38 + <!-- <li class="next disabled"><a href="#">Вперед &rarr;</a>-->
  39 + <!-- </li>-->
  40 + <!-- </ul>-->
  41 +
  42 + <!-- /.col-md-9 -->
  43 +
  44 +
  45 + <?= ListView::widget(
  46 + [
  47 + 'dataProvider' => $dataProvider,
  48 + 'itemView' => '_event',
  49 + 'options' => [
  50 + 'class' => 'col-md-9',
  51 + 'id' => 'blog-listing-medium',
  52 + ],
  53 + 'layout' => '{items}{pager}',
  54 + ]
  55 + ); ?>
  56 +
  57 +
  58 + <!-- *** LEFT COLUMN END *** -->
  59 +
  60 + <!-- *** RIGHT COLUMN ***
  61 +_________________________________________________________ -->
  62 +
  63 + <div class="col-md-3">
  64 +
  65 + <!-- *** MENUS AND WIDGETS ***
  66 +_________________________________________________________ -->
  67 +
  68 +
  69 + <div class="panel sidebar-menu">
  70 + <div class="panel-heading">
  71 + <h3 class="panel-title"><?=\Yii::t('app', 'Поиск по тегам')?></h3>
  72 + </div>
  73 +
  74 + <div class="panel-body">
  75 + <ul class="tag-cloud">
  76 + <?php foreach ($tags as $tag) { ?>
  77 + <li><a href="<?= Url::to(
  78 + [
  79 + 'alias' => $tag->alias
  80 + ]
  81 + ) ?>"><i class="fa fa-tags"></i>&#160<?= $tag->title; ?></a>
  82 + </li>
  83 + <?php } ?>
  84 + </ul>
  85 + </div>
  86 + </div>
  87 +
  88 + <!-- *** MENUS AND FILTERS END *** -->
  89 +
  90 + </div>
  91 + <!-- /.col-md-3 -->
  92 +
  93 + <!-- *** RIGHT COLUMN END *** -->
  94 +
  95 + </div>
  96 + <!-- /.row -->
  97 + </div>
  98 + <!-- /.container -->
  99 +</div>
  100 +<!-- /#content -->
0 101 \ No newline at end of file
... ...
frontend/views/event/view.php 0 → 100755
  1 +<?php
  2 +
  3 + use common\models\event\Event;
  4 + use common\models\event\Tag;
  5 + use artbox\core\helpers\Url;
  6 + use yii\web\View;
  7 +
  8 + /**
  9 + * @var View $this
  10 + * @var Event $model
  11 + * @var Tag[] $tags
  12 + */
  13 +
  14 + $this->params[ 'breadcrumbs' ][] = [
  15 + 'label' => \Yii::t('app', 'Events'),
  16 + 'url' => [ 'blog/index' ],
  17 + ];
  18 +
  19 + $this->params[ 'breadcrumbs' ][] = $model->title;
  20 +
  21 +?>
  22 +
  23 +<div id="content">
  24 + <div class="container">
  25 +
  26 + <div class="row">
  27 +
  28 + <!-- *** LEFT COLUMN ***
  29 +_________________________________________________________ -->
  30 +
  31 + <div class="col-md-9" id="blog-post">
  32 +
  33 + <h2><?= $model->title; ?></h2>
  34 +
  35 + <?php if (!empty($model->tags)) { ?>
  36 + <div class="panel sidebar-menu">
  37 + <div class="panel-body">
  38 + <ul class="tag-cloud">
  39 + <?php foreach ($model->tags as $tag) { ?>
  40 + <li><a href="<?= Url::to(
  41 + [
  42 + 'alias' => $tag->alias
  43 + ]
  44 + ) ?>"><i class="fa fa-tags"></i>&#160<?= $tag->label; ?></a>
  45 + </li>
  46 + <?php } ?>
  47 + </ul>
  48 + </div>
  49 + </div>
  50 + <?php } ?>
  51 +
  52 + <p class="text-muted text-uppercase mb-small text-left"><?= \Yii::$app->formatter->asDate(
  53 + $model->created_at
  54 + ); ?></p>
  55 +
  56 + <div id="post-content">
  57 +
  58 + <?= $model->body; ?>
  59 +
  60 + </div>
  61 + <!-- /#post-content -->
  62 +
  63 + <?php
  64 + /*
  65 +
  66 + <div id="comments">
  67 + <h4 class="text-uppercase">2 comments</h4>
  68 +
  69 +
  70 + <div class="row comment">
  71 + <div class="col-sm-3 col-md-2 text-center-xs">
  72 + <p>
  73 + <img src="img/blog-avatar2.jpg" class="img-responsive img-circle" alt="">
  74 + </p>
  75 + </div>
  76 + <div class="col-sm-9 col-md-10">
  77 + <h5 class="text-uppercase">Julie Alma</h5>
  78 + <p class="posted"><i class="fa fa-clock-o"></i> September 23, 2011 в 12:00</p>
  79 + <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper.
  80 + Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>
  81 + <p class="reply"><a href="#"><i class="fa fa-reply"></i> Ответить</a>
  82 + </p>
  83 + </div>
  84 + </div>
  85 + <!-- /.comment -->
  86 +
  87 +
  88 + <div class="row comment last">
  89 +
  90 + <div class="col-sm-3 col-md-2 text-center-xs">
  91 + <p>
  92 + <img src="img/blog-avatar.jpg" class="img-responsive img-circle" alt="">
  93 + </p>
  94 + </div>
  95 +
  96 + <div class="col-sm-9 col-md-10">
  97 + <h5 class="text-uppercase">Louise Armero</h5>
  98 + <p class="posted"><i class="fa fa-clock-o"></i> 23 сентября 2012 в 12:00</p>
  99 + <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper.
  100 + Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>
  101 + <p class="reply"><a href="#"><i class="fa fa-reply"></i> Ответить</a>
  102 + </p>
  103 + </div>
  104 +
  105 + </div>
  106 + <!-- /.comment -->
  107 + </div>
  108 + <!-- /#comments -->
  109 +
  110 +
  111 + <div id="comment-form">
  112 +
  113 + <h4 class="text-uppercase">Leave comment</h4>
  114 +
  115 + <form>
  116 + <div class="row">
  117 +
  118 + <div class="col-sm-6">
  119 + <div class="form-group">
  120 + <label for="name">Name <span class="required">*</span>
  121 + </label>
  122 + <input type="text" class="form-control" id="name">
  123 + </div>
  124 + </div>
  125 +
  126 + </div>
  127 +
  128 + <div class="row">
  129 + <div class="col-sm-6">
  130 + <div class="form-group">
  131 + <label for="email">Email <span class="required">*</span>
  132 + </label>
  133 + <input type="text" class="form-control" id="email">
  134 + </div>
  135 + </div>
  136 + </div>
  137 +
  138 + <div class="row">
  139 + <div class="col-sm-12">
  140 + <div class="form-group">
  141 + <label for="comment">Comment <span class="required">*</span>
  142 + </label>
  143 + <textarea class="form-control" id="comment" rows="4"></textarea>
  144 + </div>
  145 + </div>
  146 + </div>
  147 +
  148 + <div class="row">
  149 + <div class="col-sm-12 text-right">
  150 + <button class="btn btn-template-main"><i class="fa fa-comment-o"></i> Post comment</button>
  151 + </div>
  152 + </div>
  153 +
  154 +
  155 + </form>
  156 +
  157 + </div>
  158 + <!-- /#comment-form -->
  159 + */
  160 + ?>
  161 + </div>
  162 + <!-- /#blog-post -->
  163 +
  164 + <!-- *** LEFT COLUMN END *** -->
  165 +
  166 + <!-- *** RIGHT COLUMN ***
  167 + _________________________________________________________ -->
  168 +
  169 + <div class="col-md-3">
  170 +
  171 + <!-- *** MENUS AND WIDGETS ***
  172 +_________________________________________________________ -->
  173 +
  174 + <div class="panel sidebar-menu">
  175 + <div class="panel-heading">
  176 + <h3 class="panel-title"><?=\Yii::t('app', 'Поиск по тегам')?></h3>
  177 + </div>
  178 +
  179 + <div class="panel-body">
  180 + <ul class="tag-cloud">
  181 + <?php foreach ($tags as $tag) { ?>
  182 + <li><a href="<?= Url::to(
  183 + [
  184 + 'alias' => $tag->alias
  185 + ]
  186 + ) ?>"><i class="fa fa-tags"></i>&#160<?= $tag->label; ?></a>
  187 + </li>
  188 + <?php } ?>
  189 + </ul>
  190 + </div>
  191 + </div>
  192 +
  193 + <!-- *** MENUS AND FILTERS END *** -->
  194 +
  195 + </div>
  196 + <!-- /.col-md-3 -->
  197 + <!-- *** RIGHT COLUMN END *** -->
  198 +
  199 +
  200 + </div>
  201 + <!-- /.row -->
  202 +
  203 + </div>
  204 + <!-- /.container -->
  205 +</div>
  206 +<!-- /#content -->
  207 +
0 208 \ No newline at end of file
... ...
frontend/views/layouts/main.php
... ... @@ -307,7 +307,6 @@ _________________________________________________________ --&gt;
307 307 foreach ($category->pages as $page) {
308 308 $pages[] = [
309 309 'label' => $page->title,
310   - // @TODO without index 0 not use createUrl
311 310 'url' => Url::to(['alias' => $page->alias]),
312 311 ];
313 312 }
... ... @@ -328,6 +327,10 @@ _________________________________________________________ --&gt;
328 327 'label' => \Yii::t('app', 'Blog'),
329 328 'url' => [ 'blog/index' ],
330 329 ];
  330 + $items[] = [
  331 + 'label' => \Yii::t('app', 'Events'),
  332 + 'url' => [ 'event/index' ],
  333 + ];
331 334 echo Nav::widget(
332 335 [
333 336 'items' => $items,
... ...
frontend/views/site/index.php
... ... @@ -21,15 +21,17 @@ _________________________________________________________ --&gt;
21 21 <div class="dark-mask"></div>
22 22  
23 23 <div class="container">
24   - <div class="homepage owl-carousel">
  24 + <div class="homepage owl-carousel" >
  25 +
25 26 <?php foreach ($slides as $slide){?>
  27 + <div class="home-carousel" style="background: url(<?=$slide->background->getPath()?>) center center repeat">
26 28 <div class="item">
27 29 <div class="row">
28 30 <div class="col-sm-5 right">
29 31 <h1><?=$slide->title?></h1>
30   - <p>Личный подбор маршрута. Планирование поездки. Бронь билетов. Страховка.</p>
  32 + <p><?=$slide->description?></p>
31 33 <p style="margin-top:25px;"> </p>
32   - <p><a href="#" class="btn btn-template-transparent-primary">Подробнее</a></p>
  34 + <p><a href="<?=$slide->link?>" class="btn btn-template-transparent-primary">Подробнее</a></p>
33 35 </div>
34 36 <div class="col-sm-7">
35 37 <a href="<?=$slide->link?>"><?=ImageHelper::set($slide->language->image->getPath())
... ... @@ -39,6 +41,7 @@ _________________________________________________________ --&gt;
39 41 </div>
40 42 </div>
41 43 </div>
  44 + </div>
42 45 <?php }?>
43 46 </div>
44 47 <!-- /.project owl-slider -->
... ...