The Gitlab instance will be restarted on Monday April 28th at 2AM. There will be a short interruption of service.

Skip to content
Snippets Groups Projects
Commit d828aa84 authored by Demian Katz's avatar Demian Katz
Browse files

Resolving VUFIND-850 (Label search sources in history listing)

parent ac26f71e
No related merge requests found
......@@ -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
<?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
......@@ -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);
......
......@@ -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>
......
......@@ -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')
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment