Skip to content
Merged
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: 2 additions & 1 deletion module/Activity/src/Service/Activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Activity\Model\SignupField as SignupFieldModel;
use Activity\Model\SignupList as SignupListModel;
use Activity\Model\SignupOption as SignupOptionModel;
use Application\Model\Enums\Languages;
use Application\Service\Email as EmailService;
use Company\Model\Company as CompanyModel;
use Company\Service\Company as CompanyService;
Expand Down Expand Up @@ -352,7 +353,7 @@
?OrganModel $organ,
): void {
// Default to an English title, otherwise use the Dutch title
$activityTitle = $activity->getName()->getText('en');
$activityTitle = $activity->getName()->getText(Languages::English);
$activityTime = $activity->getBeginTime()->format('d-m-Y H:i');

$type = sprintf('activity_creation_require_%s', $facilityType);
Expand Down Expand Up @@ -457,7 +458,7 @@

if (0 !== $currentActivity->getUpdateProposal()->count()) {
$proposal = $currentActivity->getUpdateProposal()->first();
//Remove old update proposal

Check failure on line 461 in module/Activity/src/Service/Activity.php

View workflow job for this annotation

GitHub Actions / Psalm

PossiblyFalseReference

module/Activity/src/Service/Activity.php:461:37: PossiblyFalseReference: Cannot call method getNew on possibly false value (see https://psalm.dev/105)
$oldUpdate = $proposal->getNew();
$proposal->setNew($newActivity);
$em->remove($oldUpdate);
Expand Down
5 changes: 3 additions & 2 deletions module/Activity/view/activity/admin/view.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
declare(strict_types=1);

use Activity\Model\Activity as ActivityModel;
use Application\Model\Enums\Languages;
use Application\View\HelperTrait;
use Laminas\View\Renderer\PhpRenderer;

Expand Down Expand Up @@ -82,10 +83,10 @@ $this->breadcrumbs()
<tr>
<td><?= $activity->getId() ?></td>
<td>
<a href="<?= $this->url('activity/view', ['id' => $activity->getId()]) ?>"><?= $activity->getName()->getText("nl") ?></a>
<a href="<?= $this->url('activity/view', ['id' => $activity->getId()]) ?>"><?= $activity->getName()->getText(Languages::Dutch) ?></a>
</td>
<td>
<a href="<?= $this->url('activity/view', ['id' => $activity->getId()]) ?>"><?= $activity->getName()->getText("en") ?></a>
<a href="<?= $this->url('activity/view', ['id' => $activity->getId()]) ?>"><?= $activity->getName()->getText(Languages::English) ?></a>
</td>
<td><?= $activity->getBeginTime()->format('Y-m-d') ?></td>
<td><?= (null === $activity->getOrgan()) ? $this->translate('None') : $this->escapeHtml($activity->getOrgan()->getAbbr()) ?></td>
Expand Down
21 changes: 13 additions & 8 deletions module/Activity/view/email/activity-update-proposed.phtml
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
<?php

use Application\Model\Enums\Languages;

?>
For English, see below.

L.s.<br/><br/>

Er is een voorstel gedaan om een activiteit aan te passen op de GEWIS website.

<h3><?= $this->escapeHtml($activity->getName()->getText("nl")) ?></h3>
<h3><?= $this->escapeHtml($activity->getName()->getText(Languages::Dutch)) ?></h3>

<p><?= $this->escapeHtml($activity->getDescription()->getText("nl")) ?></p>
<p><?= $this->escapeHtml($activity->getDescription()->getText(Languages::Dutch)) ?></p>

<table>
<tr>
Expand All @@ -19,11 +24,11 @@ Er is een voorstel gedaan om een activiteit aan te passen op de GEWIS website.
</tr>
<tr>
<td><strong>Locatie:</strong></td>
<td><?= $this->escapeHtml($activity->getLocation()->getText("nl")) ?></td>
<td><?= $this->escapeHtml($activity->getLocation()->getText(Languages::Dutch)) ?></td>
</tr>
<tr>
<td><strong>Kosten:</strong></td>
<td><?= $this->escapeHtml($activity->getCosts()->getText("nl")) ?></td>
<td><?= $this->escapeHtml($activity->getCosts()->getText(Languages::Dutch)) ?></td>
</tr>
</table>
<br/>
Expand All @@ -38,9 +43,9 @@ L.s.<br/><br/>

An update proposal was made for an activity on the GEWIS website. See below for details.

<h1><?= $this->escapeHtml($activity->getName()->getText("en")) ?></h1>
<h1><?= $this->escapeHtml($activity->getName()->getText(Languages::English)) ?></h1>

<p><?= $this->escapeHtml($activity->getDescription()->getText("en")) ?></p>
<p><?= $this->escapeHtml($activity->getDescription()->getText(Languages::English)) ?></p>

<table>
<tr>
Expand All @@ -53,11 +58,11 @@ An update proposal was made for an activity on the GEWIS website. See below for
</tr>
<tr>
<td><strong>Location:</strong></td>
<td><?= $this->escapeHtml($activity->getLocation()->getText("en")) ?></td>
<td><?= $this->escapeHtml($activity->getLocation()->getText(Languages::English)) ?></td>
</tr>
<tr>
<td><strong>Costs:</strong></td>
<td><?= $this->escapeHtml($activity->getCosts()->getText("en")) ?></td>
<td><?= $this->escapeHtml($activity->getCosts()->getText(Languages::English)) ?></td>
</tr>
</table>
<br/>
Expand Down
21 changes: 13 additions & 8 deletions module/Activity/view/email/activity-updated.phtml
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
<?php

use Application\Model\Enums\Languages;

?>
For English, see below.

L.s.<br/><br/>

Er is een activiteit aangepast op de GEWIS website.

<h3><?= $this->escapeHtml($activity->getName()->getText("nl")) ?></h3>
<h3><?= $this->escapeHtml($activity->getName()->getText(Languages::Dutch)) ?></h3>

<p><?= $this->escapeHtml($activity->getDescription()->getText("nl")) ?></p>
<p><?= $this->escapeHtml($activity->getDescription()->getText(Languages::Dutch)) ?></p>

<table>
<tr>
Expand All @@ -19,11 +24,11 @@ Er is een activiteit aangepast op de GEWIS website.
</tr>
<tr>
<td><strong>Locatie:</strong></td>
<td><?= $this->escapeHtml($activity->getLocation()->getText("nl")) ?></td>
<td><?= $this->escapeHtml($activity->getLocation()->getText(Languages::Dutch)) ?></td>
</tr>
<tr>
<td><strong>Kosten:</strong></td>
<td><?= $this->escapeHtml($activity->getCosts()->getText("nl")) ?></td>
<td><?= $this->escapeHtml($activity->getCosts()->getText(Languages::Dutch)) ?></td>
</tr>
</table>
<br/>
Expand All @@ -39,9 +44,9 @@ L.s.<br/><br/>

An activity was updated on the GEWIS website. See below for details.

<h1><?= $this->escapeHtml($activity->getName()->getText("en")) ?></h1>
<h1><?= $this->escapeHtml($activity->getName()->getText(Languages::English)) ?></h1>

<p><?= $this->escapeHtml($activity->getDescription()->getText("en")) ?></p>
<p><?= $this->escapeHtml($activity->getDescription()->getText(Languages::English)) ?></p>

<table>
<tr>
Expand All @@ -54,11 +59,11 @@ An activity was updated on the GEWIS website. See below for details.
</tr>
<tr>
<td><strong>Location:</strong></td>
<td><?= $this->escapeHtml($activity->getLocation()->getText("en")) ?></td>
<td><?= $this->escapeHtml($activity->getLocation()->getText(Languages::English)) ?></td>
</tr>
<tr>
<td><strong>Costs:</strong></td>
<td><?= $this->escapeHtml($activity->getCosts()->getText("en")) ?></td>
<td><?= $this->escapeHtml($activity->getCosts()->getText(Languages::English)) ?></td>
</tr>
</table>
<br/>
Expand Down
21 changes: 13 additions & 8 deletions module/Activity/view/email/activity.phtml
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
<?php

use Application\Model\Enums\Languages;

?>
For English, see below.

L.s.<br/><br/>

Er is een nieuwe activiteit aangemaakt op de GEWIS website.

<h3><?= $this->escapeHtml($activity->getName()->getText("nl")) ?></h3>
<h3><?= $this->escapeHtml($activity->getName()->getText(Languages::Dutch)) ?></h3>

<p><?= $this->escapeHtml($activity->getDescription()->getText("nl")) ?></p>
<p><?= $this->escapeHtml($activity->getDescription()->getText(Languages::Dutch)) ?></p>

<table>
<tr>
Expand All @@ -19,11 +24,11 @@ Er is een nieuwe activiteit aangemaakt op de GEWIS website.
</tr>
<tr>
<td><strong>Locatie:</strong></td>
<td><?= $this->escapeHtml($activity->getLocation()->getText("nl")) ?></td>
<td><?= $this->escapeHtml($activity->getLocation()->getText(Languages::Dutch)) ?></td>
</tr>
<tr>
<td><strong>Kosten:</strong></td>
<td><?= $this->escapeHtml($activity->getCosts()->getText("nl")) ?></td>
<td><?= $this->escapeHtml($activity->getCosts()->getText(Languages::Dutch)) ?></td>
</tr>
</table>
<br/>
Expand All @@ -39,9 +44,9 @@ L.s.<br/><br/>

A new activity was created at the GEWIS website. See below for details.

<h1><?= $this->escapeHtml($activity->getName()->getText("en")) ?></h1>
<h1><?= $this->escapeHtml($activity->getName()->getText(Languages::English)) ?></h1>

<p><?= $this->escapeHtml($activity->getDescription()->getText("en")) ?></p>
<p><?= $this->escapeHtml($activity->getDescription()->getText(Languages::English)) ?></p>

<table>
<tr>
Expand All @@ -54,11 +59,11 @@ A new activity was created at the GEWIS website. See below for details.
</tr>
<tr>
<td><strong>Location:</strong></td>
<td><?= $this->escapeHtml($activity->getLocation()->getText("en")) ?></td>
<td><?= $this->escapeHtml($activity->getLocation()->getText(Languages::English)) ?></td>
</tr>
<tr>
<td><strong>Costs:</strong></td>
<td><?= $this->escapeHtml($activity->getCosts()->getText("en")) ?></td>
<td><?= $this->escapeHtml($activity->getCosts()->getText(Languages::English)) ?></td>
</tr>
</table>
<br/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
<?php

use Application\Model\Enums\Languages;

?>
For English, see below.

L.s.<br/><br/>

Er is een nieuwe activiteit aangemaakt op de GEWIS website waarvoor een fotograaf van GEFLITST nodig is.

<h3><?= $this->escapeHtml($activity->getName()->getText("nl")) ?></h3>
<h3><?= $this->escapeHtml($activity->getName()->getText(Languages::Dutch)) ?></h3>

<p><?= $this->escapeHtml($activity->getDescription()->getText("nl")) ?></p>
<p><?= $this->escapeHtml($activity->getDescription()->getText(Languages::Dutch)) ?></p>

<br/>

Expand All @@ -23,9 +28,9 @@ L.s.<br/><br/>

A new activity has been created on the GEWIS website that needs a photographer of GEFLITST.

<h3><?= $this->escapeHtml($activity->getName()->getText("en")) ?></h3>
<h3><?= $this->escapeHtml($activity->getName()->getText(Languages::English)) ?></h3>

<p><?= $this->escapeHtml($activity->getDescription()->getText("en")) ?></p>
<p><?= $this->escapeHtml($activity->getDescription()->getText(Languages::English)) ?></p>

<br/>

Expand Down
13 changes: 9 additions & 4 deletions module/Activity/view/email/activity_created_require_Zettle.phtml
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
<?php

use Application\Model\Enums\Languages;

?>
For English, see below.

L.s.<br/><br/>

Er is een nieuwe activiteit aangemaakt op de GEWIS website waarvoor een Zettle nodig is.

<h3><?= $this->escapeHtml($activity->getName()->getText("nl")) ?></h3>
<h3><?= $this->escapeHtml($activity->getName()->getText(Languages::Dutch)) ?></h3>

<p><?= $this->escapeHtml($activity->getDescription()->getText("nl")) ?></p>
<p><?= $this->escapeHtml($activity->getDescription()->getText(Languages::Dutch)) ?></p>

<br/>

Expand All @@ -23,9 +28,9 @@ L.s.<br/><br/>

A new activity has been created on the GEWIS website that needs Zettle for payments.

<h3><?= $this->escapeHtml($activity->getName()->getText("en")) ?></h3>
<h3><?= $this->escapeHtml($activity->getName()->getText(Languages::English)) ?></h3>

<p><?= $this->escapeHtml($activity->getDescription()->getText("en")) ?></p>
<p><?= $this->escapeHtml($activity->getDescription()->getText(Languages::English)) ?></p>

<br/>

Expand Down
16 changes: 9 additions & 7 deletions module/Application/src/Model/LocalisedText.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,23 @@ public function updateValueNL(?string $valueNL): void
*
* @throws InvalidArgumentException
*/
public function getText(?string $locale = null): ?string
public function getText(?Languages $locale = null): ?string
{
if (null === $locale) {
$locale = $this->getPreferredLocale();
} else {
$locale = $locale->getLangParam();
}

return match ($locale) {
'nl' => null !== $this->valueNL ? $this->valueNL : $this->valueEN,
'en' => null !== $this->valueEN ? $this->valueEN : $this->valueNL,
Languages::Dutch->getLangParam() => null !== $this->valueNL ? $this->valueNL : $this->valueEN,
Languages::English->getLangParam() => null !== $this->valueEN ? $this->valueEN : $this->valueNL,
default => throw new InvalidArgumentException('Locale not supported: ' . $locale),
};
}

/**
* @return string the preferred language: either 'nl' or 'en'
* @psalm-return 'en'|'nl' - From {@link Languages::getLangParam()}.
*/
private function getPreferredLocale(): string
{
Expand All @@ -102,12 +104,12 @@ public function getExactText(?Languages $locale = null): ?string
if (null === $locale) {
$locale = $this->getPreferredLocale();
} else {
$locale = $locale->value;
$locale = $locale->getLangParam();
}

return match ($locale) {
'nl' => $this->valueNL,
'en' => $this->valueEN,
Languages::Dutch->getLangParam() => $this->valueNL,
Languages::English->getLangParam() => $this->valueEN,
default => throw new InvalidArgumentException('Locale not supported: ' . $locale),
};
}
Expand Down
3 changes: 2 additions & 1 deletion module/Frontpage/view/frontpage/frontpage/home.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
declare(strict_types=1);

use Activity\Model\Activity as ActivityModel;
use Application\Model\Enums\Languages;
use Application\View\HelperTrait;
use Company\Model\CompanyBannerPackage as CompanyBannerPackageModel;
use Decision\Service\AclService as DecisionAclService;
Expand Down Expand Up @@ -177,7 +178,7 @@ $lang = $this->plugin('translate')->getTranslator()->getLocale();
<?php foreach ($activities as $activity): ?>
<a class="list-group-item"
href="<?= $this->url('activity/view', ['id' => $activity->getId()]) ?>">
<h4 class="list-group-item-heading"><?= $activity->getName()->getText($lang) ?></h4>
<h4 class="list-group-item-heading"><?= $activity->getName()->getText(Languages::fromLangParam($lang)) ?></h4>
<p class="list-group-item-text text-muted"><?= ucfirst($this->dateFormat($activity->getBeginTime(), IntlDateFormatter::FULL, IntlDateFormatter::SHORT, $lang)); ?></p>
</a>
<?php endforeach; ?>
Expand Down
Loading