From: Petr Skoda Date: Thu, 14 Jan 2010 19:18:04 +0000 (+0000) Subject: MDL-21235 new single button rendering X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=3ba60ee16a0537396534b0a05ba570da3b8d93d7;p=moodle.git MDL-21235 new single button rendering --- diff --git a/admin/delete.php b/admin/delete.php index 6f7f86d341..090ecf490c 100644 --- a/admin/delete.php +++ b/admin/delete.php @@ -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); diff --git a/grade/edit/tree/index.php b/grade/edit/tree/index.php index d35bafad4b..f9cee5e0a6 100644 --- a/grade/edit/tree/index.php +++ b/grade/edit/tree/index.php @@ -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; diff --git a/lib/outputcomponents.php b/lib/outputcomponents.php index fb077b2ab2..03fabb3bdb 100644 --- a/lib/outputcomponents.php +++ b/lib/outputcomponents.php @@ -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']; - } - } } diff --git a/lib/outputrenderers.php b/lib/outputrenderers.php index 2cd5f6e180..4d7f76a76d 100644 --- a/lib/outputrenderers.php +++ b/lib/outputrenderers.php @@ -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 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); } /** diff --git a/mod/lesson/pagetypes/branchtable.php b/mod/lesson/pagetypes/branchtable.php index c059c75570..d069a8be0c 100644 --- a/mod/lesson/pagetypes/branchtable.php +++ b/mod/lesson/pagetypes/branchtable.php @@ -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 diff --git a/mod/lesson/renderer.php b/mod/lesson/renderer.php index 35e144bf0f..dc99d9e4a9 100644 --- a/mod/lesson/renderer.php +++ b/mod/lesson/renderer.php @@ -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; diff --git a/mod/quiz/accessrules.php b/mod/quiz/accessrules.php index 21a9df77cf..c5bee922cb 100644 --- a/mod/quiz/accessrules.php +++ b/mod/quiz/accessrules.php @@ -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 "\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); } /** diff --git a/mod/quiz/summary.php b/mod/quiz/summary.php index 4cc204538c..a8888fac45 100644 --- a/mod/quiz/summary.php +++ b/mod/quiz/summary.php @@ -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 diff --git a/mod/workshop/allocation/manual/lib.php b/mod/workshop/allocation/manual/lib.php index 6ff3fe267d..ea81781937 100644 --- a/mod/workshop/allocation/manual/lib.php +++ b/mod/workshop/allocation/manual/lib.php @@ -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'); } } diff --git a/mod/workshop/excompare.php b/mod/workshop/excompare.php index 44e97e949e..628bfec92d 100644 --- a/mod/workshop/excompare.php +++ b/mod/workshop/excompare.php @@ -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 diff --git a/mod/workshop/exsubmission.php b/mod/workshop/exsubmission.php index fd2645c5c9..3f5d5c1f08 100644 --- a/mod/workshop/exsubmission.php +++ b/mod/workshop/exsubmission.php @@ -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 diff --git a/mod/workshop/locallib.php b/mod/workshop/locallib.php index a73ec6022b..9b7c562c7c 100644 --- a/mod/workshop/locallib.php +++ b/mod/workshop/locallib.php @@ -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; } diff --git a/mod/workshop/renderer.php b/mod/workshop/renderer.php index 0bf58841d7..eb10e6265f 100644 --- a/mod/workshop/renderer.php +++ b/mod/workshop/renderer.php @@ -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(); diff --git a/mod/workshop/submission.php b/mod/workshop/submission.php index 465cf4cd9e..971e63bc5c 100644 --- a/mod/workshop/submission.php +++ b/mod/workshop/submission.php @@ -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) diff --git a/mod/workshop/view.php b/mod/workshop/view.php index aceb5d4d8e..5a093c7d29 100644 --- a/mod/workshop/view.php +++ b/mod/workshop/view.php @@ -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(); } } diff --git a/portfolio/add.php b/portfolio/add.php index ec0c9293f0..b81975ea7f 100644 --- a/portfolio/add.php +++ b/portfolio/add.php @@ -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();