<?php
/**
 * 留言求片插件
 *
 */
class ckplayer_plu extends plugin{

    /**
     * 插件名称
     *
     * @var unknown_type
     */
    public $name = 'ckplayer';

    /**
     * 插件类型 (HOOK位置)
     *
     * @var unknown_type
     */
    public $ctype = 1;

    /**
     * 注册钩子
     *
     * @var unknown_type
     */
    public $hook = array(
        1   => 'show'
    );
    
    /**
     * 插件配置信息
     *
     * @var unknown_type
     */
    public $info = array(
        'author'    => 'ReGinX',
        'supurl'    => 'http://www.reginx.com',
        'ver'       => '1.0',
        'conf'      => false
    );
    
    public function conf(){
        if(is_file(DATA_PATH . 'ckplayer.lock') && defined('PLUGIN_EXEC')){
            $this->mod->assign("player" , $this->get(1));
            $this->mod->assign('atitle' , 'ckplayer播放器配置');
            $this->mod->display('plugin@ckplayer:admin/conf.html');
        }
        $this->mod->showmsg('尚未安装!');
    }
    
    /**
     * 播放
     *
     */
    public function show(){
        if(defined('PLUGIN_EXEC')){
            $param = func_get_args();
            $this->mod->assign('vod' , $param[0]);
            $this->mod->assign('ads' , $param[1]);
            echo($this->mod->fetchtpl('plugin@ckplayer:player.html' , false));
        }
    }

    /**
     * 管理
     *
     * @param unknown_type $exec
     */
    public function cp(){
        $this->conf();
    }

    /**
     * 安装
     *
     * @param unknown_type $exec
     * @return unknown
     */
    public function install(){
        if(!is_file(DATA_PATH . 'ckplayer.lock') &&  defined('PLUGIN_EXEC')){
            file_put_contents(DATA_PATH . 'ckplayer.lock' , 'ReGinX.com');
            return true;
        }
        return false;
    }

    /**
     * 卸载
     *
     * @param unknown_type $exec
     * @return unknown
     */
    public function uninstall(){
        if(is_file(DATA_PATH . 'ckplayer.lock') && defined('PLUGIN_EXEC')){
            unlink(DATA_PATH . 'ckplayer.lock');
            return true;
        }
        return false;
    }
}
?>