mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-25002, fixed wiki preview
This commit is contained in:
parent
55c5882639
commit
980c237e6c
2 changed files with 24 additions and 7 deletions
|
@ -42,7 +42,6 @@ $contentformat = optional_param('contentformat', '', PARAM_ALPHA);
|
||||||
$option = optional_param('editoption', '', PARAM_TEXT);
|
$option = optional_param('editoption', '', PARAM_TEXT);
|
||||||
$section = optional_param('section', "", PARAM_TEXT);
|
$section = optional_param('section', "", PARAM_TEXT);
|
||||||
$version = optional_param('version', -1, PARAM_INT);
|
$version = optional_param('version', -1, PARAM_INT);
|
||||||
$newcontent = optional_param('newcontent', '', PARAM_CLEANHTML);
|
|
||||||
$attachments = optional_param('attachments', 0, PARAM_INT);
|
$attachments = optional_param('attachments', 0, PARAM_INT);
|
||||||
$deleteuploads = optional_param('deleteuploads', 0, PARAM_RAW);
|
$deleteuploads = optional_param('deleteuploads', 0, PARAM_RAW);
|
||||||
|
|
||||||
|
@ -90,7 +89,6 @@ if ($option == get_string('save', 'wiki')) {
|
||||||
}
|
}
|
||||||
$wikipage = new page_wiki_preview($wiki, $subwiki, $cm);
|
$wikipage = new page_wiki_preview($wiki, $subwiki, $cm);
|
||||||
$wikipage->set_page($page);
|
$wikipage->set_page($page);
|
||||||
$wikipage->set_newcontent($newcontent);
|
|
||||||
} else {
|
} else {
|
||||||
if ($option == get_string('cancel')) {
|
if ($option == get_string('cancel')) {
|
||||||
//delete lock
|
//delete lock
|
||||||
|
|
|
@ -963,6 +963,7 @@ class page_wiki_preview extends page_wiki_edit {
|
||||||
parent::__construct($wiki, $subwiki, $cm);
|
parent::__construct($wiki, $subwiki, $cm);
|
||||||
$buttons = $OUTPUT->update_module_button($cm->id, 'wiki');
|
$buttons = $OUTPUT->update_module_button($cm->id, 'wiki');
|
||||||
$PAGE->set_button($buttons);
|
$PAGE->set_button($buttons);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function print_header() {
|
function print_header() {
|
||||||
|
@ -1013,13 +1014,31 @@ class page_wiki_preview extends page_wiki_edit {
|
||||||
$format = $version->contentformat;
|
$format = $version->contentformat;
|
||||||
$content = $version->content;
|
$content = $version->content;
|
||||||
|
|
||||||
|
$url = $CFG->wwwroot . '/mod/wiki/edit.php?pageid=' . $this->page->id;
|
||||||
|
if (!empty($this->section)) {
|
||||||
|
$url .= "§ion=" . $this->section;
|
||||||
|
}
|
||||||
|
$params = array('attachmentoptions' => page_wiki_edit::$attachmentoptions, 'format' => $this->format, 'version' => $this->versionnumber);
|
||||||
|
|
||||||
|
if ($this->format != 'html') {
|
||||||
|
$params['contextid'] = $context->id;
|
||||||
|
$params['component'] = 'mod_wiki';
|
||||||
|
$params['filearea'] = 'attachments';
|
||||||
|
$params['fileitemid'] = $this->page->id;
|
||||||
|
}
|
||||||
|
$form = new mod_wiki_edit_form($url, $params);
|
||||||
|
|
||||||
|
|
||||||
$options = array('swid' => $this->page->subwikiid, 'pageid' => $this->page->id, 'pretty_print' => true);
|
$options = array('swid' => $this->page->subwikiid, 'pageid' => $this->page->id, 'pretty_print' => true);
|
||||||
|
|
||||||
$parseroutput = wiki_parse_content($format, $this->newcontent, $options);
|
if ($data = $form->get_data()) {
|
||||||
echo $OUTPUT->notification(get_string('previewwarning', 'wiki'), 'notifyproblem wiki_info');
|
$parseroutput = wiki_parse_content($data->contentformat, $data->newcontent_editor['text'], $options);
|
||||||
$content = format_text($parseroutput['parsed_text'], FORMAT_HTML);
|
$this->set_newcontent($data->newcontent_editor['text']);
|
||||||
echo $OUTPUT->box($content, 'generalbox wiki_previewbox');
|
echo $OUTPUT->notification(get_string('previewwarning', 'wiki'), 'notifyproblem wiki_info');
|
||||||
$content = $this->newcontent;
|
$content = format_text($parseroutput['parsed_text'], FORMAT_HTML);
|
||||||
|
echo $OUTPUT->box($content, 'generalbox wiki_previewbox');
|
||||||
|
$content = $this->newcontent;
|
||||||
|
}
|
||||||
|
|
||||||
$this->print_edit($content);
|
$this->print_edit($content);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue