当前位置: 首页>>代码示例>>PHP>>正文


PHP Tree::array2tree方法代码示例

本文整理汇总了PHP中Tree::array2tree方法的典型用法代码示例。如果您正苦于以下问题:PHP Tree::array2tree方法的具体用法?PHP Tree::array2tree怎么用?PHP Tree::array2tree使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tree的用法示例。


在下文中一共展示了Tree::array2tree方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createAction

 /**
  * 生成缓存
  *
  * @return object 本类实例
  */
 public function createAction()
 {
     $data = $this->_model->order('parent_id ASC,is_show DESC,sort_order ASC, area_id ASC')->index($this->_pk_field)->select();
     if ($data === false) {
         $this->_ajaxReturn(false, L('CREATE_AREA_CACHE,FAILURE'), 'EXIT');
     }
     $area_data = array();
     foreach ($data as $area_id => &$item) {
         if ($item['level'] < 3) {
             $item['leaf'] = $this->_model->checkIsLeaf($area_id, '`level` IN(2,3)');
             $item['expanded'] = $item['level'] == 1;
             $area_data[$area_id] = $item;
         }
     }
     $area_data = Tree::array2tree($area_data, $this->_pk_field);
     //树形式
     return $this->cache(null, null, $data)->cache(null, $this->_getControllerName() . '_tree', $area_data);
 }
开发者ID:yunsite,项目名称:yablog,代码行数:23,代码来源:AreaController.class.php

示例2: dirname

<?php

require dirname(__DIR__) . '/common.php';
require INCLUDE_PATH . 'Tree.class.php';
$data = $db->select(array('table' => TB_MENU, 'field' => array('*,`menu_id` AS id,`menu_name` AS text')));
echo json_encode(Tree::array2tree($data));
开发者ID:yunsite,项目名称:yablog,代码行数:6,代码来源:get_tree.php

示例3: createAction

 /**
  * 生成缓存
  *
  * @author          mrmsl <msl-138@163.com>
  * @date            2013-03-21 13:38:34
  *
  * @return object $this
  */
 public function createAction()
 {
     $data = $this->_model->order('parent_id ASC,is_show DESC,sort_order ASC, cate_id ASC')->index($this->_pk_field)->select();
     if ($data === false) {
         $this->_ajaxReturn(false, L('CREATE_CATEGORY_CACHE,FAILURE'), 'EXIT');
     }
     new_mkdir($ssi_path = SSI_PATH . 'category/');
     $suffix = C('HTML_SUFFIX');
     $nav = '<a href="' . BASE_SITE_URL . 'category' . $suffix . '">' . L('CN_WANGWEN') . '</a>' . BREAD_SEPARATOR;
     file_put_contents($ssi_path . 'nav0' . $suffix, $nav);
     foreach ($data as $v) {
         //生成分类ssi导航
         $html = $nav;
         foreach (explode(',', $v['node']) as $item) {
             $info = $data[$item];
             $html .= '<a href="' . $info['link_url'] . '">' . $info['cate_name'] . '</a>' . BREAD_SEPARATOR;
         }
         file_put_contents($ssi_path . 'nav' . $v[$this->_pk_field] . $suffix, $html);
     }
     $tree_data = Tree::array2tree($data, $this->_pk_field);
     //树形式
     return $this->cache(null, null, $data)->cache(null, $this->_getControllerName() . '_tree', $tree_data);
 }
开发者ID:yunsite,项目名称:yablog,代码行数:31,代码来源:CategoryController.class.php

示例4: createAction

 /**
  * 生成缓存
  *
  * @author          mrmsl <msl-138@163.com>
  * @lastmodify      2013-01-22 10:46:49 by mrmsl
  *
  * @return object this
  */
 public function createAction()
 {
     $data = $this->_model->alias('a')->join('LEFT JOIN ' . TB_ADMIN_ROLE_PRIV . ' AS b ON a.menu_id=b.menu_id')->join('LEFT JOIN ' . TB_ADMIN_ROLE . ' AS c ON b.role_id=c.role_id')->field(array('a.*', "CONCAT('#controller=', a.controller, '&action=', a.action)" => 'href', 'GROUP_CONCAT(c.role_id)' => 'priv', 'GROUP_CONCAT(c.role_name)' => 'priv_letter'))->group('a.menu_id')->order('a.parent_id ASC,a.is_show DESC,a.sort_order ASC, a.menu_id ASC')->key_column($this->_pk_field)->select();
     if ($data === false) {
         $this->_model->addLog();
         $this->_ajaxReturn(false, L('CREATE_MENU_CACHE,FAILURE'), 'EXIT');
     }
     array_walk($data, array($this, '_explodePriv'));
     $tree_data = Tree::array2tree($data, $this->_pk_field);
     //树形式
     return $this->_setCache($data)->_setCache($tree_data, $this->_getControllerName() . '_tree');
 }
开发者ID:yunsite,项目名称:yablog,代码行数:20,代码来源:Menu.class.php

示例5: _getReplyComments

 /**
  * 获取评论回复
  *
  * @author          mrmsl <msl-138@163.com>
  * @date            2013-04-28 12:47:13
  *
  * @param int   $comment_id 评论id
  *
  * @return string $this->getRecurrsiveComments()返回html
  */
 private function _getReplyComments($comment_id)
 {
     $data = $this->_model->table(TB_COMMENTS)->where('status=' . COMMENT_STATUS_PASS . " AND node LIKE '{$comment_id},%'")->order('comment_id')->select();
     return $data ? $this->_getRecurrsiveComments(Tree::array2tree($data, 'comment_id'), true) : '';
 }
开发者ID:yunsite,项目名称:yablog,代码行数:15,代码来源:Common.class.php

示例6: array

<?php

require __DIR__ . '/common.php';
require INCLUDE_PATH . 'Tree.class.php';
$data = $db->select(array('table' => TB_MENU, 'field' => array('*')));
$return = array();
foreach ($data as $v) {
    $v['id'] = $v['menu_id'];
    $v['text'] = $v['menu_name'];
    $return[] = $v;
}
echo json_encode(Tree::array2tree($return));
开发者ID:yunsite,项目名称:yablog,代码行数:12,代码来源:get_tree.php

示例7: viewAction

 /**
  * 查看某一条留言评论
  *
  * @author          mrmsl <msl-138@163.com>
  * @date            2013-06-01 11:00:03
  *
  * @return void 无返回值
  */
 public function viewAction()
 {
     $comment_id = Filter::int($this->_pk_field, 'get');
     $add_time = Filter::int('add_time', 'get');
     $field = '*,INET_NTOA(user_ip) AS user_ip';
     if (!$comment_id && !$add_time) {
         //非法参数
         $log = L('CN_CHAKAN,CONTROLLER_NAME,%.,INVALID_PARAM') . "{$this->_pk_field}({$comment_id}),add_time({$add_time})";
         $msg = L('INVALID_PARAM');
     } elseif (!($comment_info = $this->_model->field($field)->where(array($this->_pk_field => $comment_id, 'add_time' => $add_time))->select())) {
         //不存在
         $log = L('CN_CHAKAN,CONTROLLER_NAME') . ".{$this->_pk_field}({$comment_id}),add_time({$add_time})" . L('NOT_EXIST');
         $msg = L('CONTROLLER_NAME,NOT_EXIST');
     }
     if (!empty($msg)) {
         //错误
         $log = get_method_line(__METHOD__, __LINE__, LOG_INVALID_PARAM) . $log;
         trigger_error($log, E_USER_ERROR);
         $this->_ajaxReturn(false, $msg);
     }
     $store = array($this->_pk_field => $comment_id, 'add_time' => $add_time, 'content' => '');
     $info = $comment_info[0];
     if (COMMENT_REPLY_TYPE_REPLIED == $info['admin_reply_type']) {
         //
         $reply_content = $this->_model->where('admin_reply_type=' . COMMENT_REPLY_TYPE_ADMIN . ' AND real_parent_id=' . $info[$this->_pk_field])->getField('content');
         $store['content'] = $reply_content;
     }
     if ($parent_id = $info['parent_id']) {
         $node_arr = explode(',', $info['node']);
         $comment_info = $this->_model->field($field)->where("type={$info['type']} AND (node LIKE '{$node_arr[0]},%' OR {$this->_pk_field} = {$node_arr[0]}) AND comment_id<={$comment_id}")->select();
     }
     $this->_ajaxReturn(true, $store, Tree::array2tree($comment_info, $this->_pk_field));
 }
开发者ID:yunsite,项目名称:yablog,代码行数:41,代码来源:CommentsController.class.php

示例8: createAction

 /**
  * 生成缓存
  *
  * @author          mrmsl <msl-138@163.com>
  * @date            2013-06-19 17:47:25
  *
  * @return object this
  */
 public function createAction()
 {
     $data = $this->_model->order('parent_id ASC, sort_order ASC, module_id ASC')->index($this->_pk_field)->select();
     if ($data === false) {
         $this->_ajaxReturn(false, L('CREATE_LANGUAGEMODULES_CACHE,FAILURE'));
     }
     $tree_data = Tree::array2tree($data, $this->_pk_field);
     //树形式
     return $this->cache(null, null, $data)->cache(null, CONTROLLER_NAME . '_tree', $tree_data);
 }
开发者ID:yunsite,项目名称:yablog,代码行数:18,代码来源:LanguageModulesController.class.php

示例9: _getTreeData

 /**
  * 获取菜单树数据
  *
  * @author          mrmsl <msl-138@163.com>
  * @date            2012-08-15 11:38:13
  * @lastmodify      2013-01-21 16:28:38 by mrmsl
  *
  * @param int  $pk_value      主键值,比如加载某个节点。默认null,$_GET['node']获取
  * @param bool $checked       null树不带复选框。默认null
  * @param bool $include_total true包含总数total键。默认false
  *
  * @return array 菜单树数据
  */
 protected function _getTreeData($pk_value = null, $checked = null, $include_total = false)
 {
     $pk_value = $pk_value === null ? Filter::int('node', 'get') : $pk_value;
     $data = array();
     $data_arr = $this->cache();
     $total = 0;
     foreach ($data_arr as $item) {
         if ($item['parent_id'] == $pk_value) {
             $total++;
             $item['checked'] = $checked;
             $item['leaf'] = $this->_checkIsLeaf($item[$this->_pk_field], $data_arr);
             $data[$item[$this->_pk_field]] = $item;
         }
     }
     $data = Tree::array2tree($data, $this->_pk_field);
     return $include_total ? array('data' => $data, 'total' => $total) : $data;
 }
开发者ID:yunsite,项目名称:yablog,代码行数:30,代码来源:CommonController.class.php


注:本文中的Tree::array2tree方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。