本文整理汇总了PHP中Tree::addItem方法的典型用法代码示例。如果您正苦于以下问题:PHP Tree::addItem方法的具体用法?PHP Tree::addItem怎么用?PHP Tree::addItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tree
的用法示例。
在下文中一共展示了Tree::addItem方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addColumn
/**
* Add column
* @param string $id
* @param Ext_Objejct $object
* @param string $parent - paren object name
*/
public function addColumn($id, $object, $parent = 0)
{
if (strpos($object->getClass(), 'Grid_Column') != 0) {
return false;
}
return $this->_columns->addItem($id, $parent, $object);
}
示例2: addObject
/**
* Add Ext_Object to the project
* @param string $parent - parant object name or "0" for root
* @param Ext_Object $object
* @return boolean - success flag
*/
public function addObject($parent, Ext_Object $object)
{
if (strlen($parent) && $parent !== 0 && !$this->objectExists($parent) || in_array($object->getClass(), self::$_nonDraggable, true)) {
$parent = 0;
}
return $this->_tree->addItem($object->getName(), $parent, $object);
}
示例3: getTree
/**
* Get class hierarchy
* @param integer $vers
* @return Tree
*/
public function getTree($vers)
{
$data = $this->getList(false, array('vers' => $vers), array('id', 'parentId', 'name'));
$tree = new Tree();
if (!empty($data)) {
foreach ($data as $k => $v) {
if (empty($v['parentId'])) {
$v['parentId'] = 0;
}
$tree->addItem($v['id'], $v['parentId'], $v['name']);
}
}
return $tree;
}
示例4: getCategoriesTree
/**
* Get categories tree
* @return array
*/
public function getCategoriesTree()
{
$categoryModel = Model::factory('Mediacategory');
$data = $categoryModel->getList();
$tree = new Tree();
if (!empty($data)) {
foreach ($data as $k => $v) {
if (is_null($v['parent_id'])) {
$v['parent_id'] = 0;
}
$tree->addItem($v['id'], $v['parent_id'], $v);
}
}
return $this->_fillCatChilds($tree, 0);
}
示例5: fileListToTree
/**
* Convert files list into Tree structure
* @param array $data
* @return Tree
*/
public static function fileListToTree(array $data)
{
$tree = new Tree();
foreach ($data as $k => $v) {
$tmp = explode('/', substr($v, 2));
for ($i = 0, $s = sizeof($tmp); $i < $s; $i++) {
if ($i == 0) {
$id = $tmp[0];
$par = 0;
} else {
$id = implode('/', array_slice($tmp, 0, $i + 1));
$par = implode('/', array_slice($tmp, 0, $i));
}
$tree->addItem($id, $par, $tmp[$i]);
}
}
return $tree;
}
示例6: getTreeList
/**
* Get data for Tree.Panel
* @param array $version
*/
public function getTreeList($version)
{
/*
* Add required fields
*/
$fields = array('id', 'parentId', 'path', 'isDir', 'name', 'hid');
$data = $this->getList(array('sort' => array('isDir' => 'DESC', 'path', 'name'), 'dir' => 'ASC'), array('vers' => $version), $fields);
if (empty($data)) {
return array();
}
$tree = new Tree();
foreach ($data as $value) {
if (!$value['parentId']) {
$value['parentId'] = 0;
}
$tree->addItem($value['id'], $value['parentId'], $value);
}
return $this->_fillChilds($tree, 0);
}
示例7: Tree
<a href="' . $v['data']['link_url'] . '">' . $v['data']['title'] . '</a>
</div>';
if ($tree->hasChilds($v['id'])) {
$s .= $createMenuNode($tree, $v['id'], $page, $pagesTree);
}
$s .= '</div>';
}
return $s;
};
$pagesTree = $this->get('pagesTree');
$tree = new Tree();
$menuData = $this->get('menuData');
$config = $this->get('config');
if (is_array($menuData) && !empty($menuData)) {
foreach ($menuData as $k => $v) {
$tree->addItem($v['tree_id'], $v['parent_id'], $v, $v['order']);
}
}
?>
<div class="blockItem">
<?php
if ($config['show_title']) {
echo '<div class="blockTitle">', $config['title'], '</div>';
}
?>
<div class="blockContent">
<?php
if ($tree->hasChilds(0)) {
echo $createMenuNode($tree, 0, $this->get('page'), $pagesTree);
}
?>
示例8: getTree
/**
* Get pages Tree
* @return Tree
*/
public function getTree()
{
static $tree = false;
if ($tree instanceof Tree) {
return $tree;
}
if (self::$_dataCache) {
$cacheKey = $this->getCacheKey(array('pages_tree_data'));
$tree = self::$_dataCache->load($cacheKey);
}
if ($tree instanceof Tree) {
return $tree;
}
$fields = array('id', 'parent_id', 'order_no', 'code', 'menu_title', 'is_fixed', 'published', 'in_site_map');
$data = $this->getListVc(array('sort' => 'order_no', 'dir' => 'ASC'), false, false, $fields, false, false);
$tree = new Tree();
if (!empty($data)) {
foreach ($data as $k => $v) {
$tree->addItem($v['id'], $v['parent_id'], $v);
}
}
if (self::$_dataCache) {
self::$_dataCache->save($tree, $cacheKey);
}
return $tree;
}
示例9: addAction
/**
* Add action object
* @param string $id
* @param mixed $data
*/
public function addAction($id, $data)
{
$this->_actions->addItem($id, 0, $data);
}
示例10: addPart
/**
* Add Query part
* @param Db_Query_Part $part
* @param string $parentPartId - parend Db_Part id
* @return boolean
*/
public function addPart(Db_Query_Part $part, $parentPartId = 0)
{
$part->setParentPart($parentPartId);
return $this->_tree->addItem($part->getId(), $parentPartId, $part);
}
示例11: exportsiteStructure
/**
* Import Data from Site structure
*/
public function exportsiteStructure()
{
$pageModel = Model::factory('page');
$data = $pageModel->getList(array('sort' => 'order_no', 'dir' => 'DESC'), false, array('tree_id' => 'id', 'title' => 'menu_title', 'page_id' => $pageModel->getPrimaryKey(), 'published' => 'published', 'parent_id' => 'parent_id', 'order' => 'order_no'));
if (!$data) {
return array();
}
$tree = new Tree();
foreach ($data as $value) {
$value['link_type'] = 'page';
$value['resource_id'] = '';
$value['url'] = '';
$tree->addItem($value['tree_id'], intval($value['parent_id']), $value, $value['order']);
}
return $this->_fillChilds($tree, 0);
}
示例12: testGetParentsList
public function testGetParentsList()
{
$tree = new Tree();
$tree->addItem(1, 0, 100);
$tree->addItem(2, 0, 200);
$tree->addItem(3, 2, 300);
$tree->addItem(4, 3, 400);
$tree->addItem(5, 3, 500);
$this->assertEquals($tree->getParentsList(5), array(2, 3));
}