Beispiel #1
0
 /**
  * Recursively returns a value / label array of all active categories
  * @param Mage_Catalog_Model_Category $category
  * @param String $parentname
  * @return array
  */
 private function getChildCategories($category, $parentname = '')
 {
     //category not active - skip it
     if (!$category->getIsActive()) {
         return '';
     }
     //array containing all the categories to return
     $ret = array();
     /* Add the current category to return array
      * Root categories shouldn't be selected
      */
     if ($category->getLevel() > 1) {
         $ret[$category->getID()] = $category->getName() . $parentname;
     }
     // get all children
     if (Mage::helper('catalog/category_flat')->isEnabled()) {
         $children = (array) $category->getChildrenNodes();
         $childrenCount = count($children);
     } else {
         $children = $category->getChildrenCategories();
         $childrenCount = $children->count();
     }
     $hasChildren = $children && $childrenCount;
     // select active children
     $activeChildren = array();
     foreach ($children as $child) {
         if ($child->getIsActive()) {
             $activeChildren[] = $child;
         }
     }
     $activeChildrenCount = count($activeChildren);
     $hasActiveChildren = $activeChildrenCount > 0;
     /**
      * Use recursion to include all children categories too
      */
     foreach ($activeChildren as $child) {
         $childarray = $this->getChildCategories($child, " / " . $category->getName() . $parentname);
         foreach ($childarray as $k => $v) {
             $ret[$k] = $v;
         }
     }
     return $ret;
 }
 /**
  * Enter description here...
  *
  * @param Mage_Catalog_Model_Category $category
  * @param int $level
  * @param boolean $last
  * @return string
  */
 public function drawItemSingle($category, $level = 0, $last = false)
 {
     $html = '';
     if (!$category->getIsActive()) {
         return $html;
     }
     if (Mage::helper('catalog/category_flat')->isEnabled()) {
         $children = $category->getChildrenNodes();
         $childrenCount = count($children);
     } else {
         $children = $category->getChildren();
         $childrenCount = $children->count();
     }
     $hasChildren = $children && $childrenCount;
     $html .= '<li';
     if ($hasChildren) {
         $html .= ' onmouseover="toggleMenu(this,1)" onmouseout="toggleMenu(this,0)"';
     }
     $html .= ' class="level' . $level;
     $html .= ' nav-' . str_replace('/', '-', Mage::helper('catalog/category')->getCategoryUrlPath($category->getRequestPath()));
     if ($this->isCategoryActive($category)) {
         $html .= ' active';
     }
     if ($last) {
         $html .= ' last';
     }
     if ($hasChildren) {
         $cnt = 0;
         foreach ($children as $child) {
             if ($child->getIsActive()) {
                 $cnt++;
             }
         }
         if ($cnt > 0) {
             $html .= ' parent';
         }
     }
     $html .= '">' . "\n";
     $html .= '<a href="' . $this->getCategoryUrl($category) . '"><span>' . $this->htmlEscape($category->getName()) . '</span></a>' . "\n";
     $html .= '</li>' . "\n";
     return $html;
 }
 /**
  * Render category to html
  *
  * @param Mage_Catalog_Model_Category $category
  * @param int Nesting level number
  * @param boolean Whether ot not this item is last, affects list item class
  * @param boolean Whether ot not this item is first, affects list item class
  * @param boolean Whether ot not this item is outermost, affects list item class
  * @param string Extra class of outermost list items
  * @param string If specified wraps children list in div with this class
  * @param boolean Whether ot not to add on* attributes to list item
  * @return string
  */
 protected function _renderCategoryMenuItemHtml($category, $level = 0, $isLast = false, $isFirst = false, $isOutermost = false, $outermostItemClass = '', $childrenWrapClass = '', $noEventAttributes = false)
 {
     if (!$category->getIsActive()) {
         return '';
     }
     $html = array();
     // get all children
     if (Mage::helper('catalog/category_flat')->isEnabled()) {
         $children = (array) $category->getChildrenNodes();
         $childrenCount = count($children);
     } else {
         $children = $category->getChildren();
         $childrenCount = $children->count();
     }
     $hasChildren = $children && $childrenCount;
     // select active children
     $activeChildren = array();
     foreach ($children as $child) {
         if ($child->getIsActive()) {
             $activeChildren[] = $child;
         }
     }
     $activeChildrenCount = count($activeChildren);
     $hasActiveChildren = $activeChildrenCount > 0;
     // prepare list item html classes
     $classes = array();
     $classes[] = 'level' . $level;
     $classes[] = 'nav-' . $this->_getItemPosition($level);
     if ($this->isCategoryActive($category)) {
         $classes[] = 'active';
     }
     $linkClass = '';
     if ($isOutermost && $outermostItemClass) {
         $classes[] = $outermostItemClass;
         $linkClass = ' class="' . $outermostItemClass . '"';
     }
     if ($isFirst) {
         $classes[] = 'first';
     }
     if ($isLast) {
         $classes[] = 'last';
     }
     if ($hasActiveChildren) {
         $classes[] = 'parent';
     }
     // prepare list item attributes
     $attributes = array();
     if (count($classes) > 0) {
         $attributes['class'] = implode(' ', $classes);
     }
     if ($hasActiveChildren && !$noEventAttributes) {
         $attributes['onmouseover'] = 'toggleMenu(this,1)';
         $attributes['onmouseout'] = 'toggleMenu(this,0)';
     }
     // assemble list item with attributes
     $htmlLi = '<li';
     foreach ($attributes as $attrName => $attrValue) {
         $htmlLi .= ' ' . $attrName . '="' . str_replace('"', '\\"', $attrValue) . '"';
     }
     $htmlLi .= '>';
     $html[] = $htmlLi;
     $html[] = '<a href="' . $this->getCategoryUrl($category) . '"' . $linkClass . '>';
     $html[] = '<span>' . $this->escapeHtml($category->getName()) . '</span>';
     $html[] = '</a>';
     // render children
     $htmlChildren = '';
     $j = 0;
     foreach ($activeChildren as $child) {
         $htmlChildren .= $this->_renderCategoryMenuItemHtml($child, $level + 1, $j == $activeChildrenCount - 1, $j == 0, false, $outermostItemClass, $childrenWrapClass, $noEventAttributes);
         $j++;
     }
     if (!empty($htmlChildren)) {
         if ($childrenWrapClass) {
             $html[] = '<div class="' . $childrenWrapClass . '">';
         }
         $html[] = '<ul class="level' . $level . '">';
         $html[] = $htmlChildren;
         $html[] = '</ul>';
         if ($childrenWrapClass) {
             $html[] = '</div>';
         }
     }
     $html[] = '</li>';
     $html = implode("\n", $html);
     return $html;
 }
 /**
  * Render category to html
  *
  * @param Mage_Catalog_Model_Category $category
  * @param int Nesting level number
  * @param boolean Whether ot not this item is last, affects list item class
  * @param boolean Whether ot not this item is first, affects list item class
  * @param boolean Whether ot not this item is outermost, affects list item class
  * @param string Extra class of outermost list items
  * @param string If specified wraps children list in div with this class
  * @param boolean Whether ot not to add on* attributes to list item
  * @return string
  */
 protected function _renderCategoryMenuItemHtml($category, $level = 0, $isLast = false, $isFirst = false, $isOutermost = false, $outermostItemClass = '', $childrenWrapClass = '', $noEventAttributes = false)
 {
     if (!$category->getIsActive()) {
         return '';
     }
     $config = $this->getConfig();
     $html = array();
     $expanded = null;
     $ulThumb = '';
     $image = '';
     $thumb = '';
     $htmlLi = '';
     // get all children
     if (Mage::helper('catalog/category_flat')->isEnabled()) {
         $children = (array) $category->getChildrenNodes();
         $childrenCount = count($children);
     } else {
         $children = $category->getChildren();
         if (!$this->_getHelper()->isSearchResultsPage()) {
             $childrenCount = $children->count();
         } else {
             if (is_string($children)) {
                 $children = explode(',', $children);
             }
             $childrenCount = count($children);
         }
     }
     // select active children
     $activeChildren = array();
     foreach ($children as $child) {
         if ($child->getIsActive()) {
             $activeChildren[] = $child;
         }
     }
     $activeChildrenCount = count($activeChildren);
     $hasActiveChildren = $activeChildrenCount > 0;
     // prepare list item html classes
     $classes = array();
     $classes[] = 'level' . $level;
     $classes[] = 'nav-' . $this->_getItemPosition($level);
     if ($this->isCategoryActive($category)) {
         $classes[] = 'active';
     } else {
         if (Mage::registry('current_product') !== null && $config->activeProductCategoriesInDirectAccess()) {
             $classes = $this->_getCategoryModel()->getProductCategoriesInDirectAccess($category, $classes);
         }
     }
     $linkClass = '';
     if ($isOutermost && $outermostItemClass) {
         $classes[] = $outermostItemClass;
         $linkClass = ' class="' . $outermostItemClass . '"';
     }
     if ($isFirst) {
         $classes[] = 'first';
     }
     if ($isLast) {
         $classes[] = 'last';
     }
     if ($hasActiveChildren) {
         $classes[] = 'parent';
     }
     // prepare list item attributes
     $attributes = array();
     if (count($classes) > 0) {
         $attributes['class'] = implode(' ', $classes);
     }
     if ($hasActiveChildren && !$noEventAttributes) {
         $attributes['onmouseover'] = 'toggleMenu(this,1)';
         $attributes['onmouseout'] = 'toggleMenu(this,0)';
     }
     // assemble list item with attributes
     $thumbWidth = 14;
     $thumbHeight = 14;
     $thumbPosition = $config->getThumbPosition();
     $liMarginLeft = 0;
     $ulMarginLeft = 5;
     $ulPaddingLeft = 10;
     // define image thumbnail variables
     if ($config->isThumbImageActive()) {
         if ($config->getThumbSize()) {
             $thumbWidth = $config->getThumbWidth();
             $thumbHeight = $config->getThumbHeight();
         }
         $thumbnail = $this->_getCategoryModel()->load($category->getId())->getThumbnailImageUrl();
         $ulThumb = ' ul-thumb';
         if (!empty($thumbnail)) {
             $image = '<img class="thumb-img-' . $thumbPosition . '" src="' . $thumbnail . '" style= "width:' . $thumbWidth . 'px; height:' . $thumbHeight . 'px; float: ' . $thumbPosition . ';" />';
             $thumb = ' thumb';
             if ($thumbPosition === 'left') {
                 if ($config->isCollapsible() && $config->isThumbImageActive()) {
                     $liMarginLeft = $thumbWidth + 3;
                     $ulMarginLeft = 0;
                 } else {
                     $liMarginLeft = 0;
                     $ulMarginLeft = $thumbWidth + 3;
                 }
                 $ulPaddingLeft = 0;
             }
         } else {
             $thumb = ' no-thumb';
             $liMarginLeft = $thumbPosition === 'right' ? 0 : $thumbWidth + 3;
             if ($thumbPosition === 'left') {
                 $ulMarginLeft = 0;
                 $ulPaddingLeft = 0;
             }
         }
     }
     $collapsibleClass = '';
     if ($config->isCollapsible()) {
         $collapsibleClass = ' collapsible';
     }
     // add collapsible arrow and wrraper
     $arrow = '';
     $extraStyle = '';
     $collapsibleIconPosition = $config->getCollapsibleIconPosition();
     if ($config->isCollapsible()) {
         $width = $config->getCollapsibleIconType() === 'arrow' ? 8 : 16;
         $height = 0;
         $expanded = 0;
         if ($hasActiveChildren) {
             $width = $config->getCollapsibleIconType() === 'arrow' ? 8 : 16;
             $height = 16;
         }
         if ($height == 0) {
             $extraStyle = ' display:none;';
         }
         if ($height == 0 && $collapsibleIconPosition === 'left') {
             $liMarginLeft += $width;
         }
         if ($this->isCategoryActive($category)) {
             $expanded = 1;
         }
         $expanded = ' expanded="' . $expanded . '"';
         $spanOnclick = 'onclick="Codnitive.expandMenu(this.parentNode)';
         $spanClass = $config->getCollapsibleIconType() . '-' . $collapsibleIconPosition;
         $arrow = '<span class="' . $spanClass . ' " ' . $spanOnclick . '" style="width: ' . $width . 'px; height: ' . $height . 'px;' . $extraStyle . '"></span>';
     }
     $htmlLi .= '<li';
     foreach ($attributes as $attrName => $attrValue) {
         $htmlLi .= ' ' . $attrName . '="' . str_replace('"', '\\"', $attrValue) . $thumb . $collapsibleClass . '"';
     }
     $htmlLi .= ' style="margin-left: ' . $liMarginLeft . 'px;' . '">';
     $html[] = $htmlLi;
     $html[] = $arrow;
     // add wrapper
     $aClass = '';
     $aStyle = '';
     $onclick = '';
     if ($config->isCollapsible() || $config->isThumbImageActive()) {
         $wrapperMargin = $config->isCollapsible() && $collapsibleIconPosition === 'left' ? 14 : 0;
         $extraMargin = !$config->isThumbImageActive() ? 0 : !empty($thumbnail) && $thumbPosition === 'left' ? $thumbWidth + 3 : 0;
         $collWrapper = $wrapperMargin + $extraMargin;
         // makes parent category name clickable to open/close collapsible menus if option is enabled
         $collapseName = '';
         if ($hasActiveChildren && $config->isCollapsible() && $config->expandByParentName()) {
             $onclick = ' onclick="Codnitive.expandMenu(this.parentNode);return false;"';
             $collapseName = ' collapse-name';
         }
         $aClass = 'class="collapsible-wrapper' . $collapseName . '"';
         $aStyle = ' style="margin-left: ' . $collWrapper . 'px;"';
     }
     $html[] = '<a ' . $aClass . $onclick . 'href="' . $this->getCategoryUrl($category) . '"' . $linkClass . '>' . '<span class="category_name">' . $this->escapeHtml($category->getName()) . '</span></a>';
     // add thumbnail image
     $html[] = $image;
     // add product count
     if ($config->showProductCount()) {
         $count = Mage::getModel('catalog/layer')->setCurrentCategory($category->getID())->getProductCollection()->getSize();
         if ($config->removeZeroCount() && $count > 0 || !$config->removeZeroCount()) {
             $html[] = '<span class="product-count">(' . $count . ')</span>';
         }
     }
     // render children
     $htmlChildren = '';
     $j = 0;
     foreach ($activeChildren as $child) {
         $htmlChildren .= $this->_renderCategoryMenuItemHtml($child, $level + 1, $j == $activeChildrenCount - 1, $j == 0, false, $outermostItemClass, $childrenWrapClass, $noEventAttributes);
         $j++;
     }
     if (!empty($htmlChildren)) {
         if ($childrenWrapClass) {
             $html[] = '<div class="' . $childrenWrapClass . '">';
         }
         $html[] = '<ul class="level' . $level . $ulThumb . $collapsibleClass . '" style="margin-left: ' . $ulMarginLeft . 'px; padding-left: ' . $ulPaddingLeft . 'px;"' . $expanded . '>';
         $html[] = $htmlChildren;
         $html[] = '</ul>';
         if ($childrenWrapClass) {
             $html[] = '</div>';
         }
     }
     $html[] = '</li>';
     $html = implode("\n", $html);
     return $html;
 }
Beispiel #5
0
 /**
  * Enter description here...
  *
  * @param Mage_Catalog_Model_Category $category
  * @param int $level
  * @param boolean $last
  * @return string
  */
 public function drawItem2($category, $level = 0, $last = false)
 {
     $html = '';
     if (!$category->getIsActive()) {
         return $html;
     }
     if (Mage::helper('catalog/category_flat')->isEnabled()) {
         $children = $category->getChildrenNodes();
         $childrenCount = count($children);
     } else {
         $children = $category->getChildren();
         $childrenCount = $children->count();
     }
     $hasChildren = $children && $childrenCount;
     $html .= '<li><a href="' . $this->getCategoryUrl($category) . '">' . $this->htmlEscape($category->getName()) . '</a>' . '</li>' . "\n";
     return $html;
 }
Beispiel #6
0
    /**
     * Render category to html
     *
     * @param Mage_Catalog_Model_Category $category
     * @param int Nesting level number
     * @param boolean Whether ot not this item is last, affects list item class
     * @param boolean Whether ot not this item is first, affects list item class
     * @param boolean Whether ot not this item is outermost, affects list item class
     * @param string Extra class of outermost list items
     * @param string If specified wraps children list in div with this class
     * @param boolean Whether ot not to add on* attributes to list item
     * @return string
     */
    protected function _renderCategoryMenuItemHtml($category, $level = 0, $isLast = false, $isFirst = false, $isOutermost = false, $outermostItemClass = '', $childrenWrapClass = '', $noEventAttributes = false)
    {
        if (!$category->getIsActive()) {
            return '';
        }
        $category_ids = array();
        $postData = Mage::app()->getRequest()->getPost('filter_cat');
        foreach ($postData as $posdata) {
            array_push($category_ids, $posdata);
        }
        $config = $this->getConfig();
        $html = array();
        $expanded = null;
        $ulThumb = '';
        $image = '';
        $thumb = '';
        $htmlLi = '';
        // get all children
        if (Mage::helper('catalog/category_flat')->isEnabled()) {
            $children = (array) $category->getChildrenNodes();
            $childrenCount = count($children);
        } else {
            $children = $category->getChildren();
            if (!$this->_getHelper()->isSearchResultsPage()) {
                $childrenCount = $children->count();
            } else {
                if (is_string($children)) {
                    $children = explode(',', $children);
                }
                $childrenCount = count($children);
            }
        }
        // select active children
        $activeChildren = array();
        foreach ($children as $child) {
            if ($child->getIsActive()) {
                $activeChildren[] = $child;
            }
        }
        $activeChildrenCount = count($activeChildren);
        $hasActiveChildren = $activeChildrenCount > 0;
        // prepare list item html classes
        $classes = array();
        $classes[] = 'level' . $level;
        $classes[] = 'nav-' . $this->_getItemPosition($level);
        if ($this->isCategoryActive($category)) {
            $classes[] = 'active';
        } else {
            if (Mage::registry('current_product') !== null && $config->activeProductCategoriesInDirectAccess()) {
                $classes = $this->_getCategoryModel()->getProductCategoriesInDirectAccess($category, $classes);
            }
        }
        $linkClass = '';
        if ($isOutermost && $outermostItemClass) {
            $classes[] = $outermostItemClass;
            $linkClass = ' class="' . $outermostItemClass . '"';
        }
        if ($isFirst) {
            $classes[] = 'first';
        }
        if ($isLast) {
            $classes[] = 'last';
        }
        if ($hasActiveChildren) {
            $classes[] = 'parent has-sub';
        }
        // prepare list item attributes
        $attributes = array();
        if (count($classes) > 0) {
            $attributes['class'] = implode(' ', $classes);
        }
        if ($hasActiveChildren && !$noEventAttributes) {
            $attributes['onmouseover'] = 'toggleMenu(this,1)';
            $attributes['onmouseout'] = 'toggleMenu(this,0)';
        }
        // assemble list item with attributes
        $thumbWidth = 14;
        $thumbHeight = 14;
        $thumbPosition = $config->getThumbPosition();
        $liMarginLeft = 0;
        $ulMarginLeft = 5;
        $ulPaddingLeft = 10;
        // define image thumbnail variables
        if ($config->isThumbImageActive()) {
            if ($config->getThumbSize()) {
                $thumbWidth = $config->getThumbWidth();
                $thumbHeight = $config->getThumbHeight();
            }
            $thumbnail = $this->_getCategoryModel()->load($category->getId())->getThumbnailImageUrl();
            $ulThumb = ' ul-thumb';
            if (!empty($thumbnail)) {
                $image = '<img class="thumb-img-' . $thumbPosition . '" src="' . $thumbnail . '" style= "width:' . $thumbWidth . 'px; height:' . $thumbHeight . 'px; float: ' . $thumbPosition . ';" />';
                $thumb = ' thumb';
                if ($thumbPosition === 'left') {
                    if ($config->isCollapsible() && $config->isThumbImageActive()) {
                        $liMarginLeft = $thumbWidth + 3;
                        $ulMarginLeft = 0;
                    } else {
                        $liMarginLeft = 0;
                        $ulMarginLeft = $thumbWidth + 3;
                    }
                    $ulPaddingLeft = 0;
                }
            } else {
                $thumb = ' no-thumb';
                $liMarginLeft = $thumbPosition === 'right' ? 0 : $thumbWidth + 3;
                if ($thumbPosition === 'left') {
                    $ulMarginLeft = 0;
                    $ulPaddingLeft = 0;
                }
            }
        }
        $collapsibleClass = '';
        if ($config->isCollapsible()) {
            $collapsibleClass = ' collapsible';
        }
        if ($level == 0) {
            $ulMarginLeft = 0;
            $ulPaddingLeft = 0;
        }
        // add collapsible arrow and wrraper
        $arrow = '';
        $extraStyle = '';
        $checkbox = '';
        $label_start = '<span>';
        $label_end = '</span>';
        $collapsibleIconPosition = $config->getCollapsibleIconPosition();
        if ($config->isCollapsible() && $category->getId() == 18) {
            $width = $config->getCollapsibleIconType() === 'arrow' ? 8 : 16;
            $height = 0;
            $expanded = 0;
            if ($hasActiveChildren) {
                $width = $config->getCollapsibleIconType() === 'arrow' ? 8 : 16;
                $height = 16;
            }
            if ($height == 0) {
                $extraStyle = ' display:none;';
            }
            if ($height == 0 && $collapsibleIconPosition === 'left') {
                $liMarginLeft += $width;
            }
            if ($this->isCategoryActive($category)) {
                $expanded = 1;
            }
            $expanded = ' expanded="' . $expanded . '"';
            $spanOnclick = 'onclick="Codnitive.expandMenu(this.parentNode)';
            $spanClass = $config->getCollapsibleIconType() . '-' . $collapsibleIconPosition;
            $arrow = '<span class="' . $spanClass . ' " ' . $spanOnclick . '" style="width: ' . $width . 'px; height: ' . $height . 'px;' . $extraStyle . '"></span>';
        }
        if ($category->getId() != 10 && $category->getId() != 15) {
            $htmlLi .= '<li';
            foreach ($attributes as $attrName => $attrValue) {
                $htmlLi .= ' ' . $attrName . '="' . str_replace('"', '\\"', $attrValue) . $thumb . $collapsibleClass . '"';
            }
            $selected = in_array($category->getId(), $category_ids) ? 'checked="checked"' : '';
            $checkbox = strpos($attrValue, "level2") === false ? '' : '<input id="check' . $category->getId() . '"class="css-checkbox" type="checkbox" name="filter_cat[]" value="' . $category->getId() . '" ' . $selected . '/>';
            $htmlLi .= ' style="margin-left: ' . $liMarginLeft . 'px;' . '">';
            $html[] = $htmlLi;
            $html[] = $arrow;
            // add wrapper
            $aClass = '';
            $aStyle = '';
            $onclick = '';
            if ($config->isCollapsible() || $config->isThumbImageActive()) {
                $wrapperMargin = $config->isCollapsible() && $collapsibleIconPosition === 'left' ? 14 : 0;
                $extraMargin = !$config->isThumbImageActive() ? 0 : !empty($thumbnail) && $thumbPosition === 'left' ? $thumbWidth + 3 : 0;
                $collWrapper = $wrapperMargin + $extraMargin;
                // makes parent category name clickable to open/close collapsible menus if option is enabled
                $collapseName = '';
                if ($hasActiveChildren && $config->isCollapsible() && $config->expandByParentName()) {
                    $onclick = ' onclick="Codnitive.expandMenu(this.parentNode);return false;"';
                    $collapseName = ' collapse-name';
                }
                $hidebottom_line = $category->getId() == 18 ? "border-bottom: 0px!important;" : "";
                $aClass = 'class="collapsible-wrapper' . $collapseName . '"';
                $aStyle = ' style="margin-left: ' . $collWrapper . 'px;"' . $hidebottom_line . '';
            }
            $cat_link = $this->getCategoryUrl($category);
            if ($checkbox != "") {
                $label_start = '<label for="check' . $category->getId() . '" class="css-label">';
                $label_end = '</label>';
                $cat_link = '#';
            }
            $hide = $category->getId() == 13 ? "style='display:none;'" : "";
            $html[] = '<a ' . $hidebottom_line . ' ' . $hide . ' ' . $aClass . $onclick . 'href="' . $cat_link . '"' . $linkClass . '>' . $checkbox . $label_start . '' . $this->escapeHtml($category->getName()) . $label_end . '</a>';
            // add thumbnail image
            $html[] = $image;
            // add product count
            if ($config->showProductCount()) {
                $count = Mage::getModel('catalog/layer')->setCurrentCategory($category->getID())->getProductCollection()->getSize();
                if ($config->removeZeroCount() && $count > 0 || !$config->removeZeroCount()) {
                    $html[] = '<span class="product-count">(' . $count . ')</span>';
                }
            }
            // render children
            $htmlChildren = '';
            $j = 0;
            foreach ($activeChildren as $child) {
                $htmlChildren .= $this->_renderCategoryMenuItemHtml($child, $level + 1, $j == $activeChildrenCount - 1, $j == 0, false, $outermostItemClass, $childrenWrapClass, $noEventAttributes);
                $j++;
            }
            if (!empty($htmlChildren)) {
                if ($childrenWrapClass) {
                    $html[] = '<div class="' . $childrenWrapClass . '">';
                }
                echo $ulThumb;
                if (strpos($htmlChildren, 'checked')) {
                    $expanded = "display:block;expanded=1";
                }
                //set padding and margin to 0 if level 1 -monarc
                $html[] = '<ul class="level' . $level . $ulThumb . $collapsibleClass . '" style="margin-left: ' . $ulMarginLeft . 'px; padding-left: ' . $ulPaddingLeft . 'px;"' . $expanded . '>';
                $html[] = $htmlChildren;
                $html[] = '</ul>';
                if ($childrenWrapClass) {
                    $html[] = '</div>';
                }
            }
            $html[] = '</li>';
            if ($category->getId() == 18) {
                $htmlLi .= '<li >
                        <ul class="buttons" style="margin:0px;padding:0px;">

                        <li><a href="#"><input type="button" value="CLEAR" name="clear_all" id="clearme"></a></li>
                        <li><a href="#"><input type="submit" value="FILTER" name="filter"></a></li>
                        </ul>
                        </li>';
                $html[] = $htmlLi;
            }
        }
        $html = implode("\n", $html);
        return $html;
    }
Beispiel #7
0
 /**
  * Enter description here...
  *
  * @param Mage_Catalog_Model_Category $category
  * @param int $level
  * @param boolean $last
  * @return string
  */
 public function drawItem($category, $level = 0, $last = false)
 {
     $html = '';
     if (!$category->getIsActive()) {
         return $html;
     }
     if (Mage::helper('catalog/category_flat')->isEnabled()) {
         $children = $category->getChildrenNodes();
         $childrenCount = count($children);
     } else {
         $children = $category->getChildren();
         $childrenCount = $children->count();
     }
     $hasChildren = $children && $childrenCount;
     $html .= '<li';
     if ($hasChildren) {
         //$html.= ' onmouseover="Element.addClassName(this, \'over\') " onmouseout="Element.removeClassName(this, \'over\') "';
     }
     $html .= ' class="level' . $level;
     $html .= ' nav-' . str_replace('/', '-', Mage::helper('catalog/category')->getCategoryUrlPath($category->getRequestPath()));
     if ($this->isCategoryActive($category)) {
         $html .= ' active';
     }
     if ($last) {
         $html .= ' last';
     }
     if ($hasChildren) {
         $cnt = 0;
         foreach ($children as $child) {
             if ($child->getIsActive()) {
                 $cnt++;
             }
         }
         if ($cnt > 0) {
             $html .= ' parent';
         }
     }
     $html .= '">' . "\n";
     if ($level == 0) {
         $html .= '<a href="' . $this->getCategoryUrl($category) . '"><span>' . $this->htmlEscape($category->getName()) . '</span></a><span class="head"><a href="#" style="float:right;"></a></span>' . "\n";
     } else {
         $html .= '<a href="' . $this->getCategoryUrl($category) . '"><span>' . $this->htmlEscape($category->getName()) . '</span></a>' . "\n";
     }
     if ($hasChildren) {
         $j = 0;
         $htmlChildren = '';
         foreach ($children as $child) {
             if ($child->getIsActive()) {
                 $htmlChildren .= $this->drawItem($child, $level + 1, ++$j >= $cnt);
             }
         }
         if (!empty($htmlChildren)) {
             $html .= '<ul class="level' . $level . '">' . "\n" . $htmlChildren . '</ul>';
         }
     }
     $html .= '</li>' . "\n";
     return $html;
 }
Beispiel #8
0
 /**
  * Render category to html
  *
  * @param Mage_Catalog_Model_Category $category
  * @param int Nesting level number
  * @param boolean Whether ot not this item is last, affects list item class
  * @param boolean Whether ot not this item is first, affects list item class
  * @param boolean Whether ot not this item is outermost, affects list item class
  * @param string Extra class of outermost list items
  * @param string If specified wraps children list in div with this class
  * @param boolean Whether ot not to add on* attributes to list item
  * @return string
  */
 protected function _renderCategoryMenuItemHtml($category, $level = 0, $isLast = false, $isFirst = false, $isOutermost = false, $outermostItemClass = '', $childrenWrapClass = '', $noEventAttributes = false)
 {
     $level2 = $level + 1;
     if (!$category->getIsActive()) {
         return '';
     }
     $html = array();
     $childrenWrapClass = true;
     // get all children
     if (Mage::helper('catalog/category_flat')->isEnabled()) {
         $children = (array) $category->getChildrenNodes();
         $childrenCount = count($children);
     } else {
         $children = $category->getChildren();
         $childrenCount = $children->count();
     }
     $hasChildren = $children && $childrenCount;
     // select active children
     $activeChildren = array();
     foreach ($children as $child) {
         if ($child->getIsActive()) {
             $activeChildren[] = $child;
         }
     }
     $activeChildrenCount = count($activeChildren);
     $hasActiveChildren = $activeChildrenCount > 0;
     // prepare list item html classes
     $classes = array();
     $classes[] = 'level' . $level;
     $test = 'nav-' . $this->_getItemPosition($level);
     $classes[] = $test;
     if ($this->isCategoryActive($category)) {
         $classes[] = 'active';
     }
     $linkClass = '';
     if ($isOutermost && $outermostItemClass) {
         $classes[] = $outermostItemClass;
         $linkClass = ' class="' . $outermostItemClass . '"';
     }
     if ($isFirst) {
         if ($level == 0) {
             $html[] = '<li class="first-home"><a href="/"><span class="navigation-name">' . $this->__('Home') . '</span></a></li>';
         }
         $classes[] = 'first';
     }
     if ($isLast) {
         $classes[] = 'last';
     }
     if ($hasActiveChildren) {
         $classes[] = 'parent';
     }
     // prepare list item attributes
     $attributes = array();
     if (count($classes) > 0) {
         $attributes['class'] = implode(' ', $classes);
     }
     if ($hasActiveChildren && !$noEventAttributes) {
         $attributes['onmouseover'] = 'toggleMenu(this,1)';
         $attributes['onmouseout'] = 'toggleMenu(this,0)';
     }
     // assemble list item with attributes
     $htmlLi = '<li';
     foreach ($attributes as $attrName => $attrValue) {
         $htmlLi .= ' ' . $attrName . '="' . str_replace('"', '\\"', $attrValue) . '"';
     }
     $htmlLi .= '>';
     $html[] = $htmlLi;
     $html[] = '<a href="' . $this->getCategoryUrl($category) . '"' . $linkClass . '>';
     $html[] = '<span class="navigation-name">' . $this->escapeHtml($category->getName()) . '</span>';
     if ($hasActiveChildren && $level == 0 && !in_array('last', $classes)) {
         $html[] = '<span class="arrow">&nbsp;</span>';
     }
     $html[] = '</a>';
     // render children
     $htmlChildren = '';
     $j = 0;
     foreach ($activeChildren as $child) {
         $htmlChildren .= $this->_renderCategoryMenuItemHtml($child, $level + 1, $j == $activeChildrenCount - 1, $j == 0, false, $outermostItemClass, $childrenWrapClass, $noEventAttributes);
         $j++;
     }
     if (!empty($htmlChildren)) {
         if ($childrenWrapClass) {
             $categorytmp = Mage::getModel('catalog/category')->load($category->getId());
             $html[] = '<div class="dropdown_5columns_' . $test . '"><span class="top"></span><span class="category-title">' . $categorytmp->getCategorySpecName() . '</span>';
         }
         $htmlChildren .= '<li class="level' . ($level + 1) . ' view-all"><a href="' . $this->getCategoryUrl($category) . '?viewall=1">+ View All</a></li>';
         $html[] = '<ul class="level' . $level . '">';
         $html[] = $htmlChildren;
         $html[] = '</ul>';
         if (!in_array('last', $classes)) {
             $html[] = $this->getFeaturedProductsBox($categorytmp);
         }
         if ($childrenWrapClass) {
             $html[] = '<span class="bottom"></span></div>';
         }
     }
     $html[] = '</li>';
     $html = implode("\n", $html);
     return $html;
 }
Beispiel #9
0
 /**
  * Render category to html
  *
  * @param Mage_Catalog_Model_Category $category
  * @param int Nesting level number
  * @param boolean Whether ot not this item is last, affects list item class
  * @param boolean Whether ot not this item is first, affects list item class
  * @param boolean Whether ot not this item is outermost, affects list item class
  * @param string Extra class of outermost list items
  * @param string If specified wraps children list in div with this class
  * @param boolean Whether ot not to add on* attributes to list item
  * @return string
  */
 public function _renderCategoryMenuItemHtml($category, $level = 0, $isLast = false, $isFirst = false, $isOutermost = false, $outermostItemClass = '', $childrenWrapClass = '', $noEventAttributes = false)
 {
     if (!$category->getIsActive()) {
         return '';
     }
     $html = array();
     // get all children
     if (Mage::helper('catalog/category_flat')->isEnabled()) {
         $children = (array) $category->getChildrenNodes();
         $childrenCount = count($children);
     } else {
         $children = $category->getChildren();
         $childrenCount = $children->count();
     }
     $hasChildren = $children && $childrenCount;
     // select active children
     $activeChildren = array();
     foreach ($children as $child) {
         if ($child->getIsActive()) {
             $activeChildren[] = $child;
         }
     }
     $activeChildrenCount = count($activeChildren);
     $hasActiveChildren = $activeChildrenCount > 0;
     // prepare list item html classes
     $classes = array();
     if ($level == 0) {
         $classes[] = 'title';
     }
     $classes[] = 'level' . $level;
     $classes[] = 'nav-' . $this->_getItemPosition($level);
     if ($this->isCategoryActive($category)) {
         $classes[] = 'active';
     }
     $linkClass = '';
     if ($isOutermost && $outermostItemClass) {
         $classes[] = $outermostItemClass;
         $linkClass = ' class="' . $outermostItemClass . '"';
     }
     if ($isFirst) {
         $classes[] = 'first';
     }
     if ($isLast) {
         $classes[] = 'last';
     }
     if ($hasActiveChildren) {
         $classes[] = 'parent';
     }
     if ($this->isCategoryActive($category)) {
         $classes[] = 'current';
     }
     $classes[] = 'collapse closed';
     // prepare list item attributes
     $attributes = array();
     if (count($classes) > 0) {
         $attributes['class'] = implode(' ', $classes);
     }
     if ($hasActiveChildren && !$noEventAttributes) {
         $attributes['onmouseover'] = 'toggleMenu(this,1)';
         $attributes['onmouseout'] = 'toggleMenu(this,0)';
     }
     if ($level == 0) {
         $category_data = Mage::getModel('catalog/category')->load($category->getId());
     }
     if ($level == 0) {
         $html[] = '<li class="col"><ul>';
     }
     // assemble list item with attributes
     $htmlLi = '<li';
     foreach ($attributes as $attrName => $attrValue) {
         $htmlLi .= ' ' . $attrName . '="' . str_replace('"', '\\"', $attrValue) . '"';
     }
     $htmlLi .= '>';
     $html[] = $htmlLi;
     if ($level == 0) {
         if ($category_icon = $category_data->getBs_category_icon()) {
             $html[] = '<img class="icon" alt="" width="28"  src="' . Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'wysiwyg/ev_category_icons/' . $category_icon . '">';
         }
     }
     $html[] = '<a class="collapse closed" href="' . $this->getCategoryUrl($category) . '">' . $this->escapeHtml($category->getName());
     if ($level == 0) {
         $label = $category_data->getBs_category_lable();
         if (!empty($label)) {
             $html[] = '<span class="hot"> ' . $label . ' </span>';
         }
     }
     $html[] = '</a>';
     if ($level != 0 && $hasChildren) {
         $html[] = '<span class="minus click">&#8211;</span><span class="plus click">+</span>';
     }
     // render children
     $htmlChildren = '';
     $j = 0;
     foreach ($activeChildren as $child) {
         $htmlChildren .= $this->_renderCategoryMenuItemHtml($child, $level + 1, $j == $activeChildrenCount - 1, $j == 0, false, $outermostItemClass, $childrenWrapClass, $noEventAttributes);
         $j++;
     }
     if (!empty($htmlChildren)) {
         if ($level != 0) {
             $html[] = '<ul class="nav nav-list">';
         }
         $html[] = $htmlChildren;
         if ($level != 0) {
             $html[] = '</ul>';
         }
     }
     $html[] = '</li>';
     if ($level == 0) {
         $html[] = '</li></ul>';
     }
     $html = implode("\n", $html);
     return $html;
 }
Beispiel #10
0
    /**
     * Render category to html
     *
     * @param Mage_Catalog_Model_Category $category
     * @param int Nesting level number
     * @param boolean Whether ot not this item is last, affects list item class
     * @param boolean Whether ot not this item is first, affects list item class
     * @param boolean Whether ot not this item is outermost, affects list item class
     * @param string Extra class of outermost list items
     * @param string If specified wraps children list in div with this class
     * @param boolean Whether ot not to add on* attributes to list item
     * @return string
     */
    protected function _renderCategoryMenuItemHtml($category, $level = 0, $isLast = false, $isFirst = false, $isOutermost = false, $outermostItemClass = '', $childrenWrapClass = '', $noEventAttributes = false)
    {
        if (!$category->getIsActive()) {
            return '';
        }
        $html = array();
        $js = null;
        $expanded = null;
        $ulThumb = '';
        $image = '';
        $thumb = '';
        $htmlLi = '';
        // get all children
        if (Mage::helper('catalog/category_flat')->isEnabled()) {
            $children = (array) $category->getChildrenNodes();
            $childrenCount = count($children);
        } else {
            $children = $category->getChildren();
            $childrenCount = $children->count();
        }
        $hasChildren = $children && $childrenCount;
        // select active children
        $activeChildren = array();
        foreach ($children as $child) {
            if ($child->getIsActive()) {
                $activeChildren[] = $child;
            }
        }
        $activeChildrenCount = count($activeChildren);
        $hasActiveChildren = $activeChildrenCount > 0;
        // prepare list item html classes
        $classes = array();
        $classes[] = 'level' . $level;
        $classes[] = 'nav-' . $this->_getItemPosition($level);
        if ($this->isCategoryActive($category)) {
            $classes[] = 'active';
        }
        $linkClass = '';
        if ($isOutermost && $outermostItemClass) {
            $classes[] = $outermostItemClass;
            $linkClass = ' class="' . $outermostItemClass . '"';
        }
        if ($isFirst) {
            $classes[] = 'first';
        }
        if ($isLast) {
            $classes[] = 'last';
        }
        if ($hasActiveChildren) {
            $classes[] = 'parent';
        }
        // prepare list item attributes
        $attributes = array();
        if (count($classes) > 0) {
            $attributes['class'] = implode(' ', $classes);
        }
        if ($hasActiveChildren && !$noEventAttributes) {
            $attributes['onmouseover'] = 'toggleMenu(this,1)';
            $attributes['onmouseout'] = 'toggleMenu(this,0)';
        }
        // assemble list item with attributes
        $config = Mage::getModel('sidenav/config');
        $thumbWidth = 14;
        $thumbHeight = 14;
        $liMarginLeft = 0;
        $ulMarginLeft = 5;
        $ulPaddingLeft = 10;
        // define image thumbnail variables
        if ($config->getThumbImageActive()) {
            if ($config->getThumbSize()) {
                $thumbWidth = $config->getThumbWidth();
                $thumbHeight = $config->getThumbHeight();
            }
            $thumbnail = $config->load($category->getId())->getThumbnailImageUrl();
            $ulThumb = ' ul-thumb';
            if (!empty($thumbnail)) {
                $image = '<img src="' . $thumbnail . '" style= "width:' . $thumbWidth . 'px; height:' . $thumbHeight . 'px; float: left;" />';
                $thumb = ' thumb';
                if ($config->getCollapsible() && $config->getThumbImageActive()) {
                    $liMarginLeft = $thumbWidth + 3;
                    $ulMarginLeft = 0;
                } else {
                    $liMarginLeft = 0;
                    $ulMarginLeft = $thumbWidth + 3;
                }
                $ulPaddingLeft = 0;
            } else {
                $thumb = ' no-thumb';
                $liMarginLeft = $thumbWidth + 3;
                $ulMarginLeft = 0;
                $ulPaddingLeft = 0;
            }
        }
        $htmlLi .= '<li';
        foreach ($attributes as $attrName => $attrValue) {
            $htmlLi .= ' ' . $attrName . '="' . str_replace('"', '\\"', $attrValue) . $thumb . '"';
        }
        $htmlLi .= ' style="margin-left: ' . $liMarginLeft . 'px;">';
        $html[] = $htmlLi;
        // add collapsible arrow and wrraper
        if ($config->getCollapsible()) {
            $width = 8;
            $height = 0;
            $expanded = 0;
            if ($hasActiveChildren) {
                $width = 8;
                $height = 10;
            }
            if ($this->isCategoryActive($category)) {
                $expanded = 1;
            }
            $html[] = '<span class="arrow" onClick="expandMenu(this.parentNode)" 
		    	style="width: ' . $width . 'px; height: ' . $height . 'px;"></span>';
        }
        // add thumbnail image
        $html[] = $image;
        // add wrapper
        if ($config->getCollapsible() || $config->getThumbImageActive()) {
            $wrapperMargin = $config->getCollapsible() ? 14 : 0;
            /*if ($config->getThumbImageActive()) {
                  $extraMargin = !empty($thumbnail) ? $thumbWidth + 3 : 0;
              }*/
            $extraMargin = !$config->getThumbImageActive() ? 0 : !empty($thumbnail) ? $thumbWidth + 3 : 0;
            $collWrapper = $wrapperMargin + $extraMargin;
            $html[] = '<div class="collapsible-wrapper" style="margin-left: ' . $collWrapper . 'px;">';
        }
        $html[] = '<a href="' . $this->getCategoryUrl($category) . '"' . $linkClass . '><span class="category_name">' . $this->escapeHtml($category->getName()) . '</span></a>';
        //        $html[] = '<span class="category_name">' . $this->escapeHtml($category->getName()) . '</span></a>';
        //        $html[] = '</a>';
        // add product count
        if ($config->getShowProductCount()) {
            $count = Mage::getModel('catalog/layer')->setCurrentCategory($category->getID())->getProductCollection()->getSize();
            if ($config->removeZeroCount() && $count > 0 || !$config->removeZeroCount()) {
                $html[] = '<span class="product-count">(' . $count . ')</span>';
            }
        }
        // close wrapper
        if ($config->getCollapsible() || $config->getThumbImageActive()) {
            $html[] = '</div>';
        }
        // render children
        $htmlChildren = '';
        $j = 0;
        foreach ($activeChildren as $child) {
            $htmlChildren .= $this->_renderCategoryMenuItemHtml($child, $level + 1, $j == $activeChildrenCount - 1, $j == 0, false, $outermostItemClass, $childrenWrapClass, $noEventAttributes);
            $j++;
        }
        if (!empty($htmlChildren)) {
            if ($childrenWrapClass) {
                $html[] = '<div class="' . $childrenWrapClass . '">';
            }
            $html[] = '<ul class="level' . $level . $ulThumb . '" style="margin-left: ' . $ulMarginLeft . 'px; padding-left: ' . $ulPaddingLeft . 'px;" expanded="' . $expanded . '">';
            $html[] = $htmlChildren;
            $html[] = '</ul>';
            if ($childrenWrapClass) {
                $html[] = '</div>';
            }
        }
        $html[] = '</li>';
        $html = implode("\n", $html);
        return $html;
    }
    /**
     * Enter description here...
     *
     * @param Mage_Catalog_Model_Category $category
     * @param int $level
     * @param boolean $last
     * @return string
     */
    public function drawItem($category, $level = 0, $last = false)
    {
        $html = '';
        if (!$category->getIsActive()) {
            return $html;
        }
        if (Mage::helper('catalog/category_flat')->isEnabled()) {
            $children = $category->getChildrenNodes();
            $childrenCount = count($children);
        } else {
            $children = $category->getChildren();
            $childrenCount = $children->count();
        }
        $hasChildren = $children && $childrenCount;
        $html .= '<li';
        if ($hasChildren || $category->getName() == 'Frames') {
            $html .= ' onmouseover="toggleMenu(this,1)" onmouseout="toggleMenu(this,0)"';
        }
        $html .= ' class="level' . $level;
        //$html.= ' nav-'.str_replace('/', '-', Mage::helper('catalog/category')->getCategoryUrlPath($category->getRequestPath()));
        $html .= ' nav-' . $this->_getItemPosition($level);
        if ($this->isCategoryActive($category)) {
            $html .= ' active';
        }
        if ($last) {
            $html .= ' last';
        }
        if ($hasChildren) {
            $cnt = 0;
            foreach ($children as $child) {
                if ($child->getIsActive()) {
                    $cnt++;
                }
            }
            if ($cnt > 0) {
                $html .= ' parent';
            }
        }
        $html .= '">' . "\n";
        $html .= '<a href="' . $this->getCategoryUrl($category) . '"><span>' . $this->htmlEscape($category->getName()) . '</span></a>' . "\n";
        if ($category->getName() != 'Frames') {
            if ($hasChildren) {
                $j = 0;
                $htmlChildren = '';
                foreach ($children as $child) {
                    if ($child->getIsActive()) {
                        $htmlChildren .= $this->drawItem($child, $level + 1, ++$j >= $cnt);
                    }
                }
                if (!empty($htmlChildren)) {
                    $html .= '<ul class="level' . $level . '">' . "\n" . $htmlChildren . '</ul>';
                }
            }
        } else {
            $_myStore = Mage::app()->getStore()->getCode();
            if ($_myStore == 'wholesaledefault') {
                $html .= '<ul class="level0">
		<li class="level1 nav-1-1">
		<a href="' . $this->getBaseURL() . 'frames/mixte-72.html"><span>Mixte</span></a>
		</li>
		
		<li class="level1 nav-1-2">
		<a href="' . $this->getBaseURL() . 'frames/polyvalent-55.html"><span>Polyvalent</span></a>
		</li>
		
		<li class="level1 nav-1-3 last">
		<a href="' . $this->getBaseURL() . 'frames/rando-74.html"><span>Rando</span></a>
		</li>
		
		
		</ul>';
            } else {
                $html .= '<ul class="level0">
		<li class="level1 nav-1-1">
		<a href="' . $this->getBaseURL() . 'frames/mixte-72.html"><span>Mixte</span></a>
		</li>
		
		<li class="level1 nav-1-2">
		<a href="' . $this->getBaseURL() . 'frames/polyvalent-55.html"><span>Polyvalent</span></a>
		</li>
		
		<li class="level1 nav-1-3">
		<a href="' . $this->getBaseURL() . 'frames/rando-74.html"><span>Rando</span></a>
		</li>
		
		<li class="level1 nav-1-4 last">
		<a href="' . $this->getBaseURL() . 'frames/build-kit.html"><span>Build Kits</span></a>
		</li>
		
		</ul>';
            }
        }
        $html .= '</li>' . "\n";
        return $html;
    }
Beispiel #12
0
 /**
  * Render category to html
  *
  * @param Mage_Catalog_Model_Category $category
  * @param int Nesting level number
  * @param boolean Whether ot not this item is last, affects list item class
  * @param boolean Whether ot not this item is first, affects list item class
  * @param string Extra class of outermost list items
  * @param string If specified wraps children list in div with this class
  * @param boolean Whether ot not to add on* attributes to list item
  * @return string
  */
 protected function ___renderCategoryMenuItemHtml($category, $level = 0, $isLast = false, $isFirst = false, $isOutermost = false, $outermostItemClass = '', $childrenWrapClass = '', $noEventAttributes = false)
 {
     if (!$category->getIsActive()) {
         return '';
     }
     $html = array();
     // get all children
     // If Flat Data enabled then use it but only on frontend
     $flatHelper = Mage::helper('catalog/category_flat');
     if ($flatHelper->isAvailable() && $flatHelper->isBuilt(true) && !Mage::app()->getStore()->isAdmin()) {
         $children = (array) $category->getChildrenNodes();
         $childrenCount = count($children);
     } else {
         $children = $category->getChildren();
         $childrenCount = $children->count();
     }
     $hasChildren = $children && $childrenCount;
     // select active children
     $activeChildren = array();
     foreach ($children as $child) {
         if ($child->getIsActive()) {
             $activeChildren[] = $child;
         }
     }
     $_tmp_children = array();
     foreach ($activeChildren as $child) {
         if ($child->getIsActive()) {
             $_tmp_children[$child->getName()] = $child;
         }
     }
     ksort($_tmp_children, SORT_STRING);
     $activeChildren = $_tmp_children;
     $activeChildrenCount = count($activeChildren);
     $hasActiveChildren = $activeChildrenCount > 0;
     // prepare list item html classes
     $classes = array();
     $classes[] = 'level' . $level;
     $classes[] = 'nav-' . $this->_getItemPosition($level);
     if ($this->isCategoryActive($category)) {
         $classes[] = 'active';
     }
     $linkClass = '';
     if ($isOutermost && $outermostItemClass) {
         $classes[] = $outermostItemClass;
         $linkClass = ' class="' . $outermostItemClass . '"';
     }
     if ($isFirst) {
         $classes[] = 'first';
     }
     if ($isLast) {
         $classes[] = 'last';
     }
     if ($hasActiveChildren) {
         $classes[] = 'parent';
     }
     // prepare list item attributes
     $attributes = array();
     if (count($classes) > 0) {
         $attributes['class'] = implode(' ', $classes);
     }
     if ($hasActiveChildren && !$noEventAttributes) {
         $attributes['onmouseover'] = 'toggleMenu(this,1)';
         $attributes['onmouseout'] = 'toggleMenu(this,0)';
     }
     // assemble list item with attributes
     $htmlLi = '<li';
     foreach ($attributes as $attrName => $attrValue) {
         $htmlLi .= ' ' . $attrName . '="' . str_replace('"', '\\"', $attrValue) . '"';
     }
     $htmlLi .= '>';
     $html[] = $htmlLi;
     $html[] = '<a href="' . $this->getCategoryUrl($category) . '"' . $linkClass . '>';
     $html[] = '<span>' . $this->escapeHtml($category->getName()) . '</span>';
     $html[] = '</a>';
     // render children
     $j = 0;
     if (count($activeChildren) > 0) {
         $int = 0;
         $catCount = count($activeChildren);
         $thirdCount = ceil($catCount / 3);
         $remain = $catCount % 3;
         $colCount = 0;
         $htmlChildren = '<ol thirdCount="' . $thirdCount . '" subCats="' . count($activeChildren) . '">';
     } else {
         $htmlChildren = '';
     }
     $htmlChildren = '<ol thirdCount="' . $thirdCount . '" subCats="' . count($activeChildren) . '">';
     foreach ($activeChildren as $child) {
         if ($int == $thirdCount && $colCount != 2) {
             $int = 0;
             $colCount = $colCount + 1;
             $htmlChildren .= '</ol><ol>';
         }
         $int = $int + 1;
         $htmlChildren .= $this->__renderCategoryMenuItemHtml($child, $level + 1, $j == $activeChildrenCount - 1, $j == 0, false, $outermostItemClass, $childrenWrapClass, $noEventAttributes);
         $j++;
     }
     if (count($activeChildren) != 0) {
         $htmlChildren .= '</ol>';
         if ($childrenWrapClass) {
             $html[] = '<div class="' . $childrenWrapClass . '">';
         }
         $html[] = '<ul class="level' . $level . '">';
         $html[] = $htmlChildren;
         $html[] = '</ul>';
         if ($childrenWrapClass) {
             $html[] = '</div>';
         }
     }
     $html[] = '</li>';
     $html = implode("\n", $html);
     return $html;
 }
 /**
  * Render category to html
  *
  * @param Mage_Catalog_Model_Category $category
  * @param int Nesting level number
  * @param boolean Whether ot not this item is last, affects list item class
  * @param boolean Whether ot not this item is first, affects list item class
  * @param boolean Whether ot not this item is outermost, affects list item class
  * @param string Extra class of outermost list items
  * @param string If specified wraps children list in div with this class
  * @param boolean Whether ot not to add on* attributes to list item
  * @return string
  */
 protected function _renderCategoryMenuItemHtml($category, $level = 0, $isLast = false, $isFirst = false, $isOutermost = false, $outermostItemClass = '', $childrenWrapClass = '', $noEventAttributes = false, $showThumbnails = false, $isMobile = false)
 {
     $_config = Mage::getStoreConfig('milanoconfig/menuoptions');
     $ca = Mage::getModel('catalog/category')->load($category->getId());
     $categoryMmenuStyle = $ca->getCategoryMmenuStyle();
     if (!empty($categoryMmenuStyle)) {
         $_config['mmenu_style'] = $categoryMmenuStyle;
     }
     if (!$category->getIsActive()) {
         return '';
     }
     $html = array();
     // check if thumbnail is allowed
     if (!$isMobile && $showThumbnails && ($categoryThumbnail = $ca->getThumbnail())) {
         $_isThumbnail = true;
     }
     // get all children
     if (Mage::helper('catalog/category_flat')->isEnabled()) {
         $children = (array) $category->getChildrenNodes();
         $childrenCount = count($children);
     } else {
         $children = $category->getChildren();
         $childrenCount = $children->count();
     }
     $hasChildren = $children && $childrenCount;
     // select active children
     $activeChildren = array();
     foreach ($children as $child) {
         if ($child->getIsActive()) {
             $activeChildren[] = $child;
         }
     }
     $activeChildrenCount = count($activeChildren);
     $hasActiveChildren = $activeChildrenCount > 0;
     // prepare list item html classes
     $classes = array();
     $classes[] = 'level' . $level;
     $classes[] = 'nav-' . $this->_getItemPosition($level);
     if ($this->isCategoryActive($category)) {
         $classes[] = 'active';
     }
     $linkClass = '';
     $categoryClass = Mage::getModel('catalog/category')->load($category->getId());
     // added by Romars
     $csscatClass = $categoryClass->getData('navigation_style');
     // added by Romars
     if ($isOutermost && $outermostItemClass) {
         $classes[] = $outermostItemClass;
         $linkClass = ' class="' . $outermostItemClass . ' ' . $csscatClass . '"';
         // added by Romars
     }
     if ($isFirst) {
         $classes[] = 'first ' . $csscatClass;
         // added by Romars
     }
     if ($isLast) {
         $classes[] = 'last ' . $csscatClass;
         // added by Romars
     }
     if ($hasActiveChildren) {
         $classes[] = 'parent ' . $csscatClass;
         // added by Romars
         $this->_columnsCount++;
     }
     if ($_isThumbnail) {
         $classes[] = 'category-thumbnail ' . $csscatClass;
         // added by Romars
     }
     // prepare list item attributes
     $attributes = array();
     if (count($classes) > 0) {
         $attributes['class'] = implode(' ', $classes);
     }
     if ($hasActiveChildren && !$noEventAttributes) {
         $attributes['onmouseover'] = 'toggleMenu(this,1)';
         $attributes['onmouseout'] = 'toggleMenu(this,0)';
     }
     // assemble list item with attributes
     $htmlLi = '<li';
     foreach ($attributes as $attrName => $attrValue) {
         $htmlLi .= ' ' . $attrName . '="' . str_replace('"', '\\"', $attrValue) . '"';
     }
     $htmlLi .= '>';
     $html[] = $htmlLi;
     $html[] = '<a href="' . $this->getCategoryUrl($category) . '"' . $linkClass . '>';
     // add the thumbnail
     if ($_isThumbnail) {
         $html[] = '<img src="' . Mage::getBaseUrl('media') . 'catalog/category/' . $categoryThumbnail . '" />';
     }
     // get atribute from backend
     // added by Romars
     $categoryClass = Mage::getModel('catalog/category')->load($category->getId());
     $html[] = '<span class="' . $categoryClass->getData('navigation_style') . '">' . $this->escapeHtml($category->getName()) . '</span>';
     $html[] = '</a>';
     // render children
     $htmlChildren = '';
     $j = 0;
     foreach ($activeChildren as $child) {
         $htmlChildren .= $this->_renderCategoryMenuItemHtml($child, $level + 1, $j == $activeChildrenCount - 1, $j == 0, false, $outermostItemClass, $childrenWrapClass, $noEventAttributes, $level == 0 && $_config['menutype'] == 1 && $_config['mmenu_style'] == 2, $isMobile);
         $j++;
         $columns++;
     }
     if (!empty($htmlChildren)) {
         if ($childrenWrapClass) {
             $html[] = '<div class="' . $childrenWrapClass . '">';
         }
         if ($level == 0) {
             $child = ' child child' . $columns;
         }
         $html[] = '<ul class="level' . $level . '' . $child . '">';
         //Display category description
         if (!$isMobile && $level == 0 && $_config['menutype'] == 1 && $_config['mmenu_style'] == 1) {
             $categoryDescription = $this->helper('catalog/output')->categoryAttribute($ca, $ca->getCategoryMenuDescription(), 'category_menu_description');
             if (!empty($categoryDescription)) {
                 $html[] = '<li class="nav-text-block right">' . $categoryDescription . '</li>';
             }
         }
         $html[] = $htmlChildren;
         $html[] = '</ul>';
         if ($childrenWrapClass) {
             $html[] = '</div>';
         }
     }
     $html[] = '</li>';
     $html = implode("", $html);
     return $html;
 }
 /**
  * Render category to html
  *
  * @param Mage_Catalog_Model_Category $category
  * @param int Nesting level number
  * @param boolean Whether ot not this item is last, affects list item class
  * @param boolean Whether ot not this item is first, affects list item class
  * @param boolean Whether ot not this item is outermost, affects list item class
  * @param string Extra class of outermost list items
  * @param string If specified wraps children list in div with this class
  * @param boolean Whether ot not to add on* attributes to list item
  * @return string
  */
 protected function _renderCategoryMenuItemHtml($category, $level = 0, $isLast = false, $isFirst = false, $isOutermost = false, $outermostItemClass = '', $childrenWrapClass = '', $noEventAttributes = false)
 {
     if (!$category->getIsActive()) {
         return '';
     }
     $html = array();
     // get all children
     if (Mage::helper('catalog/category_flat')->isEnabled()) {
         $children = (array) $category->getChildrenNodes();
         $childrenCount = count($children);
     } else {
         $children = $category->getChildren();
         $childrenCount = $children->count();
     }
     $hasChildren = $children && $childrenCount;
     // select active children
     $activeChildren = array();
     foreach ($children as $child) {
         if ($child->getIsActive()) {
             $activeChildren[] = $child;
         }
     }
     $activeChildrenCount = count($activeChildren);
     $hasActiveChildren = $activeChildrenCount > 0;
     // prepare list item html classes
     $classes = array();
     $classes[] = 'level' . $level;
     $classes[] = 'nav-' . $this->_getItemPosition($level);
     if ($this->isCategoryActive($category)) {
         $classes[] = 'active';
     }
     $linkClass = '';
     if ($isOutermost && $outermostItemClass) {
         $classes[] = $outermostItemClass;
         $linkClass = ' class="' . $outermostItemClass . '"';
     }
     if ($isFirst) {
         $classes[] = 'first';
     }
     if ($isLast) {
         $classes[] = 'last';
     }
     if ($hasActiveChildren) {
         $classes[] = 'parent';
     }
     // prepare list item attributes
     $attributes = array();
     if (count($classes) > 0) {
         $attributes['class'] = implode(' ', $classes);
     }
     if ($hasActiveChildren && !$noEventAttributes) {
         $attributes['onmouseover'] = 'toggleMenu(this,1)';
         $attributes['onmouseout'] = 'toggleMenu(this,0)';
     }
     // assemble list item with attributes
     $htmlLi = '<li';
     foreach ($attributes as $attrName => $attrValue) {
         $htmlLi .= ' ' . $attrName . '="' . str_replace('"', '\\"', $attrValue) . '"';
     }
     $htmlLi .= '>';
     $html[] = $htmlLi;
     $html[] = '<a href="' . $this->getCategoryUrl($category) . '"' . $linkClass . '>';
     $html[] = '<span>' . $this->escapeHtml($category->getName()) . '</span>';
     $html[] = '</a>';
     // render children
     $htmlChildren = '';
     $j = 0;
     $sub_categories = Mage::getModel('catalog/category')->load($category->getEntityId())->getChildrenCategories();
     $ctr = 1;
     $htmlChildren .= '<span class="groupArrow">';
     foreach ($sub_categories as $child) {
         $htmlChildren .= '<li>';
         $htmlChildren .= '<a href="' . $this->getCategoryUrl($child) . '" >';
         $htmlChildren .= '<span>' . $this->escapeHtml($child->getName()) . '</span>';
         $htmlChildren .= '</a>';
         $htmlChildren .= '</li>';
         if ($ctr % 7 == 0) {
             echo $ctr . "<br>";
             $htmlChildren .= '</span>';
             $htmlChildren .= '<span class="groupArrow">';
         }
         $ctr++;
     }
     /* $htmlChildren.= '<li>';
        $htmlChildren.= '<a href="'.$this->getBaseUrl().'arrivals/?id='.urlencode($category->getEntityId()).'" >';
        $htmlChildren.= '<span>New Arrivals</span>';
        $htmlChildren.= '</a>';
        $htmlChildren.= '</li>'; */
     $htmlChildren .= '</span>';
     /* foreach ($activeChildren as $child) {
        $htmlChildren .= $this->_renderCategoryMenuItemHtml(
        $child,
        ($level + 1),
        ($j == $activeChildrenCount - 1),
        ($j == 0),
        false,
        $outermostItemClass,
        $childrenWrapClass,
        $noEventAttributes
        );
        $j++;
        } */
     if (!empty($htmlChildren)) {
         if ($childrenWrapClass) {
             $html[] = '<div class="' . $childrenWrapClass . '">';
         }
         $Category = Mage::getModel("catalog/category")->load($category->getEntityId());
         if ($Category->getImageUrl()) {
             $imageUrl = '<img src=' . $Category->getImageUrl() . ' class="nav_image">';
         }
         if ($Category->getThumbnail()) {
             $imageUrl = '<img src=' . Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'catalog/category/' . $Category->getThumbnail() . ' class="nav_image">';
         } else {
             $imageUrl = '<img src=' . $this->getSkinUrl('images/noimage.jpg') . ' class="nav_image">';
         }
         $html[] = '<ul class="level' . $level . '">';
         $html[] = $htmlChildren;
         $html[] = '<span class="groupArrow2">';
         $html[] = '<li class="nav_img">' . $imageUrl . '</li>';
         $html[] = '</span>';
         $html[] = '</ul>';
         if ($childrenWrapClass) {
             $html[] = '</div>';
         }
     }
     $html[] = '</li>';
     $html = implode("\n", $html);
     return $html;
 }
 /**
  * Render category to html
  *
  * @param Mage_Catalog_Model_Category $category
  * @param int Nesting level number
  * @param boolean Whether ot not this item is last, affects list item class
  * @param boolean Whether ot not this item is first, affects list item class
  * @param boolean Whether ot not this item is outermost, affects list item class
  * @param string Extra class of outermost list items
  * @param string If specified wraps children list in div with this class
  * @param boolean Whether ot not to add on* attributes to list item
  * @return string
  */
 protected function _renderAthleteCategoryMenuItemHtml($category, $level = 0, $isLast = false, $isFirst = false, $isOutermost = false, $outermostItemClass = '', $childrenWrapClass = '', $noEventAttributes = false)
 {
     if (!$category->getIsActive()) {
         return '';
     }
     $html = array();
     // get all children
     if (Mage::helper('catalog/category_flat')->isEnabled()) {
         $children = (array) $category->getChildrenNodes();
         $childrenCount = count($children);
     } else {
         $children = $category->getChildren();
         $childrenCount = $children->count();
     }
     $hasChildren = $children && $childrenCount;
     // select active children
     $activeChildren = array();
     foreach ($children as $child) {
         if ($child->getIsActive()) {
             $activeChildren[] = $child;
         }
     }
     $activeChildrenCount = count($activeChildren);
     $hasActiveChildren = $activeChildrenCount > 0;
     // prepare list item html classes
     $classes = array();
     $classes[] = 'level' . $level;
     $classes[] = 'nav-' . $this->_getItemPosition($level);
     if ($this->isCategoryActive($category)) {
         $classes[] = 'active';
     }
     $linkClass = '';
     if ($isOutermost && $outermostItemClass) {
         $classes[] = $outermostItemClass;
         $linkClass = ' class="' . $outermostItemClass . '"';
     }
     if ($isFirst) {
         $classes[] = 'first';
     }
     if ($isLast) {
         $classes[] = 'last';
     }
     if ($hasActiveChildren) {
         $classes[] = 'parent';
     }
     // prepare list item attributes
     $attributes = array();
     if (count($classes) > 0) {
         $attributes['class'] = implode(' ', $classes);
     }
     if ($hasActiveChildren && !$noEventAttributes) {
         $attributes['onmouseover'] = 'toggleMenu(this,1)';
         $attributes['onmouseout'] = 'toggleMenu(this,0)';
     }
     // assemble list item with attributes
     $htmlLi = '<li';
     foreach ($attributes as $attrName => $attrValue) {
         $htmlLi .= ' ' . $attrName . '="' . str_replace('"', '\\"', $attrValue) . '"';
     }
     $htmlLi .= '>';
     $html[] = $htmlLi;
     $html[] = '<a href="' . $this->getCategoryUrl($category) . '"' . $linkClass . '>';
     $html[] = '<span>' . $this->escapeHtml($category->getName()) . '</span>';
     $html[] = '</a>';
     if ($level == 0) {
         //get category description
         $ca = Mage::getModel('catalog/category')->load($category->getId());
         $description = $ca->getDescription();
         if (empty($description) || !Mage::helper('athlete')->getCfg('header/show_description')) {
             $columns = 4;
         } else {
             $columns = 2;
         }
         $columnItemsNum = array_fill(0, $columns, floor($activeChildrenCount / $columns));
         if ($activeChildrenCount % $columns > 0) {
             for ($i = 0; $i < $activeChildrenCount % $columns; $i++) {
                 $columnItemsNum[$i]++;
             }
         }
         $this->_columnHtml = array();
     }
     // render children
     $htmlChildren = '';
     $j = 0;
     //child index
     $i = 0;
     //column index
     $itemsCount = $activeChildrenCount;
     if (isset($columnItemsNum[$i])) {
         $itemsCount = $columnItemsNum[$i];
     }
     foreach ($activeChildren as $child) {
         if ($level == 0) {
             $isLast = $j + 1 == $itemsCount || $j == $activeChildrenCount - 1;
             if ($isLast) {
                 $i++;
                 if (isset($columnItemsNum[$i])) {
                     $itemsCount += $columnItemsNum[$i];
                 }
             }
         } else {
             $isLast = $j == $activeChildrenCount - 1;
         }
         $childHtml = $this->_renderAthleteCategoryMenuItemHtml($child, $level + 1, $isLast, $j == 0, false, $outermostItemClass, $childrenWrapClass, $noEventAttributes);
         if ($level == 0) {
             //to fix Notice: Indirect modification of overloaded property
             $this->_columnHtml += array(count($this->_columnHtml) => $childHtml);
         } else {
             $htmlChildren .= $childHtml;
         }
         $j++;
     }
     if ($level == 0 && $this->_columnHtml) {
         $i = 0;
         foreach ($columnItemsNum as $columnNum) {
             $chunk = array_slice($this->_columnHtml, $i, $columnNum);
             $i += $columnNum;
             $htmlChildren .= '<li ' . (count($this->_columnHtml) == $i ? 'class="last"' : '') . '><ol>';
             foreach ($chunk as $item) {
                 $htmlChildren .= $item;
             }
             $htmlChildren .= '</ol></li>';
         }
     }
     if (!empty($description) && !empty($htmlChildren) && Mage::helper('athlete')->getCfg('header/show_description')) {
         $htmlChildren .= '<li class="menu-category-description clearfix">' . $description;
         $htmlChildren .= '<p><button class="button" onclick="window.location=\'' . $this->getCategoryUrl($category) . '\'"><span><span>' . $this->__('learn more') . '</span></span></button></p>';
         $htmlChildren .= '</li>';
     }
     if (!empty($htmlChildren)) {
         if ($childrenWrapClass) {
             $html[] = '<div class="' . $childrenWrapClass . '">';
         }
         $html[] = '<ul class="level' . $level . '">';
         $html[] = $htmlChildren;
         $html[] = '</ul>';
         if ($childrenWrapClass) {
             $html[] = '</div>';
         }
     }
     $html[] = '</li>';
     $html = implode("\n", $html);
     return $html;
 }
 /**
  * Render category to html
  *
  * @param Mage_Catalog_Model_Category $category
  * @param int Nesting level number
  * @param boolean Whether ot not this item is last, affects list item class
  * @param boolean Whether ot not this item is first, affects list item class
  * @param boolean Whether ot not this item is outermost, affects list item class
  * @param string Extra class of outermost list items
  * @param string If specified wraps children list in div with this class
  * @param boolean Whether ot not to add on* attributes to list item
  * @return string
  */
 protected function _renderCategorySelectOption($category, $level = 0, $isLast = false, $isFirst = false, $isOutermost = false, $outermostItemClass = '', $childrenWrapClass = '', $noEventAttributes = false)
 {
     if (!$category->getIsActive()) {
         return '';
     }
     $html = array();
     // get all children
     if (Mage::helper('catalog/category_flat')->isEnabled()) {
         $children = (array) $category->getChildrenNodes();
     } else {
         $children = $category->getChildren();
     }
     // select active children
     $activeChildren = array();
     foreach ($children as $child) {
         if ($child->getIsActive()) {
             $activeChildren[] = $child;
         }
     }
     $active = '';
     if ($this->isCategoryActive($category)) {
         $active = 'selected="selected"';
     }
     // assemble list item with attributes
     $html[] = '<option value="' . $this->getCategoryUrl($category) . '" ' . $active . '>' . str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;', $level) . $this->escapeHtml($category->getName()) . '</option>';
     // render children
     $htmlChildren = '';
     foreach ($activeChildren as $child) {
         $childHtml = $this->_renderCategorySelectOption($child, $level + 1, 0, 0, false, $outermostItemClass, $childrenWrapClass, $noEventAttributes);
         $htmlChildren .= $childHtml;
     }
     if (!empty($htmlChildren)) {
         $html[] = $htmlChildren;
     }
     $html = implode("\n", $html);
     return $html;
 }
 /**
  * Enter description here...
  *
  * @param Mage_Catalog_Model_Category $category
  * @param int $level
  * @param boolean $last
  * @return string
  */
 public function drawItem($category, $level = 0, $last = false)
 {
     $html = '';
     if (!$category->getIsActive()) {
         return $html;
     }
     if (Mage::helper('catalog/category_flat')->isEnabled()) {
         $children = $category->getChildrenNodes();
         $childrenCount = count($children);
     } else {
         $children = $category->getChildren();
         $childrenCount = $children->count();
     }
     $hasChildren = $children && $childrenCount;
     $html .= '<li';
     $html .= ' class="item';
     $html .= ' nav-' . str_replace('/', '-', Mage::helper('catalog/category')->getCategoryUrlPath($category->getRequestPath()));
     if ($this->isCategoryActive($category)) {
         $html .= ' active';
     }
     if ($last) {
         $html .= ' last';
     }
     if ($hasChildren) {
         $cnt = 0;
         foreach ($children as $child) {
             if ($child->getIsActive()) {
                 $cnt++;
             }
         }
         if ($cnt > 0) {
             $html .= ' hasChild';
         }
     }
     $html .= '">' . "\n";
     if ($level == 0) {
         if ($hasChildren) {
             $html .= '<a class="item" href="' . $this->getCategoryUrl($category) . '">' . $this->htmlEscape($category->getName()) . '</a>' . "\n";
             //$html.= '<span class="collapse">collapse</span>';
         } else {
             $html .= '<a class="item" href="' . $this->getCategoryUrl($category) . '">' . $this->htmlEscape($category->getName()) . '</a>' . "\n";
         }
     } else {
         if ($hasChildren) {
             $html .= '<a class="item" href="' . $this->getCategoryUrl($category) . '">' . $this->htmlEscape($category->getName()) . '</a>' . "\n";
             //$html.= '<span class="collapse">collapse</span>';
         } else {
             $html .= '<a class="item" href="' . $this->getCategoryUrl($category) . '">' . $this->htmlEscape($category->getName()) . '</a>' . "\n";
         }
     }
     if ($hasChildren) {
         $j = 0;
         $htmlChildren = '';
         foreach ($children as $child) {
             if ($child->getIsActive()) {
                 $htmlChildren .= $this->drawItem($child, $level + 1, ++$j >= $cnt);
             }
         }
         if (!empty($htmlChildren)) {
             $html .= '<ul class="detail-parent">' . "\n" . $htmlChildren . '</ul>';
         }
     }
     $html .= '</li>' . "\n";
     return $html;
 }