From 9952a73d7f2c8879606a6e5cadd69deefb8c3c94 Mon Sep 17 00:00:00 2001 From: Rasmus Fuhse <fuhse@data-quest.de> Date: Fri, 19 Jan 2024 08:36:21 +0000 Subject: [PATCH] Resolve "Wiki ab 5.5: Fehler nach dem Merge im Main" Closes #3652 Merge request studip/studip!2532 --- app/controllers/course/wiki.php | 33 ++++++++++++++++++++++-- app/views/course/wiki/allpages.php | 14 +++++----- app/views/course/wiki/newpages.php | 11 +++++++- app/views/course/wiki/versioncompare.php | 4 +-- 4 files changed, 49 insertions(+), 13 deletions(-) diff --git a/app/controllers/course/wiki.php b/app/controllers/course/wiki.php index 0394f9d907e..d817ce01a94 100644 --- a/app/controllers/course/wiki.php +++ b/app/controllers/course/wiki.php @@ -545,6 +545,32 @@ class Course_WikiController extends AuthenticatedController public function newpages_action() { Navigation::activateItem('/course/wiki/listnew'); + + $this->limit = Config::get()->ENTRIES_PER_PAGE; + $statement = DBManager::get()->prepare(" + SELECT COUNT(*) FROM ( + SELECT `wiki_pages`.`page_id` AS `id`, + 0 AS `is_version`, + `wiki_pages`.`chdate` AS `timestamp` + FROM `wiki_pages` + WHERE `wiki_pages`.`range_id` = :range_id + + UNION + + SELECT `wiki_versions`.`version_id` AS `id`, + 1 AS `is_version`, + `wiki_versions`.`mkdate` AS `timestamp` + FROM `wiki_versions` + JOIN `wiki_pages` USING (`page_id`) + WHERE `wiki_pages`.`range_id` = :range_id + ) AS `all_entries` + "); + $statement->execute([ + 'range_id' => $this->range->id + ]); + $this->num_entries = $statement->fetch(PDO::FETCH_COLUMN); + $this->page = Request::int('page', 0); + $statement = DBManager::get()->prepare(" SELECT `wiki_pages`.`page_id` AS `id`, 0 AS `is_version`, @@ -560,10 +586,13 @@ class Course_WikiController extends AuthenticatedController FROM `wiki_versions` JOIN `wiki_pages` USING (`page_id`) WHERE `wiki_pages`.`range_id` = :range_id - ORDER BY `timestamp` + ORDER BY `timestamp` DESC + LIMIT :offset, :limit "); $statement->execute([ - 'range_id' => $this->range->id + 'range_id' => $this->range->id, + 'offset' => Request::int('page', 0) * $this->limit, + 'limit' => $this->limit ]); $this->versions = []; foreach ($statement->fetchAll(PDO::FETCH_ASSOC) as $row) { diff --git a/app/views/course/wiki/allpages.php b/app/views/course/wiki/allpages.php index 0bfe4ce4b04..5e4fcb86a00 100644 --- a/app/views/course/wiki/allpages.php +++ b/app/views/course/wiki/allpages.php @@ -12,26 +12,24 @@ <thead> <tr> <th data-sort="text"><?= _('Seitenname') ?></th> - <th data-sort="text"><?= _('Änderungen') ?></th> - <th data-sort="text"><?= _('Letzte Änderung') ?></th> + <th data-sort="digit"><?= _('Änderungen') ?></th> + <th data-sort="htmldata"><?= _('Letzte Änderung') ?></th> <th data-sort="text"><?= _('Zuletzt bearbeitet von') ?></th> </tr> </thead> <tbody> <? foreach ($pages as $page) : ?> <tr> - <td data-sort-value="<?= htmlReady($page->name) ?>"> + <td data-text="<?= htmlReady($page->name) ?>"> <a href="<?= $controller->page($page) ?>"> <?= htmlReady($page->name) ?> </a> </td> - <td data-sort-value="<?= count($page->versions) + 1 ?>"> - <?= count($page->versions) + 1 ?> - </td> - <td data-sort-value="<?= htmlReady($page->chdate) ?>"> + <td><?= count($page->versions) + 1 ?></td> + <td data-sort-value="<?= $page->chdate ?>"> <?= $page->chdate > 0 ? date('d.m.Y H:i:s', $page->chdate) : _('unbekannt') ?> </td> - <td data-sort-value="<?= htmlReady($page->user ? $page->user->getFullName() : _('unbekannt')) ?>"> + <td data-text="<?= htmlReady($page->user ? $page->user->getFullName() : _('unbekannt')) ?>"> <?= Avatar::getAvatar($page->user_id)->getImageTag(Avatar::SMALL) ?> <?= htmlReady($page->user ? $page->user->getFullName() : _('unbekannt')) ?> </td> diff --git a/app/views/course/wiki/newpages.php b/app/views/course/wiki/newpages.php index da7b560da2a..0220ac4dcde 100644 --- a/app/views/course/wiki/newpages.php +++ b/app/views/course/wiki/newpages.php @@ -1,4 +1,4 @@ -<table class="default sortable-table" data-sortlist="[[3, 0]]"> +<table class="default sortable-table" data-sortlist="[[3, 1]]"> <caption> <?= _('Letzte Änderungen') ?> </caption> @@ -15,4 +15,13 @@ <?= $this->render_partial('course/wiki/versioncompare', ['version' => $version]) ?> <? endforeach ?> </tbody> + <? if ($num_entries > $limit) : ?> + <tfoot> + <tr> + <td colspan="4" class="actions"> + <?= Pagination::create($num_entries, $page, $limit)->asLinks() ?> + </td> + </tr> + </tfoot> + <? endif ?> </table> diff --git a/app/views/course/wiki/versioncompare.php b/app/views/course/wiki/versioncompare.php index 490d1e28cd6..9c98ce4a27c 100644 --- a/app/views/course/wiki/versioncompare.php +++ b/app/views/course/wiki/versioncompare.php @@ -18,11 +18,11 @@ $oldcontent = substr($oldcontent, 0, -1); } if ($content) { - echo nl2br(htmlReady($content)); + echo nl2br(htmlReady(mila($content, 300))); } elseif ($oldcontent) { echo _('Gelöscht') . ': ' . nl2br(htmlReady($oldcontent)); } else { - echo nl2br(strip_tags(wikiReady($version->content))); + echo nl2br(strip_tags(wikiReady(mila($version->content, 300)))); } ?></td> -- GitLab