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


PHP node_merge函數代碼示例

本文整理匯總了PHP中node_merge函數的典型用法代碼示例。如果您正苦於以下問題:PHP node_merge函數的具體用法?PHP node_merge怎麽用?PHP node_merge使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


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

示例1: node_merge

/**
 * 遞歸重組節點信息為多維數組
 */
function node_merge($node, $access = null, $pid = 0)
{
    // p($node);
    $arr = array();
    foreach ($node as $v) {
        if (is_array($access)) {
            // echo "mark";
            // p($access);
            // p($v);
            $v['access'] = in_array($v['id'], $access) ? 1 : 0;
            // p($v['access']);
        }
        // p($v);
        // die();
        if ($v['pid'] == $pid) {
            // p($v);
            // die();
            $v['child'] = node_merge($node, $access, $v['id']);
            // p($v['child']);
            $arr[] = $v;
            // p($arr[]);
        }
        // p($v);
    }
    return $arr;
}
開發者ID:ppxj,項目名稱:rbac,代碼行數:29,代碼來源:function.php

示例2: access

 public function access()
 {
     $rid = I('rid', 0, 'intval');
     $node = M('node')->order('sort')->select();
     $access = M('access')->where(array('role_id' => $rid))->getField('node_id', true);
     $this->node = node_merge($node, $access);
     $this->rid = $rid;
     $this->display();
 }
開發者ID:pude01,項目名稱:doc,代碼行數:9,代碼來源:RbacAction.class.php

示例3: __construct

 public function __construct()
 {
     parent::__construct();
     $menu = D('Menu');
     $map['status'] = 1;
     $this->menu = node_merge($menu->getAllMenu($map));
     $this->remark = CONTROLLER_NAME . '/' . ACTION_NAME;
     $this->controller = CONTROLLER_NAME;
     //dd($this->menu);
 }
開發者ID:mcxzyang,項目名稱:vip,代碼行數:10,代碼來源:CommController.class.php

示例4: checkAuth

 public function checkAuth()
 {
     $ci =& get_instance();
     $module = strtolower($ci->uri->segment(1));
     if ($module == 'admin') {
         // 判斷已登錄
         $user = $ci->session->userdata('user');
         // 登錄方法做是否已登錄判斷
         $action = strtolower($ci->uri->segment(3));
         $controller = strtolower($ci->uri->segment(2));
         if ($user && $action == 'login') {
             redirect('/admin/main/index');
         } else {
             if (!$user && $action != 'login') {
                 redirect('/admin/login/login');
             }
         }
         $noauth = $ci->config->item('noauth_controller');
         $ci->load->model('M_node', 'node');
         $list = $ci->node->getList(array('ASC' => 'sort', 'id_in' => $user['node']));
         $open = 0;
         $actId = 0;
         $nav = array('首頁', '網站信息');
         foreach ($list as $k => $v) {
             $con = explode('/', $v['name']);
             $num = count($con);
             if (strtolower($con[0]) == $controller && $num > 1) {
                 $open = $v['pid'];
                 $nav = array($list[$v['pid']]['title'], $v['title']);
                 foreach ($list as $val) {
                     if ($val['pid'] == $v['id'] && $action == strtolower($val['name'])) {
                         $actId = $val['id'];
                         break;
                     }
                 }
                 break;
             }
         }
         $list = node_merge($list);
         $ci->assign('leftnav', $list);
         $ci->assign('open', $open);
         if (!in_array(ucwords($controller), $noauth)) {
             if ($open <= 0 || $actId <= 0) {
                 $json = $ci->input->get('json');
                 if (isset($json) && $json == 1) {
                     $ci->outJson(101, '', '對不起,您沒有權限操作此項!');
                 }
                 $ci->error('對不起,您沒有權限操作此項!', 2);
             }
         }
         $ci->assign('nav', $nav);
     }
     // show_error('您無權訪問該功能,該錯誤已經被記錄!點擊<a href="'. site_url('admin/main/index') .'">返回</a>');
 }
開發者ID:jimmysum,項目名稱:potato-cms,代碼行數:54,代碼來源:Auth.php

示例5: node_merge

/**
 * 遞歸重組節點信息
 */
function node_merge($node, $pid = 0)
{
    $arr = array();
    foreach ($node as $v) {
        if ($v['pid'] == $pid) {
            $v['child'] = node_merge($node, $v['id']);
            $arr[] = $v;
        }
    }
    return $arr;
}
開發者ID:qq907274532,項目名稱:cms,代碼行數:14,代碼來源:function.php

示例6: edit

 public function edit()
 {
     $rid = I('role_id', 0, 'intval');
     $field = array('id', 'name', 'title', 'pid');
     $node = M('node')->order('sort')->field($field)->select();
     //原有權限
     $access = M('access')->where(array('role_id' => $rid))->getField('node_id', true);
     $node = node_merge($node, $access);
     //組裝數組
     $this->assign('node', $node);
     $this->assign('rid', $rid);
     $this->display();
 }
開發者ID:xazzz,項目名稱:EasyCMS,代碼行數:13,代碼來源:RbacaccessAction.class.php

示例7: index

 public function index()
 {
     if (IS_POST) {
         M('Admin')->data(I("post."))->save();
         $this->mtReturn(200, '保存成功', '', true);
     }
     $menu = D('Menu');
     $map['status'] = 1;
     $this->menu = node_merge($menu->getAllMenu($map));
     $Rs = M('Admin')->find(session('uid'));
     $this->assign('Rs', $Rs);
     $this->display();
 }
開發者ID:mcxzyang,項目名稱:vipclub,代碼行數:13,代碼來源:IndexController.class.php

示例8: node_merge

function node_merge($node, $access = null, $pid = 0)
{
    $arr = array();
    foreach ($node as $v) {
        if (is_array($access)) {
            $v['access'] = in_array($v['id'], $access) ? 1 : 0;
        }
        if ($v['pid'] == $pid) {
            $v['child'] = node_merge($node, $access, $v['id']);
            $arr[] = $v;
        }
    }
    return $arr;
}
開發者ID:nbhtm2014,項目名稱:big,代碼行數:14,代碼來源:function.php

示例9: add

 public function add()
 {
     $input = $this->input->post();
     if ($input) {
         $this->load->library('form_validation');
         $this->form_validation->set_data($input);
         $this->form_validation->set_rules($this->rules);
         if ($this->form_validation->run() == TRUE) {
             $input['time'] = time();
             if (isset($input['id'])) {
                 $res = $this->node->update($input, 'id');
             } else {
                 $res = $this->node->add($input);
             }
             if ($res) {
                 $this->outJson(0);
             } else {
                 $this->outJson(1);
             }
         } else {
             $this->outJson(101, '', current($this->form_validation->error_array()));
         }
     } else {
         $id = $this->input->get('id');
         $data = array();
         if ($id) {
             $data = $this->node->getOne($id);
             if (!$data) {
                 $this->error('節點不存在');
             }
         }
         // echo '<pre>';print_r($data);die;
         $list = $this->node->getAll();
         $list = node_merge($list);
         $this->assign('list', $list);
         $this->assign('data', $data);
         $this->display();
     }
 }
開發者ID:jimmysum,項目名稱:potato-cms,代碼行數:39,代碼來源:Node.php

示例10: add

 public function add()
 {
     $input = $this->input->post();
     if ($input) {
         $this->load->library('form_validation');
         $this->form_validation->set_data($input);
         $this->form_validation->set_rules($this->rules);
         if ($this->form_validation->run() == TRUE) {
             $input['time'] = time();
             if (isset($input['id'])) {
                 $res = $this->category->update($input, 'id');
             } else {
                 $res = $this->category->add($input);
             }
             if ($res) {
                 $this->outJson(0);
             } else {
                 $this->outJson(1);
             }
         } else {
             $this->outJson(101, '', current($this->form_validation->error_array()));
         }
     } else {
         $id = $this->input->get('id');
         $cate = array();
         if ($id) {
             $cate = $this->category->getOne($id);
             if (!$cate) {
                 $this->error('分類不存在');
             }
         }
         $this->assign('cate', $cate);
         $list = $this->category->getAll();
         $list = node_merge($list);
         $this->assign('list', $list);
         $this->display();
     }
 }
開發者ID:jimmysum,項目名稱:potato-cms,代碼行數:38,代碼來源:Cate.php

示例11: access

 public function access()
 {
     if (IS_POST) {
         $rid = isset($_POST['rid']) ? $_POST['rid'] : 0;
         $arr = array();
         $acc = M('access');
         $acc->where('role_id=' . $rid)->delete();
         foreach ($_POST['access'] as $v) {
             $tmp = explode('_', $v);
             // p($tmp);
             $arr[] = array('role_id' => $rid, 'node_id' => $tmp[0], 'level' => $tmp[1]);
         }
         // p($arr);die;
         $res = $acc->addAll($arr);
         if ($res) {
             $this->success('權限修改成功', U('adminList'));
         } else {
             $this->error('權限修改失敗', U('access'));
         }
         return;
     }
     $rid = isset($_GET['rid']) ? $_GET['rid'] : 0;
     $res = K('Node')->getNode();
     $acc = M('access')->where('role_id=' . $rid)->all();
     if (!$res) {
         $res = 0;
     }
     $role = array();
     foreach ($acc as $v) {
         $role[] = $v['node_id'];
     }
     $res = node_merge($res, $role);
     $this->assign('node', $res);
     $this->assign('rid', $rid);
     $this->display();
 }
開發者ID:sujinw,項目名稱:webPHP,代碼行數:36,代碼來源:AdminUserController.class.php

示例12: add

 public function add()
 {
     $input = $this->input->post();
     if ($input) {
         // print_r($input);die;
         $this->load->library('form_validation');
         $this->form_validation->set_data($input);
         $this->form_validation->set_rules($this->rules);
         if ($this->form_validation->run() == TRUE) {
             $user = $this->session->userdata('user');
             $input['userid'] = $user['info']['id'];
             $input['publish_time'] = strtotime($input['publish_time']);
             if (isset($input['id'])) {
                 $input['update_time'] = time();
                 $res = $this->article->update($input, 'id');
             } else {
                 $input['time'] = time();
                 $res = $this->article->add($input);
             }
             if ($res) {
                 $this->outJson(0);
             } else {
                 $this->outJson(1);
             }
         } else {
             $this->outJson(101, '', current($this->form_validation->error_array()));
         }
     } else {
         $id = $this->input->get('id');
         $article = array();
         if ($id) {
             $article = $this->article->getOne($id);
             if (!$article) {
                 $this->error('文章不存在');
             }
             $this->load->model('M_Admin', 'user');
             $user = $this->user->getUserById($article['userid']);
             $article['username'] = $user['username'];
         }
         $this->assign('article', $article);
         $list = $this->category->getAll();
         $list = node_merge($list);
         $this->assign('list', $list);
         $this->display();
     }
 }
開發者ID:jimmysum,項目名稱:potato-cms,代碼行數:46,代碼來源:Article.php

示例13: cate_list

 /**
  * [cate_list 公共的無限級分類]
  * @param  [type] $model [description]
  * @return [type]        [description]
  */
 public function cate_list($model, $where = array(), $order = array())
 {
     $list = $model->where($where)->order($order)->select();
     return node_merge($list);
 }
開發者ID:qq907274532,項目名稱:cms,代碼行數:10,代碼來源:BaseController.class.php

示例14: access

 public function access()
 {
     $rid = $_GET['rid'];
     //讀取有用字段
     $field = array('id', 'name', 'title', 'pid');
     $node = M('node')->order('sort')->field($field)->select();
     //讀取用戶原有權限
     $access = M('access')->where(array('role_id' => $rid))->getField('node_id', true);
     $node = node_merge($node, $access);
     $this->assign('rid', $rid);
     $this->assign('node', $node);
     $this->display();
 }
開發者ID:zmou,項目名稱:service,代碼行數:13,代碼來源:RBACAction.class.php

示例15: getwhere

 public function getwhere()
 {
     $info = D('Node')->getRbac($_SESSION['id']);
     $list = node_merge($info);
     foreach ($list as $k => $v) {
         foreach ($v['child'] as $key => $va) {
             $list[$k]['child'][$key]['url'] = U($va['name'] . '/index');
         }
     }
     return $list;
     //$result=M('access')->alias('a')->join('')
 }
開發者ID:qq907274532,項目名稱:YmxCMS,代碼行數:12,代碼來源:BaseController.class.php


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