}
         $pageversion->xhtml = substr_replace($pageversion->xhtml, $replace, $position, 0);
         $neednewversion = true;
         $spanlength = strlen($replace);
         $prevkey = $key;
     }
 }
 // if we have got this far then commit the transaction, remove any unwanted spans
 // and save a new wiki version if required
 $neednewversion = ouwiki_cleanup_annotation_tags($updated, $pageversion->xhtml) ? true : $neednewversion;
 // Note: Because we didn't get data values from the form, they have not been
 // sanity-checked so we don't know if the field actually existed or not.
 // That means we need to do another lock capability check here in addition
 // to the one done when displaying the form.
 if (has_capability('mod/ouwiki:lock', $context)) {
     ouwiki_lock_editing($pageversion->pageid, $lockunlock);
 }
 if ($neednewversion) {
     if (strpos($pageversion->xhtml, '"view.php') !== false) {
         // Tidy up and revert converted content (links) back to original format.
         $pattern = '(<a\\b[^>]*?href="view\\.php[^>]*?>(.*?)<\\/a>)';
         $pageversion->xhtml = preg_replace($pattern, "[[\$1]]", $pageversion->xhtml);
     }
     if ($contenttag = strpos($pageversion->xhtml, '<div class="ouwiki_content">') !== false) {
         // Strip out content tag.
         $pageversion->xhtml = substr_replace($pageversion->xhtml, '', $contenttag, 28);
         $endtag = strrpos($pageversion->xhtml, '</div>');
         if ($endtag !== false) {
             $pageversion->xhtml = substr_replace($pageversion->xhtml, '', $endtag, 6);
         }
     }
Exemple #2
0
    $overridelock = get_string('overridelock', 'ouwiki');
    $overridebutton = $canoverride ? "\n<form class='ouwiki_overridelock' action='override.php' method='post'>\n  <input type='hidden' name='redirpage' value='view'>\n  {$wikiformfields}\n  <input type='submit' value='{$overridelock}' />\n</form>\n" : '';
    $cancel = get_string('cancel');
    $tryagain = get_string('tryagain', 'ouwiki');
    print "\n<div id='ouwiki_lockinfo'>\n  <h2>{$pagelockedtitle}</h2>\n  <p>{$pagelockeddetails} {$pagelockedtimeout}</p>\n  {$pagelockedoverride}\n  <div class='ouwiki_lockinfobuttons'>\n    <form action='edit.php' method='get'>\n      {$wikiformfields}\n      {$sectionfields}\n      <input type='submit' value='{$tryagain}' />\n    </form>\n    <form action='view.php' method='get'>\n      {$wikiformfields}\n      <input type='submit' value='{$cancel}' />\n    </form>\n    {$overridebutton}\n  </div>\n</div>";
    print_footer($course);
    exit;
}
// The page is now locked to us!
// To have got this far everything checks out so lock or unlock the page as requested
if ($action == get_string('lockpage', 'ouwiki')) {
    ouwiki_lock_editing($pageid, true);
    $eventtype = 'lock';
} else {
    if ($action == get_string('unlockpage', 'ouwiki')) {
        ouwiki_lock_editing($pageid, false);
        $eventtype = 'unlock';
    }
}
// all done - release the editing lock...
ouwiki_release_lock($pageversion->pageid);
// add to moodle log...
$url = 'view.php';
$url .= (strpos($url, '?') === false ? '?' : '&') . 'id=' . $cm->id;
if ($subwiki->groupid) {
    $url .= '&group=' . $subwiki->groupid;
}
if ($subwiki->userid) {
    $url .= '&user='******'';