<?php
defined('WEKIT_VERSION') or exit(403);
Wind::import('SRV:forum.srv.threadDisplay.do.PwThreadDisplayDoBase');
/**
* 帖子内容展示
*
* @author 兰度 <love@medz.cn>
* @copyright http://www.medz.cn
* @license http://www.medz.cn
*/
class App_MediaurlPwThreadDisplayDo extends PwThreadDisplayDoBase {
/*
* @see PwThreadDisplayDoBase
*/
public function __construct() {

}

public function bulidRead($read) {
$wordFilter = Wekit::load('SRV:word.srv.PwWordFilter');
$service = Wekit::load('config.PwConfig');
$config = $service->getValues('mediaurl');
$content = $read['subject']. '<wind>' .$read['content'];
if ($config[lock] == '1') {

if ($config[youku] == '1') {
//youku	
$content = preg_replace('/<a[^>]*href=\"http:\/\/v.youku.com\/v_show\/id_(.*?).html(.*?)\"(.*?)\>(.*?)<\/a>/i',"<embed src=\"http://player.youku.com/player.php/sid/$1/v.swf\" allowFullScreen=\"true\" quality=\"high\" width=\"575\" height=\"460\" align=\"middle\" allowScriptAccess=\"always\" type=\"application/x-shockwave-flash\"></embed>",$content,-1,$count);
}

if ($config[tudou] == '1') {
//tudou
$content = preg_replace('/<a[^>]*href=\"http:\/\/www.tudou.com\/programs\/view\/([\w\-]+)\/?(.*?)\"(.*?)\>(.*?)<\/a>/i',"<embed src=\"http://www.tudou.com/v/$1/&resourceId=0_04_02_99/v.swf\" allowFullScreen=\"true\" quality=\"high\" width=\"575\" height=\"460\" align=\"middle\" allowScriptAccess=\"always\" type=\"application/x-shockwave-flash\"></embed>",$content);
$content = preg_replace('/<a[^>]*href=\"http:\/\/www.tudou.com\/albumplay\/(.*?).html(.*?)\"(.*?)\>(.*?)<\/a>/i',"<embed src=\"http://www.tudou.com/a/$1/&resourceId=0_04_02_99/v.swf\" allowFullScreen=\"true\" quality=\"high\" width=\"575\" height=\"460\" align=\"middle\" allowScriptAccess=\"always\" type=\"application/x-shockwave-flash\"></embed>",$content);
$content = preg_replace('/<a[^>]*href=\"http:\/\/www.tudou.com\/listplay\/(.*?).html(.*?)\"(.*?)\>(.*?)<\/a>/i',"<embed src=\"http://www.tudou.com/l/$1/&resourceId=0_04_02_99/v.swf\" allowFullScreen=\"true\" quality=\"high\" width=\"575\" height=\"460\" align=\"middle\" allowScriptAccess=\"always\" type=\"application/x-shockwave-flash\"></embed>",$content);
}
 
if ($config[_56] == '1') {
//56
$content = preg_replace('/<a[^>]*href=\"http:\/\/www.56.com\/u(.*?)\/v_(.*?).html(.*?)\"(.*?)\>(.*?)<\/a>/i',"<embed src=\"http://player.56.com/v_\${2}.swf\" allowFullScreen=\"true\" quality=\"high\" width=\"575\" height=\"460\" align=\"middle\" allowScriptAccess=\"always\" type=\"application/x-shockwave-flash\"></embed>",$content);
$content = preg_replace('/<a[^>]*href=\"http:\/\/www.56.com\/w(.*?)\/play_album\-aid\-\d+_vid\-(.*?).html(.*?)\"(.*?)\>(.*?)<\/a>/i',"<embed src=\"http://player.56.com/v_\${2}.swf\" allowFullScreen=\"true\" quality=\"high\" width=\"575\" height=\"460\" align=\"middle\" allowScriptAccess=\"always\" type=\"application/x-shockwave-flash\"></embed>",$content);
}
if ($config[ku6] == '1') {
//ku6
$content = preg_replace('/<a[^>]*href=\"http:\/\/v.ku6.com\/show\/(.*?).html(.*?)\"(.*?)\>(.*?)<\/a>/i',"<embed src=\"http://player.ku6.com/refer/\${1}/v.swf\" allowFullScreen=\"true\" quality=\"high\" width=\"575\" height=\"460\" align=\"middle\" allowScriptAccess=\"always\" type=\"application/x-shockwave-flash\"></embed>",$content);
$content = preg_replace('/<a[^>]*href=\"http:\/\/v.ku6.com\/special\/show_(.*?)\/(.*?).html(.*?)\"(.*?)\>(.*?)<\/a>/i',"<embed src=\"http://player.ku6.com/refer/\${2}/v.swf\" allowFullScreen=\"true\" quality=\"high\" width=\"575\" height=\"460\" align=\"middle\" allowScriptAccess=\"always\" type=\"application/x-shockwave-flash\"></embed>",$content);
}
if ($config[yinyuetai] == '1') {
//yinyuetai
$content = preg_replace('/<a[^>]*href=\"http:\/\/v.yinyuetai.com\/video\/(\d+)\/?(.*?)\"(.*?)\>(.*?)<\/a>/i',"<embed src=\"http://player.yinyuetai.com/video/player/\${1}/v_0.swf\" allowFullScreen=\"true\" quality=\"high\" width=\"575\" height=\"460\" align=\"middle\" allowScriptAccess=\"always\" type=\"application/x-shockwave-flash\"></embed>",$content);
$content = preg_replace('/<a[^>]*href=\"http:\/\/v.yinyuetai.com\/playlist\/(\d+)\/?(.*?)\"(.*?)\>(.*?)<\/a>/i',"<embed src=\"http://player.yinyuetai.com/playlist/player/\${1}/v_0.swf\" allowFullScreen=\"true\" quality=\"high\" width=\"575\" height=\"460\" align=\"middle\" allowScriptAccess=\"always\" type=\"application/x-shockwave-flash\"></embed>",$content);
}
}	
$content = $wordFilter->replaceWord($content, $read['word_version']);
if ($content === false) return $read;
list($read['subject'], $read['content']) = explode('<wind>', $content);
return $read;
}

protected function _getThreadService() {
return Wekit::load('forum.PwThread');
}
private function _loadConfigService() {
return Wekit::load('config.PwConfig');
}

}

?>