public function index() { $Menu = M('Menu'); $indexchild = $Menu->where('pid=1')->order('listorder,id')->select(); $index = $Menu->where('id=1')->find(); $list = $Menu->where('pid<>1 AND status=1')->order('listorder,id')->select(); foreach ($list as $item) { $item['name'] = L($item['name']); $item['icon'] = $item['icon'] ? '<span class="' . $item['icon'] . '"></span>' : ''; $item['url'] = U($item['model'] . '/' . $item['action'], $item['data'] . '&' . $this->vl); $item['tar'] = $item['id'] == 1 ? 'noa' : 'tarmain'; $newarr[] = $item; } $atag = "<a class='dropdown-toggle' href='javascript:;'>"; $icon = "<span class='glyphicon glyphicon-menu-right'></span>"; $icon2 = "<b class='arrow glyphicon glyphicon-menu-down'></b>"; $li = array(array('folder' => $atag . "\$icon<span class='menu-text'>\$name</span>" . $icon2 . "</a>", 'file' => "<a class='\$tar' href='\$url'>\$icon<span class='menu-text'>\$name</span></a>"), array('folder' => $atag . $icon . "\$icon \$name<b class='arrow glyphicon glyphicon-menu-down'></b></a>", 'file' => "<a class='tarmain' href='\$url'>" . $icon . " \$icon \$name</a>"), array('folder' => $atag . "\$icon\$name<b class='arrow glyphicon glyphicon-menu-down'></b></a>", 'file' => "<a class='tarmain' href='\$url'>\$icon\$name</a>")); $tree = new \Common\Lib\Tree($newarr); $Lang = D('Lang'); if (!S('langs')) { $langs = $Lang->where('status=1')->order('listorder,id')->select(); S('langs', $langs); } $tlang = $Lang->where('value=\'' . LANG_SET . '\'')->find(); $this->assign('tlang', $tlang); $this->assign('mlang', S('langs')); $this->assign('indexchild', $indexchild); $this->assign('index', $index); $this->assign('list', $tree->get_backnav(0, '', 'nav nav-list', $li)); $this->display(); }
public function edit() { if (!IS_AJAX) { $this->error(L('_ERROR_ACTION_')); } $Type = M('Type'); $lang = I('get.lang') ? I('get.lang') : $this->clang; $list = $Type->field('id,pid,name')->where('status=1 AND lang=\'' . $lang . '\'')->select(); $tree = new \Common\Lib\Tree($list); if (IS_POST) { if ($Type->create()) { $Model = new \Think\Model(); $query = $Model->query("SHOW TABLE STATUS LIKE '__TYPE__'"); $nextid = $query[0]['auto_increment']; $top = I('post.pid') == 0 ? $nextid : $tree->get_top(I('post.pid')); $data = array('pid' => I('post.pid'), 'name' => I('post.name'), 'description' => I('post.description'), 'status' => I('post.status') ? 1 : 0, 'keyid' => $top['id'], 'lang' => I('post.lang')); $result = $Type->where('id=' . I('post.id'))->save($data); if ($result !== FALSE) { $this->success(L('SAVE_OK'), U('Type/index', $this->vl . '&pid=' . $data['pid'])); } else { $this->error(L('SAVE_ERROR')); } } else { $this->error($Type->getError()); } } else { $str = "<li data-val='\$id'>\$spacer\$name</li>"; $vo = $Type->where('id=' . I('get.id'))->find(); $this->assign('pids', $tree->get_tree(0, $str)); $this->assign('vo', $vo); $this->display(); } }
public function edit() { if (!IS_AJAX) { $this->error(L('_ERROR_ACTION_')); } $Cat = D('Category'); if (IS_POST) { print_r(I('post.')); } else { if (I('get.lang')) { $l = I('get.lang'); } elseif ($this->clang) { $l = $this->clang; } else { $l = LANG_SET; } $cats = $Cat->where('status=1 AND lang=\'' . $l . '\'')->order('listorder')->select(); $tree = new \Common\Lib\Tree($cats); $tree->icon = array('<span class="text-muted"> │</span>', '<span class="text-muted"> ├─</span>', '<span class="text-muted"> └─</span>'); $str = "<li data-val='\$id'>\$spacer\$name</li>"; $Module = M('Module'); $modules = $Module->where('status=1 AND type=1')->select(); $vo = $Cat->where('id=' . I('get.id'))->find(); $Urlrule = M('Urlrule'); $rules = $Urlrule->where('ishtml=1')->order('listorder asc')->select(); $this->assign('modules', $modules); $this->assign('cats', $tree->get_tree(0, $str)); $this->assign('urlrules', $rules); $this->assign('vo', $vo); $this->display(); } }
public function del() { if (IS_AJAX && IS_GET) { $Menu = D('Menu'); $alldata = $Menu->order('listorder,id')->select(); $allmenu = new \Common\Lib\Tree($alldata); $cids = $allmenu->get_all_childids(I('get.id')); if ($cids) { $ids = I('get.id') . ',' . implode(',', $cids); } else { $ids = I('get.id'); } $isos = $Menu->where('id IN (' . $ids . ') AND isos=1')->select(); if ($isos) { $this->error(L('ISOS_ERROR')); } $result = $Menu->where('id IN (' . $ids . ')')->delete(); if ($result !== FALSE) { $this->success(L('DEL_OK'), U('Menu/index', $this->vl)); } else { $this->error(L('DEL_ERROR')); } } else { $this->error(L('_ERROR_ACTION_')); } }