]> git.mjollnir.org Git - moodle.git/commitdiff
some changes to setHelpButton methods on elements and MoodleQuickForm to allow non...
authorjamiesensei <jamiesensei>
Mon, 13 Nov 2006 07:43:22 +0000 (07:43 +0000)
committerjamiesensei <jamiesensei>
Mon, 13 Nov 2006 07:43:22 +0000 (07:43 +0000)
12 files changed:
lib/form/checkbox.php
lib/form/file.php
lib/form/group.php
lib/form/hidden.php
lib/form/modgroupmode.php
lib/form/password.php
lib/form/radio.php
lib/form/select.php
lib/form/static.php
lib/form/text.php
lib/form/textarea.php
lib/formslib.php

index 69ff6fe2b800435dd46a5542b2caec23534b2cc1..9c13dcaafdeef4dde9a3336c73cd4b69ac1edfa3 100644 (file)
@@ -3,7 +3,7 @@ require_once('HTML/QuickForm/checkbox.php');
 
 /**
  * HTML class for a checkbox type element
- * 
+ *
  * @author       Jamie Pratt
  * @access       public
  */
@@ -19,18 +19,19 @@ class MoodleQuickForm_checkbox extends HTML_QuickForm_checkbox{
      *
      * @access   public
      * @param array $help array of arguments to make a help button
+     * @param string $function function name to call to get html
      */
-    function setHelpButton($helpbuttonargs){
+    function setHelpButton($helpbuttonargs, $function='helpbutton'){
         if (!is_array($helpbuttonargs)){
             $helpbuttonargs=array($helpbuttonargs);
         }else{
             $helpbuttonargs=$helpbuttonargs;
         }
-        //we do this to to return html instead of printing it 
+        //we do this to to return html instead of printing it
         //without having to specify it in every call to make a button.
         $defaultargs=array('', '', 'moodle', true, false, '', true);
         $helpbuttonargs=$helpbuttonargs + $defaultargs ;
-        $this->_helpbutton=call_user_func_array('helpbutton', $helpbuttonargs);
+        $this->_helpbutton=call_user_func_array($function, $helpbuttonargs);
     }
     /**
      * get html for help button
@@ -43,13 +44,13 @@ class MoodleQuickForm_checkbox extends HTML_QuickForm_checkbox{
     }
    /**
     * Automatically generates and assigns an 'id' attribute for the element.
-    * 
+    *
     * Currently used to ensure that labels work on radio buttons and
     * checkboxes. Per idea of Alexander Radivanovich.
     * Overriden in moodleforms to remove qf_ prefix.
     *
     * @access private
-    * @return void 
+    * @return void
     */
     function _generateId()
     {
index db00d12ad5636421f8780b22d3e73ee2e71b46d0..15192338c0ff16c687595a5b04c63b889c844ed9 100644 (file)
@@ -3,7 +3,7 @@ require_once('HTML/QuickForm/file.php');
 
 /**
  * HTML class for a form element to upload a file
- * 
+ *
  * @author       Jamie Pratt
  * @access       public
  */
@@ -19,24 +19,26 @@ class MoodleQuickForm_file extends HTML_QuickForm_file{
      *
      * @access   public
      * @param array $help array of arguments to make a help button
+     * @param string $function function name to call to get html
      */
-    function setHelpButton($helpbuttonargs){
+    function setHelpButton($helpbuttonargs, $function='helpbutton'){
         if (!is_array($helpbuttonargs)){
             $helpbuttonargs=array($helpbuttonargs);
         }else{
             $helpbuttonargs=$helpbuttonargs;
         }
-        //we do this to to return html instead of printing it 
+        //we do this to to return html instead of printing it
         //without having to specify it in every call to make a button.
         $defaultargs=array('', '', 'moodle', true, false, '', true);
         $helpbuttonargs=$helpbuttonargs + $defaultargs ;
-        $this->_helpbutton=call_user_func_array('helpbutton', $helpbuttonargs);
+        $this->_helpbutton=call_user_func_array($function, $helpbuttonargs);
     }
     /**
-     * get html for help button
+     * set html for help button
      *
      * @access   public
-     * @return  string html for help button
+     * @param array $help array of arguments to make a help button
+     * @param string $function function name to call to get html
      */
     function getHelpButton(){
         return $this->_helpbutton;
index 8c3fcf8f06c0f627c3a4eadb2f8e3ffba56c9357..23ef0db77b54ba94370040e9a91f668b87fb8551 100644 (file)
@@ -3,7 +3,7 @@ require_once("HTML/QuickForm/group.php");
 
 /**
  * HTML class for a form element group
- * 
+ *
  * @author       Adam Daniel <adaniel1@eesus.jnj.com>
  * @author       Bertrand Mansion <bmansion@mamasam.com>
  * @version      1.0
@@ -25,24 +25,26 @@ class MoodleQuickForm_group extends HTML_QuickForm_group{
      *
      * @access   public
      * @param array $help array of arguments to make a help button
+     * @param string $function function name to call to get html
      */
-    function setHelpButton($helpbuttonargs){
+    function setHelpButton($helpbuttonargs, $function='helpbutton'){
         if (!is_array($helpbuttonargs)){
             $helpbuttonargs=array($helpbuttonargs);
         }else{
             $helpbuttonargs=$helpbuttonargs;
         }
-        //we do this to to return html instead of printing it 
+        //we do this to to return html instead of printing it
         //without having to specify it in every call to make a button.
         $defaultargs=array('', '', 'moodle', true, false, '', true);
         $helpbuttonargs=$helpbuttonargs + $defaultargs ;
-        $this->_helpbutton=call_user_func_array('helpbutton', $helpbuttonargs);
+        $this->_helpbutton=call_user_func_array($function, $helpbuttonargs);
     }
     /**
-     * get html for help button
+     * set html for help button
      *
      * @access   public
-     * @return  string html for help button
+     * @param array $help array of arguments to make a help button
+     * @param string $function function name to call to get html
      */
     function getHelpButton(){
         return $this->_helpbutton;
index 26e50bb334c3385994ceb175179063deb54094fc..7e78b1b1fab4d8ea5f751ed3621122d2c1a41177 100644 (file)
@@ -3,7 +3,7 @@ require_once('HTML/QuickForm/hidden.php');
 
 /**
  * HTML class for a hidden type element
- * 
+ *
  * @author       Jamie Pratt
  * @access       public
  */
@@ -19,9 +19,10 @@ class MoodleQuickForm_hidden extends HTML_QuickForm_hidden{
      *
      * @access   public
      * @param array $help array of arguments to make a help button
+     * @param string $function function name to call to get html
      */
-    function setHelpButton($helpbuttonargs){
-        
+    function setHelpButton($helpbuttonargs, $function='helpbutton'){
+
     }
     /**
      * get html for help button
index 3a10ce8bfa5294a7091535e6ffa02f91338d6800..d54361ac677123276581c748b45a9ee9da024225 100644 (file)
@@ -9,8 +9,6 @@ require_once "$CFG->libdir/form/select.php";
  * @access       public
  */
 class MoodleQuickForm_modgroupmode extends MoodleQuickForm_select{
-
-
     /**
      * Class constructor
      *
@@ -43,9 +41,10 @@ class MoodleQuickForm_modgroupmode extends MoodleQuickForm_select{
     {
         switch ($event) {
             case 'createElement':
-                $choices=array();
+                $choices = array();
                 $choices[0] = get_string('no');
                 $choices[1] = get_string('yes');
+                $this->setHelpButton(array('groupmode', get_string('groupmode')));
                 $this->load($choices);
                 break;
         }
index 834d853aa62e7b6f6b714205271334f489b72ce6..183221d6f18665fdf04c164c9e0dfd01b280a7ca 100644 (file)
@@ -3,7 +3,7 @@ require_once('HTML/QuickForm/password.php');
 
 /**
  * HTML class for a password type element
- * 
+ *
  * @author       Jamie Pratt
  * @access       public
  */
@@ -19,18 +19,19 @@ class MoodleQuickForm_password extends HTML_QuickForm_password{
      *
      * @access   public
      * @param array $help array of arguments to make a help button
+     * @param string $function function name to call to get html
      */
-    function setHelpButton($helpbuttonargs){
+    function setHelpButton($helpbuttonargs, $function='helpbutton'){
         if (!is_array($helpbuttonargs)){
             $helpbuttonargs=array($helpbuttonargs);
         }else{
             $helpbuttonargs=$helpbuttonargs;
         }
-        //we do this to to return html instead of printing it 
+        //we do this to to return html instead of printing it
         //without having to specify it in every call to make a button.
         $defaultargs=array('', '', 'moodle', true, false, '', true);
         $helpbuttonargs=$helpbuttonargs + $defaultargs ;
-        $this->_helpbutton=call_user_func_array('helpbutton', $helpbuttonargs);
+        $this->_helpbutton=call_user_func_array($function, $helpbuttonargs);
     }
     /**
      * get html for help button
index 5c9769eec1479a2a2a651a267b9929c5b656932e..f80244a23233437b0f122f894ee775d0bee0ce47 100644 (file)
@@ -3,7 +3,7 @@ require_once('HTML/QuickForm/radio.php');
 
 /**
  * HTML class for a radio type element
- * 
+ *
  * @author       Jamie Pratt
  * @access       public
  */
@@ -19,18 +19,19 @@ class MoodleQuickForm_radio extends HTML_QuickForm_radio{
      *
      * @access   public
      * @param array $help array of arguments to make a help button
+     * @param string $function function name to call to get html
      */
-    function setHelpButton($helpbuttonargs){
+    function setHelpButton($helpbuttonargs, $function='helpbutton'){
         if (!is_array($helpbuttonargs)){
             $helpbuttonargs=array($helpbuttonargs);
         }else{
             $helpbuttonargs=$helpbuttonargs;
         }
-        //we do this to to return html instead of printing it 
+        //we do this to to return html instead of printing it
         //without having to specify it in every call to make a button.
         $defaultargs=array('', '', 'moodle', true, false, '', true);
         $helpbuttonargs=$helpbuttonargs + $defaultargs ;
-        $this->_helpbutton=call_user_func_array('helpbutton', $helpbuttonargs);
+        $this->_helpbutton=call_user_func_array($function, $helpbuttonargs);
     }
     /**
      * get html for help button
@@ -43,13 +44,13 @@ class MoodleQuickForm_radio extends HTML_QuickForm_radio{
     }
    /**
     * Automatically generates and assigns an 'id' attribute for the element.
-    * 
+    *
     * Currently used to ensure that labels work on radio buttons and
     * checkboxes. Per idea of Alexander Radivanovich.
     * Overriden in moodleforms to remove qf_ prefix.
     *
     * @access private
-    * @return void 
+    * @return void
     */
     function _generateId()
     {
index 58ae596ce97aeb75034258b8a67d45b0dfe31879..28ead18a825880f90a730ff5eaaa93a3e8fc958a 100644 (file)
@@ -3,7 +3,7 @@ require_once('HTML/QuickForm/select.php');
 
 /**
  * HTML class for a select type element
- * 
+ *
  * @author       Jamie Pratt
  * @access       public
  */
@@ -19,18 +19,19 @@ class MoodleQuickForm_select extends HTML_QuickForm_select{
      *
      * @access   public
      * @param array $help array of arguments to make a help button
+     * @param string $function function name to call to get html
      */
-    function setHelpButton($helpbuttonargs){
+    function setHelpButton($helpbuttonargs, $function='helpbutton'){
         if (!is_array($helpbuttonargs)){
             $helpbuttonargs=array($helpbuttonargs);
         }else{
             $helpbuttonargs=$helpbuttonargs;
         }
-        //we do this to to return html instead of printing it 
+        //we do this to to return html instead of printing it
         //without having to specify it in every call to make a button.
         $defaultargs=array('', '', 'moodle', true, false, '', true);
         $helpbuttonargs=$helpbuttonargs + $defaultargs ;
-        $this->_helpbutton=call_user_func_array('helpbutton', $helpbuttonargs);
+        $this->_helpbutton=call_user_func_array($function, $helpbuttonargs);
     }
     /**
      * get html for help button
index 438092183fc98aeb61d96e4b6ede4689643e8cbb..acc5e0bd09499d9c4c57af7f23842627d32f3dc2 100644 (file)
@@ -3,7 +3,7 @@ require_once("HTML/QuickForm/static.php");
 
 /**
  * HTML class for a text type element
- * 
+ *
  * @author       Jamie Pratt
  * @access       public
  */
@@ -19,18 +19,19 @@ class MoodleQuickForm_static extends HTML_QuickForm_static{
      *
      * @access   public
      * @param array $help array of arguments to make a help button
+     * @param string $function function name to call to get html
      */
-    function setHelpButton($helpbuttonargs){
+    function setHelpButton($helpbuttonargs, $function='helpbutton'){
         if (!is_array($helpbuttonargs)){
             $helpbuttonargs=array($helpbuttonargs);
         }else{
             $helpbuttonargs=$helpbuttonargs;
         }
-        //we do this to to return html instead of printing it 
+        //we do this to to return html instead of printing it
         //without having to specify it in every call to make a button.
         $defaultargs=array('', '', 'moodle', true, false, '', true);
         $helpbuttonargs=$helpbuttonargs + $defaultargs ;
-        $this->_helpbutton=call_user_func_array('helpbutton', $helpbuttonargs);
+        $this->_helpbutton=call_user_func_array($function, $helpbuttonargs);
     }
     /**
      * get html for help button
index 834c9b3cf32689756a4cdfc809889621084d34a2..b83ee767f7d6599ab60750c7aebba81e818dafff 100644 (file)
@@ -3,7 +3,7 @@ require_once("HTML/QuickForm/text.php");
 
 /**
  * HTML class for a text type element
- * 
+ *
  * @author       Jamie Pratt
  * @access       public
  */
@@ -19,18 +19,19 @@ class MoodleQuickForm_text extends HTML_QuickForm_text{
      *
      * @access   public
      * @param array $help array of arguments to make a help button
+     * @param string $function function name to call to get html
      */
-    function setHelpButton($helpbuttonargs){
+    function setHelpButton($helpbuttonargs, $function='helpbutton'){
         if (!is_array($helpbuttonargs)){
             $helpbuttonargs=array($helpbuttonargs);
         }else{
             $helpbuttonargs=$helpbuttonargs;
         }
-        //we do this to to return html instead of printing it 
+        //we do this to to return html instead of printing it
         //without having to specify it in every call to make a button.
         $defaultargs=array('', '', 'moodle', true, false, '', true);
         $helpbuttonargs=$helpbuttonargs + $defaultargs ;
-        $this->_helpbutton=call_user_func_array('helpbutton', $helpbuttonargs);
+        $this->_helpbutton=call_user_func_array($function, $helpbuttonargs);
     }
     /**
      * get html for help button
index ee3ffb87d513d831ad998f988411ef99e33ae742..ebd04cf3e5bce6b434669b5b80d4b2fc115514bb 100644 (file)
@@ -3,7 +3,7 @@ require_once('HTML/QuickForm/textarea.php');
 
 /**
  * HTML class for a textarea type element
- * 
+ *
  * @author       Jamie Pratt
  * @access       public
  */
@@ -19,18 +19,19 @@ class MoodleQuickForm_textarea extends HTML_QuickForm_textarea{
      *
      * @access   public
      * @param array $help array of arguments to make a help button
+     * @param string $function function name to call to get html
      */
-    function setHelpButton($helpbuttonargs){
+    function setHelpButton($helpbuttonargs, $function='helpbutton'){
         if (!is_array($helpbuttonargs)){
             $helpbuttonargs=array($helpbuttonargs);
         }else{
             $helpbuttonargs=$helpbuttonargs;
         }
-        //we do this to to return html instead of printing it 
+        //we do this to to return html instead of printing it
         //without having to specify it in every call to make a button.
         $defaultargs=array('', '', 'moodle', true, false, '', true);
         $helpbuttonargs=$helpbuttonargs + $defaultargs ;
-        $this->_helpbutton=call_user_func_array('helpbutton', $helpbuttonargs);
+        $this->_helpbutton=call_user_func_array($function, $helpbuttonargs);
     }
     /**
      * get html for help button
index 8ac8d8bd59eee36762c7f12c5cc9f38a869864b4..f64744b33131cd7102951a7ec56577bf98685af8 100644 (file)
@@ -337,7 +337,6 @@ class moodleform_mod extends moodleform {
         $mform=$this->_form;
         $mform->addElement('header', '', get_string('modstandardels', 'form'));
         $mform->addElement('modgroupmode', 'groupmode', get_string('groupmode'));
-        $mform->setHelpButton('groupmode', array('groupmode', get_string('groupmode')));
         $mform->setType('groupmode', PARAM_INT);
 
         $mform->addElement('modvisible', 'visible', get_string('visible'));
@@ -554,26 +553,27 @@ class MoodleQuickForm extends HTML_QuickForm_DHTMLRulesTableless {
      *
      * @access   public
     */
-    function setHelpButtons($buttons, $suppresscheck=false){
+    function setHelpButtons($buttons, $suppresscheck=false, $function='helpbutton'){
 
         foreach ($buttons as $elementname => $button){
-            $this->setHelpButton($elementname, $button, $suppresscheck);
+            $this->setHelpButton($elementname, $button, $suppresscheck, $function);
         }
     }
     /**
      * Add a single button.
      *
      * @param string $elementname name of the element to add the item to
-     * @param array $button - arguments to pass to setHelpButton
+     * @param array $button - arguments to pass to function $function
      * @param boolean $suppresscheck - whether to throw an error if the element
      *                                  doesn't exist.
+     * @param string $function - function to generate html from the arguments in $button
      */
-    function setHelpButton($elementname, $button, $suppresscheck=false){
+    function setHelpButton($elementname, $button, $suppresscheck=false, $function='helpbutton'){
         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')){
-                $element->setHelpButton($button);
+                $element->setHelpButton($button, $function);
             }else{
                 $a=new object();
                 $a->name=$element->getName();
@@ -935,5 +935,6 @@ MoodleQuickForm::registerElementType('hidden', "$CFG->libdir/form/hidden.php", '
 MoodleQuickForm::registerElementType('modvisible', "$CFG->libdir/form/modvisible.php", 'MoodleQuickForm_modvisible');
 MoodleQuickForm::registerElementType('modgroupmode', "$CFG->libdir/form/modgroupmode.php", 'MoodleQuickForm_modgroupmode');
 MoodleQuickForm::registerElementType('selectyesno', "$CFG->libdir/form/selectyesno.php", 'MoodleQuickForm_selectyesno');
+MoodleQuickForm::registerElementType('modgrade', "$CFG->libdir/form/modgrade.php", 'MoodleQuickForm_modgrade');
 
 ?>
\ No newline at end of file