PageRenderTime 54ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/templates/modules/mod-search.tpl

https://gitlab.com/ElvisAns/tiki
Smarty Template | 178 lines | 164 code | 10 blank | 4 comment | 12 complexity | 820da0378880a573e8b9c3df5183dde0 MD5 | raw file
  1. {* $Id$ *}
  2. {compact}
  3. {if $tiki_p_search eq 'y'}
  4. {tikimodule error=$module_error title=$smod_params.title name="search" flip=$smod_params.flip decorations=$smod_params.decorations nobox=$smod_params.nobox notitle=$smod_params.notitle}
  5. {if $smod_params.tiki_search neq 'none'}
  6. <form id="search-module-form{$search_mod_usage_counter}" method="get" action="{$smod_params.search_action}"{if $smod_params.use_autocomplete eq 'y'} onsubmit="return submitSearch{$search_mod_usage_counter}()"{/if} style="position: relative;">
  7. <div class="{if $smod_params.compact eq 'y'}input-group{else}mb-3{/if}{*d-flex flex-wrap mx-0 align-items-center*}">
  8. {* <div class="{*col-auto*}{*me-2"> *}
  9. <input style="min-width: 4rem;{if $smod_params.compact eq "y"}{*width:72%;border-bottom-right-radius:0;border-top-right-radius: 0;*}{/if}" placeholder="{tr}Find{/tr}" class="form-control my-1" id="search_mod_input_{$search_mod_usage_counter}" name="{if $smod_params.search_action eq 'tiki-searchindex.php'}filter~content{else}find{/if}" {if !empty($smod_params.input_size)}size="{$smod_params.input_size}" style="width: auto"{/if} type="text" accesskey="s" value="{$smod_params.input_value|escape}">
  10. <label class="sr-only" for="search_mod_input_{$search_mod_usage_counter}">Find</label>
  11. {* </div>*}
  12. {if $smod_params.show_object_filter eq 'y'}
  13. <label class="col-form-label" for="filterType">
  14. {tr}in{/tr}&nbsp;
  15. </label>
  16. <div class="col-auto">
  17. {if $smod_params.search_action eq 'tiki-searchindex.php'}
  18. <select id="filterType" name="filter~type" class="form-select my-1" {*style="width:{$smod_params.select_size}em;"*}>
  19. <option value="">{tr}Entire Site{/tr}</option>
  20. {if $prefs.feature_wiki eq 'y'}<option value="wiki page"{if $smod_params.where eq "wiki page"} selected="selected"{/if}>{tr}Wiki Pages{/tr}</option>{/if}
  21. {if $prefs.feature_blogs eq 'y'}<option value="blog post"{if $smod_params.where eq "blog post"} selected="selected"{/if}>{tr}Blog Posts{/tr}</option>{/if}
  22. {if $prefs.feature_articles eq 'y'}<option value="article"{if $smod_params.where eq "article"} selected="selected"{/if}>{tr}Articles{/tr}</option>{/if}
  23. {if $prefs.feature_file_galleries eq 'y'}<option value="file"{if $smod_params.where eq "file"} selected="selected"{/if}>{tr}Files{/tr}</option>{/if}
  24. {if $prefs.feature_forums eq 'y'}<option value="forum post"{if $smod_params.where eq "forum post"} selected="selected"{/if}>{tr}Forums{/tr}</option>{/if}
  25. {if $prefs.feature_trackers eq 'y'}<option value="trackeritem"{if $smod_params.where eq "trackeritem"} selected="selected"{/if}>{tr}Trackers{/tr}</option>{/if}
  26. {if $prefs.feature_sheet eq 'y'}<option value="sheet"{if $smod_params.where eq "sheet"} selected="selected"{/if}>{tr}Spreadsheets{/tr}</option>{/if}
  27. </select>
  28. {else}
  29. <select class="form-select my-1" name="where" {*style="width:{$smod_params.select_size}em;"*}>
  30. <option value="pages">{tr}Entire Site{/tr}</option>
  31. {if $prefs.feature_wiki eq 'y'}<option value="wikis"{if $smod_params.where eq "wikis"} selected="selected"{/if}>{tr}Wiki Pages{/tr}</option>{/if}
  32. {if $prefs.feature_directory eq 'y'}<option value="directory"{if $smod_params.where eq "directory"} selected="selected"{/if}>{tr}Directory{/tr}</option>{/if}
  33. {if $prefs.feature_file_galleries eq 'y'}<option value="files"{if $smod_params.where eq "files"} selected="selected"{/if}>{tr}Files{/tr}</option>{/if}
  34. {if $prefs.feature_articles eq 'y'}<option value="articles"{if $smod_params.where eq "articles"} selected="selected"{/if}>{tr}Articles{/tr}</option>{/if}
  35. {if $prefs.feature_forums eq 'y'}<option value="forums"{if $smod_params.where eq "forums"} selected="selected"{/if}>{tr}Forums{/tr}</option>{/if}
  36. {if $prefs.feature_blogs eq 'y'}
  37. <option value="blogs"{if $smod_params.where eq "blogs"} selected="selected"{/if}>{tr}Blogs{/tr}</option>
  38. <option value="posts"{if $smod_params.where eq "posts"} selected="selected"{/if}>{tr}Blog Posts{/tr}</option>
  39. {/if}
  40. {if $prefs.feature_faqs eq 'y'}<option value="faqs"{if $smod_params.where eq "faqs"} selected="selected"{/if}>{tr}FAQs{/tr}</option>{/if}
  41. {if $prefs.feature_trackers eq 'y'}<option value="trackers"{if $smod_params.where eq "trackers"} selected="selected"{/if}>{tr}Trackers{/tr}</option>{/if}
  42. </select>
  43. {/if}
  44. </div>
  45. {elseif !empty($prefs.search_default_where)}
  46. {if is_array($prefs.search_default_where)}
  47. {foreach from=$prefs.search_default_where item=t}
  48. <input type="hidden" name="{if $smod_params.search_action eq 'tiki-searchindex.php'}filter~type[]{else}where[]{/if}" value="{$t|escape}" />
  49. {/foreach}
  50. {else}
  51. <input type="hidden" name="{if $smod_params.search_action eq 'tiki-searchindex.php'}filter~type{else}where{/if}" value="{$prefs.search_default_where|escape}" />
  52. {/if}
  53. {/if}
  54. {if $smod_params.compact eq "y"}
  55. <button type="submit" class="btn btn-info my-1 search_mod_magnifier" aria-label="{tr}Search{/tr}">
  56. {icon name="search"}
  57. </button>
  58. </div>
  59. <div class="btn-group search_mod_buttons box">
  60. {else}
  61. <div class="btn-group my-1">
  62. {/if}
  63. {foreach $smod_params.additional_filters as $key => $filter}
  64. <input type="hidden" name="filter~{$key|escape}" value="{$filter|escape}"/>
  65. {/foreach}
  66. {if $smod_params.show_search_button eq 'y'}
  67. <input type = "submit" class="btn btn-info btn-sm tips{if $smod_params.default_button eq 'search'} btn-primary button_default{/if}{if $smod_params.compact eq "y"} bottom{/if}"
  68. name = "search" value = "{$smod_params.search_submit|escape}"
  69. title="{tr}Search{/tr}|{tr}Search for text throughout the site.{/tr}"
  70. {if $smod_params.compact eq "y"}data-bs-placement="bottom"{/if}
  71. onclick = "$('#search-module-form{$search_mod_usage_counter}').attr('action', '{$smod_params.search_action|escape:javascript}').attr('page_selected','');"
  72. />
  73. {/if}
  74. {if $smod_params.show_go_button eq 'y'}
  75. <input type="hidden" name="exact_match" value="" />
  76. <input type = "submit" class="btn btn-info btn-sm tips{if $smod_params.compact eq "y"} bottom{/if}{if $smod_params.default_button eq 'go'} btn-primary button_default{/if}"
  77. name = "go" value = "{$smod_params.go_submit|escape}"
  78. title="{tr}Go{/tr}|{tr}Go directly to a page, or search in page titles if exact match is not found.{/tr}"
  79. {if $smod_params.compact eq "y"}data-bs-placement="bottom"{/if}
  80. onclick = "$('#search-module-form{$search_mod_usage_counter}').attr('action', '{$smod_params.go_action|escape:javascript}').attr('page_selected','');
  81. {if $smod_params.search_action eq 'tiki-searchindex.php'}
  82. $('#search-module-form{$search_mod_usage_counter} input[name=\'filter~content\']').attr('name', 'find');
  83. {/if}
  84. "
  85. >
  86. {/if}
  87. {if $smod_params.show_edit_button eq 'y' and $tiki_p_edit eq 'y'}
  88. <input type = "submit" class = "btn btn-primary btn-sm tips{if $smod_params.compact eq "y"} bottom{/if}{if $smod_params.default_button eq 'edit'} btn-primary button_default{/if}"
  89. name = "edit" value = "{$smod_params.edit_submit|escape}"
  90. title="{tr}Edit{/tr}|{tr}Edit existing page or create a new one.{/tr}"
  91. {if $smod_params.compact eq "y"}data-bs-placement="bottom"{/if}
  92. onclick = "$('#search-module-form{$search_mod_usage_counter} input[name!={if $smod_params.search_action eq 'tiki-searchindex.php'}\'filter~content\'{else}\'find\'{/if}]').attr('name', '');
  93. $('#search-module-form{$search_mod_usage_counter} input[name={if $smod_params.search_action eq 'tiki-searchindex.php'}\'filter~content\'{else}\'find\'{/if}]').attr('name', 'page');
  94. $('#search-module-form{$search_mod_usage_counter}').attr('action', '{$smod_params.edit_action|escape:javascript}').attr('page_selected','');
  95. "
  96. >
  97. {/if}
  98. {* </div>*}
  99. </div>
  100. {if $smod_params.tiki_search neq 'y'}
  101. {if $smod_params.advanced_search_option eq 'y'}
  102. <div class="form-check"{* style="padding-left: 6px; padding-right: 6px; display: inline-block;"*}>
  103. <input type="checkbox" class="form-check-input" name="boolean" id="boolean"{if $smod_params.advanced_search eq "y"} checked="checked"{/if} />
  104. <label for="boolean" class="form-check-label">{tr}Advanced{/tr}
  105. {if $smod_params.advanced_search_help eq 'y'}
  106. <a href="{bootstrap_modal controller=search action=help}" class="text-info">{icon name='help'} {tr}Search Help{/tr}</a>
  107. {/if}
  108. </label>
  109. </div>
  110. {else}
  111. {if $smod_params.advanced_search eq "y"}<input type="hidden" name="boolean" value="on" />{/if}
  112. {/if}
  113. <input type="hidden" name="boolean_last" value="{$smod_params.advanced_search}" />
  114. {/if}
  115. {if $smod_params.compact eq "y"}
  116. {jq}
  117. $(".search_mod_magnifier").mouseover( function () {
  118. $(".search_mod_buttons", $(this).parents(".module"))
  119. .show('fast')
  120. .mouseleave( function () {
  121. $(this).hide('fast');
  122. });
  123. }).click( function () {
  124. $(this).parents("form").submit();
  125. });
  126. $("#search_mod_input_{{$search_mod_usage_counter}}")
  127. .keydown( function () {
  128. $(".search_mod_magnifier", $(this).parent()).mouseover();}
  129. );
  130. {/jq}
  131. {else}
  132. </div>
  133. {/if}
  134. </form>
  135. {jq notonready=true}
  136. function submitSearch{{$search_mod_usage_counter}}() {
  137. var $f = $('#search-module-form{{$search_mod_usage_counter}}');
  138. if ($f.attr('action') !== "tiki-editpage.php" && $f.data('page_selected') === $("#search_mod_input_{{$search_mod_usage_counter}}").val()) {
  139. if ($f.find('input[name="find"]').length) {
  140. $f.find('input[name="find"]').val($f.data('page_selected'));
  141. } else {
  142. $f.append($('<input name="find">').val($f.data('page_selected')));
  143. }
  144. $f.attr('action', '{{$smod_params.go_action|escape:javascript}}');
  145. } else if ($f.attr('action') == "#") {
  146. $f.attr('action', '{{$smod_params.search_action|escape:javascript}}');
  147. }
  148. $exact = $f.find("input[name=exact_match]");
  149. if ($exact.val() != "y") {
  150. $exact.remove(); // seems exact_match is true even if empty
  151. }
  152. return true;
  153. }
  154. {/jq}
  155. {if $smod_params.use_autocomplete eq 'y'}
  156. {capture name="selectFn"}select: function(event, item) {ldelim}
  157. $('#search-module-form{$search_mod_usage_counter}').data('page_selected', item.item.value).find("input[name=exact_match]").val("y");
  158. {rdelim}, open: function(event, item) {ldelim}
  159. $(".search_mod_buttons", "#search-module-form{$search_mod_usage_counter}").hide();
  160. {rdelim}, close: function(event, item) {ldelim}
  161. $(".search_mod_buttons", "#search-module-form{$search_mod_usage_counter}").show();
  162. {rdelim}{/capture}
  163. {autocomplete element="#search_mod_input_"|cat:$search_mod_usage_counter type="pagename" options=$smarty.capture.selectFn}
  164. {/if}
  165. {/if}
  166. {/tikimodule}
  167. {/if}
  168. {/compact}