]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-21198 minor cleanup and improvements
authorPetr Skoda <skodak@moodle.org>
Sat, 2 Jan 2010 13:57:44 +0000 (13:57 +0000)
committerPetr Skoda <skodak@moodle.org>
Sat, 2 Jan 2010 13:57:44 +0000 (13:57 +0000)
lib/outputcomponents.php
lib/outputrenderers.php

index a3eaa7a74eac2210455103c0cbd03882d605fead..e5c3f66d86d52a25175b1938c2b0c026d73ac5cb 100644 (file)
@@ -1547,7 +1547,7 @@ class html_form extends html_component {
         parent::prepare($output, $page, $target);
     }
 
-    public static function make_button($url, $params, $label=null, $method='post') {
+    public static function make_button($url, array $params=null, $label=null, $method='post') {
         if ($label === null) {
             $label = get_string('ok');
         }
index 524066b101cd30949e06354f1cf354511a6dcee0..299e424d48673411a6e8a76bec7ededa50059458 100644 (file)
@@ -965,39 +965,23 @@ class core_renderer extends renderer_base {
     * 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
+    * @param html_form|moodle_url|string $continue The html_form component representing the Continue answer. Can also be a moodle_url or string URL
+    * @param html_form|moodle_url|string $cancel The html_form component representing the Cancel answer. Can also be a moodle_url or string URL
     * @return string HTML fragment
     */
     public function confirm($message, $continue, $cancel) {
         if ($continue instanceof html_form) {
             $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 if (is_string($continue) or $continue instanceof moodle_url) {
+            $continue = html_form::make_button($continue, null, get_string('continue'), 'post');
         } else {
             throw new coding_exception('The continue param to $OUTPUT->confirm must be either a URL (string/moodle_url) or a html_form object.');
         }
 
         if ($cancel instanceof html_form) {
             $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) {
-            $cancelform = new html_form();
-            $cancelform->button->text = get_string('cancel');
-            $cancelform->url = $cancel;
-            $cancel = $cancelform;
+        } else if (is_string($cancel) or $cancel instanceof moodle_url) {
+            $cancel = html_form::make_button($cancel, null, get_string('cancel'), 'get');
         } else {
             throw new coding_exception('The cancel param to $OUTPUT->confirm must be either a URL (string/moodle_url) or a html_form object.');
         }