Commit 9217ef8e4fcee02b2ab8661d57d76f2c73f2a1d4
1 parent
89571990
09.02.16
Showing
8 changed files
with
178 additions
and
125 deletions
Show diff stats
| 1 | +<?php | |
| 2 | + | |
| 3 | +namespace common\behaviors; | |
| 4 | + | |
| 5 | +use yii; | |
| 6 | +use yii\base\Behavior; | |
| 7 | + | |
| 8 | +class ShowImage extends Behavior | |
| 9 | +{ | |
| 10 | + function minImg($dir, $width, $height=null){ | |
| 11 | + if($width=='original'){ | |
| 12 | + $preg = '/\/(.[^\/]*)$/'; | |
| 13 | + preg_match('/\.(.[^.]*)$/', $dir, $type); | |
| 14 | + $row = preg_replace( $preg, '/original.'.$type[1], $dir); | |
| 15 | + } else { | |
| 16 | + $preg = '/\/(.[^\/]*)$/'; | |
| 17 | + preg_match('/\.(.[^.]*)$/', $dir, $type); | |
| 18 | + $row = preg_replace( $preg, '/'.$width.'X'.$height.'.'.$type[1], $dir); | |
| 19 | + } | |
| 20 | + | |
| 21 | + return $row; | |
| 22 | + | |
| 23 | + | |
| 24 | + } | |
| 25 | + | |
| 26 | +} | |
| 0 | 27 | \ No newline at end of file | ... | ... |
common/models/Gallery.php
frontend/controllers/AccountsController.php
| ... | ... | @@ -249,13 +249,33 @@ |
| 249 | 249 | ]); |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | + public function actionGalleryVideo() | |
| 253 | + { | |
| 254 | + | |
| 255 | + $user = \Yii::$app->user->identity; | |
| 256 | + | |
| 257 | + $video = Fields::getData($user->id,Gallery::className(),'youtube'); | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + if(!empty(Yii::$app->request->post('Fields'))) { | |
| 262 | + Fields::saveFieldData(Yii::$app->request->post('Fields'), $user->id, Gallery::className(), 'ru'); | |
| 263 | + } | |
| 264 | + | |
| 265 | + return $this->render('gallery-video', [ | |
| 266 | + 'video' => $video, | |
| 267 | + 'user' => $user, | |
| 268 | + ]); | |
| 269 | + } | |
| 270 | + | |
| 271 | + | |
| 252 | 272 | public function actionGalleryCreate() |
| 253 | 273 | { |
| 254 | 274 | $gallery = new Gallery(); |
| 255 | 275 | $user = \Yii::$app->user->identity; |
| 256 | 276 | $post = \Yii::$app->request->post(); |
| 257 | 277 | if($gallery->load($post) && $gallery->save()) { |
| 258 | - Fields::saveFieldData(Yii::$app->request->post('Fields'), $gallery->gallery_id, Gallery::className(), 'ru'); | |
| 278 | + | |
| 259 | 279 | return $this->redirect([ |
| 260 | 280 | 'gallery-update', |
| 261 | 281 | 'id' => $gallery->gallery_id, | ... | ... |
frontend/controllers/PerformerController.php
| ... | ... | @@ -3,10 +3,12 @@ namespace frontend\controllers; |
| 3 | 3 | |
| 4 | 4 | use common\models\Blog; |
| 5 | 5 | use common\models\Fields; |
| 6 | +use common\models\Gallery; | |
| 6 | 7 | use Yii; |
| 7 | 8 | use yii\data\ArrayDataProvider; |
| 8 | 9 | use yii\data\Pagination; |
| 9 | 10 | use yii\helpers\ArrayHelper; |
| 11 | +use yii\web\BadRequestHttpException; | |
| 10 | 12 | use yii\web\Controller; |
| 11 | 13 | use common\models\User; |
| 12 | 14 | |
| ... | ... | @@ -51,6 +53,10 @@ class PerformerController extends Controller |
| 51 | 53 | |
| 52 | 54 | $user = User::findOne($performer_id); |
| 53 | 55 | |
| 56 | + if(!$user instanceof User){ | |
| 57 | + throw new BadRequestHttpException('Пользователь не найден'); | |
| 58 | + } | |
| 59 | + | |
| 54 | 60 | $educations = Fields::getData($user->id,$user->className(),'education'); |
| 55 | 61 | $phones = Fields::getData($user->id,$user->className(),'phone'); |
| 56 | 62 | $sites = Fields::getData($user->id,$user->className(),'site'); |
| ... | ... | @@ -71,6 +77,11 @@ class PerformerController extends Controller |
| 71 | 77 | { |
| 72 | 78 | $user = User::findOne($performer_id); |
| 73 | 79 | |
| 80 | + if(!$user instanceof User){ | |
| 81 | + throw new BadRequestHttpException('Пользователь не найден'); | |
| 82 | + } | |
| 83 | + | |
| 84 | + | |
| 74 | 85 | return $this->render('portfolio',[ |
| 75 | 86 | 'user' => $user |
| 76 | 87 | ]); |
| ... | ... | @@ -81,6 +92,11 @@ class PerformerController extends Controller |
| 81 | 92 | { |
| 82 | 93 | $user = User::findOne($performer_id); |
| 83 | 94 | |
| 95 | + if(!$user instanceof User){ | |
| 96 | + throw new BadRequestHttpException('Пользователь не найден'); | |
| 97 | + } | |
| 98 | + | |
| 99 | + | |
| 84 | 100 | $query = Blog::find(['user_id'=>$performer_id]); |
| 85 | 101 | |
| 86 | 102 | $countQuery = clone $query; |
| ... | ... | @@ -108,6 +124,12 @@ class PerformerController extends Controller |
| 108 | 124 | public function actionBlogView($performer_id, $link) |
| 109 | 125 | { |
| 110 | 126 | $user = User::findOne($performer_id); |
| 127 | + | |
| 128 | + if(!$user instanceof User){ | |
| 129 | + throw new BadRequestHttpException('Пользователь не найден'); | |
| 130 | + } | |
| 131 | + | |
| 132 | + | |
| 111 | 133 | $article = Blog::findOne(['link'=>$link,'user_id'=>$performer_id]); |
| 112 | 134 | $article->view_count ++; |
| 113 | 135 | $article->save(); |
| ... | ... | @@ -123,6 +145,12 @@ class PerformerController extends Controller |
| 123 | 145 | public function actionReview($performer_id) |
| 124 | 146 | { |
| 125 | 147 | $user = User::findOne($performer_id); |
| 148 | + | |
| 149 | + if(!$user instanceof User){ | |
| 150 | + throw new BadRequestHttpException('Пользователь не найден'); | |
| 151 | + } | |
| 152 | + | |
| 153 | + | |
| 126 | 154 | return $this->render('review',[ |
| 127 | 155 | 'user' => $user |
| 128 | 156 | ]); |
| ... | ... | @@ -131,6 +159,9 @@ class PerformerController extends Controller |
| 131 | 159 | public function actionWorkplace($performer_id) |
| 132 | 160 | { |
| 133 | 161 | $user = User::findOne($performer_id); |
| 162 | + if(!$user instanceof User){ | |
| 163 | + throw new BadRequestHttpException('Пользователь не найден'); | |
| 164 | + } | |
| 134 | 165 | |
| 135 | 166 | return $this->render('workplace',[ |
| 136 | 167 | 'user' => $user |
| ... | ... | @@ -140,9 +171,34 @@ class PerformerController extends Controller |
| 140 | 171 | public function actionGallery($performer_id) |
| 141 | 172 | { |
| 142 | 173 | $user = User::findOne($performer_id); |
| 174 | + | |
| 175 | + if(!$user instanceof User){ | |
| 176 | + throw new BadRequestHttpException('Пользователь не найден'); | |
| 177 | + } | |
| 178 | + | |
| 179 | + | |
| 180 | + $query = Gallery::find(['user_id'=>$performer_id]); | |
| 181 | + | |
| 182 | + $countQuery = clone $query; | |
| 183 | + | |
| 184 | + $pagination = new Pagination(['totalCount' => $countQuery->count(), | |
| 185 | + 'pageSize' => 5, | |
| 186 | + ]); | |
| 187 | + | |
| 188 | + $gallery = $query->offset($pagination->offset) | |
| 189 | + ->limit($pagination->limit) | |
| 190 | + ->all(); | |
| 191 | + | |
| 192 | + $gallery = new ArrayDataProvider([ | |
| 193 | + 'allModels' => $gallery, | |
| 194 | + ]); | |
| 195 | + | |
| 143 | 196 | $this->layout = 'gallery'; |
| 197 | + | |
| 144 | 198 | return $this->render('gallery',[ |
| 145 | - 'user' => $user | |
| 146 | - ]); | |
| 199 | + 'user' => $user, | |
| 200 | + 'gallery' =>$gallery, | |
| 201 | + 'pagination' => $pagination | |
| 202 | + ]); | |
| 147 | 203 | } |
| 148 | 204 | } | ... | ... |
frontend/views/accounts/_gallery_form.php
| ... | ... | @@ -5,9 +5,7 @@ |
| 5 | 5 | */ |
| 6 | 6 | use common\models\Gallery; |
| 7 | 7 | use common\models\User; |
| 8 | - use common\widgets\FieldEditor; | |
| 9 | 8 | use common\widgets\ImageUploader; |
| 10 | - use mihaildev\ckeditor\CKEditor; | |
| 11 | 9 | use yii\helpers\Html; |
| 12 | 10 | use yii\widgets\ActiveForm; |
| 13 | 11 | |
| ... | ... | @@ -28,34 +26,24 @@ |
| 28 | 26 | <?= ImageUploader::widget([ |
| 29 | 27 | 'model' => $gallery, |
| 30 | 28 | 'field' => 'cover', |
| 31 | - 'width' => 100, | |
| 32 | - 'height' => 100, | |
| 29 | + 'width' => 210, | |
| 30 | + 'height' => 150, | |
| 33 | 31 | 'multi' => false, |
| 34 | 32 | 'gallery' => $gallery->cover, |
| 35 | 33 | 'name' => 'Загрузить главное фото', |
| 36 | 34 | ]); ?> |
| 37 | 35 | |
| 38 | -<?= $form->field($gallery, 'type') | |
| 39 | - ->radioList([ | |
| 40 | - 1 => 'Фото', | |
| 41 | - 2 => 'Видео', | |
| 42 | - ]) ?> | |
| 43 | - | |
| 44 | 36 | <?= ImageUploader::widget([ |
| 45 | 37 | 'model' => $gallery, |
| 46 | 38 | 'field' => 'photo', |
| 47 | - 'width' => 100, | |
| 48 | - 'height' => 100, | |
| 39 | + 'width' => 148, | |
| 40 | + 'height' => 104, | |
| 49 | 41 | 'multi' => true, |
| 50 | 42 | 'gallery' => $gallery->photo, |
| 51 | 43 | 'name' => 'Загрузить фото галереи', |
| 52 | 44 | ]); ?> |
| 53 | 45 | |
| 54 | -<?= FieldEditor::widget ( | |
| 55 | - [ | |
| 56 | - 'template' => 'youtube', 'item_id' => $gallery->gallery_id, 'model' => 'common\models\Gallery', 'language' => 'ru', | |
| 57 | - ] | |
| 58 | -); ?> | |
| 46 | + | |
| 59 | 47 | |
| 60 | 48 | <?= Html::submitButton('Добавить') ?> |
| 61 | 49 | ... | ... |
| 1 | +<?php | |
| 2 | +/** | |
| 3 | +* @var Gallery $gallery | |
| 4 | +* @var User $user | |
| 5 | +*/ | |
| 6 | +use common\models\Gallery; | |
| 7 | +use common\models\User; | |
| 8 | +use common\widgets\FieldEditor; | |
| 9 | +use yii\helpers\Html; | |
| 10 | +use yii\widgets\ActiveForm; | |
| 11 | + | |
| 12 | +$this->title = 'Мой профиль'; | |
| 13 | +$this->params[ 'breadcrumbs' ][] = $this->title; | |
| 14 | +?> | |
| 15 | +<h1><?= $this->title ?></h1> | |
| 16 | + | |
| 17 | +<?php | |
| 18 | +$form = ActiveForm::begin(); | |
| 19 | +?> | |
| 20 | + | |
| 21 | +<?= FieldEditor::widget ( | |
| 22 | + [ | |
| 23 | + 'template' => 'youtube', 'item_id' => $user->id, 'model' => 'common\models\Gallery', 'language' => 'ru', | |
| 24 | + ] | |
| 25 | +); ?> | |
| 26 | + | |
| 27 | +<?= Html::submitButton('Добавить') ?> | |
| 28 | + | |
| 29 | +<?php | |
| 30 | +$form->end(); | |
| 31 | +?> | |
| 32 | + | ... | ... |
| 1 | +<?php | |
| 2 | + use yii\helpers\Html; | |
| 3 | +?> | |
| 4 | +<div class="gallery-box"> | |
| 5 | + <a href="#" class="gallery-box-min"><?= Html::img($model->cover)?></a> | |
| 6 | + <div class="gallery-box-hidden"> | |
| 7 | + <div class="gallery-box-preview"> | |
| 8 | + <?php foreach(explode(',', $model->photo ) as $image):?> | |
| 9 | + <span data-link="<?= $image ?>"></span> | |
| 10 | + <?php endforeach; ?> | |
| 11 | + | |
| 12 | + </div> | |
| 13 | + <div class="gallery-box-big"> | |
| 14 | + <?php foreach(explode(',', $model->photo ) as $image):?> | |
| 15 | + <span data-link="<?= $model->minImg($image, 'original'); ?>"></span> | |
| 16 | + <?php endforeach; ?> | |
| 17 | + </div> | |
| 18 | + </div> | |
| 19 | +</div> | |
| 0 | 20 | \ No newline at end of file | ... | ... |
frontend/views/performer/gallery.php
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | use \yii\helpers\Html; |
| 4 | +use yii\widgets\LinkPager; | |
| 5 | +use yii\widgets\ListView; | |
| 4 | 6 | |
| 5 | 7 | /* @var $this yii\web\View */ |
| 6 | 8 | $this->params['user'] = $user; |
| ... | ... | @@ -47,114 +49,21 @@ $this->title = 'My Yii Application'; |
| 47 | 49 | <div class="gallery-performer-wrapper style"> |
| 48 | 50 | <div class="gallery-title">Фото: 130</div> |
| 49 | 51 | <div class="gallery-performer-margin"> |
| 50 | - <div class="gallery-box"> | |
| 51 | - <a href="#" class="gallery-box-min"><img src="/images/gallery-pic/gal-img-1.jpg" alt=""/></a> | |
| 52 | - <div class="gallery-box-hidden"> | |
| 53 | - <div class="gallery-box-preview"> | |
| 54 | - <span data-link="images/gallery-pic/gallery-preview/img-1.jpg"></span> | |
| 55 | - <span data-link="images/gallery-pic/gallery-preview/img-2.jpg"></span> | |
| 56 | - <span data-link="images/gallery-pic/gallery-preview/img-3.jpg"></span> | |
| 57 | - <span data-link="images/gallery-pic/gallery-preview/img-4.jpg"></span> | |
| 58 | - <span data-link="images/gallery-pic/gallery-preview/img-5.jpg"></span> | |
| 59 | - <span data-link="images/gallery-pic/gallery-preview/img-6.jpg"></span> | |
| 60 | - <span data-link="images/gallery-pic/gallery-preview/img-7.jpg"></span> | |
| 61 | - <span data-link="images/gallery-pic/gallery-preview/img-8.jpg"></span> | |
| 62 | - <span data-link="images/gallery-pic/gallery-preview/img-9.jpg"></span> | |
| 63 | - <!--<span data-link="images/gallery-pic/gallery-preview/img-10.jpg"></span>--> | |
| 64 | - <!--<span data-link="images/gallery-pic/gallery-preview/img-1.jpg"></span>--> | |
| 65 | - <!--<span data-link="images/gallery-pic/gallery-preview/img-2.jpg"></span>--> | |
| 66 | - <!--<span data-link="images/gallery-pic/gallery-preview/img-3.jpg"></span>--> | |
| 67 | - <!--<span data-link="images/gallery-pic/gallery-preview/img-4.jpg"></span>--> | |
| 68 | - <!--<span data-link="images/gallery-pic/gallery-preview/img-5.jpg"></span>--> | |
| 69 | - <!--<span data-link="images/gallery-pic/gallery-preview/img-6.jpg"></span>--> | |
| 70 | - <!--<span data-link="images/gallery-pic/gallery-preview/img-7.jpg"></span>--> | |
| 71 | - | |
| 72 | - </div> | |
| 73 | - <div class="gallery-box-big"> | |
| 74 | - <span data-link="images/gallery-pic/gallery-big/img-big-1.jpg"></span> | |
| 75 | - <span data-link="images/gallery-pic/gallery-big/img-big-2.jpg"></span> | |
| 76 | - <span data-link="images/gallery-pic/gallery-big/img-big-3.jpg"></span> | |
| 77 | - <span data-link="images/gallery-pic/gallery-big/img-big-4.jpg"></span> | |
| 78 | - <span data-link="images/gallery-pic/gallery-big/img-big-5.jpg"></span> | |
| 79 | - <span data-link="images/gallery-pic/gallery-big/img-big-6.jpg"></span> | |
| 80 | - <span data-link="images/gallery-pic/gallery-big/img-big-7.jpg"></span> | |
| 81 | - <span data-link="images/gallery-pic/gallery-big/img-big-8.jpg"></span> | |
| 82 | - <span data-link="images/gallery-pic/gallery-big/img-big-9.jpg"></span> | |
| 83 | - <span data-link="images/gallery-pic/gallery-big/img-big-10.jpg"></span> | |
| 84 | - <span data-link="images/gallery-pic/gallery-big/img-big-1.jpg"></span> | |
| 85 | - <span data-link="images/gallery-pic/gallery-big/img-big-2.jpg"></span> | |
| 86 | - <span data-link="images/gallery-pic/gallery-big/img-big-3.jpg"></span> | |
| 87 | - <span data-link="images/gallery-pic/gallery-big/img-big-4.jpg"></span> | |
| 88 | - <span data-link="images/gallery-pic/gallery-big/img-big-5.jpg"></span> | |
| 89 | - <span data-link="images/gallery-pic/gallery-big/img-big-6.jpg"></span> | |
| 90 | - <span data-link="images/gallery-pic/gallery-big/img-big-7.jpg"></span> | |
| 91 | - </div> | |
| 92 | - </div> | |
| 93 | - </div> | |
| 94 | - | |
| 95 | - <div class="gallery-box"> | |
| 96 | - <a href="#" class="gallery-box-min"><img src="/images/gallery-pic/gal-img-2.jpg" alt=""/></a> | |
| 97 | - <div class="gallery-box-hidden"> | |
| 98 | - <div class="gallery-box-preview"> | |
| 99 | - <span data-link="images/gallery-pic/gallery-preview/img-6.jpg"></span> | |
| 100 | - <span data-link="images/gallery-pic/gallery-preview/img-7.jpg"></span> | |
| 101 | - <span data-link="images/gallery-pic/gallery-preview/img-8.jpg"></span> | |
| 102 | - <span data-link="images/gallery-pic/gallery-preview/img-9.jpg"></span> | |
| 103 | - <span data-link="images/gallery-pic/gallery-preview/img-10.jpg"></span> | |
| 104 | - | |
| 105 | - </div> | |
| 106 | - <div class="gallery-box-big"> | |
| 107 | - <span data-link="images/gallery-pic/gallery-big/img-big-6.jpg"></span> | |
| 108 | - <span data-link="images/gallery-pic/gallery-big/img-big-7.jpg"></span> | |
| 109 | - <span data-link="images/gallery-pic/gallery-big/img-big-8.jpg"></span> | |
| 110 | - <span data-link="images/gallery-pic/gallery-big/img-big-9.jpg"></span> | |
| 111 | - <span data-link="images/gallery-pic/gallery-big/img-big-10.jpg"></span> | |
| 112 | - </div> | |
| 113 | - </div> | |
| 114 | - </div> | |
| 115 | - | |
| 116 | - <div class="gallery-box"> | |
| 117 | - <a href="#" class="gallery-box-min"><img src="/images/gallery-pic/gal-img-3.jpg" alt=""/></a> | |
| 118 | - </div> | |
| 119 | - <div class="gallery-box"> | |
| 120 | - <a href="#" class="gallery-box-min"><img src="/images/gallery-pic/gal-img-4.jpg" alt=""/></a> | |
| 121 | - </div> | |
| 122 | - <div class="gallery-box"> | |
| 123 | - <a href="#" class="gallery-box-min"><img src="/images/gallery-pic/gal-img-1.jpg" alt=""/></a> | |
| 124 | - </div> | |
| 125 | - <div class="gallery-box"> | |
| 126 | - <a href="#" class="gallery-box-min"><img src="/images/gallery-pic/gal-img-2.jpg" alt=""/></a> | |
| 127 | - </div> | |
| 128 | - <div class="gallery-box"> | |
| 129 | - <a href="#" class="gallery-box-min"><img src="/images/gallery-pic/gal-img-3.jpg" alt=""/></a> | |
| 130 | - </div> | |
| 131 | - <div class="gallery-box"> | |
| 132 | - <a href="#" class="gallery-box-min"><img src="/images/gallery-pic/gal-img-4.jpg" alt=""/></a> | |
| 133 | - </div> | |
| 134 | - <div class="gallery-box"> | |
| 135 | - <a href="#" class="gallery-box-min"><img src="/images/gallery-pic/gal-img-1.jpg" alt=""/></a> | |
| 136 | - </div> | |
| 137 | - <div class="gallery-box"> | |
| 138 | - <a href="#" class="gallery-box-min"><img src="/images/gallery-pic/gal-img-2.jpg" alt=""/></a> | |
| 139 | - </div> | |
| 140 | - <div class="gallery-box"> | |
| 141 | - <a href="#" class="gallery-box-min"><img src="/images/gallery-pic/gal-img-3.jpg" alt=""/></a> | |
| 142 | - </div> | |
| 143 | - <div class="gallery-box"> | |
| 144 | - <a href="#" class="gallery-box-min"><img src="/images/gallery-pic/gal-img-4.jpg" alt=""/></a> | |
| 145 | - </div> | |
| 52 | + <?= | |
| 53 | + ListView::widget( [ | |
| 54 | + 'dataProvider' => $gallery, | |
| 55 | + 'itemView'=>'_gallery_list_view', | |
| 56 | + 'summary'=>'', | |
| 57 | + ] ); | |
| 58 | + ?> | |
| 146 | 59 | </div> |
| 147 | 60 | |
| 148 | 61 | <div class="navi-buttons-wr style gallery-style"> |
| 149 | - <ul class="pagination"> | |
| 150 | - <li><a href="#">1</a></li> | |
| 151 | - <li><a href="#">2</a></li> | |
| 152 | - <li><a href="#">3</a></li> | |
| 153 | - <li><a href="#">4</a></li> | |
| 154 | - <li><a href="#">5</a></li> | |
| 155 | - <li class="dots-next"><a href="#">...</a></li> | |
| 156 | - <li><a href="#">156</a></li> | |
| 157 | - </ul> | |
| 62 | + <?= | |
| 63 | + LinkPager::widget([ | |
| 64 | + 'pagination' => $pagination, | |
| 65 | + ]); | |
| 66 | + ?> | |
| 158 | 67 | </div> |
| 159 | 68 | |
| 160 | 69 | </div> |
| 161 | 70 | \ No newline at end of file | ... | ... |