Esempio n. 1
0
 private function addMenuNode($parent, NestedSet\NodeWrapper $node, $homepage)
 {
     $menuItem = $node->getNode();
     $name = $menuItem->getName();
     $url = $menuItem->getUrl();
     if ($homepage) {
         $newNode = $parent->setupHomepage($name, $url);
     } else {
         $newNode = $parent->add($name, $url);
     }
     $newNode->setAsCurrent($menuItem->isCurrent());
     $newNode->setOpenInNewWindow($menuItem->isExternal());
     foreach ($node->getChildren() as $child) {
         $this->addMenuNode($newNode, $child, false);
     }
 }
 /**
  * Serializes the given NodeWrapper as array including all children.
  * @param NodeWrapper $node The category nodewrapper to serialize
  * @throws \Exception
  */
 public function serializeTree(NodeWrapper $node = null)
 {
     if ($node == null) {
         throw new \Exception("Node must not be null!");
     }
     $aData = $node->getNode()->serialize();
     $aData["children"] = array();
     if (count($node->getChildren()) == 0) {
         $aData["leaf"] = true;
     } else {
         $aData["expanded"] = true;
     }
     foreach ($node->getChildren() as $child) {
         $aData["children"][] = $this->serializeTree($child);
     }
     return $aData;
 }
 /**
  * Updates the category paths for a given node and all children.
  * 
  * This method is usually called whenever a category is moved.
  * 
  * @param NodeWrapper $startNode The node to start updating at
  */
 public function updateCategoryPaths(NodeWrapper $startNode)
 {
     $pathSeparator = Configuration::getOption("partkeepr.category.path_separator", " ➤ ");
     $startNode->getNode()->setCategoryPath($startNode->getPath($pathSeparator, true));
     foreach ($startNode->getChildren() as $child) {
         $this->updateCategoryPaths($child);
     }
 }