// edit page case "edit": if (!$wiki->pageExists($wiki_title) && !$is_allowedToCreate) { $tool_content .= $langWikiNotAllowedToCreate; } elseif ($wiki->pageExists($wiki_title) && !$is_allowedToEdit) { $tool_content .= $langWikiNotAllowedToEdit; } else { $script = $_SERVER['SCRIPT_NAME'] . "?course={$course_code}"; //Do not show progress bar if a lock conflict was detected if (!isset($pre_action) || $pre_action != 'conflict') { //add lock time progress bar $head_content .= "<script type='text/javascript'>\n function secondsToHms(d) {\n d = Number(d);\n var h = Math.floor(d / 3600);\n var m = Math.floor(d % 3600 / 60);\n var s = Math.floor(d % 3600 % 60);\n return ((h > 0 ? h + \":\" : \"\") + (m > 0 ? (h > 0 && m < 10 ? \"0\" : \"\") + m + \":\" : \"0:\") + (s < 10 ? \"0\" : \"\") + s); }\n </script>\n\n"; $head_content .= "<script type='text/javascript'>\n \tfunction countdown(callback) {\n \t var bar = document.getElementById('progress'),\n \t timer = document.getElementById('progresstime'),\n \t time = max = " . ($lock_manager->lock_duration - 5) . ",\n \t \n \t url = 'lib/confirmlock.php'\n \t data = { uid : " . $uid . ", page_title : \"" . rawurlencode($wiki_title) . "\", wiki_id : " . $wikiId . " }\n \t \n \t int = setInterval(function() { \n \t \ttimer.innerHTML = secondsToHms(time);\n \t bar.style.width = Math.floor(100 * time-- / max) + '%';\n \t if (time + 1 == 0) {\n \t clearInterval(int);\n \t // 600ms - width animation time\n \t callback && setTimeout(callback, 600);\n \t }\n \t if ((max - time) % 25 == 0) {//ajax polling to keep lock alive \n \t \$.post(url, data); \n \t }\n \t }, 1000);\n \t}\n \t \n \t\$(document).ready(function(){\n \t countdown(function() {\n \t bootbox.alert('" . $langWikiLockTimeEnd . "');\n \t });\n })\n </script>\n"; $tool_content .= " <div>\n {$langWikiLockTimeRemaining}\n <span id='progresstime'>" . intval(gmdate('i', $lock_manager->lock_duration - 5)) . ":" . gmdate('s', $lock_manager->lock_duration - 5) . "</span>\n </div>\n <div class='progress'>\n <div class='progress-bar progress-bar-striped active' id='progress'></div>\n </div>\n <noscript>\n <div>\n <img src='lib/nojslock.php?uid={$uid}&page_title=" . urlencode($wiki_title) . "&wiki_id={$wikiId}'>\n </div>\n </noscript>"; } $tool_content .= claro_disp_wiki_editor($wikiId, $wiki_title, $versionId, $content, $changelog, $script, true, false); } break; //delete page //delete page case "delete": if ($wiki_title != "__MainPage__" and $is_editor) { //only a teacher can delete a page if ($wikiStore->pageExists($wikiId, $wiki_title)) { $wikiPage->loadPage($wiki_title); if ($wikiPage->delete()) { Session::Messages($langWikiPageDeleted, 'alert-success'); redirect_to_home_page("modules/wiki/page.php?course={$course_code}&wikiId={$wikiId}&action=show"); } else { Session::Messages($langWikiDeletePageError, 'alert-danger'); redirect_to_home_page("modules/wiki/page.php?course={$course_code}&action=show&title=" . rawurlencode($wiki_title) . "&wikiId={$wikiId}");
$link = '<a href="' . claro_htmlspecialchars(Url::Contextualize($_SERVER['PHP_SELF'] . '?wikiId=' . (int) $wikiId . '&title=' . $pgtitle . '&action=show')) . '">' . $page['title'] . '</a>'; $out .= '<li>' . $link . '</li>' . "\n"; } $out .= '</ul>' . "\n"; } break; // edit page // edit page case 'edit': if (!$wiki->pageExists($title) && !$is_allowedToCreate) { $out .= get_lang("You are not allowed to create pages"); } elseif ($wiki->pageExists($title) && !$is_allowedToEdit) { $out .= get_lang("You are not allowed to edit this page"); } else { $script = claro_htmlspecialchars(Url::Contextualize($_SERVER['PHP_SELF'])); $out .= claro_disp_wiki_editor($wikiId, $title, $versionId, $content, $script, get_conf('showWikiEditorToolbar'), get_conf('forcePreviewBeforeSaving')); } break; // page preview // page preview case 'preview': if (!isset($content)) { $content = ''; } $out .= claro_disp_wiki_preview($wikiRenderer, $title, $content); $out .= claro_disp_wiki_preview_buttons($wikiId, $title, $content); break; // view page // view page case 'show': if ($wikiPage->hasError()) {