/xquery/search-panel.xqm

http://transcriptstudio4isha.googlecode.com/ · Unknown · 95 lines · 91 code · 4 blank · 0 comment · 0 complexity · 9c56dd7879ffa8afbec46f289b5db3ab MD5 · raw file

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