<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of TabPage
 *
 * @author Administrator
 */
class TabPage {
    private $ci;
    public function __construct() {
        $this->ci =& get_instance();
        $this->ci->load->library('parser');

        //$CI->load->library('Memcached');
        //$this->mc = $CI->memcached;
    }
    
    /**
     * 
     * @param type $menus
     * @param type $curPage
     * @param type $rightBtns array(array(url=>'',name=>''))
     * @return null
     */
    public function generate($menus,$curPage,$rightBtns=array()) {
        if(count($menus)){
            foreach ($menus as $key => &$value) {
                $value['itemOn'] = $key==$curPage?'itemOn':'';
            }
            $data = array('menus'=>$menus,'rightBtns'=>$rightBtns);
            return $this->ci->parser->parse_string($this->template(),$data , TRUE);
        } else {
            return null;
        }
        //$this->parser->parse_string();
    }
    
    private function  template() {
        return '<div class="titleTabB clearfix">
                        <dl class="list">
                        {menus}
                            <dd class="item {itemOn}"> <a href="{url}" class="link"> {name}</a> </dd>
                        {/menus}
                        {rightBtns}
                        <dd class="itemRight"><a style="background:none;color:#3887f2;" target="_blank" class="link" href="{url}">{name}</a></dd>
                        {/rightBtns}
                        </dl>
                    </div>';
    }
}

?>
