adv_query_search.smarty
5.36 KB
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
<h2>{i18n}Search Criteria Editor{/i18n}</h2>
<p class="descriptiveText">
{i18n}The search criteria editor allows you to utilise the full power of the search engine by allowing you to perform more complicated searches by using the free text criteria format.{/i18n}
{capture assign=options}
<a href="{$rootUrl}/search2.php?action=guiBuilder">{i18n}Advanced Search{/i18n}</a>
{/capture}
<p>
{i18n arg_options=$options}The #options# may also be used to perform searches.{/i18n}
<P>
<div>
<table>
<tr>
<td valign=top>
<fieldset>
{if $txtQuery == ''}
{assign var=txtQuery value="Title contains \"something\" or \nMetadata contains \"else\""}
{/if}
{literal}
<script>
var parseSuccess = true;
var actionAfterParse = 'none';
var gotSearchParseStatus = function callBack(o)
{
if (o.responseText != '{}')
{
var resp = eval('(' + o.responseText + ')');
var butSearch = document.getElementById('butSearch');
if (resp.status == 0)
{
parseSuccess = true;
if (actionAfterParse == 'none')
{
alert('{/literal}{i18n}The expression parsed successfully.{/i18n}{literal}');
}
else if (actionAfterParse == 'search')
{
var frmQuery = document.getElementById('frmQuery');
frmQuery.submit();
}
else if (actionAfterParse == 'save')
{
actionAfterParse = 'saveCompleted';
var txtQuery = document.getElementById('txtAdvQuery');
url='{/literal}{$rootUrl}{literal}/search2/ajax/saveExpr.php?iSavedId={/literal}{$iSavedSearchId}{literal}';
//alert(url);
Ext.Ajax.request(
{
url: url,
method: 'GET',
success:gotSearchParseStatus,
failure:gotNoStatus,
params: {
txtQuery: txtQuery.value
}
});
}
else if (actionAfterParse == 'saveCompleted')
{
$('saved').style.display='block';
}
}
else
{
if (actionAfterParse == 'none' || actionAfterParse == 'save')
{
alert('{/literal}{i18n}There is a problem with the expression.{/i18n}{literal}\n\n' + resp.message );
}
else if (actionAfterParse == 'saveCompleted')
{
alert('{/literal}{i18n}There is a problem saving the expression.{/i18n}{literal}\n\n' + resp.message );
}
parseSuccess = false;
}
}
}
var gotNoStatus = function callBack(o)
{
alert('{/literal}{i18n}There is a problem communicating with the server.{/i18n}{literal}' + o.responseText);
}
function startParsing()
{
if (!parseSuccess)
{
alert('{/literal}{i18n}There has been a parsing problem. Please check the search expression.{/i18n}{literal}');
return;
}
var txtQuery = document.getElementById('txtAdvQuery');
url='{/literal}{$rootUrl}{literal}/search2/ajax/parseExpr.php';
Ext.Ajax.request(
{
url: url,
method: 'GET',
success:gotSearchParseStatus,
failure:gotNoStatus,
params: {
txtQuery: txtQuery.value
}
});
}
function butParseClick()
{
actionAfterParse = 'none';
parseSuccess = true;
startParsing();
}
function butClearClick()
{
var txtQuery = document.getElementById('txtAdvQuery');
txtQuery.value = '';
}
function butSearchClick()
{
actionAfterParse = 'search';
startParsing();
}
function butSaveClick()
{
actionAfterParse = 'save';
startParsing();
}
function txtQueryChange(el)
{
if($('saved') != null){
$('saved').style.display='none';
}
}
</script>
{/literal}
<legend>{i18n}Advanced Query{/i18n}</legend>
<form id=frmQuery name=frmQuery method="POST" action="{addQS}action=process{/addQS}">
<textarea id="txtAdvQuery" name="txtQuery" cols=50 rows=10 onkeypress="txtQueryChange(this)">{$txtQuery}</textarea>
<br/>
<input type="button" id="butSearch" value="{i18n}Search{/i18n}" onclick="butSearchClick()"/>
<input type="button" value="{i18n}Parse{/i18n}" onclick="butParseClick(true)"/>
<input type="reset" value="{i18n}Reset{/i18n}" />
<input type="button" value="{i18n}Clear{/i18n}" onclick="butClearClick()"/>
</form>
</div>
</fieldset>
{if $bSave}
<fieldset>
<legend>{i18n}Save{/i18n}</legend>
{i18n}You are currently editing the saved search:{/i18n}{$edtSaveQueryName}<br/>
<table>
<tr><td><input type="button" align="right" value="{i18n}Save{/i18n}" onclick="butSaveClick()"/>
<td><div id="saved" style="display: none"><font color=brown>{i18n}Saved{/i18n}</font></div>
</table>
</td>
</div>
</fieldset>
{/if}
</td>
<td valign=top>
<fieldset>
<legend>{i18n}Grammar{/i18n}</legend>
{i18n}Criteria may be built up using the following grammar:{/i18n}<br/>
expr ::= expr {literal}{{/literal} AND | OR {literal}}{/literal} expr<br/>
expr ::= NOT expr<br/>
expr ::= (expr)<br/>
expr ::= field {literal}{ < | <= | = | > | >= | CONTAINS |STARTS WITH | ENDS WITH }{/literal} value<br/>
expr ::= field BETWEEN value AND value<br/>
expr ::= field DOES [ NOT ] CONTAIN value<br/>
expr ::= field IS [ NOT ] LIKE value<br/>
value ::= "{i18n}search text here{/i18n}"
</fieldset>
<p class="descriptiveText">
{literal}
<script>
function wordclicked(word)
{
var sq = document.getElementById('txtAdvQuery');
if (sq.value != '') sq.value += ' ';
sq.value += word + ' ';
}
</script>
{/literal}
<fieldset>
<legend>{i18n}Fields{/i18n}</legend>
{i18n}The following fields may be used in search criteria:{/i18n}
{assign var=i value=0}
{foreach item=alias from=$aliases}
{if (substr($alias,0,2) != '["')}
{if $i>0}, {/if}
{if (($i % 8) == 0)}<br>{/if}
<span onclick="wordclicked('{$alias|escape}')">{$alias}</span>
{assign var=i value=$i+1}
{/if}
{/foreach}
</fieldset>
</p>
</td>
</tr>
</table>