本文整理汇总了PHP中tree::get_tree方法的典型用法代码示例。如果您正苦于以下问题:PHP tree::get_tree方法的具体用法?PHP tree::get_tree怎么用?PHP tree::get_tree使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tree
的用法示例。
在下文中一共展示了tree::get_tree方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index()
{
require APPPATH . 'libraries/tree.class.php';
$category_edit_option = $category_del_option = false;
if (check_backend_module_perm('edit', 'category', $this->data['user_info'])) {
$category_edit_option = true;
}
if (check_backend_module_perm('del', 'category', $this->data['user_info'])) {
$category_del_option = true;
}
$edit_str = $del_str = '';
$categorys = $this->categorys;
foreach ($categorys as $key => $row) {
if ($category_edit_option) {
$edit_str = '<a href="#" data="' . $row['catid'] . '" class="green cate_edit" title="编辑"><i class="icon-pencil bigger-130"></i></a>';
}
if ($category_del_option) {
$del_str = '<a href="#" data="' . $row['catid'] . '" data-title="' . $row['catname'] . '" class="red delete_confirm" title="删除"><i class="icon-trash bigger-130"></i></a>';
}
$categorys[$key]['str_manage'] = "{$edit_str} {$del_str}";
$categorys[$key]['str_menu'] = $row['ismenu'] ? '<span class="label label-sm label-success">YES</span>' : '<span class="label label-sm label-danger">NO</span>';
}
$tree = new tree();
$tree->icon = array(' │ ', ' ├─ ', ' └─ ');
$tree->nbsp = ' ';
$str = "<tr>\n \t\t\t\t<td><label><input type='checkbox' class='ace' name='id[]' value='\$id' /><span class='lbl'></span></label></td>\n \t\t\t\t<td>\$id</td>\n \t\t\t\t<td class='left'>\$spacer\$catname</td>\n \t\t\t\t<td>\$str_menu</td>\n \t\t\t\t<td>\$str_manage</td>\n \t\t\t</tr>";
$tree->init($categorys);
$categorys = $tree->get_tree(0, $str);
$this->data['categorys'] = $categorys;
$this->repair(false);
$this->load->view('category/list', $this->data);
}
示例2: getActionTree
public function getActionTree()
{
$sql = "SELECT id,parent_id,action_name from {$this->_table}";
$cates = $res = $this->getList($sql);
$this->load->helper('html_tree');
$tree = new tree($cates);
$tree->icon = array(' │ ', ' ├─ ', ' └─ ');
//树形图标
$tree->nbsp = ' ';
//三个空格
$options = '';
$tree->init($cates);
return $tree->get_tree(0, "<option value='\$id'>\$spacer\$action_name</option>\n");
}
示例3: get_tree
/**
* 根据 site_id 获取该 站点 下所有的虚拟分类的树
* @param $site_id int
* @param $str string 生成树型结构的基本代码,例如:例如:'<option value={$id} {$selected}>{$spacer}{$title}</option>'
* @param $sid int 被选中的ID,比如在做树型下拉框的时候需要用到
* @param $icon 前缀
* @return string
*/
public function get_tree($str, $sid = 0, $icon = '--')
{
$result = array();
$query_struct = array('where' => array(), 'like' => array(), 'orderby' => array(), 'limit' => array());
$result = $this->query_assoc($query_struct);
$tree = tree::get_tree($result, $str, 0, $sid, $icon);
return $tree;
}
示例4: categoryedit
public function categoryedit()
{
$this->_checkSecurity('category');
$id = intval($_GET["id"]);
if (!$id) {
$this->error(L('_SELECT_NOT_EXIST_'));
}
$Category = D("Category");
$list = $Category->find($id);
if (!$list) {
$this->error(L('_SELECT_NOT_EXIST_'));
}
$parentId = $list['parentid'];
//父ID
$map['module'] = 1;
$map['parent_id'] = 0;
$Category = D('Category')->order("displayorder desc")->where($map)->findall();
foreach ($Category as $catid => $category) {
$Categorys[$category['id']] = array('id' => $category['id'], 'parent_id' => $category['parent_id'], 'title' => $category['title']);
}
import('ORG.Util.Tree');
$tree = new tree($Categorys);
$str = "<option value=\$id \$selected>\$spacer\$title</option>";
$html .= $tree->get_tree(0, $str, $parentId);
//用户组
$Group = D('Usergroup')->where('ID NOT IN (1,2)')->order("id asc")->findall();
if (!$Group) {
$this->error('用户组丢失,请检查');
}
//用户组丢失,请检查
$this->assign('group', $Group);
$this->assign('html', $html);
$this->assign('list', $list);
$this->assign('cate', $Category);
$this->display();
}
示例5: edit
public function edit()
{
role::check('product_filter_edit');
$return_struct = array('status' => 0, 'code' => 501, 'msg' => 'Not Implemented', 'content' => array());
try {
//* 初始化返回数据 */
$return_data = array('action' => "post", 'data' => array(), 'category_list' => NULL);
//* 收集请求数据 ==根据业务逻辑定制== */
$request_data = $this->input->get();
//数据验证
if (!isset($request_data['id']) || !is_numeric($request_data['id'])) {
throw new MyRuntimeException(Kohana::lang('o_global.bad_request'), 404);
}
$alias_filter_service = Alias_filterService::get_instance();
$filter = $alias_filter_service->get($request_data['id']);
//虚拟分类树
$str = '<option value={$id} {$selected}>{$spacer}{$title}</option>';
$return_data['filter_list'] = $alias_filter_service->get_tree($str, $filter['pid']);
//返回数据
$category_service = CategoryService::get_instance();
$categories = $category_service->get_categories();
$str = '<option value={$id} {$selected}>{$spacer}{$title_manage}</option>';
$return_data['category_list'] = tree::get_tree($categories, $str, 0, $filter['category_id']);
if (!empty($filter['category_id'])) {
$category = $category_service->get($filter['category_id']);
if (!empty($category['classify_id'])) {
$classify_service = ClassifyService::get_instance();
$classify = $classify_service->get($category['classify_id']);
$filter['classify_name'] = $classify['name'];
//获取类型关联品牌数组
$filter['brand_list'] = $classify_service->get_brands_by_classify_id($category['classify_id']);
//获取类型关联规格及规格项数组
$filter['attribute_list'] = $classify_service->get_attribute_options_by_classify_id($category['classify_id'], AttributeService::ATTRIBUTE_SPEC);
//获取类型关联特性及特性值数组
$filter['feature_list'] = $classify_service->get_attribute_options_by_classify_id($category['classify_id'], AttributeService::ATTRIBUTE_FEATURE);
}
} else {
//当前站点品牌
$filter['brand_list'] = BrandService::get_instance()->get_brands();
//当前站点规格
$filter['attribute_list'] = AttributeService::get_instance()->get_attribute_spec_options();
//当前站点品牌
$filter['feature_list'] = AttributeService::get_instance()->get_attribute_feature_options();
}
//获取过滤条件
$filter['filter_struct'] = json_decode($filter['filter_struct'], TRUE);
$filter['filter_struct']['pricefrom'] = !empty($filter['filter_struct']['pricefrom']) ? $filter['filter_struct']['pricefrom'] : '';
$filter['filter_struct']['priceto'] = !empty($filter['filter_struct']['priceto']) ? $filter['filter_struct']['priceto'] : '';
$return_data['data'] = $filter;
//* 补充&修改返回结构体 */
$return_struct['status'] = 1;
$return_struct['code'] = 200;
$return_struct['msg'] = '';
$return_struct['content'] = $return_data;
//* 请求类型 */
if ($this->is_ajax_request()) {
// ajax 请求
// json 输出
$this->template->content = $return_struct;
} else {
// html 输出
//* 模板输出 */
$content = new View('product/' . $this->class_name . '/' . __FUNCTION__);
//* 变量绑定 */
$this->template->title = Kohana::config('site.name');
$this->template->content = $content;
//* 请求结构数据绑定 */
$this->template->content->request_data = $request_data;
//* 返回结构体绑定 */
$this->template->content->return_struct = $return_struct;
}
// end of request type determine
} catch (MyRuntimeException $ex) {
$return_struct['status'] = 0;
$return_struct['code'] = $ex->getCode();
$return_struct['msg'] = $ex->getMessage();
//TODO 异常处理
//throw $ex;
if ($this->is_ajax_request()) {
$this->template->content = $return_struct;
} else {
$this->template->return_struct = $return_struct;
$content = new View('info');
$this->template->content = $content;
//* 请求结构数据绑定 */
$this->template->content->request_data = $request_data;
//* 返回结构体绑定 */
$this->template->content->return_struct = $return_struct;
}
}
}
示例6:
<td>{$classify_name} </td>
<td class=\\"over\\">
<div class=\\"new_float_parent\\">
<input type=\\"text\\" class=\\"text\\" size=\\"4\\" name=\\"position\\" value=\\"{$position}\\" />
<div class=\\"new_float\\" style=\\"z-index:9999\\">
<input type=\\"text\\" class=\\"text\\" size=\\"4\\" name=\\"order\\" value=\\"{$position}\\" />
<input type=\\"button\\" class=\\"ui-button-small\\" value=\\"保存\\" name=\\"submit_order_form\\" />
<input type=\\"hidden\\" name=\\"id\\" value=\\"{$id}\\"/>
<input type=\\"button\\" class=\\"ui-button-small\\" value=\\"取消\\" name=\\"cancel_order_form\\" />
</div>
</div>
</td>
<td>{$update_timestamp} </td>
<td>{$is_show} </td>
</tr>';
$tree = tree::get_tree($list, $str, 0, 0, ' ');
echo $tree;
?>
</tbody>
</form>
</table>
<?php
} else {
?>
<?php
echo remind::no_rows();
?>
<?php
}
?>
</div>
示例7: edit
public function edit()
{
role::check('product_category_edit');
$return_struct = array('status' => 0, 'code' => 501, 'msg' => 'Not Implemented', 'content' => array());
try {
//* 初始化返回数据 */
$return_data = array('action' => 'post');
//* 收集请求数据 ==根据业务逻辑定制== */
$request_data = $this->input->get();
//数据验证
if (!isset($request_data['id']) || !is_numeric($request_data['id'])) {
throw new MyRuntimeException(Kohana::lang('o_global.input_error'), 404);
}
$category_service = CategoryService::get_instance();
$category = $category_service->get($request_data['id']);
//返回数据
//$category['pic_url'] = AttributeService::get_attach_url($category['pic_attach_id'], 't');
$category['pic_url'] = AttService::get_instance($this->img_dir_name)->get_img_url($category['pic_attach_id']);
$return_data['data'] = $category;
//uri_name处理
$route = Myroute::instance()->get();
$route_type = $route['type'];
$category_route = $route['category'];
$category_suffix = $route['category_suffix'];
if ($route_type == 0) {
// 0: none get category and product with id
$category_permalink = $category_route . '/' . $category['id'];
} else {
if ($route_type == 1) {
// 1: get product with {product}/permalink
$category_permalink = $category_route . '/';
} else {
if ($route_type == 2 || $route_type == 4) {
// 2: get category and product with {category_permalink} and {category+permalink}/{product_permalink}
$category_permalink = '';
} else {
if ($route_type == 3) {
// 3: get category and prdouct with {category_permalink1}/.../{category_permalinkn} and {category_permalink1}/.../{category_permalinkn}/{product_permalink}
$parents = $category_service->get_parents_by_category_id($category['id']);
$category_permalink = '';
$i = 1;
foreach ($parents as $val) {
if ($i != 1) {
$category_permalink = urlencode($val['uri_name']) . '/' . $category_permalink;
}
$i++;
}
}
}
}
}
//当前站点分类
$categories = $category_service->get_categories();
$child_ids = $category_service->get_childrens_by_category_id($category['id']);
$parent_data = $category_service->get_parents_by_category_id($category['id']);
$parent_is_show = isset($parent_data[1]) ? $parent_data[1]['is_show'] : 1;
//去掉子分类和自己
foreach ($categories as $key => $val) {
if (in_array($val['id'], $child_ids) || $val['id'] == $category['id']) {
unset($categories[$key]);
}
}
$str = '<option value={$id} {$selected}>{$spacer}{$title}</option>';
//$return_data['category_list'] = $category_service->get_tree_by_site_id($request_data['site_id'], '<option value={$id} {$selected}>{$spacer}{$title}</option>',$category['pid']);
$return_data['category_list'] = tree::get_tree($categories, $str, 0, $category['pid']);
//当前站点类型
$classify = ClassifyService::get_instance()->get_classifies();
$return_data['classify_list'] = '';
foreach ($classify as $val) {
$selected = $category['classify_id'] == $val['id'] ? 'selected' : '';
$return_data['classify_list'] .= '<option value=' . $val['id'] . ' ' . $selected . '>--' . $val['name'] . '--</option>';
}
//* 补充&修改返回结构体 */
$return_struct['status'] = 1;
$return_struct['code'] = 200;
$return_struct['msg'] = '';
$return_struct['content'] = $return_data;
//* 请求类型 */
if ($this->is_ajax_request()) {
// ajax 请求
// json 输出
$this->template->content = $return_struct;
} else {
// html 输出
//* 模板输出 */
$content = new View($this->package . '/' . $this->class_name . '/' . __FUNCTION__);
//* 变量绑定 */
$this->template->title = Kohana::config('site.name');
$this->template->content = $content;
//* 请求结构数据绑定 */
$this->template->content->request_data = $request_data;
//* 返回结构体绑定 */
$this->template->content->return_struct = $return_struct;
//:: 当前应用专用数据
$this->template->content->has_child = count($child_ids);
$this->template->content->parent_is_show = $parent_is_show;
$this->template->content->route_type = $route_type;
$this->template->content->category_suffix = $category_suffix;
$this->template->content->category_permalink = $category_permalink;
}
//.........这里部分代码省略.........
示例8: cache_category
function cache_category($moduleid = 0, $data = array())
{
global $db, $DT, $MODULE;
if ($moduleid) {
if (!$data) {
$result = $db->query("SELECT * FROM {$db->pre}category WHERE moduleid='{$moduleid}' ORDER BY listorder,catid");
while ($r = $db->fetch_array($result)) {
$data[$r['catid']] = $r;
}
}
$mod = cache_read('module-' . $moduleid . '.php');
$a = array();
$d = array('listorder', 'moduleid', 'item', 'template', 'show_template', 'seo_title', 'seo_keywords', 'seo_description', 'group_list', 'group_show', 'group_add');
foreach ($data as $r) {
$e = $r['catid'];
foreach ($d as $_d) {
unset($r[$_d]);
}
$a[$e] = $r;
}
cache_write('category-' . $moduleid . '.php', $a);
if (count($data) < 100) {
$categorys = array();
foreach ($data as $id => $cat) {
$categorys[$id] = array('id' => $id, 'parentid' => $cat['parentid'], 'name' => $cat['catname']);
}
require_once DT_ROOT . '/include/tree.class.php';
$tree = new tree();
$tree->tree($categorys);
$content = $tree->get_tree(0, "<option value=\\\"\$id\\\">\$spacer\$name</option>") . '</select>';
cache_write('catetree-' . $moduleid . '.php', $content);
} else {
cache_delete('catetree-' . $moduleid . '.php');
}
} else {
foreach ($MODULE as $moduleid => $module) {
cache_category($moduleid);
}
}
}
示例9: getAllAuthItem
/**
* 获取所有菜单的下拉列表
* @return type
*/
public function getAllAuthItem()
{
$all = self::model()->findAll("1=1 order By pid DESC ,sort DESC");
$wall = array();
foreach ($all as $key => $value) {
$wall[$value['id']]['id'] = $value['id'];
$wall[$value['id']]['name'] = $value['name'];
$wall[$value['id']]['pid'] = $value['pid'];
}
$tree = new tree($wall);
$str = "\$id+\$spacer\$name,";
$strs = trim($tree->get_tree(0, $str));
$arr1 = explode(",", $strs);
$result = array();
foreach ($arr1 as $key => $value) {
if ($value == "") {
unset($arr1[$key]);
}
$arra[] = explode("+", $value);
}
//去除重复
foreach ($arra as $key => $value) {
foreach ($value as $key1 => $value1) {
if ($value1 == "") {
unset($arra[$key]);
}
}
}
//整理数组
$re = array();
foreach ($arra as $key => $value) {
$re[$value[0]] = $value[1];
}
return $re;
}
示例10: get_tree_by_category_id
/**
* 根据 category_id 获取该 分类 下所有的子分类树
* @param $category_id int
* @param $str string 生成树型结构的基本代码,例如:例如:'<option value={$id} {$selected}>{$spacer}{$title}</option>'
* @param $sid int 被选中的ID,比如在做树型下拉框的时候需要用到
* @param $icon 前缀
* @return string
*/
public function get_tree_by_category_id($category_id, $str, $sid = 0, $icon = '--')
{
$categories = array();
$category = $this->get($category_id);
$site_id = $category['site_id'];
$categories = $this->load();
$tree = tree::get_tree($categories, $str, $category_id, $sid, $icon);
return $tree;
}
示例11: getTree
public static function getTree($data, $format = "<option value='\$catid' \$selected>\$spacer\$name</option>", $id = 0, $nbsp = " ", $icon = array(" ", " ", " "))
{
Ibos::import("ext.Tree", true);
$tree = new tree();
$tree->init($data);
$tree->icon = $icon;
$tree->nbsp = $nbsp;
$trees = $tree->get_tree(0, $format, $id);
return $trees;
}
示例12: category_menu_edit
/**
* 编辑商品分类导航
*/
public function category_menu_edit($id)
{
$site_menu = Mysite_menu::instance($id);
$temp = Mysite_menu::instance()->site_menu_queue($id);
if ($_POST) {
//标签过滤
tool::filter_strip_tags($_POST);
/* 获取要编辑的导航的level_depth并修改其下所有的子导航的level_depth*/
$data = $_POST;
$parent_id = $this->input->post('parent_id');
if ($parent_id == 0) {
$data['level_depth'] = 1;
} else {
$parent_level_depth = Mysite_menu::instance($parent_id)->get('level_depth');
$data['level_depth'] = $parent_level_depth + 1;
}
if (!Mysite_menu::instance()->child_level_depth_edit($id, $data['level_depth'], $temp)) {
remind::set(Kohana::lang('o_global.update_error'), 'site/menu');
}
/* 获取所添加的分类的url*/
$category_id = $this->input->post('category_id');
$data['url'] = category::permalink($category_id, false);
//'/category/'.$category_id;
/* 标志导航类型*/
$data['memo'] = 'category';
$data['type'] = $this->MENU_TYPE_CATEGORY;
$data['relation_id'] = $category_id;
if ($site_menu->site_menu_edit($id, $data)) {
remind::set(Kohana::lang('o_global.update_success'), 'site/menu/', 'success');
} else {
remind::set(Kohana::lang('o_global.update_error'), 'site/menu');
}
}
$site_menu_data = $site_menu->get();
/* 得到导航列表并删除自身及自身的子目录*/
$child_ids = array();
$site_menus = Mysite_menu::instance()->site_menu_queue();
foreach ($temp as $val) {
$child_ids[] = $val['id'];
}
foreach ($site_menus as $key => $value) {
if ($value['id'] == $id || in_array($value['id'], $child_ids)) {
unset($site_menus[$key]);
}
}
/* 当前站点分类*/
$categories = CategoryService::get_instance()->get_categories();
$str = '<option value={$id} {$selected}>{$spacer}{$title_manage}</option>';
$category_list = tree::get_tree($categories, $str, 0, $site_menu_data['relation_id']);
$this->template->content = new View("site/category_menu_edit");
$this->template->content->site_menus = $site_menus;
$this->template->content->category_list = $category_list;
$this->template->content->site_menu_data = $site_menu_data;
}