<?php
Yii::import('zii.widgets.CMenu');
 
class IIMenu extends CMenu
{
    // centering menu items
    public $centerItems = false;
    
    public $menuCssClass = 'mainMenu';
    public $activeCssClass = 'active';
	public $centeringCssClass = 'center';
    
    public function init()
    {
        // $cssFile; ??????
		parent::init();
	}

    /**
     * Recursively renders the menu items.
     * @param array $items the menu items to be rendered recursively
     */
    protected function renderMenu($items)
    {
        $menuClasses = array($this->menuCssClass);
        
        // Add CSS centering class if required
        if($this->centerItems){
        	$menuClasses[] = $this->centeringCssClass;
        }
        
        
        echo "\n" . CHtml::openTag('ul', array('class' => implode(' ', $menuClasses)))."\n";
                
        foreach($items as $item){
                         
			$options = array();
            if($item['active']){
            	$options['class'] = $this->activeCssClass;
            }            
            echo "\t" . CHtml::openTag('li', $options);
            
            $image = ModuleManager::getIconForModule($item['name'], '3x', 'sectionIcon');

            // Image and title as link
            echo CHtml::link(
                $image . "<span class='sectionLabel'>" . __($item['label']) . "</span>",
                $item['url'],
                array(
                    'id'=>$item['id'],
                    'data-translation-id' => $item['label'],
                )
            );
            
            echo CHtml::closeTag('li')."\n";
        }
        echo CHtml::closeTag('ul')."\n";
    }
}
