diff --git a/config/vufind/config.ini b/config/vufind/config.ini index 330b99adc99c2d119c9a9608d9a84a15c339e6ca..116322d8627a772002b05731070322dffc7246ae 100644 --- a/config/vufind/config.ini +++ b/config/vufind/config.ini @@ -881,4 +881,13 @@ max_tag_length = 64 [SearchTabs] ;Solr = Catalog ;Summon = Summon -;WorldCat = WorldCat \ No newline at end of file +;WorldCat = WorldCat + +; Uncomment portions of this section to label searches from particular sources in the +; search history display. Keys are search backend names, values are labels for use in +; the user interface (subject to translation). +[SearchHistoryLabels] +;Solr = Catalog +;Summon = Summon +;WorldCat = WorldCat +;SolrWeb = "Library Website" \ No newline at end of file diff --git a/module/VuFind/src/VuFind/View/Helper/Root/HistoryLabel.php b/module/VuFind/src/VuFind/View/Helper/Root/HistoryLabel.php new file mode 100644 index 0000000000000000000000000000000000000000..a0cf0bb1cf463d4a84c77fd66af85ab3c8ee8c88 --- /dev/null +++ b/module/VuFind/src/VuFind/View/Helper/Root/HistoryLabel.php @@ -0,0 +1,81 @@ +<?php +/** + * "Search history label" view helper + * + * PHP version 5 + * + * Copyright (C) Villanova University 2010. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @category VuFind2 + * @package View_Helpers + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/vufind2:developer_manual Wiki + */ +namespace VuFind\View\Helper\Root; + +/** + * "Search history label" view helper + * + * @category VuFind2 + * @package View_Helpers + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/vufind2:developer_manual Wiki + */ +class HistoryLabel extends \Zend\View\Helper\AbstractHelper +{ + /** + * Label configuration + * + * @var array + */ + protected $config; + + /** + * Translation helper + * + * @var TransEsc + */ + protected $translator; + + /** + * Constructor + * + * @param array $config Label configuration + * @param TransEsc $url Translation helper + */ + public function __construct(array $config, TransEsc $translator) + { + $this->config = $config; + $this->translator = $translator; + } + + /** + * Return a label for the specified class (if configured). + * + * @param string $class The search class ID of the active search + * + * @return string + */ + public function __invoke($class) + { + if (isset($this->config[$class])) { + return $this->translator->__invoke($this->config[$class]) . ':'; + } + return ''; + } +} \ No newline at end of file diff --git a/themes/blueprint/templates/search/history-table.phtml b/themes/blueprint/templates/search/history-table.phtml index a79cb4f02eb969e0ce480363b66004620c9a1211..b3cd1b643d9d9f74f29d31e3609ee6794fe30f54 100644 --- a/themes/blueprint/templates/search/history-table.phtml +++ b/themes/blueprint/templates/search/history-table.phtml @@ -10,6 +10,7 @@ <tr class="<?=$iteration % 2 == 1 ? 'even' : 'odd'?>row"> <td><?=$this->escapeHtml(date("g:ia, jS M y", $info->getStartTime()))?></td> <td> + <?=$this->historylabel($info->getParams()->getSearchClassId())?> <a href="<?=$this->url($info->getOptions()->getSearchAction()) . $info->getUrlQuery()->getParams()?>"><? $desc = $info->getParams()->getDisplayQuery(); echo empty($desc) ? $this->transEsc("history_empty_search") : $this->escapeHtml($desc); diff --git a/themes/jquerymobile/templates/search/history-table.phtml b/themes/jquerymobile/templates/search/history-table.phtml index 6c6dfe3609ab701b3daa6df125deb394e6a8ca50..eee9e65abf8c98c5c8c53fcc284b559002bf63c6 100644 --- a/themes/jquerymobile/templates/search/history-table.phtml +++ b/themes/jquerymobile/templates/search/history-table.phtml @@ -3,6 +3,7 @@ <a rel="external" href="<?=$this->url($info->getOptions()->getSearchAction()) . $info->getUrlQuery()->getParams()?>"> <div class="result"> <h3><? + echo $this->historylabel($info->getParams()->getSearchClassId()) . ' '; $desc = $info->getParams()->getDisplayQuery(); echo empty($desc) ? $this->transEsc("history_empty_search") : $this->escapeHtml($desc); ?></h3> diff --git a/themes/root/theme.config.php b/themes/root/theme.config.php index 8f705fdf90662491865e4b8755adcd39d6bfd482..4e0670b1baa81e3102cc47f0f2ce4707b2dbe4e0 100644 --- a/themes/root/theme.config.php +++ b/themes/root/theme.config.php @@ -66,6 +66,14 @@ return array( ? $config->GoogleAnalytics->apiKey : false; return new \VuFind\View\Helper\Root\GoogleAnalytics($key); }, + 'historylabel' => function ($sm) { + $config = $sm->getServiceLocator()->get('VuFind\Config')->get('config'); + $config = isset($config->SearchHistoryLabels) + ? $config->SearchHistoryLabels->toArray() : array(); + return new VuFind\View\Helper\Root\HistoryLabel( + $config, $sm->get('transesc') + ); + }, 'ils' => function ($sm) { return new \VuFind\View\Helper\Root\Ils( $sm->getServiceLocator()->get('VuFind\ILSConnection')