Commit 57dc2d5aab7a34dc9ed219b927f5e0bf6f2e1bc2
1 parent
43500852
KTS-3202
"Update search2 widget to persist search results default state" Fixed. Used the session variable to persist state. Committed by: Megan Watson Reviewed by: Jonathan Byrne git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@8312 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
5 changed files
with
55 additions
and
15 deletions
config/config.ini
| ... | ... | @@ -279,6 +279,11 @@ df = df |
| 279 | 279 | ; defaults to 25 |
| 280 | 280 | resultsPerPage = default |
| 281 | 281 | |
| 282 | +; The format in which to display the results | |
| 283 | +; options are searchengine or browseview | |
| 284 | +; defaults to searchengine | |
| 285 | +resultsDisplayFormat = default | |
| 286 | + | |
| 282 | 287 | ; The date format used when making queries using widgets |
| 283 | 288 | ; defaults to Y-m-d |
| 284 | 289 | dateFormat = default | ... | ... |
config/dmsDefaults.php
| ... | ... | @@ -573,6 +573,7 @@ function catchFatalErrors($p_OnOff='On'){ |
| 573 | 573 | |
| 574 | 574 | $oKTConfig->setdefaultns('search', 'searchBasePath', KT_DIR . '/search2'); |
| 575 | 575 | $oKTConfig->setdefaultns('search', 'fieldsPath', '${searchBasePath}/search/fields'); |
| 576 | + $oKTConfig->setdefaultns('search', 'resultsDisplayFormat', 'searchengine'); | |
| 576 | 577 | $oKTConfig->setdefaultns('search', 'resultsPerPage', 25); |
| 577 | 578 | $oKTConfig->setdefaultns('search', 'dateFormat', 'Y-m-d'); |
| 578 | 579 | |
| ... | ... | @@ -702,7 +703,7 @@ require_once(KT_LIB_DIR . '/util/ktutil.inc'); |
| 702 | 703 | |
| 703 | 704 | require_once(KT_LIB_DIR . '/ktentity.inc'); |
| 704 | 705 | |
| 705 | -$KTInit->catchFatalErrors(); | |
| 706 | +//$KTInit->catchFatalErrors(); | |
| 706 | 707 | |
| 707 | 708 | if (phpversion()<5){ |
| 708 | 709 | ... | ... |
resources/js/search2widget.js
| ... | ... | @@ -26,6 +26,18 @@ function onMetadataClick() |
| 26 | 26 | Ext.example.msg(sSearchTranslations[0], sSearchTranslations[2]); /* Quick Search Options, Searches will now only search metadata */ |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | +function onSearchEngineFormatClick() | |
| 30 | +{ | |
| 31 | + bResultsFormatSearchEngine = true; | |
| 32 | + document.location=rootURL + "/search2.php?action=searchResults&format=searchengine"; | |
| 33 | +} | |
| 34 | + | |
| 35 | +function onBrowseFormatClick() | |
| 36 | +{ | |
| 37 | + bResultsFormatSearchEngine = false; | |
| 38 | + document.location=rootURL + "/search2.php?action=searchResults&format=browseview"; | |
| 39 | +} | |
| 40 | + | |
| 29 | 41 | function onSavedSearchClick(item) |
| 30 | 42 | { |
| 31 | 43 | id = item.id.substr(11); |
| ... | ... | @@ -138,7 +150,24 @@ function createSearchBar(div, suffix) |
| 138 | 150 | }, |
| 139 | 151 | { |
| 140 | 152 | text: sSearchTranslations[13] , /*Toggle results format*/ |
| 141 | - handler: function() { document.location=rootURL + "/search2.php?action=searchResults&format=toggle"; } | |
| 153 | + menu: { | |
| 154 | + items: [ | |
| 155 | + new Ext.menu.CheckItem({ | |
| 156 | + text: sSearchTranslations[14], /* search engine format */ | |
| 157 | + id: 'cbResultsFormatSearchEngine' + suffix, | |
| 158 | + checked: bResultsFormatSearchEngine, | |
| 159 | + group: 'options', | |
| 160 | + handler: onSearchEngineFormatClick | |
| 161 | + }), | |
| 162 | + new Ext.menu.CheckItem({ | |
| 163 | + text: sSearchTranslations[15], /* browse view format */ | |
| 164 | + id: 'cbBrowseSearchEngine' + suffix, | |
| 165 | + checked: !bResultsFormatSearchEngine, | |
| 166 | + group: 'options', | |
| 167 | + handler: onBrowseFormatClick | |
| 168 | + }) | |
| 169 | + ] | |
| 170 | + } | |
| 142 | 171 | } |
| 143 | 172 | ] |
| 144 | 173 | }); | ... | ... |
search2.php
| ... | ... | @@ -332,22 +332,21 @@ class SearchDispatcher extends KTStandardDispatcher { |
| 332 | 332 | { |
| 333 | 333 | if (array_key_exists('format', $_GET)) |
| 334 | 334 | { |
| 335 | - if ($_GET['format'] == 'toggle') | |
| 336 | - { | |
| 337 | - switch ($_SESSION['search2resultFormat']) | |
| 338 | - { | |
| 339 | - case 'searchengine': | |
| 340 | - $_SESSION['search2resultFormat'] = 'browseview'; | |
| 341 | - break; | |
| 342 | - case 'browseview': | |
| 343 | - $_SESSION['search2resultFormat'] = 'searchengine'; | |
| 344 | - break; | |
| 345 | - } | |
| 346 | - } | |
| 335 | + switch ($_GET['format']){ | |
| 336 | + case 'searchengine': | |
| 337 | + $_SESSION['search2resultFormat'] = 'searchengine'; | |
| 338 | + break; | |
| 339 | + case 'browseview': | |
| 340 | + $_SESSION['search2resultFormat'] = 'browseview'; | |
| 341 | + break; | |
| 342 | + } | |
| 347 | 343 | } |
| 348 | 344 | else |
| 349 | 345 | { |
| 350 | - $_SESSION['search2resultFormat'] = 'searchengine'; | |
| 346 | + if(!array_key_exists('search2resultFormat', $_SESSION)){ | |
| 347 | + global $default; | |
| 348 | + $_SESSION['search2resultFormat'] = $default->resultsDisplayFormat; | |
| 349 | + } | |
| 351 | 350 | } |
| 352 | 351 | |
| 353 | 352 | if ($_SESSION['search2resultFormat'] == 'browseview') | ... | ... |
templates/kt3/standard_page.smarty
| ... | ... | @@ -127,6 +127,12 @@ |
| 127 | 127 | {assign var=count value=$count+1} |
| 128 | 128 | {/foreach} |
| 129 | 129 | ]; |
| 130 | + | |
| 131 | + {if $smarty.session.search2resultFormat != 'searchengine'} | |
| 132 | + var bResultsFormatSearchEngine = false; | |
| 133 | + {else} | |
| 134 | + var bResultsFormatSearchEngine = true; | |
| 135 | + {/if} | |
| 130 | 136 | </script> |
| 131 | 137 | {literal} |
| 132 | 138 | ... | ... |