Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
EuropeanaResultsDeferred
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
2 / 2
4
100.00% covered (success)
100.00%
1 / 1
 initLookFor
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
3
 getAjaxModule
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3/**
4 * EuropeanaResultsDeferred Recommendations Module
5 *
6 * PHP version 8
7 *
8 * Copyright (C) Villanova University 2010.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2,
12 * as published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
22 *
23 * @category VuFind
24 * @package  Recommendations
25 * @author   Lutz Biedinger <lutz.biedinger@gmail.com>
26 * @author   Demian Katz <demian.katz@villanova.edu>
27 * @license  http://opensource.org/licenses/gpl-2.0.php GNU General Public License
28 * @link     https://vufind.org/wiki/development:plugins:recommendation_modules Wiki
29 */
30
31namespace VuFind\Recommend;
32
33use function is_object;
34
35/**
36 * EuropeanaResultsDeferred Recommendations Module
37 *
38 * This class sets up an AJAX call to trigger a call to the EuropeanaResults
39 * module.
40 *
41 * @category VuFind
42 * @package  Recommendations
43 * @author   Lutz Biedinger <lutz.biedigner@gmail.com>
44 * @license  http://opensource.org/licenses/gpl-2.0.php GNU General Public License
45 * @link     https://vufind.org/wiki/development:plugins:recommendation_modules Wiki
46 */
47class EuropeanaResultsDeferred extends AbstractSearchObjectDeferred
48{
49    /**
50     * Number of expected module parameters (from .ini config)
51     *
52     * @var int
53     */
54    protected $paramCount = 4;
55
56    /**
57     * Initialize the lookFor query parameter. Called from init().
58     *
59     * @param \VuFind\Search\Base\Params $params   Search parameter object
60     * @param \Laminas\Stdlib\Parameters $request  Parameter object representing user
61     * request.
62     * @param array                      $settings Parameter array (passed by reference)
63     *
64     * @return void
65     */
66    protected function initLookFor($params, $request, &$settings)
67    {
68        // Collect the best possible search term(s):
69        $this->lookfor = $request->get('lookfor', '');
70        if (empty($this->lookfor) && is_object($params)) {
71            $this->lookfor = $params->getQuery()->getAllTerms();
72        }
73        $this->lookfor = trim($this->lookfor);
74    }
75
76    /**
77     * Store the configuration of the recommendation module.
78     *
79     * @return string Module name in call to AjaxHandler
80     */
81    protected function getAjaxModule()
82    {
83        return 'EuropeanaResults';
84    }
85}