Skip to content

Commit

Permalink
CKEditor and more: Use ck-content class for displaying content + othe…
Browse files Browse the repository at this point in the history
…r bugfixes (#1152)

* Added the "ck-content" class for the content that was created in the CKEditor.
* ilch.css: set "overflow: auto" for ck-content or otherwise it would affect everything after the "ck-content" div.
* Contact: Removed required attribute for the textarea used by CKEditor as it doesn't work with CKEditor 5.
* Rule: Fix "Invalid argument supplied for foreach() in application/modules/rule/views/admin/index/treat.php:52".
* Newsletter: Remove unsubscribe link from show action.
* Newsletter: Remove email from unreadable link.
* Teams: Fix error with no leader or coleader.
* War: Fix invalid group image error.
* War: Fix error when trying to add a map.
* War: The matchtype couldn't be entered when trying to add a war.
* HTMLPurifier: Added a unit test for "Wrap text: Left aligned image".
  • Loading branch information
blackcoder87 authored Jan 12, 2025
1 parent df19d49 commit 6cee514
Show file tree
Hide file tree
Showing 52 changed files with 121 additions and 86 deletions.
12 changes: 8 additions & 4 deletions application/libraries/Ilch/Comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,11 @@ private function rec(int $id, int $commentId, int $uid, int $req, Base $obj): st
<div class="fload-end text-muted small">
<i class="fa-solid fa-reply fa-flip-vertical"></i> ' . $user_rep->getName() . '
</div>
</div>'
</div>
<div class="ck-content">'
. nl2br($obj->alwaysPurify($fk_comment->getText())) .
'<div>';
'</div>
<div>';
if ($obj->getUser() && !in_array($obj->getUser()->getId(), $voted)) {
$commentsHtml .= '
<div class="btn-group">
Expand Down Expand Up @@ -293,9 +295,11 @@ public function getComments(string $key, $object, Base $layout): string
<p class="text-muted small">
<i class="fa-regular fa-clock" title="' . $layout->getTrans('commentDateTime') . '"></i> ' . $commentDate->format('d.m.Y - H:i', true) . '
</p>
</div>'
</div>
<div class="ck-content">'
. nl2br($layout->alwaysPurify($comment->getText())) .
'<div>';
'</div>
<div>';

if ($layout->getUser() && !in_array($layout->getUser()->getId(), $voted)) {
$commentsHtml .= '
Expand Down
3 changes: 2 additions & 1 deletion application/modules/admin/layouts/maintenance.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<link href="<?=$this->getStaticUrl('css/ilch.css') ?>" rel="stylesheet">
<link href="<?=$this->getBaseUrl('application/modules/admin/static/css/maintenance.css') ?>" rel="stylesheet">
<link href="<?=$this->getVendorUrl('npm-asset/jquery-ui/dist/themes/ui-lightness/jquery-ui.min.css') ?>" rel="stylesheet">
<link href="<?=$this->getStaticUrl('js/ckeditor5/build/ckeditor.css') ?>" rel="stylesheet" type="text/css">

<!-- SCRIPTS -->
<script src="<?=$this->getVendorUrl('npm-asset/jquery/dist/jquery.min.js') ?>"></script>
Expand Down Expand Up @@ -96,7 +97,7 @@
style="width: <?=$config->get('maintenance_status') ?>%;">
</div>
</div>
<div class="install_content">
<div class="install_content ck-content">
<?=$config->get('maintenance_text') ?>
</div>

Expand Down
4 changes: 2 additions & 2 deletions application/modules/article/views/index/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@

<?php if (strpos($content, '[PREVIEWSTOP]') !== false): ?>
<?php $contentParts = explode('[PREVIEWSTOP]', $content); ?>
<?=$this->purify(reset($contentParts)) ?>
<div class="ck-content"><?=$this->purify(reset($contentParts)) ?></div>
<br />
<a href="<?=$this->getUrl(['action' => 'show', 'id' => $article->getId()]) ?>" class="float-end"><?=$this->getTrans('readMore') ?></a>
<?php else: ?>
<?=$this->purify($content) ?>
<div class="ck-content"><?=$this->purify($content) ?></div>
<?php endif; ?>
<hr />
<div>
Expand Down
2 changes: 1 addition & 1 deletion application/modules/article/views/index/show.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<?php endif; ?>
</figure>
<?php endif; ?>
<?=$this->purify($content) ?>
<div class="ck-content"><?=$this->purify($content) ?></div>
<hr />
<div>
<?php
Expand Down
2 changes: 1 addition & 1 deletion application/modules/calendar/views/events/show.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
<div class="col-xl-2"><?=$this->getTrans('description') ?></div>
<div class="col-xl-12">
<?php if ($calendar->getText()) : ?>
<?=$this->purify($calendar->getText()) ?>
<div class="ck-content"><?=$this->purify($calendar->getText()) ?></div>
<?php else : ?>
<?=$this->getTrans('noDescription') ?>
<?php endif; ?>
Expand Down
2 changes: 1 addition & 1 deletion application/modules/checkoutbasic/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Config extends \Ilch\Config\Install
{
public $config = [
'key' => 'checkoutbasic',
'version' => '1.6.0',
'version' => '1.6.1',
'icon_small' => 'fa-regular fa-credit-card',
'author' => 'Stantin, Thomas',
'link' => 'https://ilch.de',
Expand Down
2 changes: 1 addition & 1 deletion application/modules/checkoutbasic/views/index/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
?>

<h1><?=$this->getTrans('accountdata') ?></h1>
<?=($this->get('checkout_contact') != '') ? $this->purify($this->get('checkout_contact')) : '' ?>
<?=($this->get('checkout_contact') != '') ? '<div class="ck-content">' . $this->purify($this->get('checkout_contact')) . '</div>' : '' ?>
<br>
<br>
<h1><?=$this->getTrans('bankbalance') ?></h1>
Expand Down
3 changes: 1 addition & 2 deletions application/modules/contact/views/admin/settings/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
<textarea class="form-control ckeditor"
id="ck_1"
name="welcomeMessage"
toolbar="ilch_html"
required><?=($this->escape($this->get('welcomeMessage')) != '') ? $this->escape($this->get('welcomeMessage')) : $this->escape($this->originalInput('welcomeMessage')) ?></textarea>
toolbar="ilch_html"><?=($this->escape($this->get('welcomeMessage')) != '') ? $this->escape($this->get('welcomeMessage')) : $this->escape($this->originalInput('welcomeMessage')) ?></textarea>
</div>
</div>
<?=$this->getSaveBar() ?>
Expand Down
2 changes: 1 addition & 1 deletion application/modules/contact/views/index/index.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<h1><?=$this->getTrans('menuContact') ?></h1>
<?php if (!empty($this->get('welcomeMessage'))) : ?>
<div class="card card-default">
<div class="card-body welcomeMessage"><?=$this->alwaysPurify($this->get('welcomeMessage')) ?></div>
<div class="card-body welcomeMessage ck-content"><?=$this->alwaysPurify($this->get('welcomeMessage')) ?></div>
</div>
<?php endif; ?>
<?php if ($this->get('receivers') != ''): ?>
Expand Down
2 changes: 1 addition & 1 deletion application/modules/events/views/show/event.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@
<div class="eventBoxHead">
<strong><?=$this->getTrans('description') ?></strong>
</div>
<div class="eventBoxContent">
<div class="eventBoxContent ck-content">
<?=$this->alwaysPurify($event->getText()) ?>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion application/modules/faq/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Config extends \Ilch\Config\Install
{
public $config = [
'key' => 'faq',
'version' => '1.10.1',
'version' => '1.10.2',
'icon_small' => 'fa-regular fa-circle-question',
'author' => 'Veldscholten, Kevin',
'link' => 'https://ilch.de',
Expand Down
2 changes: 1 addition & 1 deletion application/modules/faq/views/index/show.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
?>

<h1><?=$this->escape($faq->getQuestion()) ?></h1>
<?=$faq->getAnswer() ?>
<div class="ck-content"><?=$faq->getAnswer() ?></div>
2 changes: 1 addition & 1 deletion application/modules/forum/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Config extends \Ilch\Config\Install
{
public $config = [
'key' => 'forum',
'version' => '1.35.3',
'version' => '1.35.4',
'icon_small' => 'fa-solid fa-list',
'author' => 'Stantin Thomas',
'link' => 'https://ilch.de',
Expand Down
4 changes: 2 additions & 2 deletions application/modules/forum/views/showposts/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,13 @@
</div>
<div class="postbody">
<hr class="hr-top" />
<div class="content">
<div class="content ck-content">
<?=$this->alwaysPurify($post->getText()) ?>
</div>

<?php if ($post->getAutor()->getSignature()) : ?>
<hr />
<?=$this->alwaysPurify($post->getAutor()->getSignature()) ?>
<div class="ck-content"><?=$this->alwaysPurify($post->getAutor()->getSignature()) ?></div>
<?php endif; ?>
</div>
<dl class="postprofile">
Expand Down
2 changes: 1 addition & 1 deletion application/modules/guestbook/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Config extends \Ilch\Config\Install
{
public $config = [
'key' => 'guestbook',
'version' => '1.14.1',
'version' => '1.14.2',
'icon_small' => 'fa-solid fa-book',
'author' => 'Stantin, Thomas',
'link' => 'https://ilch.de',
Expand Down
2 changes: 1 addition & 1 deletion application/modules/guestbook/views/index/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
</div>
</div>
</div>
<div class="card-body">
<div class="card-body ck-content">
<?=$this->alwaysPurify($entry->getText()) ?>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion application/modules/history/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Config extends \Ilch\Config\Install
{
public $config = [
'key' => 'history',
'version' => '1.10.0',
'version' => '1.10.1',
'icon_small' => 'fa-solid fa-clock-rotate-left',
'author' => 'Veldscholten, Kevin',
'link' => 'https://ilch.de',
Expand Down
2 changes: 1 addition & 1 deletion application/modules/history/views/admin/index/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<td><?=$this->getDeleteIcon(['action' => 'del', 'id' => $entry->getId()]) ?></td>
<td><?=$getDate->format('d.m.Y', true) ?></td>
<td><?=$this->escape($entry->getTitle()) ?></td>
<td><?=$this->purify($entry->getText()) ?></td>
<td class="ck-content"><?=$this->purify($entry->getText()) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
Expand Down
2 changes: 1 addition & 1 deletion application/modules/history/views/index/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

<div class="cd-timeline-content">
<h3 id="history-<?=$history->getId() ?>"><a href="<?=$this->getUrl(['action' => 'index']) ?>#history-<?=$history->getId() ?>"><?=$this->escape($history->getTitle()) ?></a></h3>
<?=$this->purify($history->getText()) ?>
<div class="ck-content"><?=$this->purify($history->getText()) ?></div>
<?php $getDate = new \Ilch\Date($history->getDate()); ?>
<span class="cd-date"><?=$getDate->format('d. ', true) . $this->getTrans($getDate->format('F', true)) . $getDate->format(' Y', true) ?></span>
</div>
Expand Down
2 changes: 1 addition & 1 deletion application/modules/imprint/views/index/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
$imprint = $this->get('imprint');
?>
<h1><?=$this->getTrans('menuImprint') ?></h1>
<?=$this->purify($imprint->getImprint()) ?>
<div class="ck-content"><?=$this->purify($imprint->getImprint()) ?></div>
2 changes: 1 addition & 1 deletion application/modules/jobs/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Config extends \Ilch\Config\Install
{
public $config = [
'key' => 'jobs',
'version' => '1.7.0',
'version' => '1.7.1',
'icon_small' => 'fa-solid fa-briefcase',
'author' => 'Veldscholten, Kevin',
'link' => 'https://ilch.de',
Expand Down
8 changes: 5 additions & 3 deletions application/modules/jobs/views/index/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,18 @@
<?php if ($jobs) : ?>
<div class="row">
<?php foreach ($jobs as $job) : ?>
<div class="col-xl-2">
<div class="col-xl-1">
<i class="fa-solid fa-briefcase fa-4x briefcase"></i>
</div>
<div class="col-xl-10" style="margin-bottom: 35px;">
<div class="col-xl-11" style="margin-bottom: 35px;">
<h1>
<a href="<?=$this->getUrl('jobs/index/show/id/' . $job->getId()) ?>">
<?=$this->escape($job->getTitle()) ?>
</a>
</h1>
<?=$this->purify($job->getText()) ?>
<div class="ck-content">
<?=$this->purify($job->getText()) ?>
</div>

<?php if ($this->getUser()) : ?>
<br />
Expand Down
8 changes: 5 additions & 3 deletions application/modules/jobs/views/index/show.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@
<h1><?=$this->getTrans('menuJob') ?></h1>

<div class="row">
<div class="col-xl-2">
<div class="col-xl-1">
<i class="fa-solid fa-briefcase fa-4x briefcase"></i>
</div>
<div class="col-xl-10" style="margin-bottom: 35px;">
<div class="col-xl-11" style="margin-bottom: 35px;">
<h1><?=$this->escape($job->getTitle()) ?></h1>
<?=$this->purify($job->getText()) ?>
<div class="ck-content">
<?=$this->purify($job->getText()) ?>
</div>
</div>
</div>

Expand Down
2 changes: 1 addition & 1 deletion application/modules/newsletter/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Config extends Install
{
public $config = [
'key' => 'newsletter',
'version' => '1.8.1',
'version' => '1.8.2',
'icon_small' => 'fa-regular fa-newspaper',
'author' => 'Veldscholten, Kevin',
'link' => 'https://ilch.de',
Expand Down
2 changes: 1 addition & 1 deletion application/modules/newsletter/controllers/admin/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public function treatAction()
'{sitetitle}' => $this->getLayout()->escape($this->getConfig()->get('page_title')),
'{date}' => $date->format('l, d. F Y', true),
'{footer}' => $this->getTranslator()->trans('noReplyMailFooter'),
'{unreadable}' => $this->getTranslator()->trans('mailUnreadable', $newsletterMapper->getLastId(), $email->getEmail()),
'{unreadable}' => $this->getTranslator()->trans('mailUnreadable', $newsletterMapper->getLastId()),
'{unsubscribe}' => $this->getTranslator()->trans('mailUnsubscribe', $email->getSelector(), $email->getConfirmCode()),
];
$message = str_replace(array_keys($messageReplace), array_values($messageReplace), $messageTemplate);
Expand Down
3 changes: 0 additions & 3 deletions application/modules/newsletter/layouts/show.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
use Ilch\Translator;

$config = Registry::get('config');
$subscriberMapper = new Modules\Newsletter\Mappers\Subscriber();
$subscriber = $subscriberMapper->getSubscriberByEMail($this->getRequest()->getParam('email'));
$translator = new Translator();
$translator->load(APPLICATION_PATH . '/modules/newsletter/translations/');
?>
Expand Down Expand Up @@ -223,7 +221,6 @@
<td class="container">
<div class="content" align="center">
<p><?=$translator->trans('noReplyMailFooter') ?></p>
<p><?=$translator->trans('mailUnsubscribe', $subscriber->getSelector(), $subscriber->getConfirmCode()) ?></p>
</div>
</td>
<td></td>
Expand Down
2 changes: 1 addition & 1 deletion application/modules/newsletter/translations/de.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
'unsubscribeSuccess' => 'E-Mail wurde erfolgreich ausgetragen.',
'subscribeFailed' => 'Eintragen fehlgeschlagen.',
'noReplyMailFooter' => 'Bitte antworten Sie nicht auf diese E-Mail. Dieses Postfach wird nicht überwacht, deshalb werden Sie keine Antwort erhalten.',
'mailUnreadable' => 'Falls Sie keine HTML E-Mail lesen können klicken Sie <a href="' . BASE_URL . '/index.php/newsletter/index/show/id/%s/email/%s">hier</a>.',
'mailUnreadable' => 'Falls Sie keine HTML E-Mail lesen können klicken Sie <a href="' . BASE_URL . '/index.php/newsletter/index/show/id/%s">hier</a>.',
'mailUnsubscribe' => 'Wenn Sie keine Newsletter von uns erhalten wollen, können Sie diese jederzeit <a href="' . BASE_URL . '/index.php/newsletter/index/unsubscribe/selector/%s/code/%s">hier</a> abmelden.',
'incompleteUnsubscribeUrl' => 'Die Adresse zum Austragen aus dem Newsletter ist ungültig.',
'incompleteDoubleOptInUrl' => 'Die Adresse zur Bestätigung der Registrierung für den Newsletter ist ungültig.',
Expand Down
2 changes: 1 addition & 1 deletion application/modules/newsletter/translations/en.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
'unsubscribeSuccess' => 'E-Mail has been successfully removed.',
'subscribeFailed' => 'Subscribing failed.',
'noReplyMailFooter' => 'Please do not reply to this email. This mailbox is not monitored, so you will not receive a response.',
'mailUnreadable' => 'If you can not read HTML E-Mail click <a href="' . BASE_URL . '/index.php/newsletter/index/show/id/%s/email/%s">here</a>.',
'mailUnreadable' => 'If you can not read HTML E-Mail click <a href="' . BASE_URL . '/index.php/newsletter/index/show/id/%s">here</a>.',
'mailUnsubscribe' => 'If you do not wish to receive newsletters from us, you can cancel these at any time <a href="' . BASE_URL . '/index.php/newsletter/index/unsubscribe/selector/%s/code/%s">here</a>.',
'incompleteUnsubscribeUrl' => 'The url to unsubscribe from the newsletter is invalid.',
'incompleteDoubleOptInUrl' => 'The url to confirm the subscription to the newsletter is invalid.',
Expand Down
47 changes: 25 additions & 22 deletions application/modules/newsletter/views/admin/index/show.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,34 @@
?>

<h1><?=$this->getTrans('show') ?></h1>
<form method="POST" action="">
<?=$this->getTokenField() ?>
<div class="row mb-3">
<div class="col-xl-2">
<?=$this->getTrans('date') ?>:
</div>
<div class="col-xl-4"><?=$date->format('d.m.Y H:i', true) ?></div>
<div class="row mb-3">
<div class="col-xl-2">
<?=$this->getTrans('date') ?>:
</div>
<div class="col-xl-4"><?=$date->format('d.m.Y H:i', true) ?></div>
</div>
<div class="row mb-3">
<div class="col-xl-2">
<?=$this->getTrans('from') ?>:
</div>
<div class="row mb-3">
<div class="col-xl-2">
<?=$this->getTrans('from') ?>:
</div>
<div class="col-xl-4"><a href="<?=$this->getUrl('user/profil/index/user/' . $user->getId()) ?>" target="_blank"><?=$this->escape($user->getName()) ?></a></div>
<div class="col-xl-4"><a href="<?=$this->getUrl('user/profil/index/user/' . $user->getId()) ?>" target="_blank"><?=$this->escape($user->getName()) ?></a></div>
</div>
<div class="row mb-3">
<div class="col-xl-2">
<?=$this->getTrans('subject') ?>:
</div>
<div class="row mb-3">
<div class="col-xl-2">
<?=$this->getTrans('subject') ?>:
</div>
<div class="col-xl-10"><?=$this->escape($newsletter->getSubject()) ?></div>
<div class="col-xl-10"><?=$this->escape($newsletter->getSubject()) ?></div>
</div>
<div class="row mb-3">
<div class="col-xl-2">
<?=$this->getTrans('text') ?>:
</div>
<div class="row mb-3">
<div class="col-xl-2">
<?=$this->getTrans('text') ?>:
</div>
<div class="col-xl-10"><?=$this->purify($newsletter->getText()) ?></div>
<div class="col-xl-10 ck-content">
<?=$this->purify($newsletter->getText()) ?>
</div>
</div>

<form method="POST" action="">
<?=$this->getTokenField() ?>
<?=$this->getSaveBar('delete') ?>
</form>
2 changes: 1 addition & 1 deletion application/modules/newsletter/views/index/show.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
<p class="small text-muted"><?=$date->format('l, d. F Y', true) ?></p>
<p>&nbsp;</p>
<p><b><?=$newsletter->getSubject() ?></b></p>
<p><?=$newsletter->getText() ?></p>
<div class="ck-content"><?=$this->purify($newsletter->getText()) ?></div>
2 changes: 1 addition & 1 deletion application/modules/privacy/views/index/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
}
?>
<h1><b><?=$this->escape($privacy->getTitle()) ?></b></h1>
<p><?=$this->purify($privacy->getText()) ?><br /></p>
<div class="ck-content"><?=$this->purify($privacy->getText()) ?></div><br>
<?php endforeach; ?>
<?php if (count($sources) > 0) : ?>
<b><?=$this->getTrans('source') ?>:</b>
Expand Down
2 changes: 1 addition & 1 deletion application/modules/rule/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Config extends \Ilch\Config\Install
{
public $config = [
'key' => 'rule',
'version' => '1.9.1',
'version' => '1.9.2',
'icon_small' => 'fa-solid fa-gavel',
'author' => 'Veldscholten, Kevin',
'link' => 'https://ilch.de',
Expand Down
Loading

0 comments on commit 6cee514

Please sign in to comment.