Skip to content
Snippets Groups Projects
Commit e50f2f79 authored by Anna Headley's avatar Anna Headley Committed by Demian Katz
Browse files

new recommendation module to provide a link to the alphabrowse index

parent 432aa8f4
No related merge requests found
...@@ -335,6 +335,8 @@ CallNumber = callnumber-sort ...@@ -335,6 +335,8 @@ CallNumber = callnumber-sort
; ;
; Available modules recommended for use in the "no results" area: ; Available modules recommended for use in the "no results" area:
; ;
; AlphaBrowseLink:index
; Use the query to generate a link to the specified alphabrowse index
; SwitchQuery:[backend]:[checks to skip]:[transforms to add] ; SwitchQuery:[backend]:[checks to skip]:[transforms to add]
; This module analyzes the user's query and offers suggestions for ways to ; This module analyzes the user's query and offers suggestions for ways to
; improve it. [backend] is the name of the search backend currently in use, ; improve it. [backend] is the name of the search backend currently in use,
...@@ -367,6 +369,7 @@ CallNumber[] = "TopFacets:ResultsTop" ; disable spelling in this conte ...@@ -367,6 +369,7 @@ CallNumber[] = "TopFacets:ResultsTop" ; disable spelling in this conte
[NoResultsRecommendations] [NoResultsRecommendations]
CallNumber[] = SwitchQuery::wildcard:truncatechar CallNumber[] = SwitchQuery::wildcard:truncatechar
;CallNumber[] = AlphaBrowseLink:lcc
; These settings control the top and side recommendations within the special Author ; These settings control the top and side recommendations within the special Author
; module (the page accessed by clicking on an author's name within the search ; module (the page accessed by clicking on an author's name within the search
......
...@@ -49,6 +49,7 @@ All Fields = "All Fields" ...@@ -49,6 +49,7 @@ All Fields = "All Fields"
All Pages Loaded = "All Pages Loaded" All Pages Loaded = "All Pages Loaded"
All Text = "All Text" All Text = "All Text"
alphabrowse_matches = "Results" alphabrowse_matches = "Results"
alphabrowselink_html = "Browse entries by %%index%% starting from <a href="%%url%%">%%from%%</a>."
An error has occurred = "An error has occurred" An error has occurred = "An error has occurred"
An error occurred during execution; please try again later. = "An error occurred during execution; please try again later." An error occurred during execution; please try again later. = "An error occurred during execution; please try again later."
AND = "AND" AND = "AND"
......
...@@ -419,6 +419,7 @@ $config = [ ...@@ -419,6 +419,7 @@ $config = [
'worldcatterms' => 'VuFind\Recommend\Factory::getWorldCatTerms', 'worldcatterms' => 'VuFind\Recommend\Factory::getWorldCatTerms',
], ],
'invokables' => [ 'invokables' => [
'alphabrowselink' => 'VuFind\Recommend\AlphaBrowseLink',
'europeanaresultsdeferred' => 'VuFind\Recommend\EuropeanaResultsDeferred', 'europeanaresultsdeferred' => 'VuFind\Recommend\EuropeanaResultsDeferred',
'facetcloud' => 'VuFind\Recommend\FacetCloud', 'facetcloud' => 'VuFind\Recommend\FacetCloud',
'openlibrarysubjects' => 'VuFind\Recommend\OpenLibrarySubjects', 'openlibrarysubjects' => 'VuFind\Recommend\OpenLibrarySubjects',
......
<?php
/**
* AlphaBrowseLink Recommendations Module
*
* 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 Recommendations
* @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:recommendation_modules Wiki
*/
namespace VuFind\Recommend;
/**
* AlphaBrowseLink Recommendations Module
*
* This class recommends a look at the alphabrowse index.
*
* @category VuFind2
* @package Recommendations
* @author Demian Katz <demian.katz@villanova.edu>
* @author Anna Headley <aheadle1@swarthmore.edu>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link http://vufind.org/wiki/vufind2:recommendation_modules Wiki
*/
class AlphaBrowseLink implements RecommendInterface
{
/**
* Search query submitted
*
* @var string
*/
protected $query;
/**
* Alphabrowse index to link to
*
* @var string
*/
protected $index;
/**
* Store the configuration of the recommendation module.
*
* @param string $settings Settings from searches.ini.
*
* @return void
*/
public function setConfig($settings)
{
// so far there's just the one setting.
$this->index = $settings;
}
/**
* Called at the end of the Search Params objects' initFromRequest() method.
* This method is responsible for setting search parameters needed by the
* recommendation module and for reading any existing search parameters that may
* be needed.
*
* @param \VuFind\Search\Base\Params $params Search parameter object
* @param \Zend\StdLib\Parameters $request Parameter object representing user
* request.
*
* @return void
*/
public function init($params, $request)
{
}
/**
* Called after the Search Results object has performed its main search. This
* may be used to extract necessary information from the Search Results object
* or to perform completely unrelated processing.
*
* @param \VuFind\Search\Base\Results $results Search results object
*
* @return void
*/
public function process($results)
{
$this->query = $results->getParams()->getDisplayQuery();
}
/**
* Get the search query.
*
* @return string
*/
public function getQuery()
{
return $this->query;
}
/**
* Get the alphabrowse index to link to
*
* @return string
*/
public function getIndex()
{
return $this->index;
}
}
<?
$index = $this->recommend->getIndex();
$from = $this->recommend->getQuery();
$link = $this->translate(
'alphabrowselink_html',
[
'%%index%%' => $this->transEsc('browse_' . $index),
'%%from%%' => $this->escapeHtml($from),
'%%url%%' => $this->url('alphabrowse-home')
. '?from=' . urlencode($from) . '&amp;source=' . urlencode($index)
]
);
?>
<div class="info"><?=$link?></div>
\ No newline at end of file
<?
$index = $this->recommend->getIndex();
$from = $this->recommend->getQuery();
$link = $this->translate(
'alphabrowselink_html',
[
'%%index%%' => $this->transEsc('browse_' . $index),
'%%from%%' => $this->escapeHtml($from),
'%%url%%' => $this->url('alphabrowse-home')
. '?from=' . urlencode($from) . '&amp;source=' . urlencode($index)
]
);
?>
<div class="alert alert-info"><?=$link?></div>
\ No newline at end of file
<?
$index = $this->recommend->getIndex();
$from = $this->recommend->getQuery();
$link = $this->translate(
'alphabrowselink_html',
[
'%%index%%' => $this->transEsc('browse_' . $index),
'%%from%%' => $this->escapeHtml($from),
'%%url%%' => $this->url('alphabrowse-home')
. '?from=' . urlencode($from) . '&amp;source=' . urlencode($index)
]
);
?>
<div class="info"><?=$link?></div>
\ No newline at end of file
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