<?php
/**
 * 模板管理模块
 * @copyright reginx.com
 * $Id$
 */
class tpl_mod extends admin_mod {
    
    /**
     * 列表页
     *
     */
    public function listAct(){
        $this->nocache();
        $this->assign('tpls' , tpl_lib::getlist());
        clearstatcache();
        $appconf = include(DATA_PATH . 'config.ini.php');
        $this->assign('tpl' , $appconf['tpl']);
        $this->assign('atitle' , '模板管理');
        $this->display('tpl/list.html');
    }
    
    
    public function useAct(){
        $tpl  = $this->get('code');
        $tpls = tpl_lib::getlist();
        if(isset($tpls[$tpl])){
            config_lib::mod('tpl' , $tpl);
            $this->showmsg('操作成功' , core::url('tpl-list') , 1 , 3);
        }else{
            $this->showmsg('该模板不可用');
        }
    }
    
    /**
     * 模板安装 
     *
     */
    public function updateAct(){
        $name = $this->get('code');
        if(preg_match('/^\w+$/i' , $name)){
            $ret = tpl_lib::update(strtolower($name));
            $this->showmsg('操作成功' , null , 1 , 1);
        }
        $this->showmsg('未找到该模板');
    }
    
    /**
     * 模板安装 
     *
     */
    public function insAct(){
        $name = $this->get('code');
        if(preg_match('/^\w+$/i' , $name)){
            $ret = tpl_lib::install(strtolower($name));
            $this->showmsg($ret['msg'] , null , 1 , 1);
        }
        $this->showmsg('未找到该模板');
    }
    
    /**
     * 模板卸载
     *
     */
    public function uninsAct(){
        $name = $this->get('code');
        if(preg_match('/^\w+$/i' , $name)){
            $ret = tpl_lib::uninstall(strtolower($name));
            $this->showmsg($ret['msg'] , null , 1 , 1);
        }
        $this->showmsg('未找到该模板');
    }
}// End Class
?>