diff --git a/config/config.ini b/config/config.ini index f5f5a8f..604cb72 100644 --- a/config/config.ini +++ b/config/config.ini @@ -279,6 +279,11 @@ df = df ; defaults to 25 resultsPerPage = default +; The format in which to display the results +; options are searchengine or browseview +; defaults to searchengine +resultsDisplayFormat = default + ; The date format used when making queries using widgets ; defaults to Y-m-d dateFormat = default diff --git a/config/dmsDefaults.php b/config/dmsDefaults.php index 2ebdc00..ea06064 100644 --- a/config/dmsDefaults.php +++ b/config/dmsDefaults.php @@ -573,6 +573,7 @@ function catchFatalErrors($p_OnOff='On'){ $oKTConfig->setdefaultns('search', 'searchBasePath', KT_DIR . '/search2'); $oKTConfig->setdefaultns('search', 'fieldsPath', '${searchBasePath}/search/fields'); + $oKTConfig->setdefaultns('search', 'resultsDisplayFormat', 'searchengine'); $oKTConfig->setdefaultns('search', 'resultsPerPage', 25); $oKTConfig->setdefaultns('search', 'dateFormat', 'Y-m-d'); @@ -702,7 +703,7 @@ require_once(KT_LIB_DIR . '/util/ktutil.inc'); require_once(KT_LIB_DIR . '/ktentity.inc'); -$KTInit->catchFatalErrors(); +//$KTInit->catchFatalErrors(); if (phpversion()<5){ diff --git a/resources/js/search2widget.js b/resources/js/search2widget.js index 02be512..6c304f3 100644 --- a/resources/js/search2widget.js +++ b/resources/js/search2widget.js @@ -26,6 +26,18 @@ function onMetadataClick() Ext.example.msg(sSearchTranslations[0], sSearchTranslations[2]); /* Quick Search Options, Searches will now only search metadata */ } +function onSearchEngineFormatClick() +{ + bResultsFormatSearchEngine = true; + document.location=rootURL + "/search2.php?action=searchResults&format=searchengine"; +} + +function onBrowseFormatClick() +{ + bResultsFormatSearchEngine = false; + document.location=rootURL + "/search2.php?action=searchResults&format=browseview"; +} + function onSavedSearchClick(item) { id = item.id.substr(11); @@ -138,7 +150,24 @@ function createSearchBar(div, suffix) }, { text: sSearchTranslations[13] , /*Toggle results format*/ - handler: function() { document.location=rootURL + "/search2.php?action=searchResults&format=toggle"; } + menu: { + items: [ + new Ext.menu.CheckItem({ + text: sSearchTranslations[14], /* search engine format */ + id: 'cbResultsFormatSearchEngine' + suffix, + checked: bResultsFormatSearchEngine, + group: 'options', + handler: onSearchEngineFormatClick + }), + new Ext.menu.CheckItem({ + text: sSearchTranslations[15], /* browse view format */ + id: 'cbBrowseSearchEngine' + suffix, + checked: !bResultsFormatSearchEngine, + group: 'options', + handler: onBrowseFormatClick + }) + ] + } } ] }); diff --git a/search2.php b/search2.php index 5bbef82..42ad6da 100644 --- a/search2.php +++ b/search2.php @@ -332,22 +332,21 @@ class SearchDispatcher extends KTStandardDispatcher { { if (array_key_exists('format', $_GET)) { - if ($_GET['format'] == 'toggle') - { - switch ($_SESSION['search2resultFormat']) - { - case 'searchengine': - $_SESSION['search2resultFormat'] = 'browseview'; - break; - case 'browseview': - $_SESSION['search2resultFormat'] = 'searchengine'; - break; - } - } + switch ($_GET['format']){ + case 'searchengine': + $_SESSION['search2resultFormat'] = 'searchengine'; + break; + case 'browseview': + $_SESSION['search2resultFormat'] = 'browseview'; + break; + } } else { - $_SESSION['search2resultFormat'] = 'searchengine'; + if(!array_key_exists('search2resultFormat', $_SESSION)){ + global $default; + $_SESSION['search2resultFormat'] = $default->resultsDisplayFormat; + } } if ($_SESSION['search2resultFormat'] == 'browseview') diff --git a/templates/kt3/standard_page.smarty b/templates/kt3/standard_page.smarty index 4981114..d6a9d5e 100644 --- a/templates/kt3/standard_page.smarty +++ b/templates/kt3/standard_page.smarty @@ -127,6 +127,12 @@ {assign var=count value=$count+1} {/foreach} ]; + + {if $smarty.session.search2resultFormat != 'searchengine'} + var bResultsFormatSearchEngine = false; + {else} + var bResultsFormatSearchEngine = true; + {/if} {literal}