contentEx=array('Meting_Plugin','playerReplace'); Typecho_Plugin::factory('Widget_Abstract_Contents')->excerptEx=array('Meting_Plugin','playerReplace'); Typecho_Plugin::factory('Widget_Archive')->header=array('Meting_Plugin','header'); Typecho_Plugin::factory('Widget_Archive')->footer=array('Meting_Plugin','footer'); Typecho_Plugin::factory('admin/write-post.php')->bottom = array('Meting_Plugin', 'addButton'); Typecho_Plugin::factory('admin/write-page.php')->bottom = array('Meting_Plugin', 'addButton'); } /** * 禁用插件方法,如果禁用失败,直接抛出异常 * * @static * @access public * @return void * @throws Typecho_Plugin_Exception */ public static function deactivate(){ Meting_Plugin::uninstall(); Helper::removeRoute("Meting_Route"); } /** * 获取插件配置面板 * * @access public * @param Typecho_Widget_Helper_Form $form 配置面板 * @return void */ public static function config(Typecho_Widget_Helper_Form $form){ $t = new Typecho_Widget_Helper_Form_Element_Radio( 'cloudapi', array('true'=>_t('是'),'false'=>_t('否')),'false', _t('METO 云解析 (beta)'), _t('当插件无法正常工作时,可以勾选开启。歌单混播、音质调节将失效')); $form->addInput($t); $t = new Typecho_Widget_Helper_Form_Element_Text( 'theme', null, '#ad7a86', _t('播放器颜色'), _t('播放器默认的主题颜色,支持如 #372e21、#75c、red,该设定会被[Meting]标签中的theme属性覆盖,默认为 #ad7a86')); $form->addInput($t); $t = new Typecho_Widget_Helper_Form_Element_Text( 'height', null, '340px', _t('播放器列表最大高度'), _t('')); $form->addInput($t); $t = new Typecho_Widget_Helper_Form_Element_Radio( 'autoplay', array('true'=>_t('是'),'false'=>_t('否')),'false', _t('全局自动播放'), _t('')); $form->addInput($t); $t = new Typecho_Widget_Helper_Form_Element_Radio( 'mode', array('circulation'=>_t('循环'),'single'=>_t('单曲'),'order'=>_t('列表'),'random'=>_t('随机')),'circulation', _t('全局播放模式'), _t('')); $form->addInput($t); $t= new Typecho_Widget_Helper_Form_Element_Radio( 'preload', array('auto'=>_t('自动'),'none'=>_t('不加载'),'metadata'=>_t('加载元数据')), 'auto', _t('预加载属性'), _t('')); $form->addInput($t); $t= new Typecho_Widget_Helper_Form_Element_Radio( 'bitrate', array('128'=>_t('流畅品质'),'192'=>_t('清晰品质'),'320'=>_t('高品质')), '192', _t('默认音质'), _t('')); $form->addInput($t); } public static function personalConfig(Typecho_Widget_Helper_Form $form){} /** * 获取插件配置面板 * * @access public * @param Typecho_Widget_Helper_Form $form 配置面板 * @return void */ public static function header(){ $dir=Helper::options()->pluginUrl.'/Meting/assets/'; $ver=METING_VERSION; echo "\n"; echo "\n"; if(Typecho_Widget::widget('Widget_Options')->plugin('Meting')->cloudapi){ echo "\n"; } echo "\n"; } public static function footer(){ if(Typecho_Widget::widget('Widget_Options')->plugin('Meting')->cloudapi){ echo "\n"; } } public static function getPID(){ return ++self::$PID; } public static function playerReplace($data,$widget,$last){ $text=empty($last)?$data:$last; if($widget instanceof Widget_Archive){ $data=$text; $pattern=self::get_shortcode_regex(array('Meting')); $text=preg_replace_callback("/$pattern/",array('Meting_Plugin','parseCallback'),$data); } return $text; } public static function parseCallback($matches){ $setting=self::shortcode_parse_atts(htmlspecialchars_decode($matches[3])); $matches[5]=htmlspecialchars_decode($matches[5]); $pattern=self::get_shortcode_regex(array('Music')); preg_match_all("/$pattern/",$matches[5],$all); if(sizeof($all[3]))return Meting_Plugin::parseMusic($all[3],$setting); } public static function parseMusic($matches,$setting){ $data=array(); foreach($matches as $vo){ $t=self::shortcode_parse_atts(htmlspecialchars_decode($vo)); if(!in_array($t['server'],array('netease','tencent','xiami','baidu','kugou')))continue; if(!in_array($t['type'],array('search','album','playlist','artist','song')))continue; $data[]=$t; } $id=self::getPID(); $dir=Typecho_Common::url('MetingAPI',Helper::options()->index); if(Typecho_Widget::widget('Widget_Options')->plugin('Meting')->cloudapi){ $str="