Skip to content

Commit

Permalink
Add ajax mode
Browse files Browse the repository at this point in the history
  • Loading branch information
maccabeelevine committed Dec 19, 2023
1 parent 24a3922 commit 8bcf949
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 0 deletions.
2 changes: 2 additions & 0 deletions config/vufind/searches.ini
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,8 @@ WorkKeys = year
; search results matching the terms found in the specified GET parameter
; (default = "lookfor"), limited to a specified number of matches
; (default = 5).
; ConsortialVuFindDeferred:[requestParam]:[limit]:[ini section]
; Same as ConsortialVuFind, but loaded via AJAX.
; Databases:[result limit]:[ini name]
; Displays a list of the databases referenced in EDS or similar facets, each
; linking to its individual website. The .ini file must contain a [Databases]
Expand Down
67 changes: 67 additions & 0 deletions module/VuFind/src/VuFind/Recommend/ConsortialVuFindDeferred.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?php

/**
* ConsortialVuFindDeferred Recommendations Module
*
* PHP version 8
*
* Copyright (C) Villanova University 2020.
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category VuFind
* @package Recommendations
* @author Demian Katz <[email protected]>
* @author Maccabee Levine <[email protected]>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org/wiki/development:plugins:recommendation_modules Wiki
*/

namespace VuFind\Recommend;

/**
* ConsortialVuFindDeferred Recommendations Module
*
* This class sets up an AJAX call to trigger a call to the ConsortialVuFind module.
*
* Note: ConsortialVuFind is not actually an AbstractSearchObject subclass. But
* AbstractSearchObjectDeferred does not require that.
*
* @category VuFind
* @package Recommendations
* @author Demian Katz <[email protected]>
* @author Maccabee Levine <[email protected]>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org/wiki/development:plugins:recommendation_modules Wiki
*/
class ConsortialVuFindDeferred extends AbstractSearchObjectDeferred
{

/**
* Number of expected module parameters (from .ini config)
*
* @var int
*/
protected $paramCount = 3;

/**
* Store the configuration of the recommendation module.
*
* @return string Module name in call to AjaxHandler
*/
protected function getAjaxModule()
{
return 'ConsortialVuFind';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php
// Set up Javascript for use below:
$loadJs = 'var url = VuFind.path + "/AJAX/Recommend?' . $this->recommend->getUrlParams() . '";'
. "VuFind.loadHtml(\$('#consortialVuFindDeferredRecommend'), url);";
?>
<div id="consortialVuFindDeferredRecommend">
<p><?=$this->icon('spinner') ?> <?=$this->transEsc('loading_ellipsis')?></p>
<?=$this->inlineScript(\Laminas\View\Helper\HeadScript::SCRIPT, $loadJs, 'SET')?>
</div>

0 comments on commit 8bcf949

Please sign in to comment.