MDL-23395, go straight to page editing page when title is not empyt and forceformat is set

This commit is contained in:
Dongsheng Cai
2010-11-08 06:33:00 +00:00
parent ae671b6c67
commit 97f2eb45a1
4 changed files with 24 additions and 19 deletions
+3 -5
View File
@@ -94,15 +94,13 @@ case 'create':
$wikipage->create_page($title);
break;
case 'new':
if (!empty($title)) {
// create page from interlink with pagetitle
$wikipage->print_header();
$wikipage->print_content($title);
if ((int)$wiki->forceformat == 1 && !empty($title)) {
$wikipage->create_page($title);
} else {
// create link from moodle navigation block without pagetitle
$wikipage->print_header();
// new page without page title
$wikipage->print_content();
$wikipage->print_content($title);
}
$wikipage->print_footer();
break;
+13 -11
View File
@@ -44,19 +44,21 @@ class mod_wiki_create_form extends moodleform {
}
$mform->addElement('text', 'pagetitle', get_string('newpagetitle', 'wiki'), $textoptions);
$mform->addElement('static', 'format', get_string('format', 'wiki'));
$mform->addHelpButton('format', 'format', 'wiki');
foreach ($formats as $format) {
if ($format == $defaultformat) {
$attr = array('checked'=>'checked');
}else if (!empty($forceformat)){
if ($forceformat) {
$mform->addElement('hidden', 'pageformat', $defaultformat);
} else {
$mform->addElement('static', 'format', get_string('format', 'wiki'));
$mform->addHelpButton('format', 'format', 'wiki');
foreach ($formats as $format) {
if ($format == $defaultformat) {
$attr = array('checked'=>'checked');
}else if (!empty($forceformat)){
$attr = array('disabled'=>'disabled');
} else {
$attr = array();
} else {
$attr = array();
}
$mform->addElement('radio', 'pageformat', '', get_string('format'.$format, 'wiki'), $format, $attr);
}
$mform->addElement('radio', 'pageformat', '', get_string('format'.$format, 'wiki'), $format, $attr);
}
//hiddens
+2 -1
View File
@@ -45,7 +45,8 @@ $version = optional_param('version', -1, PARAM_INT);
$attachments = optional_param('attachments', 0, PARAM_INT);
$deleteuploads = optional_param('deleteuploads', 0, PARAM_RAW);
if (is_array($newcontent)) {
$newconent = '';
if (!empty($newcontent) && is_array($newcontent)) {
$newcontent = $newcontent['text'];
}
+6 -2
View File
@@ -942,14 +942,18 @@ class page_wiki_create extends page_wiki {
$this->mform->display();
}
function create_page() {
function create_page($pagetitle) {
global $USER, $CFG, $PAGE;
$data = $this->mform->get_data();
if (empty($this->subwiki)) {
$swid = wiki_add_subwiki($PAGE->activityrecord->id, $this->gid, $this->uid);
$this->subwiki = wiki_get_subwiki($swid);
}
$id = wiki_create_page($this->subwiki->id, $data->pagetitle, $data->pageformat, $USER->id);
if ($data) {
$id = wiki_create_page($this->subwiki->id, $data->pagetitle, $data->pageformat, $USER->id);
} else {
$id = wiki_create_page($this->subwiki->id, $pagetitle, $PAGE->activityrecord->defaultformat, $USER->id);
}
redirect($CFG->wwwroot . '/mod/wiki/edit.php?pageid=' . $id);
}
}