主要是针对不同的网上直接复制了的内容,有的适合ubb,有的适合html,所以设计了两个按钮
改动有:
editor/ubb/ubbeditor.js
editor/ubb/editordef.php
lang/zh-cn/backend.php
======================================================
editor/ubb/ubbeditor.js
======================================================
这个文件里主要是编辑器的函数定义,html转贴得主要函数我加到了这里:

function html_trans(str) {
str = str.replace(/\r/g,"");
str = str.replace(/on(load|click|dbclick|mouseover|mousedown|mouseup)="[^"]+"/ig,"");
str = str.replace(/<script[^>]*?>([\w\W]*?)<\/script>/ig,"");
str = str.replace(/<font([^>]+)color=([^ >]+)([^>]*)>(.*?)<\/font>/ig,"[color=$2]<font$1$3>$4</font>[/color]");
str = str.replace(/<font([^>]+)size=([^ >]+)([^>]*)>(.*?)<\/font>/ig,"[size=$2]<font$1$3>$4</font>[/size]");
str = str.replace(/<font[^>]+face=([^ >]+)[^>]*>(.*?)<\/font>/ig,"[font=$1]$2[/font]");
str = str.replace(/<img[^>]+src=[" ]?([^"]+)[" ]?[^>]*>/ig,"\n[img]$1[/img]\n");
str = str.replace(/<([\/]?)b>/ig,"[$1b]");
str = str.replace(/<([\/]?)strong>/ig,"[$1b]");
str = str.replace(/<([\/]?)u>/ig,"[$1u]");
str = str.replace(/<([\/]?)i>/ig,"[$1i]");
str = str.replace(/&nbsp;/g," ");
str = str.replace(/&amp;/g,"&");
str = str.replace(/&quot;/g,"\"");
str = str.replace(/&lt;/g,"<");
str = str.replace(/&gt;/g,">");
str = str.replace(/<br>/ig,"\n");
str = str.replace(/<p[^>]*?>/ig,"\n\n");
str = str.replace(/<[^>]*?>/g,"");
str = str.replace(/\[url=([^\]]+)\]\n(\[img\]\1\[\/img\])\n\[\/url\]/g,"$2");
str = str.replace(/\n+/g,"\n");

return str;
}

function trans(flag){//1:html,0:ubb
var str = "";
rtf.focus();
rtf.document.body.innerHTML = "";
rtf.document.execCommand("paste");
str = rtf.document.body.innerHTML;
if(str.length == 0) {
alert($lna[961]);
return "";
}
if(flag==0){return html_trans(str)}
return str;
}


==================================================
editor/ubb/editordef.php
==================================================
这个文件主要是ubb编辑器的布局
主要改了两处,第一处:

$onloadjs=" onload=\"init_ubb ('content');\"";
$editorbody=<<<eot

后添加:
<IFRAME id=rtf style="WIDTH: 0px; HEIGHT: 0px" marginWidth=0 marginHeight=0 src="about:blank" scrolling=no></IFRAME>
<SCRIPT>rtf.document.designMode="On";</SCRIPT>


然后添加:

<a href="JavaScript: void(0); "><IMG border=0 onclick=AddText(trans(0)) title="{$lna[959]}" src="editor/ubb/images/paste.gif" ></a>
<a href="JavaScript: void(0); "><IMG border=0 onclick=AddText(trans(1)) title="{$lna[960]}" src="editor/ubb/images/paste2.gif" ></a>



图标为:paste1.gif 和paste2.gif
=====================================================
lang/zh-cn/backend.php
=====================================================
给数组添加三个元素:
959=>'粘贴为ubb',
960=>'粘贴为html',
961=>'剪贴版不存在超文本数据!'
到此完成修改。


引用自: simple&clear|hill's blog|true-angel
Tags: , ,
X3 Homepage
2009/08/18 07:34
网站做的真好! 代孕网与贵站交换友情连接QQ:458649409
123
2007/12/16 09:41
sssssssssssss
分页: 1/1 第一页 1 最后页
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]