コード例 #1
0
ファイル: Node.php プロジェクト: Airmal/Magento-Em
 public function removeChild($childNode)
 {
     $this->_childNodes->delete($childNode);
     return $this;
 }
コード例 #2
0
ファイル: Tree.php プロジェクト: Airmal/Magento-Em
 /**
  * Enter description here...
  *
  * @param unknown_type $nodeId
  * @return Varien_Data_Tree_Node
  */
 public function getNodeById($nodeId)
 {
     return $this->_nodes->searchById($nodeId);
 }
コード例 #3
0
 /**
  * Expand recursively hidden (include_in_menu = 0) categories. Preserve
  * order of categories. Hide empty (no subcategories) and hidden categories.
  *
  * @param Varien_Data_Tree_Node_Collection $categories Collection of nodes
  * @return Varien_Data_Tree_Node_Collection
  */
 protected function _expandCategories($categories)
 {
     if (!$categories->count()) {
         return $categories;
     }
     foreach ($categories as $id => $category) {
         $children = $this->_expandCategories($category->getChildren());
         $noChildren = !$children->count();
         $notIncludeInMenu = !$category->getIncludeInMenu();
         //Hide empty and not included in menu categories
         if ($notIncludeInMenu && $noChildren) {
             $categories->delete($category);
             continue;
         }
         //Ignore empty categories
         if ($noChildren) {
             continue;
         }
         //Remember hidden category to expand on next step
         if ($notIncludeInMenu) {
             $replace[$id] = true;
         }
     }
     if (isset($replace)) {
         //Expand hidden categories and re-add visible categories as is to preserve
         //original order
         foreach ($categories as $id => $category) {
             $categories->delete($category);
             if (isset($replace[$id])) {
                 //Copy level and position values of expanded category to it's children
                 $level = $category->getLevel();
                 $position = $category->getPosition();
                 foreach ($category->getChildren() as $child) {
                     $child->setLevel($level)->setPosition($position);
                     $category->removeChild($child);
                     $categories->add($child);
                 }
             } else {
                 $categories->add($category);
             }
         }
     }
     return $categories;
 }