Ejemplo n.º 1
0
 /**
  * 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);
 }
Ejemplo n.º 2
0
 /**
  * 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);
 }
Ejemplo n.º 3
0
 /**
  * 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;
 }
Ejemplo n.º 4
0
 /**
  * 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);
 }
Ejemplo n.º 5
0
 /**
  * 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;
 }
Ejemplo n.º 6
0
 /**
  * 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);
 }
Ejemplo n.º 7
0
                 	<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);
}
?>
Ejemplo n.º 8
0
 /**
  * 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;
 }
Ejemplo n.º 9
0
 /**
  * Add action object
  * @param string $id
  * @param mixed $data
  */
 public function addAction($id, $data)
 {
     $this->_actions->addItem($id, 0, $data);
 }
Ejemplo n.º 10
0
 /**
  * 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);
 }
Ejemplo n.º 11
0
 /**
  * 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);
 }
Ejemplo n.º 12
0
 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));
 }