`
- 浏览:
49375 次
- 性别:
- 来自:
福州
-
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/** *//**
* @author zsy
*/
public final class Ubbcode ...{
private static final String imagePath = "images/"; // 定义图片路径
private static final String strIcons = "1";
private static final String picUrl = "edit/images/";
private static final String imgName = "edit/images/face/";
private static final String notePath = "http://www.richmap.com.cn/richmap4/api/tools/";
private static String ubbItem(String strContent, String re, String replayStr,
Pattern pattern, Matcher matcher, boolean IgnoreCase) ...{
pattern = Pattern.compile(re);
matcher = pattern.matcher(strContent);
strContent = matcher.replaceAll(replayStr);
if (IgnoreCase) ...{
pattern = Pattern.compile(re.toUpperCase());
matcher = pattern.matcher(strContent);
strContent = matcher.replaceAll(replayStr);
}
return strContent;
}
private static String quote(String strContent, Pattern pattern,
Matcher matcher, boolean IgnoreCase) ...{
String re = "(\[quote\])(.*?)(\[\/quote\])";
int start = strContent.lastIndexOf("[quote]");
int end = strContent.indexOf("[/quote]");
String subStr = null;
String newStr = null;
while (start != -1 && end != -1) ...{
subStr = strContent.substring(start, end + 8);
pattern = Pattern.compile(re);
matcher = pattern.matcher(subStr);
newStr = matcher.replaceAll("<TABLE style="BORDER-RIGHT: #cccccc 1px dotted; " +
"TABLE-LAYOUT: fixed; BORDER-TOP: #cccccc 1px dotted; BORDER-LEFT: " +
"#cccccc 1px dotted; BORDER-BOTTOM: #cccccc 1px dotted" cellSpacing=0 " +
"cellPadding=6 width=95% align=center border=0><TBODY><TR><TD " +
"style="WORD-WRAP: break-word;font-size:12px;" bgColor=#f3f3f3><FONT " +
"style="FONT-WEIGHT: bold; COLOR: #990000; font-size:12px;">***以下是引" +
"用***</FONT><HR width=95% style="border:1px dotted #cccccc "><center>" +
"$2</center></TD></TR></TBODY></TABLE>");
strContent = strContent.replace(subStr, newStr);
start = strContent.lastIndexOf("[quote]");
end = strContent.indexOf("[/quote]");
}
if (IgnoreCase) ...{
re = "(\[QUOTE\])(.*?)(\[\/QUOTE\])";
start = strContent.lastIndexOf("[QUOTE]");
end = strContent.indexOf("[/QUOTE]");
while (start != -1 && end != -1) ...{
subStr = strContent.substring(start, end + 8);
pattern = Pattern.compile(re);
matcher = pattern.matcher(subStr);
newStr = matcher.replaceAll("<TABLE style="BORDER-RIGHT: #cccccc 1px dotted; " +
"TABLE-LAYOUT: fixed; BORDER-TOP: #cccccc 1px dotted; BORDER-LEFT: " +
"#cccccc 1px dotted; BORDER-BOTTOM: #cccccc 1px dotted" cellSpacing=0 " +
"cellPadding=6 width=95% align=center border=0><TBODY><TR><TD " +
"style="WORD-WRAP: break-word;font-size:12px;" bgColor=#f3f3f3><FONT " +
"style="FONT-WEIGHT: bold; COLOR: #990000; font-size:12px;">***以下是引" +
"用***</FONT><HR width=95% style="border:1px dotted #cccccc "><center>" +
"$2</center></TD></TR></TBODY></TABLE>");
strContent = strContent.replace(subStr, newStr);
start = strContent.lastIndexOf("[QUOTE]");
end = strContent.indexOf("[/QUOTE]");
}
}
return strContent;
}
/** *//**
* @description 转换代码,使之支持ubbcode.
* @param strContent
* 转换前的代码.
* @return result 转换后的内容.
*/
public static String ubbCode(String strContent) ...{
strContent = dvHTMLEncode(strContent);
Pattern pattern = null;
Matcher matcher = null;
//随意贴
strContent = ubbItem(strContent,
"\[richmapfrm=(.[^\[]*)\](.+?)\[\/richmapfrm\]",
"<iframe src=" + notePath + "singleNote.jsp?w=600&h=480" +
"¬eid=$1 frameborder=0 marginheight=0 marginwidth=0 scrolling=no height=400 " +
"width=600 title=睿图随意贴,贴出你的故事,贴出你的心情 target=_blank><img src=" +
picUrl + "button/richiframe.gif border=0> $2</iframe>",
pattern, matcher, true);
strContent = ubbItem(strContent,
"\[richmap=(.[^\[]*)\](.+?)\[\/richmap\]",
"<a href=" + notePath + "myNote.jsp?¬eid=$1 " +
"title=睿图随意贴,贴出你的故事,贴出你的心情 target=_blank><img src=" + picUrl +
"button/richwindow.gif border=0>$2</a>",
pattern, matcher, true);
//转换IMG
strContent = ubbItem(strContent,
"\[img\](.+?)\[\/img\]",
"<a href="$1" target="_blank">" +
"<IMG SRC="$1" border="0" alt="按此在新窗口浏览图片" " +
"onload="javascript:if(this.width>600)this.width=600" " +
"galleryImg="no"></a>",
pattern, matcher, true);
//转换附件[FILE=路径,图片]名称[/FILE]
strContent = ubbItem(strContent,
"(\[file=(.[^\[]*),(.[^\[]*)\])(.*?)(\[\/file\])",
"<br><IMG SRC=$3 border=0><br> <a href=$2>$4</a>",
pattern, matcher, true);
//DIR
strContent = ubbItem(strContent,
"\[dir=*([0-9]*),*([0-9]*)\](.*?)\[\/dir]",
"<object classid=clsid:" +
"166B1BCA-3F9C-11CF-8075-444553540000 codebase=" +
"http://download.macromedia.com/pub/shockwave/cabs/director/" +
"sw.cab#version=7,0,2,0 width=$1 height=$2><param name=src " +
"value=$3><embed src=$3 pluginspage=http://www.macromedia.com/" +
"shockwave/download/ width=$1 height=$2></embed></object>",
pattern, matcher, true);
//QT
strContent = ubbItem(strContent,
"\[qt=*([0-9]*),*([0-9]*)\](.*?)\[\/qt]",
"<embed src=$3 width=$1 height=$2 " +
"autoplay=true loop=false controller=true playeveryframe=false " +
"cache=false scale=TOFIT bgcolor=#000000 kioskmode=false " +
"targetcache=false pluginspage=http://www.apple.com/quicktime/>",
pattern, matcher, true);
//MP
strContent = ubbItem(strContent,
"\[mp=*([0-9]*),*([0-9]*)\](.*?)\[\/mp]",
"<object align=middle classid=CLSID:" +
分享到:
Global site tag (gtag.js) - Google Analytics
相关推荐
一个实现了ubb代码的java类,并预留了扩展接口,便于你增加新的样式代码
ubb文件ubb文件ubb文件ubb文件ubb文件ubb文件ubb文件ubb文件ubb文件
UBB语法.txtUBB语法.txtUBB语法.txtUBB语法.txt
迷你UBBEditor在线编辑器 v1.0,具有体积小巧,兼容性好(支持IE6,7,8 Safari, Firefox, Chrome 等众多浏览器)、安全性高,用它产生的是UBB代码,如果在网页中输出显示时,需要通过服务器脚本来解析这些代码,还有...
增强版是加了下面这些功能.
UBB 论坛 6.04 汉化版
本站文章系统中使用的UBB标签转换引擎,有以下特点: 1. 性能极高,对全文只扫描一遍,且和UBB标签的种类数量无关,因此可以任意添加新的UBB标签而不必担心性能会下降 2. 容错性非常好,比如对于错误UBB语法"[b]你...
this is ubb ubb代码加注释
动网风格ubb 动网风格ubb 动网风格ubb
UBB_URL转换UBB_URL转换UBB_URL转换UBB_URL转换UBB_URL转换UBB_URL转换UBB_URL转换UBB_URL转换UBB_URL转换UBB_URL转换UBB_URL转换UBB_URL转换UBB_URL转换
UBB配置文件详细介绍
java ubbeditor 标签转换成 html标签输出。
在线编辑器 ubb插件 ubb 可以插入在网页上提供用户在线对文本编辑样式
Ubb简单编辑器
discuz的ubb编辑器discuz的ubb编辑器discuz的ubb编辑器
ubb编辑器整合thinkphp3.0的方法及所需的文档,因为之前公司项目需要,但是在网上一直没找到简洁明了的编辑器,或者是可以简洁的编辑但是不能用ubb,反复搜寻终于找到一款可以做成接口并且,参数都可以根据需要只...
此编辑器是根据discuz论坛(php 7.0)版UBB编辑器进行二次开发的,默认为所见即所得模式。本来没有打算进行二次开发的,但由于项目是.net,在网上搜了一大箩筐UBB编辑器都不怎么样,还是觉得discuz这个比较好,但这个...
C#的UBB代码,大家看一下
HTM与UBB互转
ubb函数代码