aboutsummaryrefslogtreecommitdiff
path: root/app/views/course/wiki
diff options
context:
space:
mode:
Diffstat (limited to 'app/views/course/wiki')
-rw-r--r--app/views/course/wiki/ask_deleting.php31
-rw-r--r--app/views/course/wiki/history.php20
-rw-r--r--app/views/course/wiki/newpages.php22
-rw-r--r--app/views/course/wiki/search.php19
-rw-r--r--app/views/course/wiki/searchpage.php48
5 files changed, 134 insertions, 6 deletions
diff --git a/app/views/course/wiki/ask_deleting.php b/app/views/course/wiki/ask_deleting.php
new file mode 100644
index 0000000..5afd19f
--- /dev/null
+++ b/app/views/course/wiki/ask_deleting.php
@@ -0,0 +1,31 @@
+<form action="" method="post">
+ <?= CSRFProtection::tokenTag() ?>
+ <div class="file_select_possibilities">
+ <div>
+ <div class="clickable">
+ <?= Icon::create('archive2')->asInput(50, [
+ 'formaction' => $controller->deleteversionURL($page, ['redirect_to' => 'page']),
+ 'data-confirm' => _('Wirklich die letzte Änderung löschen?')
+ ]) ?>
+ <button
+ class="undecorated"
+ data-confirm="<?= _('Wirklich die letzte Änderung löschen?') ?>"
+ formaction="<?= $controller->deleteversionURL($page, ['redirect_to' => 'page']) ?>">
+ <?= _('Nur die letzte Änderung löschen') ?>
+ </button>
+ </div>
+ <div class="clickable">
+ <?= Icon::create('wiki')->asInput(50, [
+ 'formaction' => $controller->deleteURL($page),
+ 'data-confirm' => _('Wollen Sie wirklich die komplette Seite löschen?')
+ ]) ?>
+ <button
+ class="undecorated"
+ data-confirm="<?= _('Wollen Sie wirklich die komplette Seite löschen?') ?>"
+ formaction="<?= $controller->deleteURL($page) ?>">
+ <?= _('Ganze Wikiseite löschen') ?>
+ </button>
+ </div>
+ </div>
+ </div>
+</form>
diff --git a/app/views/course/wiki/history.php b/app/views/course/wiki/history.php
index 81fde59..cbd324d 100644
--- a/app/views/course/wiki/history.php
+++ b/app/views/course/wiki/history.php
@@ -45,6 +45,16 @@
<a href="<?= $controller->versiondiff($page) ?>" data-dialog>
<?= Icon::create('log')->asImg(['class' => 'text-bottom']) ?>
</a>
+ <? if ($page->isEditable()) : ?>
+ <form action="<?= $controller->deleteversion($page) ?>"
+ method="post"
+ class="inline"
+ title="<?= _('Version löschen') ?>"
+ data-confirm="<?= _('Wirklich diese Version löschen?') ?>">
+ <?= CSRFProtection::tokenTag() ?>
+ <?= Icon::create('trash')->asInput() ?>
+ </form>
+ <? endif ?>
</td>
</tr>
<? foreach ($page->versions as $i => $version) : ?>
@@ -69,6 +79,16 @@
<a href="<?= $controller->versiondiff($page, $version->id) ?>" data-dialog>
<?= Icon::create('log')->asImg(['class' => 'text-bottom']) ?>
</a>
+ <? if ($page->isEditable()) : ?>
+ <form action="<?= $controller->deleteversion($page, $version->id) ?>"
+ method="post"
+ class="inline"
+ title="<?= _('Version löschen') ?>"
+ data-confirm="<?= _('Wirklich diese Version löschen?') ?>">
+ <?= CSRFProtection::tokenTag() ?>
+ <?= Icon::create('trash')->asInput() ?>
+ </form>
+ <? endif ?>
</td>
</tr>
<? endforeach ?>
diff --git a/app/views/course/wiki/newpages.php b/app/views/course/wiki/newpages.php
index d9e0dce..99e0f29 100644
--- a/app/views/course/wiki/newpages.php
+++ b/app/views/course/wiki/newpages.php
@@ -55,36 +55,41 @@
<td>
<?
$authors = [$page->user_id => $page->user];
+ $versions = [$page];
$oldcontent = "";
$oldversion = $page;
while ($oldversion = $oldversion->predecessor) {
if ($oldversion->mkdate >= $last_visit && $oldversion->user_id !== User::findCurrent()->id) {
$oldcontent = $oldversion->content;
if (!isset($authors[$oldversion->user_id])) {
+ $versions[] = $oldversion;
$authors[$oldversion->user_id] = $oldversion->user;
}
} else {
break;
}
}
+ if ($oldversion) {
+ $oldcontent = $oldversion->content;
+ }
$oldcontent = strip_tags(wikiReady($oldcontent));
$content = strip_tags(wikiReady($page->content));
$commonFromStart = $controller->findLongestCommonSubstring($content, $oldcontent);
$commonFromEnd = $controller->findLongestCommonSubstring($content, $oldcontent, true);
- $content = mb_substr($content, $commonFromStart, $commonFromEnd);
- $oldcontent = mb_substr($oldcontent, $commonFromStart, $commonFromEnd);
+ $oldcontent = mb_substr($oldcontent, $commonFromStart, mb_strlen($oldcontent) - mb_strlen($content));
+ $content = mb_substr($content, $commonFromStart, $commonFromEnd - $commonFromStart);
if ($content) {
echo htmlReady(mila($content, 300), true, true);
} elseif ($oldcontent) {
- echo _('Gelöscht') . ': ' . htmlReady($oldcontent, true, true);
+ echo _('Gelöscht') . ': ' . htmlReady(mila($oldcontent, 300), true, true);
}
?>
</td>
<td>
<ul class="wiki_authors">
- <? foreach ($authors as $user) : ?>
+ <? foreach ($authors as $user_id => $user) : ?>
<li>
<? if ($user): ?>
<a href="<?= URLHelper::getLink('dispatch.php/profile', ['username' => $user->username]) ?>"
@@ -95,6 +100,15 @@
<? else: ?>
<?= _('unbekannt') ?>
<? endif; ?>
+ <? foreach ($versions as $version) : ?>
+ <? if ($version->user_id === $user_id) : ?>
+ <a href="<?= $controller->versiondiff($page, is_a($version, 'WikiVersion') ? $version->id : null) ?>"
+ title="<?= _('Einzelne Änderung anzeigen') ?>"
+ data-dialog>
+ <?= Icon::create('log')->asImg(['class' => 'text-bottom']) ?>
+ </a>
+ <? endif ?>
+ <? endforeach ?>
</li>
<? endforeach ?>
</ul>
diff --git a/app/views/course/wiki/search.php b/app/views/course/wiki/search.php
index 27811eb..8ef886a 100644
--- a/app/views/course/wiki/search.php
+++ b/app/views/course/wiki/search.php
@@ -10,7 +10,7 @@
<table class="default">
<caption>
- <?= sprintf(_('Treffer für Suche nach <em>%s</em> in allen Versionen'), htmlReady(Request::get('search'))) ?>
+ <?= sprintf(_('Treffer für Suche nach <em>%s</em>'), htmlReady(Request::get('search'))) ?>
</caption>
<thead>
<tr>
@@ -45,6 +45,7 @@
<td>
<?
$content = Studip\Markup::removeHtml($content);
+ $ignore_next_hits = 0;
$offset = 0;
$output = [];
@@ -55,7 +56,7 @@
break;
}
$offset = $pos + 1;
- if (($ignore_next_hits--) > 0) {
+ if ($ignore_next_hits-- > 0) {
// if more than one occurence is found
// in a fragment to be displayed,
// the fragment is only shown once
@@ -95,6 +96,20 @@
<? endif ?>
</td>
</tr>
+ <? if ($pagedata['is_in_history'] && count($pagedata['versions']) > 1 || ($pagedata['is_in_content'] && count($pagedata['versions']) > 0)) : ?>
+ <tr>
+ <td colspan="3">
+ <a href="<?= $controller->searchpage($page_id, ['search' => Request::get('search')]) ?>">
+ <?= Icon::create('add')->asImg(['class' => 'text-bottom']) ?>
+ <? if (count($pagedata['versions']) === 1) : ?>
+ <?= _('Weiterer Treffer in einer älteren Version.') ?>
+ <? else : ?>
+ <?= sprintf(_('Weitere Treffer in %d älteren Versionen.'), count($pagedata['versions'])) ?>
+ <? endif ?>
+ </a>
+ </td>
+ </tr>
+ <? endif ?>
<? endforeach ?>
</tbody>
</table>
diff --git a/app/views/course/wiki/searchpage.php b/app/views/course/wiki/searchpage.php
new file mode 100644
index 0000000..95b6ff4
--- /dev/null
+++ b/app/views/course/wiki/searchpage.php
@@ -0,0 +1,48 @@
+<table class="default">
+ <caption>
+ <?= sprintf(_('Treffer für Suche nach <em>%s</em> auf Seite %s'), htmlReady(Request::get('search')), htmlReady($page->name)) ?>
+ </caption>
+ <thead>
+ <tr>
+ <th><?= _('Seite') ?></th>
+ <th><?= _('Treffer') ?></th>
+ <th><?= _('Datum') ?></th>
+ </tr>
+ </thead>
+ <tbody>
+ <? $pos_name = mb_stripos($page->name, Request::get('search')) ?>
+ <? $pos_content = mb_stripos($page->content, Request::get('search')) ?>
+ <? if ($pos_name !== false || $pos_content !== false) : ?>
+ <tr>
+ <td>
+ <a href="<?= $controller->page($page) ?>">
+ <?= htmlReady($page->name) ?>
+ </a>
+ </td>
+ <td>
+ <?= $controller->findTextualHits($page->content, Request::get('search'), 200) ?>
+ </td>
+ <td>
+ <?= $page->chdate > 0 ? date('d.m.Y H:i:s', $page->chdate) : _('unbekannt') ?>
+ (<?= _('Version').' '.htmlReady($page->versionnumber) ?>)
+ </td>
+ </tr>
+ <? endif ?>
+ <? foreach ($versions as $version) : ?>
+ <tr>
+ <td>
+ <a href="<?= $controller->version($version) ?>">
+ <?= htmlReady($version->name) ?>
+ </a>
+ </td>
+ <td>
+ <?= $controller->findTextualHits($version->content, Request::get('search'), 200) ?>
+ </td>
+ <td>
+ <?= $version->mkdate > 0 ? date('d.m.Y H:i:s', $version->mkdate) : _('unbekannt') ?>
+ (<?= _('Version').' '.htmlReady($version->versionnumber) ?>)
+ </td>
+ </tr>
+ <? endforeach ?>
+ </tbody>
+</table>