protected function printCategoryChildrenHardWay(Mage_Catalog_Model_Category $category)
 {
     /**
      * @var $child Mage_Catalog_Model_Category
      * @var $catCollection Mage_Catalog_Model_Resource_Category_Collection
      */
     $childrenIds = $category->getChildren();
     echo "<p><b>&nbsp;&nbsp;Children Ids:&nbsp;</b>{$childrenIds}</p>";
     $catCollection = Mage::getModel('catalog/category')->getCollection();
     $catCollection->addIdFilter(explode(',', $childrenIds))->addNameToResult()->load(true, true);
     foreach ($catCollection as $child) {
         echo "<p>&nbsp;&nbsp;&nbsp;<b>Child cat#{$child->getId()}&nbsp;</b>::&nbsp;{$child->getName()}</p>";
     }
 }
 /**
  * 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;
 }
 /**
  * Retrieve a collection of child categories for the provided category
  *
  * @param Mage_Catalog_Model_Category $category
  * @return Varien_Data_Collection_Db
  */
 protected function getChildrenCategories(Mage_Catalog_Model_Category $category)
 {
     $collection = $category->getCollection();
     $collection->addAttributeToSelect('url_key')->addAttributeToSelect('name')->addAttributeToSelect('is_anchor')->addAttributeToFilter('is_active', 1)->addIdFilter($category->getChildren())->setOrder('position', Varien_Db_Select::SQL_ASC)->load();
     return $collection;
 }
Exemple #4
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;
     }
     $children = $category->getChildren();
     $hasChildren = $children && $children->count();
     $html .= '<li';
     if ($hasChildren) {
         $html .= ' onmouseover="toggleMenu(this,1)" onmouseout="toggleMenu(this,0)"';
     }
     $html .= ' class="level' . $level;
     if ($this->isCategoryActive($category)) {
         $html .= ' active';
     }
     if ($last) {
         $html .= ' last';
     }
     if ($hasChildren) {
         $cnt = 0;
         foreach ($children as $child) {
             if ($child->getIsActive()) {
                 $cnt++;
             }
         }
         $html .= ' parent';
     }
     $html .= '">' . "\n";
     $html .= '<a href="' . $this->getCategoryUrl($category) . '"><span>' . $category->getName() . '</span></a>' . "\n";
     //$html.= '<span>'.$level.'</span>';
     if ($hasChildren) {
         $j = 0;
         $htmlChildren = '';
         foreach ($children as $child) {
             $htmlChildren .= $this->drawItem($child, $level + 1, ++$j >= $cnt);
         }
         if (!empty($htmlChildren)) {
             $html .= '<ul class="level' . $level . '">' . "\n" . $htmlChildren . '</ul>';
         }
     }
     $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)
 {
     $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;
 }
 /**
  * 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;
 }
 /**
  * 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 _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;
 }
Exemple #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;
 }
Exemple #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;
    }
Exemple #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 _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;
 }
Exemple #16
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;
 }
Exemple #17
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();
     // get all children
     $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->_navigation_place == self::MENU_BAR) {
         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 ($isFirst && $this->getTypeNavigation() == GoMage_Navigation_Model_Layer::FILTER_TYPE_ACCORDION) {
         $classes[] = 'accordion-active';
     }
     // prepare list item attributes
     $attributes = array();
     if (count($classes) > 0) {
         $attributes['class'] = implode(' ', $classes);
     }
     switch ($this->getTypeNavigation()) {
         case GoMage_Navigation_Model_Layer::FILTER_TYPE_DROPDOWN:
             if ($this->getIsAjax()) {
                 $attributes['onchange'] = "GomageNavigation.setNavigationUrl(this.value); return false;";
             } else {
                 $attributes['onchange'] = "window.location=this.value";
             }
             $curent_id = 0;
             if (Mage::registry('current_category')) {
                 $curent_id = Mage::registry('current_category')->getId();
             }
             if ($category->getLevel() == $this->_root_level) {
                 $htmlSel = '<li><select';
                 foreach ($attributes as $attrName => $attrValue) {
                     $htmlSel .= ' ' . $attrName . '="' . str_replace('"', '\\"', $attrValue) . '"';
                 }
                 $htmlSel .= '>';
                 $html[] = $htmlSel;
                 $option_value = $this->getIsAjax() ? $this->getAjaxUrl($category) : $this->getCategoryUrl($category);
                 $html[] = '<option class="gan-dropdown-top" value="' . $option_value . '">' . (str_repeat('&nbsp;&nbsp;', $category->getLevel() - $this->_root_level) . $category->getName()) . '</option>';
             }
             $option_selected = $curent_id == $category->getId() ? 'selected="selected"' : '';
             $option_value = $this->getIsAjax() ? $this->getAjaxUrl($category) : $this->getCategoryUrl($category);
             $html[] = '<option ' . $option_selected . ' value="' . $option_value . '">' . (str_repeat('&nbsp;&nbsp;', $category->getLevel() - $this->_root_level) . $category->getName()) . '</option>';
             // 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)) {
                 $html[] = $htmlChildren;
             }
             if ($category->getLevel() == $this->_root_level) {
                 $html[] = '</select></li>';
             }
             break;
         case GoMage_Navigation_Model_Layer::FILTER_TYPE_PLAIN:
             $linkClass = '';
             if ($isOutermost && $outermostItemClass) {
                 $linkClass = $outermostItemClass;
             }
             if ($this->getIsActiveAjaxCategory($category) || $this->isCategoryActive($category)) {
                 $linkClass .= ' active';
             }
             $linkClass = ' class="' . $linkClass . '" ';
             if ($category->getLevel() == $this->_root_level) {
                 $this->_plain_root_cat = $category;
                 //Offer Block
                 $this->_offer_block_html = null;
                 if ($this->_navigation_place == self::MENU_BAR) {
                     if ($category->getData('navigation_pw_ob_show')) {
                         $offer_block_styles = '';
                         if ($category->getData('navigation_pw_ob_bgcolor')) {
                             $offer_block_styles .= 'background-color:' . Mage::helper('gomage_navigation')->formatColor($category->getData('navigation_pw_ob_bgcolor')) . ';';
                         }
                         if ($category->getData('navigation_pw_ob_width')) {
                             $offer_block_styles .= 'width:' . $category->getData('navigation_pw_ob_width') . 'px;';
                         }
                         if ($category->getData('navigation_pw_ob_height')) {
                             $offer_block_styles .= 'height:' . $category->getData('navigation_pw_ob_height') . 'px;';
                         }
                         $offer_block_class = GoMage_Navigation_Model_Adminhtml_System_Config_Source_Category_Image_Position::getOfferBlockPositionClass($category->getData('navigation_pw_ob_pos'));
                         if (in_array($category->getData('navigation_pw_ob_pos'), array(GoMage_Navigation_Model_Adminhtml_System_Config_Source_Category_Image_Position::LEFT, GoMage_Navigation_Model_Adminhtml_System_Config_Source_Category_Image_Position::RIGHT)) && !$category->getData('navigation_pw_ob_height')) {
                             $offer_block_class .= ' gan-ob-noheight';
                         }
                         $this->_offer_block_html = '<div class="' . $offer_block_class . '" style="' . $offer_block_styles . '">';
                         $_desc = $category->getData('navigation_pw_ob_desc');
                         $_desc = nl2br($this->helper('cms')->getBlockTemplateProcessor()->filter($_desc));
                         $this->_offer_block_html .= $_desc;
                         $this->_offer_block_html .= '</div>';
                     }
                 }
                 if ($hasActiveChildren && !$noEventAttributes) {
                     $attributes['onmouseover'] = 'toggleMenu(this,1)';
                     $attributes['onmouseout'] = 'toggleMenu(this,0)';
                 }
                 if ($this->_navigation_place == self::MENU_BAR) {
                     if (isset($attributes['class'])) {
                         $attributes['class'] = $attributes['class'] . ' nav-' . $category->getId();
                     } else {
                         $attributes['class'] = 'nav-' . $category->getId();
                     }
                     if ($category->getData('navigation_pw_s_template')) {
                         $attributes['class'] = $attributes['class'] . ' gan-plain-style' . $category->getData('navigation_pw_s_template');
                     }
                 }
                 $htmlLi = '<li';
                 foreach ($attributes as $attrName => $attrValue) {
                     $htmlLi .= ' ' . $attrName . '="' . str_replace('"', '\\"', $attrValue) . '"';
                 }
                 $htmlLi .= '>';
                 $html[] = $htmlLi;
                 $htmlA = '<a href="' . $this->getCategoryUrl($category) . '"' . $linkClass;
                 if ($this->getIsAjax()) {
                     $htmlA .= ' onclick="GomageNavigation.setNavigationUrl(\'' . $this->getAjaxUrl($category) . '\'); return false;" ';
                 }
                 $htmlA .= '>';
                 $html[] = $htmlA;
                 $html[] = '<span>' . $this->escapeHtml($category->getName()) . '</span>';
                 $html[] = '</a>';
                 if ($hasActiveChildren) {
                     if ($this->_navigation_place == self::MENU_BAR) {
                         $_width = $category->getData('navigation_pw_s_width');
                     } else {
                         $_width = $category->getData('navigation_pw_side_width');
                     }
                     $gan_plain_style = '';
                     if ($this->_navigation_place == self::MENU_BAR) {
                         if ($category->getData('navigation_pw_s_bgcolor')) {
                             $gan_plain_style .= 'background-color:' . Mage::helper('gomage_navigation')->formatColor($category->getData('navigation_pw_s_bgcolor')) . ';';
                         }
                         if ($category->getData('navigation_pw_s_height')) {
                             $gan_plain_style .= 'height:' . $category->getData('navigation_pw_s_height') . 'px;';
                         }
                         if ($category->getData('navigation_pw_s_bsize') && $category->getData('navigation_pw_s_bcolor')) {
                             $gan_plain_style .= 'border:' . $category->getData('navigation_pw_s_bsize') . 'px solid ' . Mage::helper('gomage_navigation')->formatColor($category->getData('navigation_pw_s_bcolor')) . ';';
                         }
                     }
                     $gan_plain_style .= $_width ? 'width:' . $_width . 'px;' : '';
                     if ($gan_plain_style) {
                         $gan_plain_style = 'style="' . $gan_plain_style . '"';
                     }
                     $gan_plain_class = 'gan-plain';
                     if ($this->_navigation_place == self::MENU_BAR) {
                         $gan_plain_class .= ' nav-' . $category->getId();
                     }
                     $html[] = '<div ' . $gan_plain_style . ' class="' . $gan_plain_class . '" >';
                     if (!($this->_navigation_place == self::MENU_BAR)) {
                         $html[] = '<span class="gan-plain-border"></span>';
                     }
                     $gan_plain_items_class = 'gan-plain-items';
                     $gan_plain_items_style = '';
                     if ($this->_offer_block_html) {
                         switch ($category->getData('navigation_pw_ob_pos')) {
                             case GoMage_Navigation_Model_Adminhtml_System_Config_Source_Category_Image_Position::TOP:
                                 $html[] = $this->_offer_block_html;
                                 break;
                             case GoMage_Navigation_Model_Adminhtml_System_Config_Source_Category_Image_Position::LEFT:
                                 $gan_plain_items_style .= 'float:right;';
                                 $_width = intval($category->getData('navigation_pw_s_width')) - intval($category->getData('navigation_pw_ob_width')) - 10;
                                 if ($_width > 0) {
                                     $gan_plain_items_style .= 'width:' . $_width . 'px;';
                                 }
                                 break;
                             case GoMage_Navigation_Model_Adminhtml_System_Config_Source_Category_Image_Position::RIGHT:
                                 $gan_plain_items_style .= 'float:left;';
                                 $_width = intval($category->getData('navigation_pw_s_width')) - intval($category->getData('navigation_pw_ob_width')) - 10;
                                 if ($_width > 0) {
                                     $gan_plain_items_style .= 'width:' . $_width . 'px;';
                                 }
                                 break;
                         }
                     }
                     $html[] = '<div class="' . $gan_plain_items_class . '" style="' . $gan_plain_items_style . '">';
                     $activeChildren = $this->sort_category($activeChildren);
                 }
             } else {
                 $_cat_column = null;
                 if ($category->getLevel() == $this->_root_level + 1) {
                     if ($this->_navigation_place == self::MENU_BAR) {
                         $_cat_column = $category->getData('navigation_pw_s_column') ? $category->getData('navigation_pw_s_column') : 1;
                     } else {
                         $_cat_column = $category->getData('navigation_column_side') ? $category->getData('navigation_column_side') : 1;
                     }
                 }
                 if ($this->_childs_count == 1 || $_cat_column && $_cat_column != $this->_current_column) {
                     $this->_current_column = $_cat_column;
                     if ($this->_childs_count != 1) {
                         $html[] = '</ul>';
                     }
                     $_ul_styles = '';
                     if ($this->_plain_root_cat->getData('navigation_pw_s_cwidth')) {
                         $_ul_styles .= 'width:' . $this->_plain_root_cat->getData('navigation_pw_s_cwidth') . 'px;';
                     } else {
                         if ($this->_plain_root_cat->getData('navigation_pw_s_width') && $this->_columns) {
                             $_width = (intval($this->_plain_root_cat->getData('navigation_pw_s_width')) - intval($this->_plain_root_cat->getData('navigation_pw_ob_width'))) / $this->_columns - intval($this->_plain_root_cat->getData('navigation_pw_s_c_indentl')) - intval($this->_plain_root_cat->getData('navigation_pw_s_c_indentr'));
                             if ($_width > 0) {
                                 $_ul_styles .= 'width:' . $_width . 'px;';
                             }
                         }
                     }
                     if ($this->_plain_root_cat->getData('navigation_pw_s_c_indentl')) {
                         $_ul_styles .= 'padding-left:' . $this->_plain_root_cat->getData('navigation_pw_s_c_indentl') . 'px;';
                     }
                     if ($this->_plain_root_cat->getData('navigation_pw_s_c_indentr')) {
                         $_ul_styles .= 'padding-right:' . $this->_plain_root_cat->getData('navigation_pw_s_c_indentr') . 'px;';
                     }
                     $html[] = '<ul style="' . $_ul_styles . '" class="gan-plain-item">';
                 }
                 $li_class = $category->getLevel() == $this->_root_level + 1 ? 'gan-plain-item-bold' : '';
                 if ($this->_navigation_place == self::MENU_BAR) {
                     if ($category->getLevel() == $this->_root_level + 1) {
                         $li_class .= ' sub-level1';
                     }
                     if ($category->getLevel() == $this->_root_level + 2) {
                         $li_class .= ' sub-level2';
                     }
                 }
                 $navigation_image = '';
                 $image_position = 0;
                 $category_view = 0;
                 if ($this->_navigation_place == self::MENU_BAR && $category->getData('navigation_pw_s_img')) {
                     if ($category->getLevel() == $this->_root_level + 1) {
                         $category_view = $this->_plain_root_cat->getData('navigation_pw_fl_view');
                         if ($category_view != GoMage_Navigation_Model_Adminhtml_System_Config_Source_Category_Attribute_View::TEXT) {
                             $navigation_image = $this->renderPlainImage($category->getData('navigation_pw_s_img'), $category, true);
                             $image_position = $this->_plain_root_cat->getData('navigation_pw_fl_ipos');
                         }
                     }
                     if ($category->getLevel() == $this->_root_level + 2) {
                         $category_view = $this->_plain_root_cat->getData('navigation_pw_sl_view');
                         if ($category_view != GoMage_Navigation_Model_Adminhtml_System_Config_Source_Category_Attribute_View::TEXT) {
                             $navigation_image = $this->renderPlainImage($category->getData('navigation_pw_s_img'), $category, false);
                             $image_position = $this->_plain_root_cat->getData('navigation_pw_sl_ipos');
                         }
                     }
                     if ($navigation_image) {
                         $li_class .= GoMage_Navigation_Model_Adminhtml_System_Config_Source_Category_Image_Position::getListPositionClass($image_position);
                     }
                 }
                 $html[] = '<li class="' . $li_class . '">';
                 $htmlA = '<a style="padding-left:' . 10 * ($category->getLevel() - ($this->_root_level + 1)) . 'px;" href="' . $this->getCategoryUrl($category) . '"' . $linkClass;
                 if ($this->getIsAjax()) {
                     $htmlA .= ' onclick="GomageNavigation.setNavigationUrl(\'' . $this->getAjaxUrl($category) . '\'); return false;" ';
                 }
                 $htmlA .= '>';
                 $html[] = $htmlA;
                 if ($navigation_image && in_array($image_position, array(GoMage_Navigation_Model_Adminhtml_System_Config_Source_Category_Image_Position::TOP, GoMage_Navigation_Model_Adminhtml_System_Config_Source_Category_Image_Position::LEFT))) {
                     $html[] = $navigation_image;
                 }
                 if (!($navigation_image && $category_view == GoMage_Navigation_Model_Adminhtml_System_Config_Source_Category_Attribute_View::IMAGE)) {
                     $html[] = '<span>' . $this->escapeHtml($category->getName()) . '</span>';
                 }
                 if ($navigation_image && in_array($image_position, array(GoMage_Navigation_Model_Adminhtml_System_Config_Source_Category_Image_Position::RIGHT, GoMage_Navigation_Model_Adminhtml_System_Config_Source_Category_Image_Position::BOTTOM))) {
                     $html[] = $navigation_image;
                 }
                 $html[] = '</a>';
                 $html[] = '</li>';
             }
             // render children
             $htmlChildren = '';
             $j = 0;
             foreach ($activeChildren as $child) {
                 $this->_childs_count++;
                 $htmlChildren .= $this->_renderCategoryMenuItemHtml($child, $level + 1, $j == $activeChildrenCount - 1, $j == 0, false, $outermostItemClass, $childrenWrapClass, $noEventAttributes);
                 $j++;
             }
             if (!empty($htmlChildren)) {
                 $html[] = $htmlChildren;
             }
             if ($category->getLevel() == $this->_root_level) {
                 if ($hasActiveChildren) {
                     $html[] = '</ul>';
                     $html[] = '</div>';
                     //gan-plain-items
                     if ($this->_offer_block_html && $category->getData('navigation_pw_ob_pos') != GoMage_Navigation_Model_Adminhtml_System_Config_Source_Category_Image_Position::TOP) {
                         $html[] = $this->_offer_block_html;
                     }
                     $html[] = '</div>';
                     //gan-plain
                 }
                 $html[] = '</li>';
             }
             break;
         case GoMage_Navigation_Model_Layer::FILTER_TYPE_FOLDING:
             $htmlLi = '<li';
             foreach ($attributes as $attrName => $attrValue) {
                 $htmlLi .= ' ' . $attrName . '="' . str_replace('"', '\\"', $attrValue) . '"';
             }
             $htmlLi .= '>';
             $html[] = $htmlLi;
             $htmlA = '<a href="' . $this->getCategoryUrl($category) . '"';
             $htmlA .= ' style="padding-left: ' . 10 * ($category->getLevel() - $this->_root_level) . 'px;" ';
             if ($this->getIsAjax()) {
                 $htmlA .= ' onclick="GomageNavigation.setNavigationUrl(\'' . $this->getAjaxUrl($category) . '\'); return false;" ';
             }
             if ($this->getIsActiveAjaxCategory($category) || $this->isCategoryActive($category)) {
                 $htmlA .= ' class="active" ';
             }
             $htmlA .= '>';
             $html[] = $htmlA;
             $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)) {
                 $html[] = $htmlChildren;
             }
             $html[] = '</li>';
             break;
         case GoMage_Navigation_Model_Layer::FILTER_TYPE_IMAGE:
             $htmlLi = '<li';
             foreach ($attributes as $attrName => $attrValue) {
                 $htmlLi .= ' ' . $attrName . '="' . str_replace('"', '\\"', $attrValue) . '"';
             }
             $htmlLi .= '>';
             $html[] = $htmlLi;
             $htmlA = '<a href="' . $this->getCategoryUrl($category) . '"';
             if ($this->getIsAjax()) {
                 $htmlA .= ' onclick="GomageNavigation.setNavigationUrl(\'' . $this->getAjaxUrl($category) . '\'); return false;" ';
             }
             if ($this->getIsActiveAjaxCategory($category) || $this->isCategoryActive($category)) {
                 $htmlA .= ' class="active" ';
             }
             $htmlA .= '>';
             $html[] = $htmlA;
             $image_url = $category->getData('filter_image');
             if ($image_url) {
                 $image_url = Mage::getBaseUrl('media') . '/catalog/category/' . $image_url;
                 if ($image_width = $this->getImageWidth()) {
                     $image_width = 'width="' . $image_width . '"';
                 } else {
                     $image_width = '';
                 }
                 if ($image_height = $this->getImageHeight()) {
                     $image_height = 'height="' . $image_height . '"';
                 } else {
                     $image_height = '';
                 }
                 $html[] = '<img ' . $image_width . ' ' . $image_height . ' title="' . $category->getName() . '" src="' . $image_url . '" alt="' . $category->getName() . '" />';
             }
             if ($this->canShowLabels()) {
                 $html[] = '<span>' . $this->escapeHtml($category->getName()) . '</span>';
             }
             $html[] = '</a>';
             $html[] = '</li>';
             break;
         case GoMage_Navigation_Model_Layer::FILTER_TYPE_DEFAULT_PRO:
             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;
             $htmlA = '<a href="' . $this->getCategoryUrl($category) . '"';
             if ($this->getIsAjax()) {
                 $htmlA .= ' onclick="GomageNavigation.setNavigationUrl(\'' . $this->getAjaxUrl($category) . '\'); return false;" ';
             }
             if ($this->isCategoryActive($category)) {
                 $htmlA .= ' class="active" ';
             }
             $htmlA .= '>';
             $html[] = $htmlA;
             $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>';
             break;
         case GoMage_Navigation_Model_Layer::FILTER_TYPE_ACCORDION:
             $linkClass = '';
             if ($isOutermost && $outermostItemClass) {
                 $linkClass = $outermostItemClass;
             }
             if ($this->getIsActiveAjaxCategory($category) || $this->isCategoryActive($category)) {
                 $linkClass .= ' active';
             }
             $linkClass = ' class="' . $linkClass . '" ';
             if ($category->getLevel() == $this->_root_level) {
                 $htmlLi = '<li';
                 foreach ($attributes as $attrName => $attrValue) {
                     $htmlLi .= ' ' . $attrName . '="' . str_replace('"', '\\"', $attrValue) . '"';
                 }
                 $htmlLi .= '>';
                 $html[] = $htmlLi;
                 $htmlA = '<a href="' . $this->getCategoryUrl($category) . '"' . $linkClass;
                 $htmlA .= ' onclick="ganShowAccordionItem(this);return false;" ';
                 $htmlA .= '>';
                 $html[] = $htmlA;
                 $html[] = '<span>' . $this->escapeHtml($category->getName()) . '</span>';
                 $html[] = '</a>';
                 if ($hasActiveChildren) {
                     $html[] = '<div class="gan-accordion-items">';
                 }
             } else {
                 if ($this->_childs_count == 1) {
                     $html[] = '<ul class="gan-accordion-item">';
                 }
                 $html[] = '<li>';
                 $htmlA = '<a href="' . $this->getCategoryUrl($category) . '"' . $linkClass;
                 if ($this->getIsAjax()) {
                     $htmlA .= ' onclick="GomageNavigation.setNavigationUrl(\'' . $this->getAjaxUrl($category) . '\'); return false;" ';
                 }
                 $htmlA .= '>';
                 $html[] = $htmlA;
                 $html[] = '<span>' . $this->escapeHtml($category->getName()) . '</span>';
                 $html[] = '</a>';
                 $html[] = '</li>';
             }
             // render children
             $htmlChildren = '';
             $j = 0;
             foreach ($activeChildren as $child) {
                 $this->_childs_count++;
                 $htmlChildren .= $this->_renderCategoryMenuItemHtml($child, $level + 1, $j == $activeChildrenCount - 1, $j == 0, false, $outermostItemClass, $childrenWrapClass, $noEventAttributes);
                 $j++;
             }
             if (!empty($htmlChildren)) {
                 $html[] = $htmlChildren;
             }
             if ($category->getLevel() == $this->_root_level) {
                 if ($hasActiveChildren) {
                     $html[] = '</ul>';
                     $html[] = '</div>';
                     //gan-accordion-items
                 }
                 $html[] = '</li>';
             }
             break;
         default:
             if ($this->_navigation_place == self::MENU_BAR) {
                 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>';
             } else {
                 $htmlLi = '<li';
                 foreach ($attributes as $attrName => $attrValue) {
                     $htmlLi .= ' ' . $attrName . '="' . str_replace('"', '\\"', $attrValue) . '"';
                 }
                 $htmlLi .= '>';
                 $html[] = $htmlLi;
                 $htmlA = '<a href="' . $this->getCategoryUrl($category) . '"';
                 $htmlA .= ' style="padding-left: ' . 10 * ($category->getLevel() - $this->_root_level) . 'px;" ';
                 if ($this->getIsAjax()) {
                     $htmlA .= ' onclick="GomageNavigation.setNavigationUrl(\'' . $this->getAjaxUrl($category) . '\'); return false;" ';
                 }
                 if ($this->getIsActiveAjaxCategory($category) || $this->isCategoryActive($category)) {
                     $htmlA .= ' class="active" ';
                 }
                 $htmlA .= '>';
                 $html[] = $htmlA;
                 $html[] = '<span>' . $this->escapeHtml($category->getName()) . '</span>';
                 $html[] = '</a>';
                 // render children
                 $htmlChildren = '';
                 $j = 0;
                 if ($this->getIsActiveAjaxCategory($category) || $this->getIsShowAllSubcategories()) {
                     foreach ($activeChildren as $child) {
                         $htmlChildren .= $this->_renderCategoryMenuItemHtml($child, $level + 1, $j == $activeChildrenCount - 1, $j == 0, false, $outermostItemClass, $childrenWrapClass, $noEventAttributes);
                         $j++;
                     }
                 } else {
                     foreach ($activeChildren as $child) {
                         if ($this->_getActiveChildren($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 '';
     }
     $html = array();
     // get all children
     $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->_navigation_place == self::MENU_BAR) {
         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);
     }
     switch ($this->getTypeNavigation()) {
         case GoMage_Navigation_Model_Layer::FILTER_TYPE_DROPDOWN:
             if ($this->getIsAjax()) {
                 $attributes['onchange'] = "setNavigationUrl(this.value); return false;";
             } else {
                 $attributes['onchange'] = "window.location=this.value";
             }
             $curent_id = 0;
             if (Mage::registry('current_category')) {
                 $curent_id = Mage::registry('current_category')->getId();
             }
             if ($category->getLevel() == $this->_root_level) {
                 $htmlSel = '<li><select';
                 foreach ($attributes as $attrName => $attrValue) {
                     $htmlSel .= ' ' . $attrName . '="' . str_replace('"', '\\"', $attrValue) . '"';
                 }
                 $htmlSel .= '>';
                 $html[] = $htmlSel;
                 $option_value = $this->getIsAjax() ? $this->getAjaxUrl($category) : $this->getCategoryUrl($category);
                 $html[] = '<option class="gan-dropdown-top" value="' . $option_value . '">' . (str_repeat('&nbsp;&nbsp;', $category->getLevel() - $this->_root_level) . $category->getName()) . '</option>';
             }
             $option_selected = $curent_id == $category->getId() ? 'selected="selected"' : '';
             $option_value = $this->getIsAjax() ? $this->getAjaxUrl($category) : $this->getCategoryUrl($category);
             $html[] = '<option ' . $option_selected . ' value="' . $option_value . '">' . (str_repeat('&nbsp;&nbsp;', $category->getLevel() - $this->_root_level) . $category->getName()) . '</option>';
             // 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)) {
                 $html[] = $htmlChildren;
             }
             if ($category->getLevel() == $this->_root_level) {
                 $html[] = '</select></li>';
             }
             break;
         case GoMage_Navigation_Model_Layer::FILTER_TYPE_PLAIN:
             $linkClass = '';
             if ($isOutermost && $outermostItemClass) {
                 $linkClass = $outermostItemClass;
             }
             if ($this->getIsActiveAjaxCategory($category) || $this->isCategoryActive($category)) {
                 $linkClass .= ' active';
             }
             $linkClass = ' class="' . $linkClass . '" ';
             if ($category->getLevel() == $this->_root_level) {
                 if ($hasActiveChildren && !$noEventAttributes) {
                     $attributes['onmouseover'] = 'toggleMenu(this,1)';
                     $attributes['onmouseout'] = 'toggleMenu(this,0)';
                 }
                 $htmlLi = '<li';
                 foreach ($attributes as $attrName => $attrValue) {
                     $htmlLi .= ' ' . $attrName . '="' . str_replace('"', '\\"', $attrValue) . '"';
                 }
                 $htmlLi .= '>';
                 $html[] = $htmlLi;
                 $htmlA = '<a href="' . $this->getCategoryUrl($category) . '"' . $linkClass;
                 if ($this->getIsAjax()) {
                     $htmlA .= ' onclick="setNavigationUrl(\'' . $this->getAjaxUrl($category) . '\'); return false;" ';
                 }
                 $htmlA .= '>';
                 $html[] = $htmlA;
                 $html[] = '<span>' . $this->escapeHtml($category->getName()) . '</span>';
                 $html[] = '</a>';
                 if ($hasActiveChildren) {
                     if ($this->_navigation_place == self::MENU_BAR) {
                         $_width = $category->getData('navigation_pw_width');
                     } else {
                         $_width = $category->getData('navigation_pw_side_width');
                     }
                     $gan_plain_style = ($this->_navigation_place == self::MENU_BAR ? 'background-color: ' . $this->getColumnColor() . ';' : '') . ($_width ? 'width: ' . $_width . 'px;' : '');
                     if ($gan_plain_style) {
                         $gan_plain_style = 'style="' . $gan_plain_style . '"';
                     }
                     $html[] = '<div ' . $gan_plain_style . ' class="gan-plain" >';
                     if (!($this->_navigation_place == self::MENU_BAR)) {
                         $html[] = '<span class="gan-plain-border"></span>';
                     }
                     $_add_style = '';
                     if ($this->_navigation_place == self::MENU_BAR) {
                         $navigation_image = $category->getData('navigation_image');
                         $navigation_image_position = $category->getData('navigation_image_position');
                         if ($navigation_image) {
                             $navigation_image = $this->getResizedImage($navigation_image, $category->getData('navigation_image_width'), $category->getData('navigation_image_height'));
                         }
                         if ($navigation_image) {
                             $_add_image_style = '';
                             if ($category->getData('navigation_image_width')) {
                                 $_add_image_style = 'width:' . $category->getData('navigation_image_width') . 'px;';
                             }
                             if ($category->getData('navigation_image_height')) {
                                 $_add_image_style .= 'height:' . $category->getData('navigation_image_height') . 'px;';
                             }
                             if ($_add_image_style) {
                                 $_add_image_style = 'style="' . $_add_image_style . '"';
                             }
                             $this->_plain_image = '<div class="' . GoMage_Navigation_Model_Adminhtml_System_Config_Source_Category_Image_Position::getPositionClass($navigation_image_position) . '">';
                             $this->_plain_image .= '<img ' . $_add_image_style . ' src="' . Mage::getBaseUrl('media') . "catalog/product/cache/cat_resized/" . $navigation_image . '" alt="' . $this->escapeHtml($category->getName()) . '" />';
                             $this->_plain_image .= '</div>';
                             $imageObj = new Varien_Image(Mage::getBaseDir('media') . DS . "catalog" . DS . "product" . DS . "cache" . DS . "cat_resized" . DS . $navigation_image);
                             switch ($navigation_image_position) {
                                 case GoMage_Navigation_Model_Adminhtml_System_Config_Source_Category_Image_Position::RIGHT:
                                     $_add_style = ' style="margin-right: ' . ((int) ($category->getData('navigation_image_width') ? $category->getData('navigation_image_width') : $imageObj->getOriginalWidth()) + 10) . 'px;" ';
                                     $html[] = $this->_plain_image;
                                     $this->_plain_image = '';
                                     break;
                                 case GoMage_Navigation_Model_Adminhtml_System_Config_Source_Category_Image_Position::TOP:
                                     $html[] = $this->_plain_image;
                                     $this->_plain_image = '';
                                     break;
                                 case GoMage_Navigation_Model_Adminhtml_System_Config_Source_Category_Image_Position::BOTTOM:
                                     break;
                                 default:
                                 case GoMage_Navigation_Model_Adminhtml_System_Config_Source_Category_Image_Position::LEFT:
                                     $_add_style = ' style="margin-left: ' . ((int) ($category->getData('navigation_image_width') ? $category->getData('navigation_image_width') : $imageObj->getOriginalWidth()) + 10) . 'px;" ';
                                     $html[] = $this->_plain_image;
                                     $this->_plain_image = '';
                                     break;
                             }
                         }
                     }
                     $html[] = '<div ' . $_add_style . ' class="gan-plain-items">';
                     $activeChildren = $this->sort_category($activeChildren);
                 }
             } else {
                 $_cat_column = null;
                 if ($category->getLevel() == $this->_root_level + 1) {
                     if ($this->_navigation_place == self::MENU_BAR) {
                         $_cat_column = $category->getData('navigation_column') ? $category->getData('navigation_column') : 1;
                     } else {
                         $_cat_column = $category->getData('navigation_column_side') ? $category->getData('navigation_column_side') : 1;
                     }
                 }
                 if ($this->_childs_count == 1 || $_cat_column && $_cat_column != $this->_current_column) {
                     $this->_current_column = $_cat_column;
                     $_with_percent = floor(100 / $this->_columns);
                     if ($this->_childs_count != 1) {
                         $html[] = '</ul>';
                     }
                     $html[] = '<ul style="width:' . $_with_percent . '%;" class="gan-plain-item">';
                 }
                 $html[] = '<li' . ($category->getLevel() == $this->_root_level + 1 ? ' class="gan-plain-item-bold" ' : '') . '>';
                 $htmlA = '<a style="padding-left: ' . 10 * ($category->getLevel() - ($this->_root_level + 1)) . 'px;" href="' . $this->getCategoryUrl($category) . '"' . $linkClass;
                 if ($this->getIsAjax()) {
                     $htmlA .= ' onclick="setNavigationUrl(\'' . $this->getAjaxUrl($category) . '\'); return false;" ';
                 }
                 $htmlA .= '>';
                 $html[] = $htmlA;
                 $html[] = '<span>' . $this->escapeHtml($category->getName()) . '</span>';
                 $html[] = '</a>';
                 $html[] = '</li>';
             }
             // render children
             $htmlChildren = '';
             $j = 0;
             foreach ($activeChildren as $child) {
                 $this->_childs_count++;
                 $htmlChildren .= $this->_renderCategoryMenuItemHtml($child, $level + 1, $j == $activeChildrenCount - 1, $j == 0, false, $outermostItemClass, $childrenWrapClass, $noEventAttributes);
                 $j++;
             }
             if (!empty($htmlChildren)) {
                 $html[] = $htmlChildren;
             }
             if ($category->getLevel() == $this->_root_level) {
                 if ($hasActiveChildren) {
                     $html[] = '</ul>';
                     $html[] = '</div>';
                     //gan-plain-items
                     if ($this->_plain_image) {
                         $html[] = $this->_plain_image;
                         $this->_plain_image = '';
                     }
                     $html[] = '</div>';
                     //gan-plain
                 }
                 $html[] = '</li>';
             }
             break;
         case GoMage_Navigation_Model_Layer::FILTER_TYPE_FOLDING:
             $htmlLi = '<li';
             foreach ($attributes as $attrName => $attrValue) {
                 $htmlLi .= ' ' . $attrName . '="' . str_replace('"', '\\"', $attrValue) . '"';
             }
             $htmlLi .= '>';
             $html[] = $htmlLi;
             $htmlA = '<a href="' . $this->getCategoryUrl($category) . '"';
             $htmlA .= ' style="padding-left: ' . 10 * ($category->getLevel() - $this->_root_level) . 'px;" ';
             if ($this->getIsAjax()) {
                 $htmlA .= ' onclick="setNavigationUrl(\'' . $this->getAjaxUrl($category) . '\'); return false;" ';
             }
             if ($this->getIsActiveAjaxCategory($category) || $this->isCategoryActive($category)) {
                 $htmlA .= ' class="active" ';
             }
             $htmlA .= '>';
             $html[] = $htmlA;
             $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)) {
                 $html[] = $htmlChildren;
             }
             $html[] = '</li>';
             break;
         case GoMage_Navigation_Model_Layer::FILTER_TYPE_IMAGE:
             $htmlLi = '<li';
             foreach ($attributes as $attrName => $attrValue) {
                 $htmlLi .= ' ' . $attrName . '="' . str_replace('"', '\\"', $attrValue) . '"';
             }
             $htmlLi .= '>';
             $html[] = $htmlLi;
             $htmlA = '<a href="' . $this->getCategoryUrl($category) . '"';
             if ($this->getIsAjax()) {
                 $htmlA .= ' onclick="setNavigationUrl(\'' . $this->getAjaxUrl($category) . '\'); return false;" ';
             }
             if ($this->getIsActiveAjaxCategory($category) || $this->isCategoryActive($category)) {
                 $htmlA .= ' class="active" ';
             }
             $htmlA .= '>';
             $html[] = $htmlA;
             $image_url = $category->getData('filter_image');
             if ($image_url) {
                 $image_url = Mage::getBaseUrl('media') . '/catalog/category/' . $image_url;
                 if ($image_width = $this->getImageWidth()) {
                     $image_width = 'width="' . $image_width . '"';
                 } else {
                     $image_width = '';
                 }
                 if ($image_height = $this->getImageHeight()) {
                     $image_height = 'height="' . $image_height . '"';
                 } else {
                     $image_height = '';
                 }
                 $html[] = '<img ' . $image_width . ' ' . $image_height . ' title="' . $category->getName() . '" src="' . $image_url . '" alt="' . $category->getName() . '" />';
             }
             if ($this->canShowLabels()) {
                 $html[] = '<span>' . $this->escapeHtml($category->getName()) . '</span>';
             }
             $html[] = '</a>';
             $html[] = '</li>';
             break;
         case GoMage_Navigation_Model_Layer::FILTER_TYPE_DEFAULT_PRO:
             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;
             $htmlA = '<a href="' . $this->getCategoryUrl($category) . '"';
             if ($this->getIsAjax()) {
                 $htmlA .= ' onclick="setNavigationUrl(\'' . $this->getAjaxUrl($category) . '\'); return false;" ';
             }
             if ($this->isCategoryActive($category)) {
                 $htmlA .= ' class="active" ';
             }
             $htmlA .= '>';
             $html[] = $htmlA;
             $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>';
             break;
         default:
             if ($this->_navigation_place == self::MENU_BAR) {
                 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="children_class">';
                     // }
                     $html[] = '<ul class="level' . $level . '">';
                     $html[] = $htmlChildren;
                     $html[] = '</ul>';
                     //  if ($childrenWrapClass) {
                     $html[] = '</div>';
                     //   }
                 }
                 $html[] = '</li>';
             } else {
                 $htmlLi = '<li';
                 foreach ($attributes as $attrName => $attrValue) {
                     $htmlLi .= ' ' . $attrName . '="' . str_replace('"', '\\"', $attrValue) . '"';
                 }
                 $htmlLi .= '>';
                 $html[] = $htmlLi;
                 $htmlA = '<a href="' . $this->getCategoryUrl($category) . '"';
                 $htmlA .= ' style="padding-left: ' . 10 * ($category->getLevel() - $this->_root_level) . 'px;" ';
                 if ($this->getIsAjax()) {
                     $htmlA .= ' onclick="setNavigationUrl(\'' . $this->getAjaxUrl($category) . '\'); return false;" ';
                 }
                 if ($this->getIsActiveAjaxCategory($category) || $this->isCategoryActive($category)) {
                     $htmlA .= ' class="active" ';
                 }
                 $htmlA .= '>';
                 $html[] = $htmlA;
                 $html[] = '<span>' . $this->escapeHtml($category->getName()) . '</span>';
                 $html[] = '</a>';
                 // render children
                 $htmlChildren = '';
                 $j = 0;
                 if ($this->getIsActiveAjaxCategory($category) || $this->getIsShowAllSubcategories()) {
                     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;
 }
Exemple #19
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;
    }
Exemple #20
0
 public function testGetChildren()
 {
     $this->_model->load(3);
     $this->assertEquals('4', $this->_model->getChildren());
 }
Exemple #21
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;
 }
Exemple #22
0
 /**
  * Return child categories
  *
  * @param Mage_Catalog_Model_Category $category
  * @return Mage_Catalog_Model_Resource_Category_Collection
  */
 public function getChildrenCategories($category)
 {
     $collection = $category->getCollection();
     /* @var $collection Mage_Catalog_Model_Resource_Category_Collection */
     $collection->addAttributeToSelect('url_key')->addAttributeToSelect('name')->addAttributeToSelect('all_children')->addAttributeToSelect('is_anchor')->addAttributeToFilter('is_active', 1)->addIdFilter($category->getChildren())->setOrder('position', Varien_Db_Select::SQL_ASC)->joinUrlRewrite()->load();
     return $collection;
 }
 /**
  * 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;
 }