MDL-25002, fixed wiki preview

This commit is contained in:
Dongsheng Cai 2010-11-02 05:19:37 +00:00
parent 55c5882639
commit 980c237e6c
2 changed files with 24 additions and 7 deletions

View file

@ -42,7 +42,6 @@ $contentformat = optional_param('contentformat', '', PARAM_ALPHA);
$option = optional_param('editoption', '', PARAM_TEXT);
$section = optional_param('section', "", PARAM_TEXT);
$version = optional_param('version', -1, PARAM_INT);
$newcontent = optional_param('newcontent', '', PARAM_CLEANHTML);
$attachments = optional_param('attachments', 0, PARAM_INT);
$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->set_page($page);
$wikipage->set_newcontent($newcontent);
} else {
if ($option == get_string('cancel')) {
//delete lock

View file

@ -963,6 +963,7 @@ class page_wiki_preview extends page_wiki_edit {
parent::__construct($wiki, $subwiki, $cm);
$buttons = $OUTPUT->update_module_button($cm->id, 'wiki');
$PAGE->set_button($buttons);
}
function print_header() {
@ -1013,13 +1014,31 @@ class page_wiki_preview extends page_wiki_edit {
$format = $version->contentformat;
$content = $version->content;
$url = $CFG->wwwroot . '/mod/wiki/edit.php?pageid=' . $this->page->id;
if (!empty($this->section)) {
$url .= "&section=" . $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);
$parseroutput = wiki_parse_content($format, $this->newcontent, $options);
echo $OUTPUT->notification(get_string('previewwarning', 'wiki'), 'notifyproblem wiki_info');
$content = format_text($parseroutput['parsed_text'], FORMAT_HTML);
echo $OUTPUT->box($content, 'generalbox wiki_previewbox');
$content = $this->newcontent;
if ($data = $form->get_data()) {
$parseroutput = wiki_parse_content($data->contentformat, $data->newcontent_editor['text'], $options);
$this->set_newcontent($data->newcontent_editor['text']);
echo $OUTPUT->notification(get_string('previewwarning', 'wiki'), 'notifyproblem wiki_info');
$content = format_text($parseroutput['parsed_text'], FORMAT_HTML);
echo $OUTPUT->box($content, 'generalbox wiki_previewbox');
$content = $this->newcontent;
}
$this->print_edit($content);
}