protected function print_save() { global $CFG, $USER, $OUTPUT, $PAGE; $url = $CFG->wwwroot . '/mod/wiki/edit.php?pageid=' . $this->page->id; if (!empty($this->section)) { $url .= "§ion=" . urlencode($this->section); } $params = array( 'attachmentoptions' => page_wiki_edit::$attachmentoptions, 'format' => $this->format, 'version' => $this->versionnumber, 'contextid' => $this->modcontext->id ); if ($this->format != 'html') { $params['fileitemid'] = $this->page->id; $params['component'] = 'mod_wiki'; $params['filearea'] = 'attachments'; } $form = new mod_wiki_edit_form($url, $params); $save = false; $data = false; if ($data = $form->get_data()) { if ($this->format == 'html') { $data = file_postupdate_standard_editor($data, 'newcontent', page_wiki_edit::$attachmentoptions, $this->modcontext, 'mod_wiki', 'attachments', $this->subwiki->id); } if (isset($this->section)) { $save = wiki_save_section($this->page, $this->section, $data->newcontent, $USER->id); } else { $save = wiki_save_page($this->page, $data->newcontent, $USER->id); } } if ($save && $data) { if (!empty($CFG->usetags)) { tag_set('wiki_pages', $this->page->id, $data->tags); } $message = '<p>' . get_string('saving', 'wiki') . '</p>'; if (!empty($save['sections'])) { foreach ($save['sections'] as $s) { $message .= '<p>' . get_string('repeatedsection', 'wiki', $s) . '</p>'; } } if ($this->versionnumber + 1 != $save['version']) { $message .= '<p>' . get_string('wrongversionsave', 'wiki') . '</p>'; } if (isset($errors) && !empty($errors)) { foreach ($errors as $e) { $message .= "<p>" . get_string('filenotuploadederror', 'wiki', $e->get_filename()) . "</p>"; } } //deleting old locks wiki_delete_locks($this->page->id, $USER->id, $this->section); $url = new moodle_url('view.php', array('pageid' => $this->page->id, 'group' => $this->subwiki->groupid)); redirect($url); } else { print_error('savingerror', 'wiki'); } }