/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Domain::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); // Important: here is how we set up the sorting // The key is the attribute name on our "TourSearch" instance $dataProvider->sort->attributes['search_date_created'] = ['asc' => ['created_at' => SORT_ASC], 'desc' => ['created_at' => SORT_DESC]]; // Important: here is how we set up the sorting // The key is the attribute name on our "TourSearch" instance $dataProvider->sort->attributes['search_date_updated'] = ['asc' => ['updated_at' => SORT_ASC], 'desc' => ['updated_at' => SORT_DESC]]; $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'status' => $this->status, 'locale_group_id' => $this->locale_group_id, 'dealer_id' => $this->dealer_id]); if ($this->search_date_created != '') { $this->data_begin_created = strtotime($this->search_date_created); $this->data_end_created = strtotime($this->search_date_created) + 24 * 60 * 60; } if ($this->search_date_updated != '') { $this->data_begin_updated = strtotime($this->search_date_updated); $this->data_end_updated = strtotime($this->search_date_updated) + 24 * 60 * 60; } $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['between', 'created_at', $this->data_begin_created, $this->data_end_created])->andFilterWhere(['between', 'updated_at', $this->data_begin_updated, $this->data_end_updated])->andFilterWhere(['like', 'locale', $this->locale]); return $dataProvider; }
/** * @return array */ private function _getHeaderCustomParams() { $result = []; if ($domain = Domain::findOne(['id' => $this->domain_id])) { if ($domain->desktopLogoUrl) { $result['logo_url'] = $domain->desktopLogoUrl; } if ($domain->mobileLogoUrl) { $result['m_logo_url'] = $domain->mobileLogoUrl; } } return $result; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Domain::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'status' => $this->status, 'locale_group_id' => $this->locale_group_id, 'dealer_id' => $this->dealer_id]); $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'locale', $this->locale]); return $dataProvider; }
echo Yii::t('backend', 'Extend page'); ?> <span class="caret"></span> </button> <ul class="dropdown-menu" aria-labelledby="dropdownMenu1"> <?php foreach ($list as $key => $value) { echo '<li><a href="/page/create?locale_group_id=' . $key . '&scenario=extend">' . $value . '</a></li>'; } ?> </ul> </span> <?php $columns = ['id', 'title', 'slug', 'status', ['class' => 'yii\\grid\\ActionColumn', 'template' => '{update} {log} {delete}', 'buttons' => ['log' => function ($url, $model) { $customurl = Yii::$app->getUrlManager()->createUrl(['timeline-event/index', 'TimelineEventSearch[category]' => 'common\\models\\locale\\Page', 'TimelineEventSearch[row_id]' => $model->id]); return Html::a('<span class="glyphicon glyphicon-time"></span>', $customurl, ['title' => Yii::t('yii', 'Log'), 'data-pjax' => '0']); }]]]; if (\Yii::$app->user->can('administrator')) { // adding after status array_splice($columns, 4, 0, [['attribute' => 'domain_id', 'content' => function ($model) { $domain = Domain::findOne($model->domain_id); $domain = $domain ? $domain->title : ''; return Html::tag('div', $model->domain_id, ['data-toggle' => 'tooltip', 'data-placement' => 'left', 'title' => $domain, 'style' => 'cursor:default;']); }]]); } echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => $columns]); ?> </div>
private function _getDomainsArray() { $domainsArray = ArrayHelper::map(Domain::find()->active()->all(), 'id', 'title'); $domainsArray['0'] = ''; ksort($domainsArray); return $domainsArray; }
/** * @return \yii\db\ActiveQuery */ public function getDomains() { return $this->hasMany(Domain::className(), ['site_id' => 'id']); }
/** * Finds the Domain model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Domain the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Domain::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
<?php $forms = ['label' => Yii::t('backend', 'Forms'), 'icon' => '<i class="fa fa-edit"></i>', 'options' => ['class' => 'treeview'], 'items' => [['label' => Yii::t('backend', 'Subscribes'), 'url' => ['/subscribes/index'], 'icon' => '<i class="fa fa-angle-double-right"></i>'], ['label' => Yii::t('backend', 'Corporate Sales'), 'url' => ['/corporate/index'], 'icon' => '<i class="fa fa-angle-double-right"></i>']]]; $feedbacks = ['label' => Yii::t('backend', 'Feedback'), 'icon' => '<i class="fa fa-envelope-o"></i>', 'options' => ['class' => 'treeview'], 'items' => [['label' => Yii::t('backend', 'Emails'), 'url' => ['/emailf/index'], 'icon' => '<i class="fa fa-at"></i>'], ['label' => Yii::t('backend', 'Questions'), 'url' => ['/feedback/index'], 'icon' => '<i class="fa fa-comments-o"></i>']]]; ?> <?php } else { ?> <?php $feedbacks = ['label' => Yii::t('backend', 'Feedback'), 'icon' => '<i class="fa fa-envelope-o"></i>', 'options' => ['class' => 'treeview'], 'url' => ['/feedback/index']]; ?> <?php } ?> <?php echo Menu::widget(['options' => ['class' => 'sidebar-menu'], 'labelTemplate' => '<a href="#">{icon}<span>{label}</span>{right-icon}{badge}</a>', 'linkTemplate' => '<a href="{url}">{icon}<span>{label}</span>{right-icon}{badge}</a>', 'submenuTemplate' => "\n<ul class=\"treeview-menu\">\n{items}\n</ul>\n", 'activateParents' => true, 'items' => [['label' => Yii::t('backend', 'Timeline'), 'icon' => '<i class="fa fa-bar-chart-o"></i>', 'url' => ['/timeline-event/index'], 'badge' => TimelineEvent::find()->today()->count(), 'badgeBgClass' => 'label-success'], ['label' => Yii::t('backend', 'Content'), 'icon' => '<i class="fa fa-edit"></i>', 'options' => ['class' => 'treeview'], 'items' => [['label' => Yii::t('backend', 'Pages'), 'url' => ['/page/index'], 'icon' => '<i class="fa fa-angle-double-right"></i>', 'active' => preg_match('/^page/', Yii::$app->request->pathinfo)], ['label' => Yii::t('backend', 'News'), 'url' => ['/article/index'], 'icon' => '<i class="fa fa-angle-double-right"></i>', 'active' => preg_match('/^article/', Yii::$app->request->pathinfo)], ['label' => Yii::t('backend', 'Promo'), 'url' => ['/promo/index'], 'icon' => '<i class="fa fa-angle-double-right"></i>', 'active' => preg_match('/^promo/', Yii::$app->request->pathinfo)], ['label' => Yii::t('backend', 'Models'), 'icon' => '<i class="fa fa-edit"></i>', 'options' => ['class' => 'treeview'], 'items' => [['label' => Yii::t('backend', 'Categories'), 'url' => ['/model-category/index'], 'icon' => '<i class="fa fa-angle-double-right"></i>'], ['label' => Yii::t('backend', 'List'), 'icon' => '<i class="fa fa-edit"></i>', 'options' => ['class' => 'treeview'], 'items' => Model::getLeftMenuListItems()], ['label' => Yii::t('backend', 'Pages'), 'icon' => '<i class="fa fa-edit"></i>', 'options' => ['class' => 'treeview'], 'items' => Model::getLeftMenuPageItems()]]], $forms, ['label' => Yii::t('backend', 'Service pages'), 'icon' => '<i class="fa fa-edit"></i>', 'options' => ['class' => 'treeview'], 'items' => Service::getLeftMenuItems()], ['label' => Yii::t('backend', 'About pages'), 'icon' => '<i class="fa fa-edit"></i>', 'options' => ['class' => 'treeview'], 'items' => About::getLeftMenuItems()], ['label' => Yii::t('backend', 'Finance pages'), 'icon' => '<i class="fa fa-edit"></i>', 'options' => ['class' => 'treeview'], 'items' => Finance::getLeftMenuItems()], ['label' => Yii::t('backend', 'Common blocks'), 'url' => ['/block/index'], 'icon' => '<i class="fa fa-angle-double-right"></i>']]], ['label' => Yii::t('backend', 'SEO'), 'icon' => '<i class="fa fa-edit"></i>', 'options' => ['class' => 'treeview'], 'items' => [['label' => Yii::t('backend', 'robots.txt'), 'url' => ['widget-text/update?id=frontend.web.robots.txt'], 'icon' => '<i class="fa fa-angle-double-right"></i>'], ['label' => Yii::t('backend', 'sitemap.xml'), 'url' => Domain::getFrontendUrl() . '/sitemap.xml', 'icon' => '<i class="fa fa-angle-double-right"></i>', 'template' => '<a href="{url}" target="_blank"><i class="fa fa-angle-double-right"></i><span>{label}</span></a>'], ['label' => Yii::t('backend', 'Third-party code'), 'url' => ['custom-code/index'], 'icon' => '<i class="fa fa-angle-double-right"></i>']]], $feedbacks, ['label' => Yii::t('backend', 'Domains'), 'icon' => '<i class="fa fa-university"></i>', 'url' => ['/domain/index'], 'visible' => Yii::$app->user->can('administrator')], ['label' => Yii::t('backend', 'Users'), 'icon' => '<i class="fa fa-users"></i>', 'url' => ['/user/index'], 'visible' => Yii::$app->user->can('administrator')], ['label' => Yii::t('backend', 'System'), 'icon' => '<i class="fa fa-cogs"></i>', 'options' => ['class' => 'treeview'], 'visible' => Yii::$app->user->can('administrator'), 'items' => [['label' => Yii::t('backend', 'i18n'), 'icon' => '<i class="fa fa-flag"></i>', 'options' => ['class' => 'treeview'], 'items' => [['label' => Yii::t('backend', 'i18n Source Message'), 'url' => ['/i18n/i18n-source-message/index'], 'icon' => '<i class="fa fa-angle-double-right"></i>'], ['label' => Yii::t('backend', 'i18n Message'), 'url' => ['/i18n/i18n-message/index'], 'icon' => '<i class="fa fa-angle-double-right"></i>']]], ['label' => Yii::t('backend', 'Key-Value Storage'), 'url' => ['/key-storage/index'], 'icon' => '<i class="fa fa-angle-double-right"></i>'], ['label' => Yii::t('backend', 'File Storage'), 'url' => ['/file-storage/index'], 'icon' => '<i class="fa fa-angle-double-right"></i>'], ['label' => Yii::t('backend', 'Cache'), 'url' => ['/cache/index'], 'icon' => '<i class="fa fa-angle-double-right"></i>'], ['label' => Yii::t('backend', 'File Manager'), 'url' => ['/file-manager/index'], 'icon' => '<i class="fa fa-angle-double-right"></i>'], ['label' => Yii::t('backend', 'Widgets list'), 'url' => ['/site/widgets'], 'icon' => '<i class="fa fa-angle-double-right"></i>'], ['label' => Yii::t('backend', 'Logs'), 'url' => ['/log/index'], 'icon' => '<i class="fa fa-angle-double-right"></i>', 'badge' => \backend\models\SystemLog::find()->count(), 'badgeBgClass' => 'label-danger']]]]]); ?> </section> <!-- /.sidebar --> </aside> <!-- Right side column. Contains the navbar and content of the page --> <aside class="content-wrapper"> <!-- Content Header (Page header) --> <section class="content-header"> <h1> <?php echo $this->title; ?> <?php if (isset($this->params['subtitle'])) {
/** * @return \yii\db\ActiveQuery */ public function getDomain() { return $this->hasOne(Domain::className(), ['id' => 'domain_id']); }