Skip to content
Snippets Groups Projects
Commit 9952a73d authored by Rasmus Fuhse's avatar Rasmus Fuhse
Browse files

Resolve "Wiki ab 5.5: Fehler nach dem Merge im Main"

Closes #3652

Merge request studip/studip!2532
parent 1383328e
No related branches found
No related tags found
No related merge requests found
...@@ -545,6 +545,32 @@ class Course_WikiController extends AuthenticatedController ...@@ -545,6 +545,32 @@ class Course_WikiController extends AuthenticatedController
public function newpages_action() public function newpages_action()
{ {
Navigation::activateItem('/course/wiki/listnew'); 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(" $statement = DBManager::get()->prepare("
SELECT `wiki_pages`.`page_id` AS `id`, SELECT `wiki_pages`.`page_id` AS `id`,
0 AS `is_version`, 0 AS `is_version`,
...@@ -560,10 +586,13 @@ class Course_WikiController extends AuthenticatedController ...@@ -560,10 +586,13 @@ class Course_WikiController extends AuthenticatedController
FROM `wiki_versions` FROM `wiki_versions`
JOIN `wiki_pages` USING (`page_id`) JOIN `wiki_pages` USING (`page_id`)
WHERE `wiki_pages`.`range_id` = :range_id WHERE `wiki_pages`.`range_id` = :range_id
ORDER BY `timestamp` ORDER BY `timestamp` DESC
LIMIT :offset, :limit
"); ");
$statement->execute([ $statement->execute([
'range_id' => $this->range->id 'range_id' => $this->range->id,
'offset' => Request::int('page', 0) * $this->limit,
'limit' => $this->limit
]); ]);
$this->versions = []; $this->versions = [];
foreach ($statement->fetchAll(PDO::FETCH_ASSOC) as $row) { foreach ($statement->fetchAll(PDO::FETCH_ASSOC) as $row) {
......
...@@ -12,26 +12,24 @@ ...@@ -12,26 +12,24 @@
<thead> <thead>
<tr> <tr>
<th data-sort="text"><?= _('Seitenname') ?></th> <th data-sort="text"><?= _('Seitenname') ?></th>
<th data-sort="text"><?= _('Änderungen') ?></th> <th data-sort="digit"><?= _('Änderungen') ?></th>
<th data-sort="text"><?= _('Letzte Änderung') ?></th> <th data-sort="htmldata"><?= _('Letzte Änderung') ?></th>
<th data-sort="text"><?= _('Zuletzt bearbeitet von') ?></th> <th data-sort="text"><?= _('Zuletzt bearbeitet von') ?></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<? foreach ($pages as $page) : ?> <? foreach ($pages as $page) : ?>
<tr> <tr>
<td data-sort-value="<?= htmlReady($page->name) ?>"> <td data-text="<?= htmlReady($page->name) ?>">
<a href="<?= $controller->page($page) ?>"> <a href="<?= $controller->page($page) ?>">
<?= htmlReady($page->name) ?> <?= htmlReady($page->name) ?>
</a> </a>
</td> </td>
<td data-sort-value="<?= count($page->versions) + 1 ?>"> <td><?= count($page->versions) + 1 ?></td>
<?= count($page->versions) + 1 ?> <td data-sort-value="<?= $page->chdate ?>">
</td>
<td data-sort-value="<?= htmlReady($page->chdate) ?>">
<?= $page->chdate > 0 ? date('d.m.Y H:i:s', $page->chdate) : _('unbekannt') ?> <?= $page->chdate > 0 ? date('d.m.Y H:i:s', $page->chdate) : _('unbekannt') ?>
</td> </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) ?> <?= Avatar::getAvatar($page->user_id)->getImageTag(Avatar::SMALL) ?>
<?= htmlReady($page->user ? $page->user->getFullName() : _('unbekannt')) ?> <?= htmlReady($page->user ? $page->user->getFullName() : _('unbekannt')) ?>
</td> </td>
......
<table class="default sortable-table" data-sortlist="[[3, 0]]"> <table class="default sortable-table" data-sortlist="[[3, 1]]">
<caption> <caption>
<?= _('Letzte Änderungen') ?> <?= _('Letzte Änderungen') ?>
</caption> </caption>
...@@ -15,4 +15,13 @@ ...@@ -15,4 +15,13 @@
<?= $this->render_partial('course/wiki/versioncompare', ['version' => $version]) ?> <?= $this->render_partial('course/wiki/versioncompare', ['version' => $version]) ?>
<? endforeach ?> <? endforeach ?>
</tbody> </tbody>
<? if ($num_entries > $limit) : ?>
<tfoot>
<tr>
<td colspan="4" class="actions">
<?= Pagination::create($num_entries, $page, $limit)->asLinks() ?>
</td>
</tr>
</tfoot>
<? endif ?>
</table> </table>
...@@ -18,11 +18,11 @@ ...@@ -18,11 +18,11 @@
$oldcontent = substr($oldcontent, 0, -1); $oldcontent = substr($oldcontent, 0, -1);
} }
if ($content) { if ($content) {
echo nl2br(htmlReady($content)); echo nl2br(htmlReady(mila($content, 300)));
} elseif ($oldcontent) { } elseif ($oldcontent) {
echo _('Gelöscht') . ': ' . nl2br(htmlReady($oldcontent)); echo _('Gelöscht') . ': ' . nl2br(htmlReady($oldcontent));
} else { } else {
echo nl2br(strip_tags(wikiReady($version->content))); echo nl2br(strip_tags(wikiReady(mila($version->content, 300))));
} }
?></td> ?></td>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment