Ejemplo n.º 1
0
 /**
  * Get actions list
  * @return $array
  */
 public function getActions()
 {
     if (!$this->_actions->hasChilds(0)) {
         return array();
     }
     $list = $this->_actions->getChilds(0);
     $result = array();
     if (!empty($list)) {
         foreach ($list as $k => $v) {
             $result[$v['id']] = $v['data'];
         }
     }
     return $result;
 }
Ejemplo n.º 2
0
 /**
  * Fill childs data array for tree panel
  * @param Tree $tree
  * @param mixed $root
  * @return array
  */
 protected function _fillChilds(Tree $tree, $root = 0)
 {
     $result = array();
     $childs = $tree->getChilds($root);
     if (empty($childs)) {
         return array();
     }
     foreach ($childs as $k => $v) {
         $row = $v['data'];
         $obj = new stdClass();
         $obj->id = $row['id'];
         $obj->text = $row['name'];
         $obj->expanded = false;
         $obj->isDir = $row['isDir'];
         $obj->path = $row['path'];
         $obj->name = $row['name'];
         $obj->hid = $row['hid'];
         if ($row['isDir']) {
             $obj->leaf = false;
         } else {
             $obj->leaf = true;
         }
         $cld = array();
         if ($tree->hasChilds($row['id'])) {
             $cld = $this->_fillChilds($tree, $row['id']);
         }
         $obj->children = $cld;
         $result[] = $obj;
     }
     return $result;
 }
Ejemplo n.º 3
0
 /**
  * Fill childs data array for tree panel
  * @param Tree $tree
  * @param mixed $root
  * @return array
  */
 protected function _fillChilds(Tree $tree, $root = 0)
 {
     $result = array();
     $childs = $tree->getChilds($root);
     if (empty($childs)) {
         return array();
     }
     $appConfig = Registry::get('main', 'config');
     foreach ($childs as $k => $v) {
         $row = $v['data'];
         $obj = new stdClass();
         $obj->id = $row['id'];
         $obj->text = $row['menu_title'] . ' <i>(' . $row['code'] . $appConfig['urlExtension'] . ')</i>';
         $obj->expanded = true;
         $obj->leaf = false;
         if ($row['published']) {
             $obj->qtip = $row['menu_title'] . ' <i>(' . $row['code'] . $appConfig['urlExtension'] . ')</i> published';
             $obj->iconCls = 'pagePublic';
         } else {
             $obj->qtip = $row['menu_title'] . ' <i>(' . $row['code'] . $appConfig['urlExtension'] . ')</i> not published';
             $obj->iconCls = 'pageHidden';
         }
         if ($row['is_fixed']) {
             $obj->allowDrag = false;
         }
         $cld = array();
         if ($tree->hasChilds($row['id'])) {
             $cld = $this->_fillChilds($tree, $row['id']);
         }
         $obj->children = $cld;
         $result[] = $obj;
     }
     return $result;
 }
Ejemplo n.º 4
0
 /**
  * Fill childs data array for tree panel
  * @param Tree $tree
  * @param mixed $root
  * @return array
  */
 protected function _fillChilds(Tree $tree, $root = 0)
 {
     $result = array();
     $childs = $tree->getChilds($root);
     if (empty($childs)) {
         return array();
     }
     foreach ($childs as $k => $v) {
         $row = $v['data'];
         $obj = new stdClass();
         $obj->id = $row['tree_id'];
         $obj->text = $row['title'];
         $obj->expanded = true;
         $obj->leaf = false;
         $obj->allowDrag = true;
         $obj->page_id = $row['page_id'];
         $obj->parent_id = $row['parent_id'];
         $obj->published = $row['published'];
         $obj->url = isset($row['url']) ? $row['url'] : '';
         $obj->resource_id = isset($row['resource_id']) ? $row['resource_id'] : '';
         $obj->link_type = isset($row['link_type']) ? $row['link_type'] : '';
         if ($row['published']) {
             $obj->iconCls = 'pagePublic';
         } else {
             $obj->iconCls = 'pageHidden';
         }
         $cld = array();
         if ($tree->hasChilds($row['tree_id'])) {
             $cld = $this->_fillChilds($tree, $row['tree_id']);
         }
         $obj->children = $cld;
         $result[] = $obj;
     }
     return $result;
 }
Ejemplo n.º 5
0
 /**
  * Recursive method
  * @param string $parent - parent part id
  * @param Db_Select $sql
  */
 protected function _fillQuery($partId, $sql, $countOnly = false)
 {
     $parentItem = $this->_tree->getItem($partId);
     $childs = $this->_tree->getChilds($partId);
     foreach ($childs as $child) {
         $this->_addSqlPart($child['data'], $sql, $parentItem['data'], $countOnly);
         $part = $child['data'];
         if ($this->_tree->hasChilds($part->getId())) {
             $this->_fillQuery($part->getId(), $sql, $countOnly);
         }
     }
 }
Ejemplo n.º 6
0
    public function perform(IHttpContext $context, $params = null)
    {
        $tree = new Tree();
        $db = PluginManager::getInstance()->getPlugin('creole')->getC();
        if ($params[0] == null) {
            $rs = $db->executeQuery('SELECT t.object_id, o.* FROM tree t, objects o WHERE t.object_id = o.id AND depth = 2');
            $ret = array();
            while ($rs->next()) {
                $ret[] = $rs->getRow();
            }
            return array('result' => $ret, 'type' => 'cat');
        } else {
            if ($tree->hasChilds($params[0])) {
                $rs = $db->executeQuery('SELECT o.*
								     FROM objects o
									 LEFT JOIN tree t ON ( t.object_id = o.id )
									 WHERE t.parent_id =' . $params[0]);
                $ret = array();
                while ($rs->next()) {
                    $ret[] = $rs->getRow();
                }
                return array('result' => $ret, 'type' => 'titles');
            } else {
                $rs = $db->executeQuery('SELECT o.*, u.FirstName, u.LastName
								     FROM objects o
									 LEFT JOIN tree t ON ( t.object_id = o.id )
									 LEFT JOIN lum_user u ON (o.user_id = u.id)
									 WHERE t.object_id =' . $params[0]);
                $ret = array();
                while ($rs->next()) {
                    $ret = $rs->getRow();
                }
                return array('result' => $ret, 'type' => 'text');
            }
        }
    }
Ejemplo n.º 7
0
 /**
  * Fill childs data array for tree panel
  * @param Tree $tree
  * @param mixed $root
  * @return array
  */
 protected function _fillCatChilds(Tree $tree, $root = 0)
 {
     $result = array();
     $childs = $tree->getChilds($root);
     if (empty($childs)) {
         return array();
     }
     foreach ($childs as $k => $v) {
         $row = $v['data'];
         $obj = new stdClass();
         $obj->id = $row['id'];
         $obj->text = $row['title'];
         $obj->expanded = !intval($root);
         $obj->leaf = false;
         $obj->allowDrag = true;
         $cld = array();
         if ($tree->hasChilds($row['id'])) {
             $cld = $this->_fillCatChilds($tree, $row['id']);
         }
         $obj->children = $cld;
         $result[] = $obj;
     }
     return $result;
 }
Ejemplo n.º 8
0
    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);
}
?>
	</div>
</div>
<div class="sep"></div>



Ejemplo n.º 9
0
 /**
  * Fill childs data array for tree panel
  * @param Tree $tree
  * @param mixed $root
  * @return array
  */
 protected function _fillChilds(Tree $tree, $root = 0)
 {
     $expanded = array('system', 'system/app', 'system/library');
     $result = array();
     $childs = $tree->getChilds($root);
     if (empty($childs)) {
         return array();
     }
     foreach ($childs as $k => $v) {
         $obj = new stdClass();
         $obj->id = $v['id'];
         $obj->text = $v['data'];
         $obj->expanded = false;
         $cld = array();
         if (strpos($obj->text, '.php')) {
             $obj->leaf = true;
         } else {
             if ($tree->hasChilds($v['id'])) {
                 $cld = $this->_fillChilds($tree, $v['id']);
                 if (empty($cld)) {
                     continue;
                 }
             } else {
                 continue;
             }
             $obj->leaf = false;
             $obj->expanded = in_array($v['id'], $expanded, true);
         }
         $obj->checked = false;
         $obj->allowDrag = false;
         $obj->children = $cld;
         $result[] = $obj;
     }
     return $result;
 }
Ejemplo n.º 10
0
 /**
  * Fill childs data array for columns tree
  * @param Tree $tree
  * @param mixed $root
  * @return array
  */
 protected function _compileColumns(Tree $tree, $root = 0)
 {
     $result = array();
     $childs = $tree->getChilds($root);
     if (empty($childs)) {
         return array();
     }
     foreach ($childs as $k => $v) {
         $column = $v['data'];
         $column->columns = '';
         if ($tree->hasChilds($v['id'])) {
             $column->columns = "[\n\t" . Utils_String::addIndent(implode(",\n", $this->_compileColumns($tree, $v['id'])), 2) . "\n]";
         }
         $result[] = Utils_String::addIndent($column->__toString(), 2);
     }
     return $result;
 }
Ejemplo n.º 11
0
 /**
  * Fill childs data array for tree panel
  * @param Tree $tree
  * @param mixed $root
  * @return array
  */
 protected function _fillContainers(Tree $tree, $root = 0, $exceptStorage = true)
 {
     $exceptions = array('Store', 'Data_Store', 'Data_Store_Tree', 'Model');
     $result = array();
     $childs = $tree->getChilds($root);
     if (empty($childs)) {
         return array();
     }
     foreach ($childs as $k => $v) {
         $object = $v['data'];
         $objectClass = $object->getClass();
         $objectName = $object->getName();
         if ($exceptStorage && in_array($objectClass, $exceptions, true)) {
             continue;
         }
         $item = new stdClass();
         $item->id = $v['id'];
         $inst = '';
         $ext = '';
         if ($object->isInstance()) {
             $inst = ' <span class="extInstanceLabel" data-qtip="Object instance">instance of </span>' . $object->getObject()->getName();
         } elseif ($object->isExtendedComponent()) {
             $ext = ' <span class="extCmpLabel" data-qtip="Extended component">ext</span> ';
             if ($object->defineOnly) {
                 $objectName = '<span class="extClassLabel" data-qtip="defineOnly:true">' . $objectName . '</span>';
             }
         }
         $item->text = $ext . $objectName . ' (' . $objectClass . ')' . $inst;
         $item->expanded = true;
         $item->objClass = $objectClass;
         $item->isInstance = $object->isInstance();
         $item->leaf = true;
         $item->iconCls = self::getIconClass($objectClass);
         $item->allowDrag = Designer_Project::isDraggable($objectClass);
         if ($objectClass == 'Docked') {
             $item->iconCls = 'objectDocked';
             $item->text = 'Docked Items';
         } elseif ($objectClass == 'Menu') {
             $item->text = 'Menu Items';
             $item->iconCls = 'menuItemsIcon';
         }
         if (Designer_Project::isContainer($objectClass) && !$object->isInstance()) {
             $item->leaf = false;
             $item->children = array();
         }
         if ($tree->hasChilds($v['id'])) {
             $item->children = $this->_fillContainers($tree, $v['id'], $exceptStorage);
         }
         $result[] = $item;
     }
     return $result;
 }
Ejemplo n.º 12
0
 /**
  * Check if object has childs.
  * @param string $name
  * @return boolean
  */
 public function hasChilds($name)
 {
     return $this->_tree->hasChilds($name);
 }
Ejemplo n.º 13
0
 /**
  * Fill childs data array for tree panel
  * @param Tree $tree
  * @param mixed $root
  * @return array
  */
 protected function _fillChilds(Tree $tree, $root = 0)
 {
     $result = array();
     $childs = $tree->getChilds($root);
     if (empty($childs)) {
         return array();
     }
     foreach ($childs as $k => $v) {
         $obj = new stdClass();
         $obj->id = $v['id'];
         $obj->text = $v['data'];
         $obj->expanded = false;
         $obj->checked = false;
         $obj->allowDrag = false;
         if (strpos($obj->text, '.') && !$tree->hasChilds($v['id'])) {
             $obj->leaf = true;
         } else {
             $obj->leaf = false;
         }
         $cld = array();
         if ($tree->hasChilds($v['id'])) {
             $cld = $this->_fillChilds($tree, $v['id']);
         }
         $obj->children = $cld;
         $result[] = $obj;
     }
     return $result;
 }
Ejemplo n.º 14
0
 public function testRemoveItem()
 {
     $tree = new Tree();
     $item = new stdClass();
     $item->id = 1;
     $tree->addItem($item->id, 0, $item);
     $item2 = new stdClass();
     $item2->id = 2;
     $tree->addItem($item2->id, 1, $item2);
     $tree->removeItem(2);
     $this->assertEquals($tree->getItemsCount(), 1);
     $this->assertFalse($tree->itemExists(2));
     $this->assertFalse($tree->hasChilds(1));
 }