first commit

This commit is contained in:
CHIEFSOFT\ameye
2024-06-08 17:09:23 -04:00
commit df3a033196
17887 changed files with 8637778 additions and 0 deletions
@@ -0,0 +1,154 @@
<?php
/**
* @file classes/mail/variables/ContextEmailVariable.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 ContextEmailVariable
*
* @ingroup mail_variables
*
* @brief Represents variables that are associated with a given context (journal or press)
*/
namespace PKP\mail\variables;
use Illuminate\Support\Facades\Mail;
use PKP\context\Context;
use PKP\core\Dispatcher;
use PKP\core\PKPApplication;
use PKP\core\PKPRequest;
use PKP\core\PKPString;
use PKP\mail\Mailable;
class ContextEmailVariable extends Variable
{
public const CONTACT_NAME = 'contactName';
public const CONTACT_EMAIL = 'contactEmail';
public const CONTEXT_NAME = 'contextName';
public const CONTEXT_SIGNATURE = 'contextSignature';
public const CONTEXT_URL = 'contextUrl';
public const MAILING_ADDRESS = 'mailingAddress';
public const PASSWORD_LOST_URL = 'passwordLostUrl';
public const SUBMISSIONS_URL = 'submissionsUrl';
public const USER_PROFILE_URL = 'userProfileUrl';
protected Context $context;
protected PKPRequest $request;
protected Dispatcher $dispatcher;
public function __construct(Context $context, Mailable $mailable)
{
parent::__construct($mailable);
$this->context = $context;
$application = PKPApplication::get();
$this->request = $application->getRequest();
$this->dispatcher = $application->getDispatcher();
}
/**
* @copydoc Variable::descriptions()
*/
public static function descriptions(): array
{
return
[
static::CONTEXT_NAME => __('emailTemplate.variable.context.contextName'),
static::CONTEXT_SIGNATURE => __('emailTemplate.variable.context.contextSignature'),
static::CONTEXT_URL => __('emailTemplate.variable.context.contextUrl'),
static::CONTACT_NAME => __('emailTemplate.variable.context.contactName'),
static::CONTACT_EMAIL => __('emailTemplate.variable.context.contactEmail'),
static::MAILING_ADDRESS => __('emailTemplate.variable.context.mailingAddress'),
static::PASSWORD_LOST_URL => __('emailTemplate.variable.context.passwordLostUrl'),
static::SUBMISSIONS_URL => __('emailTemplate.variable.context.submissionsUrl'),
static::USER_PROFILE_URL => __('emailTemplate.variable.context.userProfileUrl'),
];
}
/**
* @copydoc Variable::values()
*/
public function values(string $locale): array
{
return
[
static::CONTEXT_NAME => htmlspecialchars($this->context->getLocalizedData('name', $locale)),
static::CONTEXT_URL => $this->getContextUrl(),
static::CONTACT_NAME => htmlspecialchars((string) $this->context->getData('contactName')),
static::CONTACT_EMAIL => htmlspecialchars((string) $this->context->getData('contactEmail')),
static::MAILING_ADDRESS => PKPString::stripUnsafeHtml((string) $this->context->getData('mailingAddress')),
static::PASSWORD_LOST_URL => $this->getPasswordLostUrl(),
static::SUBMISSIONS_URL => $this->getSubmissionsUrl(),
static::USER_PROFILE_URL => $this->getUserProfileUrl(),
];
}
/**
* Retrieve context; required to generate other email template variables
*/
public function getContextFromVariable(): Context
{
return $this->context;
}
protected function getContextUrl(): string
{
return $this->dispatcher->url($this->request, PKPApplication::ROUTE_PAGE, $this->context->getData('urlPath'));
}
/**
* Get the CONTEXT_SIGNATURE and render the variable values
* in the signature
*
* @param array $values The values of this email variable
*/
protected function getContextSignature(array $values): string
{
$signature = Mail::compileParams(
PKPString::stripUnsafeHtml((string) $this->context->getData('emailSignature')),
$values
);
return $signature
? PKPString::stripUnsafeHtml($signature)
: '';
}
/**
* URL to the lost password page
*/
protected function getPasswordLostUrl(): string
{
return $this->dispatcher->url($this->request, PKPApplication::ROUTE_PAGE, $this->context->getData('urlPath'), 'login', 'lostPassword');
}
/**
* URL to the submissions lists
*/
protected function getSubmissionsUrl(): string
{
return $this->dispatcher->url(
$this->request,
PKPApplication::ROUTE_PAGE,
$this->context->getPath(),
'submissions',
);
}
/**
* URL to the user profile page
*/
protected function getUserProfileUrl(): string
{
return $this->dispatcher->url(
$this->request,
PKPApplication::ROUTE_PAGE,
$this->context->getPath(),
'user',
'profile'
);
}
}
@@ -0,0 +1,79 @@
<?php
/**
* @file classes/mail/variables/DecisionEmailVariable.php
*
* Copyright (c) 2014-2022 Simon Fraser University
* Copyright (c) 2000-2022 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class DecisionEmailVariable
*
* @ingroup mail_variables
*
* @brief Represents variables associated with an editorial decision
*/
namespace PKP\mail\variables;
use APP\decision\Decision;
use APP\facades\Repo;
use PKP\decision\DecisionType;
use PKP\mail\Mailable;
use PKP\workflow\WorkflowStageDAO;
class DecisionEmailVariable extends Variable
{
public const DECISION = 'decision';
public const DESCRIPTION = 'decisionDescription';
public const STAGE = 'decisionStage';
public const ROUND = 'decisionReviewRound';
protected Decision $decision;
protected DecisionType $decisionType;
public function __construct(Decision $decision, Mailable $mailable)
{
parent::__construct($mailable);
$this->decision = $decision;
$this->decisionType = Repo::decision()->getDecisionType($decision->getData('decision'));
}
/**
* @copydoc Variable::descriptions()
*/
public static function descriptions(): array
{
return
[
self::DECISION => __('emailTemplate.variable.decision.name'),
self::DESCRIPTION => __('emailTemplate.variable.decision.description'),
self::STAGE => __('emailTemplate.variable.decision.stage'),
self::ROUND => __('emailTemplate.variable.decision.round'),
];
}
/**
* @copydoc Variable::values()
*/
public function values(string $locale): array
{
return
[
self::DECISION => $this->decisionType->getLabel($locale),
self::DESCRIPTION => $this->decisionType->getDescription($locale),
self::STAGE => $this->getStageName($locale),
self::ROUND => (string) $this->decision->getData('round'),
];
}
protected function getStageName(string $locale): string
{
return __(
(string) WorkflowStageDAO::getTranslationKeyFromId($this->decision->getData('stageId')),
[],
$locale
);
}
}
@@ -0,0 +1,83 @@
<?php
/**
* @file classes/mail/variables/QueuedPaymentEmailVariable.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 QueuedPaymentEmailVariable
*
* @ingroup mail_variables
*
* @brief Represents email template variables that are associated with payments
*/
namespace PKP\mail\variables;
use APP\core\Application;
use PKP\mail\Mailable;
use PKP\payment\QueuedPayment;
class QueuedPaymentEmailVariable extends Variable
{
public const PAYMENT_NAME = 'paymentName';
public const PAYMENT_AMOUNT = 'paymentAmount';
public const PAYMENT_CURRENCY_CODE = 'paymentCurrencyCode';
protected QueuedPayment $queuedPayment;
public function __construct(QueuedPayment $queuedPayment, Mailable $mailable)
{
parent::__construct($mailable);
$this->queuedPayment = $queuedPayment;
}
/**
* @copydoc Validation::descriptions()
*/
public static function descriptions(): array
{
return
[
self::PAYMENT_NAME => __('emailTemplate.variable.queuedPayment.itemName'),
self::PAYMENT_AMOUNT => __('emailTemplate.variable.queuedPayment.itemCost'),
self::PAYMENT_CURRENCY_CODE => __('emailTemplate.variable.queuedPayment.itemCurrencyCode'),
];
}
/**
* @copydoc Validation::values()
*/
public function values(string $locale): array
{
return
[
self::PAYMENT_NAME => htmlspecialchars($this->getItemName()),
self::PAYMENT_AMOUNT => (string) $this->getItemCost(),
self::PAYMENT_CURRENCY_CODE => (string) $this->getItemCurrencyCode(),
];
}
protected function getItemName(): string
{
$context = $this->getContext();
$paymentManager = Application::getPaymentManager($context);
return $paymentManager->getPaymentName($this->queuedPayment);
}
/**
* @return float|int|string|null
*/
protected function getItemCost()
{
return $this->queuedPayment->getAmount();
}
protected function getItemCurrencyCode(): ?string
{
return $this->queuedPayment->getCurrencyCode();
}
}
@@ -0,0 +1,92 @@
<?php
/**
* @file classes/mail/variables/RecipientEmailVariable.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 RecipientEmailVariable
*
* @ingroup mail_variables
*
* @brief Represents variables that are associated with an email recipient
*/
namespace PKP\mail\variables;
use InvalidArgumentException;
use PKP\identity\Identity;
use PKP\mail\Mailable;
class RecipientEmailVariable extends Variable
{
public const RECIPIENT_FULL_NAME = 'recipientName';
public const RECIPIENT_USERNAME = 'recipientUsername';
/** @var iterable<Identity> */
protected iterable $recipients;
public function __construct(iterable $recipients, Mailable $mailable)
{
parent::__construct($mailable);
foreach ($recipients as $recipient) {
if (!is_a($recipient, Identity::class)) {
throw new InvalidArgumentException('recipient array values should be an instances or ancestors of ' . Identity::class . ', ' . get_class($recipient) . ' is given');
}
}
$this->recipients = $recipients;
}
/**
* @copydoc Variable::descriptions()
*/
public static function descriptions(): array
{
return
[
self::RECIPIENT_FULL_NAME => __('emailTemplate.variable.recipient.userFullName'),
self::RECIPIENT_USERNAME => __('emailTemplate.variable.recipient.username'),
];
}
/**
* @copydoc Variable::values()
*/
public function values(string $locale): array
{
return
[
self::RECIPIENT_FULL_NAME => htmlspecialchars($this->getRecipientsFullName($locale)),
self::RECIPIENT_USERNAME => htmlspecialchars($this->getRecipientsUserName()),
];
}
/**
* Full names of recipients in all supported locales separated by a comma
*/
protected function getRecipientsFullName(string $locale): string
{
$names = [];
foreach ($this->recipients as $recipient) {
$names[] = $recipient->getFullName(true, false, $locale);
}
return join(__('common.commaListSeparator'), $names);
}
/**
* Usernames of recipients separated by a comma
*/
protected function getRecipientsUserName(): string
{
$userNames = [];
foreach ($this->recipients as $recipient) {
$userNames[] = $recipient->getData('userName');
}
return join(__('common.commaListSeparator'), $userNames);
}
}
@@ -0,0 +1,136 @@
<?php
/**
* @file classes/mail/variables/ReviewAssignmentEmailVariable.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 ReviewAssignmentEmailVariable
*
* @ingroup mail_variables
*
* @brief Represents email template variables that are associated with a review assignment
*/
namespace PKP\mail\variables;
use PKP\context\Context;
use PKP\core\PKPApplication;
use PKP\core\PKPString;
use PKP\mail\Mailable;
use PKP\submission\reviewAssignment\ReviewAssignment;
class ReviewAssignmentEmailVariable extends Variable
{
public const RESPONSE_DUE_DATE = 'responseDueDate';
public const REVIEW_ASSIGNED_DATE = 'reviewAssignedDate';
public const REVIEW_ASSIGNMENT_URL = 'reviewAssignmentUrl';
public const REVIEW_DUE_DATE = 'reviewDueDate';
public const REVIEW_METHOD = 'reviewMethod';
public const REVIEW_RECOMMENDATION = 'reviewRecommendation';
public const REVIEW_ROUND = 'reviewRound';
public const REVIEWER_NAME = 'reviewerName';
protected ReviewAssignment $reviewAssignment;
public function __construct(ReviewAssignment $reviewAssignment, Mailable $mailable)
{
parent::__construct($mailable);
$this->reviewAssignment = $reviewAssignment;
}
/**
* @copydoc Variable::descriptions()
*/
public static function descriptions(): array
{
return
[
self::RESPONSE_DUE_DATE => __('emailTemplate.variable.recipient.responseDueDate'),
self::REVIEW_ASSIGNED_DATE => __('emailTemplate.variable.review.assignedDate'),
self::REVIEW_ASSIGNMENT_URL => __('emailTemplate.variable.recipient.reviewAssignmentUrl'),
self::REVIEW_DUE_DATE => __('emailTemplate.variable.recipient.reviewDueDate'),
self::REVIEW_METHOD => __('emailTemplate.variable.review.method'),
self::REVIEW_RECOMMENDATION => __('emailTemplate.variable.review.recommendation'),
self::REVIEW_ROUND => __('emailTemplate.variable.review.round'),
self::REVIEWER_NAME => __('emailTemplate.variable.review.name'),
];
}
/**
* @copydoc Variable::values()
*/
public function values(string $locale): array
{
$context = $this->getContext();
return
[
self::RESPONSE_DUE_DATE => $this->formatDate((string) $this->reviewAssignment->getDateResponseDue(), $locale, $context) ?? '{$' . self::RESPONSE_DUE_DATE . '}',
self::REVIEW_ASSIGNED_DATE => $this->formatDate((string) $this->reviewAssignment->getDateAssigned(), $locale, $context) ?? '{$' . self::REVIEW_ASSIGNED_DATE . '}',
self::REVIEW_ASSIGNMENT_URL => $this->getReviewUrl($context),
self::REVIEW_DUE_DATE => $this->formatDate((string) $this->reviewAssignment->getDateDue(), $locale, $context) ?? '{$' . self::REVIEW_DUE_DATE . '}',
self::REVIEW_METHOD => $this->getReviewMethod($locale),
self::REVIEW_RECOMMENDATION => $this->getRecommendation($locale),
self::REVIEW_ROUND => __('common.reviewRoundNumber', ['round' => $this->reviewAssignment->getRound()], $locale),
self::REVIEWER_NAME => $this->reviewAssignment->getReviewerFullName(),
];
}
protected function formatDate(string $date, string $locale, Context $context): ?string
{
$time = strtotime($date);
if ($time === -1 || $time === false) {
return null;
}
$format = PKPString::convertStrftimeFormat($context->getLocalizedDateFormatShort($locale));
return date($format, $time);
}
protected function getRecommendation(string $locale): string
{
$recommendationOptions = ReviewAssignment::getReviewerRecommendationOptions();
return isset($recommendationOptions[$this->reviewAssignment->getRecommendation()])
? __($recommendationOptions[$this->reviewAssignment->getRecommendation()], [], $locale)
: __('common.none', [], $locale);
}
protected function getReviewMethod(string $locale): string
{
if (!$this->reviewAssignment->getReviewMethod()) {
return '';
}
return __(
$this->reviewAssignment->getReviewMethodKey(),
[],
$locale
);
}
/**
* URL of the submission for the assigned reviewer
*/
protected function getReviewUrl(Context $context): string
{
$application = PKPApplication::get();
$request = $application->getRequest();
$dispatcher = $application->getDispatcher();
return $dispatcher->url(
$request,
PKPApplication::ROUTE_PAGE,
$context->getData('urlPath'),
'reviewer',
'submission',
null,
['submissionId' => $this->reviewAssignment->getSubmissionId()]
);
}
}
@@ -0,0 +1,74 @@
<?php
/**
* @file classes/mail/variables/SenderEmailVariable.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 SenderEmailVariable
*
* @ingroup mail_variables
*
* @brief Represents variables that are associated with an email sender
*/
namespace PKP\mail\variables;
use PKP\core\PKPString;
use PKP\mail\Mailable;
use PKP\user\User;
class SenderEmailVariable extends Variable
{
public const SENDER_NAME = 'senderName';
public const SENDER_EMAIL = 'senderEmail';
public const SENDER_CONTACT_SIGNATURE = 'signature';
protected User $sender;
public function __construct(User $sender, Mailable $mailable)
{
parent::__construct($mailable);
$this->sender = $sender;
}
/**
* @copydoc Variable::descriptions()
*/
public static function descriptions(): array
{
return
[
self::SENDER_NAME => __('emailTemplate.variable.sender.senderName'),
self::SENDER_EMAIL => __('emailTemplate.variable.sender.senderEmail'),
self::SENDER_CONTACT_SIGNATURE => __('emailTemplate.variable.sender.signature'),
];
}
/**
* @copydoc Variable::values()
*/
public function values(string $locale): array
{
return
[
self::SENDER_NAME => htmlspecialchars($this->sender->getFullName(true, false, $locale)),
self::SENDER_EMAIL => htmlspecialchars($this->sender->getData('email')),
self::SENDER_CONTACT_SIGNATURE => $this->getSignature($locale),
];
}
/**
* Sender's contact signature
*/
protected function getSignature(string $locale): string
{
$signature = $this->sender->getSignature($locale);
return $signature
? PKPString::stripUnsafeHtml($signature)
: '<p>' . htmlspecialchars($this->sender->getFullName(true, false, $locale)) . '</p>';
}
}
@@ -0,0 +1,68 @@
<?php
/**
* @file classes/mail/variables/SiteEmailVariable.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 SiteEmailVariable
*
* @ingroup mail_variables
*
* @brief Represents variables that are associated with a website
*/
namespace PKP\mail\variables;
use PKP\mail\Mailable;
use PKP\site\Site;
class SiteEmailVariable extends Variable
{
public const SITE_TITLE = 'siteTitle';
public const SITE_CONTACT = 'siteContactName';
public const SITE_EMAIL = 'siteContactEmail';
public const SITE_SIGNATURE = 'siteSignature';
protected Site $site;
public function __construct(Site $site, Mailable $mailable)
{
parent::__construct($mailable);
$this->site = $site;
}
/**
* @copydoc Variable::descriptions()
*/
public static function descriptions(): array
{
return
[
self::SITE_TITLE => __('emailTemplate.variable.site.siteTitle'),
self::SITE_CONTACT => __('emailTemplate.variable.site.siteContactName'),
self::SITE_EMAIL => __('emailTemplate.variable.site.siteContactEmail'),
self::SITE_SIGNATURE => __('emailTemplate.variable.site.siteSignature'),
];
}
/**
* @copydoc Variable::values()
*/
public function values(string $locale): array
{
return
[
self::SITE_TITLE => htmlspecialchars($this->site->getLocalizedData('title', $locale)),
self::SITE_CONTACT => htmlspecialchars($this->site->getLocalizedData('contactName', $locale)),
self::SITE_EMAIL => htmlspecialchars($this->site->getLocalizedData('contactEmail', $locale)),
self::SITE_SIGNATURE => '<p>' .
htmlspecialchars($this->site->getLocalizedData('contactName', $locale)) . '<br/>' .
htmlspecialchars($this->site->getLocalizedData('title', $locale)) .
'</p>',
];
}
}
@@ -0,0 +1,163 @@
<?php
/**
* @file classes/mail/variables/SubmissionEmailVariable.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 SubmissionEmailVariable
*
* @ingroup mail_variables
*
* @brief Represents variables associated with a submission that can be assigned to a template
*/
namespace PKP\mail\variables;
use APP\publication\Publication;
use APP\submission\Submission;
use PKP\author\Author;
use PKP\context\Context;
use PKP\core\PKPApplication;
use PKP\core\PKPString;
use PKP\mail\Mailable;
abstract class SubmissionEmailVariable extends Variable
{
public const AUTHOR_SUBMISSION_URL = 'authorSubmissionUrl';
public const AUTHORS = 'authors';
public const AUTHORS_SHORT = 'authorsShort';
public const SUBMISSION_ABSTRACT = 'submissionAbstract';
public const SUBMISSION_ID = 'submissionId';
public const SUBMISSION_PUBLISHED_URL = 'submissionPublishedUrl';
public const SUBMISSION_TITLE = 'submissionTitle';
public const SUBMISSION_URL = 'submissionUrl';
public const SUBMISSION_WIZARD_URL = 'submissionWizardUrl';
protected Submission $submission;
protected Publication $currentPublication;
public function __construct(Submission $submission, Mailable $mailable)
{
parent::__construct($mailable);
$this->submission = $submission;
$this->currentPublication = $this->submission->getCurrentPublication();
}
/**
* @copydoc Variable::descriptions()
*/
public static function descriptions(): array
{
return
[
self::AUTHOR_SUBMISSION_URL => __('emailTemplate.variable.submission.authorSubmissionUrl'),
self::AUTHORS => __('emailTemplate.variable.submission.authors'),
self::AUTHORS_SHORT => __('emailTemplate.variable.submission.authorsShort'),
self::SUBMISSION_ABSTRACT => __('emailTemplate.variable.submission.submissionAbstract'),
self::SUBMISSION_ID => __('emailTemplate.variable.submission.submissionId'),
self::SUBMISSION_PUBLISHED_URL => __('emailTemplate.variable.submission.submissionPublishedUrl'),
self::SUBMISSION_TITLE => __('emailTemplate.variable.submission.submissionTitle'),
self::SUBMISSION_URL => __('emailTemplate.variable.submission.submissionUrl'),
self::SUBMISSION_WIZARD_URL => __('emailTemplate.variable.submission.submissionWizardUrl'),
];
}
/**
* @copydoc Variable::values()
*/
public function values(string $locale): array
{
$context = $this->getContext();
return
[
self::AUTHOR_SUBMISSION_URL => $this->getAuthorSubmissionUrl($context),
self::AUTHORS => htmlspecialchars($this->getAuthorsFull($locale)),
self::AUTHORS_SHORT => htmlspecialchars($this->currentPublication->getShortAuthorString($locale)),
self::SUBMISSION_ABSTRACT => PKPString::stripUnsafeHtml($this->currentPublication->getLocalizedData('abstract', $locale)),
self::SUBMISSION_ID => (string) $this->submission->getId(),
self::SUBMISSION_PUBLISHED_URL => $this->getSubmissionPublishedUrl($this->getContext()),
self::SUBMISSION_TITLE => $this->currentPublication->getLocalizedFullTitle($locale, 'html'),
self::SUBMISSION_URL => $this->getSubmissionUrl($context),
self::SUBMISSION_WIZARD_URL => $this->getSubmissionWizardUrl($context),
];
}
/**
* List of authors as a string separated by a comma
*/
protected function getAuthorsFull(string $locale): string
{
$authors = $this->currentPublication->getData('authors');
$fullNames = array_map(function (Author $author) use ($locale) {
return $author->getFullName(true, false, $locale);
}, iterator_to_array($authors));
return join(__('common.commaListSeparator'), $fullNames);
}
/**
* URL to the author's submission workflow
*/
protected function getAuthorSubmissionUrl(Context $context): string
{
$request = PKPApplication::get()->getRequest();
return $request->getDispatcher()->url(
$request,
PKPApplication::ROUTE_PAGE,
$context->getData('urlPath'),
'authorDashboard',
'submission',
[
$this->submission->getId(),
]
);
}
/**
* URL to a current workflow stage of the submission
*/
protected function getSubmissionUrl(Context $context): string
{
$application = PKPApplication::get();
$request = $application->getRequest();
$dispatcher = $application->getDispatcher();
return $dispatcher->url(
$request,
PKPApplication::ROUTE_PAGE,
$context->getData('urlPath'),
'workflow',
'access',
$this->submission->getId()
);
}
/**
* URL to the submission in the submission wizard
*/
protected function getSubmissionWizardUrl(Context $context): string
{
$application = PKPApplication::get();
$request = $application->getRequest();
$dispatcher = $application->getDispatcher();
return $dispatcher->url(
$request,
PKPApplication::ROUTE_PAGE,
$context->getPath(),
'submission',
null,
null,
[
'id' => $this->submission->getId(),
]
);
}
/**
* URL to the published submission
*/
abstract protected function getSubmissionPublishedUrl(Context $context): string;
}
@@ -0,0 +1,62 @@
<?php
/**
* @file classes/mail/variables/Variable.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 Variable
*
* @ingroup mail_variables
*
* @brief A base class for email template variables
*/
namespace PKP\mail\variables;
use Exception;
use Illuminate\Support\Arr;
use PKP\context\Context;
use PKP\mail\Mailable;
abstract class Variable
{
protected Mailable $mailable;
public function __construct(Mailable $mailable)
{
$this->mailable = $mailable;
}
/**
* Retrieve mailable context from associated variables, see pkp/pkp-lib#8204
*/
protected function getContext(): Context
{
$contextEmailVariable = Arr::first($this->mailable->getVariables(), function (Variable $variable) {
return $variable instanceof ContextEmailVariable;
});
if (!$contextEmailVariable) {
throw new Exception(static::class . ' is unable to generate email variables without providing the context to the Mailable');
}
return $contextEmailVariable->getContextFromVariable();
}
/**
* Get descriptions of the variables provided by this class
*
* @return string[]
*/
abstract public static function descriptions(): array;
/**
* Get the value of variables supported by this class
*
* @return string[]
*/
abstract public function values(string $locale): array;
}