Example #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = MenuType::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'created_by' => $this->created_by, 'updated_by' => $this->updated_by, 'lock' => $this->lock]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'alias', $this->alias])->andFilterWhere(['like', 'note', $this->note]);
     return $dataProvider;
 }
Example #2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getMenuType()
 {
     return $this->hasOne(MenuType::className(), ['id' => 'menu_type_id']);
 }
Example #3
0
        <div class="col-sm-6">
            <?php 
//= $form->field($model, 'language', ['horizontalCssClasses' => ['wrapper' => 'col-xs-8 col-sm-4', 'label' => 'col-xs-4 col-sm-3']])->dropDownList(Yii::$app->getAcceptedLanguagesList(), ['prompt' => Yii::t('gromver.platform', 'Select ...')])
?>
        </div>
        <div class="col-sm-6">
            <?php 
echo $form->field($model, 'note', ['wrapperOptions' => ['class' => 'col-sm-9']])->textInput(['maxlength' => 255]);
?>
        </div>
    </div>

    <div class="row">
        <div class="col-sm-6">
            <?php 
echo $form->field($model, 'menu_type_id', ['wrapperOptions' => ['class' => 'col-sm-9']])->dropDownList(['' => Yii::t('gromver.platform', 'Select ...')] + \yii\helpers\ArrayHelper::map(\app\modules\menu\models\MenuType::find()->all(), 'id', 'title'));
?>
        </div>
        <div class="col-sm-6">
            <?php 
$idLanguage = Html::getInputId($model, 'language');
$idMenu_type_id = Html::getInputId($model, 'menu_type_id');
$idParent_id = Html::getInputId($model, 'parent_id');
echo $form->field($model, 'parent_id', ['wrapperOptions' => ['class' => 'col-sm-9'], 'inputTemplate' => '<div class="input-group select2-bootstrap-append">{input}' . \app\widgets\ModalIFrame::widget(['options' => ['class' => 'input-group-addon', 'title' => \Yii::t('gromver.platform', 'Select Category')], 'label' => '<i class="glyphicon glyphicon-folder-open"></i>', 'url' => ['select', 'modal' => true, 'MenuItemSearch[excludeItem]' => $model->isNewRecord ? null : $model->id], 'dataHandler' => <<<JS
                            function(data) {
    \$("#{$idParent_id}").html('<option value="' + data.id + '">' + data.title + '</option>').val(data.id).trigger('change');
}
JS
, 'actionHandler' => 'function(url) {return (new URI(url)).addSearch("MenuItemSearch[language]", $("#' . $idLanguage . '").val()).addSearch("MenuItemSearch[menu_type_id]", $("#' . $idMenu_type_id . '").val())}']) . '</div>'])->widget(\kartik\select2\Select2::className(), ['initValueText' => $model->parent ? $model->parent->isRoot() ? Yii::t('gromver.platform', 'Top Level') : $model->parent->title : null, 'theme' => \kartik\select2\Select2::THEME_BOOTSTRAP, 'pluginOptions' => ['allowClear' => true, 'placeholder' => Yii::t('gromver.platform', 'Top Level'), 'ajax' => ['url' => \yii\helpers\Url::to(['item-list', 'exclude' => $model->isNewRecord ? null : $model->id]), 'data' => new \yii\web\JsExpression('function(params) { return {q:params.term, language:$("#' . $idLanguage . '").val(), menu_type_id:$("#' . $idMenu_type_id . '").val()}; }')]]]);
?>
Example #4
0
$this->title = Yii::t('gromver.platform', 'Select Menu Item');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="menu-index">

	<?php 
/*<h1><?= Html::encode($this->title) ?></h1>*/
?>

	<?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

	<?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'id' => 'grid', 'pjax' => true, 'pjaxSettings' => ['neverTimeout' => true], 'columns' => [['attribute' => 'id', 'hAlign' => GridView::ALIGN_CENTER, 'vAlign' => GridView::ALIGN_MIDDLE, 'width' => '60px'], ['attribute' => 'language', 'hAlign' => GridView::ALIGN_CENTER, 'vAlign' => GridView::ALIGN_MIDDLE, 'width' => '60px', 'filter' => Yii::$app->getAcceptedLanguagesList()], ['attribute' => 'menu_type_id', 'vAlign' => GridView::ALIGN_MIDDLE, 'width' => '120px', 'value' => function ($model) {
    /** @var $model \app\modules\menu\models\MenuItem */
    return $model->menuType->title;
}, 'filter' => \yii\helpers\ArrayHelper::map(\app\modules\menu\models\MenuType::find()->all(), 'id', 'title')], ['attribute' => 'title', 'vAlign' => GridView::ALIGN_MIDDLE, 'value' => function ($model) {
    /** @var $model \app\modules\menu\models\MenuItem */
    return str_repeat(" • ", max($model->level - 2, 0)) . $model->title . '<br/>' . Html::tag('small', $model->path, ['class' => 'text-muted']);
}, 'format' => 'html'], ['attribute' => 'status', 'hAlign' => GridView::ALIGN_CENTER, 'vAlign' => GridView::ALIGN_MIDDLE, 'value' => function ($model) {
    /** @var $model \app\modules\menu\models\MenuItem */
    return $model->getStatusLabel();
}, 'width' => '150px', 'filter' => \app\modules\menu\models\MenuItem::statusLabels()], ['header' => Yii::t('gromver.platform', 'Action'), 'hAlign' => GridView::ALIGN_CENTER, 'vAlign' => GridView::ALIGN_MIDDLE, 'value' => function ($model) {
    /** @var $model \app\modules\menu\models\MenuItem */
    return Html::a(Yii::t('gromver.platform', 'Select'), '#', ['class' => 'btn btn-primary btn-xs', 'onclick' => \gromver\widgets\ModalIFrame::postDataJs(['id' => $model->id, 'title' => $model->title, 'description' => Yii::t('gromver.platform', 'Menu Item: {title}', ['title' => $model->title]), 'route' => Yii::$app->urlManager->createUrl($model->getFrontendViewLink()), 'link' => Yii::$app->urlManager->createUrl($model->getFrontendViewLink()), 'value' => $model->id . ':' . $model->alias])]);
}, 'width' => '80px', 'mergeHeader' => true, 'format' => 'raw']], 'responsive' => true, 'hover' => true, 'condensed' => true, 'floatHeader' => true, 'floatHeaderOptions' => ['scrollingTop' => 0], 'bordered' => false, 'panel' => ['heading' => '<h3 class="panel-title"><i class="glyphicon glyphicon-th-list"></i> ' . Html::encode($this->title) . '</h3>', 'type' => 'info', 'after' => Html::a('<i class="glyphicon glyphicon-repeat"></i> ' . Yii::t('gromver.platform', 'Reset List'), [null], ['class' => 'btn btn-info']), 'showFooter' => false]]);
?>

</div>
Example #5
0
 /**
  * Finds the Menu model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return MenuType the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = MenuType::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException(Yii::t('gromver.platform', 'The requested page does not exist.'));
     }
 }