\jmwlTree

jmwl\Tree 通用的树型类

Summary

Methods
Properties
Constants
__construct()
instance()
init()
getChild()
getChildren()
getChildrenIds()
getParent()
getParents()
getParentsIds()
getTree()
getTreeUl()
getTreeMenu()
getTreeSpecial()
getTreeArray()
getTreeList()
$options
$arr
$icon
$nbsp
$pidname
No constants found
No protected methods found
$instance
$config
N/A
No private methods found
No private properties found
N/A

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

Methods

__construct()

__construct(  $options = array()) 

Parameters

$options

instance()

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

初始化

Parameters

array $options

参数

Returns

\jmwl\Tree

init()

init(array  $arr = array(), string  $pidname = null, string  $nbsp = null) : \jmwl\Tree

初始化方法

Parameters

array $arr

2维数组,例如: array( 1 => array('id'=>'1','pid'=>0,'name'=>'一级栏目一'), 2 => array('id'=>'2','pid'=>0,'name'=>'一级栏目二'), 3 => array('id'=>'3','pid'=>1,'name'=>'二级栏目一'), 4 => array('id'=>'4','pid'=>1,'name'=>'二级栏目二'), 5 => array('id'=>'5','pid'=>2,'name'=>'二级栏目三'), 6 => array('id'=>'6','pid'=>3,'name'=>'三级栏目一'), 7 => array('id'=>'7','pid'=>3,'name'=>'三级栏目二') )

string $pidname

父字段名称

string $nbsp

空格占位符

Returns

\jmwl\Tree

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, boolean  $withself = false) : array

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

Parameters

$myid
boolean $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', string  $wrapattr = '') : string

树型结构UL

Parameters

integer $myid

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

string $itemtpl

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

string $selectedids

选中的ID

string $disabledids

禁用的ID

string $wraptag

子列表包裹标签

string $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, string  $itemprefix = '') : string

特殊

Parameters

integer $myid

要查询的ID

string $itemtpl1

第一种HTML代码方式

string $itemtpl2

第二种HTML代码方式

mixed $selectedids

默认选中

mixed $disabledids

禁用

string $itemprefix

前缀

Returns

string

getTreeArray()

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

获取树状数组

Parameters

string $myid

要查询的ID

string $itemprefix

前缀

Returns

array

getTreeList()

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

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

Parameters

array $data
string $field

Returns

array