示例#1
0
 /**
  * 列表
  *
  */
 public function indexAction()
 {
     // 分页
     $page = intval($this->getg('page', 1));
     $pageSize = 10;
     // 排序
     $orderby = $this->getg('sort');
     if ($orderby) {
         $orderby = str_replace('.', ' ', $orderby);
     } else {
         $orderby = 'id asc';
     }
     // 实例化Model
     $log = new LogModel();
     // 查询条件
     $params = array('field' => array(), 'where' => array('status>' => 0), 'order' => $orderby, 'page' => $page, 'per' => $pageSize);
     // 列表
     $result = $log->getLists($params);
     // 数据总条数
     $total = $log->getCount($params);
     // 分页url
     $url = Tools_help::url('backend/log/index') . '?page=';
     $pagestr = Tools_help::pager($page, $total, $pageSize, $url);
     // 模版分配数据
     $this->_view->assign('pagestr', $pagestr);
     $this->_view->assign('result', $result);
     $this->_view->assign("pageTitle", '列表');
 }
 protected function doDisplay(array $context, array $blocks = array())
 {
     // line 1
     echo "前台\n<a href=\"";
     // line 2
     echo twig_escape_filter($this->env, Tools_help::url("index/test", array("id" => "1", "name" => "codejm")), "html", null, true);
     echo "\" >测试</a>\n";
 }
示例#3
0
 public function get()
 {
     $menustr = '<ul class="nav nav-list">';
     foreach ($this->menuArr as $menu) {
         if (is_array($menu['controller'])) {
             foreach ($menu['controller'] as $controller) {
                 if (strtolower($controller) == strtolower($this->controllerName)) {
                     $active = ' class="active"';
                     break;
                 } else {
                     $active = '';
                 }
             }
         } else {
             $active = strtolower($menu['controller']) == strtolower($this->controllerName) ? ' class="active"' : '';
         }
         if (isset($menu['sub']) && !empty($menu['sub'])) {
             // 权限判断
             if (!$this->isShowController($menu['controller'])) {
                 continue;
             }
             // 组菜单
             $menustr .= '<li' . $active . '> <a href="#" class="dropdown-toggle"> <i class="menu-icon fa fa-desktop"></i> <span class="menu-text"> ' . $menu['name'] . '</span> <b class="arrow fa fa-angle-down"></b> </a> <b class="arrow"></b><ul class="submenu">';
             foreach ($menu['sub'] as $submenu) {
                 // 权限判断
                 if (!$this->isShowAction($submenu)) {
                     continue;
                 }
                 // 组菜单
                 $active = '';
                 if (stripos($submenu['url'], $this->url) !== false) {
                     $active = ' class="active"';
                 }
                 $menustr .= '<li' . $active . '> <a href="' . Tools_help::url($submenu['url']) . '"> <i class="menu-icon fa fa-caret-right"></i> ' . $submenu['name'] . '</a> <b class="arrow"></b> </li>';
             }
             $menustr .= '</ul> </li>';
         } else {
             // 权限判断
             if (!$this->isShowController($menu['controller'])) {
                 continue;
             }
             // 组数组
             $menustr .= '<li' . $active . '><a href="' . Tools_help::url($menu['url']) . '"><i class="menu-icon fa fa-tachometer"></i><span class="menu-text"> ' . $menu['name'] . '</span></a><b class="arrow"></b></li>';
         }
     }
     $menustr .= '</ul>';
     return $menustr;
 }
示例#4
0
 /**
  * 返回上一页并显示错误
  *
  */
 protected function error($msg, $type = 'ErrorMessage', $url = '')
 {
     // 验证失败
     Tools_help::setSession($type, $msg);
     if ($url) {
         header("Location: " . $url);
     } else {
         if (isset($_SERVER['HTTP_REFERER'])) {
             header("Location: " . $_SERVER['HTTP_REFERER']);
         } else {
             $url = Tools_help::url(strtolower($this->moduleName) . '/' . strtolower($this->controllerName) . '/index');
             header("Location: " . $url);
         }
     }
     $this->_exit();
 }
示例#5
0
 public function editPermissionAction()
 {
     $id = $this->getg('id', 0);
     if (empty($id)) {
         exit;
     }
     $rbac = new Rbac_Core();
     if ($this->getRequest()->isPost()) {
         $rp = $this->getp("rp");
         $rbac->assign($id, $rp, time());
         Tools_help::setSession('Message', '修改成功!');
         $this->redirect(Tools_help::url('/backend/roles/editPermission', array('id' => $id)));
         exit;
     }
     $rp = $rbac->getRolePermissions($id);
     $rpArr = array();
     foreach ($rp as $value) {
         $rpArr[$value['pid']] = $value['pid'];
     }
     unset($rp);
     $permissions = $rbac->getPermissions();
     $permissionArr = array();
     if ($permissions) {
         foreach ($permissions as $item) {
             if ($item['ismenu'] == -1) {
                 $permissionArr[$item['id']] = $item;
             } else {
                 $permissionArr[$item['fid']]['sub'][] = $item;
             }
         }
     }
     $this->_view->assign('result', $permissionArr);
     $this->_view->assign('rpArr', $rpArr);
     $this->_view->assign('id', $id);
     $this->_view->assign("pageTitle", '赋权限');
 }
示例#6
0
 /**
  * 后台登录显示
  *
  */
 public function indexAction()
 {
     if ($this->getRequest()->isPost()) {
         // test
         $member = new MembersModel();
         $pdata = $this->getAllPost();
         $result = $member->validation->validate($pdata, 'only_login');
         $member->parseAttributes($pdata);
         if ($result) {
             $data = $member->select(array('where' => array('username' => $member->username, 'status>' => '1')));
             // 验证是否可以登录
             if ($data && $data['role_type'] == 'admin' && $data['password'] == Tools_help::hash($member->password)) {
                 $member->reMemberMe($data, $member->rememberme);
                 $this->redirect(Tools_help::url('backend/index/index'));
             } else {
                 $this->_view->assign("errors", $this->errorStr('用户名或密码错误请重新填写'));
             }
         } else {
             $this->_view->assign("errors", $member->validation->getErrorSummaryFormatted());
         }
         $this->_view->assign("member", $member);
     }
     $this->_view->assign("pageTitle", '后台登录');
 }