]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-21235 new single button rendering
authorPetr Skoda <skodak@moodle.org>
Thu, 14 Jan 2010 19:18:04 +0000 (19:18 +0000)
committerPetr Skoda <skodak@moodle.org>
Thu, 14 Jan 2010 19:18:04 +0000 (19:18 +0000)
16 files changed:
admin/delete.php
grade/edit/tree/index.php
lib/outputcomponents.php
lib/outputrenderers.php
mod/lesson/pagetypes/branchtable.php
mod/lesson/renderer.php
mod/quiz/accessrules.php
mod/quiz/summary.php
mod/workshop/allocation/manual/lib.php
mod/workshop/excompare.php
mod/workshop/exsubmission.php
mod/workshop/locallib.php
mod/workshop/renderer.php
mod/workshop/submission.php
mod/workshop/view.php
portfolio/add.php

index 6f7f86d341ffd0ce8ee427593cd24f412626a551..090ecf490c74788b994d104f91fa0303ef383d51 100644 (file)
@@ -33,7 +33,7 @@
     if (!data_submitted() or empty($reallysure)) {
         $optionsyes = array('sure'=>'yes', 'sesskey'=>sesskey(), 'reallysure'=>'yes');
         $formcontinue = new single_button(new moodle_url('delete.php', $optionsyes), get_string('yes'));
-        $formcancel = new signle_button('index.php', get_string('no'), 'get');
+        $formcancel = new single_button('index.php', get_string('no'), 'get');
         echo $OUTPUT->confirm('Are you REALLY REALLY completely sure you want to delete everything inside the directory '.
                 $deletedir .' (this includes all user images, and any other course files that have been created) ?',
                 $formcontinue, $formcancel);
index d35bafad4bd073869ff337a2ce8492e1b239111a..f9cee5e0a6547fcb20139a28e3b46bd3065f43f4 100644 (file)
@@ -165,7 +165,7 @@ switch ($action) {
                 $optionsyes = array('eid'=>$eid, 'confirm'=>1, 'sesskey'=>sesskey(), 'id'=>$course->id, 'action'=>'delete');
                 $optionsno  = array('id'=>$course->id);
                 $formcontinue = new single_button(new moodle_url('index.php', $optionsyes), get_string('yes'));
-                $formcancel = new signle_button(new moodle_url('index.php', $optionsno), get_string('no'), 'get');
+                $formcancel = new single_button(new moodle_url('index.php', $optionsno), get_string('no'), 'get');
                 echo $OUTPUT->confirm($strdeletecheckfull, $formcontinue, $formcancel);
                 echo $OUTPUT->footer();
                 die;
index fb077b2ab2187882d1133bdc62a85317be0bd976..03fabb3bdba10f2feb621dd54c01058652e78637 100644 (file)
@@ -188,6 +188,61 @@ class help_icon implements renderable {
 }
 
 
+/**
+ * Data structure representing a simple form with only one button.
+ *
+ * @copyright 2009 Petr Skoda
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @since     Moodle 2.0
+ */
+class single_button implements renderable {
+    /** Target url */
+    var $url;
+    /** Button label */
+    var $label;
+    /** Form submit method */
+    var $method = 'post';
+    /** Form class */
+    var $class = 'singlebutton';
+    /** True if button disabled, false if normal */
+    var $disabled = false;
+    /** Button tooltip */
+    var $tooltip = '';
+    /** Form id */
+    var $formid;
+    /** List of attached actions */
+    var $actions = array();
+
+    /**
+     * Constructor
+     * @param string|moodle_url
+     * @param string $label button text
+     * @param string $method get or post submit method
+     * @param array $options associative array form attributes + {disabled, title}
+     */
+    public function __construct(moodle_url $url, $label, $method='post') {
+        $this->url    = clone($url);
+        $this->label  = $label;
+        $this->method = $method;
+    }
+
+    /**
+     * Shortcut for adding a JS confirm dialog when the component is clicked.
+     * The message must be a yes/no question.
+     * @param string $message The yes/no confirmation question. If "Yes" is clicked, the original action will occur.
+     * @return void
+     */
+    public function add_confirm_action($confirmmessage) {
+        $this->add_action(new component_action('click', 'confirm_dialog', array('message' => $confirmmessage)));
+    }
+
+    public function add_action(component_action $action) {
+        $this->actions[] = $action;
+    }
+}
+
+
+
 // ==== HTML writer and helper classes, will be probably moved elsewhere ======
 
 
@@ -1809,49 +1864,6 @@ class html_form extends html_component {
 
         parent::prepare($output, $page, $target);
     }
-
-    public static function make_button($url, array $params=null, $label=null, $method='post', array $formoptions=null) {
-        //TODO: to be removed soon, repalced by ew single_button()
-        //      in any case the $params argument is not appropriate here, we use moodle_urls now!
-        $form = new html_form($formoptions);
-        $form->url = new moodle_url($url, $params);
-        if ($label !== null) {
-            $form->button->text = $label;
-        }
-        $form->method = $method;
-
-        return $form;
-    }
-}
-
-
-/**
- * A component representing a simple form with only one button.
- *
- * @copyright 2009 Petr Skoda
- * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @since     Moodle 2.0
- */
-class single_button extends html_form {
-    /**
-     * Constructor
-     * @param string|moodle_url
-     * @param string $label button text
-     * @param string $method get or post submit method
-     * @param array $options associative array form attributes + {disabled, title}
-     */
-    public function __construct($url, $label, $method='post', array $options=null) {
-        parent::__construct($options);
-        $this->url = $url;
-        $form->method = $method;
-        $this->button->text = $label;
-        if (!empty($options['disabled'])) {
-            $this->button->disabled = true;
-        }
-        if (!empty($options['title'])) {
-            $this->button->title = $options['title'];
-        }
-    }
 }
 
 
index 2cd5f6e180f89c8e79059b65786539f08b0ca0ae..4d7f76a76dacbcf34c875bab64cfc277b234aad1 100644 (file)
@@ -923,22 +923,18 @@ 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 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
+    * @param single_button|moodle_url|string $continue The single_button component representing the Continue answer. Can also be a moodle_url or string URL
+    * @param single_button|moodle_url|string $cancel The single_button 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) { //TODO: change to single_button
-            $continue = clone($continue);
-        } else if (is_string($continue) or $continue instanceof moodle_url) {
+        if (is_string($continue) or $continue instanceof moodle_url) {
             $continue = new single_button($continue, 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 instance.');
         }
 
-        if ($cancel instanceof html_form) { //TODO: change to single_button
-            $cancel = clone($cancel);
-        } else if (is_string($cancel) or $cancel instanceof moodle_url) {
+        if (is_string($cancel) or $cancel instanceof moodle_url) {
             $cancel = new single_button($cancel, 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 instance.');
@@ -946,63 +942,79 @@ class core_renderer extends renderer_base {
 
         $output = $this->box_start('generalbox', 'notice');
         $output .= html_writer::tag('p', array(), $message);
-        $output .= html_writer::tag('div', array('class' => 'buttons'), $this->button($continue) . $this->button($cancel));
+        $output .= html_writer::tag('div', array('class' => 'buttons'), $this->render($continue) . $this->render($cancel));
         $output .= $this->box_end();
         return $output;
     }
 
     /**
-     * Returns a form with single button.
-     * If first parameter is html_form instance all other parameters are ignored.
+     * Returns a form with a single button.
      *
-     * @param string|moodle_url|single_button $url_or_singlebutton
+     * @param string|moodle_url $url
      * @param string $label button text
      * @param string $method get or post submit method
-     * @param array $options associative array {disabled, title}
+     * @param array $options associative array {disabled, title, etc.}
      * @return string HTML fragment
      */
-    public function single_button($url_or_singlebutton, $label=null, $method='post', array $options=null) {
-        if ($url_or_singlebutton instanceof single_button) {
-            $button = $url_or_singlebutton;
-            if (func_num_args() > 1) {
-                debugging('html_form instance used as first parameter of $OUTPUT->single_button(), all other parameters are ignored.');
-            }
-        } else if ($url_or_singlebutton instanceof moodle_url or is_string($url_or_singlebutton)) {
-            $button = new single_button($url_or_singlebutton, $label, $method, $options);
+    public function single_button($url, $label, $method='post', array $options=null) {
+        if ($url instanceof moodle_url) {
+            $button = new single_button($url, $label, $method);
+        } else if (is_string($url_or_singlebutton)) {
+            $button = new single_button(new moodle_url($url), $label, $method);
         } else {
-            throw new coding_exception('The $$url_or_singlebutton param to $OUTPUT->single_button() must be either a URL (string/moodle_url) or a single_button instance.');
+            throw new coding_exception('The $url param to $OUTPUT->single_button() must be either a string or moodle_url.');
+        }
+        foreach ((array)$options as $key=>$value) {
+            if (array_key_exists($key, $button)) {
+                $button->$key = $value;
+            }
         }
 
-        return $this->button($button);
+        return $this->render($button);
     }
 
     /**
-     * Given a html_form object, outputs an <input> tag within a form that uses the object's attributes.
-     *
-     * @param html_form $form A html_form object
+     * Internal implementation of single_button rendering
+     * @param single_button $button
      * @return string HTML fragment
      */
-    public function button(html_form $form) {
-        if (empty($form->button) or !($form->button instanceof html_button)) {
-            throw new coding_exception('$OUTPUT->button($form) requires $form to have a button (html_button) value');
+    protected function render_single_button(single_button $button) {
+        $attributes = array('type'     => 'submit',
+                            'value'    => $button->label,
+                            'disabled' => $button->disabled,
+                            'title'    => $button->tooltip);
+
+        if ($button->actions) {
+            $id = html_writer::random_id('single_button');
+            $attributes['id'] = $id;
+            foreach ($button->actions as $action) {
+                $this->add_action_handler($id, $action);
+            }
         }
-        $form = clone($form);
-        $form->button->prepare($this, $this->page, $this->target);
 
-        $this->prepare_event_handlers($form->button);
+        // first the input element
+        $output = html_writer::empty_tag('input', $attributes);
 
-        $buttonattributes = array('class' => $form->button->get_classes_string(),
-                                  'type' => 'submit',
-                                  'value' => $form->button->text,
-                                  'disabled' => $form->button->disabled,
-                                  'id' => $form->button->id);
+        // then hidden fields
+        $params = $button->url->params();
+        if ($button->method === 'post') {
+            $params['sesskey'] = sesskey();
+        }
+        foreach ($params as $var => $val) {
+            $output .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => $var, 'value' => $val));
+        }
 
-        $buttonoutput = html_writer::empty_tag('input', $buttonattributes);
+        // then div wrapper for xhtml strictness
+        $output = html_writer::tag('div', array(), $output);
 
-        // Removing the button so it doesn't get output again
-        unset($form->button);
+        // now the form itself around it
+        $attributes = array('method' => $button->method,
+                            'action' => $button->url->out(true), // url without params
+                            'id'     => $button->formid);
+        $output = html_writer::tag('form', $attributes, $output);
 
-        return html_writer::tag('div', array('class' => 'singlebutton'), $this->form($form, $buttonoutput));
+        // and finally one more wrapper with class
+        return html_writer::tag('div', array('class' => $button->class), $output);
     }
 
     /**
@@ -1435,11 +1447,8 @@ class core_renderer extends renderer_base {
         if (has_capability('moodle/course:manageactivities', get_context_instance(CONTEXT_MODULE, $cmid))) {
             $modulename = get_string('modulename', $modulename);
             $string = get_string('updatethis', '', $modulename);
-
-            $form = new html_form();
-            $form->url = new moodle_url("$CFG->wwwroot/course/mod.php", array('update' => $cmid, 'return' => true, 'sesskey' => sesskey()));
-            $form->button->text = $string;
-            return $this->button($form);
+            $url = new moodle_url("$CFG->wwwroot/course/mod.php", array('update' => $cmid, 'return' => true, 'sesskey' => sesskey()));
+            return $this->single_button($url, $string);
         } else {
             return '';
         }
@@ -1460,12 +1469,9 @@ class core_renderer extends renderer_base {
             $edit = '1';
         }
 
-        $form = new html_form();
-        $form->url = $url;
-        $form->url->param('edit', $edit);
-        $form->button->text = $string;
+        $url = new moodle_url($url, array('edit'=>$edit));
 
-        return $this->button($form);
+        return $this->single_button($url, $string);
     }
 
     /**
@@ -1538,21 +1544,17 @@ class core_renderer extends renderer_base {
     /**
      * Prints a simple button to close a window
      *
-     * @global objec)t
      * @param string $text The lang string for the button's label (already output from get_string())
-     * @return string|void if $return is true, void otherwise
+     * @return string html fragment
      */
     public function close_window_button($text='') {
         if (empty($text)) {
             $text = get_string('closewindow');
         }
-        $closeform = new html_form();
-        $closeform->url = '#';
-        $closeform->method = 'get';
-        $closeform->button->text = $text;
-        $closeform->button->add_action('click', 'close_window');
-        $closeform->button->prepare($this, $this->page, $this->target);
-        return $this->container($this->button($closeform), 'closewindow');
+        $button = new single_button($this->page->url.'#', $text, 'get');
+        $button->add_action('click', 'close_window');
+
+        return $this->container($this->render($button), 'closewindow');
     }
 
     /**
@@ -1931,20 +1933,17 @@ class core_renderer extends renderer_base {
     /**
      * Print a continue button that goes to a particular URL.
      *
-     * @param string|moodle_url $link The url the button goes to.
+     * @param string|moodle_url $url The url the button goes to.
      * @return string the HTML to output.
      */
-    public function continue_button($link) {
-        if (!is_a($link, 'moodle_url')) {
-            $link = new moodle_url($link);
+    public function continue_button($url) {
+        if (!($url instanceof moodle_url)) {
+            $url = new moodle_url($url);
         }
-        $form = new html_form();
-        $form->url = $link;
-        $form->values = $link->params();
-        $form->button->text = get_string('continue');
-        $form->method = 'get';
+        $button = new single_button($url, get_string('continue'), 'get');
+        $button->class = 'continuebutton';
 
-        return html_writer::tag('div', array('class' => 'continuebutton') , $this->button($form));
+        return $this->render($button);
     }
 
     /**
index c059c75570daaf2bc69f9820186e822a09f2bc44..d069a8be0cb90c5d5422193b57d902e5059cd943 100644 (file)
@@ -92,7 +92,8 @@ class lesson_page_type_branchtable extends lesson_page {
             $params['pageid'] = $this->properties->id;
             $params['sesskey'] = sesskey();
             $params['jumpto'] = $answer->jumpto;
-            $buttons[] = $renderer->button(new single_button(new moodle_url($CFG->wwwroot.'/mod/lesson/continue.php', $params), strip_tags(format_text($answer->answer, FORMAT_MOODLE, $options))));
+            $url = new moodle_url($CFG->wwwroot.'/mod/lesson/continue.php', $params);
+            $buttons[] = $renderer->single_button($url, strip_tags(format_text($answer->answer, FORMAT_MOODLE, $options)));
             $i++;
         }
         // Set the orientation
index 35e144bf0fd2c29f6d3c088ed942cdc9481c91bc..dc99d9e4a9ba302995cbdc112ffa88e44cd63051 100644 (file)
@@ -140,11 +140,11 @@ class mod_lesson_renderer extends plugin_renderer_base {
      * @param html_form $button
      * @return string
      */
-    public function message($message, html_form $button = null) {
+    public function message($message, single_button $button = null) {
         $output  = $this->output->box_start('generalbox boxaligncenter');
         $output .= $message;
         if ($button !== null) {
-            $output .= $this->output->box($this->output->button($button),'lessonbutton standardbutton');
+            $output .= $this->output->box($this->output->render($button), 'lessonbutton standardbutton');
         }
         $output .= $this->output->box_end();
         return $output;
index 21a9df77cffa2af003b336c1730fb9bac621f0c4..c5bee922cb8593a001c20fecfebc51053173c844 100644 (file)
@@ -220,11 +220,11 @@ class quiz_access_manager {
         if ($this->securewindow_required($canpreview)) {
             $this->_securewindowrule->print_start_attempt_button($buttontext, $strconfirmstartattempt);
         } else {
-            $form = new single_button(new moodle_url($this->_quizobj->start_attempt_url(), array('cmid' => $this->_quizobj->get_cmid())), $buttontext);
+            $button = new single_button(new moodle_url($this->_quizobj->start_attempt_url(), array('cmid' => $this->_quizobj->get_cmid())), $buttontext);
             if ($strconfirmstartattempt) {
-                $form->button->add_confirm_action($strconfirmstartattempt);
+                $button->add_confirm_action($strconfirmstartattempt);
             }
-            echo $OUTPUT->single_button($form);
+            echo $OUTPUT->render($button);
         }
         echo "</div>\n";
     }
@@ -745,9 +745,9 @@ class securewindow_access_rule extends quiz_access_rule_base {
      */
     public function make_review_link($linktext, $attemptid) {
         global $OUTPUT;
-        $form = new single_button($this->_quizobj->review_url($attemptid), $linktext);
-        $form->button->add_action(new popup_action('click', $form->url, 'quizpopup', $this->windowoptions));
-        return $OUTPUT->single_button($form);
+        $button = new single_button($this->_quizobj->review_url($attemptid), $linktext);
+        $button->add_action(new popup_action('click', $form->url, 'quizpopup', $this->windowoptions));
+        return $OUTPUT->render($button);
     }
 
     /**
index 4cc204538c13b6252594d0a21540e86ff0b794e0..a8888fac4519ce41cc9d40dacfa0772293aadd53 100644 (file)
@@ -124,11 +124,11 @@ $options = array(
     'sesskey' => sesskey(),
 );
 
-$form = new single_button(new moodle_url($attemptobj->processattempt_url(), $options), get_string('finishattempt', 'quiz'));
-$form->id = 'responseform';
-$form->button->add_confirm_action(get_string('confirmclose', 'quiz'));
+$button = new single_button(new moodle_url($attemptobj->processattempt_url(), $options), get_string('finishattempt', 'quiz'));
+$button->id = 'responseform';
+$button->add_confirm_action(get_string('confirmclose', 'quiz'));
 
-echo $OUTPUT->single_button($form);
+echo $OUTPUT->render($button);
 echo $OUTPUT->container_end();
 
 /// Finish the page
index 6ff3fe267d6f8c865588ef834f0926309f0e7108..ea81781937ea3e73ebaaff25b293f6c91fa169b5 100644 (file)
@@ -184,12 +184,8 @@ class workshop_manual_allocator implements workshop_allocator {
                 break;
             }
             if ($m[0] == self::MSG_CONFIRM_DEL) {
-                $form = new html_form();
-                $form->url = new moodle_url($PAGE->url, array('mode' => 'del', 'what' => $m[1], 'confirm' => 1));
-                $form->button = new html_button();
-                $form->button->text = get_string('iamsure', 'workshop');
-                $form->method = 'post';
-                $msg->extra = $OUTPUT->button($form);
+                $aurl = new moodle_url($PAGE->url, array('mode' => 'del', 'what' => $m[1], 'confirm' => 1));
+                $msg->extra = $OUTPUT->single_button($url, get_string('iamsure', 'workshop'), 'post');
             }
         }
 
index 44e97e949e51a8f3d743a49e4a04faaaccfe809c..628bfec92d041ac23368b3e2fb442212e42fe8d8 100644 (file)
@@ -96,11 +96,8 @@ if ($isreviewer) {
 $mformassessment->display();
 echo $OUTPUT->container_start('buttonsbar');
 if ($isreviewer and $workshop->assessing_examples_allowed()) {
-    $button                 = new html_form();
-    $button->method         = 'get';
-    $button->button->text   = get_string('reassess', 'workshop');
-    $button->url            = new moodle_url($workshop->exsubmission_url($example->id), array('assess' => 'on', 'sesskey' => sesskey()));
-    echo $OUTPUT->button($button);
+    $aurl = new moodle_url($workshop->exsubmission_url($example->id), array('assess' => 'on', 'sesskey' => sesskey()));
+    echo $OUTPUT->single_button($aurl, get_string('reassess', 'workshop'), 'get');
 }
 echo $OUTPUT->container_end(); // buttonsbar
 
index fd2645c5c9a0c3c65ced71e3d06044a2eb198dec..3f5d5c1f082f34ce8ac7f348de510f0deb02e664 100644 (file)
@@ -184,26 +184,17 @@ if ($example->id) {
 echo $OUTPUT->container_start('buttonsbar');
 if ($canmanage) {
     if (empty($edit) and empty($delete)) {
-        $button                 = new html_form();
-        $button->method         = 'get';
-        $button->button->text   = get_string('exampleedit', 'workshop');
-        $button->url            = new moodle_url($workshop->exsubmission_url($example->id), array('edit' => 'on'));
-        echo $OUTPUT->button($button);
-
-        $button                 = new html_form();
-        $button->method         = 'get';
-        $button->button->text   = get_string('exampledelete', 'workshop');
-        $button->url            = new moodle_url($workshop->exsubmission_url($example->id), array('delete' => 'on'));
-        echo $OUTPUT->button($button);
+        $aurl = new moodle_url($workshop->exsubmission_url($example->id), array('edit' => 'on'));
+        echo $OUTPUT->single_button($aurl, get_string('exampleedit', 'workshop'), 'get');
+
+        $aurl = new moodle_url($workshop->exsubmission_url($example->id), array('delete' => 'on'));
+        echo $OUTPUT->single_button($aurl, get_string('exampledelete', 'workshop'), 'get');
     }
 }
 // ...and optionally assess it
 if ($canassess or ($canmanage and empty($edit) and empty($delete))) {
-    $button                 = new html_form();
-    $button->method         = 'get';
-    $button->button->text   = get_string('exampleassess', 'workshop');
-    $button->url            = new moodle_url($workshop->exsubmission_url($example->id), array('assess' => 'on', 'sesskey' => sesskey()));
-    echo $OUTPUT->button($button);
+    $aurl = new moodle_url($workshop->exsubmission_url($example->id), array('assess' => 'on', 'sesskey' => sesskey()));
+    echo $OUTPUT->single_button($aurl, get_string('exampleassess', 'workshop'), 'get');
 }
 echo $OUTPUT->container_end(); // buttonsbar
 // and possibly display the example's review(s) - todo
index a73ec6022b6f397805d16cf1e34613c12d60d283..9b7c562c7c40c4223f04a5a36ff4f848e4447aa1 100644 (file)
@@ -573,10 +573,8 @@ class workshop {
         $summary->gradeinfo->received = $this->real_grade($example->grade);
         $summary->gradeinfo->max      = $this->real_grade(100);
 
-        $summary->btnform = new html_form();
-        $summary->btnform->method       = 'get';
-        $summary->btnform->button->text = $buttontext;
-        $summary->btnform->url          = new moodle_url($this->exsubmission_url($example->id), array('assess' => 'on', 'sesskey' => sesskey()));
+        $aurl = new moodle_url($this->exsubmission_url($example->id), array('assess' => 'on', 'sesskey' => sesskey()));
+        $summary->btnform = new single_button($aurl, $buttontext, 'get');
 
         return $summary;
     }
index 0bf58841d7c0d49c49e5d27df5b21a9d7d47b622..eb10e6265f321fd202906d895ba6d9849b17fa82 100644 (file)
@@ -320,7 +320,7 @@ class mod_workshop_renderer extends plugin_renderer_base {
         }
 
         // button to assess
-        $o .= $this->output->container($this->output->button($summary->btnform), 'example-actions');
+        $o .= $this->output->container($this->output->render($summary->btnform), 'example-actions');
 
         // end of wrapping box
         $o .= $this->output->box_end();
index 465cf4cd9e77523ae6e75d995257851cb8004c2d..971e63bc5cafc0156e3b0f127dbf58d8ed2f3f85 100644 (file)
@@ -171,11 +171,8 @@ if ($submission->id) {
 }
 
 if ($ownsubmission and $editable) {
-    $editbutton                 = new html_form();
-    $editbutton->method         = 'get';
-    $editbutton->button->text   = get_string('editsubmission', 'workshop');
-    $editbutton->url            = new moodle_url($PAGE->url, array('edit' => 'on', 'id' => $submission->id));
-    echo $OUTPUT->button($editbutton);
+    $url = new moodle_url($PAGE->url, array('edit' => 'on', 'id' => $submission->id));
+    echo $OUTPUT->sinle_button($url, get_string('editsubmission', 'workshop'), 'get');
 }
 
 // and possibly display the submission's review(s)
index aceb5d4d8ea6f886d8611c57a3b6a649cb7b4c69..5a093c7d295f5fc4530dde5465f6ca2b9bc8ab79 100644 (file)
@@ -84,11 +84,8 @@ case workshop::PHASE_SETUP:
                 $summary = $workshop->prepare_example_summary($example);
                 echo $wsoutput->example_summary($summary);
             }
-            $editbutton                 = new html_form();
-            $editbutton->method         = 'get';
-            $editbutton->button->text   = get_string('exampleadd', 'workshop');
-            $editbutton->url            = new moodle_url($workshop->exsubmission_url(0), array('edit' => 'on'));
-            echo $OUTPUT->button($editbutton);
+            $aurl = new moodle_url($workshop->exsubmission_url(0), array('edit' => 'on'));
+            echo $OUTPUT->single_button($aurl, get_string('exampleadd', 'workshop'), 'get');
         } else {
             echo $OUTPUT->container(get_string('noexamplesformready', 'workshop'));
         }
@@ -151,11 +148,8 @@ case workshop::PHASE_SUBMISSION:
             echo $OUTPUT->container(get_string('noyoursubmission', 'workshop'));
         }
         if ($workshop->submitting_allowed()) {
-            $editbutton                 = new html_form();
-            $editbutton->method         = 'get';
-            $editbutton->button->text   = get_string('editsubmission', 'workshop');
-            $editbutton->url            = new moodle_url($workshop->submission_url(), array('edit' => 'on'));
-            echo $OUTPUT->button($editbutton);
+            $aurl = new moodle_url($workshop->submission_url(), array('edit' => 'on'));
+            echo $OUTPUT->single_button($aurl, get_string('editsubmission', 'workshop'), 'get');
         }
         echo $OUTPUT->box_end();
         print_collapsible_region_end();
@@ -249,11 +243,8 @@ case workshop::PHASE_ASSESSMENT:
             }
             echo $OUTPUT->box_start('generalbox assessment-summary' . $class);
             echo $wsoutput->submission_summary($submission, $shownames);
-            $button = new html_form();
-            $button->method         = 'get';
-            $button->button->text   = $buttontext;
-            $button->url            = $workshop->assess_url($assessment->id);
-            echo $OUTPUT->button($button);
+            $aurl = $workshop->assess_url($assessment->id);
+            echo $OUTPUT->single_button($aurl, $buttontext, 'get');
             echo $OUTPUT->box_end();
         }
     }
index ec0c9293f01918f79f617870e13817be98dee49b..b81975ea7f4884129f9a9c9f25d6691cc90daa0a 100644 (file)
@@ -95,9 +95,10 @@ if (!empty($dataid)) {
             $exporter->print_header('confirmcancel');
             echo $OUTPUT->box_start();
             $yesbutton = new single_button(new moodle_url($CFG->wwwroot . '/portfolio/add.php', array('id' => $dataid, 'cancel' => 1, 'cancelsure' => 1, 'logreturn' => $logreturn)). get_string('yes'));
-            $nobutton  = new single_button(new moodle_url($CFG->wwwroot . '/portfolio/add.php', array('id' => $dataid)), get_string('no'));
             if ($logreturn) {
-                $nobutton->url = $CFG->wwwroot . '/user/portfoliologs.php';
+                $nobutton  = new single_button(new moodle_url($CFG->wwwroot . '/user/portfoliologs.php', array('id' => $dataid)), get_string('no'));
+            } else {
+                $nobutton  = new single_button(new moodle_url($CFG->wwwroot . '/portfolio/add.php', array('id' => $dataid)), get_string('no'));
             }
             echo $OUTPUT->confirm(get_string('confirmcancel', 'portfolio'), $yesbutton, $nobutton);
             echo $OUTPUT->box_end();