Commit 2e35d6bdfdf36060d255c7ffab7d728615be0250
1 parent
65ef9266
test
Showing
7 changed files
with
83 additions
and
18 deletions
Show diff stats
common/models/Portfolio.php
| @@ -22,6 +22,7 @@ | @@ -22,6 +22,7 @@ | ||
| 22 | * @property string $description | 22 | * @property string $description |
| 23 | * @property string $cover | 23 | * @property string $cover |
| 24 | * @property integer $gallery_id | 24 | * @property integer $gallery_id |
| 25 | + * @property string $preview | ||
| 25 | * @property PortfolioSpecialization[] $portfolioSpecializations | 26 | * @property PortfolioSpecialization[] $portfolioSpecializations |
| 26 | * @property Specialization[] $specializations | 27 | * @property Specialization[] $specializations |
| 27 | */ | 28 | */ |
| @@ -65,6 +66,7 @@ | @@ -65,6 +66,7 @@ | ||
| 65 | [ | 66 | [ |
| 66 | [ | 67 | [ |
| 67 | 'name', | 68 | 'name', |
| 69 | + 'preview', | ||
| 68 | ], | 70 | ], |
| 69 | 'required', | 71 | 'required', |
| 70 | ], | 72 | ], |
| @@ -94,6 +96,13 @@ | @@ -94,6 +96,13 @@ | ||
| 94 | ], | 96 | ], |
| 95 | [ | 97 | [ |
| 96 | [ | 98 | [ |
| 99 | + 'preview', | ||
| 100 | + ], | ||
| 101 | + 'string', | ||
| 102 | + 'max' => 1000, | ||
| 103 | + ], | ||
| 104 | + [ | ||
| 105 | + [ | ||
| 97 | 'specializationInput', | 106 | 'specializationInput', |
| 98 | ], | 107 | ], |
| 99 | 'safe', | 108 | 'safe', |
| @@ -167,4 +176,9 @@ | @@ -167,4 +176,9 @@ | ||
| 167 | { | 176 | { |
| 168 | $this->specializationString = $value; | 177 | $this->specializationString = $value; |
| 169 | } | 178 | } |
| 179 | + | ||
| 180 | + public function getGallery() | ||
| 181 | + { | ||
| 182 | + $this->hasOne(Gallery::className(), ['gallery_id' => 'gallery_id']); | ||
| 183 | + } | ||
| 170 | } | 184 | } |
common/models/User.php
| @@ -541,4 +541,9 @@ | @@ -541,4 +541,9 @@ | ||
| 541 | return $this->hasMany(Vacancy::className(), [ 'user_id' => 'id' ]); | 541 | return $this->hasMany(Vacancy::className(), [ 'user_id' => 'id' ]); |
| 542 | } | 542 | } |
| 543 | 543 | ||
| 544 | + public function getGalleries() | ||
| 545 | + { | ||
| 546 | + return $this->hasMany(Gallery::className(), [ 'user_id' => 'id' ]); | ||
| 547 | + } | ||
| 548 | + | ||
| 544 | } | 549 | } |
common/models/Vacancy.php
common/widgets/views/phone_field.php
| @@ -20,7 +20,7 @@ | @@ -20,7 +20,7 @@ | ||
| 20 | <?= Html::beginTag('div',['class'=>'form-group','id'=>isset($model[$i]['parent_key']) ? $model[$i]['parent_key'] : 0 ])?> | 20 | <?= Html::beginTag('div',['class'=>'form-group','id'=>isset($model[$i]['parent_key']) ? $model[$i]['parent_key'] : 0 ])?> |
| 21 | <div class="input-blocks"> | 21 | <div class="input-blocks"> |
| 22 | <label for="cont-phone-<?= ++$label ?>">Телефон</label> | 22 | <label for="cont-phone-<?= ++$label ?>">Телефон</label> |
| 23 | - <input id="cont-phone-<?= $label ?>" type="tel" pattern="^\+?(?:\d{0,3})?[\(\s]?\d{0,5}[\)\s]?\d{3}[-\s]?\d{2}[-\s]?\d{2}$" placeholder="" class="form-control custom-input-2" value="<?= isset($model[$t]['value']) ? $model[$t]['value'] : '' ?>" name="Fields[phone][<?=$row?>][0][phone]" /> | 23 | + <input id="cont-phone-<?= $label ?>" type="tel" pattern="^\+?(?:\d{0,3})?[\(\s]?\d{0,5}[\)\s]?\d{3}[-\s]?\d{2}[-\s]?\d{2}$" placeholder="+xx(xxx)xxx-xx-xx" class="form-control custom-input-2" value="<?= isset($model[$t]['value']) ? $model[$t]['value'] : '' ?>" name="Fields[phone][<?=$row?>][0][phone]" /> |
| 24 | </div> | 24 | </div> |
| 25 | <span data-id="<?= isset($model[$i]['parent_key']) ? $model[$i]['parent_key'] : 0 ?>" title="удалить" class="glyphicon glyphicon-trash delete-field-item"></span> | 25 | <span data-id="<?= isset($model[$i]['parent_key']) ? $model[$i]['parent_key'] : 0 ?>" title="удалить" class="glyphicon glyphicon-trash delete-field-item"></span> |
| 26 | <?= Html::endTag('div')?> | 26 | <?= Html::endTag('div')?> |
| @@ -42,7 +42,7 @@ | @@ -42,7 +42,7 @@ | ||
| 42 | var sub_block = '<div class="form-group" >'+ | 42 | var sub_block = '<div class="form-group" >'+ |
| 43 | '<div class="input-blocks">'+ | 43 | '<div class="input-blocks">'+ |
| 44 | '<label for="cont-phone-' + ++start_label_<?=$this->context->id?> +'">Телефон</label>'+ | 44 | '<label for="cont-phone-' + ++start_label_<?=$this->context->id?> +'">Телефон</label>'+ |
| 45 | - '<input id="cont-phone-' + start_label_<?=$this->context->id?> +'" type="tel" pattern="^\\+?(?:\\d{0,3})?[\\(\\s]?\\d{0,5}[\\)\\s]?\\d{3}[-\\s]?\\d{2}[-\\s]?\\d{2}$" placeholder="" class="form-control custom-input-2" value="" name="Fields[phone]['+ start_i_<?=$this->context->id?>++ +'][0][phone]" />'+ | 45 | + '<input id="cont-phone-' + start_label_<?=$this->context->id?> +'" type="tel" pattern="^\\+?(?:\\d{0,3})?[\\(\\s]?\\d{0,5}[\\)\\s]?\\d{3}[-\\s]?\\d{2}[-\\s]?\\d{2}$" placeholder="+xx(xxx)xxx-xx-xx" class="form-control custom-input-2" value="" name="Fields[phone]['+ start_i_<?=$this->context->id?>++ +'][0][phone]" />'+ |
| 46 | '</div>'+ | 46 | '</div>'+ |
| 47 | '<span class="glyphicon glyphicon-trash delete-field-item custom-remove-ico"></span>'+ | 47 | '<span class="glyphicon glyphicon-trash delete-field-item custom-remove-ico"></span>'+ |
| 48 | '<div>'; | 48 | '<div>'; |
frontend/controllers/AccountsController.php
| @@ -336,8 +336,10 @@ | @@ -336,8 +336,10 @@ | ||
| 336 | */ | 336 | */ |
| 337 | public function actionGalleryUpdate($id) | 337 | public function actionGalleryUpdate($id) |
| 338 | { | 338 | { |
| 339 | - $gallery = Gallery::findOne($id); | ||
| 340 | $user = \Yii::$app->user->identity; | 339 | $user = \Yii::$app->user->identity; |
| 340 | + $gallery = $user->getGalleries() | ||
| 341 | + ->where([ 'gallery_id' => $id ]) | ||
| 342 | + ->one(); | ||
| 341 | $post = \Yii::$app->request->post(); | 343 | $post = \Yii::$app->request->post(); |
| 342 | if($gallery->load($post) && $gallery->save()) { | 344 | if($gallery->load($post) && $gallery->save()) { |
| 343 | return $this->redirect([ | 345 | return $this->redirect([ |
| @@ -462,11 +464,20 @@ | @@ -462,11 +464,20 @@ | ||
| 462 | */ | 464 | */ |
| 463 | public function actionPortfolioCreate() | 465 | public function actionPortfolioCreate() |
| 464 | { | 466 | { |
| 467 | + $user = \Yii::$app->user->identity; | ||
| 465 | $portfolio = new Portfolio(); | 468 | $portfolio = new Portfolio(); |
| 466 | $specializations = Specialization::find() | 469 | $specializations = Specialization::find() |
| 467 | ->where([ 'specialization_pid' => 0 ]) | 470 | ->where([ 'specialization_pid' => 0 ]) |
| 468 | ->orderBy('specialization_id') | 471 | ->orderBy('specialization_id') |
| 469 | ->all(); | 472 | ->all(); |
| 473 | + $galleries = $user->getGalleries() | ||
| 474 | + ->select([ | ||
| 475 | + 'name', | ||
| 476 | + 'gallery_id', | ||
| 477 | + ]) | ||
| 478 | + ->asArray() | ||
| 479 | + ->indexBy('gallery_id') | ||
| 480 | + ->column(); | ||
| 470 | $post = \Yii::$app->request->post(); | 481 | $post = \Yii::$app->request->post(); |
| 471 | if(!empty( $post )) { | 482 | if(!empty( $post )) { |
| 472 | $portfolio->load($post); | 483 | $portfolio->load($post); |
| @@ -483,6 +494,7 @@ | @@ -483,6 +494,7 @@ | ||
| 483 | return $this->render('_portfolio_form', [ | 494 | return $this->render('_portfolio_form', [ |
| 484 | 'portfolio' => $portfolio, | 495 | 'portfolio' => $portfolio, |
| 485 | 'specializations' => $specializations, | 496 | 'specializations' => $specializations, |
| 497 | + 'galleries' => $galleries, | ||
| 486 | ]); | 498 | ]); |
| 487 | } | 499 | } |
| 488 | 500 | ||
| @@ -500,6 +512,14 @@ | @@ -500,6 +512,14 @@ | ||
| 500 | $portfolio = $user->getPortfolios() | 512 | $portfolio = $user->getPortfolios() |
| 501 | ->where([ 'portfolio_id' => $id ]) | 513 | ->where([ 'portfolio_id' => $id ]) |
| 502 | ->one(); | 514 | ->one(); |
| 515 | + $galleries = $user->getGalleries() | ||
| 516 | + ->select([ | ||
| 517 | + 'name', | ||
| 518 | + 'gallery_id', | ||
| 519 | + ]) | ||
| 520 | + ->asArray() | ||
| 521 | + ->indexBy('gallery_id') | ||
| 522 | + ->column(); | ||
| 503 | if(!$portfolio instanceof ActiveRecord) { | 523 | if(!$portfolio instanceof ActiveRecord) { |
| 504 | throw new NotFoundHttpException('Запись не найдена'); | 524 | throw new NotFoundHttpException('Запись не найдена'); |
| 505 | } | 525 | } |
| @@ -527,6 +547,7 @@ | @@ -527,6 +547,7 @@ | ||
| 527 | return $this->render('_portfolio_form', [ | 547 | return $this->render('_portfolio_form', [ |
| 528 | 'portfolio' => $portfolio, | 548 | 'portfolio' => $portfolio, |
| 529 | 'specializations' => $specializations, | 549 | 'specializations' => $specializations, |
| 550 | + 'galleries' => $galleries, | ||
| 530 | ]); | 551 | ]); |
| 531 | } | 552 | } |
| 532 | 553 |
frontend/views/accounts/_portfolio_form.php
| @@ -2,6 +2,7 @@ | @@ -2,6 +2,7 @@ | ||
| 2 | /** | 2 | /** |
| 3 | * @var Portfolio $portfolio | 3 | * @var Portfolio $portfolio |
| 4 | * @var integer[] $specializations | 4 | * @var integer[] $specializations |
| 5 | + * @var string[] $galleries | ||
| 5 | */ | 6 | */ |
| 6 | use common\models\Option; | 7 | use common\models\Option; |
| 7 | use common\models\Portfolio; | 8 | use common\models\Portfolio; |
| @@ -60,14 +61,14 @@ | @@ -60,14 +61,14 @@ | ||
| 60 | <li> | 61 | <li> |
| 61 | <a href="#" title="<?= $child_second->specialization_name ?>"> | 62 | <a href="#" title="<?= $child_second->specialization_name ?>"> |
| 62 | <?= $form->field($portfolio, "specializationInput[{$child_second->specialization_id}]", [ | 63 | <?= $form->field($portfolio, "specializationInput[{$child_second->specialization_id}]", [ |
| 63 | - 'template' => '{input}{label}{hint}{error}', | 64 | + 'template' => '{input}{label}{hint}{error}', |
| 64 | ]) | 65 | ]) |
| 65 | ->label('<span></span>' . $child_second->specialization_name) | 66 | ->label('<span></span>' . $child_second->specialization_name) |
| 66 | ->checkbox([ | 67 | ->checkbox([ |
| 67 | 'value' => $child_second->specialization_id, | 68 | 'value' => $child_second->specialization_id, |
| 68 | 'label' => NULL, | 69 | 'label' => NULL, |
| 69 | 'uncheck' => NULL, | 70 | 'uncheck' => NULL, |
| 70 | - 'class' => 'custom-check', | 71 | + 'class' => 'custom-check', |
| 71 | ], false) ?> | 72 | ], false) ?> |
| 72 | </a> | 73 | </a> |
| 73 | </li> | 74 | </li> |
| @@ -98,9 +99,12 @@ | @@ -98,9 +99,12 @@ | ||
| 98 | ]); ?> | 99 | ]); ?> |
| 99 | </div> | 100 | </div> |
| 100 | 101 | ||
| 101 | - <div class="input-blocks-wrapper admin-avatar admin-blog-min-img admin-portfolio-foto"> | ||
| 102 | - <div style="font-size: 13px;color: inherit;font-weight: 700;color: red">Фотогалерея</div> | ||
| 103 | - | 102 | + <div class="input-blocks-wrapper"> |
| 103 | + <div class="input-blocks admin-project-list admin-currency-second"> | ||
| 104 | + <?= $form->field($portfolio, 'gallery_id') | ||
| 105 | + ->hint("<p>Для создания галереи перейдите по " . Html::a('ссылке', [ 'accounts/gallery-create' ], [ 'target' => '_BLANK' ]) . "</p>") | ||
| 106 | + ->dropDownList($galleries, [ 'prompt' => 'Выберите галерею' ]) ?> | ||
| 107 | + </div> | ||
| 104 | </div> | 108 | </div> |
| 105 | 109 | ||
| 106 | <div class="input-blocks-wrapper"> | 110 | <div class="input-blocks-wrapper"> |
| @@ -137,6 +141,12 @@ | @@ -137,6 +141,12 @@ | ||
| 137 | </div> | 141 | </div> |
| 138 | </div> | 142 | </div> |
| 139 | 143 | ||
| 144 | + <div class="input-blocks-wrapper full-blocks admin-editor-bl"> | ||
| 145 | + <div class="input-blocks"> | ||
| 146 | + <?= $form->field($portfolio, 'preview') | ||
| 147 | + ->widget(CKEditor::className(), [ 'editorOptions' => [ 'preset' => 'basic' ] ]) ?> | ||
| 148 | + </div> | ||
| 149 | + </div> | ||
| 140 | 150 | ||
| 141 | <div class="input-blocks-wrapper full-blocks admin-editor-bl"> | 151 | <div class="input-blocks-wrapper full-blocks admin-editor-bl"> |
| 142 | <div class="input-blocks"> | 152 | <div class="input-blocks"> |
frontend/views/performer/_portfolio_list_view.php
| 1 | <?php | 1 | <?php |
| 2 | -use yii\helpers\ArrayHelper; | ||
| 3 | -use yii\helpers\Html; | ||
| 4 | -use yii\helpers\StringHelper; | ||
| 5 | - | 2 | + /** |
| 3 | + * @var Portfolio $model | ||
| 4 | + */ | ||
| 5 | + use common\models\Portfolio; | ||
| 6 | + use yii\helpers\ArrayHelper; | ||
| 7 | + use yii\helpers\Html; | ||
| 8 | + use yii\helpers\StringHelper; | ||
| 6 | 9 | ||
| 7 | ?> | 10 | ?> |
| 8 | <div class="portfolio-project-blocks-wr"> | 11 | <div class="portfolio-project-blocks-wr"> |
| 9 | <div class="portfolio-project-blocks-img-title"> | 12 | <div class="portfolio-project-blocks-img-title"> |
| 10 | <div class="portfolio-project-blocks-img"> | 13 | <div class="portfolio-project-blocks-img"> |
| 11 | - <?= Html::a(Html::img($model->cover), '#');?> | 14 | + <?= Html::a(Html::img($model->cover), '#'); ?> |
| 12 | </div> | 15 | </div> |
| 13 | <div class="portfolio-project-blocks-title-wr"> | 16 | <div class="portfolio-project-blocks-title-wr"> |
| 14 | <div class="portfolio-project-blocks-title"> | 17 | <div class="portfolio-project-blocks-title"> |
| 15 | - <a href="#"><?= $model->name?></a> | 18 | + <?= Html::a($model->name, [ |
| 19 | + 'performer/portfolio-view', | ||
| 20 | + 'performer_id' => \Yii::$app->user->getId(), | ||
| 21 | + 'portfolio_id' => $model->portfolio_id, | ||
| 22 | + ]) ?> | ||
| 16 | </div> | 23 | </div> |
| 17 | </div> | 24 | </div> |
| 18 | </div> | 25 | </div> |
| 19 | <div class="portfolio-project-views-wr"> | 26 | <div class="portfolio-project-views-wr"> |
| 20 | <div class="portfolio-project-views ico-views-bl"> | 27 | <div class="portfolio-project-views ico-views-bl"> |
| 21 | <div class="portfolio-project-views-img-wr"> | 28 | <div class="portfolio-project-views-img-wr"> |
| 22 | - <div class="portfolio-project-views-img"><img src="/images/portfolio-project/ico-1.png"/></div> | 29 | + <div class="portfolio-project-views-img"> |
| 30 | + <img src="/images/portfolio-project/ico-1.png"/></div> | ||
| 23 | </div> | 31 | </div> |
| 24 | <div class="portfolio-project-views-txt">127</div> | 32 | <div class="portfolio-project-views-txt">127</div> |
| 25 | </div> | 33 | </div> |
| 26 | <div class="portfolio-project-rati ico-views-bl"> | 34 | <div class="portfolio-project-rati ico-views-bl"> |
| 27 | <div class="portfolio-project-views-img-wr"> | 35 | <div class="portfolio-project-views-img-wr"> |
| 28 | - <div class="portfolio-project-views-img"><img src="/images/portfolio-project/ico-2.png"/></div> | 36 | + <div class="portfolio-project-views-img"> |
| 37 | + <img src="/images/portfolio-project/ico-2.png"/></div> | ||
| 29 | </div> | 38 | </div> |
| 30 | <div class="portfolio-project-views-txt">10.0</div> | 39 | <div class="portfolio-project-views-txt">10.0</div> |
| 31 | </div> | 40 | </div> |
| 32 | <div class="ico-views-bl"> | 41 | <div class="ico-views-bl"> |
| 33 | <div class="portfolio-project-views-img-wr"> | 42 | <div class="portfolio-project-views-img-wr"> |
| 34 | - <div class="portfolio-project-views-img"><img src="/images/portfolio-project/ico-3.png"/></div> | 43 | + <div class="portfolio-project-views-img"> |
| 44 | + <img src="/images/portfolio-project/ico-3.png"/></div> | ||
| 35 | </div> | 45 | </div> |
| 36 | <div class="portfolio-project-views-txt">14</div> | 46 | <div class="portfolio-project-views-txt">14</div> |
| 37 | </div> | 47 | </div> |
| 38 | </div> | 48 | </div> |
| 39 | - <div class="portfolio-project-blocks-tags"><?= StringHelper::truncate(implode(', ',ArrayHelper::getColumn($model->specializations,'specialization_name')),20)?></div> | 49 | + <div class="portfolio-project-blocks-tags"><?= StringHelper::truncate(implode(', ', ArrayHelper::getColumn($model->specializations, 'specialization_name')), 20) ?></div> |
| 40 | </div> | 50 | </div> |
| 41 | \ No newline at end of file | 51 | \ No newline at end of file |