From 225c516879dcb750b511acdc566cdcfdb21912de Mon Sep 17 00:00:00 2001 From: Yarik Date: Tue, 22 Mar 2016 18:21:51 +0200 Subject: [PATCH] test --- common/models/Fields.php | 289 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------------------------------------------------------------------------------- common/widgets/views/education_field.php | 4 ++-- frontend/controllers/CompanyController.php | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++------------ frontend/controllers/PerformerController.php | 14 +++++++++----- frontend/views/company/_company_common_review.php | 36 ++++++++++++++++++++++++++++++++++++ frontend/views/company/common.php | 409 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- frontend/views/performer/common.php | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------- frontend/web/css/style.css | 3 +++ 8 files changed, 525 insertions(+), 362 deletions(-) create mode 100644 frontend/views/company/_company_common_review.php diff --git a/common/models/Fields.php b/common/models/Fields.php index dcd60fc..ca60c59 100755 --- a/common/models/Fields.php +++ b/common/models/Fields.php @@ -1,155 +1,184 @@ 255] - ]; - } - /** - * @inheritdoc - */ - public function attributeLabels() - { - return [ - 'id' => 'ID', - 'table_name' => 'Model Name', - 'table_id' => 'Model ID', - 'value' => 'Value', - 'field_name' => 'Field Name', - 'language' => 'Language', - ]; - } - - public static function getData($id, $model, $type){ - $data = ArrayHelper::toArray(self::find()->where(['table_id'=>$id, 'table_name'=>$model, 'field_type'=>$type])->all()); - $result = []; - for($i=0; $i < count($data); $i ++){ - $result[$data[$i]['parent_key']][$data[$i]['field_name']] = $data[$i]['value']; + /** + * @inheritdoc + */ + public static function tableName() + { + return '{{%fields}}'; } - return $result; - } - - - /** - * @param $post - array with field data - * @param $table_id - row id in model table - * @param $table_name - madel table name - * @param $language - language id - */ - - public static function saveFieldData($post,$table_id,$table_name, $language){ - - self::deleteAll(['table_id'=>$table_id, 'table_name'=>$table_name, 'language' => $language, 'field_type' => array_keys($post)]); - - if($post){ - - - foreach($post as $k => $field){ - + /** + * @inheritdoc + */ + public function rules() + { + return [ + [ + [ + 'table_name', + 'table_id', + ], + 'required', + ], + [ + [ + 'table_id', + 'parent_key', + 'key', + ], + 'integer', + ], + [ + [ + 'table_name', + 'value', + 'field_name', + 'field_type', + 'language', + ], + 'string', + 'max' => 255, + ], + ]; + } + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'id' => 'ID', + 'table_name' => 'Model Name', + 'table_id' => 'Model ID', + 'value' => 'Value', + 'field_name' => 'Field Name', + 'language' => 'Language', + ]; + } - foreach($field as $parent_key => $row){ + public static function getData($id, $model, $type) + { + $data = ArrayHelper::toArray(self::find() + ->where([ + 'table_id' => $id, + 'table_name' => $model, + 'field_type' => $type, + ]) + ->all()); + $result = [ ]; + for($i = 0; $i < count($data); $i++) { + $result[ $data[ $i ][ 'parent_key' ] ][ $data[ $i ][ 'field_name' ] ] = $data[ $i ][ 'value' ]; + } - foreach($row as $key => $value){ + return $result; + } - $field_model = new Fields(); - $field_model->field_name = array_keys($value)[0]; - $field_model->value = $value[array_keys($value)[0]]; - $field_model->table_name = $table_name; - $field_model->table_id = $table_id; - $field_model->field_type = $k; - $field_model->language = 'ru'; - $field_model->parent_key = $parent_key; - $field_model->key = $key; - $field_model->save(); + /** + * @param array $post - array with field data + * @param int $table_id - row id in model table + * @param string $table_name - madel table name + * @param int $language - language id + */ + public static function saveFieldData($post, $table_id, $table_name, $language) + { + self::deleteAll([ + 'table_id' => $table_id, + 'table_name' => $table_name, + 'language' => $language, + 'field_type' => array_keys($post), + ]); + if($post) { + /* + * $k - field group name + * $field - array of group variations + */ + foreach($post as $k => $field) { + /** + * $parent_key - group variation index + * $row - array of indexed rows + */ + foreach($field as $parent_key => $row) { + /** + * $key - row sorting index + * $value - array, where key - subfield name, value - subfield value + */ + foreach($row as $key => $value) { + if(!empty($value[array_keys($value)[0]])) { + $field_model = new Fields(); + $field_model->field_name = array_keys($value)[ 0 ]; + $field_model->value = $value[ array_keys($value)[ 0 ] ]; + $field_model->table_name = $table_name; + $field_model->table_id = $table_id; + $field_model->field_type = $k; + $field_model->language = 'ru'; + $field_model->parent_key = $parent_key; + $field_model->key = $key; + $field_model->save(); + } + } } - } } } - } - - - /** - * @param $post - array with field data - * @param $table_id - row id in model table - * @param $table_name - madel table name - * @param $language - language id - */ - - public static function saveFieldVideoData($post,$table_id,$table_name, $language){ - - self::deleteAll(['table_id'=>$table_id, 'table_name'=>$table_name, 'language' => $language, 'field_type' => array_keys($post)]); - - if($post){ - - - foreach($post as $k => $field){ - - - - foreach($field as $parent_key => $row){ - - foreach($row as $key => $value){ - - preg_match('/src=\"(.[^"]*)\"/', $value[array_keys($value)[0]], $video_url); - - if(isset($video_url[1]) && !empty($video_url[1])){ - - $field_model = new Fields(); - $field_model->field_name = array_keys($value)[0]; - $field_model->value = $video_url[1].'?showinfo=0&autoplay=0'; - $field_model->table_name = $table_name; - $field_model->table_id = $table_id; - $field_model->field_type = $k; - $field_model->language = 'ru'; - $field_model->parent_key = $parent_key; - $field_model->key = $key; - $field_model->save(); + /** + * @param $post - array with field data + * @param $table_id - row id in model table + * @param $table_name - madel table name + * @param $language - language id + */ + + public static function saveFieldVideoData($post, $table_id, $table_name, $language) + { + self::deleteAll([ + 'table_id' => $table_id, + 'table_name' => $table_name, + 'language' => $language, + 'field_type' => array_keys($post), + ]); + if($post) { + foreach($post as $k => $field) { + foreach($field as $parent_key => $row) { + foreach($row as $key => $value) { + preg_match('/src=\"(.[^"]*)\"/', $value[ array_keys($value)[ 0 ] ], $video_url); + if(isset( $video_url[ 1 ] ) && !empty( $video_url[ 1 ] )) { + $field_model = new Fields(); + $field_model->field_name = array_keys($value)[ 0 ]; + $field_model->value = $video_url[ 1 ] . '?showinfo=0&autoplay=0'; + $field_model->table_name = $table_name; + $field_model->table_id = $table_id; + $field_model->field_type = $k; + $field_model->language = 'ru'; + $field_model->parent_key = $parent_key; + $field_model->key = $key; + $field_model->save(); + + } } - - } - } } } } -} diff --git a/common/widgets/views/education_field.php b/common/widgets/views/education_field.php index b24e544..bc38657 100755 --- a/common/widgets/views/education_field.php +++ b/common/widgets/views/education_field.php @@ -22,11 +22,11 @@ 'id' => isset( $model[ $i ][ 'parent_key' ] ) ? $model[ $i ][ 'parent_key' ] : 0, ]) ?>
- +
- +
diff --git a/frontend/controllers/CompanyController.php b/frontend/controllers/CompanyController.php index f09a100..11d9444 100755 --- a/frontend/controllers/CompanyController.php +++ b/frontend/controllers/CompanyController.php @@ -13,10 +13,12 @@ use yii\data\ActiveDataProvider; use yii\data\ArrayDataProvider; use yii\data\Pagination; + use yii\data\Sort; use yii\helpers\ArrayHelper; use yii\web\BadRequestHttpException; use yii\web\Controller; use common\models\User; + use yii\web\NotFoundHttpException; /** * Site controller @@ -51,19 +53,57 @@ public function actionCommon($company_id) { - $company = User::findOne($company_id); + /** + * @var User $company + */ + if(!$company = User::find() + ->where([ 'id' => $company_id ]) + ->with('teams') + ->with('teams.department') + ->with('userInfo') + ->with('companyInfo') + ->one() + ) { + throw new NotFoundHttpException('Компания не найдена'); + } - $educations = Fields::getData($company->id, $company->className(), 'education'); - $phones = Fields::getData($company->id, $company->className(), 'phone'); - $sites = Fields::getData($company->id, $company->className(), 'site'); - $soft = implode(', ', ArrayHelper::getColumn(Fields::getData($company->id, $company->className(), 'soft'), 'soft')); + $projectProvider = new ActiveDataProvider([ + 'query' => $company->getProjects(), + ]); + + $blogProvider = new ActiveDataProvider([ + 'query' => $company->getBlog() + ->with('comments'), + 'sort' => new Sort([ + 'defaultOrder' => [ + 'date_add' => SORT_DESC, + 'name' => SORT_ASC, + ], + ]), + 'pagination' => new Pagination([ + 'pageSize' => 2, + 'pageParam' => '', + ]), + ]); + + $commentProvider = new ActiveDataProvider([ + 'query' => $company->getComments(), + 'sort' => new Sort([ + 'defaultOrder' => [ + 'date_add' => SORT_DESC, + ], + ]), + 'pagination' => new Pagination([ + 'pageSize' => 4, + 'pageParam' => '', + ]), + ]); return $this->render('common', [ - 'company' => $company, - 'educations' => $educations, - 'phones' => $phones, - 'sites' => $sites, - 'soft' => $soft, + 'company' => $company, + 'projectProvider' => $projectProvider, + 'blogProvider' => $blogProvider, + 'commentProvider' => $commentProvider, ]); } @@ -165,9 +205,9 @@ throw new BadRequestHttpException('Пользователь не найден'); } $comments = new ActiveDataProvider([ - 'query' => $company->getComments(), + 'query' => $company->getComments(), 'pagination' => [ - 'pageSize' => 4 + 'pageSize' => 4, ], ]); $query = Team::find() diff --git a/frontend/controllers/PerformerController.php b/frontend/controllers/PerformerController.php index 40dcb90..ee1c271 100755 --- a/frontend/controllers/PerformerController.php +++ b/frontend/controllers/PerformerController.php @@ -69,16 +69,20 @@ } $educations = Fields::getData($user->id, $user->className(), 'education'); + $developments = Fields::getData($user->id, $user->className(), 'development'); + $courses = Fields::getData($user->id, $user->className(), 'courses'); $phones = Fields::getData($user->id, $user->className(), 'phone'); $sites = Fields::getData($user->id, $user->className(), 'site'); $soft = implode(', ', ArrayHelper::getColumn(Fields::getData($user->id, $user->className(), 'soft'), 'soft')); return $this->render('common', [ - 'user' => $user, - 'educations' => $educations, - 'phones' => $phones, - 'sites' => $sites, - 'soft' => $soft, + 'user' => $user, + 'educations' => $educations, + 'developments' => $developments, + 'courses' => $courses, + 'phones' => $phones, + 'sites' => $sites, + 'soft' => $soft, ]); } diff --git a/frontend/views/company/_company_common_review.php b/frontend/views/company/_company_common_review.php new file mode 100644 index 0000000..a98bf61 --- /dev/null +++ b/frontend/views/company/_company_common_review.php @@ -0,0 +1,36 @@ + +cover), [ + 'company/blog-view', + 'company_id' => $model->user_id, + 'link' => $model->link, + ]); +?> +
+
+ +
+ +

view_count ?>

+
+
+ +

comments) ?>

+
+
+ name, [ + 'company/blog-view', + 'company_id' => $model->user_id, + 'link' => $model->link, + ]) ?> +
\ No newline at end of file diff --git a/frontend/views/company/common.php b/frontend/views/company/common.php index f9dd130..878bff4 100755 --- a/frontend/views/company/common.php +++ b/frontend/views/company/common.php @@ -1,26 +1,35 @@ params['company'] = $company; -$this->title = 'My Yii Application'; + /** + * @var View $this + * @var User $company + * @var ActiveDataProvider $projectProvider + * @var ActiveDataProvider $blogProvider + * @var ActiveDataProvider $commentProvider + */ + use common\models\User; + use yii\data\ActiveDataProvider; + use yii\helpers\ArrayHelper; + use yii\web\View; + use yii\widgets\ListView; + + $this->params[ 'company' ] = $company; + $this->title = 'My Yii Application'; ?> -
О компании
-
-

Строительная компания «Познякижилстрой» (официально – это корпорация) хорошо известна на столичном рынке недвижимости. Данный застройщик – единственный в Украине, который имеет сертификаты по трем международным стандартам.

-

Более миллиона квадратных метров жилья и других строений разного назначения было построено компанией с 1996 года, когда молодая киевская организация начала свой славный путь. Сейчас надежный и уверенный в своих силах застройщик «Познякижилстрой» пополняет свой каталог объектов новостройками, современными ЖК, офисными помещениями, паркингами и многими другими объектами. Корпорация уверенно занимает позиции лидера на украинском строительном рынке.

-

Новые подходы к проектированию, строительным работам и управлению компанией позволяют «Познякижилстрой» выставлять на продажу качественные квартиры, часть из которых реализуются с ремонтом и по приемлемой цене.

-

Корпорация «Познякижилстрой» строго придерживается буквы закона, гарантируя персоналу, своим потребителям и обществу выполнение нормативных требований, связанных с экологией, охраной здоровья и качеством выполняемых работ. На официальном сайте компании опубликованы объекты застройщика, есть описание его политики и последние новости.

-
+
О компании
+
+ userInfo->about ?> +
beginBlock('our_objects'); ?>
-
Наши объекты (12)
+
Наши объекты (totalCount ?>)
  • Последний год
  • @@ -33,164 +42,122 @@ $this->title = 'My Yii Application';
    @@ -199,7 +166,7 @@ $this->title = 'My Yii Application';
@@ -238,64 +212,50 @@ $this->title = 'My Yii Application'; endBlock(); $this->beginBlock('blog'); + /** + * Use $blogProvider for this block + */ ?>
-
-
- -
-
- -
-

240

-
-
-

12

-
-
- Как обшить балкон - вагонкой своими руками: - пошаговая инструкция -
-
-
- -
-
- -
-

240

-
-
-

12

-
-
- Натуральные компоненты - в защитных пропитках для - древесины: природа сама - о себе заботится - -
-
-
+ $blogProvider, + 'options' => [ + 'class' => 'min-post-wr', + ], + 'itemView' => '_company_common_review', + 'itemOptions' => [ + 'class' => 'min-post-block', + ], + 'layout' => '{items}', + ]); + ?>
endBlock(); $this->beginBlock('team'); + /* + * User preloaded $company->teams models + */ + $teams = ArrayHelper::index($company->teams, 'department.name'); // Group team members according to their department ?>
Состав команды
+
@@ -315,19 +275,25 @@ $this->title = 'My Yii Application';
- + - + - + @@ -351,31 +317,41 @@ $this->title = 'My Yii Application';
+ + Петриченко Дмитрий Николаевич 22
+ + Петриченко Дмитрий Николаевич 1
+ + Петриченко Дмитрий Николаевич 3
- + - + - + - + - + @@ -399,19 +375,25 @@ $this->title = 'My Yii Application';
+ + Петриченко Дмитрий Николаевич 22
+ + Петриченко Дмитрий Николаевич 1
+ + Петриченко Дмитрий Николаевич 3
+ + Петриченко Дмитрий Николаевич 10
+ + Петриченко Дмитрий Николаевич 1
- + - + - + @@ -437,25 +419,33 @@ $this->title = 'My Yii Application';
+ + Петриченко Дмитрий Николаевич 22
+ + Петриченко Дмитрий Николаевич 1
+ + Петриченко Дмитрий Николаевич 3
- + - + - + - + @@ -480,25 +470,33 @@ $this->title = 'My Yii Application';
+ + Петриченко Дмитрий Николаевич 22
+ + Петриченко Дмитрий Николаевич 1
+ + Петриченко Дмитрий Николаевич 3
+ + Петриченко Дмитрий Николаевич 3
- + - + - + - + @@ -572,7 +570,8 @@ $this->title = 'My Yii Application'; Развернуть - + diff --git a/frontend/views/performer/common.php b/frontend/views/performer/common.php index 45a9583..a4ebc1f 100755 --- a/frontend/views/performer/common.php +++ b/frontend/views/performer/common.php @@ -1,10 +1,14 @@ params[ 'user' ] = $user; @@ -15,16 +19,64 @@ userInfo->about ?> +
- -
-
Образование:
-
-
+
+
Образование:
+ +
-
-
- + +
+ +
+
+
Собственные разработки, патенты:
+ +
+
+ +
+
+ + +
+
+
Пройденные курсы, тренинги:
+ +
+
+ +
+
+ + jobs )) { ?>
diff --git a/frontend/web/css/style.css b/frontend/web/css/style.css index d907413..01fb4e9 100755 --- a/frontend/web/css/style.css +++ b/frontend/web/css/style.css @@ -6707,4 +6707,7 @@ input[disabled], select[disabled] { .project_owner_control a { display: inline-block; margin: 0 10px; +} +.proektant-profile-courses-content { + margin-bottom: 10px; } \ No newline at end of file -- libgit2 0.21.4
+ + Петриченко Дмитрий Николаевич 22
+ + Петриченко Дмитрий Николаевич 1
+ + Петриченко Дмитрий Николаевич 3
+ + Петриченко Дмитрий Николаевич 3