diff --git a/blog/edit.php b/blog/edit.php index d5343add1bf..a87591f942a 100755 --- a/blog/edit.php +++ b/blog/edit.php @@ -69,15 +69,15 @@ if ($action=='delete'){ } require_once('edit_form.php'); -$blogpostform = new blog_post_form(null, compact('existing', 'sitecontext')); +$blogeditform = new blog_edit_form(null, compact('existing', 'sitecontext')); -if ($blogpostform->is_cancelled()){ +if ($blogeditform->is_cancelled()){ redirect($returnurl); -} elseif ($blogpostform->no_submit_button_pressed()) { - no_submit_button_actions($blogpostform, $sitecontext); +} elseif ($blogeditform->no_submit_button_pressed()) { + no_submit_button_actions($blogeditform, $sitecontext); -} elseif ($fromform = $blogpostform->data_submitted()){ +} elseif ($fromform = $blogeditform->data_submitted()){ //save stuff in db switch ($action) { case 'add': @@ -152,8 +152,8 @@ if (!$user = get_record('user', 'id', $userid)) { print_header("$SITE->shortname: $strblogs", $SITE->fullname, ''.fullname($user).' -> '.$strblogs.' -> '.$strformheading,'','',true); -$blogpostform->set_defaults($post); -$blogpostform->display(); +$blogeditform->set_defaults($post); +$blogeditform->display(); print_footer(); @@ -162,8 +162,8 @@ print_footer(); die; /***************************** edit.php functions ***************************/ -function no_submit_button_actions(&$blogpostform, $sitecontext){ - $mform =& $blogpostform->_form; +function no_submit_button_actions(&$blogeditform, $sitecontext){ + $mform =& $blogeditform->_form; $data = $mform->exportValues(); //sesskey has been checked already no need to check that //check for official tags to add @@ -176,7 +176,7 @@ function no_submit_button_actions(&$blogpostform, $sitecontext){ if (!empty($data['deleteotags']) && !empty($data['otags'])){ // adding official tag delete_otags($data['otags'], $sitecontext); } - $blogpostform->otags_select_setup(); + $blogeditform->otags_select_setup(); } function delete_otags($tagids, $sitecontext){ foreach ($tagids as $tagid) { diff --git a/course/import/activities/import_form.php b/course/import/activities/import_form.php index 11eca537882..4a684b9c183 100755 --- a/course/import/activities/import_form.php +++ b/course/import/activities/import_form.php @@ -2,7 +2,7 @@ require_once($CFG->libdir.'/formslib.php'); -class activities_import_form_1 extends moodleform { +class course_import_activities_form_1 extends moodleform { function definition() { @@ -14,11 +14,11 @@ class activities_import_form_1 extends moodleform { $mform->addElement('header', 'general', '');//fill in the data depending on page params //later using set_defaults $mform->addElement('select', 'fromcourse', $text, $options); - + // buttons $submit_string = get_string('usethiscourse'); $this->add_action_buttons(false, true, $submit_string); - + $mform->addElement('hidden', 'id'); $mform->setType('id', PARAM_INT); $mform->setConstants(array('id'=> $courseid)); @@ -31,21 +31,21 @@ class activities_import_form_1 extends moodleform { } -class activities_import_form_2 extends moodleform { +class course_import_activities_form_2 extends moodleform { function definition() { global $CFG; $mform =& $this->_form; - $courseid = $this->_customdata['courseid']; + $courseid = $this->_customdata['courseid']; $mform->addElement('header', 'general', '');//fill in the data depending on page params //later using set_defaults $mform->addElement('text', 'fromcoursesearch', get_string('searchcourses')); - + // buttons $this->add_action_buttons(false, true, get_string('searchcourses')); - + $mform->addElement('hidden', 'id'); $mform->setType('id', PARAM_INT); $mform->setConstants(array('id'=> $courseid)); diff --git a/course/import/activities/mod.php b/course/import/activities/mod.php index 69eeb7d11b6..1f587c3289f 100644 --- a/course/import/activities/mod.php +++ b/course/import/activities/mod.php @@ -6,7 +6,7 @@ require_once($CFG->dirroot.'/course/lib.php'); require_once($CFG->dirroot.'/backup/restorelib.php'); - + $syscontext = get_context_instance(CONTEXT_SYSTEM, SITEID); // if we're not a course creator , we can only import from our own courses. @@ -15,9 +15,9 @@ } $strimport = get_string("importdata"); - + $tcourseids = ''; - + if ($teachers = get_user_capability_course('moodle/course:update')) { foreach ($teachers as $teacher) { if ($teacher->id != $course->id && $teacher->id != SITEID){ @@ -51,31 +51,31 @@ notify(get_string('courseimportnotaught')); return; // yay , this will pass control back to the file that included or required us. } - + // quick forms include_once('import_form.php'); - - $mform_post = new activities_import_form_1($CFG->wwwroot.'/course/import/activities/index.php', array('options'=>$options, 'courseid' => $course->id, 'text'=> get_string('coursestaught'))); + + $mform_post = new course_import_activities_form_1($CFG->wwwroot.'/course/import/activities/index.php', array('options'=>$options, 'courseid' => $course->id, 'text'=> get_string('coursestaught'))); $mform_post ->display(); - - unset($options); + + unset($options); $options = array(); - + foreach ($cat_courses as $ccourse) { if ($ccourse->id != $course->id && $ccourse->id != SITEID) { $options[$ccourse->id] = $ccourse->fullname; } } $cat = get_record("course_categories","id",$course->category); - + if (count($options) > 0) { - $mform_post = new activities_import_form_1($CFG->wwwroot.'/course/import/activities/index.php', array('options'=>$options, 'courseid' => $course->id, 'text' => get_string('coursescategory'))); + $mform_post = new course_import_activities_form_1($CFG->wwwroot.'/course/import/activities/index.php', array('options'=>$options, 'courseid' => $course->id, 'text' => get_string('coursescategory'))); $mform_post ->display(); } if (!empty($creator)) { - $mform_post = new activities_import_form_2($CFG->wwwroot.'/course/import/activities/index.php', array('courseid' => $course->id)); - $mform_post ->display(); + $mform_post = new course_import_activities_form_2($CFG->wwwroot.'/course/import/activities/index.php', array('courseid' => $course->id)); + $mform_post ->display(); } if (!empty($fromcoursesearch) && !empty($creator)) { diff --git a/course/import/groups/import_form.php b/course/import/groups/import_form.php index 9c607032ded..02451f41c63 100755 --- a/course/import/groups/import_form.php +++ b/course/import/groups/import_form.php @@ -2,7 +2,7 @@ require_once($CFG->libdir.'/formslib.php'); -class group_import_form extends moodleform { +class course_import_groups_form extends moodleform { function definition() { @@ -10,22 +10,22 @@ class group_import_form extends moodleform { $mform =& $this->_form; $maxuploadsize = $this->_customdata['maxuploadsize']; $strimportgroups = get_string("importgroups"); - + $this->_upload_manager = new upload_manager('userfile', true, false, '', false, $maxuploadsize, true, true); $this->set_max_file_size('', $maxuploadsize); - + $mform->addElement('header', 'general', '');//fill in the data depending on page params - //later using set_defaults + //later using set_defaults // buttons - + $mform->addElement('hidden', 'sesskey'); $mform->setType('sesskey', PARAM_ALPHA); $mform->setConstants(array('sesskey'=> $USER->sesskey)); - + $mform->addElement('file', 'userfile', ''); - $mform->setHelpButton('userfile', array('attachment', get_string('attachment', 'forum'), 'forum')); - - + $mform->setHelpButton('userfile', array('attachment', get_string('attachment', 'forum'), 'forum')); + + $this->add_action_buttons(false, true, $strimportgroups); } diff --git a/course/import/groups/mod.php b/course/import/groups/mod.php index ee960641ad1..141a639a9b9 100644 --- a/course/import/groups/mod.php +++ b/course/import/groups/mod.php @@ -15,14 +15,14 @@ $maxuploadsize = get_max_upload_file_size(); echo '

'; print_simple_box_start('center','80%'); - + // use formslib include_once('import_form.php'); - $mform_post = new group_import_form($CFG->wwwroot.'/course/import/groups/index.php?id='.$id, array('maxuploadsize'=>$maxuploadsize)); + $mform_post = new course_import_groups_form($CFG->wwwroot.'/course/import/groups/index.php?id='.$id, array('maxuploadsize'=>$maxuploadsize)); $mform_post ->display(); - + print_simple_box_end(); - + echo '

'; - + ?> diff --git a/course/modedit.php b/course/modedit.php index b4e7334f27b..c1955f0537b 100644 --- a/course/modedit.php +++ b/course/modedit.php @@ -122,7 +122,7 @@ error("This module is missing important code! ($modlib)"); } - $mformclassname=$module->name.'_mod_form'; + $mformclassname = 'mod_'.$module->name.'_mod_form'; $cousesection=isset($cw->section)?$cw->section:$section; $mform=& new $mformclassname($form->instance, $cousesection, ((isset($cm))?$cm:null)); $mform->set_defaults($form); diff --git a/course/request.php b/course/request.php index 02589c295dc..79a4b21c24c 100644 --- a/course/request.php +++ b/course/request.php @@ -15,7 +15,7 @@ error(get_string('courserequestdisabled')); } - $requestform = new course_request_form('request.php'); + $requestform = new course_request_form(); $strtitle = get_string('courserequest'); print_header($strtitle, $strtitle, $strtitle, $requestform->focus()); diff --git a/enrol/authorize/enrol.php b/enrol/authorize/enrol.php index a5a60c9b4ad..6cda2556397 100755 --- a/enrol/authorize/enrol.php +++ b/enrol/authorize/enrol.php @@ -74,7 +74,7 @@ class enrolment_plugin_authorize } else { require_once($CFG->dirroot.'/enrol/authorize/enrol_form.php'); - $frmenrol = new authorize_enrol_form('enrol.php'); + $frmenrol = new enrol_authorize_form(); if ($frmenrol->data_submitted()) { $authorizeerror = ''; switch ($form->paymentmethod) { diff --git a/enrol/authorize/enrol_form.php b/enrol/authorize/enrol_form.php index 9edc15dff88..3b3c9cc126d 100755 --- a/enrol/authorize/enrol_form.php +++ b/enrol/authorize/enrol_form.php @@ -2,7 +2,7 @@ require_once($CFG->libdir.'/formslib.php'); -class enrol_authorize_enrol_form extends moodleform +class enrol_authorize_form extends moodleform { function definition() { diff --git a/lib/formslib.php b/lib/formslib.php index 68246a3b536..d4be25ca641 100644 --- a/lib/formslib.php +++ b/lib/formslib.php @@ -512,7 +512,7 @@ class moodleform { return $repeats; } /** - * Use this method to add the standard buttons to the end of your form. Pass a param of false + * Use this method to a cancel and submit button to the end of your form. Pass a param of false * if you don't want a cancel button in your form. If you have a cancel button make sure you * check for it being pressed using is_cancelled() and redirecting if it is true before trying to * get data with data_submitted(). @@ -521,21 +521,16 @@ class moodleform { * @param boolean $revert whether to show revert button, default true * @param string $submitlabel label for submit button, defaults to get_string('savechanges') */ - function add_action_buttons($cancel = true, $revert = true, $submitlabel=null){ + function add_action_buttons($cancel = true, $submitlabel=null){ if (is_null($submitlabel)){ $submitlabel = get_string('savechanges'); } $mform =& $this->_form; - if ($revert || $cancel){ - //when two or more elements we need a group + if ($cancel){ + //when two elements we need a group $buttonarray=array(); $buttonarray[] = &$mform->createElement('submit', 'submitbutton', $submitlabel); - if ($revert){ - $buttonarray[] = &$mform->createElement('reset', 'resetbutton', get_string('revert')); - } - if ($cancel){ - $buttonarray[] = &$mform->createElement('cancel'); - } + $buttonarray[] = &$mform->createElement('cancel'); $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false); $mform->closeHeaderBefore('buttonar'); } else { @@ -1134,7 +1129,7 @@ function validate_' . $this->_formName . '(frm) { function getLockOptionEndScript(){ $js = '