Example #1
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;
    }
Example #2
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;
 }
 /**
  * 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;
 }
Example #5
0
 /**
  * @param Varien_Data_Tree_Node $menuTree
  * @param string                $childrenWrapClass
  *
  * @return string
  */
 protected function _getHtml(Varien_Data_Tree_Node $menuTree, $childrenWrapClass)
 {
     $html = '';
     $counter = 1;
     $children = $menuTree->getChildren();
     $parentLevel = $menuTree->getLevel();
     $childLevel = is_null($parentLevel) ? 0 : $parentLevel + 1;
     $childrenCount = $children->count();
     $parentPositionClass = $menuTree->getPositionClass();
     $itemPositionClassPrefix = $parentPositionClass ? $parentPositionClass . '-' : 'nav-';
     foreach ($children as $child) {
         $child->setLevel($childLevel);
         $child->setIsFirst($counter == 1);
         $child->setIsLast($counter == $childrenCount);
         $child->setPositionClass($itemPositionClassPrefix . $counter);
         $outermostClassCode = '';
         $outermostClass = $menuTree->getOutermostClass();
         if ($childLevel == 0 && $outermostClass) {
             $outermostClassCode = ' class="' . $outermostClass . '" ';
             $child->setClass($outermostClass);
         }
         $blockName = $childLevel == 0 ? 'bennoislost.easy-navigation.renderer.with-children' : 'bennoislost.easy-navigation.renderer.single';
         $html .= $this->_renderBlockItem($blockName, $childrenWrapClass, $child, $outermostClassCode);
         $counter++;
     }
     return $html;
 }
Example #6
0
 /**
  * {@inheritDoc}
  */
 protected function _getHtml(Varien_Data_Tree_Node $menuTree, $childrenWrapClass)
 {
     $html = '';
     $children = $menuTree->getChildren();
     $parentLevel = $menuTree->getLevel();
     $childLevel = is_null($parentLevel) ? 0 : $parentLevel + 1;
     $counter = 1;
     $childrenCount = $children->count();
     $parentPositionClass = $menuTree->getPositionClass();
     $itemPositionClassPrefix = $parentPositionClass ? $parentPositionClass . '-' : 'nav-';
     foreach ($children as $child) {
         $child->setLevel($childLevel);
         $child->setIsFirst($counter == 1);
         $child->setIsLast($counter == $childrenCount);
         $child->setPositionClass($itemPositionClassPrefix . $counter);
         $outermostClassCode = '';
         $outermostClass = $menuTree->getOutermostClass();
         if ($childLevel == 0 && $outermostClass) {
             $outermostClassCode = ' class="' . $outermostClass . '" ';
             $child->setClass($outermostClass);
         }
         if ($child->hasChildren()) {
             $outermostClassCode .= ' data-toggle="dropdown" ';
         }
         $html .= '<li ' . $this->_getRenderedMenuItemAttributes($child) . '>';
         $html .= '<a href="' . $child->getUrl() . '" ' . $outermostClassCode . '><span>';
         $html .= $this->escapeHtml($child->getName());
         if ($child->hasChildren()) {
             $html .= ' <b class="caret"></b>';
         }
         $html .= '</span></a>';
         if ($child->hasChildren()) {
             if (!empty($childrenWrapClass)) {
                 $html .= '<div class="' . $childrenWrapClass . '">';
             }
             $html .= '<ul class="level' . $childLevel . ' dropdown-menu">';
             if (Mage::getStoreConfig('catalog/navigation/top_in_dropdown') && $childLevel == 0) {
                 $prefix = Mage::getStoreConfig('catalog/navigation/top_in_dropdown_prefix');
                 $suffix = Mage::getStoreConfig('catalog/navigation/top_in_dropdown_suffix');
                 $html .= '<li class="level1 level-top-in-dropdown">';
                 $html .= '<a href="' . $child->getUrl() . '"><span>';
                 $html .= $this->escapeHtml($this->__($prefix) . ' ' . $child->getName() . ' ' . $suffix);
                 $html .= '</span></a>';
                 $html .= '</li>';
                 $html .= '<li class="divider"></li>';
             }
             $html .= $this->_getHtml($child, $childrenWrapClass);
             $html .= '</ul>';
             if (!empty($childrenWrapClass)) {
                 $html .= '</div>';
             }
         }
         $html .= '</li>';
         $counter++;
     }
     return $html;
 }
Example #7
0
 public function buildCategoriesMultiselectValues(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->buildCategoriesMultiselectValues($child, $values, $level);
     }
     return $values;
 }
Example #8
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;
 }
Example #10
0
 /**
  * Recursively generates top menu html from data that is specified in $menuTree
  *
  * @param Varien_Data_Tree_Node $menuTree
  * @param string $childrenWrapClass
  * @return string
  */
 protected function _getHtml(Varien_Data_Tree_Node $menuTree, $childrenWrapClass)
 {
     $html = '';
     $children = $menuTree->getChildren();
     $parentLevel = $menuTree->getLevel();
     $childLevel = is_null($parentLevel) ? 0 : $parentLevel + 1;
     $counter = 1;
     $childrenCount = $children->count();
     $parentPositionClass = $menuTree->getPositionClass();
     $itemPositionClassPrefix = $parentPositionClass ? $parentPositionClass . '-' : 'nav-';
     $brandCategoryId = Mage::getStoreConfig('brand/brand/category_id');
     $_helperBrands = Mage::helper('brand');
     $brandUrl = Mage::getUrl($_helperBrands->getBrandsUrl());
     foreach ($children as $child) {
         $child->setLevel($childLevel);
         $child->setIsFirst($counter == 1);
         $child->setIsLast($counter == $childrenCount);
         $child->setPositionClass($itemPositionClassPrefix . $counter);
         $outermostClassCode = '';
         $outermostClass = $menuTree->getOutermostClass();
         if ($childLevel == 0 && $outermostClass) {
             $outermostClassCode = ' class="' . $outermostClass . '" ';
             $child->setClass($outermostClass);
         }
         $html .= '<li ' . $this->_getRenderedMenuItemAttributes($child) . '>';
         $categoryId = str_replace("category-node-", "", $child->getId());
         //$url=($categoryId==$brandCategoryId)?$brandUrl:$child->getUrl();
         $url = $child->getUrl();
         $html .= '<a href="' . $url . '" ' . $outermostClassCode . '><span>' . $this->escapeHtml($child->getName()) . '</span></a>';
         if ($child->hasChildren()) {
             if (!empty($childrenWrapClass)) {
                 $html .= '<div class="' . $childrenWrapClass . '">';
             }
             $html .= '<ul class="level' . $childLevel . '">';
             /*if($childLevel==0)
              	{
                	 $html .= '<div class="submenu">';
              	}*/
             $html .= $this->_getHtml($child, $childrenWrapClass);
             /*if($childLevel==0)
               {
                 $html .= '</div>';
               }*/
             $html .= '</ul>';
             if (!empty($childrenWrapClass)) {
                 $html .= '</div>';
             }
         }
         $html .= '</li>';
         $counter++;
     }
     return $html;
 }
Example #11
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;
 }
Example #12
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;
 }
 /**
  * Recursively generates top menu html from data that is specified in $menuTree
  *
  * @param Varien_Data_Tree_Node $menuTree
  * @param string $childrenWrapClass
  * @return string
  */
 protected function _getHtml(Varien_Data_Tree_Node $menuTree, $childrenWrapClass)
 {
     $html = '';
     $children = $menuTree->getChildren();
     $parentLevel = $menuTree->getLevel();
     $childLevel = is_null($parentLevel) ? 0 : $parentLevel + 1;
     $counter = 1;
     $childrenCount = $children->count();
     $parentPositionClass = $menuTree->getPositionClass();
     $itemPositionClassPrefix = $parentPositionClass ? $parentPositionClass . '-' : 'nav-';
     foreach ($children as $child) {
         $child->setLevel($childLevel);
         $child->setIsFirst($counter == 1);
         $child->setIsLast($counter == $childrenCount);
         $child->setPositionClass($itemPositionClassPrefix . $counter);
         $outermostClassCode = '';
         $outermostClass = $menuTree->getOutermostClass();
         if ($childLevel == 0 && $outermostClass) {
             if ($child->hasChildren()) {
                 $outermostClassCode = ' class="' . $outermostClass . ' dropdown-toggle" data-toggle="dropdown" ';
                 $child->setClass($outermostClass);
             } else {
                 $outermostClassCode = ' class="' . $outermostClass . '" ';
                 $child->setClass($outermostClass);
             }
         }
         $arrow = '';
         if ($child->hasChildren()) {
             $arrow = '<b class="caret"></b>';
         }
         $html .= '<li ' . $this->_getRenderedMenuItemAttributes($child) . '>';
         $html .= '<a href="' . $child->getUrl() . '" ' . $outermostClassCode . '><span>' . $this->escapeHtml($child->getName()) . ' ' . $arrow . '</span></a>';
         if ($child->hasChildren()) {
             if (!empty($childrenWrapClass)) {
                 $html .= '<div class="' . $childrenWrapClass . '">';
             }
             $html .= '<ul class="level' . $childLevel . ' dropdown-menu">';
             $html .= $this->_getHtml($child, $childrenWrapClass);
             $html .= '</ul>';
             if (!empty($childrenWrapClass)) {
                 $html .= '</div>';
             }
         }
         $html .= '</li>';
         $counter++;
     }
     return $html;
 }
 /**
  * Recursively adds cms pages to top menu
  *
  * @param Varien_Data_Tree_Node $parentNode
  * @param Mage_Page_Block_Html_Topmenu $menuBlock
  * @param bool $addTags
  */
 protected function _addHomePageToMenu($parentNode, $menuBlock, $addTags = false)
 {
     $tree = $parentNode->getTree();
     $request = Mage::app()->getRequest();
     $isActive = $request->getModuleName() == 'cms' && $request->getControllerName() == 'index' && $request->getActionName() == 'index';
     $pageId = Mage::getStoreConfig(Mage_Cms_Helper_Page::XML_PATH_HOME_PAGE);
     $nodeData = array('name' => $menuBlock->__('Home'), 'id' => 'cms-node-' . $pageId, 'url' => Mage::getBaseUrl(), 'is_active' => $isActive);
     $categoryNode = new Varien_Data_Tree_Node($nodeData, 'id', $tree, $parentNode);
     $currentItems = array();
     foreach ($parentNode->getChildren() as $child) {
         $currentItems[] = $child;
         $parentNode->removeChild($child);
     }
     $parentNode->addChild($categoryNode);
     foreach ($currentItems as $child) {
         $parentNode->addChild($child);
     }
 }
Example #15
0
 protected function _getHtml(Varien_Data_Tree_Node $menuTree, $childrenWrapClass)
 {
     $html = '';
     $children = $menuTree->getChildren();
     $parentLevel = $menuTree->getLevel();
     $childLevel = is_null($parentLevel) ? 0 : $parentLevel + 1;
     $counter = 1;
     $childrenCount = $children->count();
     $parentPositionClass = $menuTree->getPositionClass();
     $itemPositionClassPrefix = $parentPositionClass ? $parentPositionClass . '-' : 'nav-';
     foreach ($children as $child) {
         $categoryId = str_replace('category-node-', '', $child->getId());
         $category = Mage::getModel('catalog/category')->load($categoryId);
         if (!$category->getTopMenu()) {
             continue;
         }
         $child->setLevel($childLevel);
         $child->setIsFirst($counter == 1);
         $child->setIsLast($counter == $childrenCount);
         $child->setPositionClass($itemPositionClassPrefix . $counter);
         $outermostClassCode = '';
         $outermostClass = $menuTree->getOutermostClass();
         if ($childLevel == 0 && $outermostClass) {
             $outermostClassCode = ' class="' . $outermostClass . '" ';
             $child->setClass($outermostClass);
         }
         $html .= '<li ' . $this->_getRenderedMenuItemAttributes($child) . '>';
         $html .= '<a href="' . $child->getUrl() . '" ' . $outermostClassCode . '><span>' . $this->escapeHtml($child->getName()) . '</span></a>';
         if ($child->hasChildren()) {
             if (!empty($childrenWrapClass)) {
                 $html .= '<div class="' . $childrenWrapClass . '">';
             }
             $html .= '<ul class="level' . $childLevel . '">';
             $html .= $this->_getHtml($child, $childrenWrapClass);
             $html .= '</ul>';
             if (!empty($childrenWrapClass)) {
                 $html .= '</div>';
             }
         }
         $html .= '</li>';
         $counter++;
     }
     return $html;
 }
Example #16
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;
 }
Example #17
0
 protected function _getHtml(Varien_Data_Tree_Node $menuTree, $childrenWrapClass)
 {
     Mage::log('hi1', null, 'nil.log');
     $html = '';
     $children = $menuTree->getChildren();
     $parentLevel = $menuTree->getLevel();
     $childLevel = is_null($parentLevel) ? 0 : $parentLevel + 1;
     $counter = 1;
     $childrenCount = $children->count();
     $parentPositionClass = $menuTree->getPositionClass();
     $itemPositionClassPrefix = $parentPositionClass ? $parentPositionClass . '-' : 'nav-';
     foreach ($children as $child) {
         $child->setLevel($childLevel);
         $child->setIsFirst($counter == 1);
         $child->setIsLast($counter == $childrenCount);
         $child->setPositionClass($itemPositionClassPrefix . $counter);
         $outermostClassCode = '';
         $outermostClass = $menuTree->getOutermostClass();
         if ($childLevel == 0 && $outermostClass) {
             $outermostClassCode = ' class="' . $outermostClass . ($child->hasChildren() ? ' dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false" ' : '"');
             $child->setClass($outermostClass);
         }
         $html .= '<li ' . $this->_getRenderedMenuItemAttributes($child) . '>';
         $html .= '<a href="' . $child->getUrl() . '" ' . $outermostClassCode . $dataDropdown . '><span>' . $this->escapeHtml($child->getName()) . '</span></a>';
         if ($child->hasChildren()) {
             if (!empty($childrenWrapClass)) {
                 $html .= '<div class="' . $childrenWrapClass . '">';
             }
             if ($childLevel < 1) {
                 $html .= '<ul class="level' . $childLevel . ' dropdown-menu">';
                 $html .= $this->_getHtml($child, $childrenWrapClass);
                 $html .= '</ul>';
             }
             if (!empty($childrenWrapClass)) {
                 $html .= '</div>';
             }
         }
         $html .= '</li>';
         $counter++;
     }
     return $html;
 }
Example #18
0
 protected function _getHtml(Varien_Data_Tree_Node $menuTree, $childrenWrapClass)
 {
     $html = '';
     $children = $menuTree->getChildren();
     foreach ($children as $child) {
         $menu_class = "";
         if ($child->hasChildren()) {
             $menu_class = "has-submenu";
         }
         $html .= '<li class="' . $menu_class . '"">';
         $html .= '<a href="' . $child->getUrl() . '"><span>' . $this->escapeHtml($child->getName()) . '</span></a>';
         if ($child->hasChildren()) {
             $html .= '<ul class="left-submenu">
                 <li class="back"><a href="#">' . $this->__('Back') . '</a></li>';
             $html .= '<li><a href="' . $child->getUrl() . '">' . $this->__('View All ') . $this->escapeHtml($child->getName()) . '</a></li>';
             $html .= $this->_getHtml($child, $childrenWrapClass);
             $html .= '</ul>';
         }
         $html .= '</li>';
     }
     return $html;
 }
Example #19
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;
 }
Example #20
0
 /**
  * Recursively generates top menu html from data that is specified in $menuTree
  *
  * @param Varien_Data_Tree_Node $menuTree
  * @param string $childrenWrapClass
  * @return string
  */
 protected function _getHtml(Varien_Data_Tree_Node $menuTree, $childrenWrapClass)
 {
     $html = '';
     $children = $menuTree->getChildren();
     $parentLevel = $menuTree->getLevel();
     $childLevel = is_null($parentLevel) ? 0 : $parentLevel + 1;
     $counter = 1;
     $childrenCount = $children->count();
     $parentPositionClass = $menuTree->getPositionClass();
     $itemPositionClassPrefix = $parentPositionClass ? $parentPositionClass . '-' : 'nav-';
     foreach ($children as $child) {
         $childClass = '';
         $child->setLevel($childLevel);
         $child->setIsFirst($counter == 1);
         $child->setIsLast($counter == $childrenCount);
         $child->setPositionClass($itemPositionClassPrefix . $counter);
         $outermostClassCode = '';
         $outermostClass = $menuTree->getOutermostClass();
         $megamenuData = array('type' => '', 'layout' => 'menu', 'menu' => 1, 'top' => '', 'bottom' => '', 'right' => '', 'percent' => 0);
         if ($childLevel == 0) {
             if ($outermostClass) {
                 $childClass .= ' ' . $outermostClass;
             }
             $category = Mage::getModel('catalog/category')->load(str_replace('category-node-', '', $child->getId()));
             $childClass .= ' ' . $category->getOlegnaxmegamenuType();
             $megamenuData['type'] = $category->getOlegnaxmegamenuType();
             $megamenuData['layout'] = $category->getOlegnaxmegamenuLayout();
             $megamenuData['menu'] = $category->getOlegnaxmegamenuMenu();
             $megamenuData['top'] = $category->getOlegnaxmegamenuTop();
             $megamenuData['bottom'] = $category->getOlegnaxmegamenuBottom();
             $megamenuData['right'] = $category->getOlegnaxmegamenuRight();
             $megamenuData['percent'] = $category->getOlegnaxmegamenuRightPercent();
             if ($megamenuData['menu'] == '') {
                 $megamenuData['menu'] = 1;
             }
             if ($megamenuData['percent'] == '') {
                 $megamenuData['percent'] = 0;
             }
             if (empty($megamenuData['layout'])) {
                 $megamenuData['layout'] = 'menu';
             }
         }
         $showChildren = false;
         $leftClass = $rightClass = $top = $bottom = $right = $menu = '';
         if ($child->hasChildren() || $childLevel == 0 && $megamenuData['type'] == 'wide' && (!empty($megamenuData['top']) || !empty($megamenuData['bottom']) || !empty($megamenuData['right']) && $megamenuData['percent'] != 0)) {
             $showChildren = true;
             if ($megamenuData['type'] == 'wide') {
                 $leftClass = 'megamenu-block-col-' . (6 - $megamenuData['percent']);
                 $rightClass = 'megamenu-block-col-' . $megamenuData['percent'];
                 $top = $this->_drawMenuBlock('top', $megamenuData['top']);
                 $bottom = $this->_drawMenuBlock('bottom', $megamenuData['bottom']);
                 $right = $this->_drawMenuBlock('right', $megamenuData['right']);
             }
             if ($megamenuData['menu'] == 1 || $megamenuData['type'] != 'wide') {
                 $menu .= '<ul class="level' . $childLevel . '">';
                 $menu .= $this->_getHtml($child, $childrenWrapClass);
                 $menu .= '</ul>';
                 $menu .= '<div class="clear"></div>';
             }
             if (!$child->hasChildren() || $megamenuData['menu'] != 1) {
                 $childClass .= ' parent parent-fake';
             }
         }
         $child->setClass($childClass);
         $html .= '<li ' . $this->_getRenderedMenuItemAttributes($child) . '>';
         $html .= '<a href="' . $child->getUrl() . '" ' . $outermostClassCode . '><span>' . $this->escapeHtml($child->getName()) . '</span></a>';
         if ($showChildren) {
             if (!empty($childrenWrapClass)) {
                 $html .= '<div class="' . $childrenWrapClass . '">';
             }
             if ($childLevel == 0 && $megamenuData['type'] == 'wide') {
                 switch ($megamenuData['layout']) {
                     case 'top_menu':
                         $html .= '<div class="megamenu-block-col ' . $leftClass . '">';
                         $html .= $top;
                         $html .= $menu;
                         $html .= '</div>';
                         $html .= '<div class="megamenu-block-col ' . $rightClass . '">';
                         $html .= $right;
                         $html .= '</div>';
                         $html .= '<div class="clear"></div>';
                         $html .= $bottom;
                         break;
                     case 'top_menu_bottom':
                         $html .= '<div class="megamenu-block-col ' . $leftClass . '">';
                         $html .= $top;
                         $html .= $menu;
                         $html .= $bottom;
                         $html .= '</div>';
                         $html .= '<div class="megamenu-block-col ' . $rightClass . '">';
                         $html .= $right;
                         $html .= '</div>';
                         $html .= '<div class="clear"></div>';
                         break;
                     case 'menu':
                     default:
                         $html .= $top;
                         $html .= '<div class="megamenu-block-col ' . $leftClass . '">';
                         $html .= $menu;
                         $html .= '</div>';
                         $html .= '<div class="megamenu-block-col ' . $rightClass . '">';
                         $html .= $right;
                         $html .= '</div>';
                         $html .= '<div class="clear"></div>';
                         $html .= $bottom;
                 }
             } else {
                 $html .= $menu;
             }
             if (!empty($childrenWrapClass)) {
                 $html .= '</div>';
             }
         }
         $html .= '</li>';
         $counter++;
     }
     return $html;
 }
Example #21
0
 protected function _getHtml(Varien_Data_Tree_Node $menuTree, $childrenWrapClass)
 {
     $html = '';
     $children = $menuTree->getChildren();
     $parentLevel = $menuTree->getLevel();
     $childLevel = is_null($parentLevel) ? 0 : $parentLevel + 1;
     $counter = 1;
     $childrenCount = $children->count();
     $parentPositionClass = $menuTree->getPositionClass();
     $itemPositionClassPrefix = $parentPositionClass ? $parentPositionClass . '-' : 'nav-';
     foreach ($children as $child) {
         $catId = explode("category-node-", $child->getId());
         $categoryComplete = Mage::getModel('catalog/category')->load($catId[1]);
         $iconCode = Mage::getResourceModel('catalog/category')->getAttributeRawValue($catId[1], "meigee_cat_icon", Mage::app()->getStore()->getId());
         if ($iconCode and $childLevel <= 1) {
             $icon = '<i class="fa fa-' . $iconCode . ' custom-icon"></i>';
         } else {
             $icon = '';
         }
         $catLabel = '';
         if ($categoryComplete->getMeigeeCatCustomlabel()) {
             $catLabel = '<em class="category-label ' . $categoryComplete->getMeigeeCatCustomlabel() . '">' . $categoryComplete->getMeigeeCatLabeltext() . '</em>';
         }
         if (Mage::getStoreConfig('meigee_categoriesenhanced/options/status') and $categoryComplete->getMeigeeCatMenutype() != 1) {
             $childrenWrapClass = 'menu-wrapper';
             if ($categoryComplete->getMeigeeCatCustomlink()) {
                 if ($categoryComplete->getMeigeeCatCustomlink() == '/') {
                     $itemUrl = Mage::getBaseUrl();
                 } elseif ($categoryComplete->getMeigeeCatCustomlink() == '#') {
                     $itemUrl = '#';
                 } else {
                     $itemUrl = $categoryComplete->getMeigeeCatCustomlink();
                 }
             } else {
                 $itemUrl = $child->getUrl();
             }
             // Get ratio value
             $ratio = explode("/", $categoryComplete->getMeigeeCatRatio());
             $child->setLevel($childLevel);
             $child->setIsFirst($counter == 1);
             $child->setIsLast($counter == $childrenCount);
             $child->setPositionClass($itemPositionClassPrefix . $counter);
             $outermostClassCode = '';
             $outermostClass = $menuTree->getOutermostClass();
             if ($childLevel == 0 && $outermostClass) {
                 $outermostClassCode = ' class="' . $outermostClass . '" ';
                 $child->setClass($outermostClass);
             }
             if ($childLevel == 1) {
                 $html .= '<li class="level1">';
             } else {
                 $html .= '<li ' . $this->_getRenderedMenuItemAttributes($child) . '>';
             }
             $subTitle = '';
             if ($childLevel == 1) {
                 $subTitle = ' class="subtitle"';
             }
             if ($categoryComplete->getMeigeeCatBlockTop() && $childLevel > 0) {
                 $html .= '<div class="top-content">' . $this->helper('cms')->getBlockTemplateProcessor()->filter($categoryComplete->getMeigeeCatBlockTop()) . '</div><div class="clear"></div>';
             }
             if (!$categoryComplete->getMeigeeCatSubcontent()) {
                 $html .= '<a href="' . $itemUrl . '" ' . $outermostClassCode . ($categoryComplete->getMeigeeCatLinktarget() ? ' target="_blank"' : '') . '>' . $icon . '<span' . $subTitle . '>' . $this->escapeHtml($child->getName()) . '</span>' . $catLabel . '</a>';
             } elseif ($categoryComplete->getMeigeeCatSubcontent() && $childLevel == 0) {
                 $html .= '<a href="' . $itemUrl . '" ' . $outermostClassCode . ($categoryComplete->getMeigeeCatLinktarget() ? ' target="_blank"' : '') . '>' . $icon . '<span' . $subTitle . '>' . $this->escapeHtml($child->getName()) . '</span>' . $catLabel . '</a>';
             }
             if ($child->hasChildren()) {
                 if (!empty($childrenWrapClass) && $childLevel == 0) {
                     if ($categoryComplete->getMeigeeCatMaxQuantity() and is_numeric($categoryComplete->getMeigeeCatMaxQuantity())) {
                         $columnsCount = $categoryComplete->getMeigeeCatMaxQuantity();
                     } else {
                         $columnsCount = Mage::getStoreConfig('meigee_categoriesenhanced/options/column_count');
                     }
                     $columnsCount = ' data-columns="' . $columnsCount . '"';
                     $categoryBg = '';
                     if ($categoryComplete->getMeigeeCatBg()) {
                         $categoryBgOption = $categoryComplete->getMeigeeCatBgOption();
                         switch ($categoryBgOption) {
                             case "1":
                                 $categoryBgOption = "background-position: left 0;";
                                 break;
                             case "2":
                                 $categoryBgOption = "background-position: right 0;";
                                 break;
                             case "3":
                                 $categoryBgOption = "background-position: center 0;";
                                 break;
                             case "4":
                                 $categoryBgOption = "background-size: 100% 100%;";
                                 break;
                             default:
                                 $categoryBgOption = "background-position: left 0;";
                         }
                         $retinaBg = $categoryComplete->getMeigeeCatBgRetina();
                         if ($retinaBg) {
                             $retinaBg = ' dataX2="background-image:url(' . Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'catalog/category/' . $categoryComplete->getMeigeeCatBgRetina() . '); ' . $categoryBgOption . '"';
                         }
                         $categoryBg = ' style="background-image:url(' . Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'catalog/category/' . $categoryComplete->getMeigeeCatBg() . '); ' . $categoryBgOption . '"' . $retinaBg;
                     }
                     $html .= '<div class="' . $childrenWrapClass . '"' . $columnsCount . $categoryBg . '>';
                 }
                 if ($categoryComplete->getMeigeeCatSubcontent()) {
                     $html .= '<div class="sub-content">' . $this->helper('cms')->getBlockTemplateProcessor()->filter($categoryComplete->getMeigeeCatSubcontent()) . '</div>';
                 } else {
                     if ($categoryComplete->getMeigeeCatBlockTop() && $childLevel == 0) {
                         $html .= '<div class="top-content">' . $this->helper('cms')->getBlockTemplateProcessor()->filter($categoryComplete->getMeigeeCatBlockTop()) . '</div><div class="clear"></div>';
                     }
                     if ($categoryComplete->getMeigeeCatBlockRight() && $childLevel == 0) {
                         $html .= '<div class="row"><div class="col-md-' . $ratio[0] . '">';
                     }
                     $html .= '<ul class="level' . $childLevel . '">';
                     $html .= $this->_getHtml($child, $childrenWrapClass);
                     $html .= '</ul>';
                     if (!empty($childrenWrapClass) && $childLevel == 0) {
                         if ($categoryComplete->getMeigeeCatBlockRight()) {
                             $html .= '</div>';
                             $html .= '<div class="col-md-' . $ratio[1] . ' right-content">' . $this->helper('cms')->getBlockTemplateProcessor()->filter($categoryComplete->getMeigeeCatBlockRight()) . '</div></div>';
                         }
                         $html .= '<div class="clear"></div>';
                     }
                     if ($categoryComplete->getMeigeeCatBlockBottom() && $childLevel == 0) {
                         $html .= '<div class="bottom-content">' . $this->helper('cms')->getBlockTemplateProcessor()->filter($categoryComplete->getMeigeeCatBlockBottom()) . '</div><div class="clear"></div>';
                     }
                 }
                 if (!empty($childrenWrapClass) && $childLevel == 0) {
                     $html .= '<div class="transparent"></div></div>';
                 }
             }
             if ($categoryComplete->getMeigeeCatBlockBottom() && $childLevel > 0) {
                 $html .= '<div class="bottom-content">' . $this->helper('cms')->getBlockTemplateProcessor()->filter($categoryComplete->getMeigeeCatBlockBottom()) . '</div><div class="clear"></div>';
             }
             $html .= '</li>';
             $counter++;
         } else {
             if ($categoryComplete->getMeigeeCatCustomlink()) {
                 if ($categoryComplete->getMeigeeCatCustomlink() == '/') {
                     $itemUrl = Mage::getBaseUrl();
                 }
                 if ($categoryComplete->getMeigeeCatCustomlink() == '#') {
                     $itemUrl = '#';
                 } else {
                     $itemUrl = $categoryComplete->getMeigeeCatCustomlink();
                 }
             } else {
                 $itemUrl = $child->getUrl();
             }
             $child->setLevel($childLevel);
             $child->setIsFirst($counter == 1);
             $child->setIsLast($counter == $childrenCount);
             $child->setPositionClass($itemPositionClassPrefix . $counter);
             $outermostClassCode = '';
             $outermostClass = $menuTree->getOutermostClass();
             if ($childLevel == 0 && $outermostClass) {
                 $outermostClassCode = ' class="' . $outermostClass . '" ';
                 $child->setClass($outermostClass);
             }
             if (!Mage::getStoreConfig('meigee_categoriesenhanced/options/status')) {
                 $catLabel = '';
             }
             $html .= '<li ' . $this->_getRenderedMenuItemAttributes($child) . '>';
             $html .= '<a href="' . $itemUrl . '" ' . $outermostClassCode . '>' . $icon . '<span>' . $this->escapeHtml($child->getName()) . '</span>' . $catLabel . '</a>';
             if ($child->hasChildren()) {
                 if (empty($childrenWrapClass) and Mage::getStoreConfig('meigee_categoriesenhanced/options/status')) {
                     $childrenWrapClass = 'menu-wrapper';
                 }
                 if (!empty($childrenWrapClass)) {
                     $isDefaultMenu = '';
                     if ($categoryComplete->getMeigeeCatMenutype() == 1) {
                         $isDefaultMenu = ' default-menu';
                     }
                     $html .= '<div class="' . $childrenWrapClass . $isDefaultMenu . '">';
                 }
                 $html .= '<ul class="level' . $childLevel . '">';
                 $html .= $this->_getHtml($child, $childrenWrapClass);
                 $html .= '</ul>';
                 if (!empty($childrenWrapClass)) {
                     $html .= '<div class="transparent"></div></div>';
                 }
             }
             $html .= '</li>';
             $counter++;
         }
     }
     return $html;
 }
Example #22
0
 /**
  * Recursively generates top menu html from data that is specified in $menuTree
  *
  * @param Varien_Data_Tree_Node $menuTree
  * @param string $childrenWrapClass
  * @return string
  * @deprecated since 1.8.2.0 use child block catalog.topnav.renderer instead
  */
 protected function _getHtml(Varien_Data_Tree_Node $menuTree, $childrenWrapClass)
 {
     $html = '';
     $children = $menuTree->getChildren();
     $parentLevel = $menuTree->getLevel();
     $childLevel = is_null($parentLevel) ? 0 : $parentLevel + 1;
     $counter = 1;
     $childrenCount = $children->count();
     $parentPositionClass = $menuTree->getPositionClass();
     $itemPositionClassPrefix = $parentPositionClass ? $parentPositionClass . ' item-' : 'nav-';
     foreach ($children as $child) {
         $child->setLevel($childLevel);
         //$child->setIsFirst($counter == 1);
         //$child->setIsLast($counter == $childrenCount);
         $child->setPositionClass($itemPositionClassPrefix . $counter);
         $outermostClassCode = '';
         $outermostClass = $menuTree->getOutermostClass();
         /*
                     if ($childLevel == 0 && $outermostClass) {
                         $outermostClassCode = ' class="' . $outermostClass . '" ';
                         $child->setClass($outermostClass);
                     }
         */
         $html .= '<li ' . $this->_getRenderedMenuItemAttributes($child) . '>';
         $html .= '<a href="' . $child->getUrl() . '" title="' . $this->escapeHtml($child->getName()) . '">' . $this->escapeHtml($child->getName()) . '</a>';
         if ($child->hasChildren()) {
             if (!empty($childrenWrapClass)) {
                 $html .= '<div class="' . $childrenWrapClass . '">';
             }
             $html .= '<ul class="clearer">';
             // E-Liquids
             if ($child->getId() == 'category-node-3') {
                 if ($child->hasChildren()) {
                     $html .= 'www' . $counter;
                 }
                 var_dump(count($child->getChildren()));
                 die;
                 if ($counter <= 3) {
                     $html .= '<ul>';
                     $html .= '<li ' . $this->_getRenderedMenuItemAttributes($child) . '>';
                     $html .= '<a href="' . $child->getUrl() . '" title="' . $this->escapeHtml($child->getName()) . '">' . $this->escapeHtml($child->getName()) . '</a>';
                     //$html .= $this->_getHtml($child, $childrenWrapClass);
                     $html .= '</ul>';
                 }
             } elseif ($child->getId() == 4) {
             } else {
                 $html .= $this->_getHtml($child, $childrenWrapClass);
             }
             $html .= '</ul>';
             if (!empty($childrenWrapClass)) {
                 $html .= '</div>';
             }
         }
         $html .= '</li>';
         $counter++;
     }
     return $html;
 }
Example #23
0
 protected function _getHtml(Varien_Data_Tree_Node $menuTree, $childrenWrapClass = null)
 {
     $css = '';
     $children = $menuTree->getChildren();
     $parentLevel = $menuTree->getLevel();
     $childLevel = is_null($parentLevel) ? 0 : $parentLevel + 1;
     $counter = 1;
     $childrenCount = $children->count();
     $parentPositionClass = $menuTree->getPositionClass();
     $itemPositionClassPrefix = $parentPositionClass ? $parentPositionClass . '-' : 'nav-';
     foreach ($children as $child) {
         $child->setLevel($childLevel);
         $child->setIsFirst($counter == 1);
         $child->setIsLast($counter == $childrenCount);
         $child->setPositionClass($itemPositionClassPrefix . $counter);
         if ($child->getId() == 'home-link') {
             ++$counter;
             continue;
         }
         if ($child->getHeaderBgColor()) {
             $css .= "li.{$child->getPositionClass()} {\n";
             $css .= "    background-color: {$child->getHeaderBgColor()} !important;\n";
             $css .= "}\n";
         }
         if ($child->getHeaderBgHoverColor()) {
             $css .= "li.{$child->getPositionClass()}:hover {\n";
             $css .= "    background-color: {$child->getHeaderBgHoverColor()} !important;\n";
             $css .= "}\n";
         }
         $css .= "#wpmm-nav li.{$child->getPositionClass()} > a {\n";
         if ($child->getTitleColor()) {
             $css .= "    color: {$child->getTitleColor()} !important;\n";
         }
         $css .= "}\n";
         if ($child->getTitleHoverColor()) {
             $css .= "#wpmm-nav li.{$child->getPositionClass()} > a:hover {\n";
             $css .= "    color: {$child->getTitleHoverColor()} !important;\n";
             $css .= "}\n";
         }
         if ($child->getLevel() == 0) {
             $css .= "li.{$child->getPositionClass()} > .wpmm-nav-content {\n";
             if ($child->getContentBgColor()) {
                 $css .= "    background-color: {$child->getContentBgColor()} !important;\n";
             }
             if ($child->getContentBgImage()) {
                 $css .= "    background-image: url({$child->getContentBgImage()}) !important;\n";
             }
             switch ($child->getContentBgImgDm()) {
                 case WeltPixel_MegaMenu_Model_Category_Attribute_Source_Display::REPEAT:
                     $css .= "    background-repeat: repeat;\n";
                     break;
                 case WeltPixel_MegaMenu_Model_Category_Attribute_Source_Display::STRETCH:
                     $css .= "    background-size: cover;\n";
                     break;
             }
             $css .= "}\n";
         }
         if ($child->hasChildren()) {
             $css .= $this->_getHtml($child);
         }
         ++$counter;
     }
     if ($childLevel == 0) {
         if ($this->getDisplayMode() == WeltPixel_Selector_Model_Adminhtml_System_Config_Displaymode::BOXED) {
             $css .= "#wpmm-nav {\n";
             $css .= "    position: relative;\n";
             $css .= "}\n";
         }
     }
     return $css;
 }
Example #24
0
 /**
  * Recursively generates top menu html from data that is specified in $menuTree
  *
  * @param Varien_Data_Tree_Node $menuTree
  * @param string $childrenWrapClass
  * @return string
  */
 protected function _getHtml(Varien_Data_Tree_Node $menuTree, $childrenWrapClass)
 {
     $html = '';
     $children = $menuTree->getChildren();
     $parentLevel = $menuTree->getLevel();
     $childLevel = is_null($parentLevel) ? 0 : $parentLevel + 1;
     $counter = 1;
     $childrenCount = $children->count();
     $parentPositionClass = $menuTree->getPositionClass();
     $itemPositionClassPrefix = $parentPositionClass ? $parentPositionClass . '-' : 'nav-';
     foreach ($children as $child) {
         $child->setLevel($childLevel);
         $child->setIsFirst($counter == 1);
         $child->setIsLast($counter == $childrenCount);
         $child->setPositionClass($itemPositionClassPrefix . $counter);
         $outermostClassCode = '';
         $outermostClass = $menuTree->getOutermostClass();
         if ($childLevel == 0 && $outermostClass) {
             $outermostClassCode = ' class="' . $outermostClass . '" ';
             $child->setClass($outermostClass);
         }
         $html .= '<li ' . $this->_getRenderedMenuItemAttributes($child) . '>';
         $html .= '<a href="' . $child->getUrl() . '" ' . $outermostClassCode . '><span>' . $this->escapeHtml($child->getName()) . '</span></a>';
         if ($child->hasChildren()) {
             if (!empty($childrenWrapClass)) {
                 $html .= '<div class="' . $childrenWrapClass . '">';
             }
             // GravDept, open .menu wrapper
             if ($childLevel == 0) {
                 $html .= '<div class="menu">';
             }
             $html .= '<ul class="level' . $childLevel . '">';
             $html .= $this->_getHtml($child, $childrenWrapClass);
             $html .= '</ul>';
             // GravDept, add "View All" link for sub-category
             if ($childLevel == 1) {
                 $html .= '<a class="view-all" href="' . $child->getUrl() . '">' . $this->__('View All') . '</a>';
             }
             // GravDept, close .menu wrapper
             if ($childLevel == 0) {
                 $html .= '</div>';
             }
             if (!empty($childrenWrapClass)) {
                 $html .= '</div>';
             }
         }
         $html .= '</li>';
         $counter++;
     }
     return $html;
 }
Example #25
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;
 }
Example #26
0
 /**
  * Recursively generates top menu html from data that is specified in $menuTree
  *
  * @param Varien_Data_Tree_Node $menuTree
  * @param string $childrenWrapClass
  * @return string
  */
 protected function _getHtml(Varien_Data_Tree_Node $menuTree, $childrenWrapClass)
 {
     if (Mage::getStoreConfig('mpanel/general/enabled')) {
         $html = '';
         $children = $menuTree->getChildren();
         $parentLevel = $menuTree->getLevel();
         $childLevel = is_null($parentLevel) ? 0 : $parentLevel + 1;
         $counter = 1;
         $childrenCount = $children->count();
         $parentPositionClass = $menuTree->getPositionClass();
         $itemPositionClassPrefix = $parentPositionClass ? $parentPositionClass . '-' : 'nav-';
         foreach ($children as $child) {
             $child->setLevel($childLevel);
             $child->setIsFirst($counter == 1);
             $child->setIsLast($counter == $childrenCount);
             $child->setPositionClass($itemPositionClassPrefix . $counter);
             $outermostClassCode = '';
             $outermostClass = $menuTree->getOutermostClass();
             if ($childLevel == 0 && $outermostClass) {
                 $outermostClassCode = ' class="' . $outermostClass . '" ';
                 $child->setClass($outermostClass);
             }
             $html .= '<li ' . $this->_getRenderedMenuItemAttributes($child) . '>';
             $html .= '<a id="link-mobile-menu-' . $child->getId() . '" href="' . $child->getUrl() . '"';
             if ($child->hasChildren()) {
                 $html .= ' class="dropdown-toggle"';
             }
             $html .= '>' . $this->escapeHtml($child->getName());
             if ($child->hasChildren()) {
                 $html .= ' <i class="fa fa-plus" onclick="mgsjQuery(\'#mobile-menu-' . $child->getId() . '\').slideToggle(); mgsjQuery(\'#link-mobile-menu-' . $child->getId() . '\').toggleClass(\'collapse\'); mgsjQuery(\'#mobile-menu-' . $child->getId() . '\').toggleClass(\'active\'); return false"></i>';
             }
             $html .= '</a>';
             if ($child->hasChildren()) {
                 if (!empty($childrenWrapClass)) {
                     $html .= '<div class="' . $childrenWrapClass . '">';
                 }
                 $html .= '<ul class="dropdown-menu" id="mobile-menu-' . $child->getId() . '">';
                 $html .= $this->_getHtml($child, $childrenWrapClass);
                 $html .= '</ul>';
                 if (!empty($childrenWrapClass)) {
                     $html .= '</div>';
                 }
             }
             $html .= '</li>';
             $counter++;
         }
         return $html;
     } else {
         $html = '';
         $children = $menuTree->getChildren();
         $parentLevel = $menuTree->getLevel();
         $childLevel = is_null($parentLevel) ? 0 : $parentLevel + 1;
         $counter = 1;
         $childrenCount = $children->count();
         $parentPositionClass = $menuTree->getPositionClass();
         $itemPositionClassPrefix = $parentPositionClass ? $parentPositionClass . '-' : 'nav-';
         foreach ($children as $child) {
             $child->setLevel($childLevel);
             $child->setIsFirst($counter == 1);
             $child->setIsLast($counter == $childrenCount);
             $child->setPositionClass($itemPositionClassPrefix . $counter);
             $outermostClassCode = '';
             $outermostClass = $menuTree->getOutermostClass();
             if ($childLevel == 0 && $outermostClass) {
                 $outermostClassCode = ' class="' . $outermostClass . '" ';
                 $child->setClass($outermostClass);
             }
             $html .= '<li ' . $this->_getRenderedMenuItemAttributes($child) . '>';
             $html .= '<a href="' . $child->getUrl() . '" ' . $outermostClassCode . '><span>' . $this->escapeHtml($child->getName()) . '</span></a>';
             if ($child->hasChildren()) {
                 if (!empty($childrenWrapClass)) {
                     $html .= '<div class="' . $childrenWrapClass . '">';
                 }
                 $html .= '<ul class="level' . $childLevel . '">';
                 $html .= $this->_getHtml($child, $childrenWrapClass);
                 $html .= '</ul>';
                 if (!empty($childrenWrapClass)) {
                     $html .= '</div>';
                 }
             }
             $html .= '</li>';
             $counter++;
         }
         return $html;
     }
 }
Example #27
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;
 }
Example #28
0
 protected function _getHtml(Varien_Data_Tree_Node $menuTree, $childrenWrapClass)
 {
     $html = '';
     if (Mage::getStoreConfig('meigee_categoriesenhanced/options/status')) {
         $childrenWrapClass = 'menu-wrapper';
         $children = $menuTree->getChildren();
         $parentLevel = $menuTree->getLevel();
         $childLevel = is_null($parentLevel) ? 0 : $parentLevel + 1;
         $counter = 1;
         $childrenCount = $children->count();
         $parentPositionClass = $menuTree->getPositionClass();
         $itemPositionClassPrefix = $parentPositionClass ? $parentPositionClass . '-' : 'nav-';
         foreach ($children as $child) {
             $catId = explode("category-node-", $child->getId());
             $categoryComplete = Mage::getModel('catalog/category')->load($catId[1]);
             if ($categoryComplete->getMeigeeCatCustomlink()) {
                 if ($categoryComplete->getMeigeeCatCustomlink() == '/') {
                     $itemUrl = Mage::getBaseUrl();
                 } elseif ($categoryComplete->getMeigeeCatCustomlink() == '#') {
                     $itemUrl = '#';
                 } else {
                     $itemUrl = $categoryComplete->getMeigeeCatCustomlink();
                 }
             } else {
                 $itemUrl = $child->getUrl();
             }
             // Get ratio value
             $ratio = explode("/", $categoryComplete->getMeigeeCatRatio());
             $child->setLevel($childLevel);
             $child->setIsFirst($counter == 1);
             $child->setIsLast($counter == $childrenCount);
             $child->setPositionClass($itemPositionClassPrefix . $counter);
             $outermostClassCode = '';
             $outermostClass = $menuTree->getOutermostClass();
             if ($childLevel == 0 && $outermostClass) {
                 $outermostClassCode = ' class="' . $outermostClass . '" ';
                 $child->setClass($outermostClass);
             }
             if ($childLevel == 1) {
                 $html .= '<li class="level1 grid_2 alpha">';
             } else {
                 $html .= '<li ' . $this->_getRenderedMenuItemAttributes($child) . '>';
             }
             $subTitle = '';
             if ($childLevel == 1) {
                 $subTitle = ' class="subtitle"';
             }
             if ($categoryComplete->getMeigeeCatBlockTop() && $childLevel > 0) {
                 $html .= '<div class="top-content">' . $this->helper('cms')->getBlockTemplateProcessor()->filter($categoryComplete->getMeigeeCatBlockTop()) . '</div><div class="clear"></div>';
             }
             if (!$categoryComplete->getMeigeeCatSubcontent()) {
                 $html .= '<a href="' . $itemUrl . '" ' . $outermostClassCode . '><span' . $subTitle . '>' . $this->escapeHtml($child->getName()) . '</span></a>';
             } elseif ($categoryComplete->getMeigeeCatSubcontent() && $childLevel == 0) {
                 $html .= '<a href="' . $itemUrl . '" ' . $outermostClassCode . '><span' . $subTitle . '>' . $this->escapeHtml($child->getName()) . '</span></a>';
             }
             if ($child->hasChildren()) {
                 if (!empty($childrenWrapClass) && $childLevel == 0) {
                     $html .= '<div class="' . $childrenWrapClass . '">';
                 }
                 if ($categoryComplete->getMeigeeCatSubcontent()) {
                     $html .= '<div class="sub-content">' . $this->helper('cms')->getBlockTemplateProcessor()->filter($categoryComplete->getMeigeeCatSubcontent()) . '</div>';
                 } else {
                     if ($categoryComplete->getMeigeeCatBlockTop() && $childLevel == 0) {
                         $html .= '<div class="top-content">' . $this->helper('cms')->getBlockTemplateProcessor()->filter($categoryComplete->getMeigeeCatBlockTop()) . '</div><div class="clear"></div>';
                     }
                     if ($categoryComplete->getMeigeeCatBlockRight()) {
                         $html .= '<div class="grid_' . $ratio[0] . ' alpha omega">';
                     }
                     $html .= '<ul class="level' . $childLevel . '">';
                     $html .= $this->_getHtml($child, $childrenWrapClass);
                     $html .= '</ul>';
                     if (!empty($childrenWrapClass) && $childLevel == 0) {
                         if ($categoryComplete->getMeigeeCatBlockRight()) {
                             $html .= '</div>';
                             $html .= '<div class="grid_' . $ratio[1] . ' alpha omega right-content">' . $this->helper('cms')->getBlockTemplateProcessor()->filter($categoryComplete->getMeigeeCatBlockRight()) . '</div>';
                         }
                         $html .= '<div class="clear"></div>';
                     }
                     if ($categoryComplete->getMeigeeCatBlockBottom()) {
                         $html .= '<div class="bottom-content">' . $this->helper('cms')->getBlockTemplateProcessor()->filter($categoryComplete->getMeigeeCatBlockBottom()) . '</div><div class="clear"></div>';
                     }
                 }
                 if (!empty($childrenWrapClass) && $childLevel == 0) {
                     $html .= '</div>';
                 }
             }
             $html .= '</li>';
             $counter++;
         }
     } else {
         $children = $menuTree->getChildren();
         $parentLevel = $menuTree->getLevel();
         $childLevel = is_null($parentLevel) ? 0 : $parentLevel + 1;
         $counter = 1;
         $childrenCount = $children->count();
         $parentPositionClass = $menuTree->getPositionClass();
         $itemPositionClassPrefix = $parentPositionClass ? $parentPositionClass . '-' : 'nav-';
         foreach ($children as $child) {
             $catId = explode("category-node-", $child->getId());
             $categoryComplete = Mage::getModel('catalog/category')->load($catId[1]);
             if ($categoryComplete->getMeigeeCatCustomlink()) {
                 if ($categoryComplete->getMeigeeCatCustomlink() == '/') {
                     $itemUrl = Mage::getBaseUrl();
                 }
                 if ($categoryComplete->getMeigeeCatCustomlink() == '#') {
                     $itemUrl = '#';
                 } else {
                     $itemUrl = $categoryComplete->getMeigeeCatCustomlink();
                 }
             } else {
                 $itemUrl = $child->getUrl();
             }
             $child->setLevel($childLevel);
             $child->setIsFirst($counter == 1);
             $child->setIsLast($counter == $childrenCount);
             $child->setPositionClass($itemPositionClassPrefix . $counter);
             $outermostClassCode = '';
             $outermostClass = $menuTree->getOutermostClass();
             if ($childLevel == 0 && $outermostClass) {
                 $outermostClassCode = ' class="' . $outermostClass . '" ';
                 $child->setClass($outermostClass);
             }
             $html .= '<li ' . $this->_getRenderedMenuItemAttributes($child) . '>';
             $html .= '<a href="' . $itemUrl . '" ' . $outermostClassCode . '><span>' . $this->escapeHtml($child->getName()) . '</span></a>';
             if ($child->hasChildren()) {
                 if (!empty($childrenWrapClass)) {
                     $html .= '<div class="' . $childrenWrapClass . '">';
                 }
                 $html .= '<ul class="level' . $childLevel . '">';
                 $html .= $this->_getHtml($child, $childrenWrapClass);
                 $html .= '</ul>';
                 if (!empty($childrenWrapClass)) {
                     $html .= '</div>';
                 }
             }
             $html .= '</li>';
             $counter++;
         }
     }
     return $html;
 }
Example #29
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;
 }
Example #30
0
 /**
  * Recursively generates top menu html from data that is specified in $menuTree
  *
  * @param Varien_Data_Tree_Node $menuTree
  * @param string $childrenWrapClass
  * @return string
  */
 protected function _getHtml(Varien_Data_Tree_Node $menuTree, $childrenWrapClass)
 {
     $html = '';
     $children = $menuTree->getChildren();
     $parentLevel = $menuTree->getLevel();
     $childLevel = is_null($parentLevel) ? 0 : $parentLevel + 1;
     $counter = 1;
     $childrenCount = $children->count();
     $parentPositionClass = $menuTree->getPositionClass();
     $itemPositionClassPrefix = $parentPositionClass ? $parentPositionClass . '-' : 'nav-';
     foreach ($children as $child) {
         $child->setLevel($childLevel);
         $child->setIsFirst($counter == 1);
         $child->setIsLast($counter == $childrenCount);
         $child->setPositionClass($itemPositionClassPrefix . $counter . " ");
         $outermostClassCode = '';
         $outermostClass = $menuTree->getOutermostClass();
         if ($childLevel == 0 && $outermostClass) {
             $outermostClassCode = ' class="' . $outermostClass . '" ';
             $child->setClass($outermostClass);
         }
         if ($childLevel == 1 && ($counter == 1 || $counter == 6 || $counter == 11)) {
             $html .= '<div class="menu-column">';
         }
         $html .= '<li ' . $this->_getRenderedMenuItemAttributes($child) . '>';
         $url = $child->getName() == 'CATEGORIES' ? "javascript:;" : $child->getUrl();
         $html .= '<a href="' . $url . '" ' . $outermostClassCode . '>' . $this->escapeHtml(ucfirst($child->getName())) . '</a>';
         if ($child->hasChildren()) {
             if (!empty($childrenWrapClass)) {
                 $html .= '<div class="' . $childrenWrapClass . '">';
             }
             $html .= '<ul class="level' . $childLevel . ' sub-menu">';
             //$html .='<div class="menu-column">';
             $html .= $this->_getHtml($child, $childrenWrapClass);
             //$html .= '</div>';
             $html .= '</ul>';
             if (!empty($childrenWrapClass)) {
                 $html .= '</div>';
             }
         }
         $html .= '</li>';
         //            $url = "";
         //            if($childLevel==0  && $counter==4):
         //                $url ="/shop-by-brands.html";
         //            endif;
         if ($childLevel == 1 && $counter == $childrenCount && $child->getName() != "OUT OF STOCK") {
             $html .= '<li><a href="/shop-by-brands.html">More...</a></li>
                 ';
         }
         if ($childLevel == 1 && ($counter == 5 || $counter == 10 || $counter == 16)) {
             $html .= '</div>';
         }
         if ($counter == 15 && $child->getName() == 'BRANDS') {
             $html .= '<div class="menu-column menu-column-lg">
               <h2>Featured Brands:</h2>
               <ul class="list-unstyled">
                 <li><a href="/shop-by-brands/bieossence.html"><img src="/media/catalog/category/bio-logo.jpg" alt="Bioessence"></a></li>
                 <li><a href="/shop-by-brands/purebeauty.html"><img src="/media/catalog/category/pure-beauty-logo.jpg" alt="Pure beauty"></a></li>
                 <li><a href="/shop-by-brands/la-roche.html"><img src="/media/catalog/category/brand-6_2.jpg" alt="LA ROCHE-POSAY"></a></li>
               </ul>
             </div>';
         }
         $counter++;
     }
     return $html;
 }