當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Data::channelLevel方法代碼示例

本文整理匯總了PHP中Data::channelLevel方法的典型用法代碼示例。如果您正苦於以下問題:PHP Data::channelLevel方法的具體用法?PHP Data::channelLevel怎麽用?PHP Data::channelLevel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Data的用法示例。


在下文中一共展示了Data::channelLevel方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: show

 public function show()
 {
     $cid = Q('cid', 0, 'intval');
     $aid = Q('aid', 0, 'intval');
     $Model = K('Comment');
     $where = "comment_state=1 AND cid={$cid} AND aid={$aid}";
     $count = $Model->join()->where($where)->where("pid=0 ")->count();
     $page = new Page($count, 15);
     $data = array();
     if ($count) {
         //獲得1級回複的id
         $result = $Model->where($where)->where("pid=0 ")->limit($page->limit())->order("comment_id desc")->getField('comment_id', true);
         $comment_id = implode(',', $result);
         $data = $Model->where("comment_state=1 AND (comment_id IN ({$comment_id}) OR reply_comment_id IN ({$comment_id}))")->order("comment_id ASC")->all();
         //設置頭像(沒有頭像的用戶使用默認頭像)
         foreach ($data as $n => $d) {
             if (empty($d['icon'])) {
                 $data[$n]['icon'] = __ROOT__ . "/data/image/user/50-gray.png";
             } else {
                 $data[$n]['icon'] = __ROOT__ . '/' . $d['icon'];
             }
         }
     }
     //獲得多層
     $data = Data::channelLevel($data, 0, '', 'comment_id');
     $this->assign('page', $page->show());
     $this->assign('data', $data);
     $con = $this->fetch('index.php');
     if (Q('page')) {
         echo $con;
     } else {
         echo "document.write('<div id=\"hdcomment\">" . preg_replace('@\\r|\\n@mi', '', addslashes($con)) . "</div>')";
     }
     exit;
 }
開發者ID:jyht,項目名稱:v5,代碼行數:35,代碼來源:CommentControl.class.php

示例2: set

 public function set()
 {
     if (IS_POST) {
         $favoriteModel = M('menu_favorite');
         //刪除舊的收藏
         $map['uid'] = $_SESSION['user']['uid'];
         $favoriteModel->where($map)->del();
         if (!empty($_POST['nid'])) {
             foreach ($_POST['nid'] as $nid) {
                 $data = array('uid' => $_SESSION['user']['uid'], 'nid' => $nid);
                 $favoriteModel->add($data);
             }
         }
         $this->success('設置成功,請刷新後台');
     } else {
         $nodeModel = M('node');
         $pre = C('DB_PREFIX');
         if (IS_SUPER_ADMIN || IS_WEBMASTER) {
             $sql = "SELECT n.nid,n.pid,m.uid,n.title FROM {$pre}node AS n  LEFT JOIN\n\t\t\t\t\t\t\t (SELECT * FROM {$pre}menu_favorite WHERE uid={$_SESSION['user']['uid']}) AS m\n\t\t\t\t\t\t\t ON n.nid = m.nid WHERE n.is_show=1";
         } else {
             $sql = "SELECT n.nid,n.pid,m.uid,n.title FROM {$pre}node AS n  LEFT JOIN  {$pre}access AS a ON n.nid=a.nid LEFT JOIN\n\t\t\t\t\t\t\t (SELECT * FROM {$pre}menu_favorite WHERE uid={$_SESSION['user']['uid']}) AS m ON n.nid = m.nid\n\t\t\t\t\t\t\t WHERE n.type=2 OR (n.show=1 AND m.nid is not null)";
         }
         $nodeData = $nodeModel->query($sql);
         $nodeData = Data::channelLevel($nodeData, 0, "", "nid");
         $this->assign('data', $nodeData);
         $this->display();
     }
 }
開發者ID:suhanyujie,項目名稱:spider,代碼行數:28,代碼來源:FavoriteMenuController.class.php

示例3: edit

 public function edit()
 {
     if (IS_POST) {
         $rid = Q("post.rid");
         $this->_db->where(array("rid" => $rid))->del();
         if (!empty($_POST['nid'])) {
             foreach ($_POST['nid'] as $v) {
                 $this->_db->add(array("rid" => $rid, "nid" => $v));
             }
         }
         $this->_ajax(1, '修改成功');
     } else {
         $rid = Q("rid");
         $sql = "SELECT n.nid,n.title,n.pid,n.type,a.rid as access_rid FROM hd_node AS n LEFT JOIN (SELECT * FROM (SELECT * FROM hd_access WHERE rid={$rid}) AS aa)AS a\n                ON n.nid = a.nid ORDER BY list_order ASC";
         $result = $this->_db->query($sql);
         foreach ($result as $n => $r) {
             $checked = $r['access_rid'] || $r['type'] == 2 ? " checked=''" : '';
             $disabled = $r['type'] == 2 ? 'disabled=""' : '';
             $result[$n]['checkbox'] = "<label><input type='checkbox' name='nid[]' value='{$r['nid']}' {$checked} {$disabled}/> {$r['title']}</label>";
         }
         $this->access = Data::channelLevel($result, 0, '-', 'nid');
         $this->rid = $rid;
         $this->display();
     }
 }
開發者ID:jyht,項目名稱:v5,代碼行數:25,代碼來源:AccessControl.class.php

示例4: set

 /**
  * 權限設置 
  */
 public function set()
 {
     if (IS_POST) {
         //先刪除原來
         M('access')->where("rid={$_POST['rid']}")->del();
         if (!empty($_POST['access'])) {
             $data = array();
             foreach ($_POST['access'] as $c => $a) {
                 $data['rid'] = $_POST['rid'];
                 $data['nid'] = $a;
                 M('access')->add($data);
             }
         }
         $this->success('權限設置成功');
     } else {
         /****第一種方案***
         			//找到有權限設置的節點
         			$node=M('node')->all();
         			$node=Data::channelLevel($node,0,'&nbsp','nid');
         			//找到該角色的已有的權限
         			$map['rid']=array('EQ',$_SESSION['rid']);
         			$controller=M('access')->where($map)->getField('controller',true);
         			$action=M('access')->where($map)->getField('action',true);
         			$this->assign('controller',$controller);
         			$this->assign('action',$action);
         			$this->assign('node',$node);
         			$this->display();*/
         // ***方案二***
         $data = M()->join("__access__ a join __node__ n on a.nid=n.nid")->all();
         $node = Data::channelLevel($data, 0, '&nbsp', 'nid');
         $this->assign('node', $node);
         $this->assign('rid', $_SESSION['rid']);
         $this->display();
     }
 }
開發者ID:www2511550,項目名稱:ECSHOP,代碼行數:38,代碼來源:AccessController.class.php

示例5: edit

 public function edit()
 {
     if (IS_POST) {
         $this->db->where(array("rid" => $this->rid))->del();
         if (!empty($_POST['nid'])) {
             foreach ($_POST['nid'] as $v) {
                 $this->db->add(array("rid" => $this->rid, "nid" => $v));
             }
         }
         $this->success('修改成功');
     } else {
         $sql = "SELECT n.nid,n.title,n.pid,n.type,a.rid as access_rid FROM hd_node AS n LEFT JOIN\n            \t\t\t(SELECT * FROM (SELECT * FROM hd_access WHERE rid={$this->rid}) AS t)AS a\n                \t\tON n.nid = a.nid ORDER BY list_order ASC";
         $result = $this->db->query($sql);
         foreach ($result as $n => $r) {
             //當前角色已經有權限或不需要驗證的節點
             $checked = $r['access_rid'] || $r['type'] == 2 ? " checked=''" : '';
             //不需要驗證的節點,關閉選擇(因為所有管理員都有權限)
             $disabled = $r['type'] == 2 ? 'disabled=""' : '';
             //前台表單
             $result[$n]['checkbox'] = "<label><input type='checkbox' name='nid[]' value='{$r['nid']}' {$checked} {$disabled}/> {$r['title']}</label>";
         }
         $this->assign('access', Data::channelLevel($result, 0, '-', 'nid'));
         $this->assign('rid', $this->rid);
         $this->display();
     }
 }
開發者ID:lililishuang,項目名稱:hdcms,代碼行數:26,代碼來源:AccessController.class.php

示例6: __init

 /**
  * 構造函數
  * @return [type] [description]
  */
 public function __init()
 {
     $this->db = K('Goods');
     $this->category = S('category');
     $this->user = K('User');
     /**
      * 獲得所有欄目
      */
     $category = Data::channelLevel($this->category, 0, '-');
     $this->assign('category', $category);
 }
開發者ID:www2511550,項目名稱:ECSHOP,代碼行數:15,代碼來源:IndexController.class.php

示例7: __init

 public function __init()
 {
     /**
      * 獲得所有欄目
      */
     $category = Data::channelLevel(S('category'), 0, '-');
     $this->assign('category', $category);
     /**
      * 登陸後操作
      */
     if (!isset($_SESSION['username'])) {
         $this->error('請登陸後再操作');
     }
 }
開發者ID:www2511550,項目名稱:ECSHOP,代碼行數:14,代碼來源:MemberController.class.php

示例8: index

 /**
  * 後台首頁
  */
 public function index()
 {
     /**
      * 站長或超級管理員返回所有菜單
      */
     if (IS_SUPER_ADMIN || IS_WEBMASTER) {
         $node = M('node')->where("is_show=1")->order('list_order ASC')->all();
     } else {
         /**
          * 管理員權限節點
          */
         $node = M()->join(" __access__ a RIGHT __node__ n JOIN ON n.nid=a.nid")->where("n.is_show=1 AND (n.type=2 OR a.rid={$_SESSION['user']['rid']})")->order('list_order ASC')->all();
     }
     $node = Data::channelLevel($this->addNodeUrl($node), 0, '&nbsp;', 'nid');
     //分配菜單節點
     $this->assign('node', $node);
     //-----------------------------------------------------------------------------------
     /**
      * 快捷菜單節點
      */
     $quickMenu = M()->join("__menu_favorite__ m JOIN __node__ n ON m.nid=n.nid")->where("uid={$_SESSION['user']['uid']}")->all();
     $this->assign('quickMenu', $this->addNodeUrl($quickMenu));
     $this->display();
 }
開發者ID:suhanyujie,項目名稱:spider,代碼行數:27,代碼來源:IndexController.class.php

示例9: get_comment

 /**
  * 獲得評論列表
  */
 public function get_comment()
 {
     $where = "comment_state=1 AND cid=" . $this->_cid . " AND aid=" . $this->_aid;
     $count = $this->join()->where($where)->where("pid=0 ")->count();
     $page = new Page($count, 15);
     $data = array();
     if ($count) {
         //獲得1級回複的id
         $result = $this->where($where)->where("pid=0 ")->limit($page->limit())->order("comment_id desc")->getField('comment_id', true);
         $comment_id = implode(',', $result);
         $data = $this->where("comment_state=1 AND (comment_id IN ({$comment_id}) OR reply_comment_id IN ({$comment_id}))")->order("comment_id ASC")->all();
         //設置頭像(沒有頭像的用戶使用默認頭像)
         foreach ($data as $n => $d) {
             if (empty($d['icon'])) {
                 $data[$n]['icon'] = __ROOT__ . "/data/image/user/50-gray.png";
             } else {
                 $data[$n]['icon'] = __ROOT__ . '/' . $d['icon'];
             }
         }
     }
     //獲得多層
     $data = Data::channelLevel($data, 0, '', 'comment_id');
     return array('page' => $page->show(), 'data' => $data);
 }
開發者ID:jyht,項目名稱:v5,代碼行數:27,代碼來源:CommentModel.class.php

示例10: menus

 /**
  * 獲取當前用戶在站點後台可以使用的係統菜單
  * @return mixed
  */
 public function menus()
 {
     /**
      * 係統管理
      * 1 移除係統菜單
      * 2 將沒有三級或二級菜單的菜單移除
      */
     //移除用戶沒有使用權限的係統菜單
     $permission = Db::table('user_permission')->where('siteid', SITEID)->where('uid', v('user.info.uid'))->where('type', 'system')->pluck('permission');
     $menus = Db::table('menu')->get();
     if ($permission) {
         $permission = explode('|', $permission);
         $tmp = $menus;
         foreach ($tmp as $k => $m) {
             if ($m['permission'] != '' && !in_array($m['permission'], $permission)) {
                 unset($menus[$k]);
             }
         }
     }
     $menus = Data::channelLevel($menus, 0, '', 'id', 'pid');
     //移除沒有三級菜單的一級與二級菜單
     $tmp = $menus;
     foreach ($tmp as $k => $t) {
         //二級菜單為空時刪除些菜單
         foreach ($t['_data'] as $n => $d) {
             if (empty($d['_data'])) {
                 unset($menus[$k]['_data'][$n]);
             }
         }
         //一級菜單沒有子菜單時移除
         if (empty($menus[$k]['_data'])) {
             unset($menus[$k]);
         }
     }
     return $menus;
 }
開發者ID:houdunwang,項目名稱:hdcms,代碼行數:40,代碼來源:Menu.php

示例11: edit

 public function edit()
 {
     if (IS_POST) {
         if ($this->db->editAccess()) {
             $this->success('修改成功');
         } else {
             $this->error('修改失敗');
         }
     } else {
         $sql = "SELECT n.nid,n.title,n.pid,n.type,a.rid as access_rid FROM " . C('DB_PREFIX') . "node AS n LEFT JOIN\n            \t\t\t(SELECT * FROM " . C('DB_PREFIX') . "access WHERE rid={$this->rid}) AS a\n                \t\tON n.nid = a.nid ORDER BY list_order ASC";
         $result = $this->db->query($sql);
         foreach ($result as $n => $r) {
             //當前角色已經有權限或不需要驗證的節點
             $checked = $r['access_rid'] || $r['type'] == 2 ? " checked=''" : '';
             //不需要驗證的節點,關閉選擇(因為所有管理員都有權限)
             $disabled = $r['type'] == 2 ? 'disabled=""' : '';
             //表單
             $result[$n]['checkbox'] = "<label>\n                        <input type='checkbox' name='nid[]' value='{$r['nid']}' {$checked} {$disabled}/> {$r['title']}\n                        </label>";
         }
         $this->assign('access', Data::channelLevel($result, 0, '-', 'nid'));
         $this->assign('rid', $this->rid);
         $this->display();
     }
 }
開發者ID:suhanyujie,項目名稱:spider,代碼行數:24,代碼來源:AccessController.class.php

示例12: setFavorite

 public function setFavorite()
 {
     if (IS_POST) {
         $post = $_POST;
         //刪除舊的收藏
         $favoriteModel = M('menu_favorite');
         $favoriteModel->del(array('uid' => $_SESSION['uid']));
         if (!empty($_POST['nid'])) {
             foreach ($post['nid'] as $nid) {
                 $favoriteModel->add(array('uid' => $_SESSION['uid'], 'nid' => $nid));
             }
         }
         $pre = C("DB_PREFIX");
         //更新緩存
         $sql = "SELECT * FROM {$pre}menu_favorite AS m JOIN {$pre}node AS n ON m.nid=n.nid WHERE uid=" . $_SESSION['uid'];
         $favoriteMenu = M()->query($sql);
         cache($_SESSION['uid'], $favoriteMenu, MENU_CACHE_PATH);
         $this->success('設置成功');
     } else {
         if (!is_writable(MENU_CACHE_PATH)) {
             $this->error(MENU_CACHE_PATH . '緩存目錄不可寫');
         }
         $nodeModel = V('node');
         $pre = C('DB_PREFIX');
         if (session("WEB_MASTER") || session("rid") == 1) {
             $sql = "SELECT n.nid,n.pid,m.uid,n.title FROM {$pre}node AS n  LEFT JOIN \n\t\t\t\t\t\t\t (SELECT * FROM {$pre}menu_favorite WHERE uid={$_SESSION['uid']}) AS m ON n.nid = m.nid WHERE n.state=1";
         } else {
             $sql = "SELECT n.nid,n.pid,m.uid,n.title FROM {$pre}node AS n  LEFT JOIN  {$pre}access AS a ON n.nid=a.nid LEFT JOIN\n\t\t\t\t\t\t\t (SELECT * FROM {$pre}menu_favorite WHERE uid={$_SESSION['uid']}) AS m ON n.nid = m.nid \n\t\t\t\t\t\t\t WHERE n.type=2 OR (n.state=1 AND m.nid is not null)";
         }
         $nodeData = $nodeModel->query($sql);
         $nodeData = Data::channelLevel($nodeData, 0, "", "nid");
         $this->assign('data', $nodeData);
         $this->display();
     }
 }
開發者ID:jyht,項目名稱:v5,代碼行數:35,代碼來源:IndexControl.class.php

示例13: getchannletree

 public function getchannletree()
 {
     $data = $this->get();
     // return Data::channelList($data, 0, $html = "&nbsp;", 'id');
     return Data::channelLevel($data, 0, $html = "&nbsp;", 'id');
 }
開發者ID:arnold1119,項目名稱:cms,代碼行數:6,代碼來源:Node.php

示例14: setFavorite

 public function setFavorite()
 {
     if (IS_POST) {
         $post = $_POST;
         //刪除舊的收藏
         $favoriteModel = M('menu_favorite');
         $favoriteModel->del(array('uid' => $_SESSION['user']['uid']));
         if (!empty($_POST['nid'])) {
             foreach ($post['nid'] as $nid) {
                 $favoriteModel->add(array('uid' => $_SESSION['user']['uid'], 'nid' => $nid));
             }
         }
         $pre = C("DB_PREFIX");
         //更新緩存
         $sql = "SELECT * FROM {$pre}menu_favorite AS m JOIN {$pre}node AS n ON m.nid=n.nid WHERE uid=" . $_SESSION['user']['uid'];
         $favoriteMenu = M()->query($sql);
         S('user_menu' . $_SESSION['user']['uid'], $favoriteMenu);
         $this->success('設置成功');
     } else {
         $nodeModel = M('node');
         $pre = C('DB_PREFIX');
         if ($_SESSION['user']['web_master'] || $_SESSION['user']['rid'] == 1) {
             $sql = "SELECT n.nid,n.pid,m.uid,n.title FROM {$pre}node AS n  LEFT JOIN\n\t\t\t\t\t\t\t (SELECT * FROM {$pre}menu_favorite WHERE uid={$_SESSION['user']['uid']}) AS m ON n.nid = m.nid WHERE n.show=1";
         } else {
             $sql = "SELECT n.nid,n.pid,m.uid,n.title FROM {$pre}node AS n  LEFT JOIN  {$pre}access AS a ON n.nid=a.nid LEFT JOIN\n\t\t\t\t\t\t\t (SELECT * FROM {$pre}menu_favorite WHERE uid={$_SESSION['user']['uid']}) AS m ON n.nid = m.nid\n\t\t\t\t\t\t\t WHERE n.type=2 OR (n.show=1 AND m.nid is not null)";
         }
         $nodeData = $nodeModel->query($sql);
         $nodeData = Data::channelLevel($nodeData, 0, "", "nid");
         $this->assign('data', $nodeData);
         $this->display();
     }
 }
開發者ID:lililishuang,項目名稱:hdcms,代碼行數:32,代碼來源:IndexController.class.php


注:本文中的Data::channelLevel方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。