diff --git a/module/VuFind/src/VuFind/Controller/AjaxController.php b/module/VuFind/src/VuFind/Controller/AjaxController.php index af4244d91d1318d60d490e66ad2aad6efbfefa4f..1b44d47b1a0cb314e85b45ea85465fffa3ec373e 100644 --- a/module/VuFind/src/VuFind/Controller/AjaxController.php +++ b/module/VuFind/src/VuFind/Controller/AjaxController.php @@ -1500,4 +1500,32 @@ class AjaxController extends AbstractBase { return $this->getServiceLocator()->get('VuFind\SearchResultsPluginManager'); } + + /** + * Get Ils Status + * + * This will check the ILS for being online and will return the ils-offline + * template upon failure. + * + * @return \Zend\Http\Response + * @author André Lahmann <lahmann@ub.uni-leipzig.de> + */ + protected function getIlsStatusAjax() + { + $this->disableSessionWrites(); // avoid session write timing bug + if ($this->getILS()->getOfflineMode(true) == 'ils-offline') { + $offlineModeMsg = $this->params()->fromPost( + 'offlineModeMsg', + $this->params()->fromQuery('offlineModeMsg') + ); + return $this->output( + $this->getViewRenderer()->render( + 'Helpers/ils-offline.phtml', + compact('offlineModeMsg') + ), + self::STATUS_OK + ); + } + return $this->output('', self::STATUS_OK); + } } diff --git a/themes/bootstrap3/templates/search/home.phtml b/themes/bootstrap3/templates/search/home.phtml index 551a20c336abefb9f4d9c799a3c3396d6909e823..9008d04339455cd055c15bb3e3963219544830d0 100644 --- a/themes/bootstrap3/templates/search/home.phtml +++ b/themes/bootstrap3/templates/search/home.phtml @@ -19,7 +19,22 @@ ?> <div class="searchHomeContent"> - <?=($this->ils()->getOfflineMode() == "ils-offline") ? $this->render('Helpers/ils-offline.phtml', ['offlineModeMsg' => 'ils_offline_home_message']) : ''?> + <? + $ilsStatusScript = <<<JS + $(document).ready(function() { + $.ajax({ + dataType: 'json', + method: 'GET', + data: {'offlineModeMsg':'ils_offline_home_message'}, + url: VuFind.path + '/AJAX/JSON?method=getIlsStatus', + success: function(response) { + $('.searchHomeContent').append(response.data); + } + }); + }); +JS; + ?> + <?=$this->inlineScript(\Zend\View\Helper\HeadScript::SCRIPT, $ilsStatusScript, 'SET'); ?> <div class="well well-lg clearfix" role="search"> <?=$this->context($this)->renderInContext("search/searchbox.phtml", ['ignoreHiddenFilterMemory' => true])?> </div>