19 include_once($ROOT_PATH.
'wysiwyg_plugin.inc');
33 class Replace_Text
extends WYSIWYG_Plugin
44 function replace_text()
46 $this->_add_button(
'replacetext',
'ReplaceText',
'Replace Text',
'false',
'11');
57 function print_plugin_button_click()
61 this._popupDialog(
"ReplaceText",
"<?php echo $this->get_popup_href('replace_text.php')?>", 440, 520,
true,
function(types){
62 if (types == null)
return false;
65 var selected_html = types[0];
66 if (types[0] && editor.getSelectedHTML().length != 0) {
68 var curHTML = editor.getSelectedHTML();
71 curHTML = curHTML.replace(/\r\n/g,
"");
73 }
else if (!types[0]) {
74 selected_html =
false;
75 var curHTML = editor.getHTML();
77 alert(
"Selected text is not defined. Replace Text action aborted.");
83 var tags = curHTML.match(/<(?!\/)[^>]+>/g);
84 for(var i=0; i<tags.length; i++) {
86 curHTML = curHTML.replace(tag, tag.replace(/(\s[^\s<>=
"'`]+\s*=\s*)([^\s<>"\
'`]+)/g, '$1
"$2"'));
90 var HTMLtags = "!--|a|abbr|above|acronym|address|applet|array|area|b|base|basefont|bdo|bgsound|big|blink|blockquote|body|box|br|blink|button|caption|center|cite|code|col|colgroup|comment|dd|del|dfn|dir|div|dl|dt|em|embed|fieldset|fig|font|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|hr|html|i|id|iframe|ilayer|img|input|ins|isindex|kbd|label|layer|legend|li|link|listing|map|marquee|menu|meta|multicol|nextid|nobr|noframes|nolayer|note|noscript|object|ol|option|keygen|optgroup|p|param|pre|q|quote|range|root|s|samp|script|select|small|sound|spacer|span|sqrt|strike|strong|style|sub|sup|table|tbody|td|text|textarea|tfoot|th|thead|title|tr|tt|u|ul|var|wbr|xmp";
91 var bullet = unescape("%B7");
92 var shy = unescape("%AD");
93 for (var i=1;i<types.length;i++)
96 // Bug #3204 - Remove Word Document HTML Clipboard Tags, that get pasted through on Firefox 3
97 localreg = new RegExp("<link rel=\"[^\"]*\" href=\"file[^\"]*\">", "gi");
99 curHTML = curHTML.replace(localreg, localrep);
100 wordreg = new RegExp("<w\:[^>]*>(.*?)<\/w\:[^>]*>", "gi");
103 curHTML = curHTML.replace(wordreg, wordrep);
106 reg = new RegExp("<\/?font ?[^>]*>", "gi");
111 //#3827 -- using regexp literal
112 reg = /(\s| ){2,}/gi;
117 reg = new RegExp("<(?!(\/?(" + HTMLtags + ")[> ]))([^>]*)>", "gi");
122 reg = new RegExp("<p[^>]*>("+bullet+"|·\;)(.*?)<\/p>", "gi");
127 reg = new RegExp("(­?|"+shy+")", "gi");
132 reg = new RegExp(" style=\"?[^\">]*\"?", "gi");
137 reg = new RegExp(" class=\"?[^\">]*[\"]?", "gi");
142 reg = new RegExp("<(table|/table|tr|tbody|/tbody|td|th) ?[^>]*>", "gi");
144 curHTML = curHTML.replace(reg, rep);
145 reg = new RegExp("<(/tr|/td|/th)>", "gi");
150 reg = new RegExp("<\/?span( [^>]*>|>)", "gi");
155 reg = new RegExp("<([A-Z][A-Z0-9]*)( [^>]*)?>( | |\n|\t)*<\/\\1>", "gi");
160 reg = new RegExp('<([^/ >]+)[^>]*?([^>]*?( (src|href)=
"?[^>"]*
"?)[^>]*?)*[^>]*?>', "gi
");
164 default : return false;
166 // BUG#928 - special condition to allow empty anchor tag
168 reg2 = new RegExp("(<A NAME[^>]*?>)( | |\n|\t)*(</A>)
", "gi
");
169 rep2 = "$1matrix_anchor_tmp$3
"
170 curHTML = curHTML.replace(reg2, rep2);
171 reg2 = new RegExp("(<A ID[^>]*?>)( | |\n|\t)*(</A>)
", "gi
");
172 rep2 = "$1matrix_anchor_tmp$3
"
173 curHTML = curHTML.replace(reg2, rep2);
175 curHTML = curHTML.replace(reg, rep);
177 reg3 = new RegExp("(<A NAME[^>]*?>)matrix_anchor_tmp(</A>)
", "gi
");
179 curHTML = curHTML.replace(reg3, rep3);
180 reg3 = new RegExp("(<A ID[^>]*?>)matrix_anchor_tmp(</A>)
", "gi
");
182 curHTML = curHTML.replace(reg3, rep3);
186 if (types.length>0) {
187 editor.insertHTML(curHTML);
190 if (types.length>0) editor.setHTML(curHTML);
197 }//end print_plugin_button_click()