PageRenderTime 20ms CodeModel.GetById 14ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/xquery/search-panel.xqm

http://transcriptstudio4isha.googlecode.com/
Unknown | 95 lines | 91 code | 4 blank | 0 comment | 0 complexity | 9c56dd7879ffa8afbec46f289b5db3ab MD5 | raw file
 1xquery version "1.0";
 2
 3module namespace search-panel = "http://www.ishafoundation.org/ts4isha/xquery/search-panel";
 4
 5import module namespace search-fns = "http://www.ishafoundation.org/ts4isha/xquery/search-fns" at "search-fns.xqm";
 6import module namespace utils = "http://www.ishafoundation.org/ts4isha/xquery/utils" at "utils.xqm";
 7
 8declare namespace request = "http://exist-db.org/xquery/request";
 9declare namespace session = "http://exist-db.org/xquery/session";
10
11declare function search-panel:main() as element()*
12{
13	let $defaultTypeValues := ('markup', 'text', 'event') 
14	let $defaultTypeNames := ('Markups', 'Text', 'Events')
15	let $notSearchingNow := 'notsearchingnow' 
16	let $searchString := if (request:exists()) then
17			normalize-space(request:get-parameter('search', $notSearchingNow))
18		else
19			()
20	let $defaultType := if (request:exists()) then
21			normalize-space(request:get-parameter('defaultType', ('markup')))
22		else
23			()
24	let $groupResults := if (request:exists()) then
25			normalize-space(request:get-parameter('groupResults', ('true')))
26		else
27			()
28	let $markupUuid := if (request:exists()) then
29			normalize-space(request:get-parameter('markupUuid', ()))
30		else
31			()
32	return
33	(
34		<center><h2>Isha Foundation Transcript &amp; Event Search</h2></center>
35	,
36		<div class="panel">
37			<center>
38			<table id="header">
39				<tr><td valign="bottom">
40				<form id="search-form">
41					<input type="hidden" name="panel" value="search"/>
42					<table id="search-form-table" cellpadding="2"><tr>
43						<td>Search</td>
44						<td><select name="defaultType">
45							{
46							for $i in (1 to 3)
47							let $thisValue := $defaultTypeValues[$i]
48							let $thisName := $defaultTypeNames[$i]
49							return
50								<option value="{$thisValue}">
51								{if ($defaultType = $thisValue) then attribute selected {'selected'} else ()}
52								{$thisName}
53								</option>
54							}
55						</select></td>
56						<td>for</td>
57						<td><input type="text" name="search" size="50" value="{if (not($searchString = $notSearchingNow)) then $searchString else ()}"/></td>
58						<td><input type="submit" value="Search"/></td> 
59					</tr></table>
60				</form>
61				</td></tr>
62			</table>
63			</center>
64			{
65				if (request:get-parameter('search', 'notsearchingnow') = 'notsearchingnow') then
66					()
67				else
68				(
69					<hr/>
70				,
71					if ($searchString) then
72						search-fns:main($searchString, $defaultType, $groupResults, $markupUuid)
73					else
74						'Blank search string'
75				)
76			}
77			<hr/>
78			<div class="additional-info">
79				Additional info: <a href="main.xql?panel=all-concepts">concepts</a>, <a href="main.xql?panel=all-categories">categories</a>
80			</div>
81			{
82				if (utils:is-current-user-admin()) then
83					<div class="additional-info">
84						Admin: <a href="main.xql?panel=admin">ts4isha</a>, <a href="../../../../admin/admin.xql">eXist db</a>
85					</div>
86				else
87					()
88			}
89			<div class="additional-info">
90				Utilities: <a href="main.xql?panel=ids">id lookup</a>
91			</div>
92			<br/>
93		</div>
94	)
95};