2006-11-12 07:28:13 +00:00
< ? php // $Id$
2006-09-24 17:04:51 +00:00
/**
* formslib . php - library of classes for creating forms in Moodle , based on PEAR QuickForms .
2006-11-12 07:28:13 +00:00
*
* To use formslib then you will want to create a new file purpose_form . php eg . edit_form . php
* and you want to name your class something like { modulename } _ { purpose } _form . Your class will
* extend moodleform overriding abstract classes definition and optionally defintion_after_data
* and validation .
*
* See examples of use of this library in course / edit . php and course / edit_form . php
*
* A few notes :
* form defintion is used for both printing of form and processing and should be the same
* for both or you may lose some submitted data which won ' t be let through .
* you should be using setType for every form element except select , radio or checkbox
* elements , these elements clean themselves .
*
*
2006-09-24 17:04:51 +00:00
* @ author Jamie Pratt
* @ version $Id $
* @ license http :// www . gnu . org / copyleft / gpl . html GNU Public License
*/
//point pear include path to moodles lib/pear so that includes and requires will search there for files before anywhere else.
if ( FALSE === strstr ( ini_get ( 'include_path' ), $CFG -> libdir . '/pear' )){
ini_set ( 'include_path' , $CFG -> libdir . '/pear' . PATH_SEPARATOR . ini_get ( 'include_path' ));
}
require_once 'HTML/QuickForm.php' ;
require_once 'HTML/QuickForm/DHTMLRulesTableless.php' ;
require_once 'HTML/QuickForm/Renderer/Tableless.php' ;
2006-11-09 08:38:40 +00:00
require_once $CFG -> libdir . '/uploadlib.php' ;
2006-09-25 11:08:44 +00:00
if ( $CFG -> debug >= DEBUG_ALL ){
PEAR :: setErrorHandling ( PEAR_ERROR_PRINT );
}
2006-11-09 10:42:44 +00:00
/**
2006-11-12 07:28:13 +00:00
* Moodle specific wrapper that separates quickforms syntax from moodle code . You won ' t directly
* use this class you should write a class defintion which extends this class or a more specific
* subclass such a moodleform_mod for each form you want to display and / or process with formslib .
*
* You will write your own definition () method which performs the form set up .
2006-11-09 10:42:44 +00:00
*/
2006-10-12 07:33:57 +00:00
class moodleform {
2006-11-09 08:38:40 +00:00
var $_formname ; // form name
2006-11-15 07:40:49 +00:00
/**
* quickform object definition
*
* @ var MoodleQuickForm
*/
var $_form ;
/**
* globals workaround
*
* @ var array
*/
var $_customdata ;
/**
* file upload manager
*
* @ var upload_manager
*/
var $_upload_manager ; //
2006-10-12 07:33:57 +00:00
2006-11-24 12:20:26 +00:00
/**
* Array of buttons that if pressed do not result in the processing of the form .
*
* @ var array
*/
var $_nosubmitbuttons = array ();
2006-11-12 07:28:13 +00:00
/**
* The constructor function calls the abstract function definition () and it will then
* process and clean and attempt to validate incoming data .
*
* It will call your custom validate method to validate data and will also check any rules
* you have specified in definition using addRule
*
* The name of the form ( id attribute of the form ) is automatically generated depending on
* the name you gave the class extending moodleform . You should call your class something
* like
*
* @ param string $action the action attribute for the form .
* @ param array $customdata if your form defintion method needs access to data such as $course
* $cm , etc . to construct the form definition then pass it in this array . You can
* use globals for somethings .
* @ param string $method if you set this to anything other than 'post' then _GET and _POST will
* be merged and used as incoming data to the form .
* @ param string $target target frame for form submission . You will rarely use this . Don ' t use
* it if you don ' t need to as the target attribute is deprecated in xhtml
* strict .
* @ param mixed $attributes you can pass a string of html attributes here or an array .
* @ return moodleform
*/
2006-10-12 07:33:57 +00:00
function moodleform ( $action , $customdata = null , $method = 'post' , $target = '' , $attributes = null ) {
2006-10-14 12:32:31 +00:00
$this -> _formname = rtrim ( get_class ( $this ), '_form' );
2006-10-12 07:33:57 +00:00
$this -> _customdata = $customdata ;
2006-10-14 12:32:31 +00:00
$this -> _form =& new MoodleQuickForm ( $this -> _formname , $method , $action , $target , $attributes );
2006-10-12 07:33:57 +00:00
$this -> definition ();
$this -> _form -> addElement ( 'hidden' , 'sesskey' , null ); // automatic sesskey protection
$this -> _form -> setDefault ( 'sesskey' , sesskey ());
2006-10-14 12:32:31 +00:00
$this -> _form -> addElement ( 'hidden' , '_qf__' . $this -> _formname , null ); // form submission marker
$this -> _form -> setDefault ( '_qf__' . $this -> _formname , 1 );
$this -> _form -> _setDefaultRuleMessages ();
2006-10-12 07:33:57 +00:00
// we have to know all input types before processing submission ;-)
$this -> _process_submission ( $method );
2006-11-09 10:42:44 +00:00
// update form definition based on final data
$this -> definition_after_data ();
2006-10-12 07:33:57 +00:00
}
2006-11-09 10:42:44 +00:00
2006-10-24 11:05:50 +00:00
/**
2006-11-12 07:28:13 +00:00
* To autofocus on first form element or first element with error .
2006-10-24 11:05:50 +00:00
*
* @ return string javascript to select form element with first error or
2006-11-12 07:28:13 +00:00
* first element if no errors . Use this as a parameter
* when calling print_header
2006-10-24 11:05:50 +00:00
*/
function focus (){
2006-11-22 15:58:07 +00:00
$form =& $this -> _form ;
2006-10-30 06:27:15 +00:00
$elkeys = array_keys ( $form -> _elementIndex );
2006-11-22 15:58:07 +00:00
if ( isset ( $form -> _errors ) && 0 != count ( $form -> _errors )){
$errorkeys = array_keys ( $form -> _errors );
$elkeys = array_intersect ( $elkeys , $errorkeys );
2006-10-24 11:05:50 +00:00
}
2006-11-22 15:58:07 +00:00
$names = null ;
while ( ! $names ){
$el = array_shift ( $elkeys );
$names = $form -> _getElNamesRecursive ( $el );
}
$name = array_shift ( $names );
$focus = 'forms[\'' . $this -> _form -> getAttribute ( 'id' ) . '\'].elements[\'' . $name . '\']' ;
return $focus ;
}
2006-10-12 07:33:57 +00:00
2006-11-09 10:42:44 +00:00
/**
* Internal method . Alters submitted data to be suitable for quickforms processing .
* Must be called when the form is fully set up .
*/
2006-10-12 07:33:57 +00:00
function _process_submission ( $method ) {
$submission = array ();
if ( $method == 'post' ) {
if ( ! empty ( $_POST )) {
$submission = $_POST ;
}
} else {
$submission = array_merge_recursive ( $_GET , $_POST ); // emulate handling of parameters in xxxx_param()
}
// following trick is needed to enable proper sesskey checks when using GET forms
2006-10-14 12:32:31 +00:00
// the _qf__.$this->_formname serves as a marker that form was actually submitted
if ( array_key_exists ( '_qf__' . $this -> _formname , $submission ) and $submission [ '_qf__' . $this -> _formname ] == 1 ) {
2006-10-12 07:33:57 +00:00
if ( ! confirm_sesskey ()) {
error ( 'Incorrect sesskey submitted, form not accepted!' );
}
2006-11-09 10:42:44 +00:00
$files = $_FILES ;
2006-10-12 07:33:57 +00:00
} else {
$submission = array ();
2006-11-09 10:42:44 +00:00
$files = array ();
2006-10-12 07:33:57 +00:00
}
2006-11-09 10:42:44 +00:00
$this -> _form -> updateSubmission ( $submission , $files );
2006-10-12 07:33:57 +00:00
}
2006-11-09 10:42:44 +00:00
/**
* Internal method . Validates all uploaded files .
*/
2006-11-09 08:38:40 +00:00
function _validate_files () {
if ( empty ( $_FILES )) {
// we do not need to do any checks because no files were submitted
// TODO: find out why server side required rule does not work for uploaded files;
// testing is easily done by always returning true from this function and adding
// $mform->addRule('soubor', get_string('required'), 'required', null, 'server');
// and submitting form without selected file
return true ;
}
$errors = array ();
$mform =& $this -> _form ;
// create default upload manager if not already created
if ( empty ( $this -> _upload_manager )) {
$this -> _upload_manager = new upload_manager ();
}
// check the files
$status = $this -> _upload_manager -> preprocess_files ();
// now check that we really want each file
foreach ( $_FILES as $elname => $file ) {
if ( $mform -> elementExists ( $elname ) and $mform -> getElementType ( $elname ) == 'file' ) {
$required = $mform -> isElementRequired ( $elname );
if ( ! empty ( $this -> _upload_manager -> files [ $elname ][ 'uploadlog' ]) and empty ( $this -> _upload_manager -> files [ $elname ][ 'clear' ])) {
if ( ! $required and $file [ 'error' ] == UPLOAD_ERR_NO_FILE ) {
// file not uploaded and not required - ignore it
continue ;
}
$errors [ $elname ] = $this -> _upload_manager -> files [ $elname ][ 'uploadlog' ];
}
} else {
error ( 'Incorrect upload attemp!' );
}
}
// return errors if found
if ( $status and 0 == count ( $errors )){
return true ;
} else {
return $errors ;
}
}
2006-11-09 10:42:44 +00:00
/**
2006-11-12 07:28:13 +00:00
* Load in existing data as form defaults . Usually new entry defaults are stored directly in
* form definition ( new entry form ); this function is used to load in data where values
* already exist and data is being edited ( edit entry form ) .
2006-11-09 10:42:44 +00:00
*
* @ param mixed $default_values object or array of default values
* @ param bool $slased true if magic quotes applied to data values
*/
2006-10-12 07:33:57 +00:00
function set_defaults ( $default_values , $slashed = false ) {
if ( is_object ( $default_values )) {
$default_values = ( array ) $default_values ;
}
$filter = $slashed ? 'stripslashes' : NULL ;
$this -> _form -> setDefaults ( $default_values , $filter );
2006-11-09 10:43:26 +00:00
//update form definition when data changed
2006-11-09 10:42:44 +00:00
$this -> definition_after_data ();
2006-10-12 07:33:57 +00:00
}
2006-11-23 08:24:58 +00:00
/**
* Set maximum allowed uploaded file size .
* Must be used BEFORE creating of file element !
*
* @ param object $course
2006-11-24 12:20:26 +00:00
* @ param object $modbytes - max size limit defined in module
2006-11-23 08:24:58 +00:00
*/
function set_max_file_size ( $course = null , $modbytes = 0 ) {
global $CFG , $COURSE ;
if ( empty ( $course -> id )) {
$course = $COURSE ;
}
$maxbytes = get_max_upload_file_size ( $CFG -> maxbytes , $course -> maxbytes , $modbytes );
$this -> _form -> setMaxFileSize ( $maxbytes );
}
2006-11-09 10:42:44 +00:00
/**
* Check that form was submitted . Does not check validity of submitted data .
*
* @ return bool true if form properly submitted
*/
2006-10-12 07:33:57 +00:00
function is_submitted () {
return $this -> _form -> isSubmitted ();
}
2006-11-09 10:42:44 +00:00
/**
* Check that form data is valid .
*
* @ return bool true if form data valid
*/
2006-10-12 07:33:57 +00:00
function is_validated () {
2006-11-09 08:38:40 +00:00
static $validated = null ; // one validation is enough
2006-10-12 07:33:57 +00:00
if ( $validated === null ) {
$internal_val = $this -> _form -> validate ();
2006-10-12 09:53:32 +00:00
$moodle_val = $this -> validation ( $this -> _form -> exportValues ( null , true ));
2006-10-12 07:33:57 +00:00
if ( $moodle_val !== true ) {
if ( ! empty ( $moodle_val )) {
foreach ( $moodle_val as $element => $msg ) {
$this -> _form -> setElementError ( $element , $msg );
}
}
$moodle_val = false ;
}
2006-11-09 08:38:40 +00:00
$file_val = $this -> _validate_files ();
if ( $file_val !== true ) {
if ( ! empty ( $file_val )) {
foreach ( $file_val as $element => $msg ) {
$this -> _form -> setElementError ( $element , $msg );
}
}
$file_val = false ;
}
$validated = ( $internal_val and $moodle_val and $file_val );
2006-10-12 07:33:57 +00:00
}
return $validated ;
}
2006-11-09 10:42:44 +00:00
/**
2006-11-12 07:28:13 +00:00
* Return submitted data if properly submitted or returns NULL if validation fails or
* if there is no submitted data .
2006-11-09 10:42:44 +00:00
*
* @ param bool $slashed true means return data with addslashes applied
* @ return object submitted data ; NULL if not valid or not submitted
*/
2006-10-12 07:33:57 +00:00
function data_submitted ( $slashed = true ) {
2006-11-24 12:20:26 +00:00
foreach ( $this -> _nosubmitbuttons as $nosubmitbutton ){
if ( optional_param ( $nosubmitbutton , 0 , PARAM_TEXT )){
return NULL ;
}
}
2006-10-12 07:33:57 +00:00
if ( $this -> is_submitted () and $this -> is_validated ()) {
$data = $this -> _form -> exportValues ( null , $slashed );
2006-10-14 12:32:31 +00:00
unset ( $data [ 'sesskey' ]); // we do not need to return sesskey
unset ( $data [ '_qf__' . $this -> _formname ]); // we do not need the submission marker too
2006-10-12 07:33:57 +00:00
if ( empty ( $data )) {
return NULL ;
} else {
return ( object ) $data ;
}
} else {
return NULL ;
}
}
2006-11-09 10:42:44 +00:00
/**
* Save verified uploaded files into directory . Upload process can be customised from definition ()
2006-11-09 10:43:26 +00:00
* method by creating instance of upload manager and storing it in $this -> _upload_form
2006-11-09 10:42:44 +00:00
*
* @ param string $destination where to store uploaded files
* @ return bool success
*/
2006-11-09 08:38:40 +00:00
function save_files ( $destination ) {
if ( empty ( $this -> _upload_manager )) {
return false ;
}
if ( $this -> is_submitted () and $this -> is_validated ()) {
return $this -> _upload_manager -> save_files ( $destination );
}
return false ;
}
2006-11-07 08:48:18 +00:00
2006-11-09 10:42:44 +00:00
/**
* Print html form .
*/
2006-10-12 07:33:57 +00:00
function display () {
$this -> _form -> display ();
}
2006-11-09 08:38:40 +00:00
/**
2006-11-09 10:42:44 +00:00
* Abstract method - always override !
2006-11-09 08:38:40 +00:00
*
* If you need special handling of uploaded files , create instance of $this -> _upload_manager here .
*/
2006-10-12 07:33:57 +00:00
function definition () {
error ( 'Abstract form_definition() method in class ' . get_class ( $this ) . ' must be overriden, please fix the code.' );
}
2006-10-24 11:05:50 +00:00
2006-10-16 12:07:44 +00:00
/**
2006-11-09 10:42:44 +00:00
* Dummy stub method - override if you need to setup the form depending on current
* values . This method is called after definition (), data submission and set_defaults () .
* All form setup that is dependent on form values should go in here .
2006-10-16 12:07:44 +00:00
*/
function definition_after_data (){
}
2006-10-12 07:33:57 +00:00
2006-11-09 10:42:44 +00:00
/**
* Dummy stub method - override if you needed to perform some extra validation .
* If there are errors return array of errors ( " fieldname " => " error message " ),
* otherwise true if ok .
2006-11-09 10:43:26 +00:00
*
2006-11-09 10:42:44 +00:00
* @ param array $data array of ( " fieldname " => value ) of submitted data
2006-11-09 10:43:26 +00:00
* @ return bool array of errors or true if ok
2006-11-09 10:42:44 +00:00
*/
2006-10-12 07:33:57 +00:00
function validation ( $data ) {
return true ;
}
2006-11-24 12:20:26 +00:00
function _register_no_submit_button ( $addfieldsname ){
$this -> _nosubmitbuttons [] = $addfieldsname ;
}
2006-11-24 12:33:53 +00:00
/**
* Method to add a repeating group of elements to a form .
*
* @ param array $elementobjs Array of elements or groups of elements that are to be repeated
* @ param integer $repeats no of times to repeat elements initially
* @ param array $options Array of options to apply to elements . Array keys are element names .
* This is an array of arrays . The second sets of keys are the option types
* for the elements :
* 'default' - default value is value
* 'type' - PARAM_ * constant is value
* 'helpbutton' - helpbutton params array is value
* 'disabledif' - last three moodleform :: disabledIf ()
* params are value as an array
* @ param string $repeathiddenname name for hidden element storing no of repeats in this form
* @ param string $addfieldsname name for button to add more fields
* @ param int $addfieldsno how many fields to add at a time
* @ param array $addstring array of params for get_string for name of button , $a is no of fields that
* will be added .
*/
2006-11-24 12:20:26 +00:00
function repeat_elements ( $elementobjs , $repeats , $options , $repeathiddenname , $addfieldsname , $addfieldsno = 5 , $addstring = array ( 'addfields' , 'form' )){
$repeats = optional_param ( $repeathiddenname , $repeats , PARAM_INT );
$addfields = optional_param ( $addfieldsname , '' , PARAM_TEXT );
if ( ! empty ( $addfields )){
$repeats += $addfieldsno ;
}
$this -> _register_no_submit_button ( $addfieldsname );
$mform =& $this -> _form ;
$mform -> addElement ( 'hidden' , $repeathiddenname , $repeats );
//value not to be overridden by submitted value
$mform -> setConstants ( array ( $repeathiddenname => $repeats ));
for ( $i = 0 ; $i < $repeats ; $i ++ ) {
foreach ( $elementobjs as $elementobj ){
$elementclone = clone ( $elementobj );
$name = $elementclone -> getName ();
$elementclone -> setName ( $name . " [ $i ] " );
if ( is_a ( $elementclone , 'HTML_QuickForm_header' )){
$value = $elementclone -> _text ;
$elementclone -> setValue ( $value . ' ' . ( $i + 1 ));
}
$mform -> addElement ( $elementclone );
}
}
for ( $i = 0 ; $i < $repeats ; $i ++ ) {
foreach ( $options as $elementname => $elementoptions ){
$pos = strpos ( $elementname , '[' );
if ( $pos !== FALSE ){
$realelementname = substr ( $elementname , 0 , $pos + 1 ) . " [ $i ] " ;
$realelementname .= substr ( $elementname , $pos + 1 );
} else {
$realelementname = $elementname . " [ $i ] " ;
}
foreach ( $elementoptions as $option => $params ){
switch ( $option ){
case 'default' :
$mform -> setDefault ( $realelementname , $params );
break ;
case 'type' :
$mform -> setType ( $realelementname , $params );
break ;
case 'helpbutton' :
$mform -> setHelpButton ( $realelementname , $params );
break ;
case 'disabledif' :
$mform -> disabledIf ( $realelementname , $params [ 0 ], $params [ 1 ], $params [ 2 ]);
break ;
}
}
}
}
$mform -> addElement ( 'submit' , $addfieldsname , get_string ( 'addfields' , 'form' , $addfieldsno ),
array ( 'onclick' => 'this.form.submit();' )); //need this to bypass client validation
$renderer =& $mform -> defaultRenderer ();
$renderer -> addStopFieldsetElements ( $addfieldsname );
}
2006-10-12 07:33:57 +00:00
}
2006-11-12 07:28:13 +00:00
/**
* You never extend this class directly . The class methods of this class are available from
* the private $this -> _form property on moodleform and it ' s children . You generally only
* call methods on this class from within abstract methods that you override on moodleform such
* as definition and definition_after_data
*
*/
2006-10-12 07:33:57 +00:00
class MoodleQuickForm extends HTML_QuickForm_DHTMLRulesTableless {
var $_types = array ();
2006-11-21 09:17:46 +00:00
var $_dependencies = array ();
2006-10-12 07:33:57 +00:00
2006-09-24 17:04:51 +00:00
/**
* Class constructor - same parameters as HTML_QuickForm_DHTMLRulesTableless
* @ param string $formName Form ' s name .
* @ param string $method ( optional ) Form 's method defaults to ' POST '
* @ param string $action ( optional ) Form ' s action
* @ param string $target ( optional ) Form ' s target defaults to none
* @ param mixed $attributes ( optional ) Extra attributes for < form > tag
* @ param bool $trackSubmit ( optional ) Whether to track if the form was submitted by adding a special hidden field
* @ access public
*/
2006-10-12 07:33:57 +00:00
function MoodleQuickForm ( $formName , $method , $action , $target = '' , $attributes = null ){
2006-09-24 17:04:51 +00:00
global $CFG ;
2006-10-12 07:33:57 +00:00
2006-09-24 17:04:51 +00:00
HTML_Common :: HTML_Common ( $attributes );
$target = empty ( $target ) ? array () : array ( 'target' => $target );
//no 'name' atttribute for form in xhtml strict :
$attributes = array ( 'action' => $action , 'method' => $method , 'id' => $formName ) + $target ;
$this -> updateAttributes ( $attributes );
2006-10-12 07:33:57 +00:00
//this is custom stuff for Moodle :
2006-09-24 17:04:51 +00:00
$oldclass = $this -> getAttribute ( 'class' );
if ( ! empty ( $oldclass )){
$this -> updateAttributes ( array ( 'class' => $oldclass . ' mform' ));
} else {
2006-09-26 09:42:42 +00:00
$this -> updateAttributes ( array ( 'class' => 'mform' ));
2006-09-24 17:04:51 +00:00
}
2006-10-12 07:33:57 +00:00
$this -> _helpImageURL = " $CFG->wwwroot /lib/form/req.gif " ;
$this -> _reqHTML =
2006-09-24 17:04:51 +00:00
helpbutton ( 'requiredelement' , get_string ( 'requiredelement' , 'form' ), 'moodle' ,
true , false , '' , true , '<img alt="' . get_string ( 'requiredelement' , 'form' ) . '" src="' .
$this -> _helpImageURL . '" />' );
$this -> setRequiredNote ( get_string ( 'denotesreq' , 'form' , $this -> getReqHTML ()));
}
2006-11-08 06:22:58 +00:00
2006-11-12 07:28:13 +00:00
/**
* Should be used for all elements of a form except for select , radio and checkboxes which
* clean their own data .
*
* @ param string $elementname
* @ param integer $paramtype use the constants PARAM_ *.
* * PARAM_CLEAN is deprecated and you should try to use a more specific type .
* * PARAM_TEXT should be used for cleaning data that is expected to be plain text .
* It will strip all html tags . But will still let tags for multilang support
* through .
* * PARAM_RAW means no cleaning whatsoever , it is used mostly for data from the
* html editor . Data from the editor is later cleaned before display using
* format_text () function . PARAM_RAW can also be used for data that is validated
* by some other way or printed by p () or s () .
* * PARAM_INT should be used for integers .
* * PARAM_ACTION is an alias of PARAM_ALPHA and is used for hidden fields specifying
* form actions .
*/
2006-10-12 07:33:57 +00:00
function setType ( $elementname , $paramtype ) {
$this -> _types [ $elementname ] = $paramtype ;
}
2006-11-09 08:38:40 +00:00
2006-11-12 07:28:13 +00:00
/**
* See description of setType above . This can be used to set several types at once .
*
* @ param array $paramtypes
*/
2006-10-12 14:15:59 +00:00
function setTypes ( $paramtypes ) {
$this -> _types = $paramtypes + $this -> _types ;
}
2006-11-09 08:38:40 +00:00
function updateSubmission ( $submission , $files ) {
$this -> _flagSubmitted = false ;
2006-10-12 07:33:57 +00:00
if ( empty ( $submission )) {
$this -> _submitValues = array ();
} else {
foreach ( $submission as $key => $s ) {
if ( array_key_exists ( $key , $this -> _types )) {
$submission [ $key ] = clean_param ( $s , $this -> _types [ $key ]);
}
}
$this -> _submitValues = $this -> _recursiveFilter ( 'stripslashes' , $submission );
$this -> _flagSubmitted = true ;
}
2006-11-09 08:38:40 +00:00
if ( empty ( $files )) {
$this -> _submitFiles = array ();
} else {
if ( 1 == get_magic_quotes_gpc ()) {
foreach ( $files as $elname => $file ) {
// dangerous characters in filenames are cleaned later in upload_manager
$files [ $elname ][ 'name' ] = stripslashes ( $files [ $elname ][ 'name' ]);
}
}
$this -> _submitFiles = $files ;
$this -> _flagSubmitted = true ;
}
2006-10-24 11:05:50 +00:00
// need to tell all elements that they need to update their value attribute.
foreach ( array_keys ( $this -> _elements ) as $key ) {
$this -> _elements [ $key ] -> onQuickFormEvent ( 'updateValue' , null , $this );
}
2006-10-12 07:33:57 +00:00
}
2006-09-24 17:04:51 +00:00
function getReqHTML (){
return $this -> _reqHTML ;
}
2006-10-12 07:33:57 +00:00
/**
2006-11-12 07:28:13 +00:00
* Initializes a default form value . Used to specify the default for a new entry where
* no data is loaded in using moodleform :: set_defaults ()
2006-10-12 07:33:57 +00:00
*
* @ param string $elementname element name
* @ param mixed $values values for that element name
* @ param bool $slashed the default value is slashed
* @ access public
* @ return void
*/
function setDefault ( $elementName , $defaultValue , $slashed = false ){
$filter = $slashed ? 'stripslashes' : NULL ;
$this -> setDefaults ( array ( $elementName => $defaultValue ), $filter );
} // end func setDefault
2006-09-24 17:04:51 +00:00
/**
2006-10-12 14:15:59 +00:00
* Add an array of buttons to the form
2006-10-12 07:33:57 +00:00
* @ param array $buttons An associative array representing help button to attach to
2006-09-24 17:04:51 +00:00
* to the form . keys of array correspond to names of elements in form .
2006-10-12 07:33:57 +00:00
*
2006-09-24 17:04:51 +00:00
* @ access public
*/
2006-11-13 07:43:22 +00:00
function setHelpButtons ( $buttons , $suppresscheck = false , $function = 'helpbutton' ){
2006-10-12 07:33:57 +00:00
2006-10-12 14:15:59 +00:00
foreach ( $buttons as $elementname => $button ){
2006-11-13 07:43:22 +00:00
$this -> setHelpButton ( $elementname , $button , $suppresscheck , $function );
2006-09-24 17:04:51 +00:00
}
}
2006-10-12 14:15:59 +00:00
/**
2006-11-12 07:28:13 +00:00
* Add a single button .
2006-10-12 14:15:59 +00:00
*
* @ param string $elementname name of the element to add the item to
2006-11-13 07:43:22 +00:00
* @ param array $button - arguments to pass to function $function
2006-10-12 14:15:59 +00:00
* @ param boolean $suppresscheck - whether to throw an error if the element
* doesn ' t exist .
2006-11-13 07:43:22 +00:00
* @ param string $function - function to generate html from the arguments in $button
2006-10-12 14:15:59 +00:00
*/
2006-11-13 07:43:22 +00:00
function setHelpButton ( $elementname , $button , $suppresscheck = false , $function = 'helpbutton' ){
2006-10-12 14:15:59 +00:00
if ( array_key_exists ( $elementname , $this -> _elementIndex )){
//_elements has a numeric index, this code accesses the elements by name
$element =& $this -> _elements [ $this -> _elementIndex [ $elementname ]];
if ( method_exists ( $element , 'setHelpButton' )){
2006-11-13 07:43:22 +00:00
$element -> setHelpButton ( $button , $function );
2006-10-12 14:15:59 +00:00
} else {
$a = new object ();
$a -> name = $element -> getName ();
$a -> classname = get_class ( $element );
print_error ( 'nomethodforaddinghelpbutton' , 'form' , '' , $a );
}
} elseif ( ! $suppresscheck ){
print_error ( 'nonexistentformelements' , 'form' , '' , $elementname );
2006-10-24 11:05:50 +00:00
}
2006-10-12 14:15:59 +00:00
}
2006-10-12 07:33:57 +00:00
2006-09-27 16:00:19 +00:00
function exportValues ( $elementList = null , $addslashes = true ){
2006-09-24 17:04:51 +00:00
$unfiltered = parent :: exportValues ( $elementList );
2006-10-12 07:33:57 +00:00
2006-09-24 17:04:51 +00:00
if ( $addslashes ){
2006-09-27 16:00:19 +00:00
return $this -> _recursiveFilter ( 'addslashes' , $unfiltered );
2006-09-24 17:04:51 +00:00
} else {
return $unfiltered ;
}
}
2006-10-14 12:32:31 +00:00
/**
* Returns the client side validation script
*
* The code here was copied from HTML_QuickForm_DHTMLRulesTableless who copied it from HTML_QuickForm
* and slightly modified to run rules per - element
* Needed to override this because of an error with client side validation of grouped elements .
*
* @ access public
* @ return string Javascript to perform validation , empty string if no 'client' rules were added
*/
function getValidationScript ()
{
if ( empty ( $this -> _rules ) || empty ( $this -> _attributes [ 'onsubmit' ])) {
return '' ;
}
include_once ( 'HTML/QuickForm/RuleRegistry.php' );
$registry =& HTML_QuickForm_RuleRegistry :: singleton ();
$test = array ();
$js_escape = array (
" \r " => '\r' ,
" \n " => '\n' ,
" \t " => '\t' ,
" ' " => " \\ ' " ,
'"' => '\"' ,
'\\' => '\\\\'
);
foreach ( $this -> _rules as $elementName => $rules ) {
foreach ( $rules as $rule ) {
if ( 'client' == $rule [ 'validation' ]) {
2006-11-12 07:28:13 +00:00
unset ( $element ); //TODO: find out how to properly initialize it
2006-10-14 12:32:31 +00:00
$dependent = isset ( $rule [ 'dependent' ]) && is_array ( $rule [ 'dependent' ]);
$rule [ 'message' ] = strtr ( $rule [ 'message' ], $js_escape );
if ( isset ( $rule [ 'group' ])) {
$group =& $this -> getElement ( $rule [ 'group' ]);
// No JavaScript validation for frozen elements
if ( $group -> isFrozen ()) {
continue 2 ;
}
$elements =& $group -> getElements ();
foreach ( array_keys ( $elements ) as $key ) {
if ( $elementName == $group -> getElementName ( $key )) {
$element =& $elements [ $key ];
break ;
}
}
} elseif ( $dependent ) {
$element = array ();
$element [] =& $this -> getElement ( $elementName );
foreach ( $rule [ 'dependent' ] as $idx => $elName ) {
$element [] =& $this -> getElement ( $elName );
}
} else {
$element =& $this -> getElement ( $elementName );
}
// No JavaScript validation for frozen elements
if ( is_object ( $element ) && $element -> isFrozen ()) {
continue 2 ;
} elseif ( is_array ( $element )) {
foreach ( array_keys ( $element ) as $key ) {
if ( $element [ $key ] -> isFrozen ()) {
continue 3 ;
}
}
}
// Fix for bug displaying errors for elements in a group
//$test[$elementName][] = $registry->getValidationScript($element, $elementName, $rule);
$test [ $elementName ][ 0 ][] = $registry -> getValidationScript ( $element , $elementName , $rule );
$test [ $elementName ][ 1 ] = $element ;
//end of fix
}
}
}
$js = '
< script type = " text/javascript " >
//<![CDATA[
function qf_errorHandler ( element , _qfMsg ) {
div = element . parentNode ;
if ( _qfMsg != \ ' \ ' ) {
span = document . createElement ( " span " );
span . className = " error " ;
span . appendChild ( document . createTextNode ( _qfMsg . substring ( 3 )));
br = document . createElement ( " br " );
var errorDiv = document . getElementById ( element . name + \ ' _errorDiv\ ' );
if ( ! errorDiv ) {
errorDiv = document . createElement ( " div " );
errorDiv . id = element . name + \ ' _errorDiv\ ' ;
}
while ( errorDiv . firstChild ) {
errorDiv . removeChild ( errorDiv . firstChild );
}
2006-10-24 11:05:50 +00:00
2006-10-14 12:32:31 +00:00
errorDiv . insertBefore ( br , errorDiv . firstChild );
errorDiv . insertBefore ( span , errorDiv . firstChild );
element . parentNode . insertBefore ( errorDiv , element . parentNode . firstChild );
if ( div . className . substr ( div . className . length - 6 , 6 ) != " error "
&& div . className != " error " ) {
div . className += " error " ;
}
return false ;
} else {
var errorDiv = document . getElementById ( element . name + \ ' _errorDiv\ ' );
if ( errorDiv ) {
errorDiv . parentNode . removeChild ( errorDiv );
}
if ( div . className . substr ( div . className . length - 6 , 6 ) == " error " ) {
div . className = div . className . substr ( 0 , div . className . length - 6 );
} else if ( div . className == " error " ) {
div . className = " " ;
}
return true ;
}
} ' ;
$validateJS = '' ;
foreach ( $test as $elementName => $jsandelement ) {
// Fix for bug displaying errors for elements in a group
//unset($element);
list ( $jsArr , $element ) = $jsandelement ;
//end of fix
$js .= '
function validate_ ' . $this->_attributes[' id '] . ' _ ' . $elementName . ' ( element ) {
var value = \ ' \ ' ;
var errFlag = new Array ();
var _qfGroups = {};
var _qfMsg = \ ' \ ' ;
var frm = element . parentNode ;
while ( frm && frm . nodeName != " FORM " ) {
frm = frm . parentNode ;
}
' . join("\n", $jsArr) . '
return qf_errorHandler ( element , _qfMsg );
}
' ;
$validateJS .= '
ret = validate_ ' . $this->_attributes[' id '] . ' _ ' . $elementName.' ( frm . elements [ \ '' . $elementName . '\']) && ret;' ;
// Fix for bug displaying errors for elements in a group
//unset($element);
//$element =& $this->getElement($elementName);
//end of fix
$valFunc = 'validate_' . $this -> _attributes [ 'id' ] . '_' . $elementName . '(this)' ;
$onBlur = $element -> getAttribute ( 'onBlur' );
$onChange = $element -> getAttribute ( 'onChange' );
$element -> updateAttributes ( array ( 'onBlur' => $onBlur . $valFunc ,
'onChange' => $onChange . $valFunc ));
}
$js .= '
function validate_ ' . $this->_attributes[' id '] . ' ( frm ) {
var ret = true ;
' . $validateJS . ' ;
return ret ;
}
//]]>
</ script > ' ;
return $js ;
} // end func getValidationScript
function _setDefaultRuleMessages (){
foreach ( $this -> _rules as $field => $rulesarr ){
foreach ( $rulesarr as $key => $rule ){
if ( $rule [ 'message' ] === null ){
$a = new object ();
$a -> format = $rule [ 'format' ];
$str = get_string ( 'err_' . $rule [ 'type' ], 'form' , $a );
if ( strpos ( $str , '[[' ) !== 0 ){
$this -> _rules [ $field ][ $key ][ 'message' ] = $str ;
2006-10-24 11:05:50 +00:00
}
2006-10-14 12:32:31 +00:00
}
}
}
}
2006-11-08 06:22:58 +00:00
2006-11-22 08:53:35 +00:00
function getLockOptionEndScript (){
2006-11-21 09:17:46 +00:00
$js = '<script type="text/javascript" language="javascript">' . " \n " ;
$js .= " var " . $this -> getAttribute ( 'id' ) . " items= { " ;
foreach ( $this -> _dependencies as $dependentOn => $elements ){
$js .= $dependentOn . ' : {dependents :[' ;
foreach ( $elements as $element ){
$js .= " ' " . $element [ 'dependent' ] . " ', " ;
}
$js = rtrim ( $js , ', ' );
$js .= " ], \n " ;
2006-11-24 06:39:15 +00:00
$js .= " condition : ' { $element [ 'condition' ] } ', \n " ;
$js .= " value : ' { $element [ 'value' ] } '}, \n " ;
2006-11-21 09:17:46 +00:00
};
$js = rtrim ( $js , " , \n " );
$js .= '};' . " \n " ;
2006-11-22 08:53:35 +00:00
$js .= " lockoptionsallsetup(' " . $this -> getAttribute ( 'id' ) . " '); \n " ;
2006-11-21 09:17:46 +00:00
$js .= '</script>' . " \n " ;
return $js ;
2006-11-08 06:22:58 +00:00
}
2006-11-22 08:53:35 +00:00
function _getElNamesRecursive ( & $element , $group = null ){
if ( $group == null ){
2006-11-22 15:58:07 +00:00
$el = $this -> getElement ( $element );
2006-11-22 08:53:35 +00:00
} else {
2006-11-22 15:58:07 +00:00
$el = & $element ;
2006-11-22 08:53:35 +00:00
}
if ( is_a ( $el , 'HTML_QuickForm_group' )){
2006-11-22 15:58:07 +00:00
$group = $el ;
$elsInGroup = $group -> getElements ();
$elNames = array ();
2006-11-22 08:53:35 +00:00
foreach ( $elsInGroup as $elInGroup ){
$elNames = array_merge ( $elNames , $this -> _getElNamesRecursive ( $elInGroup , $group ));
}
} else {
2006-11-22 15:58:07 +00:00
if ( $group != null ){
$elNames = array ( $group -> getElementName ( $el -> getName ()));
} elseif ( is_a ( $el , 'HTML_QuickForm_header' )) {
return null ;
2006-11-28 08:04:00 +00:00
} elseif ( method_exists ( $el , 'getPrivateName' )) {
return array ( $el -> getPrivateName ());
2006-11-22 08:53:35 +00:00
} else {
2006-11-22 15:58:07 +00:00
$elNames = array ( $el -> getName ());
2006-11-22 08:53:35 +00:00
}
}
return $elNames ;
2006-11-21 09:17:46 +00:00
}
2006-11-21 09:33:48 +00:00
/**
* Adds a dependency for $elementName which will be disabled if $condition is met .
2006-11-22 15:58:07 +00:00
* If $condition = 'notchecked' ( default ) then the condition is that the $dependentOn element
* is not checked . If $condition = 'checked' then the condition is that the $dependentOn element
2006-11-21 09:33:48 +00:00
* is checked . If $condition is something else then it is checked to see if the value
* of the $dependentOn element is equal to $condition .
*
* @ param string $elementName the name of the element which will be disabled
* @ param string $dependentOn the name of the element whose state will be checked for
* condition
* @ param string $condition the condition to check
*/
2006-11-24 06:39:15 +00:00
function disabledIf ( $elementName , $dependentOn , $condition = 'notchecked' , $value = null ){
2006-11-22 15:58:07 +00:00
$dependents = $this -> _getElNamesRecursive ( $elementName );
2006-11-22 08:53:35 +00:00
foreach ( $dependents as $dependent ){
2006-11-22 15:58:07 +00:00
if ( $dependent != $dependentOn ) {
$this -> _dependencies [ $dependentOn ][] = array ( 'dependent' => $dependent ,
2006-11-24 06:39:15 +00:00
'condition' => $condition , 'value' => $value );
2006-11-22 15:19:20 +00:00
}
2006-11-21 09:17:46 +00:00
}
2006-11-08 06:22:58 +00:00
}
2006-09-24 17:04:51 +00:00
}
2006-11-24 06:39:15 +00:00
2006-09-24 17:04:51 +00:00
/**
2006-10-12 07:33:57 +00:00
* A renderer for MoodleQuickForm that only uses XHTML and CSS and no
2006-09-24 17:04:51 +00:00
* table tags , extends PEAR class HTML_QuickForm_Renderer_Tableless
2006-10-12 07:33:57 +00:00
*
2006-09-24 17:04:51 +00:00
* Stylesheet is part of standard theme and should be automatically included .
*
* @ author Jamie Pratt < me @ jamiep . org >
* @ license gpl license
*/
2006-10-12 07:33:57 +00:00
class MoodleQuickForm_Renderer extends HTML_QuickForm_Renderer_Tableless {
2006-09-24 17:04:51 +00:00
/**
* Element template array
* @ var array
* @ access private
*/
var $_elementTemplates ;
2006-09-27 16:00:19 +00:00
2006-09-27 19:12:52 +00:00
// uncomment templates below and edit formslib.php for
2006-09-27 16:00:19 +00:00
// ol li containers for form items.
2006-09-27 19:12:52 +00:00
/**
* Template used when opening a hidden fieldset
* ( i . e . a fieldset that is opened when there is no header element )
* @ var string
* @ access private
*/
var $_openHiddenFieldsetTemplate = " \n \t <fieldset class= \" hidden \" > " ;
2006-09-27 16:00:19 +00:00
// var $_openHiddenFieldsetTemplate = "\n\t<fieldset class=\"hidden\">\n\t\t<ol>";
// /**
// * Header Template string
// * @var string
// * @access private
// */
2006-10-12 07:33:57 +00:00
// var $_headerTemplate =
2006-09-27 16:00:19 +00:00
// "\n\t\t<legend>{header}</legend>\n\t\t<ol>";
2006-10-12 07:33:57 +00:00
// var $_headerTemplate =
2006-09-27 19:12:52 +00:00
// "\n\t\t<legend>{header}</legend>\n\t\t<ol>";
2006-10-12 07:33:57 +00:00
2006-09-27 19:12:52 +00:00
/**
* Template used when closing a fieldset
* @ var string
* @ access private
*/
var $_closeFieldsetTemplate = " \n \t \t </fieldset> " ;
2006-09-27 16:00:19 +00:00
// var $_closeFieldsetTemplate = "\n\t\t</ol>\n\t</fieldset>";
2006-09-27 19:12:52 +00:00
/**
* Required Note template string
* @ var string
* @ access private
*/
2006-10-12 07:33:57 +00:00
var $_requiredNoteTemplate =
2006-09-27 19:12:52 +00:00
" \n \t \t <div class= \" fdescription \" > { requiredNote}</div> " ;
2006-10-12 07:33:57 +00:00
function MoodleQuickForm_Renderer (){
2006-09-27 16:00:19 +00:00
// switch next two lines for ol li containers for form items.
2006-09-27 19:12:52 +00:00
// $this->_elementTemplates=array('default'=>"\n\t\t<li class=\"fitem\"><label>{label}{help}<!-- BEGIN required -->{req}<!-- END required --></label><div class=\"qfelement<!-- BEGIN error --> error<!-- END error --> {type}\"><!-- BEGIN error --><span class=\"error\">{error}</span><br /><!-- END error -->{element}</div></li>");
2006-11-22 15:58:07 +00:00
$this -> _elementTemplates = array ( 'default' => " \n \t \t <div class= \" fitem \" ><label> { label} { help}<!-- BEGIN required --> { req}<!-- END required --></label><div class= \" felement<!-- BEGIN error --> error<!-- END error --> { type} \" ><!-- BEGIN error --><span class= \" error \" > { error}</span><br /><!-- END error --> { element}</div></div> " ,
2006-09-28 04:19:56 +00:00
'fieldset' => " \n \t \t <div class= \" fitem \" ><label> { label} { help}<!-- BEGIN required --> { req}<!-- END required --></label><fieldset class= \" felement<!-- BEGIN error --> error<!-- END error --> { type} \" ><!-- BEGIN error --><span class= \" error \" > { error}</span><br /><!-- END error --> { element}</fieldset></div> " );
2006-09-24 17:04:51 +00:00
parent :: HTML_QuickForm_Renderer_Tableless ();
}
2006-10-12 07:33:57 +00:00
2006-09-24 17:04:51 +00:00
function startForm ( & $form ){
2006-11-22 15:58:07 +00:00
$this -> _reqHTML = $form -> getReqHTML ();
$this -> _elementTemplates = str_replace ( '{req}' , $this -> _reqHTML , $this -> _elementTemplates );
2006-09-24 17:04:51 +00:00
parent :: startForm ( $form );
}
2006-10-12 07:33:57 +00:00
2006-09-24 17:04:51 +00:00
function startGroup ( & $group , $required , $error ){
if ( method_exists ( $group , 'getElementTemplateType' )){
2006-09-27 16:07:37 +00:00
$html = $this -> _elementTemplates [ $group -> getElementTemplateType ()];
2006-09-24 17:04:51 +00:00
} else {
$html = $this -> _elementTemplates [ 'default' ];
2006-10-12 07:33:57 +00:00
2006-09-24 17:04:51 +00:00
}
if ( method_exists ( $group , 'getHelpButton' )){
$html = str_replace ( '{help}' , $group -> getHelpButton (), $html );
} else {
$html = str_replace ( '{help}' , '' , $html );
2006-10-12 07:33:57 +00:00
2006-09-24 17:04:51 +00:00
}
2006-09-27 19:12:52 +00:00
$html = str_replace ( '{type}' , 'fgroup' , $html );
2006-10-12 07:33:57 +00:00
2006-09-24 17:04:51 +00:00
$this -> _templates [ $group -> getName ()] = $html ;
// Fix for bug in tableless quickforms that didn't allow you to stop a
// fieldset before a group of elements.
// if the element name indicates the end of a fieldset, close the fieldset
if ( in_array ( $group -> getName (), $this -> _stopFieldsetElements )
&& $this -> _fieldsetsOpen > 0
) {
$this -> _html .= $this -> _closeFieldsetTemplate ;
$this -> _fieldsetsOpen -- ;
}
parent :: startGroup ( $group , $required , $error );
}
2006-10-12 07:33:57 +00:00
2006-09-24 17:04:51 +00:00
function renderElement ( & $element , $required , $error ){
if ( method_exists ( $element , 'getElementTemplateType' )){
$html = $this -> _elementTemplates [ $element -> getElementTemplateType ()];
} else {
$html = $this -> _elementTemplates [ 'default' ];
2006-10-12 07:33:57 +00:00
2006-09-24 17:04:51 +00:00
}
2006-09-27 19:12:52 +00:00
$html = str_replace ( '{type}' , 'f' . $element -> getType (), $html );
2006-09-24 17:04:51 +00:00
if ( method_exists ( $element , 'getHelpButton' )){
2006-11-22 15:58:07 +00:00
$html = str_replace ( '{help}' , $element -> getHelpButton (), $html );
2006-09-24 17:04:51 +00:00
} else {
2006-11-22 15:58:07 +00:00
$html = str_replace ( '{help}' , '' , $html );
2006-10-12 07:33:57 +00:00
2006-09-24 17:04:51 +00:00
}
2006-11-22 15:58:07 +00:00
$this -> _templates [ $element -> getName ()] = $html ;
2006-10-09 08:32:30 +00:00
if ( ! is_null ( $element -> getAttribute ( 'id' ))) {
$id = $element -> getAttribute ( 'id' );
} else {
$id = $element -> getName ();
}
$element -> updateAttributes ( array ( 'id' => 'id_' . $id ));
2006-09-24 17:04:51 +00:00
parent :: renderElement ( $element , $required , $error );
}
2006-11-08 06:22:58 +00:00
function finishForm ( & $form ){
parent :: finishForm ( $form );
2006-11-22 08:53:35 +00:00
// add a lockoptions script
2006-11-08 06:22:58 +00:00
if ( '' != ( $script = $form -> getLockOptionEndScript ())) {
$this -> _html = $this -> _html . " \n " . $script ;
}
}
2006-09-24 17:04:51 +00:00
}
2006-11-22 15:58:07 +00:00
$GLOBALS [ '_HTML_QuickForm_default_renderer' ] =& new MoodleQuickForm_Renderer ();
2006-09-24 17:04:51 +00:00
2006-10-12 07:33:57 +00:00
MoodleQuickForm :: registerElementType ( 'checkbox' , " $CFG->libdir /form/checkbox.php " , 'MoodleQuickForm_checkbox' );
MoodleQuickForm :: registerElementType ( 'file' , " $CFG->libdir /form/file.php " , 'MoodleQuickForm_file' );
MoodleQuickForm :: registerElementType ( 'group' , " $CFG->libdir /form/group.php " , 'MoodleQuickForm_group' );
MoodleQuickForm :: registerElementType ( 'password' , " $CFG->libdir /form/password.php " , 'MoodleQuickForm_password' );
MoodleQuickForm :: registerElementType ( 'radio' , " $CFG->libdir /form/radio.php " , 'MoodleQuickForm_radio' );
MoodleQuickForm :: registerElementType ( 'select' , " $CFG->libdir /form/select.php " , 'MoodleQuickForm_select' );
MoodleQuickForm :: registerElementType ( 'text' , " $CFG->libdir /form/text.php " , 'MoodleQuickForm_text' );
MoodleQuickForm :: registerElementType ( 'textarea' , " $CFG->libdir /form/textarea.php " , 'MoodleQuickForm_textarea' );
MoodleQuickForm :: registerElementType ( 'date_selector' , " $CFG->libdir /form/dateselector.php " , 'MoodleQuickForm_date_selector' );
MoodleQuickForm :: registerElementType ( 'date_time_selector' , " $CFG->libdir /form/datetimeselector.php " , 'MoodleQuickForm_date_time_selector' );
MoodleQuickForm :: registerElementType ( 'htmleditor' , " $CFG->libdir /form/htmleditor.php " , 'MoodleQuickForm_htmleditor' );
2006-10-26 07:02:20 +00:00
MoodleQuickForm :: registerElementType ( 'format' , " $CFG->libdir /form/format.php " , 'MoodleQuickForm_format' );
2006-10-12 07:33:57 +00:00
MoodleQuickForm :: registerElementType ( 'static' , " $CFG->libdir /form/static.php " , 'MoodleQuickForm_static' );
MoodleQuickForm :: registerElementType ( 'hidden' , " $CFG->libdir /form/hidden.php " , 'MoodleQuickForm_hidden' );
2006-11-09 18:08:34 +00:00
MoodleQuickForm :: registerElementType ( 'modvisible' , " $CFG->libdir /form/modvisible.php " , 'MoodleQuickForm_modvisible' );
MoodleQuickForm :: registerElementType ( 'modgroupmode' , " $CFG->libdir /form/modgroupmode.php " , 'MoodleQuickForm_modgroupmode' );
2006-11-12 11:30:12 +00:00
MoodleQuickForm :: registerElementType ( 'selectyesno' , " $CFG->libdir /form/selectyesno.php " , 'MoodleQuickForm_selectyesno' );
2006-11-13 07:43:22 +00:00
MoodleQuickForm :: registerElementType ( 'modgrade' , " $CFG->libdir /form/modgrade.php " , 'MoodleQuickForm_modgrade' );
2006-11-14 03:00:26 +00:00
MoodleQuickForm :: registerElementType ( 'submit' , " $CFG->libdir /form/submit.php " , 'MoodleQuickForm_submit' );
2006-11-15 07:40:49 +00:00
MoodleQuickForm :: registerElementType ( 'button' , " $CFG->libdir /form/button.php " , 'MoodleQuickForm_button' );
MoodleQuickForm :: registerElementType ( 'choosecoursefile' , " $CFG->libdir /form/choosecoursefile.php " , 'MoodleQuickForm_choosecoursefile' );
2006-09-25 11:08:44 +00:00
2006-09-24 17:04:51 +00:00
?>