Properties

$arr

$arr : array

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

Type

array

$options

$options

$icon

$icon : array

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

Type

array

$nbsp

$nbsp

$id

$id

$pidname

$pidname

$child

$child

$ret

$ret

$instance

$instance

Methods

instance()

instance(array  $options = []) : \util\Tree

初始化.

Parameters

array $options

参数

Returns

\util\Tree —

init()

init(mixed  $arr = [], mixed  $pidname = null, mixed  $nbsp = null) : mixed

构造函数,初始化类

Parameters

mixed $arr
mixed $pidname
mixed $nbsp

Returns

mixed —

getChild()

getChild(mixed  $myid) : array

得到子级数组

Parameters

mixed $myid

Returns

array —

getChildren()

getChildren(int  $myid, bool  $withself = false) : array

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

Parameters

int $myid

节点ID

bool $withself

是否包含自身

Returns

array —

getChildrenIds()

getChildrenIds(int  $myid, bool  $withself = false) : array

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

Parameters

int $myid

节点ID

bool $withself

是否包含自身

Returns

array —

getParent()

getParent(mixed  $myid) : array

得到当前位置父辈数组

Parameters

mixed $myid

Returns

array —

getParents()

getParents(mixed  $myid, bool  $withself = false) : array

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

Parameters

mixed $myid
bool $withself

是否包含自己

Returns

array —

getParentsIds()

getParentsIds(int  $myid, bool  $withself = false) : array

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

Parameters

int $myid
bool $withself

Returns

array —

getTree()

getTree(int  $myid, string  $itemtpl = '', mixed  $selectedids = '', mixed  $disabledids = '', string  $itemprefix = '', string  $toptpl = '') : string

树型结构Option

Parameters

int $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(int  $myid, string  $itemtpl, string  $selectedids = '', string  $disabledids = '', string  $wraptag = 'ul', string  $wrapattr = '') : string

树型结构UL

Parameters

int $myid

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

string $itemtpl

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

string $selectedids

选中的ID

string $disabledids

禁用的ID

string $wraptag

子列表包裹标签

string $wrapattr

子列表包裹属性

Returns

string —

toLayer()

toLayer(int  $pid, int  $max_level, int  $curr_level) : array

将数据集格式化成层次结构

Parameters

int $pid

父级id

int $max_level

最多返回多少层,0为不限制

int $curr_level

当前层数

Returns

array —

getTreeArray()

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

获取树状数组

Parameters

string $myid

要查询的ID

string $itemprefix

前缀

Returns

string —

getTreeList()

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

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

Parameters

array $data
mixed $field

Returns

array —

have()

have(mixed  $list, mixed  $item) : mixed

Parameters

mixed $list
mixed $item

Returns

mixed —