adv_search.naml
<macro name="adv_search_page" requires="servlet">
<n.node_page.>
<n.catch_exception. id="set-block">
<n.if.is_submitted_form>
<then>
<n.redirect_to.page_node.>
<n.search_path>
<query>
<n.compress.>
<n.set_message_text_contains_group/>
<n.set_message_subject_contains_group/>
<n.set_author_name_group/>
<n.set_any_message_part_contains_group/>
</n.compress.>
</query>
<days>
<n.get_int. default="0" exception="days_field_not_integer">
<n.get_parameter name="days" />
</n.get_int.>
</days>
</n.search_path>
</n.redirect_to.page_node.>
</then>
</n.if.is_submitted_form>
</n.catch_exception.>
<n.html>
<head>
<meta name="robots" content="noindex,nofollow"/>
<n.title.><t>Advanced Search</t></n.title.>
<style type="text/css">
div.group-header {
padding: .2em;
margin-top:1em;
font-size: 120%;
font-weight: bold;
}
td.form-label {
white-space: nowrap;
}
</style>
</head>
<body>
<n.adv_search_exceptions/>
<h1><t>Advanced Search</t></h1>
<p><t>Use the options below to precisely specify your search criteria.</t></p>
<n.form.>
<table class="advanced-search-table">
<n.message_text_contains_group/>
<n.message_subject_contains_group/>
<n.author_name_group/>
<n.any_message_part_contains_group/>
<n.message_date_group/>
<n.submit_button/>
</table>
</n.form.>
</body>
</n.html>
</n.node_page.>
</macro>
<macro name="adv_search_exceptions">
<n.format_error.handle_exception. for="set-block">
<n.exception. name="days_field_not_integer">
<t>Invalid number of days, must be integer.</t>
</n.exception.>
</n.format_error.handle_exception.>
</macro>
<macro name="set_message_text_contains_group">
<n.adv_search_and_query name="messageand" field="message" />
<n.adv_search_or_query name="messageor" field="message" />
<n.adv_search_phrase_query name="messagephrase" field="message" />
<n.adv_search_not_query name="messagenot" field="message" />
</macro>
<macro name="set_message_subject_contains_group">
<n.adv_search_and_query name="subjectand" field="subject" />
<n.adv_search_or_query name="subjector" field="subject" />
<n.adv_search_phrase_query name="subjectphrase" field="subject" />
<n.adv_search_not_query name="subjectnot" field="subject" />
</macro>
<macro name="set_author_name_group">
<n.adv_search_phrase_query name="authorphrase" field="author" />
<n.adv_search_not_phrase_query name="authorphrasenot" field="author" />
</macro>
<macro name="set_any_message_part_contains_group">
<n.get_parameter name="alland" />
<n.adv_search_or_query name="allor" />
<n.adv_search_phrase_query name="allphrase" />
<n.adv_search_not_query name="allnot" />
</macro>
<macro name="message_text_contains_group">
<tr>
<td colspan="2">
<div class="shaded-bg-color rounded second-font group-header">
<t>Message text contains</t>
</div>
</td>
</tr>
<tr>
<td class="form-label"><t>all of the words:</t></td>
<td><n.adv_search_input name="messageand" /></td>
</tr>
<tr>
<td class="form-label"><t>at least one of the words:</t></td>
<td><n.adv_search_input name="messageor" /></td>
</tr>
<tr>
<td class="form-label"><t>the exact phrase:</t></td>
<td><n.adv_search_input name="messagephrase" /></td>
</tr>
<tr>
<td class="form-label end-group"><t>none of the words:</t></td>
<td class="end-group"><n.adv_search_input name="messagenot" /></td>
</tr>
</macro>
<macro name="message_subject_contains_group">
<tr>
<td colspan="2">
<div class="shaded-bg-color rounded second-font group-header">
<t>Message subject contains</t>
</div>
</td>
</tr>
<tr>
<td class="form-label"><t>all of the words:</t></td>
<td><n.adv_search_input name="subjectand" /></td>
</tr>
<tr>
<td class="form-label"><t>at least one of the words:</t></td>
<td><n.adv_search_input name="subjector" /></td>
</tr>
<tr>
<td class="form-label"><t>the exact phrase:</t></td>
<td><n.adv_search_input name="subjectphrase" /></td>
</tr>
<tr>
<td class="form-label end-group"><t>none of the words:</t></td>
<td class="end-group"><n.adv_search_input name="subjectnot" /></td>
</tr>
</macro>
<macro name="author_name_group">
<tr>
<td colspan="2">
<div class="shaded-bg-color rounded second-font group-header">
<t>Author name</t>
</div>
</td>
</tr>
<tr>
<td class="form-label"><t>is:</t></td>
<td><n.adv_search_input name="authorphrase" /></td>
</tr>
<tr>
<td class="form-label end-group"><t>is not:</t></td>
<td class="end-group"><n.adv_search_input name="authorphrasenot" /></td>
</tr>
</macro>
<macro name="any_message_part_contains_group">
<tr>
<td colspan="2">
<div class="shaded-bg-color rounded second-font group-header">
<t>Any message part contains</t>
</div>
</td>
</tr>
<tr>
<td class="form-label"><t>all of the words:</t></td>
<td><n.adv_search_input name="alland" /></td>
</tr>
<tr>
<td class="form-label"><t>at least one of the words:</t></td>
<td><n.adv_search_input name="allor" /></td>
</tr>
<tr>
<td class="form-label"><t>the exact phrase:</t></td>
<td><n.adv_search_input name="allphrase" /></td>
</tr>
<tr>
<td class="form-label end-group"><t>none of the words:</t></td>
<td class="end-group"><n.adv_search_input name="allnot" /></td>
</tr>
</macro>
<macro name="message_date_group">
<tr>
<td colspan="2">
<div class="shaded-bg-color rounded second-font group-header">
<t>Message date</t>
</div>
</td>
</tr>
<tr>
<td class="form-label end-group"><t>is within the last:</t></td>
<td><input name="days" size="5" value="[n.hide_if. equals='0'][n.hide_null.get_parameter name='days' /][/n.hide_if.]" /> <t>days</t></td>
</tr>
</macro>
<macro name="submit_button">
<tr>
<td></td>
<td style="padding-top:.5em">
<input type="submit" class="toolbar action-button" value="[t]Search[/t]"/>
</td>
</tr>
</macro>
<macro name="adv_search_input" parameters="name">
<input name="[n.name/]" type="text" style="width:370px;" value="[n.hide_null.get_parameter.name/]"/>
</macro>
<macro name="adv_search_and_query" parameters="name,field">
<n.regex_replace_all. pattern='(".+?"|[^ "]+)' replacement="[n.field/]:$0"><n.get_parameter name="[n.name/]" /></n.regex_replace_all.>
</macro>
<macro name="remove_double_quotes" dot_parameter="text">
<n.regex_replace_all. pattern='"' replacement=""><n.text/></n.regex_replace_all.>
</macro>
<macro name="adv_search_phrase_query" parameters="name,field">
<n.set_var. name="value"><n.trim.remove_double_quotes.get_parameter name="[n.name/]" /></n.set_var.>
<n.if.not.is_empty.var name="value">
<then>
<n.hide_null.append text="[n.field/]" suffix=":" />"<n.var name="value" />"
</then>
</n.if.not.is_empty.var>
</macro>
<macro name="adv_search_or_query" parameters="name,field">
<n.set_var. name="value"><n.trim.get_parameter name="[n.name/]" /></n.set_var.>
<n.set_var. name="field"><n.hide_null.append text="[n.field/]" suffix=":" /></n.set_var.>
<n.if.not.is_empty.var name="value">
<then>
<n.regex. pattern='(".+?"|[^ "]+)' text="[n.var name='value'/]">
<n.no_output.next_element/>
<n.if.not.has_more_elements>
<then>
<n.var name="field"/><n.current_element/>
</then>
<else>
<n.var name="field"/>(<n.current_element/>
<n.loop.>
<n.nop/> OR <n.current_element/>
</n.loop.>)
</else>
</n.if.not.has_more_elements>
</n.regex.>
</then>
</n.if.not.is_empty.var>
</macro>
<macro name="adv_search_not_query" parameters="name,field">
<n.if.not.is_empty.trim.get_parameter name="[n.name/]">
<then>
NOT <n.adv_search_or_query name="[n.name/]" field="[n.field/]" />
</then>
</n.if.not.is_empty.trim.get_parameter>
</macro>
<macro name="adv_search_not_phrase_query" parameters="name,field">
<n.if.not.is_empty.trim.get_parameter name="[n.name/]">
<then>
NOT <n.adv_search_phrase_query name="[n.name/]" field="[n.field/]" />
</then>
</n.if.not.is_empty.trim.get_parameter>
</macro>