Пример #1
0
 public function buildCategoriesMultiselectValues(Varien_Data_Tree_Node $node, $values, $level = 0)
 {
     $level++;
     $values[$node->getId()]['value'] = $node->getId();
     if ($level > 3) {
         $values[$node->getId()]['label'] = str_repeat("-", $level) . $node->getName();
     } else {
         $values[$node->getId()]['label'] = $node->getName();
     }
     foreach ($node->getChildren() as $child) {
         $values = $this->buildCategoriesMultiselectValues($child, $values, $level);
     }
     return $values;
 }
Пример #2
0
 /**
  * Get JSON of a tree node or an associative array
  *
  * @param Varien_Data_Tree_Node|array $node
  * @param int $level
  * @return string
  */
 protected function _getNodeJson($node, $level = 1)
 {
     $item = array();
     $item['text'] = $this->htmlEscape($node->getName());
     if ($this->_withProductCount) {
         $item['text'] .= ' (' . $node->getProductCount() . ')';
     }
     $item['id'] = $node->getId();
     $item['path'] = $node->getData('path');
     $item['cls'] = 'folder ' . ($node->getIsActive() ? 'active-category' : 'no-active-category');
     $item['allowDrop'] = false;
     $item['allowDrag'] = false;
     if ($node->hasChildren()) {
         $item['children'] = array();
         foreach ($node->getChildren() as $child) {
             $item['children'][] = $this->_getNodeJson($child, $level + 1);
         }
     }
     if (empty($item['children']) && (int) $node->getChildrenCount() > 0) {
         $item['children'] = array();
     }
     if (!empty($item['children'])) {
         $item['expanded'] = true;
     }
     if (in_array($node->getId(), $this->getCategoryIds())) {
         $item['checked'] = true;
     }
     return $item;
 }
Пример #3
0
 /**
  * @param Varien_Data_Tree_Node $menuTree
  * @return string
  */
 protected function _drawTwoLevelMenu(Varien_Data_Tree_Node $menuTree)
 {
     $children = $menuTree->getChildren();
     $html = '<li>';
     $html .= '<a href="' . $menuTree->getUrl() . '"><span>' . $this->escapeHtml($menuTree->getName()) . '</span></a>';
     $html .= '<div class="drop"><div class="drop-holder"><div class="col-frame"><div class="col-holder">';
     $index = 1;
     foreach ($children as $child) {
         $html .= '<div class="col">';
         $html .= '<strong class="title-drop">' . $this->escapeHtml($child->getName()) . '</strong><ul>';
         $secondLevelChildren = $child->getChildren();
         $childrenCount = $secondLevelChildren->count();
         $key = 0;
         foreach ($secondLevelChildren as $ch) {
             if ($key == 5) {
                 break;
             }
             $html .= '<li><a href="' . $ch->getUrl() . '">' . $this->escapeHtml($ch->getName()) . '</a></li>';
             $key++;
         }
         $html .= '</ul>';
         if ($childrenCount > 5 || $childrenCount == 0) {
             $html .= '<a class="all-links" href="' . $child->getUrl() . '">All ' . $this->escapeHtml($child->getName()) . '</a>';
         }
         $html .= '</div>';
         if ($index % 3 == 0 && $index > 0) {
             $html .= '</div><div class="col-holder">';
         }
         $index++;
     }
     $html .= '</div></div></div></div>';
     $html .= '</li>';
     return $html;
 }
 private function nodeToArray(Varien_Data_Tree_Node $node, $mediaUrl, $baseUrl)
 {
     $result = array();
     $thumbnail = '';
     try {
         $thumbImg = $node->getThumbnail();
         if ($thumbImg != null) {
             $thumbnail = $mediaUrl . 'catalog/category/' . $node->getThumbnail();
         }
     } catch (Exception $e) {
     }
     $result['category_id'] = $node->getId();
     $result['image'] = $mediaUrl . 'catalog/category/' . $node->getImage();
     $result['thumbnail'] = $thumbnail;
     $result['description'] = strip_tags($node->getDescription());
     $result['parent_id'] = $node->getParentId();
     $result['name'] = $node->getName();
     $result['is_active'] = $node->getIsActive();
     $result['children'] = array();
     if (method_exists('Mage', 'getEdition') && Mage::getEdition() == Mage::EDITION_COMMUNITY) {
         $result['url_path'] = $baseUrl . $node->getData('url_path');
     } else {
         $category = Mage::getModel('catalog/category')->load($node->getId());
         $result['url_path'] = $category->getUrl();
     }
     foreach ($node->getChildren() as $child) {
         $result['children'][] = $this->nodeToArray($child, $mediaUrl, $baseUrl);
     }
     return $result;
 }
Пример #5
0
    public function BuildBranch(Varien_Data_Tree_Node $node)
    {
        $buildString = '<li style="padding-left: 16px;">';
        $buildString .= '<div class="tree-level-' . $node->getLevel() . '">';
        if ($node->getChildrenCount() != 0) {
            $buildString .= '<div class="opener" id="opener' . $node->getId() . '"  OnClick="OpenMe(this)"></div>';
        } else {
            $buildString .= '<div class="child"></div>';
        }
        $buildString .= '
			<input type="checkbox" class="inputcb" id="inputcb' . $node->getId() . '" OnClick="Decide(this)" enabled="false"/>
			<div class="folder"></div>
			<a tabindex="1" href="#" hidefocus="on" id="linkItem"><span unselectable="on" id="extdd-' . $node->getLevel() . '">' . $node->getName() . '</a>
		';
        $buildString .= '</div>';
        if ($node->getChildrenCount() != 0) {
            $buildString .= '<ul id="ToOpen' . $node->getId() . '">';
            foreach ($node->getChildren() as $child) {
                $buildString .= $this->BuildBranch($child);
            }
            $buildString .= '</ul>';
        }
        $buildString .= '</li>';
        return $buildString;
    }
Пример #6
0
 /**
  * Convert node to array with path information.
  * Path information skips the 'Root Catalog' (level=0) and 'Default Category' (level=1) levels.
  *
  * @param Varien_Data_Tree_Node $node
  * @return array
  */
 protected function _nodeToArrayPath(Varien_Data_Tree_Node $node, $parentPath)
 {
     // Only basic category data
     $categories = array();
     $category = array();
     $category['category_id'] = $node->getId();
     $category['parent_id'] = $node->getParentId();
     $category['name'] = $node->getName();
     $category['path'] = !empty($parentPath) && $node->getLevel() > 2 ? $parentPath . '/' . $node->getName() : $node->getName();
     $category['is_active'] = $node->getIsActive();
     $category['position'] = $node->getPosition();
     $category['level'] = $node->getLevel();
     $categories[] = $category;
     foreach ($node->getChildren() as $child) {
         $children = $this->_nodeToArrayPath($child, $category['path']);
         $categories = array_merge($categories, $children);
     }
     return $categories;
 }
Пример #7
0
 /**
  * @param Varien_Data_Tree_Node $node
  * @param array $values
  * @param int $level
  * @return array
  */
 protected function _buildCategoriesValues(Varien_Data_Tree_Node $node, $values, $level = 0)
 {
     ++$level;
     $values[$node->getId()]['value'] = $node->getId();
     $values[$node->getId()]['label'] = str_repeat('--', $level) . $node->getName();
     foreach ($node->getChildren() as $child) {
         $values = $this->_buildCategoriesValues($child, $values, $level);
     }
     return $values;
 }
 public function buildCategoriesMultiselectValues(Varien_Data_Tree_Node $node, $values, $level = 0)
 {
     $nonEscapableNbspChar = html_entity_decode('&#160;', ENT_NOQUOTES, 'UTF-8');
     $level++;
     $values[$node->getId()]['value'] = $node->getId();
     $values[$node->getId()]['label'] = str_repeat($nonEscapableNbspChar, ($level - 1) * 5) . $node->getName();
     foreach ($node->getChildren() as $child) {
         $values = $this->buildCategoriesMultiselectValues($child, $values, $level);
     }
     return $values;
 }
Пример #9
0
 public function buildCategoriesMultiselectValues(Varien_Data_Tree_Node $node, $values, $level = 0)
 {
     $level++;
     if ($level == 3) {
         //we have to show only third level category in drop down
         $values[$node->getId()]['value'] = $node->getId();
         $values[$node->getId()]['label'] = $node->getName();
     }
     foreach ($node->getChildren() as $child) {
         $values = $this->buildCategoriesMultiselectValues($child, $values, $level);
     }
     return $values;
 }
Пример #10
0
 function nodeToArray(Varien_Data_Tree_Node $node)
 {
     $result = array();
     $result['category_id'] = $node->getId();
     $result['parent_id'] = $node->getParentId();
     $result['name'] = $node->getName();
     $result['is_active'] = $node->getIsActive();
     $result['position'] = $node->getPosition();
     $result['level'] = $node->getLevel();
     $result['children'] = array();
     foreach ($node->getChildren() as $child) {
         $result['children'][] = $this->nodeToArray($child);
     }
     return $result;
 }
Пример #11
0
 private function nodeToArray(Varien_Data_Tree_Node $node)
 {
     $result = array();
     $category = Mage::getModel('catalog/category')->load($node->getId());
     if ($category->getAvailableForSupplier() == 1) {
         $result['category_id'] = $node->getId();
         $result['parent_id'] = $node->getParentId();
         $result['name'] = $node->getName();
         $result['is_active'] = $node->getIsActive();
         $result['position'] = $node->getPosition();
         $result['level'] = $node->getLevel();
     }
     $result['children'] = array();
     foreach ($node->getChildren() as $child) {
         $result['children'][] = $this->nodeToArray($child);
     }
     return $result;
 }
Пример #12
0
 /**
  * Convert categories tree to array recursively
  *
  * @param  Varien_Data_Tree_Node $node
  * @return array
  */
 protected function _getNodesArray($node)
 {
     $result = array('id' => (int) $node->getId(), 'parent_id' => (int) $node->getParentId(), 'children_count' => (int) $node->getChildrenCount(), 'is_active' => (bool) $node->getIsActive(), 'name' => $node->getName(), 'level' => (int) $node->getLevel(), 'product_count' => (int) $node->getProductCount());
     if (is_array($this->_allowedCategoryIds) && !in_array($result['id'], $this->_allowedCategoryIds)) {
         $result['disabled'] = true;
     }
     if ($node->hasChildren()) {
         $result['children'] = array();
         foreach ($node->getChildren() as $childNode) {
             $result['children'][] = $this->_getNodesArray($childNode);
         }
     }
     $result['cls'] = ($result['is_active'] ? '' : 'no-') . 'active-category';
     $result['expanded'] = !empty($result['children']);
     return $result;
 }
Пример #13
0
 /**
  * Convert tree node to dropdown option
  *
  * @return array
  */
 protected function _treeNodeToOption(Varien_Data_Tree_Node $node, $without)
 {
     $option = array();
     $option['label'] = $node->getName();
     if ($node->getLevel() < 2) {
         $option['value'] = array();
         foreach ($node->getChildren() as $childNode) {
             if (!in_array($childNode->getId(), $without)) {
                 $option['value'][] = $this->_treeNodeToOption($childNode, $without);
             }
         }
     } else {
         $option['value'] = $node->getId();
     }
     return $option;
 }
Пример #14
0
 protected function _nodeToArray(Varien_Data_Tree_Node $node)
 {
     if (empty($node)) {
         return array();
     }
     $result = $node->debug();
     $result['category_id'] = $node->getId();
     $result['parent_id'] = $node->getParentId();
     $result['name'] = $node->getName();
     $result['is_active'] = $node->getIsActive();
     $result['is_anchor'] = $node->getIsAnchor();
     $result['url_key'] = $node->getUrlKey();
     $result['url'] = $node->getRequestPath();
     $result['position'] = $node->getPosition();
     $result['level'] = $node->getLevel();
     $result['products'] = $node->getProducts();
     $result['children'] = array();
     foreach ($node->getChildren() as $child) {
         $result['children'][] = $this->_nodeToArray($child);
     }
     return $result;
 }