本文整理汇总了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;
}
示例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();
}
示例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);
}
示例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>');
}
示例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;
}
示例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();
}
示例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();
}
示例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;
}
示例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();
}
}
示例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();
}
}
示例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();
}
示例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();
}
}
示例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);
}
示例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();
}
示例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('')
}