25 require_once dirname(__FILE__).
'/../../../../core/include/init.inc';
26 require_once SQ_LIB_PATH.
'/html_form/html_form.inc';
27 require_once SQ_FUDGE_PATH.
'/var_serialise/var_serialise.inc';
29 $_GET[
'name'] = array_get_index($_GET,
'name',
'');
33 <html style=
"width: 370px; height: 280px;">
36 <title>Search and Replace</title>
37 <script type=
"text/javascript" src=
"../../core/popup.js"></script>
38 <script type=
"text/javascript" src=
"<?php echo sq_web_path('fudge').'/var_serialise/var_serialise.js' ?>"></script>
39 <script type=
"text/javascript" src=
"<?php echo sq_web_path('lib').'/html_form/html_form.js' ?>"></script>
40 <script type=
"text/javascript" src=
"<?php echo sq_web_path('lib').'/js/general.js' ?>"></script>
42 <script type=
"text/javascript">
45 setTimeout(
'self.focus()',100);
49 __dlg_init(
"SearchAndReplace");
50 setTimeout(
'self.focus()',100);
53 function onOK(action_type) {
55 var search_str = document.getElementById(
"search_str").value;
56 var replace_str = document.getElementById(
"replace_str").value;
58 if (document.getElementById(
"rep_type4").checked) {
59 var confirm_str =
"WARNING!\nUnlike other match options, regular expression replacement will be applied to the actual html content, therefore appearance of the content may be affected and also the action cannot be undone.\nAre you sure you want to apply the replacement?";
61 var confirm_str =
"WARNING!\nAll the occurance of the search string will be replaced and the action cannot be undone.\nAre you sure you want to apply the replacement?";
64 if ((action_type !=
"replace_all" && action_type !=
"replace_selection") || confirm(confirm_str)) {
65 var parameter_types =
new Array();
67 parameter_types.push(action_type);
68 parameter_types.push(search_str);
69 parameter_types.push(replace_str);
72 while (document.getElementById(
"rep_type"+i) != null) {
73 parameter_types.push(document.getElementById(
"rep_type"+i++).checked);
77 __dlg_close(
"SearchAndReplace", parameter_types,
false);
83 function enableButtons() {
85 if (document.getElementById(
"search_str").value !=
'') {
87 if (!document.getElementById(
"rep_type4").checked) {
88 document.getElementById(
"search_previous").disabled =
false;
89 document.getElementById(
"search_next").disabled =
false;
90 document.getElementById(
"replace_current").disabled =
false;
92 document.getElementById(
"search_previous").disabled =
true;
93 document.getElementById(
"search_next").disabled =
true;
94 document.getElementById(
"replace_current").disabled =
true;
97 document.getElementById(
"replace_all").disabled =
false;
98 document.getElementById(
"replace_selection").disabled =
false;
101 document.getElementById(
"search_previous").disabled =
true;
102 document.getElementById(
"search_next").disabled =
true;
103 document.getElementById(
"replace_current").disabled =
true;
104 document.getElementById(
"replace_all").disabled =
true;
105 document.getElementById(
"replace_selection").disabled =
true;
109 function fixMatchTypeCheckboxes(type) {
110 match_types = Array(
'1',
'2',
'3',
'4');
112 if (document.getElementById(
"rep_type"+type).checked) {
113 for(index in match_types) {
114 rep_type = match_types[index];
115 if (rep_type != type) document.getElementById(
"rep_type"+rep_type).checked =
false;
123 function onCancel() {
124 __dlg_close(
"SearchAndReplace", null);
130 <style type=
"text/css">
134 font: 11px Tahoma,Verdana,sans-serif;
141 font: 11px Tahoma,Verdana,sans-serif;
152 border-bottom: 1px solid black;
158 padding: 0px 10px 5px 5px;
159 border-color: #725B7D;
162 .fl { width: 9em;
float: left; padding: 2px 5px; text-align: right; }
163 .fr { width: 7em;
float: left; padding: 2px 5px; text-align: right; }
166 form { padding: 0px; margin: 0px; }
168 select, input, button {
169 font: 11px Tahoma,Verdana,sans-serif;
178 <body onload=
"Init()">
180 <div
class=
"title">Search And Replace</div>
182 <form action=
"" method=
"get" name=
"Form1">
183 <table border=
"0" width=
"100%">
188 <legend><b>Search and replace
string</b></legend>
189 <table style=
"width:100%">
191 <td>Search
string</td>
192 <td><input type=
"text" name=
"search_str" id=
"search_str" size=
"45" onkeyup=
"enableButtons()">
195 <td>Replace
string</td>
196 <td><input type=
"text" name=
"replace_str" id=
"replace_str" size=
"45">
206 <legend><b>Replace options</b></legend>
207 <table style=
"width:100%">
210 <input type=
"checkbox" name=
"rep_type0" id=
"rep_type0" />
211 <label
for=
"rep_type0"> Match
case</label><br/>
213 <input type=
"checkbox" name=
"rep_type1" id=
"rep_type1" onClick=
"fixMatchTypeCheckboxes('1')" />
214 <label
for=
"rep_type1"> Match the whole word</label><br/>
216 <input type=
"checkbox" name=
"rep_type2" id=
"rep_type2" onClick=
"fixMatchTypeCheckboxes('2')" />
217 <label
for=
"rep_type2"> Match beginning of the word</label><br/>
219 <input type=
"checkbox" name=
"rep_type3" id=
"rep_type3" onClick=
"fixMatchTypeCheckboxes('3')" />
220 <label
for=
"rep_type2"> Match end of the word</label><br/>
222 <input type=
"checkbox" name=
"rep_type4" id=
"rep_type4" onClick=
"fixMatchTypeCheckboxes('4')" />
223 <label
for=
"rep_type3"> Regular expression match</label><br/>
233 <div style=
"text-align: center;">
235 <button type=
"button" disabled
id=
"search_next" name=
"search_next" onclick=
"if (!onOK('search_next')) return;">Search Next</button>
236 <button type=
"button" disabled
id=
"search_previous" name=
"search_previous" onclick=
"if (!onOK('search_previous')) return;">Search Previous</button>
237 <button type=
"button" disabled
id=
"replace_current" name=
"replace_current" onclick=
"if (!onOK('replace_current')) return;">Replace</button><br />
238 <button type=
"button" disabled
id=
"replace_all" name=
"replace_all" onclick=
"if (!onOK('replace_all')) return;">Replace All</button>
239 <button type=
"button" disabled
id=
"replace_selection" name=
"replace_selection" onclick=
"if (!onOK('replace_selection')) return;">In Selection</button>
241 <button type=
"button" name=
"cancel" onclick=
"window.close();">Cancel</button>