Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions module/VuFind/config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@
],
'controllers' => [
'factories' => [
'VuFind\Controller\AjaxController' => 'VuFind\Controller\AjaxControllerFactory',
'VuFind\Controller\AlmaController' => 'VuFind\Controller\AbstractBaseFactory',
'VuFind\Controller\AlphabrowseController' => 'VuFind\Controller\AbstractBaseFactory',
'VuFind\Controller\DeveloperSettingsController' => 'VuFind\Controller\AbstractBaseFactory',
Expand Down Expand Up @@ -243,8 +242,6 @@
'VuFind\ServiceManager\ServiceInitializer',
],
'aliases' => [
'AJAX' => 'VuFind\Controller\AjaxController',
'ajax' => 'VuFind\Controller\AjaxController',
'Alma' => 'VuFind\Controller\AlmaController',
'alma' => 'VuFind\Controller\AlmaController',
'Alphabrowse' => 'VuFind\Controller\AlphabrowseController',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ protected function renderTemplate(
array $params = [],
?string $template = null,
): ResponseInterface {
return $this->getTemplateRenderer()->renderTemplate($request, $response, $params, $template);
return $this->getTemplateRenderer()->renderTemplate($request, $response, $template, $params);
}

/**
Expand Down
92 changes: 92 additions & 0 deletions module/VuFind/src/VuFind/Action/Ajax/JsonAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<?php

/**
* JSON action.
*
* PHP version 8
*
* Copyright (C) The National Library of Finland 2026.
*
* 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, see
* <https://www.gnu.org/licenses/>.
*
* @category VuFind
* @package Action
* @author Ere Maijala <ere.maijala@helsinki.fi>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org Main Site
*/

namespace VuFind\Action\Ajax;

use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use VuFind\Action\AbstractAction;
use VuFind\Action\AjaxResponseTrait;
use VuFind\AjaxHandler\PluginManager as AjaxPluginManager;
use VuFind\I18n\Translator\TranslatorAwareInterface;
use VuFind\I18n\Translator\TranslatorAwareTrait;
use VuFind\ServiceManager\Factory\Autowire;

/**
* JSON action.
*
* @category VuFind
* @package Action
* @author Ere Maijala <ere.maijala@helsinki.fi>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org Main Site
*/
class JsonAction extends AbstractAction implements TranslatorAwareInterface
{
use AjaxResponseTrait;
// For AjaxResponseTrait:
use TranslatorAwareTrait;

/**
* Constructor.
*
* @param AjaxPluginManager $ajaxManager AJAX Handler Plugin Manager
*/
#[Autowire()]
public function __construct(
AjaxPluginManager $ajaxManager
) {
parent::__construct();
$this->ajaxManager = $ajaxManager;
}

/**
* Make an AJAX call with a JSON-formatted response.
*
* @param ServerRequestInterface $request Server request
* @param ResponseInterface $response Response
*
* @return ResponseInterface
*/
public function action(
ServerRequestInterface $request,
ResponseInterface $response,
): ResponseInterface {
$method = $this->getQueryParam('method');
if (!$method) {
return $this->getAjaxResponse(
$response,
'application/json',
['error' => 'Parameter "method" missing'],
400
);
}
return $this->callAjaxMethod($request, $response, $method);
}
}
83 changes: 83 additions & 0 deletions module/VuFind/src/VuFind/Action/Ajax/OnlinePaymentNotifyAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?php

/**
* Handle online payment notification callback.
*
* PHP version 8
*
* Copyright (C) The National Library of Finland 2026.
*
* 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, see
* <https://www.gnu.org/licenses/>.
*
* @category VuFind
* @package Action
* @author Ere Maijala <ere.maijala@helsinki.fi>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org Main Site
*/

namespace VuFind\Action\Ajax;

use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use VuFind\Action\AbstractAction;
use VuFind\Action\AjaxResponseTrait;
use VuFind\AjaxHandler\PluginManager as AjaxPluginManager;
use VuFind\I18n\Translator\TranslatorAwareInterface;
use VuFind\I18n\Translator\TranslatorAwareTrait;
use VuFind\ServiceManager\Factory\Autowire;

/**
* Handle online payment notification callback.
*
* @category VuFind
* @package Action
* @author Ere Maijala <ere.maijala@helsinki.fi>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org Main Site
*/
class OnlinePaymentNotifyAction extends AbstractAction implements TranslatorAwareInterface
{
use AjaxResponseTrait;
// For AjaxResponseTrait:
use TranslatorAwareTrait;

/**
* Constructor.
*
* @param AjaxPluginManager $ajaxManager AJAX Handler Plugin Manager
*/
#[Autowire()]
public function __construct(
AjaxPluginManager $ajaxManager
) {
parent::__construct();
$this->ajaxManager = $ajaxManager;
}

/**
* Make an AJAX call with a JSON-formatted response.
*
* @param ServerRequestInterface $request Server request
* @param ResponseInterface $response Response
*
* @return ResponseInterface
*/
public function action(
ServerRequestInterface $request,
ResponseInterface $response,
): ResponseInterface {
return $this->callAjaxMethod($request, $response, 'onlinePaymentNotify', 'text/html');
}
}
83 changes: 83 additions & 0 deletions module/VuFind/src/VuFind/Action/Ajax/RecommendAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?php

/**
* Load a recommendation module via AJAX.
*
* PHP version 8
*
* Copyright (C) The National Library of Finland 2026.
*
* 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, see
* <https://www.gnu.org/licenses/>.
*
* @category VuFind
* @package Action
* @author Ere Maijala <ere.maijala@helsinki.fi>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org Main Site
*/

namespace VuFind\Action\Ajax;

use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use VuFind\Action\AbstractAction;
use VuFind\Action\AjaxResponseTrait;
use VuFind\AjaxHandler\PluginManager as AjaxPluginManager;
use VuFind\I18n\Translator\TranslatorAwareInterface;
use VuFind\I18n\Translator\TranslatorAwareTrait;
use VuFind\ServiceManager\Factory\Autowire;

/**
* Load a recommendation module via AJAX.
*
* @category VuFind
* @package Action
* @author Ere Maijala <ere.maijala@helsinki.fi>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org Main Site
*/
class RecommendAction extends AbstractAction implements TranslatorAwareInterface
{
use AjaxResponseTrait;
// For AjaxResponseTrait:
use TranslatorAwareTrait;

/**
* Constructor.
*
* @param AjaxPluginManager $ajaxManager AJAX Handler Plugin Manager
*/
#[Autowire()]
public function __construct(
AjaxPluginManager $ajaxManager
) {
parent::__construct();
$this->ajaxManager = $ajaxManager;
}

/**
* Make an AJAX call with a JSON-formatted response.
*
* @param ServerRequestInterface $request Server request
* @param ResponseInterface $response Response
*
* @return ResponseInterface
*/
public function action(
ServerRequestInterface $request,
ResponseInterface $response,
): ResponseInterface {
return $this->callAjaxMethod($request, $response, 'recommend', 'text/html');
}
}
83 changes: 83 additions & 0 deletions module/VuFind/src/VuFind/Action/Ajax/SystemStatusAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?php

/**
* Check status and return a status message for e.g. a load balancer.
*
* PHP version 8
*
* Copyright (C) The National Library of Finland 2026.
*
* 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, see
* <https://www.gnu.org/licenses/>.
*
* @category VuFind
* @package Action
* @author Ere Maijala <ere.maijala@helsinki.fi>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org Main Site
*/

namespace VuFind\Action\Ajax;

use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use VuFind\Action\AbstractAction;
use VuFind\Action\AjaxResponseTrait;
use VuFind\AjaxHandler\PluginManager as AjaxPluginManager;
use VuFind\I18n\Translator\TranslatorAwareInterface;
use VuFind\I18n\Translator\TranslatorAwareTrait;
use VuFind\ServiceManager\Factory\Autowire;

/**
* Check status and return a status message for e.g. a load balancer.
*
* @category VuFind
* @package Action
* @author Ere Maijala <ere.maijala@helsinki.fi>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org Main Site
*/
class SystemStatusAction extends AbstractAction implements TranslatorAwareInterface
{
use AjaxResponseTrait;
// For AjaxResponseTrait:
use TranslatorAwareTrait;

/**
* Constructor.
*
* @param AjaxPluginManager $ajaxManager AJAX Handler Plugin Manager
*/
#[Autowire()]
public function __construct(
AjaxPluginManager $ajaxManager
) {
parent::__construct();
$this->ajaxManager = $ajaxManager;
}

/**
* Make an AJAX call with a JSON-formatted response.
*
* @param ServerRequestInterface $request Server request
* @param ResponseInterface $response Response
*
* @return ResponseInterface
*/
public function action(
ServerRequestInterface $request,
ResponseInterface $response,
): ResponseInterface {
return $this->callAjaxMethod($request, $response, 'systemStatus', 'text/plain');
}
}
Loading
Loading