Properties

$options

$options : 

Type

$arr

$arr : array

生成树型结构所需要的2维数组

Type

array

$icon

$icon : array

生成树型结构所需修饰符号,可以换成图片

Type

array

$nbsp

$nbsp : 

Type

$pidname

$pidname : 

Type

$instance

$instance : 

Type

$config

$config : 

Type

$formatTree

$formatTree : 

将格式数组转换为树

Type

Methods

__construct()

__construct(  $options = array()) 

Parameters

$options

instance()

instance(array  $options = array()) : \org\Tree

初始化

Parameters

array $options

参数

Returns

\org\Tree

init()

init(  $arr = array(),   $pidname = NULL,   $nbsp = NULL) 

初始化方法

Parameters

$arr
$pidname
$nbsp

getChild()

getChild(  $myid) : array

得到子级数组

Parameters

$myid

Returns

array

getChildren()

getChildren(integer  $myid, boolean  $withself = FALSE) : array

读取指定节点的所有孩子节点

Parameters

integer $myid

节点ID

boolean $withself

是否包含自身

Returns

array

getChildrenIds()

getChildrenIds(integer  $myid, boolean  $withself = FALSE) : array

读取指定节点的所有孩子节点ID

Parameters

integer $myid

节点ID

boolean $withself

是否包含自身

Returns

array

getParent()

getParent(  $myid) : array

得到当前位置父辈数组

Parameters

$myid

Returns

array

getParents()

getParents(  $myid,   $withself = FALSE) : array

得到当前位置所有父辈数组

Parameters

$myid
$withself

Returns

array

getParentsIds()

getParentsIds(integer  $myid, boolean  $withself = FALSE) : array

读取指定节点所有父类节点ID

Parameters

integer $myid
boolean $withself

Returns

array

getTree()

getTree(integer  $myid, string  $itemtpl = "<option value=@id @selected @disabled>@spacer@name</option>", mixed  $selectedids = '', mixed  $disabledids = '', string  $itemprefix = '', string  $toptpl = '') : string

树型结构Option

Parameters

integer $myid

表示获得这个ID下的所有子级

string $itemtpl

条目模板 如:"<option value=@id @selected @disabled>@spacer@name"

mixed $selectedids

被选中的ID,比如在做树型下拉框的时候需要用到

mixed $disabledids

被禁用的ID,比如在做树型下拉框的时候需要用到

string $itemprefix

每一项前缀

string $toptpl

顶级栏目的模板

Returns

string

getTreeUl()

getTreeUl(integer  $myid, string  $itemtpl, string  $selectedids = '', string  $disabledids = '', string  $wraptag = 'ul',   $wrapattr = '') : string

树型结构UL

Parameters

integer $myid

表示获得这个ID下的所有子级

string $itemtpl

条目模板 如:"<li value=@id @selected @disabled>@name @childlist"

string $selectedids

选中的ID

string $disabledids

禁用的ID

string $wraptag

子列表包裹标签

$wrapattr

Returns

string

getTreeMenu()

getTreeMenu(integer  $myid, string  $itemtpl, mixed  $selectedids = '', mixed  $disabledids = '', string  $wraptag = 'ul', string  $wrapattr = '', integer  $deeplevel) : string

菜单数据

Parameters

integer $myid
string $itemtpl
mixed $selectedids
mixed $disabledids
string $wraptag
string $wrapattr
integer $deeplevel

Returns

string

getTreeSpecial()

getTreeSpecial(integer  $myid, string  $itemtpl1, string  $itemtpl2, mixed  $selectedids, mixed  $disabledids, integer  $itemprefix = '') 

特殊

Parameters

integer $myid

要查询的ID

string $itemtpl1

第一种HTML代码方式

string $itemtpl2

第二种HTML代码方式

mixed $selectedids

默认选中

mixed $disabledids

禁用

integer $itemprefix

前缀

getTreeArray()

getTreeArray(string  $myid, string  $itemprefix = '') : string

获取树状数组

Parameters

string $myid

要查询的ID

string $itemprefix

前缀

Returns

string

getTreeList()

getTreeList(array  $data = array(),   $field = 'name') : array

将getTreeArray的结果返回为二维数组

Parameters

array $data
$field

Returns

array

toTree()

toTree(array  $list = null,   $pk = 'id', string  $pid = 'pid',   $child = '_child') : array

把返回的数据集转换成Tree

Parameters

array $list

要转换的数据集

$pk
string $pid

parent标记字段

$child

Returns

array

toFormatTree()

toFormatTree(  $list, string  $title = 'title', string  $pk = 'id', string  $pid = 'pid', integer  $root) : array

生成多层树状下拉选框的工具select Author: websky

Parameters

$list
string $title
string $pk
string $pid
integer $root

Returns

array

list_to_tree()

list_to_tree(array  $list,   $pk = 'id', string  $pid = 'pid',   $child = '_child',   $root) : array

把返回的数据集转换成Tree

Parameters

array $list

要转换的数据集

$pk
string $pid

parent标记字段

$child
$root

Returns

array

tree_to_list()

tree_to_list(array  $tree, string  $child = '_child', string  $order = 'id', array  $list = array()) : array

将list_to_tree的树还原成列表

Parameters

array $tree

原来的树

string $child

孩子节点的键

string $order

排序显示的键,一般是主键 升序排列

array $list

过渡用的中间数组,

Returns

array —

返回排过序的列表数组

list_sort_by()

list_sort_by(array  $list, string  $field, array  $sortby = 'asc') : array

对查询结果集进行排序

Parameters

array $list

查询结果

string $field

排序的字段名

array $sortby

排序类型 asc正向排序 desc逆向排序 nat自然排序

Returns

array

_toFormatTree()

_toFormatTree(  $list,   $level,   $title = 'title') 

Parameters

$list
$level
$title