From 8af3c6c4c53959c51c0ed0c24104368aa686cf92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Lahmann?= <lahmann@ub.uni-leipzig.de> Date: Tue, 18 Oct 2016 12:55:27 -0400 Subject: [PATCH] AJAX ILS offline status check. --- .../src/VuFind/Controller/AjaxController.php | 28 +++++++++++++++++++ themes/bootstrap3/templates/search/home.phtml | 17 ++++++++++- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/module/VuFind/src/VuFind/Controller/AjaxController.php b/module/VuFind/src/VuFind/Controller/AjaxController.php index af4244d91d1..1b44d47b1a0 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 551a20c336a..9008d043394 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> -- GitLab