<metal:block use-macro="python:here.standard_template_macro('light')">
<metal:block fill-slot="body">

<fieldset style="width: 30%; float: right; background-color: #E9F1F8;">
<legend i18n:translate="">Search tips:</legend>
<div class="fieldset_div">
	<table cellpadding="2">
	<tr>
		<td valign="top" style="border: 1px dashed black;" i18n:translate="">fish <strong i18n:name="and">and</strong> biodiversity</td>
		<td valign="top" i18n:translate="">the two words occur in the document in any order but not necessarily together</td>
	</tr>
	<tr>
		<td valign="top" style="border: 1px dashed black;" i18n:translate="">fish <strong i18n:name="or">or</strong> biodiversity</td>
		<td valign="top" i18n:translate="">either of the words occur in the document</td>
	</tr>
	<tr>
		<td valign="top" style="border: 1px dashed black;" i18n:translate="">fish and <strong i18n:name="not">not</strong> biodiversity</td>
		<td valign="top" i18n:translate="">the word fish and not the word biodiversity occur</td>
	</tr>
	<tr>
		<td valign="top" style="border: 1px dashed black;"><tal:block i18n:translate="">bio</tal:block>*</td>
		<td valign="top" i18n:translate="">everything starting with <em i18n:name="bio" i18n:translate="">bio</em></td>
	</tr>
	</table>
</div>
</fieldset>

<h1>Search across multiple portals</h1>

<tal:block tal:define="query python:request.get('query', '');
	langs python:here.utConvertToList(request.get('langs', []));
	servers python:here.utConvertToList(request.get('servers', []));
	start python:request.get('start', 0);
	skey python:request.get('skey', 'title');
	rkey python:request.get('rkey', '');
	form_data here/getDataForExternalSearch;
	form_langs python:form_data[0];
	form_servers python:form_data[1];">

<form method="get" name="frmSearch" action="external_search_html">

<strong>Query string</strong>
<input type="text" name="query:utf8:ustring" id="query" tal:attributes="value query" size="40" maxLength="100" />

<div>
<fieldset><legend>Language(s)</legend>
	<tal:block tal:repeat="item form_langs">
		<input type="checkbox" name="langs" tal:attributes="value python:item[0]; checked python:item[0] in langs" /><span tal:content="python:item[1]" />
	</tal:block>
</fieldset>
</div>

<div>
<fieldset><legend>Server(s)</legend>
	<dl>
		<dt tal:repeat="item form_servers">
			<input type="checkbox" name="servers" tal:attributes="value item/url; checked python:item['url'] in servers" />
			<span tal:content="item/title" />
		</dt>
	</dl>
</fieldset>
</div>
<br style="clear:both;" />
<input type="submit" value="Search" />
</form>

<span tal:condition="python:request.has_key('query')">

<tal:block define="results python:here.externalSearch(servers, langs, query, skey, rkey, start);
	age here/getItemsAge; number_of_results here/getNumberOfResults;
	page_search_querystring python:'langs=%s&servers=%s&query=%s' % ('&langs='.join(langs), '&servers='.join(servers), query);
	list_paging python:results[0];
	paging_start python:list_paging[0];
	paging_upper python:list_paging[1];
	paging_total python:list_paging[2];
	paging_prev python:list_paging[3];
	paging_next python:list_paging[4];
	paging_current_page python:list_paging[5];
	paging_records_page python:list_paging[6];
	paging_pages python:list_paging[7];
	records python:results[1];
	sortdata python:({'sortable': 1, 'key': 'meta_type', 'label': 'Type'}, {'sortable': 1, 'key': 'title', 'label': 'Title/Abstract'}, {'sortable': 1, 'key': 'lang', 'label': 'Language'}, {'sortable': 1, 'key': 'time', 'label': 'Last updated'},)">
<tal:block tal:condition="python:paging_total != 0">
	<div>
		<strong i18n:translate="">Search Results</strong><br />
		<span i18n:translate="" tal:omit-tag="">Age:</span>
		<span tal:replace="python:here.external_get_items_age(records, age)"/>
		<span i18n:translate="" tal:omit-tag="">% are more then</span>
		<span tal:replace="age"/>
		<span i18n:translate="" tal:omit-tag="">month(s) old</span>
	</div>
	<table class="sortable" border="0" width="100%">
		<thead>
			<tr>
				<tal:block tal:repeat="item sortdata">
					<th tal:condition="python:not item['sortable']" scope="col"><span title="Not sortable" i18n:attributes="title" i18n:translate="" tal:content="item/label" /></th>
					<tal:block tal:condition="item/sortable">
						<tal:block tal:condition="python:skey==item['key']">
							<th tal:condition="python:rkey==''" class="sorted" scope="col">
								<a title="Sorted A..Z - Click to reverse" rel="nofollow" tal:attributes="href string:${here/absolute_url}/external_search_html?skey=${item/key}&amp;rkey=1&amp;start=${paging_start}&amp;${page_search_querystring}" i18n:attributes="title"><span i18n:translate="" tal:omit-tag="" tal:content="item/label" /><img src="misc_/Naaya/sort_asc.gif" width="12" height="12" alt="" /></a>
							</th>
							<th tal:condition="python:rkey!=''" class="sorted" scope="col">
								<a title="Sorted Z..A - Click to reverse" rel="nofollow" tal:attributes="href string:${here/absolute_url}/external_search_html?skey=${item/key}&amp;start=${paging_start}&amp;${page_search_querystring}" i18n:attributes="title"><span i18n:translate="" tal:omit-tag="" tal:content="item/label" /><img src="misc_/Naaya/sort_desc.gif" width="12" height="12" alt="" /></a>
							</th>
						</tal:block>
						<th tal:condition="python:skey!=item['key']" scope="col">
							<a title="Sortable" rel="nofollow" tal:attributes="href string:${here/absolute_url}/external_search_html?skey=${item/key}&amp;start=${paging_start}&amp;${page_search_querystring}" i18n:attributes="title"><span i18n:translate="" tal:omit-tag="" tal:content="item/label" /><img src="misc_/Naaya/sort_not.gif" width="12" height="12" alt="" /></a>
						</th>
					</tal:block>
				</tal:block>
			</tr>
		</thead>
		<tbody>
			<tr tal:repeat="record records">
				<td style="text-align: middle">
					<img tal:define="icon python:here.rstk['get_object_view_info'](record)['icon']"
							 tal:attributes="src icon/url; title icon/title; alt icon/title" />
				</td>
				<td>
					<a tal:attributes="href record/url" tal:content="record/title" />
					<span tal:condition="python:record['description'] is not None">
						<br />
						<span tal:replace="python:here.utTruncateString(here.utStripAllHtmlTags(record['description']), 200)" />
					</span>
				</td>
				<td tal:content="python:here.gl_get_language_name(record['lang'])" />
				<td>
					<span tal:replace="record/time" />
					<span tal:condition="python:here.external_get_item_age(record['time'], age)==1">
						<strong style="color: #FF9966;" i18n:translate="">Old</strong>
					</span>
				</td>
			</tr>
		</tbody>
	</table>
	<div>
		<strong i18n:translate="">Results:</strong>
		<strong tal:content="python:paging_start+1" />
		-
		<strong tal:content="paging_upper" />
		<span i18n:translate="" tal:omit-tag="">of</span>
		<strong tal:content="paging_total" /><br />
		<span i18n:translate="" tal:omit-tag="">Page:</span>
		<span tal:condition="python:paging_prev!=-1">
			<a tal:define="url python:here.absolute_url"
				tal:attributes="href string:${url}/external_search_html?start=0&amp;skey=${skey}&amp;rkey=${rkey}&amp;${page_search_querystring}"
				title="First" i18n:attributes="title">&lt;&lt;</a>
			<a tal:define="url python:here.absolute_url; start_batch python:(paging_current_page-1)*paging_records_page"
				tal:attributes="href string:${url}/external_search_html?start=${start_batch}&amp;skey=${skey}&amp;rkey=${rkey}&amp;${page_search_querystring}"
				title="Previous" i18n:attributes="title">&lt;</a>
		</span>
		<span tal:repeat="page paging_pages">
			<a class="paging-link-off" tal:condition="python:paging_current_page==page" tal:content="python:page+1"></a>
			<a tal:condition="python:paging_current_page!=page" tal:define="url here/absolute_url; start_batch python:paging_records_page*page"
				tal:attributes="href string:${url}/external_search_html?start=${start_batch}&amp;skey=${skey}&amp;rkey=${rkey}&amp;${page_search_querystring}" tal:content="python:page+1">
			</a>
		</span>
		<span tal:condition="python:paging_next!=-1">
			<a tal:define="url here/absolute_url; start_batch python:(paging_current_page+1)*paging_records_page"
				tal:attributes="href string:${url}/external_search_html?start=${start_batch}&amp;skey=${skey}&amp;rkey=${rkey}&amp;${page_search_querystring}"
				title="Next" i18n:attributes="title">&gt;</a>
			<a tal:define="url here/absolute_url; end_batch python:(paging_total/paging_records_page)*paging_records_page"
				tal:attributes="href string:${url}/external_search_html?start=${end_batch}&amp;skey=${skey}&amp;rkey=${rkey}&amp;${page_search_querystring}"
				title="Last" i18n:attributes="title">&gt;&gt;</a>
		</span>
	</div>
</tal:block>
<tal:block tal:condition="python:paging_total == 0" i18n:translate="">
	No results were found for this query.
</tal:block>
</tal:block>
</span>

</tal:block>

</metal:block>
</metal:block>
