// Insert the link $linkdesc = get_string('reloadlinkdescription', 'wiki'); $linktext = get_string('reloadlinktext', 'wiki'); echo "<div class='wikilinkright'><a href='{$me}' title='{$linkdesc}'><input type='button' value='{$linktext}' /></a></div>"; print_simple_box_start('center', '100%', '', '20'); /// Don't filter any pages containing wiki actions (except view). A wiki page containing /// actions will have the form [action]/[pagename]. If the action is 'view' or the '/' /// isn't there (so the action defaults to 'view'), filter it. /// If the page does not yet exist, the display will default to 'edit'. if ((count($actions) < 2 || $actions[0] == "view") && $wiki_entry && record_exists('wiki_pages', 'pagename', addslashes($page), 'wiki', $wiki_entry->id)) { print format_text($content, $moodle_format); } else { if ($actions[0] == 'edit' && $reallyedit) { // Check the page isn't locked before printing out standard wiki content. (Locking // is implemented as a wrapper over the existing wiki.) list($gotlock, $lock) = wiki_obtain_lock($wiki_entry->id, $pagename); if (!$gotlock) { $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id); $canoverridelock = has_capability('mod/wiki:overridelock', $modcontext); $a = new stdClass(); $a->since = userdate($lock->lockedsince); $a->seen = userdate($lock->lockedseen); $user = get_record('user', 'id', $lock->lockedby); $a->name = fullname($user, has_capability('moodle/site:viewfullnames', $modcontext)); print_string('pagelocked', 'wiki', $a); if ($canoverridelock) { $pageesc = htmlspecialchars($page); $stroverrideinfo = get_string('overrideinfo', 'wiki'); $stroverridebutton = get_string('overridebutton', 'wiki'); $sesskey = sesskey(); print "\n<form id='overridelock' method='post' action='overridelock.php'>\n <div>\n <input type='hidden' name='sesskey' value='{$sesskey}' />\n <input type='hidden' name='id' value='{$id}' />\n <input type='hidden' name='page' value='{$pageesc}' />\n {$stroverrideinfo}\n <input type='submit' value='{$stroverridebutton}' />\n </div>\n</form>\n";
/** * Tries to obtain a lock of the page/section for the current user, * if suceeds adds the AJAX code to refresh it, if not returns false. * * @param Object $WS WikiStorage * @param string $sectionhash Hash of the section (if needed) * @return boolean */ function wiki_lock_message($WS, $sectionhash = '') { global $CFG; $id = optional_param('id', 0, PARAM_INT); $page = optional_param('page', 0, PARAM_CLEANHTML); $page = str_replace('^edit/', '', $page); $url = isset($WS->dfcourse) ? $CFG->wwwroot . "/mod/wiki/" : ""; $cmid = isset($WS->dfcourse) ? $WS->cm->id : 0; if ($sectionhash != '') { $pagename = $WS->page . '#' . $sectionhash; } else { $pagename = $WS->page; } $lockid = wiki_obtain_lock($WS, $WS->dfwiki->id, $pagename); if ($lockid) { // it's our lock, add the AJAX code to refresh it $strlockcancelled = get_string('lockcancelled', 'wiki'); $strnojslockwarning = get_string('nojslockwarning', 'wiki'); $intervalms = WIKI_LOCK_RECONFIRM * 1000; // start javascript print "\n<script type='text/javascript'>\nvar intervalID;\nfunction handleResponse(o) {\n if (o.responseText == 'cancel') {\n document.forms['ewiki'].elements['preview'].disabled = true;\n document.forms['ewiki'].elements['save'].disabled = true;\n clearInterval(intervalID);\n alert('{$strlockcancelled}');\n }\n}\nfunction handleFailure(o) {\n // Ignore for now\n}\nintervalID = setInterval(function() {\n YAHOO.util.Connect.asyncRequest('POST','" . $url . "confirmlock.php',\n {success:handleResponse, failure:handleFailure},'lockid={$lockid}');\n }, {$intervalms});\n</script>\n<noscript>\n <p>\n {$strnojslockwarning}\n </p>\n</noscript>\n"; // end javascript return true; } // from if ($lock) // if it's locked and is not our lock return false; }