Blueimp 論壇首頁


列印 2024/4/20 下午 06:23:39

文章作者 jieh2007/10/25 下午 12:00:42
smile   怎样令mvnForum支持粘贴audio和video的功能
Demo见
http://www.funcrystal.com/forum/viewthread?thread=224


修改源码文件 net.myvietnam.mvncore.filter.URLFilter
在函数 filter(String)中,While循环结束前添加以下代码:
/*Added by Jing Xu, www.shorelinesolution.com . Process [aud] and [vid]*/
else if (cur == '[' && index < len - 6 && chars[i = index + 1] == 'a' &&chars[++i] == 'u' && chars[++i] == 'd' && chars[++i] == ']' ) {
//process [aud]
j = ++i;
int u1 = j-1;
int u2 = input.indexOf("[/aud]", u1 + 1);
if (u2 < 0) {
buf.append(chars, oldend, j - oldend);
oldend = j;
} else {
buf.append(chars, oldend, index - oldend);
buf.append("<embed src=\"");
String href = input.substring(u1 + 1, u2).trim();
// Add http:// to the front of links if and only if it doesn't have any protocols.
// Doing this handles this: "[aud=sun.com]SUN[/aud]"
// Changing it to <embed src="http://sun.com">SUN</embed>
// instead of <embed src="http://localhost:8080/mvnforum/sun.com">SUN</embed>
if (href.indexOf("://") == -1) {
href = "http://" + href;
}
if (href.indexOf("javascript:") == -1 && href.indexOf("file:") == -1) {
buf.append(Encoder.filterUrl(href));
}

buf.append("\" type=\"application/x-mplayer2\" pluginspage=\"http://www.microsoft.com/Windows/MediaPlayer/\" name=\"mediaplayer1\" showstatusbar=\"1\" EnableContextMenu=\"false\" autostart=\"true\" width=\"400\" height=\"50\" transparentstart=\"1\" loop=\"0\" controller=\"true\">");
oldend = u2 + 6; // 6 == length of [/aud]
}
index = oldend -1;// set to the last char of the tag, that is ']'

} else if (cur == '[' && index < len - 6 && chars[i = index + 1] == 'v' && chars[++i] == 'i' && chars[++i] == 'd' && chars[++i] == ']' ) {
//process [vid]
j = ++i;
int u1 = j-1;
int u2 = input.indexOf("[/vid]", u1 + 1);
if (u2 < 0) {
buf.append(chars, oldend, j - oldend);
oldend = j;
} else {
buf.append(chars, oldend, index - oldend);
buf.append("<embed src=\"");
String href = input.substring(u1 + 1, u2).trim();
// Add http:// to the front of links if and only if it doesn't have any protocols.
// Doing this handles this: "[vid=sun.com]SUN[/vid]"
// Changing it to <embed src="http://sun.com">SUN</embed>
// instead of <embed src="http://localhost:8080/mvnforum/sun.com">SUN</embed>
if (href.indexOf("://") == -1) {
href = "http://" + href;
}
if (href.indexOf("javascript:") == -1 && href.indexOf("file:") == -1) {
buf.append(Encoder.filterUrl(href));
}
buf.append("\" type=\"application/x-mplayer2\" pluginspage=\"http://www.microsoft.com/Windows/MediaPlayer/\" name=\"mediaplayer1\" showstatusbar=\"1\" EnableContextMenu=\"false\" autostart=\"true\" width=\"400\" height=\"400\" transparentstart=\"1\" loop=\"0\" controller=\"true\">");
oldend = u2 + 6; // 6 == length of [/vid]
}
index = oldend -1;// set to the last char of the tag, that is ']'
}//end if
/*--Added by Jing Xu, www.shorelinesolution.com Process [aud] and [vid]--*/

编译打包后覆盖原有的myvietnam.jar,这样你的论坛就可以支持粘贴以下代码了
[aud]http://yourAudioSite/audiofile.name[/aud]

[vid]http://yourVideoSite/videofile.name[/vid]

----------------------------------------
支持小惡魔
BTC : 19tn3RnCuwZVukXAwyhDWZD4uBgUZoGJPx
LTC : LTFa17pSvvoe3aU5jbmfcmEpo1xuGa9XeA
知識跟八卦一樣,越多人知道越有價值;知識最好的備份方法,散播!
藍色小惡魔(林永傑): 臉書