Example #1
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;
 }