From 2e35d6bdfdf36060d255c7ffab7d728615be0250 Mon Sep 17 00:00:00 2001 From: Yarik Date: Fri, 19 Feb 2016 18:06:11 +0200 Subject: [PATCH] test --- common/models/Portfolio.php | 14 ++++++++++++++ common/models/User.php | 5 +++++ common/models/Vacancy.php | 5 +++++ common/widgets/views/phone_field.php | 4 ++-- frontend/controllers/AccountsController.php | 23 ++++++++++++++++++++++- frontend/views/accounts/_portfolio_form.php | 20 +++++++++++++++----- frontend/views/performer/_portfolio_list_view.php | 30 ++++++++++++++++++++---------- 7 files changed, 83 insertions(+), 18 deletions(-) diff --git a/common/models/Portfolio.php b/common/models/Portfolio.php index d6b2e97..6f11514 100644 --- a/common/models/Portfolio.php +++ b/common/models/Portfolio.php @@ -22,6 +22,7 @@ * @property string $description * @property string $cover * @property integer $gallery_id + * @property string $preview * @property PortfolioSpecialization[] $portfolioSpecializations * @property Specialization[] $specializations */ @@ -65,6 +66,7 @@ [ [ 'name', + 'preview', ], 'required', ], @@ -94,6 +96,13 @@ ], [ [ + 'preview', + ], + 'string', + 'max' => 1000, + ], + [ + [ 'specializationInput', ], 'safe', @@ -167,4 +176,9 @@ { $this->specializationString = $value; } + + public function getGallery() + { + $this->hasOne(Gallery::className(), ['gallery_id' => 'gallery_id']); + } } diff --git a/common/models/User.php b/common/models/User.php index fe8a81b..ec624c6 100755 --- a/common/models/User.php +++ b/common/models/User.php @@ -541,4 +541,9 @@ return $this->hasMany(Vacancy::className(), [ 'user_id' => 'id' ]); } + public function getGalleries() + { + return $this->hasMany(Gallery::className(), [ 'user_id' => 'id' ]); + } + } diff --git a/common/models/Vacancy.php b/common/models/Vacancy.php index 3cae640..4818e66 100644 --- a/common/models/Vacancy.php +++ b/common/models/Vacancy.php @@ -95,6 +95,11 @@ 'string', 'max' => 255, ], + [ + ['phone'], + 'match', + 'pattern' => '/^\+?(?:\d{0,3})?[\(\s]?\d{0,5}[\)\s]?\d{3}[-\s]?\d{2}[-\s]?\d{2}$/', + ], ]; } diff --git a/common/widgets/views/phone_field.php b/common/widgets/views/phone_field.php index 4f70a07..4b13455 100644 --- a/common/widgets/views/phone_field.php +++ b/common/widgets/views/phone_field.php @@ -20,7 +20,7 @@ 'form-group','id'=>isset($model[$i]['parent_key']) ? $model[$i]['parent_key'] : 0 ])?>
- +
@@ -42,7 +42,7 @@ var sub_block = '
'+ '
'+ ''+ - ''+ + ''+ '
'+ ''+ '
'; diff --git a/frontend/controllers/AccountsController.php b/frontend/controllers/AccountsController.php index 656b260..df9cf43 100755 --- a/frontend/controllers/AccountsController.php +++ b/frontend/controllers/AccountsController.php @@ -336,8 +336,10 @@ */ public function actionGalleryUpdate($id) { - $gallery = Gallery::findOne($id); $user = \Yii::$app->user->identity; + $gallery = $user->getGalleries() + ->where([ 'gallery_id' => $id ]) + ->one(); $post = \Yii::$app->request->post(); if($gallery->load($post) && $gallery->save()) { return $this->redirect([ @@ -462,11 +464,20 @@ */ public function actionPortfolioCreate() { + $user = \Yii::$app->user->identity; $portfolio = new Portfolio(); $specializations = Specialization::find() ->where([ 'specialization_pid' => 0 ]) ->orderBy('specialization_id') ->all(); + $galleries = $user->getGalleries() + ->select([ + 'name', + 'gallery_id', + ]) + ->asArray() + ->indexBy('gallery_id') + ->column(); $post = \Yii::$app->request->post(); if(!empty( $post )) { $portfolio->load($post); @@ -483,6 +494,7 @@ return $this->render('_portfolio_form', [ 'portfolio' => $portfolio, 'specializations' => $specializations, + 'galleries' => $galleries, ]); } @@ -500,6 +512,14 @@ $portfolio = $user->getPortfolios() ->where([ 'portfolio_id' => $id ]) ->one(); + $galleries = $user->getGalleries() + ->select([ + 'name', + 'gallery_id', + ]) + ->asArray() + ->indexBy('gallery_id') + ->column(); if(!$portfolio instanceof ActiveRecord) { throw new NotFoundHttpException('Запись не найдена'); } @@ -527,6 +547,7 @@ return $this->render('_portfolio_form', [ 'portfolio' => $portfolio, 'specializations' => $specializations, + 'galleries' => $galleries, ]); } diff --git a/frontend/views/accounts/_portfolio_form.php b/frontend/views/accounts/_portfolio_form.php index e322aee..dde6572 100644 --- a/frontend/views/accounts/_portfolio_form.php +++ b/frontend/views/accounts/_portfolio_form.php @@ -2,6 +2,7 @@ /** * @var Portfolio $portfolio * @var integer[] $specializations + * @var string[] $galleries */ use common\models\Option; use common\models\Portfolio; @@ -60,14 +61,14 @@
  • field($portfolio, "specializationInput[{$child_second->specialization_id}]", [ - 'template' => '{input}{label}{hint}{error}', + 'template' => '{input}{label}{hint}{error}', ]) ->label('' . $child_second->specialization_name) ->checkbox([ 'value' => $child_second->specialization_id, 'label' => NULL, 'uncheck' => NULL, - 'class' => 'custom-check', + 'class' => 'custom-check', ], false) ?>
  • @@ -98,9 +99,12 @@ ]); ?>
    -
    -
    Фотогалерея
    - +
    +
    + field($portfolio, 'gallery_id') + ->hint("

    Для создания галереи перейдите по " . Html::a('ссылке', [ 'accounts/gallery-create' ], [ 'target' => '_BLANK' ]) . "

    ") + ->dropDownList($galleries, [ 'prompt' => 'Выберите галерею' ]) ?> +
    @@ -137,6 +141,12 @@
    +
    +
    + field($portfolio, 'preview') + ->widget(CKEditor::className(), [ 'editorOptions' => [ 'preset' => 'basic' ] ]) ?> +
    +
    diff --git a/frontend/views/performer/_portfolio_list_view.php b/frontend/views/performer/_portfolio_list_view.php index 8ffa7b5..2ddece6 100644 --- a/frontend/views/performer/_portfolio_list_view.php +++ b/frontend/views/performer/_portfolio_list_view.php @@ -1,40 +1,50 @@
    - cover), '#');?> + cover), '#'); ?>
    - name?> + name, [ + 'performer/portfolio-view', + 'performer_id' => \Yii::$app->user->getId(), + 'portfolio_id' => $model->portfolio_id, + ]) ?>
    -
    +
    +
    127
    -
    +
    +
    10.0
    -
    +
    +
    14
    -
    specializations,'specialization_name')),20)?>
    +
    specializations, 'specialization_name')), 20) ?>
    \ No newline at end of file -- libgit2 0.21.4