Skip to content

Commit

Permalink
fixing all the form names as per new class naming convention (PHP cla…
Browse files Browse the repository at this point in the history
…ss names are also used for html id for styling)
  • Loading branch information
jamiesensei committed Dec 28, 2006
1 parent f07b962 commit 1d284fb
Show file tree
Hide file tree
Showing 23 changed files with 89 additions and 94 deletions.
20 changes: 10 additions & 10 deletions blog/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@
}

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':
Expand Down Expand Up @@ -152,8 +152,8 @@
print_header("$SITE->shortname: $strblogs", $SITE->fullname,
'<a href="'.$CFG->wwwroot.'/user/view.php?id='.$userid.'">'.fullname($user).'</a> ->
<a href="'.$CFG->wwwroot.'/blog/index.php?userid='.$userid.'">'.$strblogs.'</a> -> '.$strformheading,'','',true);
$blogpostform->set_defaults($post);
$blogpostform->display();
$blogeditform->set_defaults($post);
$blogeditform->display();


print_footer();
Expand All @@ -162,8 +162,8 @@
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
Expand All @@ -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) {
Expand Down
14 changes: 7 additions & 7 deletions course/import/activities/import_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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() {

Expand All @@ -14,11 +14,11 @@ function definition() {
$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));
Expand All @@ -31,21 +31,21 @@ function validation($data) {

}

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));
Expand Down
26 changes: 13 additions & 13 deletions course/import/activities/mod.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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){
Expand Down Expand Up @@ -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)) {
Expand Down
18 changes: 9 additions & 9 deletions course/import/groups/import_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,30 @@

require_once($CFG->libdir.'/formslib.php');

class group_import_form extends moodleform {
class course_import_groups_form extends moodleform {

function definition() {

global $CFG, $USER;
$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);

}
Expand Down
10 changes: 5 additions & 5 deletions course/import/groups/mod.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
$maxuploadsize = get_max_upload_file_size();
echo '<p align="center">';
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 '</p>';

?>
2 changes: 1 addition & 1 deletion course/modedit.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion course/request.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion enrol/authorize/enrol.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function print_entry($course) {
}
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) {
Expand Down
2 changes: 1 addition & 1 deletion enrol/authorize/enrol_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
17 changes: 6 additions & 11 deletions lib/formslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ function repeat_elements($elementobjs, $repeats, $options, $repeathiddenname, $a
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().
Expand All @@ -521,21 +521,16 @@ function repeat_elements($elementobjs, $repeats, $options, $repeathiddenname, $a
* @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 {
Expand Down Expand Up @@ -1134,7 +1129,7 @@ function _setDefaultRuleMessages(){
function getLockOptionEndScript(){
$js = '<script type="text/javascript" language="javascript">'."\n";
$js .= '//<![CDATA['."\n";
$js .= "var ".$this->getAttribute('id')."items= {";
$js .= "var ".$this->_formName."items= {";
foreach ($this->_dependencies as $dependentOn => $elements){
$js .= "'$dependentOn'".' : {dependents :[';
foreach ($elements as $element){
Expand Down
2 changes: 1 addition & 1 deletion login/change_password.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
error('Can not use this script when "Logged in as"!');
}

$mform = new change_password_form('change_password.php');
$mform = new login_change_password_form();
$mform->set_defaults(array('id'=>$course->id, 'username'=>$USER->username));

if ($mform->is_cancelled()) {
Expand Down
12 changes: 6 additions & 6 deletions login/forgot_password.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php
// $Id$
// forgot password routine.
// find the user and call the appropriate routine for their authentication
Expand Down Expand Up @@ -53,10 +53,10 @@
set_config('auth_'.$auth.'_changepasswordurl', $CFG->changepassword);
}
set_config('changepassword', '');
}
}


$mform = new forgot_password_form('forgot_password.php');
$mform = new login_forgot_password_form();

if ($mform->is_cancelled()) {
redirect($CFG->httpswwwroot.'/login/index.php');
Expand Down Expand Up @@ -106,7 +106,7 @@
$user = $mailuser;
}
}

// if user located (and no errors) take the appropriate action
if (empty($errors) and !empty($user)) {
// check this user isn't 'unconfirmed'
Expand All @@ -117,7 +117,7 @@
$authmethod = $user->auth;
if (is_internal_auth($authmethod) or !empty($CFG->{'auth_'.$authmethod.'_stdchangepassword'})) {
// handle internal authentication

// set 'secret' string
$user->secret = random_string(15);
if (!set_field('user', 'secret', $user->secret, 'id', $user->id)) {
Expand Down Expand Up @@ -203,7 +203,7 @@

reset_login_count();
$page = 'emailsent';

$changepasswordurl = "{$CFG->httpswwwroot}/login/change_password.php";
$a = new object();
$a->email = $user->email;
Expand Down
2 changes: 1 addition & 1 deletion login/signup.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
error("Sorry, you may not use this page.");
}

$mform_signup = new login_signup_form('signup.php');
$mform_signup = new login_signup_form_1();

if ($mform_signup->is_cancelled()) {
redirect($CFG->httpswwwroot.'/login/index.php');
Expand Down
2 changes: 1 addition & 1 deletion login/signup_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require_once($CFG->libdir.'/formslib.php');

class login_signup_form extends moodleform {
class login_signup_form_1 extends moodleform {
function definition() {
global $USER, $CFG;

Expand Down
2 changes: 1 addition & 1 deletion mod/assignment/type/online/assignment.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function view() {
}

/// prepare form and process submitted data
$mform = new assignment_online_edit_form('view.php');
$mform = new mod_assignment_online_edit_form();

$defaults = new object();
$defaults->id = $this->cm->id;
Expand Down
2 changes: 1 addition & 1 deletion mod/assignment/type/upload/assignment.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ function upload_notes() {

$returnurl = 'view.php?id='.$this->cm->id;

$mform = new assignment_upload_notes_form('upload.php');
$mform = new mod_assignment_upload_notes_form();

$defaults = new object();
$defaults->id = $this->cm->id;
Expand Down
Loading

0 comments on commit 1d284fb

Please sign in to comment.