예제 #1
0
 public function actionOrder($id = null, $ordering = null, $direction = null)
 {
     if ($id != null || $ordering != null || $direction != null) {
         $sess = Yii::$app->session->get('sessMenus');
         if ($direction == "up") {
             $newSortOrder = $ordering - 1;
         } else {
             if ($direction == "down") {
                 $newSortOrder = $ordering + 1;
             }
         }
         $parent = Menus::find($id);
         $where = array();
         $where[] = "ordering = '{$newSortOrder}'";
         $where[] = "langs = '" . $sess['langs'] . "'";
         $where[] = "parent_id = '" . $parent->parent_id . "'";
         $connection = Yii::$app->db;
         $sql = "SELECT id FROM tbl_menus " . (count($where) ? "\n WHERE " . implode(' AND ', $where) : '');
         $command = $connection->createCommand($sql);
         $reader = $command->query();
         foreach ($reader as $row) {
             $otherId = $row["id"];
         }
         $where = array();
         $where[] = "id = '{$id}'";
         $where[] = "langs = '" . $sess['langs'] . "'";
         $where[] = "parent_id = '" . $parent->parent_id . "'";
         $sql = 'UPDATE tbl_menus SET ordering = "' . $newSortOrder . '" ' . (count($where) ? "\n WHERE " . implode(' AND ', $where) : '');
         $command = $connection->createCommand($sql);
         $command->execute();
         if ($reader->getRowCount() > 0) {
             $where = array();
             $where[] = "id = '{$otherId}'";
             $where[] = "langs = '" . $sess['langs'] . "'";
             $where[] = "parent_id = '" . $parent->parent_id . "'";
             $sql = 'UPDATE tbl_menus SET ordering = "' . $ordering . '"' . (count($where) ? "\n WHERE " . implode(' AND ', $where) : '');
             $command = $connection->createCommand($sql);
             $command->execute();
         }
         return $this->redirect(['index']);
     }
 }
예제 #2
0
파일: menuSub.php 프로젝트: aiyeyun/grab
                    <i class="fa fa-pencil fa-stack-1x fa-inverse"></i>
                </span>
            </a>
            <a href="javascript: void(0)" class="table-link danger menu-delete" data-info="当前操作: <?php 
    echo name($sub->father_id2, $sub->father_id3) . ' - [' . $sub->name . ']';
    ?>
" data-url="<?php 
    echo Url::to('/admin/settings/delete');
    ?>
" data-id="<?php 
    echo $sub->id;
    ?>
">
                <span class="fa-stack">
                    <i class="fa fa-square fa-stack-2x"></i>
                    <i class="fa fa-trash-o fa-stack-1x fa-inverse"></i>
                </span>
            </a>
        </td>
    </tr>

    <?php 
    $menuSub3 = Menus::menuSub(3, $sub->id);
    if ($menuSub3) {
        ?>
        <?php 
        echo $this->render('menuSub', ['menuSub' => $menuSub3]);
        ?>
    <?php 
    }
}
예제 #3
0
        }
        ?>
                            </a>
                            <!-- 二级菜单栏 start -->
                            <?php 
        if ($menu2) {
            ?>
                                <ul class="submenu">
                                    <?php 
            foreach ($menu2 as $menu) {
                ?>
                                    <?php 
                if ($menu->state) {
                    ?>
                                    <?php 
                    $menu3 = Menus::menuSub(3, $menu->id);
                    ?>
                                        <li>
                                            <script>
                                                <?php 
                    if (active($menu->controller, $menu->action)) {
                        ?>
                                                    $(function(){
                                                        var a = $('a[href="<?php 
                        echo $menu->controller . '/' . $menu->action;
                        ?>
"]');
                                                        a.parent().parent().parent().addClass('open active');
                                                    })
                                                <?php 
                    }
예제 #4
0
 public function listMenus($parent, $level, $type)
 {
     $connection = \Yii::$app->db;
     $sql = "SELECT a.id, a.names, a.icons, a.urls, a.type, a.target, Deriv1.Count FROM `tbl_menus` a  " . "LEFT OUTER JOIN (SELECT parent_id, COUNT(*) AS Count FROM `tbl_menus` GROUP BY parent_id) " . "Deriv1 ON a.id = Deriv1.parent_id WHERE a.parent_id=" . $parent . " AND a.published=1 AND " . "a.type=" . $type . " ORDER BY a.ordering";
     $command = $connection->createCommand($sql);
     $reader = $command->query();
     $data = array();
     foreach ($reader as $r) {
         if ($r['Count'] > 0) {
             $data['label'] = '<i class="' . $r['icons'] . '"></i> ' . $r['names'];
             $data['url'] = $r['article_id'] ? ['default/view', 'id' => $r['article_id']] : $r['urls'];
             $data['items'] = Menus::listMenus($r['id'], $level + 1, $type);
         } else {
             $data['label'] = '<i class="' . $r['icons'] . '"></i> ' . $r['names'];
             $htt = substr($r['urls'], 0, 4);
             $data['url'] = $htt == 'http' ? $r['urls'] : $r['urls'];
             if ($r['target'] == 1) {
                 $data['linkOptions'] = ['target' => '_blank'];
             }
             unset($data['items']);
         }
         $items[] = $data;
     }
     return $items;
 }
예제 #5
0
 /**
  * Finds the User model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return User the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Menus::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
예제 #6
0
파일: main.php 프로젝트: jatuponp/discovery
                        </div>

                        <div class="col_one_fifth col_last">

                            <?php 
$r3 = $rows[3];
?>
                            <div class="widget widget_links clearfix">

                                <h4><?php 
echo $r3->names;
?>
</h4>
                                <ul>
                                    <?php 
$que = \app\models\Menus::find()->where(['parent_id' => $r3->id, 'published' => 1])->orderBy('ordering');
$row = $que->all();
foreach ($row as $s) {
    ?>
                                        <li><a href="<?php 
    echo $s->urls;
    ?>
"><?php 
    echo $s->names;
    ?>
</a></li>
                                    <?php 
}
?>
                                </ul>
                            </div>
예제 #7
0
 public function listMenusSub($parent, $space = '|---')
 {
     global $arr;
     $children = Menus::find()->where(['parent_id' => $parent])->orderBy('ordering')->all();
     foreach ($children as $child) {
         $data = array();
         $data['id'] = $child->id;
         $data['name'] = $space . ' ' . $child->names;
         $arr[] = $data;
         $this->listMenusSub($child->id, $space . ' ---');
     }
 }
예제 #8
0
파일: menus.php 프로젝트: aiyeyun/grab
            <a href="javascript: void(0)" class="table-link danger menu-delete" data-info="当前操作: <?php 
    echo name($m->father_id2, $m->father_id3) . ' - [' . $m->name . ']';
    ?>
" data-url="<?php 
    echo Url::to('/admin/settings/delete');
    ?>
" data-id="<?php 
    echo $m->id;
    ?>
" >
                <span class="fa-stack">
                    <i class="fa fa-square fa-stack-2x"></i>
                    <i class="fa fa-trash-o fa-stack-1x fa-inverse"></i>
                </span>
            </a>
        </td>
    </tr>

    <?php 
    $menuSub = Menus::menuSub(2, $m->id);
    if ($menuSub) {
        ?>
        <?php 
        echo $this->render('menuSub', ['menuSub' => $menuSub]);
        ?>
    <?php 
    }
    ?>

<?php 
}
예제 #9
0
파일: _form.php 프로젝트: aiyeyun/grab
    ?>
                    <?php 
    echo $form->field($model, 'state')->dropDownList([0 => '隐藏', 1 => '显示']);
    ?>
                <?php 
}
?>
                <!--添加 三级菜单 表单-->
                <?php 
if ($type == 3) {
    ?>
                    <?php 
    echo $form->field($model, 'id')->label(false)->hiddenInput();
    ?>
                    <?php 
    echo $form->field($model, 'father_id3')->label('请选择父级菜单')->dropDownList(ArrayHelper::map(Menus::menus(2), 'id', 'name'));
    ?>
                    <?php 
    echo $form->field($model, 'name')->textInput(['placeholder' => '菜单名']);
    ?>
                    <?php 
    echo $form->field($model, 'controller')->textInput(['placeholder' => 'Controller 控制器']);
    ?>
                    <?php 
    echo $form->field($model, 'action')->textInput(['placeholder' => 'Action 方法']);
    ?>
                    <?php 
    echo $form->field($model, 'sort')->label('排序 - (三位数)')->textInput(['placeholder' => '排序', 'type' => 'number', 'maxlength' => 3]);
    ?>
                    <?php 
    echo $form->field($model, 'state')->dropDownList([0 => '隐藏', 1 => '显示']);
예제 #10
0
파일: main.php 프로젝트: KokLip/GST
?>
<div class="wrap">
    <?php 
NavBar::begin(['brandLabel' => 'GST', 'brandUrl' => Yii::$app->homeUrl, 'options' => ['class' => 'navbar-inverse navbar-fixed-top']]);
echo Nav::widget(['options' => ['class' => 'navbar-nav navbar-right'], 'items' => [Yii::$app->user->isGuest ? ['label' => 'Login', 'url' => ['/site/login']] : ['label' => 'Logout (' . Yii::$app->user->identity->user_name . ')', 'url' => ['/site/logout'], 'linkOptions' => ['data-method' => 'post']]]]);
NavBar::end();
?>
	
	<?php 
if (!Yii::$app->user->isGuest) {
    ?>
		<div class="container-fluid">
		  <div class="row">
			<div class="col-md-2 sidebar">
			<?php 
    echo Menu::widget(['items' => Menus::getItems(), 'options' => ['class' => 'nav nav-sidebar']]);
    ?>
			</div>	
			<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
				<?php 
    echo Breadcrumbs::widget(['links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : []]);
    ?>
			<?php 
    echo $content;
    ?>
			
			</div>
		  </div>
		</div>
	<?php 
} else {