first commit
This commit is contained in:
@@ -0,0 +1,132 @@
|
||||
<?php
|
||||
/**
|
||||
* @defgroup linkAction LinkActions
|
||||
* Link actions are representations of various kinds of actions that can be
|
||||
* invoked by clicking a link.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file classes/linkAction/LinkAction.php
|
||||
*
|
||||
* Copyright (c) 2014-2021 Simon Fraser University
|
||||
* Copyright (c) 2000-2021 John Willinsky
|
||||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
|
||||
*
|
||||
* @class LinkAction
|
||||
*
|
||||
* @ingroup linkAction
|
||||
*
|
||||
* @brief Base class defining an action that can be performed by the user
|
||||
* in the user interface.
|
||||
*/
|
||||
|
||||
namespace PKP\linkAction;
|
||||
|
||||
use PKP\linkAction\request\LinkActionRequest;
|
||||
use PKP\plugins\Hook;
|
||||
|
||||
class LinkAction
|
||||
{
|
||||
/** @var string the id of the action */
|
||||
public $_id;
|
||||
|
||||
/** @var LinkActionRequest The action to be taken when the link action is activated */
|
||||
public $_actionRequest;
|
||||
|
||||
/** @var string The localized title of the action. */
|
||||
public $_title;
|
||||
|
||||
/** @var string The localized tool tip of the action. */
|
||||
public $_toolTip;
|
||||
|
||||
/** @var string The name of an icon for the action. */
|
||||
public $_image;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $id
|
||||
* @param LinkActionRequest $actionRequest The action to be taken when the link action is activated.
|
||||
* @param string $title (optional) The localized title of the action.
|
||||
* @param string $image (optional) The name of an icon for the
|
||||
* action.
|
||||
* @param string $toolTip (optional) A localized tool tip to display when hovering over
|
||||
* the link action.
|
||||
*/
|
||||
public function __construct($id, $actionRequest, $title = null, $image = null, $toolTip = null)
|
||||
{
|
||||
$this->_id = $id;
|
||||
assert($actionRequest instanceof LinkActionRequest);
|
||||
$this->_actionRequest = $actionRequest;
|
||||
$this->_title = $title;
|
||||
$this->_image = $image;
|
||||
$this->_toolTip = $toolTip;
|
||||
Hook::call('LinkAction::construct', [$this]);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Getters and Setters
|
||||
//
|
||||
/**
|
||||
* Get the action id.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the action handler.
|
||||
*
|
||||
* @return LinkActionRequest
|
||||
*/
|
||||
public function getActionRequest()
|
||||
{
|
||||
return $this->_actionRequest;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the localized action title.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->_title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the localized action title.
|
||||
*/
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->_title = $title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the localized tool tip.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getToolTip()
|
||||
{
|
||||
return $this->_toolTip;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the action image.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getImage()
|
||||
{
|
||||
return $this->_image;
|
||||
}
|
||||
}
|
||||
|
||||
if (!PKP_STRICT_MODE) {
|
||||
class_alias('\PKP\linkAction\LinkAction', '\LinkAction');
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
* @file classes/linkAction/request/AddTabAction.php
|
||||
*
|
||||
* Copyright (c) 2014-2021 Simon Fraser University
|
||||
* Copyright (c) 2000-2021 John Willinsky
|
||||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
|
||||
*
|
||||
* @class AddTabAction
|
||||
*
|
||||
* @ingroup linkAction_request
|
||||
*
|
||||
* @brief This action triggers a containing tabset to add a new tab.
|
||||
*/
|
||||
|
||||
namespace PKP\linkAction\request;
|
||||
|
||||
class AddTabAction extends EventAction
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $targetSelector Selector for target to receive event.
|
||||
*/
|
||||
public function __construct($targetSelector, $url, $title)
|
||||
{
|
||||
parent::__construct($targetSelector, 'addTab', [
|
||||
'url' => $url,
|
||||
'title' => $title,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
if (!PKP_STRICT_MODE) {
|
||||
class_alias('\PKP\linkAction\request\AddTabAction', '\AddTabAction');
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
/**
|
||||
* @file classes/linkAction/request/AjaxAction.php
|
||||
*
|
||||
* Copyright (c) 2014-2021 Simon Fraser University
|
||||
* Copyright (c) 2000-2021 John Willinsky
|
||||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
|
||||
*
|
||||
* @class AjaxAction
|
||||
*
|
||||
* @ingroup linkAction_request
|
||||
*
|
||||
* @brief Class defining an AJAX action.
|
||||
*/
|
||||
|
||||
namespace PKP\linkAction\request;
|
||||
|
||||
use APP\core\Application;
|
||||
|
||||
class AjaxAction extends LinkActionRequest
|
||||
{
|
||||
public const AJAX_REQUEST_TYPE_GET = 'get';
|
||||
public const AJAX_REQUEST_TYPE_POST = 'post';
|
||||
|
||||
/** @var string */
|
||||
public $_remoteAction;
|
||||
|
||||
/** @var string */
|
||||
public $_requestType;
|
||||
|
||||
/** @var array */
|
||||
public $_requestData;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $remoteAction The target URL.
|
||||
* @param string $requestType One of the AJAX_REQUEST_TYPE_* constants.
|
||||
* @param array $requestData Any request data (e.g. POST params) to be sent.
|
||||
*/
|
||||
public function __construct($remoteAction, $requestType = self::AJAX_REQUEST_TYPE_POST, $requestData = [])
|
||||
{
|
||||
parent::__construct();
|
||||
$this->_remoteAction = $remoteAction;
|
||||
$this->_requestType = $requestType;
|
||||
$this->_requestData = array_merge($requestData, [
|
||||
'csrfToken' => Application::get()->getRequest()->getSession()->getCSRFToken(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Getters and Setters
|
||||
//
|
||||
/**
|
||||
* Get the target URL.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRemoteAction()
|
||||
{
|
||||
return $this->_remoteAction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the request type.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRequestType()
|
||||
{
|
||||
return $this->_requestType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the request data.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getRequestData()
|
||||
{
|
||||
return $this->_requestData;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Overridden protected methods from LinkActionRequest
|
||||
//
|
||||
/**
|
||||
* @see LinkActionRequest::getJSLinkActionRequest()
|
||||
*/
|
||||
public function getJSLinkActionRequest()
|
||||
{
|
||||
return '$.pkp.classes.linkAction.AjaxRequest';
|
||||
}
|
||||
|
||||
/**
|
||||
* @see LinkActionRequest::getLocalizedOptions()
|
||||
*/
|
||||
public function getLocalizedOptions()
|
||||
{
|
||||
return [
|
||||
'url' => $this->getRemoteAction(),
|
||||
'requestType' => $this->getRequestType(),
|
||||
'data' => $this->getRequestData(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
if (!PKP_STRICT_MODE) {
|
||||
class_alias('\PKP\linkAction\request\AjaxAction', '\AjaxAction');
|
||||
foreach ([
|
||||
'AJAX_REQUEST_TYPE_GET',
|
||||
'AJAX_REQUEST_TYPE_POST',
|
||||
] as $constantName) {
|
||||
define($constantName, constant('\AjaxAction::' . $constantName));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
/**
|
||||
* @file classes/linkAction/request/AjaxModal.php
|
||||
*
|
||||
* Copyright (c) 2014-2021 Simon Fraser University
|
||||
* Copyright (c) 2000-2021 John Willinsky
|
||||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
|
||||
*
|
||||
* @class AjaxModal
|
||||
*
|
||||
* @ingroup linkAction_request
|
||||
*
|
||||
* @brief A modal that retrieves its content from via AJAX.
|
||||
*/
|
||||
|
||||
namespace PKP\linkAction\request;
|
||||
|
||||
class AjaxModal extends Modal
|
||||
{
|
||||
/** @var string The URL to be loaded into the modal. */
|
||||
public $_url;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $url The URL of the AJAX resource to load into the modal.
|
||||
* @param string $title (optional) The localized modal title.
|
||||
* @param string $titleIcon (optional) The icon to be used in the modal title bar.
|
||||
* @param bool $canClose (optional) Whether the modal will have a close button.
|
||||
* @param string $closeOnFormSuccessId (optional) Close the modal when the
|
||||
* form with this id fires a formSuccess event.
|
||||
* @param array $closeCleanVueInstances (optional) When the modal is closed
|
||||
* destroy the registered vue instances with these ids
|
||||
*/
|
||||
public function __construct(
|
||||
$url,
|
||||
$title = null,
|
||||
$titleIcon = null,
|
||||
$canClose = true,
|
||||
$closeOnFormSuccessId = null,
|
||||
$closeCleanVueInstances = []
|
||||
) {
|
||||
parent::__construct($title, $titleIcon, $canClose, $closeOnFormSuccessId, $closeCleanVueInstances);
|
||||
|
||||
$this->_url = $url;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Getters and Setters
|
||||
//
|
||||
/**
|
||||
* Get the URL to be loaded into the modal.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUrl()
|
||||
{
|
||||
return $this->_url;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Overridden methods from LinkActionRequest
|
||||
//
|
||||
/**
|
||||
* @see LinkActionRequest::getLocalizedOptions()
|
||||
*/
|
||||
public function getLocalizedOptions()
|
||||
{
|
||||
return array_merge(
|
||||
parent::getLocalizedOptions(),
|
||||
[
|
||||
'modalHandler' => '$.pkp.controllers.modal.AjaxModalHandler',
|
||||
'url' => $this->getUrl(),
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (!PKP_STRICT_MODE) {
|
||||
class_alias('\PKP\linkAction\request\AjaxModal', '\AjaxModal');
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
/**
|
||||
* @file classes/linkAction/request/ConfirmationModal.php
|
||||
*
|
||||
* Copyright (c) 2014-2021 Simon Fraser University
|
||||
* Copyright (c) 2000-2021 John Willinsky
|
||||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
|
||||
*
|
||||
* @class ConfirmationModal
|
||||
*
|
||||
* @ingroup linkAction_request
|
||||
*
|
||||
* @brief Class defining a simple confirmation modal either with remote action or not.
|
||||
*/
|
||||
|
||||
namespace PKP\linkAction\request;
|
||||
|
||||
class ConfirmationModal extends Modal
|
||||
{
|
||||
/**
|
||||
* @var string A translation key defining the text for the confirmation
|
||||
* button of the modal.
|
||||
*/
|
||||
public $_okButton;
|
||||
|
||||
/**
|
||||
* @var string a translation key defining the text for the cancel
|
||||
* button of the modal.
|
||||
*/
|
||||
public $_cancelButton;
|
||||
|
||||
/**
|
||||
* @var string a translation key defining the text for the dialog
|
||||
* text.
|
||||
*/
|
||||
public $_dialogText;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $dialogText The localized text to appear
|
||||
* in the dialog modal.
|
||||
* @param string $title (optional) The localized modal title.
|
||||
* @param string $titleIcon (optional) The icon to be used
|
||||
* in the modal title bar.
|
||||
* @param string $okButton (optional) The localized text to
|
||||
* appear on the confirmation button.
|
||||
* @param string $cancelButton (optional) The localized text to
|
||||
* appear on the cancel button.
|
||||
* @param bool $canClose (optional) Whether the modal will
|
||||
* have a close button.
|
||||
*/
|
||||
public function __construct($dialogText, $title = null, $titleIcon = 'modal_confirm', $okButton = null, $cancelButton = null, $canClose = true)
|
||||
{
|
||||
$title = (is_null($title) ? __('common.confirm') : $title);
|
||||
parent::__construct($title, $titleIcon, $canClose);
|
||||
|
||||
$this->_okButton = (is_null($okButton) ? __('common.ok') : $okButton);
|
||||
$this->_cancelButton = (is_null($cancelButton) ? __('common.cancel') : $cancelButton);
|
||||
$this->_dialogText = $dialogText;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Getters and Setters
|
||||
//
|
||||
/**
|
||||
* Get the translation key for the confirmation
|
||||
* button text.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getOkButton()
|
||||
{
|
||||
return $this->_okButton;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the translation key for the cancel
|
||||
* button text.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCancelButton()
|
||||
{
|
||||
return $this->_cancelButton;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the translation key for the dialog
|
||||
* text.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDialogText()
|
||||
{
|
||||
return $this->_dialogText;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Overridden methods from LinkActionRequest
|
||||
//
|
||||
/**
|
||||
* @see LinkActionRequest::getLocalizedOptions()
|
||||
*/
|
||||
public function getLocalizedOptions()
|
||||
{
|
||||
return array_merge(parent::getLocalizedOptions(), [
|
||||
'modalHandler' => '$.pkp.controllers.modal.ConfirmationModalHandler',
|
||||
'okButton' => $this->getOkButton(),
|
||||
'cancelButton' => $this->getCancelButton(),
|
||||
'dialogText' => $this->getDialogText()]);
|
||||
}
|
||||
}
|
||||
|
||||
if (!PKP_STRICT_MODE) {
|
||||
class_alias('\PKP\linkAction\request\ConfirmationModal', '\ConfirmationModal');
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
/**
|
||||
* @file classes/linkAction/request/EventAction.php
|
||||
*
|
||||
* Copyright (c) 2014-2021 Simon Fraser University
|
||||
* Copyright (c) 2000-2021 John Willinsky
|
||||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
|
||||
*
|
||||
* @class EventAction
|
||||
*
|
||||
* @ingroup linkAction_request
|
||||
*
|
||||
* @brief This action triggers a Javascript event.
|
||||
*/
|
||||
|
||||
namespace PKP\linkAction\request;
|
||||
|
||||
class EventAction extends LinkActionRequest
|
||||
{
|
||||
/** @var string Target selector */
|
||||
public $targetSelector;
|
||||
|
||||
/** @var string Event name */
|
||||
public $eventName;
|
||||
|
||||
/** @var array Event options */
|
||||
public $options;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $targetSelector Selector for target to receive event.
|
||||
* @param string $eventName Name of Javascript event to trigger.
|
||||
*/
|
||||
public function __construct($targetSelector, $eventName, $options = [])
|
||||
{
|
||||
parent::__construct();
|
||||
$this->targetSelector = $targetSelector;
|
||||
$this->eventName = $eventName;
|
||||
$this->options = $options;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Overridden protected methods from LinkActionRequest
|
||||
//
|
||||
/**
|
||||
* @see LinkActionRequest::getJSLinkActionRequest()
|
||||
*/
|
||||
public function getJSLinkActionRequest()
|
||||
{
|
||||
return '$.pkp.classes.linkAction.EventAction';
|
||||
}
|
||||
|
||||
/**
|
||||
* @see LinkActionRequest::getLocalizedOptions()
|
||||
*/
|
||||
public function getLocalizedOptions()
|
||||
{
|
||||
return array_merge(
|
||||
$this->options,
|
||||
[
|
||||
'target' => $this->targetSelector,
|
||||
'event' => $this->eventName,
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (!PKP_STRICT_MODE) {
|
||||
class_alias('\PKP\linkAction\request\EventAction', '\EventAction');
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
/**
|
||||
* @file classes/linkAction/request/JsEventConfirmationModal.php
|
||||
*
|
||||
* Copyright (c) 2014-2021 Simon Fraser University
|
||||
* Copyright (c) 2000-2021 John Willinsky
|
||||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
|
||||
*
|
||||
* @class JsEventConfirmationModal
|
||||
*
|
||||
* @ingroup linkAction_request
|
||||
*
|
||||
* @brief Class defining a simple confirmation modal which generates a JS event and ok/cancel buttons.
|
||||
*/
|
||||
|
||||
namespace PKP\linkAction\request;
|
||||
|
||||
use PKP\core\JSONMessage;
|
||||
|
||||
class JsEventConfirmationModal extends ConfirmationModal
|
||||
{
|
||||
/** @var string The name of the event to be generated when this modal is confirmed */
|
||||
public $_event;
|
||||
|
||||
/** @var array extra arguments to be passed to the JS controller */
|
||||
public $_extraArguments;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $dialogText The localized text to appear
|
||||
* in the dialog modal.
|
||||
* @param string $event the name of the JS event.
|
||||
* @param array $extraArguments (optional) extra information to be passed as JSON data with the event.
|
||||
* @param string $title (optional) The localized modal title.
|
||||
* @param string $titleIcon (optional) The icon to be used
|
||||
* in the modal title bar.
|
||||
* @param string $okButton (optional) The localized text to
|
||||
* appear on the confirmation button.
|
||||
* @param string $cancelButton (optional) The localized text to
|
||||
* appear on the cancel button.
|
||||
* @param bool $canClose (optional) Whether the modal will
|
||||
* have a close button.
|
||||
*/
|
||||
public function __construct($dialogText, $event = 'confirmationModalConfirmed', $extraArguments = null, $title = null, $titleIcon = null, $okButton = null, $cancelButton = null, $canClose = true)
|
||||
{
|
||||
parent::__construct($dialogText, $title, $titleIcon, $okButton, $cancelButton, $canClose);
|
||||
|
||||
$this->_event = $event;
|
||||
$this->_extraArguments = $extraArguments;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Getters and Setters
|
||||
//
|
||||
/**
|
||||
* Get the event.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getEvent()
|
||||
{
|
||||
return $this->_event;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the extra arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getExtraArguments()
|
||||
{
|
||||
return $this->_extraArguments;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Overridden methods from LinkActionRequest
|
||||
//
|
||||
/**
|
||||
* @see LinkActionRequest::getLocalizedOptions()
|
||||
*/
|
||||
public function getLocalizedOptions()
|
||||
{
|
||||
$parentLocalizedOptions = parent::getLocalizedOptions();
|
||||
// override the modalHandler option.
|
||||
$parentLocalizedOptions['modalHandler'] = '$.pkp.controllers.modal.JsEventConfirmationModalHandler';
|
||||
$parentLocalizedOptions['jsEvent'] = $this->getEvent();
|
||||
if (is_array($this->getExtraArguments())) {
|
||||
$json = new JSONMessage();
|
||||
$json->setContent($this->getExtraArguments());
|
||||
$parentLocalizedOptions['extraArguments'] = $json->getString();
|
||||
}
|
||||
return $parentLocalizedOptions;
|
||||
}
|
||||
}
|
||||
|
||||
if (!PKP_STRICT_MODE) {
|
||||
class_alias('\PKP\linkAction\request\JsEventConfirmationModal', '\JsEventConfirmationModal');
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
/**
|
||||
* @defgroup linkAction_request Link Action Request
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file classes/linkAction/request/LinkActionRequest.php
|
||||
*
|
||||
* Copyright (c) 2014-2021 Simon Fraser University
|
||||
* Copyright (c) 2000-2021 John Willinsky
|
||||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
|
||||
*
|
||||
* @class LinkActionRequest
|
||||
*
|
||||
* @ingroup linkAction_request
|
||||
*
|
||||
* @brief Abstract base class defining an action to be taken when a link action is activated.
|
||||
*/
|
||||
|
||||
namespace PKP\linkAction\request;
|
||||
|
||||
class LinkActionRequest
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Public methods
|
||||
//
|
||||
/**
|
||||
* Return the JavaScript controller that will
|
||||
* handle this request.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getJSLinkActionRequest()
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the options to be passed on to the
|
||||
* JS action request handler.
|
||||
*
|
||||
* @return array An array describing the dialog
|
||||
* options.
|
||||
*/
|
||||
public function getLocalizedOptions()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
if (!PKP_STRICT_MODE) {
|
||||
class_alias('\PKP\linkAction\request\LinkActionRequest', '\LinkActionRequest');
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
<?php
|
||||
/**
|
||||
* @file classes/linkAction/request/Modal.php
|
||||
*
|
||||
* Copyright (c) 2014-2021 Simon Fraser University
|
||||
* Copyright (c) 2000-2021 John Willinsky
|
||||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
|
||||
*
|
||||
* @class Modal
|
||||
*
|
||||
* @ingroup linkAction_request
|
||||
*
|
||||
* @brief Abstract base class for all modal dialogs.
|
||||
*/
|
||||
|
||||
namespace PKP\linkAction\request;
|
||||
|
||||
define('MODAL_WIDTH_DEFAULT', '710');
|
||||
define('MODAL_WIDTH_AUTO', 'auto');
|
||||
|
||||
|
||||
class Modal extends LinkActionRequest
|
||||
{
|
||||
/** @var string The localized title of the modal. */
|
||||
public $_title;
|
||||
|
||||
/** @var string The icon to be displayed in the title bar. */
|
||||
public $_titleIcon;
|
||||
|
||||
/** @var bool Whether the modal has a close icon in the title bar. */
|
||||
public $_canClose;
|
||||
|
||||
/** @var string The id of a form which should close the modal when completed */
|
||||
public $_closeOnFormSuccessId;
|
||||
|
||||
/** @var array The id of any Vue instances that must be destroyed when modal closed */
|
||||
public $_closeCleanVueInstances;
|
||||
|
||||
/** @var string Text for the close button */
|
||||
public $_closeButtonText;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $title (optional) The localized modal title.
|
||||
* @param string $titleIcon (optional) The icon to be used in the modal title bar.
|
||||
* @param bool $canClose (optional) Whether the modal will have a close button.
|
||||
* @param string $closeOnFormSuccessId (optional) Close the modal when the
|
||||
* form with this id fires a formSuccess event.
|
||||
* @param array $closeCleanVueInstances (optional) When the modal is closed
|
||||
* destroy the registered vue instances with these ids
|
||||
*/
|
||||
public function __construct(
|
||||
$title = null,
|
||||
$titleIcon = null,
|
||||
$canClose = true,
|
||||
$closeOnFormSuccessId = null,
|
||||
$closeCleanVueInstances = []
|
||||
) {
|
||||
parent::__construct();
|
||||
$this->_title = $title;
|
||||
$this->_titleIcon = $titleIcon;
|
||||
$this->_canClose = $canClose;
|
||||
$this->_closeOnFormSuccessId = $closeOnFormSuccessId;
|
||||
$this->_closeCleanVueInstances = $closeCleanVueInstances;
|
||||
// @todo this should be customizable via an option
|
||||
$this->_closeButtonText = __('common.closePanel');
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Getters and Setters
|
||||
//
|
||||
/**
|
||||
* Get the localized title.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->_title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the title bar icon.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTitleIcon()
|
||||
{
|
||||
return $this->_titleIcon;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the modal has a close icon in the title bar.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getCanClose()
|
||||
{
|
||||
return $this->_canClose;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the text to be displayed on the close button for screen readers
|
||||
*/
|
||||
public function getCloseButtonText()
|
||||
{
|
||||
return $this->_closeButtonText;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Overridden methods from LinkActionRequest
|
||||
//
|
||||
/**
|
||||
* @see LinkActionRequest::getJSLinkActionRequest()
|
||||
*/
|
||||
public function getJSLinkActionRequest()
|
||||
{
|
||||
return '$.pkp.classes.linkAction.ModalRequest';
|
||||
}
|
||||
|
||||
/**
|
||||
* @see LinkActionRequest::getLocalizedOptions()
|
||||
*/
|
||||
public function getLocalizedOptions()
|
||||
{
|
||||
return [
|
||||
'title' => $this->getTitle(),
|
||||
'titleIcon' => $this->getTitleIcon(),
|
||||
'canClose' => ($this->getCanClose() ? '1' : '0'),
|
||||
'closeOnFormSuccessId' => $this->_closeOnFormSuccessId,
|
||||
'closeCleanVueInstances' => $this->_closeCleanVueInstances,
|
||||
'closeButtonText' => $this->getCloseButtonText(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
if (!PKP_STRICT_MODE) {
|
||||
class_alias('\PKP\linkAction\request\Modal', '\Modal');
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* @file classes/linkAction/request/NullAction.php
|
||||
*
|
||||
* Copyright (c) 2014-2021 Simon Fraser University
|
||||
* Copyright (c) 2000-2021 John Willinsky
|
||||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
|
||||
*
|
||||
* @class NullAction
|
||||
*
|
||||
* @ingroup linkAction_request
|
||||
*
|
||||
* @brief This action does nothing.
|
||||
*/
|
||||
|
||||
namespace PKP\linkAction\request;
|
||||
|
||||
class NullAction extends LinkActionRequest
|
||||
{
|
||||
//
|
||||
// Overridden protected methods from LinkActionRequest
|
||||
//
|
||||
/**
|
||||
* @see LinkActionRequest::getJSLinkActionRequest()
|
||||
*/
|
||||
public function getJSLinkActionRequest()
|
||||
{
|
||||
return '$.pkp.classes.linkAction.NullAction';
|
||||
}
|
||||
}
|
||||
|
||||
if (!PKP_STRICT_MODE) {
|
||||
class_alias('\PKP\linkAction\request\NullAction', '\NullAction');
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/**
|
||||
* @file classes/linkAction/request/OpenWindowAction.php
|
||||
*
|
||||
* Copyright (c) 2014-2021 Simon Fraser University
|
||||
* Copyright (c) 2000-2021 John Willinsky
|
||||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
|
||||
*
|
||||
* @class OpenWindowAction
|
||||
*
|
||||
* @ingroup linkAction_request
|
||||
*
|
||||
* @brief This action request redirects to another page.
|
||||
*/
|
||||
|
||||
namespace PKP\linkAction\request;
|
||||
|
||||
class OpenWindowAction extends LinkActionRequest
|
||||
{
|
||||
/** @var string The URL this action will invoke */
|
||||
public $_url;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $url Target URL
|
||||
*/
|
||||
public function __construct($url)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->_url = $url;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Getters and Setters
|
||||
//
|
||||
/**
|
||||
* Get the target URL.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUrl()
|
||||
{
|
||||
return $this->_url;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Overridden protected methods from LinkActionRequest
|
||||
//
|
||||
/**
|
||||
* @see LinkActionRequest::getJSLinkActionRequest()
|
||||
*/
|
||||
public function getJSLinkActionRequest()
|
||||
{
|
||||
return '$.pkp.classes.linkAction.OpenWindowRequest';
|
||||
}
|
||||
|
||||
/**
|
||||
* @see LinkActionRequest::getLocalizedOptions()
|
||||
*/
|
||||
public function getLocalizedOptions()
|
||||
{
|
||||
return ['url' => $this->getUrl()];
|
||||
}
|
||||
}
|
||||
|
||||
if (!PKP_STRICT_MODE) {
|
||||
class_alias('\PKP\linkAction\request\OpenWindowAction', '\OpenWindowAction');
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
/**
|
||||
* @file classes/linkAction/request/PostAndRedirectAction.php
|
||||
*
|
||||
* Copyright (c) 2014-2021 Simon Fraser University
|
||||
* Copyright (c) 2000-2021 John Willinsky
|
||||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
|
||||
*
|
||||
* @class PostAndRedirectAction
|
||||
*
|
||||
* @ingroup linkAction_request
|
||||
*
|
||||
* @brief Class defining a post and redirect action. See PostAndRedirectRequest.js
|
||||
* to detailed description.
|
||||
*/
|
||||
|
||||
namespace PKP\linkAction\request;
|
||||
|
||||
class PostAndRedirectAction extends RedirectAction
|
||||
{
|
||||
/** @var string The url to be used for posting data */
|
||||
public $_postUrl;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $postUrl The target URL to post data.
|
||||
* @param string $redirectUrl The target URL to redirect.
|
||||
*/
|
||||
public function __construct($postUrl, $redirectUrl)
|
||||
{
|
||||
parent::__construct($redirectUrl);
|
||||
$this->_postUrl = $postUrl;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Getters and Setters
|
||||
//
|
||||
/**
|
||||
* Get the url to post data.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPostUrl()
|
||||
{
|
||||
return $this->_postUrl;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Overridden protected methods from LinkActionRequest
|
||||
//
|
||||
/**
|
||||
* @see LinkActionRequest::getJSLinkActionRequest()
|
||||
*/
|
||||
public function getJSLinkActionRequest()
|
||||
{
|
||||
return '$.pkp.classes.linkAction.PostAndRedirectRequest';
|
||||
}
|
||||
|
||||
/**
|
||||
* @see LinkActionRequest::getLocalizedOptions()
|
||||
*/
|
||||
public function getLocalizedOptions()
|
||||
{
|
||||
$options = parent::getLocalizedOptions();
|
||||
return array_merge(
|
||||
$options,
|
||||
['postUrl' => $this->getPostUrl()]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (!PKP_STRICT_MODE) {
|
||||
class_alias('\PKP\linkAction\request\PostAndRedirectAction', '\PostAndRedirectAction');
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
/**
|
||||
* @file classes/linkAction/request/RedirectAction.php
|
||||
*
|
||||
* Copyright (c) 2014-2021 Simon Fraser University
|
||||
* Copyright (c) 2000-2021 John Willinsky
|
||||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
|
||||
*
|
||||
* @class RedirectAction
|
||||
*
|
||||
* @ingroup linkAction_request
|
||||
*
|
||||
* @brief This action request redirects to another page.
|
||||
*/
|
||||
|
||||
namespace PKP\linkAction\request;
|
||||
|
||||
class RedirectAction extends LinkActionRequest
|
||||
{
|
||||
/** @var string The URL this action will invoke */
|
||||
public $_url;
|
||||
|
||||
/** @var string The name of the window */
|
||||
public $_name;
|
||||
|
||||
/** @var string The specifications of the window */
|
||||
public $_specs;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $url Target URL
|
||||
* @param string $name Name of window to direct (defaults to current window)
|
||||
* @param string $specs Optional set of window specs (see window.open JS reference)
|
||||
*/
|
||||
public function __construct($url, $name = '_self', $specs = '')
|
||||
{
|
||||
parent::__construct();
|
||||
$this->_url = $url;
|
||||
$this->_name = $name;
|
||||
$this->_specs = $specs;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Getters and Setters
|
||||
//
|
||||
/**
|
||||
* Get the target URL.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUrl()
|
||||
{
|
||||
return $this->_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the target name.
|
||||
* See JS reference for the name parameter to "window.open".
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the target specifications.
|
||||
* See JS reference for the specs parameter to "window.open".
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSpecs()
|
||||
{
|
||||
return $this->_specs;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Overridden protected methods from LinkActionRequest
|
||||
//
|
||||
/**
|
||||
* @see LinkActionRequest::getJSLinkActionRequest()
|
||||
*/
|
||||
public function getJSLinkActionRequest()
|
||||
{
|
||||
return '$.pkp.classes.linkAction.RedirectRequest';
|
||||
}
|
||||
|
||||
/**
|
||||
* @see LinkActionRequest::getLocalizedOptions()
|
||||
*/
|
||||
public function getLocalizedOptions()
|
||||
{
|
||||
return [
|
||||
'url' => $this->getUrl(),
|
||||
'name' => $this->getName(),
|
||||
'specs' => $this->getSpecs()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
if (!PKP_STRICT_MODE) {
|
||||
class_alias('\PKP\linkAction\request\RedirectAction', '\RedirectAction');
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
/**
|
||||
* @file classes/linkAction/request/RedirectConfirmationModal.php
|
||||
*
|
||||
* Copyright (c) 2014-2021 Simon Fraser University
|
||||
* Copyright (c) 2000-2021 John Willinsky
|
||||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
|
||||
*
|
||||
* @class RedirectConfirmationModal
|
||||
*
|
||||
* @ingroup linkAction_request
|
||||
*
|
||||
* @brief Class defining a simple confirmation modal with a redirect url and ok/cancel buttons.
|
||||
*/
|
||||
|
||||
namespace PKP\linkAction\request;
|
||||
|
||||
class RedirectConfirmationModal extends ConfirmationModal
|
||||
{
|
||||
/** @var string A URL to be redirected to when the confirmation button is clicked. */
|
||||
public $_remoteUrl;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $dialogText The localized text to appear
|
||||
* in the dialog modal.
|
||||
* @param string $title (optional) The localized modal title.
|
||||
* @param string $remoteUrl (optional) A URL to be
|
||||
* redirected to when the confirmation button is clicked.
|
||||
* @param string $titleIcon (optional) The icon to be used
|
||||
* in the modal title bar.
|
||||
* @param string $okButton (optional) The localized text to
|
||||
* appear on the confirmation button.
|
||||
* @param string $cancelButton (optional) The localized text to
|
||||
* appear on the cancel button.
|
||||
* @param bool $canClose (optional) Whether the modal will
|
||||
* have a close button.
|
||||
*/
|
||||
public function __construct($dialogText, $title = null, $remoteUrl = null, $titleIcon = null, $okButton = null, $cancelButton = null, $canClose = true)
|
||||
{
|
||||
parent::__construct($dialogText, $title, $titleIcon, $okButton, $cancelButton, $canClose);
|
||||
|
||||
$this->_remoteUrl = $remoteUrl;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Getters and Setters
|
||||
//
|
||||
/**
|
||||
* Get the remote url.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRemoteUrl()
|
||||
{
|
||||
return $this->_remoteUrl;
|
||||
}
|
||||
|
||||
//
|
||||
// Overridden methods from LinkActionRequest
|
||||
//
|
||||
/**
|
||||
* @see LinkActionRequest::getLocalizedOptions()
|
||||
*/
|
||||
public function getLocalizedOptions()
|
||||
{
|
||||
$parentLocalizedOptions = parent::getLocalizedOptions();
|
||||
// override the modalHandler option.
|
||||
$parentLocalizedOptions['modalHandler'] = '$.pkp.controllers.modal.RedirectConfirmationModalHandler';
|
||||
$parentLocalizedOptions['remoteUrl'] = $this->getRemoteUrl();
|
||||
return $parentLocalizedOptions;
|
||||
}
|
||||
}
|
||||
|
||||
if (!PKP_STRICT_MODE) {
|
||||
class_alias('\PKP\linkAction\request\RedirectConfirmationModal', '\RedirectConfirmationModal');
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
/**
|
||||
* @file classes/linkAction/request/RemoteActionConfirmationModal.php
|
||||
*
|
||||
* Copyright (c) 2014-2021 Simon Fraser University
|
||||
* Copyright (c) 2000-2021 John Willinsky
|
||||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
|
||||
*
|
||||
* @class RemoteActionConfirmationModal
|
||||
*
|
||||
* @ingroup linkAction_request
|
||||
*
|
||||
* @brief Class defining a simple confirmation modal with a remote action and ok/cancel buttons.
|
||||
*/
|
||||
|
||||
namespace PKP\linkAction\request;
|
||||
|
||||
class RemoteActionConfirmationModal extends ConfirmationModal
|
||||
{
|
||||
/** @var string A URL to be called when the confirmation button is clicked. */
|
||||
public $_remoteAction;
|
||||
|
||||
/** @var string A CSRF token. */
|
||||
public $_csrfToken;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \PKP\session\Session $session The user's session object.
|
||||
* @param string $dialogText The localized text to appear
|
||||
* in the dialog modal.
|
||||
* @param string $title (optional) The localized modal title.
|
||||
* @param string $remoteAction (optional) A URL to be
|
||||
* called when the confirmation button is clicked.
|
||||
* @param string $titleIcon (optional) The icon to be used
|
||||
* in the modal title bar.
|
||||
* @param string $okButton (optional) The localized text to
|
||||
* appear on the confirmation button.
|
||||
* @param string $cancelButton (optional) The localized text to
|
||||
* appear on the cancel button.
|
||||
* @param bool $canClose (optional) Whether the modal will
|
||||
* have a close button.
|
||||
*/
|
||||
public function __construct($session, $dialogText, $title = null, $remoteAction = null, $titleIcon = null, $okButton = null, $cancelButton = null, $canClose = true)
|
||||
{
|
||||
parent::__construct($dialogText, $title, $titleIcon, $okButton, $cancelButton, $canClose);
|
||||
|
||||
$this->_remoteAction = $remoteAction;
|
||||
$this->_csrfToken = $session->getCSRFToken();
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Getters and Setters
|
||||
//
|
||||
/**
|
||||
* Get the remote action.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRemoteAction()
|
||||
{
|
||||
return $this->_remoteAction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the CSRF token.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCSRFToken()
|
||||
{
|
||||
return $this->_csrfToken;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Overridden methods from LinkActionRequest
|
||||
//
|
||||
/**
|
||||
* @see LinkActionRequest::getLocalizedOptions()
|
||||
*/
|
||||
public function getLocalizedOptions()
|
||||
{
|
||||
return array_merge(
|
||||
parent::getLocalizedOptions(),
|
||||
[
|
||||
'modalHandler' => '$.pkp.controllers.modal.RemoteActionConfirmationModalHandler',
|
||||
'remoteAction' => $this->getRemoteAction(),
|
||||
'csrfToken' => $this->getCSRFToken(),
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (!PKP_STRICT_MODE) {
|
||||
class_alias('\PKP\linkAction\request\RemoteActionConfirmationModal', '\RemoteActionConfirmationModal');
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
* @file classes/linkAction/request/WizardModal.php
|
||||
*
|
||||
* Copyright (c) 2014-2021 Simon Fraser University
|
||||
* Copyright (c) 2000-2021 John Willinsky
|
||||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
|
||||
*
|
||||
* @class WizardModal
|
||||
*
|
||||
* @ingroup linkAction_request
|
||||
*
|
||||
* @brief A modal that contains a wizard retrieved via AJAX.
|
||||
*/
|
||||
|
||||
namespace PKP\linkAction\request;
|
||||
|
||||
class WizardModal extends AjaxModal
|
||||
{
|
||||
//
|
||||
// Overridden methods from LinkActionRequest
|
||||
//
|
||||
/**
|
||||
* @see LinkActionRequest::getLocalizedOptions()
|
||||
*/
|
||||
public function getLocalizedOptions()
|
||||
{
|
||||
$options = parent::getLocalizedOptions();
|
||||
$options['modalHandler'] = '$.pkp.controllers.modal.WizardModalHandler';
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
|
||||
if (!PKP_STRICT_MODE) {
|
||||
class_alias('\PKP\linkAction\request\WizardModal', '\WizardModal');
|
||||
}
|
||||
Reference in New Issue
Block a user