<div class="mwx-menu-index"> <p> <?php echo Html::a(Yii::t('backend', 'Create Wechat Menu'), ['create'], ['class' => 'btn btn-success']); ?> <?php echo Html::a(Yii::t('backend', 'Save Menu From Wechat'), ['export'], ['class' => 'btn btn-success']); ?> <?php echo Html::a(Yii::t('backend', 'Import Menu From Wechat'), ['import'], ['class' => 'btn btn-success']); ?> </p> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'columns' => [['label' => '菜单ID', 'attribute' => 'wx_menu_id'], ['label' => '标题', 'attribute' => 'name', 'value' => function ($model, $key, $index, $column) { return $model->parent_id == 0 ? $model->name : "----" . $model->name; }, 'headerOptions' => array('style' => 'width:240px;')], ['label' => '菜单类型', 'attribute' => 'type', 'value' => function ($model, $key, $index, $column) { return MWxMenu::getMenuTypeOptionName($model->type); }, 'filter' => MWxMenu::getMenuTypeOptionName()], ['label' => '关键字', 'attribute' => 'keyword'], ['label' => '链接地址', 'attribute' => 'url'], ['label' => '是否包括子菜单', 'attribute' => 'is_sub_button', 'value' => function ($model, $key, $index, $column) { return $model->is_sub_button ? '是' : ''; }], ['label' => '父菜单ID', 'attribute' => 'parent_id'], 'sort_order', ['class' => 'yii\\grid\\ActionColumn', 'template' => '{update} {delete}']]]); ?> </div> <?php /* <? Html::a(Yii::t('backend', 'Get Menu From Wechat'), ['import'], ['class' => 'btn btn-success']) ?> */
public static function getMaxSortOrder($gh_id) { $model = MWxMenu::find()->where(['gh_id' => $gh_id])->orderBy(['sort_order' => SORT_DESC])->one(); return empty($model->sort_order) ? 0 : $model->sort_order; }
echo $form->field($model, 'name')->textInput(['maxlength' => 64]); ?> <div class="is_sub_button"> <?php echo $form->field($model, 'is_sub_button')->dropDownList(MWxMenu::getSubButtonOptionName())->label('是否是目录菜单'); ?> </div> <div class="leaf"> <?php echo $form->field($model, 'parent_id')->dropDownList(\yii\helpers\ArrayHelper::map(MWxMenu::getSubModels($gh->gh_id), 'wx_menu_id', 'name'))->label('父菜单'); ?> <?php echo $form->field($model, 'type')->dropDownList(MWxMenu::getMenuTypeOptionName()); ?> <div class="click"> <?php echo $form->field($model, 'keyword')->textInput(['maxlength' => 128]); ?> </div> <div class="view"> <?php echo $form->field($model, 'url')->textInput(['maxlength' => 512]); ?> </div> </div>
public function actionImport() { $gh = Yii::$app->user->gh; MWxMenu::importFromWechat($gh->gh_id); return $this->redirect(['index']); }