File: search_replace.tmpl

package info (click to toggle)
movabletype-opensource 4.2.3-1%2Blenny3
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 21,268 kB
  • ctags: 15,862
  • sloc: perl: 178,892; php: 26,178; sh: 161; makefile: 82
file content (296 lines) | stat: -rw-r--r-- 15,167 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
<mt:setvarblock name="page_title"><__trans phrase="Search &amp; Replace"></mt:setvarblock>
<mt:setvarblock name="html_head" append="1">
    <script type="text/javascript">
    /* <![CDATA[ */
    var tableSelect;
    function init()
    {
    	// setup
        tableSelect = new TC.TableSelect( "<$mt:var name="object_type"$>-listing-table" );
        tableSelect.rowSelect = true;
    <mt:unless name="have_results">
    	getByID('search').focus();
    </mt:unless>
    }

    TC.attachLoadEvent( init );

    function toggleVisibility(c, s) {
        var e = getByID(s);
        if (e) {
            if (c.checked) e.style.display = 'block';
            if (!c.checked) e.style.display = 'none';
        }
    }

    function toggleSearchAndReplace(selection) {
    	var s = getByID('search-bar-search-field');
    	var r = getByID('search-bar-replace-fields');
    	var sa = getByID('search-bar-advanced-search');
    	var ra = getByID('search-bar-advanced-replace');
    	if (s && r) {
    		if (selection.value == 'search') {
    			s.style.display = 'block';
    			sa.style.display = 'block';
    			r.style.display = 'none';
    			ra.style.display = 'none';
    		} else if (selection.value == 'replace') {
    			r.style.display = 'block';
    			ra.style.display = 'block';
    			s.style.display = 'none';
    			sa.style.display = 'none';
    		}
    	}
    }

    function reSearch(type) {
        if (type && (document.search_form['_type'].value != type)) {
            if (document.search_form['orig_search'] && 
                document.search_form['orig_search'].value != '') {
                document.search_form['do_search'].value = '1';
            }
            document.search_form['_type'].value = type;
            document.search_form.submit();
        }
        return false;
    }

    function unLimit(newLimit) {
        document.search_form['limit'].value = newLimit;
        document.search_form['do_search'].value = '1';
        document.search_form.submit();
        return false;
    }

    function doSearch() {
        document.search_form['limit'].value = '';
        document.search_form['do_search'].value = '1';
        document.search_form.submit();
    }

    function doReplace() {
        // gather ids from checked items listed and put them in the
        // hidden 'id' field in the search form
        var ids = new Array();
        var div = TC.elementOrId("<$mt:var name="object_type"$>-listing");
        var inputs = TC.getElementsByTagAndClassName('input', 'select', div);
        for (var i = 0; i < inputs.length; i++) {
            if (inputs[i].checked) {
                if (inputs[i].value != 'all')
                    ids[ids.length] = inputs[i].value;
            }
        }
        if (ids.length) {
            document.search_form['replace_ids'].value = ids.join(',');
            document.search_form['do_replace'].value = '1';
            document.search_form.submit();
        } else {
            alert("<__trans phrase="You must select one or more item to replace.">");
        }
        return false;
    }

    function focusDateFields(s) {
    	var dateFields = new Array(getByID('datefrom_year'),getByID('datefrom_month'),getByID('datefrom_day'),getByID('dateto_year'),getByID('dateto_month'),getByID('dateto_day'));
    	var datesDisbaled = getByID('dates-disabled');

    	if (datesDisbaled && (datesDisbaled.value == 1)) {
    		for (var i = 0; i < dateFields.length; i++) {
    			dateFields[i].value = '';
    			dateFields[i].style.color = '#000';
    		}
    		datesDisbaled.value = 0;
    	}
    }

    function blurDateFields(s) {
    	var dateFields = new Array(getByID('datefrom_year'),getByID('datefrom_month'),getByID('datefrom_day'),getByID('dateto_year'),getByID('dateto_month'),getByID('dateto_day'));
    	var datesDisbaled = getByID('dates-disabled');
    	var allEmpty = 1;

    	if (datesDisbaled && (datesDisbaled.value == 0)) {
    		for (var i = 0; i < dateFields.length; i++) {
    			if (dateFields[i].value != "") {
    				allEmpty = 0;
    			}
    		}

    		if (allEmpty) {
    			for (var i = 0; i < dateFields.length; i++) {
    				if ((i == 0) || (i == 3)) dateFields[i].value = 'YYYY';
    				if ((i == 1) || (i == 4)) dateFields[i].value = 'MM';
    				if ((i == 2) || (i == 5)) dateFields[i].value = 'DD';
    				dateFields[i].style.color = '#999';
    			}
    			datesDisbaled.value = 1;
    		}
    	}
    }
    /* ]]> */
    </script>
</mt:setvarblock>
<mt:include name="include/header.tmpl">

<div id="search-form">
    <form name="search_form" method="post" action="<mt:var name="script_url">">
    <input type="hidden" name="__mode" value="search_replace" />
    <input type="hidden" name="_type" value="<mt:var name="object_type">" />
    <input type="hidden" name="limit" value="<mt:unless name="limit_all"><mt:var name="limit" escape="html"></mt:unless>" />
<mt:if name="blog_id">
    <input type="hidden" name="blog_id" value="<mt:var name="blog_id">" />
</mt:if>
<mt:if name="entry_type">
    <input type="hidden" name="entry_type" value="<mt:var name="entry_type" escape="html">" />
</mt:if>
<mt:if name="searched"><mt:if name="search">
    <input type="hidden" name="orig_search" value="<mt:var name="search" escape="html">" /></mt:if>
</mt:if>
    <input type="hidden" name="magic_token" value="<mt:var name="magic_token">" />
    <input type="hidden" name="return_args" value="<mt:if name="search">search=<mt:var name="search" escape="html">&amp;</mt:if><mt:var name="return_args" escape="html">" />
    <input type="hidden" name="replace_ids" value="" />
    <input type="hidden" name="do_search" value="" />
    <input type="hidden" name="do_replace" value="" />

<div class="tabs">
    <ul><mt:loop name="search_tabs">
        <li<mt:if name="object_type" eq="$key"> class="yah"</mt:if> id="results-<mt:var name="key" escape="html">-tab"><a href="javascript:void(0)" onclick="reSearch('<mt:var name="key" escape="js">'); return false"><span><mt:var name="label" escape="html"></span></a></li>
    </mt:loop></ul>
</div>

<div class="search-bar">
    <div class="search-bar-inner">

<mt:if name="have_results">
    <mt:if name="can_replace">
        <div class="search-bar-toggle">
            <label for="search-replace-toggle-search"><input type="radio" id="search-replace-toggle-search" name="search-replace-toggle" value="search" checked="checked" class="rb" onclick="toggleSearchAndReplace(this)" /> <__trans phrase="Search Again"></label>
            &nbsp;
            <label for="search-replace-toggle-replace"><input type="radio" id="search-replace-toggle-replace" name="search-replace-toggle" value="replace" class="rb" onclick="toggleSearchAndReplace(this)" /> <__trans phrase="Search &amp; Replace"></label>
        </div>
    </mt:if>
</mt:if>

        <div id="search-bar-search-field" class="pkg">
            <input name="search" id="search" value="<mt:var name="search" escape="html">" />
            <div class="search-button-wrapper">
                <button
                    onclick="doSearch()"
                    type="submit"
                    accesskey="s"
                    title="<__trans phrase="Submit search (s)">"
                    id="search-button"
                    class="big-button primary-button"
                    ><__trans phrase="Search"></button>
            </div>
        </div>

<mt:if name="have_results">
        <div id="search-bar-replace-fields" style="display: none;">
            <div class="search-bar-replace-wrapper pkg">
                <div class="search-bar-replace-label"><label for="search-alt"><__trans phrase="Search"></label></div>
                <div class="search-bar-replace-field"><input name="search-alt" id="search-alt" value="<mt:var name="search" escape="html">" disabled="disabled" /></div>
            </div>
            <div class="search-bar-replace-wrapper pkg">
                <div class="search-bar-replace-label"><label for="replace"><__trans phrase="Replace"></label></div>
                <div class="search-bar-replace-field">
                    <input name="replace" id="replace" value="<mt:var name="replace" escape="html">" />
                    <button
                        onclick="doReplace(); return false"
                        type="submit"
                        id="replace-button"
                        class="big-button primary-button"
                        ><__trans phrase="Replace Checked"></button>
                </div>
            </div>
        </div>
</mt:if>

        <div id="search-bar-advanced-search">
            <label for="case"><input type="checkbox" id="case" name="case" value="1"<mt:if name="case"> checked="checked"</mt:if> class="cb" /> <__trans phrase="Case Sensitive"></label>
            &nbsp;
            <label for="is_regex"><input type="checkbox" id="is_regex" name="is_regex" value="1"<mt:if name="is_regex"> checked="checked"</mt:if> class="cb" /> <__trans phrase="Regex Match"></label>
            &nbsp;
            <label for="is_limited"><input type="checkbox" id="is_limited" name="is_limited" value="1"<mt:if name="is_limited"> checked="checked"</mt:if> class="cb" onclick="toggleVisibility(this, 'limited-fields')" /> <__trans phrase="Limited Fields"></label>
<mt:if name="can_search_by_date">
            &nbsp;
            <label for="is_dateranged"><input type="checkbox" id="is_dateranged" name="is_dateranged" value="1"<mt:if name="is_dateranged"> checked="checked"</mt:if> class="cb" onclick="toggleVisibility(this, 'date-range')" /> <__trans phrase="Date Range"></label>
</mt:if>
<mt:if name="can_search_junk">
            &nbsp;
            <label for="is_junk"><input type="checkbox" id="is_junk" name="is_junk" value="1"<mt:if name="is_junk"> checked="checked"</mt:if> class="cb" /> <__trans phrase="Reported as Spam?"></label>
</mt:if>
        </div>

<mt:if name="have_results">
        <div id="search-bar-advanced-replace">
            <label><input type="checkbox" name="replace-case" value="1"<mt:if name="case"> checked="checked"</mt:if> disabled="disabled" class="cb" /> <__trans phrase="Case Sensitive"></label>
            &nbsp;
            <label><input type="checkbox" name="replace-is_regex" value="1"<mt:if name="is_regex"> checked="checked"</mt:if> disabled="disabled" class="cb" /> <__trans phrase="Regex Match"></label>
            &nbsp;
            <label><input type="checkbox" name="replace-is_limited" value="1"<mt:if name="is_limited"> checked="checked"</mt:if> disabled="disabled" class="cb" /> <__trans phrase="Limited Fields"></label>
    <mt:if name="can_search_by_date">
            &nbsp;
            <label><input type="checkbox" name="replace-is_dateranged" value="1"<mt:if name="is_dateranged"> checked="checked"</mt:if> disabled="disabled" class="cb" /> <__trans phrase="Date Range"></label>
    </mt:if>
    <mt:if name="can_search_junk">
            &nbsp;
            <label><input type="checkbox" name="replace-is_junk" value="1"<mt:if name="is_junk"> checked="checked"</mt:if> disabled="disabled" class="cb" /> <__trans phrase="Reported as Spam?"></label>
    </mt:if>
        </div>
</mt:if>
    </div>
</div>

<div class="advanced-options" id="limited-fields"<mt:unless name="is_limited"> style="display: none;"</mt:unless>>
<mt:if name="search_cols">
    <div id="<mt:var name="object_type">-fields">
        <ul>
        <mt:loop name="search_cols">
            <mt:if name="__first__"><li class="first"><__trans phrase="Search Fields:"></li></mt:if>
            <li><label for="search_cols-<mt:var name="field" escape="html">"><input type="checkbox" id="search_cols-<mt:var name="field" escape="html">" name="search_cols" value="<mt:var name="field" escape="html">"<mt:if name="selected"> checked="checked"</mt:if> class="cb" /> <mt:var name="label" escape="html"></label></li>
        </mt:loop>
        </ul>
    </div>
</mt:if>
</div>

<div class="advanced-options" id="date-range"<mt:unless name="is_dateranged"> style="display: none;"</mt:unless>>
    <input type="hidden" name="dates-disabled" id="dates-disabled" value="<mt:if name="datefrom_year">0<mt:else>1</mt:if>" />
    <ul>
        <li class="first"><__trans phrase="Date Range">:</li>
        <li><label for="datefrom_year"><__trans phrase="_DATE_FROM">:</label> <input type="text" size="4" maxlength="4" value="<mt:if name="datefrom_year"><mt:var name="datefrom_year" escape="html"><mt:else>YYYY</mt:if>" name="datefrom_year" id="datefrom_year" onfocus="focusDateFields(this)" onblur="blurDateFields(this)"<mt:if name="datefrom_year"> class="prefilled"</mt:if> /> - <input type="text" size="2" maxlength="2" value="<mt:if name="datefrom_month"><mt:var name="datefrom_month" escape="html"><mt:else>MM</mt:if>" name="datefrom_month" id="datefrom_month" onfocus="focusDateFields(this)" onblur="blurDateFields(this)"<mt:if name="datefrom_month"> class="prefilled"</mt:if> /> - <input type="text" size="2" maxlength="2" value="<mt:if name="datefrom_day"><mt:var name="datefrom_day" escape="html"><mt:else>DD</mt:if>" name="datefrom_day" id="datefrom_day" onfocus="focusDateFields(this)" onblur="blurDateFields(this)"<mt:if name="datefrom_day"> class="prefilled"</mt:if> /></li>
        <li><label for="dateto_year"><__trans phrase="_DATE_TO">:</label> <input type="text" size="4" maxlength="4" value="<mt:if name="dateto_year"><mt:var name="dateto_year" escape="html"><mt:else>YYYY</mt:if>" name="dateto_year" id="dateto_year" onfocus="focusDateFields(this)" onblur="blurDateFields(this)"<mt:if name="dateto_year"> class="prefilled"</mt:if> /> - <input type="text" size="2" maxlength="2" value="<mt:if name="dateto_month"><mt:var name="dateto_month" escape="html"><mt:else>MM</mt:if>" name="dateto_month" id="dateto_month" onfocus="focusDateFields(this)" onblur="blurDateFields(this)"<mt:if name="dateto_month"> class="prefilled"</mt:if> /> - <input type="text" size="2" maxlength="2" value="<mt:if name="dateto_day"><mt:var name="dateto_day" escape="html"><mt:else>DD</mt:if>" name="dateto_day" id="dateto_day" onfocus="focusDateFields(this)" onblur="blurDateFields(this)"<mt:if name="dateto_day"> class="prefilled"</mt:if> /></li>
    </ul>
</div>

    </form>
</div>

<mt:if name="replace_count">
    <mtapp:statusmsg
        id="replace-count"
        class="success">
        <__trans phrase="Successfully replaced [quant,_1,record,records]." params="<mt:var name="replace_count">">
    </mtapp:statusmsg>
</mt:if>

<mt:if name="have_more">
<p><__trans phrase="Showing first [_1] results." params="<mt:var name="limit" escape="html">"> <a href="javascript:void(0)" onclick="return unLimit('all'); return false"><__trans phrase="Show all matches"></a></p>
<mt:else>
    <mt:if name="have_results">
<p><__trans phrase="[quant,_1,result,results] found" params="<mt:var name="count_matches">"></p>
    </mt:if>
</mt:if>

<mt:if name="searched" id="search_results">
<mt:ignore>Search results will be placed here from app code.</mt:ignore>
</mt:if>
<mt:if name="error">
    <mtapp:statusmsg
        id="generic-error"
        class="error">
        <mt:var name="error" escape="html">
    </mtapp:statusmsg>
</mt:if>

<mt:include name="include/footer.tmpl">