/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Module::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, 'status' => $this->status, 'order_num' => $this->order_num]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'class', $this->class])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'icon', $this->icon])->andFilterWhere(['like', 'settings', $this->settings]); return $dataProvider; }
public function activeModules() { $this->activeModules = Module::findAllActive(); $modules = []; foreach ($this->activeModules as $name => $module) { $settings = []; $modules[$name]['class'] = $module->class; if (!empty($module->settings)) { $settings = \yii\helpers\Json::decode($module->settings); } if (is_array($settings)) { $modules[$name]['settings'] = $settings; } } return $modules; }
/** * Finds the Module model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Module the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Module::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
$this->beginBody(); ?> <div class="wrap"> <?php NavBar::begin(['brandLabel' => 'Management Infomation Sysytem', 'brandUrl' => Yii::$app->homeUrl, 'options' => ['class' => 'navbar-inverse navbar-fixed-top']]); echo Nav::widget(['options' => ['class' => 'navbar-nav navbar-right'], 'items' => [['label' => 'Home', 'url' => ['/site/index']], ['label' => 'About', 'url' => ['/site/about']], ['label' => 'Contact', 'url' => ['/site/contact']], Yii::$app->user->isGuest ? ['label' => 'Login', 'url' => ['/site/login']] : '<li>' . Html::beginForm(['/site/logout'], 'post') . Html::submitButton('Logout (' . Yii::$app->user->identity->username . ')', ['class' => 'btn btn-link']) . Html::endForm() . '</li>']]); NavBar::end(); ?> <div class="container"> <div class="row"> <div class="col-sm-2"> <div class="list-group"> <?php $modules = Module::findAllActive(); foreach ($modules as $key => $module) { echo Html::a('<i class="' . $module->icon . '"></i> ' . $module->title, ["/psudev/" . $module->name], ['class' => 'list-group-item']); } ?> <?php echo Html::tag('hr'); echo Html::a('<i class="glyphicon glyphicon-cog"></i> Module settings', ["/psudev/settings"], ['class' => 'btn btn-primary btn-block']); ?> </div> </div> <div class="col-sm-10"> <?php echo Breadcrumbs::widget(['links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : []]); ?> <?php