diff --git a/module/VuFind/src/VuFind/Bootstrapper.php b/module/VuFind/src/VuFind/Bootstrapper.php index 2e2b2650663c04287cf409c32560315b36ec8416..2f072a1b0ba2e54803eb4247b8fef85284727519 100644 --- a/module/VuFind/src/VuFind/Bootstrapper.php +++ b/module/VuFind/src/VuFind/Bootstrapper.php @@ -373,4 +373,23 @@ class Bootstrapper $this->events->attach('dispatch.error', $callback); $this->events->attach('render.error', $callback); } + + /** + * Set up handling for rendering problems. + * + * @return void + */ + protected function initRenderErrorEvent() + { + // When a render.error is triggered, as a high priority, set a flag in the + // layout that can be used to suppress actions in the layout templates that + // might trigger exceptions -- this will greatly increase the odds of showing + // a user-friendly message instead of a fatal error. + $callback = function ($event) { + $serviceManager = $event->getApplication()->getServiceManager(); + $viewModel = $serviceManager->get('viewmanager')->getViewModel(); + $viewModel->renderingError = true; + }; + $this->events->attach('render.error', $callback, 10000); + } } \ No newline at end of file diff --git a/themes/blueprint/templates/header.phtml b/themes/blueprint/templates/header.phtml index 27c2e6c3a0e3347cc9a874c0c8555b3c1c066aa3..3354c9ac3ace3ee026b75d279e1749222ef2ea15 100644 --- a/themes/blueprint/templates/header.phtml +++ b/themes/blueprint/templates/header.phtml @@ -1,47 +1,49 @@ <? $account = $this->auth()->getManager(); ?> <a id="logo" href="<?=$this->url('home')?>"></a> -<div id="headerRight"> - <? $cart = $this->cart(); if ($cart->isActive()): ?> - <div id="cartSummary" class="cartSummary"> - <a id="cartItems" title="<?=$this->transEsc('View Book Bag')?>" class="bookbag" href="<?=$this->url('cart-home')?>"><strong><span><?=count($cart->getItems())?></span></strong> <?=$this->transEsc('items')?> <?=$cart->isFull() ? '(' . $this->transEsc('bookbag_full') . ')' : ''?></a> - <a id="viewCart" title="<?=$this->transEsc('View Book Bag')?>" class="viewCart bookbag offscreen" href="<?=$this->url('cart-home')?>"><strong><span id="cartSize"><?=count($cart->getItems())?></span></strong> <?=$this->transEsc('items')?><span id="cartStatus"><?=$cart->isFull() ? $this->transEsc('bookbag_full') : ' '?></span></a> - </div> - <? endif; ?> - <? if (is_object($account) && $account->loginEnabled()): // hide login/logout if unavailable ?> - <div id="logoutOptions"<?=!$account->isLoggedIn() ? ' class="hide"' : ''?>> - <a class="account" href="<?=$this->url('myresearch-home')?>"><?=$this->transEsc("Your Account")?></a> | - <a class="logout" href="<?=$this->url('myresearch-logout')?>"><?=$this->transEsc("Log Out")?></a> - </div> - <div id="loginOptions"<?=$account->isLoggedIn() ? ' class="hide"' : ''?>> - <? if ($sessionInitiator = $account->getSessionInitiator($this->serverUrl($this->url('myresearch-home')))): ?> - <a class="login" href="<?=$this->escapeHtml($sessionInitiator)?>"><?=$this->transEsc("Institutional Login")?></a> - <? else: ?> - <a class="login" href="<?=$this->url('myresearch-home')?>"><?=$this->transEsc("Login")?></a> +<? if (!isset($this->layout()->renderingError)): ?> + <div id="headerRight"> + <? $cart = $this->cart(); if ($cart->isActive()): ?> + <div id="cartSummary" class="cartSummary"> + <a id="cartItems" title="<?=$this->transEsc('View Book Bag')?>" class="bookbag" href="<?=$this->url('cart-home')?>"><strong><span><?=count($cart->getItems())?></span></strong> <?=$this->transEsc('items')?> <?=$cart->isFull() ? '(' . $this->transEsc('bookbag_full') . ')' : ''?></a> + <a id="viewCart" title="<?=$this->transEsc('View Book Bag')?>" class="viewCart bookbag offscreen" href="<?=$this->url('cart-home')?>"><strong><span id="cartSize"><?=count($cart->getItems())?></span></strong> <?=$this->transEsc('items')?><span id="cartStatus"><?=$cart->isFull() ? $this->transEsc('bookbag_full') : ' '?></span></a> + </div> <? endif; ?> - </div> - <? endif; ?> - <? if (isset($this->layout()->themeOptions) && count($this->layout()->themeOptions) > 1): ?> - <form method="post" name="themeForm" action="" id="themeForm"> - <label for="themeForm_ui"><?=$this->transEsc("Theme")?>:</label> - <select id="themeForm_ui" name="ui" class="jumpMenu"> - <? foreach ($this->layout()->themeOptions as $current): ?> - <option value="<?=$this->escapeHtml($current['name'])?>"<?=$current['selected'] ? ' selected="selected"' : ''?>><?=$this->transEsc($current['desc'])?></option> - <? endforeach; ?> - </select> - <noscript><input type="submit" value="<?=$this->transEsc("Set")?>" /></noscript> - </form> - <? endif; ?> - <? if (isset($this->layout()->allLangs) && count($this->layout()->allLangs) > 1): ?> - <form method="post" name="langForm" action="" id="langForm"> - <label for="langForm_mylang"><?=$this->transEsc("Language")?>:</label> - <select id="langForm_mylang" name="mylang" class="jumpMenu"> - <? foreach ($this->layout()->allLangs as $langCode => $langName): ?> - <option value="<?=$langCode?>"<?=$this->layout()->userLang == $langCode ? ' selected="selected"' : ''?>><?=$this->displayLanguageOption($langName)?></option> - <? endforeach; ?> - </select> - <noscript><input type="submit" value="<?=$this->transEsc("Set")?>" /></noscript> - </form> - <? endif; ?> -</div> + <? if (is_object($account) && $account->loginEnabled()): // hide login/logout if unavailable ?> + <div id="logoutOptions"<?=!$account->isLoggedIn() ? ' class="hide"' : ''?>> + <a class="account" href="<?=$this->url('myresearch-home')?>"><?=$this->transEsc("Your Account")?></a> | + <a class="logout" href="<?=$this->url('myresearch-logout')?>"><?=$this->transEsc("Log Out")?></a> + </div> + <div id="loginOptions"<?=$account->isLoggedIn() ? ' class="hide"' : ''?>> + <? if ($sessionInitiator = $account->getSessionInitiator($this->serverUrl($this->url('myresearch-home')))): ?> + <a class="login" href="<?=$this->escapeHtml($sessionInitiator)?>"><?=$this->transEsc("Institutional Login")?></a> + <? else: ?> + <a class="login" href="<?=$this->url('myresearch-home')?>"><?=$this->transEsc("Login")?></a> + <? endif; ?> + </div> + <? endif; ?> + <? if (isset($this->layout()->themeOptions) && count($this->layout()->themeOptions) > 1): ?> + <form method="post" name="themeForm" action="" id="themeForm"> + <label for="themeForm_ui"><?=$this->transEsc("Theme")?>:</label> + <select id="themeForm_ui" name="ui" class="jumpMenu"> + <? foreach ($this->layout()->themeOptions as $current): ?> + <option value="<?=$this->escapeHtml($current['name'])?>"<?=$current['selected'] ? ' selected="selected"' : ''?>><?=$this->transEsc($current['desc'])?></option> + <? endforeach; ?> + </select> + <noscript><input type="submit" value="<?=$this->transEsc("Set")?>" /></noscript> + </form> + <? endif; ?> + <? if (isset($this->layout()->allLangs) && count($this->layout()->allLangs) > 1): ?> + <form method="post" name="langForm" action="" id="langForm"> + <label for="langForm_mylang"><?=$this->transEsc("Language")?>:</label> + <select id="langForm_mylang" name="mylang" class="jumpMenu"> + <? foreach ($this->layout()->allLangs as $langCode => $langName): ?> + <option value="<?=$langCode?>"<?=$this->layout()->userLang == $langCode ? ' selected="selected"' : ''?>><?=$this->displayLanguageOption($langName)?></option> + <? endforeach; ?> + </select> + <noscript><input type="submit" value="<?=$this->transEsc("Set")?>" /></noscript> + </form> + <? endif; ?> + </div> +<? endif; ?> <div class="clear"></div> diff --git a/themes/blueprint/templates/layout/layout.phtml b/themes/blueprint/templates/layout/layout.phtml index 35d26033449d6bc29f189e694b71ff2821ee1da0..ca70bee225251f03106ae4d6ef1bbe1d8ef25dd0 100644 --- a/themes/blueprint/templates/layout/layout.phtml +++ b/themes/blueprint/templates/layout/layout.phtml @@ -22,23 +22,25 @@ $this->headScript()->prependScript("path = '" . rtrim($this->url('home'), '/') . "';"); // Deal with cart stuff: - $cart = $this->cart(); - $script = 'var vufindString = {};'; - if ($cart->isActive()) { - $this->headScript()->appendFile("jquery.cookie.js"); - $this->headScript()->appendFile("cart.js"); - $script .= 'vufindString.bulk_noitems_advice = "' . $this->transEsc('bulk_noitems_advice') . '";' - . 'vufindString.confirmEmpty = "' . $this->transEsc('bookbag_confirm_empty') . '";' - . 'vufindString.viewBookBag = "' . $this->transEsc('View Book Bag') . '";' - . 'vufindString.addBookBag = "' . $this->transEsc('Add to Book Bag') . '";' - . 'vufindString.removeBookBag = "' . $this->transEsc('Remove from Book Bag') . '";' - . 'vufindString.itemsAddBag = "' . $this->transEsc('items_added_to_bookbag') . '";' - . 'vufindString.itemsInBag = "' . $this->transEsc('items_already_in_bookbag') . '";' - . 'vufindString.bookbagMax = "' . $cart->getMaxSize() . '";' - . 'vufindString.bookbagFull = "' . $this->transEsc('bookbag_full_msg') . '";' - . 'vufindString.bookbagStatusFull = "' . $this->transEsc('bookbag_full') . '";'; + if (!isset($this->renderingError)) { + $cart = $this->cart(); + $script = 'var vufindString = {};'; + if ($cart->isActive()) { + $this->headScript()->appendFile("jquery.cookie.js"); + $this->headScript()->appendFile("cart.js"); + $script .= 'vufindString.bulk_noitems_advice = "' . $this->transEsc('bulk_noitems_advice') . '";' + . 'vufindString.confirmEmpty = "' . $this->transEsc('bookbag_confirm_empty') . '";' + . 'vufindString.viewBookBag = "' . $this->transEsc('View Book Bag') . '";' + . 'vufindString.addBookBag = "' . $this->transEsc('Add to Book Bag') . '";' + . 'vufindString.removeBookBag = "' . $this->transEsc('Remove from Book Bag') . '";' + . 'vufindString.itemsAddBag = "' . $this->transEsc('items_added_to_bookbag') . '";' + . 'vufindString.itemsInBag = "' . $this->transEsc('items_already_in_bookbag') . '";' + . 'vufindString.bookbagMax = "' . $cart->getMaxSize() . '";' + . 'vufindString.bookbagFull = "' . $this->transEsc('bookbag_full_msg') . '";' + . 'vufindString.bookbagStatusFull = "' . $this->transEsc('bookbag_full') . '";'; + } + $this->headScript()->appendScript($script); } - $this->headScript()->appendScript($script); ?> <?=$this->headScript()?> </head>