]> git.mjollnir.org Git - moodle.git/commitdiff
NOBUG: Fixed confirm() - two buttons "Yes" were displayed
authormudrd8mz <mudrd8mz>
Tue, 1 Sep 2009 14:15:49 +0000 (14:15 +0000)
committermudrd8mz <mudrd8mz>
Tue, 1 Sep 2009 14:15:49 +0000 (14:15 +0000)
Also, I change the default labels to Continue/Cancel. It is not good for
UI consistency to have Yes/No is string URL is passed and
Continue/Cancel if moodle_url is passed.
Removing the check against empty button->text as it has always the
default value "Yes".

lib/outputrenderers.php

index 65f734725f9d29aea01401a3d242f5368c363e76..6b21181df2401d4a88976298653d060d2a4ca5d2 100644 (file)
@@ -1086,8 +1086,10 @@ class moodle_core_renderer extends moodle_renderer_base {
     }
 
    /**
-    * Print a message along with button choices for Continue/Cancel. Labels default to Yes(Continue)/No(Cancel).
-    * If a string or moodle_url is given instead of a html_button, method defaults to post and text to Yes/No
+    * Print a message along with button choices for Continue/Cancel
+    *
+    * If a string or moodle_url is given instead of a html_button, method defaults to post.
+    *
     * @param string $message The question to ask the user
     * @param mixed $continue The html_form component representing the Continue answer. Can also be a moodle_url or string URL
     * @param mixed $cancel The html_form component representing the Cancel answer. Can also be a moodle_url or string URL
@@ -1098,10 +1100,12 @@ class moodle_core_renderer extends moodle_renderer_base {
             $continue = clone($continue);
         } else if (is_string($continue)) {
             $continueform = new html_form();
+            $continueform->button->text = get_string('continue');
             $continueform->url = new moodle_url($continue);
             $continue = $continueform;
         } else if ($continue instanceof moodle_url) {
             $continueform = new html_form();
+            $continueform->button->text = get_string('continue');
             $continueform->url = $continue;
             $continue = $continueform;
         } else {
@@ -1112,6 +1116,7 @@ class moodle_core_renderer extends moodle_renderer_base {
             $cancel = clone($cancel);
         } else if (is_string($cancel)) {
             $cancelform = new html_form();
+            $cancelform->button->text = get_string('cancel');
             $cancelform->url = new moodle_url($cancel);
             $cancel = $cancelform;
         } else if ($cancel instanceof moodle_url) {
@@ -1123,13 +1128,6 @@ class moodle_core_renderer extends moodle_renderer_base {
             throw new coding_exception('The cancel param to $OUTPUT->confirm must be either a URL (string/moodle_url) or a html_form object.');
         }
 
-        if (empty($continue->button->text)) {
-            $continue->button->text = get_string('yes');
-        }
-        if (empty($cancel->button->text)) {
-            $cancel->button->text = get_string('no');
-        }
-
         $output = $this->box_start('generalbox', 'notice');
         $output .= $this->output_tag('p', array(), $message);
         $output .= $this->output_tag('div', array('class' => 'buttons'), $this->button($continue) . $this->button($cancel));