コード例 #1
0
ファイル: Header.php プロジェクト: modernkernel/yii2-skeleton
 /**
  * @inheritdoc
  * @return string
  */
 public function run()
 {
     $items = [];
     $menus = Menu::find()->where(['status' => Menu::STATUS_ACTIVE, 'position' => 'header'])->orderBy('order')->all();
     foreach ($menus as $menu) {
         $items[] = ['active' => $menu->getActiveStatus(), 'label' => Yii::t('main', $menu->label), 'url' => preg_match('/\\/\\//', $menu->url) ? $menu->url : $menu->route, 'linkOptions' => ['class' => $menu->class]];
     }
     return $this->render('header', ['items' => $items]);
 }
コード例 #2
0
ファイル: MenuController.php プロジェクト: wordnews/wei_shop
 /**
  * Lists all Menu models.
  * @param int $pid
  * @return mixed
  */
 public function actionIndex($pid = 0)
 {
     if (!$this->is_access('menu/index')) {
         Yii::$app->session->setFlash('error', $this->errorInfo);
         return $this->redirect($this->redirectUrl);
     }
     $dataProvider = new ActiveDataProvider(['query' => Menu::find()->where(['pid' => $pid])]);
     Yii::$app->view->params['meta_title'] = '菜单列表';
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }
コード例 #3
0
ファイル: index.php プロジェクト: apuc/admin
function printMenuTree($parent_id)
{
    $menu = Menu::find()->where(['parent_id' => $parent_id])->orderBy('sort')->all();
    foreach ($menu as $m) {
        echo "<li class='sortitem' data-id='{$m->id}' data-parent-id='{$m->parent_id}'><span class='sortMenuLink'>{$m->name}</span> | <a class='editMenu' data-menu-id='{$m->id}' class='sortMenuLink' href='#'>Редактировать</a> | <a data-confirm='Удалить пункт меню?' class='sortMenuLink' href='/secure/menu/menu/delete?id={$m->id}'>Удалить</a>";
        echo "<ul id='sortable' class='ui-sortable'><li class='empty first'></li>";
        printMenuTree($m->id);
        echo "<li class='empty end'></li></ul>";
        echo "</li>";
    }
}
コード例 #4
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Menu::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'status' => $this->status, 'created_by' => $this->created_by, 'updated_by' => $this->updated_by, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'key', $this->key])->andFilterWhere(['like', 'title', $this->title]);
     return $dataProvider;
 }
コード例 #5
0
ファイル: Menu.php プロジェクト: EC-System/SantasAlitas
 public static function getData()
 {
     $rows = Menu::find()->all();
     $arrayData = array();
     foreach ($rows as $row) {
         $row->imagenes = Menu::getMenuImagesById($row->id);
         $arrayData[$row->id] = $row->attributes + ['imagenes' => $row->imagenes];
     }
     $jsonData = Json::encode($arrayData);
     return $jsonData;
 }
コード例 #6
0
 /**
  * Updates an existing Menu model.
  * If update is successful, the browser will be redirected to the 'view' page.
  *
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     $links = Menu::find()->noParents()->andWhere(['not', ['id' => $id]])->active()->all();
     $links = ArrayHelper::map($links, 'id', 'label');
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['index']);
     } else {
         return $this->render('update', ['model' => $model, 'links' => $links]);
     }
 }
コード例 #7
0
ファイル: NavItem.php プロジェクト: beaten-sect0r/yii2-core
 /**
  * Generate menu items for yii\widgets\Menu
  *
  * @param null|array $models
  * @return array
  */
 public static function getMenuItems(array $models = null)
 {
     $items = [];
     if ($models === null) {
         $models = Menu::find()->where(['parent_id' => null])->with('childs')->orderBy(['sort_index' => SORT_ASC])->active()->all();
     }
     foreach ($models as $model) {
         $url = preg_match('/^(http:\\/\\/|https:\\/\\/)/', $model->url) ? $model->url : Yii::$app->request->baseurl . '/' . ltrim($model->url, '/');
         $items[] = ['url' => $url, 'label' => $model->label, 'items' => self::getMenuItems($model->childs), 'active' => $model->url === Yii::$app->request->pathinfo];
     }
     return $items;
 }
コード例 #8
0
ファイル: MenuController.php プロジェクト: writesdown/app-cms
 /**
  * Displays menu page consists of CRUD for Menu and MenuItem model.
  *
  * @param null $id
  * @return mixed
  */
 public function actionIndex($id = null)
 {
     $model = new Menu();
     $postTypes = PostType::find()->where(['menu_builder' => PostType::MENU_BUILDER])->all();
     $taxonomies = Taxonomy::find()->where(['menu_builder' => Taxonomy::MENU_BUILDER])->all();
     if ($available = ArrayHelper::map(Menu::find()->all(), 'id', 'title')) {
         if ($id === null && $available) {
             reset($available);
             $id = key($available);
         }
         $selected = $this->findModel($id);
     }
     return $this->render('index', ['model' => $model, 'available' => $available, 'selected' => isset($selected) ? $selected : null, 'postTypes' => $postTypes, 'taxonomies' => $taxonomies]);
 }
コード例 #9
0
ファイル: MenuSearch.php プロジェクト: CherryPieCo/SB
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Menu::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, 'parent_id' => $this->parent_id]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'type', $this->type]);
     return $dataProvider;
 }
コード例 #10
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Menu::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_menu' => $this->id_menu, 'padre' => $this->padre]);
     $query->andFilterWhere(['like', 'nombre', $this->nombre])->andFilterWhere(['like', 'clase', $this->clase])->andFilterWhere(['like', 'enlace', $this->enlace])->andFilterWhere(['like', 'tipo_enlace', $this->tipo_enlace])->andFilterWhere(['like', 'target', $this->target]);
     return $dataProvider;
 }
コード例 #11
0
ファイル: MenuSearch.php プロジェクト: EC-System/SantasAlitas
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Menu::find();
     $query->joinWith(['categoria']);
     $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, 'id_categoria' => $this->id_categoria, 'precio' => $this->precio, 'create_user' => $this->create_user, 'create_time' => $this->create_time, 'update_user' => $this->update_user, 'update_time' => $this->update_time]);
     $query->andFilterWhere(['like', 'nombre', $this->nombre])->andFilterWhere(['like', 'descripcion', $this->descripcion])->andFilterWhere(['like', 'categoria.nombre', $this->categoria]);
     return $dataProvider;
 }
コード例 #12
0
ファイル: MenuSearch.php プロジェクト: kusma007/one-advanced
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Menu::find();
     // add conditions that should always apply here
     $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;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id, 'parent_id' => $this->parent_id, 'sort' => $this->sort]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'url', $this->url])->andFilterWhere(['like', 'position', $this->position])->andFilterWhere(['like', 'status', $this->status]);
     return $dataProvider;
 }
コード例 #13
0
ファイル: DefaultController.php プロジェクト: BoBRoID/new.k-z
 public function actionEdit($id)
 {
     $model = new MenuForm();
     if (!($desiredModel = Menu::find()->with('items')->where(['id' => $id])->one())) {
         throw new NotFoundHttpException("Не найдено меню с идентификатором {$id}!");
     }
     $model->loadMenu($desiredModel);
     if (\Yii::$app->request->post('MenuForm') && $model->load(\Yii::$app->request->post())) {
         if ($model->save()) {
             \Yii::$app->session->setFlash('success', 'Меню успешно отредактировано!');
         } else {
             \Yii::$app->session->setFlash('error', 'Произошла ошибка при редактировании меню!');
         }
     }
     return $this->render('edit', ['model' => $model]);
 }
コード例 #14
0
ファイル: MenuController.php プロジェクト: hdushku/app-cms
 /**
  * Generates menu page consists of CRUD Menu and MenuItem model.
  *
  * @param null $id
  *
  * @return mixed
  */
 public function actionIndex($id = null)
 {
     $model = new Menu();
     // List all post types
     $postTypes = PostType::find()->where(['post_type_smb' => 1])->all();
     // List all taxonomies
     $taxonomies = Taxonomy::find()->where(['taxonomy_smb' => 1])->all();
     // Get available menu
     if ($availableMenu = ArrayHelper::map(Menu::find()->all(), 'id', 'menu_title')) {
         if ($id === null && $availableMenu) {
             reset($availableMenu);
             $id = key($availableMenu);
         }
         $selectedMenu = $this->findModel($id);
     }
     return $this->render('index', ['model' => $model, 'availableMenu' => $availableMenu, 'selectedMenu' => isset($selectedMenu) ? $selectedMenu : null, 'postTypes' => $postTypes, 'taxonomies' => $taxonomies]);
 }
コード例 #15
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Menu::find();
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['order' => SORT_ASC]]]);
     $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;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id, 'status' => $this->status, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'created_by' => $this->created_by, 'updated_by' => $this->updated_by]);
     $query->andFilterWhere(['like', 'label', $this->label])->andFilterWhere(['like', 'url', $this->url])->andFilterWhere(['like', 'position', $this->position]);
     //$query->andFilterWhere([
     //    'DATE(FROM_UNIXTIME(`created_at`))' => $this->created_at,
     //]);
     return $dataProvider;
 }
コード例 #16
0
ファイル: MenuWidget.php プロジェクト: kusma007/one-advanced
 public function run()
 {
     if (!empty($this->position)) {
         $where = ['position' => $this->position, 'status' => 'on'];
     } else {
         $where = '';
     }
     $data = Menu::find()->where($where)->orderBy('sort')->asArray()->all();
     $menuView = 'menu-header-bottom';
     if ($this->position == 'headerTop') {
         $menuView = 'menu-header-top';
     } else {
         if ($this->position == 'headerBottom') {
             $menuView = 'menu-header-bottom';
         }
     }
     $itemsData = $this->getItems($data);
     $items = $this->getSubItems($itemsData);
     return $this->render($menuView, ['items' => $items]);
 }
コード例 #17
0
ファイル: MenuController.php プロジェクト: huynhtuvinh87/cms
 public function actionView($id)
 {
     $category = $this->getCategories();
     $page = Post::find()->where(['type' => 'page'])->all();
     $model = $this->findModel($id);
     if ($model->load(Yii::$app->request->post())) {
         if (!empty($_POST['category'])) {
             foreach ($_POST['category'] as $value) {
                 $category = Category::findOne($value);
                 $menuitem = new MenuItem();
                 $menuitem->menu_id = $id;
                 //                    if (!empty($category->parent_id))
                 //                        $menuitem->parent_id = $category->parent_id;
                 $menuitem->type_id = $category->id;
                 $menuitem->type = 'category';
                 $menuitem->type_name = $category->title;
                 $menuitem->type_slug = $category->slug;
                 $menuitem->order = 0;
                 $menuitem->save();
             }
             return $this->redirect(['view', 'id' => $model->id]);
         }
         if (!empty($_POST['page'])) {
             foreach ($_POST['page'] as $value) {
                 $page = Post::findOne($value);
                 $menuitem = new MenuItem();
                 $menuitem->menu_id = $id;
                 $menuitem->type_id = $page->id;
                 $menuitem->type = 'page';
                 $menuitem->type_name = $page->title;
                 $menuitem->type_slug = $page->slug;
                 $menuitem->order = 0;
                 $menuitem->save();
             }
             return $this->redirect(['view', 'id' => $model->id]);
         }
     }
     $menuitem = MenuItem::find()->where(['menu_id' => $id])->orderBy(['order' => SORT_ASC])->all();
     $menuall = Menu::find()->all();
     return $this->render('view', ['category' => $category, 'page' => $page, 'model' => $model, 'menuitem' => $menuitem, 'menuall' => $menuall]);
 }
コード例 #18
0
 public function actions()
 {
     return ['index' => ['class' => IndexAction::className(), 'query' => Menu::find()]];
 }
コード例 #19
0
ファイル: _form.php プロジェクト: EC-System/SantasAlitas
use common\models\Sucursal;
use yii\helpers\ArrayHelper;
use kartik\widgets\DateTimePicker;
/* @var $this yii\web\View */
/* @var $model common\models\Promocion */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="promocion-form">

    <?php 
$form = ActiveForm::begin();
?>

    <?php 
echo $form->field($model, 'id_menu')->dropDownList(ArrayHelper::map(Menu::find()->all(), 'id', 'nombre'), ['prompt' => 'Seleccione menú']);
?>

    <?php 
echo $form->field($model, 'id_sucursal')->dropDownList(ArrayHelper::map(Sucursal::find()->all(), 'id', 'nombre'), ['prompt' => 'Seleccione sucursal']);
?>

    <?php 
echo $form->field($model, 'precio')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'descripcion')->textInput(['maxlength' => true]);
?>

    <?php 
コード例 #20
0
 /**
  * @inheritdoc
  * @return array
  */
 public function actions()
 {
     return ['sorting' => ['class' => Sorting::className(), 'query' => Menu::find()]];
 }
コード例 #21
0
ファイル: index.php プロジェクト: beaten-sect0r/yii2-core
<?php

use yii\bootstrap\Html;
use yii\grid\GridView;
use yii\helpers\ArrayHelper;
use common\models\Menu;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\search\MenuSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('backend', 'Menu');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="menu-index">

    <p>
        <?php 
echo Html::a(Yii::t('backend', 'Create item'), ['create'], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => ['label', ['attribute' => 'parent_id', 'value' => function ($model) {
    return $model->parent ? $model->parent->label : null;
}, 'filter' => ArrayHelper::map(Menu::find()->noParents()->all(), 'id', 'label')], ['attribute' => 'status', 'format' => 'html', 'value' => function ($model) {
    return $model->status ? '<span class="glyphicon glyphicon-ok text-success"></span>' : '<span class="glyphicon glyphicon-remove text-danger"></span>';
}, 'filter' => [Menu::STATUS_DRAFT => Yii::t('backend', 'Not active'), Menu::STATUS_ACTIVE => Yii::t('backend', 'Active')]], 'sort_index', ['class' => 'yii\\grid\\ActionColumn', 'template' => '{update} {delete}']]]);
?>

</div>
コード例 #22
0
ファイル: MenuController.php プロジェクト: 171906502/wetM2.0
 public function actionGroupMenu($group_id)
 {
     $models = Menu::find()->where(['group_id' => $group_id])->all();
     return $this->render('group-menu', ['models' => $models]);
 }
コード例 #23
0
ファイル: Menu.php プロジェクト: kusma007/one-advanced
 public function getAllMenu()
 {
     return Menu::find()->where(['status' => 'on'])->all();
 }