Exemple #1
0
     // we are either returning to an existing page or a "new" one that ws
     // simultaneously created by someone else at the same time
     $returnpage = $addpage ? $frompage : $pagename;
     ouwiki_release_lock($pageversion->pageid);
     echo $OUTPUT->header();
     $pagefield = '';
     if ($returnpage !== '') {
         $pagefield = html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'page', 'value' => $returnpage));
     }
     print '<div id="ouwiki_savefail">' . '<h2>' . $savefailtitle . '</h2>' . '<p>' . $specificmessage . '</p>' . '<form action="view.php" method="get">' . '<input type="hidden" name="id" value="' . $cm->id . '" />' . $pagefield . '<input type="submit" value="' . $returntoview . '" />' . '</form>' . '<p>' . $savefailcontent . '</p>' . '<div class="ouwiki_savefailcontent">' . $actualcontent . '</div>' . '</div><div>';
     ouwiki_print_footer($course, $cm, $subwiki, $pagename);
     exit;
 }
 $event = null;
 if ($section) {
     ouwiki_save_new_version_section($course, $cm, $ouwiki, $subwiki, $pagename, $pageversion->xhtml, $formdata->content['text'], $sectiondetails, $formdata);
 } else {
     if ($addpage) {
         ouwiki_create_new_page($course, $cm, $ouwiki, $subwiki, $frompage, $pagename, $content, $formdata);
     } else {
         if ($addsection) {
             ouwiki_create_new_section($course, $cm, $ouwiki, $subwiki, $pagename, $formdata->content['text'], $sectionheader, $formdata);
         } else {
             // Normal save
             ouwiki_save_new_version($course, $cm, $ouwiki, $subwiki, $pagename, $content, -1, -1, -1, null, $formdata);
         }
     }
 }
 // Update completion state
 $completion = new completion_info($course);
 if ($completion->is_enabled($cm) && ($ouwiki->completionedits || $ouwiki->completionpages)) {
/**
 * Creates a new section on a page from scratch
 *
 * @param string $cm ID of course module
 * @param string $subwiki details if it exists
 * @param string $pagename of the original wiki page for which the new page is a link of
 * @param string $newcontent of desired new section
 * @param string $sectionheader for the new section
 */
function ouwiki_create_new_section($course, $cm, $ouwiki, $subwiki, $pagename, $newcontent, $sectionheader, $formdata)
{
    $sourcepage = ouwiki_get_current_page($subwiki, $pagename);
    $sectiondetails = ouwiki_get_new_section_details($sourcepage->xhtml, $sectionheader);
    ouwiki_save_new_version_section($course, $cm, $ouwiki, $subwiki, $pagename, $sourcepage->xhtml, $newcontent, $sectiondetails, $formdata);
}
    // If we either don't have a lock or are editing the wrong version...
    if (!$versionok || !$lockok) {
        ouwiki_release_lock($pageversion->pageid);
        ouwiki_print_start($ouwiki, $cm, $course, $subwiki, $pagename, $context);
        $savefailtitle = get_string('savefailtitle', 'ouwiki');
        $specificmessage = get_string(!$versionok ? 'savefaildesynch' : 'savefaillocked', 'ouwiki');
        $returntoview = get_string('returntoview', 'ouwiki');
        $savefailcontent = get_string('savefailcontent', 'ouwiki');
        $actualcontent = ouwiki_convert_content($content, $subwiki, $cm);
        print "\n<div id='ouwiki_savefail'>\n  <h2>{$savefailtitle}</h2>\n  <p>{$specificmessage}</p>\n  <form action='view.php' method='get'>\n    {$wikiformfields}\n    <input type='submit' value='{$returntoview}' />\n  </form>\n  <p>{$savefailcontent}</p>\n  <div class='ouwiki_savefailcontent'>\n    {$actualcontent}\n  </div>\n</div>";
        print_footer($course);
        exit;
    }
    $section = optional_param('section', null, PARAM_RAW);
    if ($section) {
        ouwiki_save_new_version_section($course, $cm, $ouwiki, $subwiki, $pagename, $pageversion->xhtml, $content, $sectiondetails);
    } else {
        if ($createnewpage) {
            ouwiki_create_new_page($course, $cm, $ouwiki, $subwiki, $originalpagename, $pagename, $content);
        } else {
            if ($addnewsection) {
                ouwiki_create_new_section($course, $cm, $ouwiki, $subwiki, $pagename, $content, $sectionheader);
            } else {
                // do normal save
                ouwiki_save_new_version($course, $cm, $ouwiki, $subwiki, $pagename, $content);
            }
            // endif
        }
        // endif
    }
}