Skip to content
Snippets Groups Projects
Commit 70be627f authored by Moritz Strohm's avatar Moritz Strohm
Browse files

fix for BIESt #1075

Merge request studip/studip!644
parent d70df557
No related branches found
No related tags found
No related merge requests found
...@@ -297,6 +297,10 @@ class WikiController extends AuthenticatedController ...@@ -297,6 +297,10 @@ class WikiController extends AuthenticatedController
"function() {jQuery(this).closest('form').submit();}" "function() {jQuery(this).closest('form').submit();}"
); );
$this->show_wiki_page_form = false;
$this->bad_course_search = false;
$this->success = false;
//The following steps are identical for the search and the import. //The following steps are identical for the search and the import.
if (Request::submitted('selected_course_id') || Request::submitted('import')) { if (Request::submitted('selected_course_id') || Request::submitted('import')) {
CSRFProtection::verifyUnsafeRequest(); CSRFProtection::verifyUnsafeRequest();
......
...@@ -393,6 +393,8 @@ class StudipCoreFormat extends TextFormat ...@@ -393,6 +393,8 @@ class StudipCoreFormat extends TextFormat
$rows = explode("\n", rtrim($matches[0])); $rows = explode("\n", rtrim($matches[0]));
$indent = 0; $indent = 0;
$result = '';
foreach ($rows as $row) { foreach ($rows as $row) {
list($level, $text) = explode(' ', $row, 2); list($level, $text) = explode(' ', $row, 2);
$level = mb_strlen($level); $level = mb_strlen($level);
......
...@@ -17,10 +17,13 @@ class WikiFormat extends StudipFormat ...@@ -17,10 +17,13 @@ class WikiFormat extends StudipFormat
private static $wiki_rules = [ private static $wiki_rules = [
'wiki-comments' => [ 'wiki-comments' => [
'start' => '\[comment(=.*?)\](.*?)\[\/comment\]', 'start' => '\[comment(=.*?)\](.*?)\[\/comment\]',
'callback' => 'WikiFormat::markupWikiComments' 'end' => '',
'callback' => 'WikiFormat::markupWikiComments',
'before' => ''
], ],
'wiki-links' => [ 'wiki-links' => [
'start' => '\[\[(.*?)(?:\|(.*?))?\]\]', 'start' => '\[\[(.*?)(?:\|(.*?))?\]\]',
'end' => '',
'callback' => 'WikiFormat::markupWikiLinks', 'callback' => 'WikiFormat::markupWikiLinks',
'before' => 'links' 'before' => 'links'
], ],
...@@ -143,7 +146,7 @@ class WikiFormat extends StudipFormat ...@@ -143,7 +146,7 @@ class WikiFormat extends StudipFormat
protected static function markupWikiLinks($markup, $matches) protected static function markupWikiLinks($markup, $matches)
{ {
$keyword = decodeHTML($matches[1]); $keyword = decodeHTML($matches[1]);
$display_page = $matches[2] ? $markup->format($matches[2]) : htmlReady($keyword); $display_page = !empty($matches[2]) ? $markup->format($matches[2]) : htmlReady($keyword);
$page = WikiPage::findLatestPage(Context::getId(), $keyword); $page = WikiPage::findLatestPage(Context::getId(), $keyword);
......
...@@ -179,7 +179,7 @@ function keywordExists($str, $sem_id = null) { ...@@ -179,7 +179,7 @@ function keywordExists($str, $sem_id = null) {
$trans_tbl = array_flip(get_html_translation_table(HTML_ENTITIES)); $trans_tbl = array_flip(get_html_translation_table(HTML_ENTITIES));
$nonhtmlstr = strtr($str, $trans_tbl); $nonhtmlstr = strtr($str, $trans_tbl);
return $keywords[$nonhtmlstr]; return $keywords[$nonhtmlstr] ?? false;
} }
...@@ -758,6 +758,7 @@ function searchWiki($searchfor, $searchcurrentversions, $keyword, $localsearch) ...@@ -758,6 +758,7 @@ function searchWiki($searchfor, $searchcurrentversions, $keyword, $localsearch)
{ {
$range_id = Context::getId(); $range_id = Context::getId();
$result = null; $result = null;
$invalid_searchstring = false;
// check for invalid search string // check for invalid search string
if (mb_strlen($searchfor) < 3) { if (mb_strlen($searchfor) < 3) {
...@@ -953,6 +954,7 @@ function searchWiki($searchfor, $searchcurrentversions, $keyword, $localsearch) ...@@ -953,6 +954,7 @@ function searchWiki($searchfor, $searchcurrentversions, $keyword, $localsearch)
**/ **/
function wikiEdit($keyword, $wikiData, $user_id, $backpage=NULL, $ancestor=NULL) function wikiEdit($keyword, $wikiData, $user_id, $backpage=NULL, $ancestor=NULL)
{ {
$parent = null;
if (!$wikiData || $wikiData->isNew()) { if (!$wikiData || $wikiData->isNew()) {
$body = ''; $body = '';
$version = 0; $version = 0;
...@@ -1005,8 +1007,9 @@ function wikiEdit($keyword, $wikiData, $user_id, $backpage=NULL, $ancestor=NULL) ...@@ -1005,8 +1007,9 @@ function wikiEdit($keyword, $wikiData, $user_id, $backpage=NULL, $ancestor=NULL)
} }
// Action menu for content bar. // Action menu for content bar.
$actionMenu = ActionMenu::get();
if ($page && $page->isLatestVersion()) { if ($page && $page->isLatestVersion()) {
$actionMenu = ActionMenu::get()->setContext($page->keyword); $actionMenu->setContext($page->keyword);
if ($page->isEditableBy($GLOBALS['user'])) { if ($page->isEditableBy($GLOBALS['user'])) {
if (!$page->isNew()) { if (!$page->isNew()) {
$actionMenu->addLink( $actionMenu->addLink(
...@@ -1103,6 +1106,7 @@ function exportAllWikiPagesPDF($mode, $sortby) ...@@ -1103,6 +1106,7 @@ function exportAllWikiPagesPDF($mode, $sortby)
$versionsortlink = 'version'; $versionsortlink = 'version';
$changesortlink = 'lastchange'; $changesortlink = 'lastchange';
$sort = '';
switch ($sortby) { switch ($sortby) {
case 'title': case 'title':
// sort by keyword, prepare link for descending sorting // sort by keyword, prepare link for descending sorting
...@@ -1512,7 +1516,7 @@ function get_toc_content() { ...@@ -1512,7 +1516,7 @@ function get_toc_content() {
} }
$toccont = '<div class="wikitoc" id="00toc">'; $toccont = '<div class="wikitoc" id="00toc">';
$toccont .= wikiReady($toc['body'], true, false, $show_comments); $toccont .= wikiReady($toc['body'], true);
$toccont .= '</div>'; $toccont .= '</div>';
return $toccont; return $toccont;
} }
...@@ -1557,8 +1561,9 @@ function showWikiPage($keyword, $version, $special="", $show_comments="icon", $h ...@@ -1557,8 +1561,9 @@ function showWikiPage($keyword, $version, $special="", $show_comments="icon", $h
} }
// Action menu for content bar. // Action menu for content bar.
$actionMenu = ActionMenu::get();
if ($page && $page->isLatestVersion()) { if ($page && $page->isLatestVersion()) {
$actionMenu = ActionMenu::get()->setContext($page->keyword); $actionMenu->setContext($page->keyword);
if ($page->isEditableBy($GLOBALS['user'])) { if ($page->isEditableBy($GLOBALS['user'])) {
if (!$page->isNew()) { if (!$page->isNew()) {
$actionMenu->addLink( $actionMenu->addLink(
......
...@@ -112,7 +112,7 @@ $getInstalledLanguages = function () { ...@@ -112,7 +112,7 @@ $getInstalledLanguages = function () {
(Navigation::hasItem('/admin/institute') && Navigation::getItem('/admin/institute')->isActive())); ?> (Navigation::hasItem('/admin/institute') && Navigation::getItem('/admin/institute')->isActive())); ?>
<div id="layout_page" <? if (!($contextable)) echo 'class="contextless"'; ?>> <div id="layout_page" <? if (!($contextable)) echo 'class="contextless"'; ?>>
<? if (PageLayout::isHeaderEnabled() && Navigation::hasItem('/course') && Navigation::getItem('/course')->isActive() && $_SESSION['seminar_change_view_'.Context::getId()]) : ?> <? if (PageLayout::isHeaderEnabled() && Navigation::hasItem('/course') && Navigation::getItem('/course')->isActive() && !empty($_SESSION['seminar_change_view_'.Context::getId()])) : ?>
<?= $this->render_partial('change_view', ['changed_status' => $_SESSION['seminar_change_view_'.Context::getId()]]) ?> <?= $this->render_partial('change_view', ['changed_status' => $_SESSION['seminar_change_view_'.Context::getId()]]) ?>
<? endif ?> <? endif ?>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment