From 5c2ed7e2156dbd73cd81bcda6892bccebe177369 Mon Sep 17 00:00:00 2001 From: Petr Skoda Date: Sun, 3 Jan 2010 15:46:14 +0000 Subject: [PATCH] MDL-21198 $OUTPUT->single_button() resurrection, hopefully much easier to use than $OUTPUT->button(); fixed some regressions and code style improvements --- admin/mnet/mnet_themes.html | 4 ++-- admin/roles/define.php | 10 +++++----- admin/roles/manage.php | 2 +- admin/settings.php | 8 ++++---- admin/webservice/service_functions.php | 14 ++++--------- backup/restore_check.html | 2 +- backup/restorelib.php | 2 +- blocks/rss_client/managefeeds.php | 8 ++------ calendar/delete.php | 17 +++++----------- calendar/view.php | 2 +- course/category.php | 8 ++++---- course/index.php | 16 ++++----------- course/lib.php | 13 ++++++------ course/pending.php | 8 ++++---- course/search.php | 9 +++------ enrol/authorize/enrol.php | 4 ++-- enrol/manual/enrol.html | 2 +- grade/edit/outcome/import.php | 6 +++--- grade/edit/outcome/index.php | 7 +++---- grade/edit/scale/index.php | 2 +- grade/edit/tree/index.php | 10 +++++----- grade/export/keymanager.php | 2 +- grade/export/lib.php | 5 ++--- grade/import/keymanager.php | 2 +- grade/report/grader/index.php | 2 +- group/groupings.php | 2 +- lib/adminlib.php | 4 +++- lib/deprecatedlib.php | 14 ++++++------- lib/outputrenderers.php | 16 ++++++++++----- .../filtersettingsperformancetester.php | 15 ++++++-------- lib/weblib.php | 2 +- login/confirm.php | 4 ++-- message/lib.php | 4 ++-- .../type/online/assignment.class.php | 3 +-- .../type/upload/assignment.class.php | 6 +++--- mod/choice/report.php | 6 +++--- mod/choice/view.php | 2 +- mod/data/preset.php | 4 ++-- mod/feedback/analysis.php | 6 ++---- mod/feedback/analysis_course.php | 6 ++---- mod/feedback/import.php | 9 ++------- mod/feedback/show_entries.php | 18 ++++++----------- mod/forum/index.php | 20 ++++++------------- mod/forum/lib.php | 10 ++++------ mod/glossary/editcategories.php | 6 +++--- mod/glossary/lib.php | 2 +- mod/hotpot/review.php | 6 +++--- mod/lesson/continue.php | 9 ++++----- mod/lesson/locallib.php | 7 +++---- mod/lesson/view.php | 5 ++--- mod/quiz/accessrules.php | 4 ++-- mod/quiz/attemptlib.php | 4 ++-- mod/quiz/editlib.php | 11 ++-------- mod/quiz/lib.php | 4 ++-- mod/quiz/report/statistics/report.php | 4 ++-- mod/quiz/summary.php | 2 +- mod/survey/report.php | 6 +++--- my/index.php | 6 ++---- question/editlib.php | 6 ++---- theme/index.php | 4 ++-- user/profile/index.php | 2 +- webservice/renderer.php | 9 ++------- 62 files changed, 170 insertions(+), 243 deletions(-) diff --git a/admin/mnet/mnet_themes.html b/admin/mnet/mnet_themes.html index a18e4db05a08b..d105458a2af5f 100644 --- a/admin/mnet/mnet_themes.html +++ b/admin/mnet/mnet_themes.html @@ -38,7 +38,7 @@ $options['choose'] = $unlikely_name;// Something unlikely to ever be a theme name... initially $unlikely_name = 'ZoqZoqZ'; $options['sesskey'] = $sesskey; $options['hostid'] = $mnet_peer->id; - echo $OUTPUT->button(html_form::make_button('mnet_themes.php', $options, $strchoose)); + echo $OUTPUT->single_button(new moodle_url('mnet_themes.php', $options), $strchoose); echo ''; echo ""; @@ -111,7 +111,7 @@ $options['choose'] = $theme; $options['sesskey'] = $sesskey; $options['hostid'] = $mnet_peer->id; - echo $OUTPUT->button(html_form::make_button('mnet_themes.php', $options, $strchoose)); + echo $OUTPUT->single_button(new moodle_url('mnet_themes.php', $options), $strchoose); echo ''; echo ""; } diff --git a/admin/roles/define.php b/admin/roles/define.php index ec8c49f854df1..65f6911b67fb2 100755 --- a/admin/roles/define.php +++ b/admin/roles/define.php @@ -135,16 +135,16 @@ $options = array(); $options['roleid'] = $roleid; $options['action'] = 'edit'; - echo $OUTPUT->button(html_form::make_button($defineurl, $options, get_string('edit'))); + echo $OUTPUT->single_button(new moodle_url($defineurl, $options), get_string('edit')); $options['action'] = 'reset'; if ($definitiontable->get_legacy_type()) { - echo $OUTPUT->button(html_form::make_button($manageurl, $options, get_string('resetrole', 'role'))); + echo $OUTPUT->single_button(new moodle_url($manageurl, $options), get_string('resetrole', 'role')); } else { - echo $OUTPUT->button(html_form::make_button($manageurl, $options, get_string('resetrolenolegacy', 'role'))); + echo $OUTPUT->single_button(new moodle_url($manageurl, $options), get_string('resetrolenolegacy', 'role')); } $options['action'] = 'duplicate'; - echo $OUTPUT->button(html_form::make_button($defineurl, $options, get_string('duplicaterole', 'role'))); - echo $OUTPUT->button(html_form::make_button($manageurl, null, get_string('listallroles', 'role'))); + echo $OUTPUT->single_button(new moodle_url($defineurl, $options), get_string('duplicaterole', 'role')); + echo $OUTPUT->single_button(new moodle_url($manageurl), get_string('listallroles', 'role')); echo $OUTPUT->container_end(); } diff --git a/admin/roles/manage.php b/admin/roles/manage.php index e13f9320a68c1..ed160fae539e2 100755 --- a/admin/roles/manage.php +++ b/admin/roles/manage.php @@ -265,7 +265,7 @@ echo $OUTPUT->table($table); echo $OUTPUT->container_start('buttons'); - echo $OUTPUT->button(html_form::make_button($defineurl, array('action' => 'add'), get_string('addrole', 'role'), 'get')); + echo $OUTPUT->single_button(new moodle_url($defineurl, array('action' => 'add')), get_string('addrole', 'role'), 'get'); echo $OUTPUT->container_end(); echo $OUTPUT->footer(); diff --git a/admin/settings.php b/admin/settings.php index cba9c55bade8d..c8a4bd6aea8a9 100644 --- a/admin/settings.php +++ b/admin/settings.php @@ -90,15 +90,15 @@ } else { if ($PAGE->user_allowed_editing()) { - $options = $PAGE->url->params(); + $url = clone($PAGE->url); if ($PAGE->user_is_editing()) { $caption = get_string('blockseditoff'); - $options['adminedit'] = 'off'; + $url->param('adminedit', 'off'); } else { $caption = get_string('blocksediton'); - $options['adminedit'] = 'on'; + $url->param('adminedit', 'on'); } - $buttons = $OUTPUT->button(html_form::make_button($PAGE->url->out(), $options, $caption, 'get')); + $buttons = $OUTPUT->single_button($url, $caption, 'get'); } $visiblepathtosection = array_reverse($settingspage->visiblepath); diff --git a/admin/webservice/service_functions.php b/admin/webservice/service_functions.php index ecce2ce78435c..f2153a4f5ec68 100644 --- a/admin/webservice/service_functions.php +++ b/admin/webservice/service_functions.php @@ -130,19 +130,13 @@ // we can edit only custom functions, the build-in would be overridden after each upgrade if (empty($service->component)) { - $form = new html_form(); - $form->url = new moodle_url('service_functions.php', array('sesskey'=>sesskey(), 'id'=>$service->id, 'action'=>'add')); - $form->button->text = get_string('add'); - $form->method = 'get'; - echo $OUTPUT->button($form); + $url = new moodle_url('service_functions.php', array('sesskey'=>sesskey(), 'id'=>$service->id, 'action'=>'add')); + echo $OUTPUT->single_button($url, get_string('add'), 'get'); } // simple back button -$form = new html_form(); -$form->url = new moodle_url('../settings.php', array('section'=>'externalservices')); -$form->button->text = get_string('back'); -$form->method = 'get'; -echo $OUTPUT->button($form); +$url = new moodle_url('../settings.php', array('section'=>'externalservices')); +echo $OUTPUT->single_button($url, get_string('back'), 'get'); echo $OUTPUT->footer(); diff --git a/backup/restore_check.html b/backup/restore_check.html index a97933def7194..0d620004ab1a1 100644 --- a/backup/restore_check.html +++ b/backup/restore_check.html @@ -401,7 +401,7 @@ /// Restore button - echo $OUTPUT->button(html_form::make_button("restore.php", $hidden, get_string("restorecoursenow"))); + echo $OUTPUT->single_button(new moodle_url("restore.php", $hidden), get_string("restorecoursenow")); } echo ""; diff --git a/backup/restorelib.php b/backup/restorelib.php index aac97521edcf6..d389d4aebb5ab 100644 --- a/backup/restorelib.php +++ b/backup/restorelib.php @@ -8296,7 +8296,7 @@ function restore_precheck($id,$file,&$errorstr,$noredirect=false) { $hidden["launch"] = "form"; $hidden["file"] = $file; $hidden["id"] = $id; - echo $OUTPUT->button(html_form::make_button("restore.php", $hidden, get_string("continue"))); + echo $OUTPUT->single_button(new moodle_url("restore.php", $hidden), get_string("continue")); echo ""; } else { diff --git a/blocks/rss_client/managefeeds.php b/blocks/rss_client/managefeeds.php index 650b41feb0787..4a7f7580341e0 100644 --- a/blocks/rss_client/managefeeds.php +++ b/blocks/rss_client/managefeeds.php @@ -132,12 +132,8 @@ $table->print_html(); -$button = new html_form(); -$button->method = 'get'; -$button->url = $CFG->wwwroot . '/blocks/rss_client/editfeed.php?' . substr($extraparams, 1); -$button->showbutton = true; -$button->button->text = get_string('addnewfeed', 'block_rss_client'); -echo '
' . $OUTPUT->button($button) . '
'; +$url = $CFG->wwwroot . '/blocks/rss_client/editfeed.php?' . substr($extraparams, 1); +echo '
' . $OUTPUT->single_button($url, get_string('addnewfeed', 'block_rss_client'), 'get') . '
'; if ($returnurl) { diff --git a/calendar/delete.php b/calendar/delete.php index c92ed08db579e..f8336ad0665e2 100644 --- a/calendar/delete.php +++ b/calendar/delete.php @@ -100,26 +100,19 @@ echo $OUTPUT->box_start('eventlist'); // Delete this event button is always shown -$deleteone = new html_form(); -$deleteone->button->text = get_string('delete'); -$deleteone->url = new moodle_url(CALENDAR_URL.'delete.php', array('id'=>$event->id, 'confirm'=>true)); -$buttons = $OUTPUT->button($deleteone); +$url = new moodle_url(CALENDAR_URL.'delete.php', array('id'=>$event->id, 'confirm'=>true)); +$buttons = $OUTPUT->single_button($url, get_string('delete')); // If there are repeated events then add a Delete Repeated button $repeatspan = ''; if (!empty($event->eventrepeats) && $event->eventrepeats > 0) { - $deleteall = new html_form(); - $deleteall->button->text = get_string('deleteall'); - $deleteall->url = new moodle_url(CALENDAR_URL.'delete.php', array('id'=>$event->repeatid, 'confirm'=>true, 'repeats'=>true)); - $buttons .= $OUTPUT->button($deleteall); + $url = new moodle_url(CALENDAR_URL.'delete.php', array('id'=>$event->repeatid, 'confirm'=>true, 'repeats'=>true)); + $buttons .= $OUTPUT->single_button($url, get_string('deleteall')); $repeatspan = '

'.$OUTPUT->span(get_string('youcandeleteallrepeats', 'calendar')); } // And add the cancel button -$cancel = new html_form(); -$cancel->button->text = get_string('cancel'); -$cancel->url = $viewcalendarurl; -$buttons .= $OUTPUT->button($cancel); +$buttons .= $OUTPUT->single_button($viewcalendarurl, get_string('cancel')); // And show the buttons and notes echo $OUTPUT->box_start('generalbox', 'notice'); diff --git a/calendar/view.php b/calendar/view.php index da79b2812fb19..127b4f316d5e6 100644 --- a/calendar/view.php +++ b/calendar/view.php @@ -183,7 +183,7 @@ //Link to calendar export page echo $OUTPUT->container_start('bottom'); if (!empty($CFG->enablecalendarexport)) { - echo $OUTPUT->button(html_form::make_button('export.php', array('course'=>$courseid), get_string('exportcalendar', 'calendar'))); + echo $OUTPUT->single_button(new moodle_url('export.php', array('course'=>$courseid)), get_string('exportcalendar', 'calendar')); if (!empty($USER->id)) { $authtoken = sha1($USER->username . $USER->password . $CFG->calendar_exportsalt); diff --git a/course/category.php b/course/category.php index 37dcc6d75ec4e..f64e6d1b25fe8 100644 --- a/course/category.php +++ b/course/category.php @@ -207,11 +207,11 @@ // Print button to update this category $options = array('id' => $category->id); - echo $OUTPUT->button(html_form::make_button($CFG->wwwroot.'/course/editcategory.php', $options, get_string('editcategorythis'), 'get')); + echo $OUTPUT->single_button(new moodle_url($CFG->wwwroot.'/course/editcategory.php', $options), get_string('editcategorythis'), 'get'); // Print button for creating new categories $options = array('parent' => $category->id); - echo $OUTPUT->button(html_form::make_button($CFG->wwwroot.'/course/editcategory.php', $options, get_string('addsubcategory'), 'get')); + echo $OUTPUT->single_button(new moodle_url($CFG->wwwroot.'/course/editcategory.php', $options), get_string('addsubcategory'), 'get'); echo $OUTPUT->container_end(); } @@ -451,14 +451,14 @@ $options['id'] = $category->id; $options['resort'] = 'name'; $options['sesskey'] = sesskey(); - echo $OUTPUT->button(html_form::make_button('category.php', $options, get_string('resortcoursesbyname'), 'get')); + echo $OUTPUT->single_button(new moodle_url('category.php', $options), get_string('resortcoursesbyname'), 'get'); } if (has_capability('moodle/course:create', $context)) { /// Print button to create a new course unset($options); $options['category'] = $category->id; - echo $OUTPUT->button(html_form::make_button('edit.php', $options, get_string('addnewcourse'), 'get')); + echo $OUTPUT->single_button(new moodle_url('edit.php', $options), get_string('addnewcourse'), 'get'); } if (!empty($CFG->enablecourserequests) && $category->id == $CFG->enablecourserequests) { diff --git a/course/index.php b/course/index.php index 895feba4578f4..266cc20760886 100644 --- a/course/index.php +++ b/course/index.php @@ -103,9 +103,7 @@ /// Print link to create a new course /// Get the 1st available category $options = array('category' => $CFG->defaultrequestcategory); - $form = html_form::make_button('edit.php', $options, get_string('addnewcourse')); - $form->method = 'get'; - echo $OUTPUT->button($form); + echo $OUTPUT->single_button(new moodle_url('edit.php', $options), get_string('addnewcourse'), 'get'); } print_course_request_buttons($systemcontext); echo $OUTPUT->container_end(); @@ -265,20 +263,14 @@ echo '
'; if (has_capability('moodle/course:create', $systemcontext)) { // print create course link to first category - $options = array(); $options = array('category' => $CFG->defaultrequestcategory); - $form = html_form::make_button('edit.php', $options, get_string('addnewcourse')); - $form->method = 'get'; - echo $OUTPUT->button($form); + echo $OUTPUT->single_button(new moodle_url('edit.php', $options), get_string('addnewcourse'), 'get'); } // Print button for creating new categories if (has_capability('moodle/category:manage', $systemcontext)) { - $options = array(); - $options['parent'] = 0; - $form = html_form::make_button('editcategory.php', $options, get_string('addnewcategory')); - $form->method = 'get'; - echo $OUTPUT->button($form); + $options = array('parent'=>0); + echo $OUTPUT->single_button(new moodle_url('editcategory.php', $options), get_string('addnewcategory'), 'get'); } print_course_request_buttons($systemcontext); diff --git a/course/lib.php b/course/lib.php index 9c260cea5f10e..a546bd09db401 100644 --- a/course/lib.php +++ b/course/lib.php @@ -2047,13 +2047,12 @@ function print_course_request_buttons($systemcontext) { } if (isloggedin() && !isguestuser() && !has_capability('moodle/course:create', $systemcontext) && has_capability('moodle/course:request', $systemcontext)) { /// Print a button to request a new course - echo $OUTPUT->button(html_form::make_button('request.php', NULL, get_string('requestcourse'), 'get')); + echo $OUTPUT->single_button('request.php', get_string('requestcourse'), 'get'); } /// Print a button to manage pending requests if (has_capability('moodle/site:approvecourse', $systemcontext)) { - $form = html_form::make_button('pending.php', NULL, get_string('coursespending'), 'get'); - $form->button->disabled = !$DB->record_exists('course_request', array()); - echo $OUTPUT->button($form); + $disabled = !$DB->record_exists('course_request', array()); + echo $OUTPUT->single_button('pending.php', get_string('coursespending'), 'get', array('disabled'=>$disabled)); } } @@ -2100,7 +2099,7 @@ function update_category_button($categoryid = 0) { } else { $page = 'index.php'; } - return $OUTPUT->button(html_form::make_button($CFG->wwwroot . '/course/' . $page, $options, $label, 'get')); + return $OUTPUT->single_button(new moodle_url($CFG->wwwroot . '/course/' . $page, $options), $label, 'get'); } /** @@ -2146,7 +2145,7 @@ function print_courses($category) { $options = array(); $options['category'] = $category->id; echo '
'; - echo $OUTPUT->button(html_form::make_button($CFG->wwwroot.'/course/edit.php', $options, get_string("addnewcourse"))); + echo $OUTPUT->single_button(new moodle_url($CFG->wwwroot.'/course/edit.php', $options), get_string("addnewcourse")); echo '
'; } } @@ -2324,7 +2323,7 @@ function print_my_moodle() { echo "
"; print_course_search("", false, "short"); echo ""; - echo $OUTPUT->button(html_form::make_button("$CFG->wwwroot/course/index.php", NULL, get_string("fulllistofcourses"), "get")); + echo $OUTPUT->single_button("$CFG->wwwroot/course/index.php", get_string("fulllistofcourses"), "get"); echo "
\n"; } diff --git a/course/pending.php b/course/pending.php index 3a6ff80e4e84b..38d03bdc3cfe3 100644 --- a/course/pending.php +++ b/course/pending.php @@ -106,7 +106,7 @@ $strrequireskey = get_string('requireskey'); // Loop over requested courses. - $keyicon = $OUTPUT->image('y/key', array('alt'=>$strrequireskey, 'class'=>'icon')); + $keyicon = $OUTPUT->image('i/key', array('alt'=>$strrequireskey, 'class'=>'icon')); foreach ($pending as $course) { $course = new course_request($course); @@ -127,8 +127,8 @@ $row[] = fullname($course->get_requester()); $row[] = $course->summary; $row[] = format_string($course->reason); - $row[] = $OUTPUT->button(html_form::make_button($baseurl, array('approve' => $course->id, 'sesskey' => sesskey()), get_string('approve'), 'get')) . - $OUTPUT->button(html_form::make_button($baseurl, array('reject' => $course->id), get_string('rejectdots'), 'get')); + $row[] = $OUTPUT->single_button(new moodle_url($baseurl, array('approve' => $course->id, 'sesskey' => sesskey())), get_string('approve'), 'get') . + $OUTPUT->single_button(new moodle_url($baseurl, array('reject' => $course->id)), get_string('rejectdots'), 'get'); /// Add the row to the table. $table->data[] = $row; @@ -144,5 +144,5 @@ } /// Finish off the page. -echo $OUTPUT->button(html_form::make_button($CFG->wwwroot . '/course/index.php', array(), get_string('backtocourselisting'))); +echo $OUTPUT->single_button($CFG->wwwroot . '/course/index.php', get_string('backtocourselisting')); echo $OUTPUT->footer(); \ No newline at end of file diff --git a/course/search.php b/course/search.php index 66053e439486e..4cb70f3cfb412 100644 --- a/course/search.php +++ b/course/search.php @@ -188,16 +188,13 @@ $edit = "on"; } - $form = new html_form(); - $form->url = new moodle_url("$CFG->wwwroot/course/search.php", array( + $aurl = new moodle_url("$CFG->wwwroot/course/search.php", array( 'edit' => $edit, 'sesskey' => sesskey(), - 'search' => s($search, true), + 'search' => $search, 'page' => $page, 'perpage' => $perpage)); - $form->method = 'get'; - $form->button->text = s($string); - $searchform = $OUTPUT->button($form); + $searchform = $OUTPUT->single_button($aurl, $string, 'get'); } } diff --git a/enrol/authorize/enrol.php b/enrol/authorize/enrol.php index 7040492622c4f..44747829adef6 100755 --- a/enrol/authorize/enrol.php +++ b/enrol/authorize/enrol.php @@ -316,8 +316,8 @@ private function cc_submit($form, $course) echo $OUTPUT->box_start('generalbox notice'); echo '

'. get_string('paymentthanks', 'moodle', $course->fullname) .'

'; echo $OUTPUT->container_start('buttons'); - echo $OUTPUT->button(html_form::make_button("$CFG->wwwroot/enrol/authorize/index.php", array('order'=>$order->id), get_string('payments'))); - echo $OUTPUT->button(html_form::make_button("$CFG->wwwroot/course/view.php", array('id'=>$course->id), $course->fullname)); + echo $OUTPUT->single_button(new moodle_url("$CFG->wwwroot/enrol/authorize/index.php", array('order'=>$order->id)), get_string('payments')); + echo $OUTPUT->single_button(new moodle_url("$CFG->wwwroot/course/view.php", array('id'=>$course->id)), $course->fullname); echo $OUTPUT->container_end(); echo $OUTPUT->box_end(); echo $OUTPUT->footer(); diff --git a/enrol/manual/enrol.html b/enrol/manual/enrol.html index 4033f84054b5a..b865562d9b9b2 100644 --- a/enrol/manual/enrol.html +++ b/enrol/manual/enrol.html @@ -41,7 +41,7 @@ if (isguestuser()) { echo $OUTPUT->box_start('centerpara'); $loginurl = get_login_url(); - echo $OUTPUT->button(html_form::make_button($loginurl, null, get_string('login'))); + echo $OUTPUT->single_button($loginurl, get_string('login')); echo $OUTPUT->box_end(); } ?> diff --git a/grade/edit/outcome/import.php b/grade/edit/outcome/import.php index 0cd188002104f..32284ff40a7b6 100644 --- a/grade/edit/outcome/import.php +++ b/grade/edit/outcome/import.php @@ -135,7 +135,7 @@ if ($error) { echo $OUTPUT->box_start('generalbox importoutcomenofile'); echo get_string('importoutcomenofile', 'grades', $line); - echo $OUTPUT->button(html_form::make_button($CFG->wwwroot.'/grade/edit/outcome/index.php', array('id'=> $courseid), get_string('back'), 'get')); + echo $OUTPUT->single_button(new moodle_url($CFG->wwwroot.'/grade/edit/outcome/index.php', array('id'=> $courseid)), get_string('back'), 'get'); echo $OUTPUT->box_end(); $fatal_error = true; break; @@ -154,7 +154,7 @@ if ( count($csv_data) != count($file_headers) ) { echo $OUTPUT->box_start('generalbox importoutcomenofile'); echo get_string('importoutcomenofile', 'grades', $line); - echo $OUTPUT->button(html_form::make_button($CFG->wwwroot.'/grade/edit/outcome/index.php', array('id'=> $courseid), get_string('back'), 'get')); + echo $OUTPUT->single_button(new moodle_url($CFG->wwwroot.'/grade/edit/outcome/index.php', array('id'=> $courseid)), get_string('back'), 'get'); echo $OUTPUT->box_end(); $fatal_error = true; //echo $OUTPUT->box(var_export($csv_data, true) ."
". var_export($header, true)); @@ -166,7 +166,7 @@ if ($csv_data[$imported_headers[$header]] == '') { echo $OUTPUT->box_start('generalbox importoutcomenofile'); echo get_string('importoutcomenofile', 'grades', $line); - echo $OUTPUT->button(html_form::make_button($CFG->wwwroot.'/grade/edit/outcome/index.php', array('id'=> $courseid), get_string('back'), 'get')); + echo $OUTPUT->single_button(new moodle_url($CFG->wwwroot.'/grade/edit/outcome/index.php', array('id'=> $courseid)), get_string('back'), 'get'); echo $OUTPUT->box_end(); $fatal_error = true; break; diff --git a/grade/edit/outcome/index.php b/grade/edit/outcome/index.php index 3550e5ccc3077..6f201f437905d 100644 --- a/grade/edit/outcome/index.php +++ b/grade/edit/outcome/index.php @@ -247,9 +247,9 @@ } echo $OUTPUT->container_start('buttons'); -echo $OUTPUT->button(html_form::make_button('edit.php', array('courseid'=>$courseid), $strcreatenewoutcome)); +echo $OUTPUT->single_button(new moodle_url('edit.php', array('courseid'=>$courseid)), $strcreatenewoutcome); if ( !empty($outcomes_tables) ) { - echo $OUTPUT->button(html_form::make_button('export.php', array('id'=>$courseid, 'sesskey'=>sesskey()), get_string('exportalloutcomes', 'grades'))); + echo $OUTPUT->single_button(new moodle_url('export.php', array('id'=>$courseid, 'sesskey'=>sesskey())), get_string('exportalloutcomes', 'grades')); } echo $OUTPUT->container_end(); @@ -268,7 +268,6 @@ function grade_print_scale_link($courseid, $scale, $gpr) { global $CFG, $OUTPUT; $url = new moodle_url($CFG->wwwroot.'/grade/edit/scale/edit.php', array('courseid' => $courseid, 'id' => $scale->id)); $url = $gpr->add_url_params($url); - $link = html_link::make($url, $scale->get_name()); - return $OUTPUT->link($link); + return $OUTPUT->link($url, $scale->get_name()); } diff --git a/grade/edit/scale/index.php b/grade/edit/scale/index.php index d169e023331e9..3e74bb2413c8c 100644 --- a/grade/edit/scale/index.php +++ b/grade/edit/scale/index.php @@ -162,6 +162,6 @@ echo $OUTPUT->heading($strstandardscale, 3, 'main'); echo $OUTPUT->table($table2); echo $OUTPUT->container_start('buttons'); -echo $OUTPUT->button(html_form::make_button('edit.php', array('courseid'=>$courseid), $srtcreatenewscale)); +echo $OUTPUT->single_button(new moodle_url('edit.php', array('courseid'=>$courseid)), $srtcreatenewscale); echo $OUTPUT->container_end(); echo $OUTPUT->footer(); diff --git a/grade/edit/tree/index.php b/grade/edit/tree/index.php index 90b6701cccf12..d3a6b389fdbe9 100644 --- a/grade/edit/tree/index.php +++ b/grade/edit/tree/index.php @@ -341,16 +341,16 @@ echo $OUTPUT->container_start('buttons'); if ($moving) { - echo $OUTPUT->button(html_form::make_button('index.php', array('id'=>$course->id), get_string('cancel'), 'get')); + echo $OUTPUT->single_button(new moodle_url('index.php', array('id'=>$course->id)), get_string('cancel'), 'get'); } else { - echo $OUTPUT->button(html_form::make_button('category.php', array('courseid'=>$course->id), get_string('addcategory', 'grades'), 'get')); - echo $OUTPUT->button(html_form::make_button('item.php', array('courseid'=>$course->id), get_string('additem', 'grades'), 'get')); + echo $OUTPUT->single_button(new moodle_url('category.php', array('courseid'=>$course->id)), get_string('addcategory', 'grades'), 'get'); + echo $OUTPUT->single_button(new moodle_url('item.php', array('courseid'=>$course->id)), get_string('additem', 'grades'), 'get'); if (!empty($CFG->enableoutcomes)) { - echo $OUTPUT->button(html_form::make_button('outcomeitem.php', array('courseid'=>$course->id), get_string('addoutcomeitem', 'grades'), 'get')); + echo $OUTPUT->single_button(new moodle_url('outcomeitem.php', array('courseid'=>$course->id)), get_string('addoutcomeitem', 'grades'), 'get'); } - //print_single_button('index.php', array('id'=>$course->id, 'action'=>'autosort'), get_string('autosort', 'grades'), 'get'); + //echo $OUTPUT->(new moodle_url('index.php', array('id'=>$course->id, 'action'=>'autosort')), get_string('autosort', 'grades'), 'get'); } echo $OUTPUT->container_end(); diff --git a/grade/export/keymanager.php b/grade/export/keymanager.php index d09d9c635135d..e63b06cf2f67b 100644 --- a/grade/export/keymanager.php +++ b/grade/export/keymanager.php @@ -77,7 +77,7 @@ echo $OUTPUT->table($table); echo $OUTPUT->container_start('buttons mdl-align'); -echo $OUTPUT->button(html_form::make_button('key.php', array('courseid'=>$course->id), get_string('newuserkey', 'userkey'))); +echo $OUTPUT->single_button(new moodle_url('key.php', array('courseid'=>$course->id)), get_string('newuserkey', 'userkey')); echo $OUTPUT->container_end(); echo $OUTPUT->footer(); diff --git a/grade/export/lib.php b/grade/export/lib.php index 1c468591212c0..2e6449f7f47b3 100755 --- a/grade/export/lib.php +++ b/grade/export/lib.php @@ -295,8 +295,7 @@ public function print_continue() { echo $OUTPUT->container_start('gradeexportlink'); if (!$this->userkey) { // this button should trigger a download prompt - echo $OUTPUT->button(html_form::make_button($CFG->wwwroot.'/grade/export/'.$this->plugin.'/export.php', - $params, get_string('download', 'admin'))); + echo $OUTPUT->single_button(new moodle_url($CFG->wwwroot.'/grade/export/'.$this->plugin.'/export.php', $params), get_string('download', 'admin')); } else { $paramstr = ''; @@ -308,7 +307,7 @@ public function print_continue() { $link = $CFG->wwwroot.'/grade/export/'.$this->plugin.'/dump.php'.$paramstr.'&key='.$this->userkey; - echo get_string('download', 'admin').': ' . $OUTPUT->link(html_link::make($link, $link)); + echo get_string('download', 'admin').': ' . $OUTPUT->link($link, $link); } echo $OUTPUT->container_end(); } diff --git a/grade/import/keymanager.php b/grade/import/keymanager.php index 46c4b7fbb5fe5..270b7de9b0c26 100644 --- a/grade/import/keymanager.php +++ b/grade/import/keymanager.php @@ -74,7 +74,7 @@ echo $OUTPUT->table($table); echo $OUTPUT->container_start('buttons mdl-align'); -echo $OUTPUT->button(html_form::make_button('key.php', array('courseid'=>$course->id), get_string('newuserkey', 'userkey'))); +echo $OUTPUT->single_button(new moodle_url('key.php', array('courseid'=>$course->id)), get_string('newuserkey', 'userkey')); echo $OUTPUT->container_end(); echo $OUTPUT->footer(); diff --git a/grade/report/grader/index.php b/grade/report/grader/index.php index b5225f4f88c4d..ba6c99095ee43 100644 --- a/grade/report/grader/index.php +++ b/grade/report/grader/index.php @@ -84,7 +84,7 @@ $string = get_string('turneditingon'); } - $buttons = $OUTPUT->button(html_form::make_button('index.php', $options, $string, 'get')); + $buttons = $OUTPUT->single_button(new moodle_url('index.php', $options), $string, 'get'); } else { $USER->gradeediting[$course->id] = 0; diff --git a/group/groupings.php b/group/groupings.php index 9d7879137f52a..3cec9b7101a07 100644 --- a/group/groupings.php +++ b/group/groupings.php @@ -101,7 +101,7 @@ echo $OUTPUT->table($table); echo $OUTPUT->container_start('buttons'); -echo $OUTPUT->button(html_form::make_button('grouping.php', array('courseid'=>$courseid), $srtnewgrouping)); +echo $OUTPUT->single_button(new moodle_url('grouping.php', array('courseid'=>$courseid)), $srtnewgrouping); echo $OUTPUT->container_end(); echo $OUTPUT->footer(); diff --git a/lib/adminlib.php b/lib/adminlib.php index a3baf54b2d810..df29208b15429 100644 --- a/lib/adminlib.php +++ b/lib/adminlib.php @@ -5263,7 +5263,9 @@ function admin_externalpage_print_header($focus='') { $caption = get_string('blocksediton'); $options['adminedit'] = 'on'; } - $buttons = $OUTPUT->button(html_form::make_button($PAGE->url->out(), $options, $caption, 'get')); + $url = clone($PAGE->url); + $url->params($options); + $buttons = $OUTPUT->single_button($url, $caption, 'get'); } $PAGE->set_title("$SITE->shortname: " . implode(": ",$visiblepathtosection)); diff --git a/lib/deprecatedlib.php b/lib/deprecatedlib.php index ed0eb4604345e..744fbc8669551 100644 --- a/lib/deprecatedlib.php +++ b/lib/deprecatedlib.php @@ -2472,7 +2472,7 @@ function button_to_popup_window ($url, $name=null, $linkname=null, $id=null, $class=null) { global $OUTPUT; - debugging('button_to_popup_window() has been deprecated. Please change your code to use $OUTPUT->button().'); + debugging('button_to_popup_window() has been deprecated. Please change your code to use $OUTPUT->single_button().'); if ($options == 'none') { $options = null; @@ -2516,7 +2516,7 @@ function button_to_popup_window ($url, $name=null, $linkname=null, } $form->button->add_action(new popup_action('click', $url, $name, $popupparams)); - $output = $OUTPUT->button($form); + $output = $OUTPUT->single_button($form); if ($return) { return $output; @@ -2546,7 +2546,7 @@ function print_single_button($link, $options, $label='OK', $method='get', $notus $return=false, $tooltip='', $disabled = false, $jsconfirmmessage='', $formid = '') { global $OUTPUT; - debugging('print_single_button() has been deprecated. Please change your code to use $OUTPUT->button().'); + debugging('print_single_button() has been deprecated. Please change your code to use $OUTPUT->single_button().'); // Cast $options to array $options = (array) $options; @@ -2562,7 +2562,7 @@ function print_single_button($link, $options, $label='OK', $method='get', $notus $form->button->add_confirm_action($jsconfirmmessage); } - $output = $OUTPUT->button($form); + $output = $OUTPUT->single_button($form); if ($return) { return $output; @@ -3561,10 +3561,8 @@ function update_module_button($cmid, $ignored, $string) { if (has_capability('moodle/course:manageactivities', get_context_instance(CONTEXT_MODULE, $cmid))) { $string = get_string('updatethis', '', $string); - $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 $OUTPUT->button($form); + $url = new moodle_url("$CFG->wwwroot/course/mod.php", array('update' => $cmid, 'return' => true, 'sesskey' => sesskey())); + return $OUTPUT->single_button($url, $string); } else { return ''; } diff --git a/lib/outputrenderers.php b/lib/outputrenderers.php index 6461ae5468945..668786e6dc8d5 100644 --- a/lib/outputrenderers.php +++ b/lib/outputrenderers.php @@ -995,20 +995,26 @@ public function confirm($message, $continue, $cancel) { /** * Returns a form with single button. + * If first parameter is html_form instance all other parameters are ignored. * * @param string|moodle_url|html_form $url_or_form * @param string $label button text * @param string $method get or post submit method + * @param array $options associative array {disabled, title} * @return string HTML fragment */ - public function single_button($url_or_form, $label=null, $method='get') { + public function single_button($url_or_form, $label=null, $method='post', array $options=null) { if ($url_or_form instanceof html_form) { - $form = clone($url_or_form); - if (!is_null($label)) { - $form->button->text = $label; + $form = $url_or_form; + if (func_num_args() > 1) { + debugging('html_form instance used as first parameter of $OUTPUT->single_button(), all other parameters are ignored.'); } } else { $form = html_form::make_button($url_or_form, null, $label, $method); + $form->button->disabled = !empty($options['disabled']); + if (!empty($options['title'])) { + $form->button->title = $options['title']; + } } return $this->button($form); @@ -1058,7 +1064,7 @@ public function form(html_form $form, $contents=null) { $buttonoutput = null; if (empty($contents) && !empty($form->button)) { - debugging("You probably want to use \$OUTPUT->button(\$form), please read that function's documentation", DEBUG_DEVELOPER); + debugging("You probably want to use \$OUTPUT->single_button(\$form), please read that function's documentation", DEBUG_DEVELOPER); } else if (empty($contents)) { $contents = $this->output_empty_tag('input', array('type' => 'submit', 'value' => get_string('ok'))); } else if (!empty($form->button)) { diff --git a/lib/simpletest/filtersettingsperformancetester.php b/lib/simpletest/filtersettingsperformancetester.php index c6bb20baf35aa..271378f286c0b 100644 --- a/lib/simpletest/filtersettingsperformancetester.php +++ b/lib/simpletest/filtersettingsperformancetester.php @@ -116,17 +116,14 @@ echo $OUTPUT->container_start(); -$form = html_form::make_button($baseurl, array('action' => 'setup'), 'Set up test tables', 'get'); -$form->button->disabled = $issetup > 0; -echo $OUTPUT->button($form); +$aurl = new moodle_url($baseurl, array('action' => 'setup')); +echo $OUTPUT->single_button($aurl, 'Set up test tables', 'get', array('disabled'=>($issetup > 0))); -$form = html_form::make_button($baseurl, array('action' => 'teardown'), 'Drop test tables', 'get'); -$form->button->disabled = $issetup == 0; -echo $OUTPUT->button($form); +$aurl = new moodle_url($baseurl, array('action' => 'teardown')); +echo $OUTPUT->single_button($aurl, 'Drop test tables', 'get', array('disabled'=>($issetup == 0))); -$form = html_form::make_button($baseurl, array('action' => 'test'), 'Run tests', 'get'); -$form->button->disabled = $issetup != count($requiredtables); -echo $OUTPUT->button($form); +$aurl = new moodle_url($baseurl, array('action' => 'test')); +echo $OUTPUT->single_button($aurl, 'Run tests', 'get', array('disabled'=>($issetup != count($requiredtables)))); echo $OUTPUT->container_end(); diff --git a/lib/weblib.php b/lib/weblib.php index d73113ce388ee..16826465c3eea 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -2218,7 +2218,7 @@ function switchroles_form($courseid) { $options['sesskey'] = sesskey(); $options['switchrole'] = 0; - return $OUTPUT->button(html_form::make_button($CFG->wwwroot.'/course/view.php', $options, get_string('switchrolereturn'))); + return $OUTPUT->single_button(new moodle_url($CFG->wwwroot.'/course/view.php', $options), get_string('switchrolereturn')); } if (has_capability('moodle/role:switchroles', $context)) { diff --git a/login/confirm.php b/login/confirm.php index 09aa3e735ddf6..fde3b05e73302 100644 --- a/login/confirm.php +++ b/login/confirm.php @@ -39,7 +39,7 @@ echo $OUTPUT->box_start('generalbox centerpara boxwidthnormal boxaligncenter'); echo "

".get_string("thanks").", ". fullname($user) . "

\n"; echo "

".get_string("alreadyconfirmed")."

\n"; - echo $OUTPUT->button(html_form::make_button("$CFG->wwwroot/course/", null, get_string('courses'))); + echo $OUTPUT->single_button("$CFG->wwwroot/course/", get_string('courses')); echo $OUTPUT->box_end(); echo $OUTPUT->footer(); exit; @@ -66,7 +66,7 @@ echo $OUTPUT->box_start('generalbox centerpara boxwidthnormal boxaligncenter'); echo "

".get_string("thanks").", ". fullname($USER) . "

\n"; echo "

".get_string("confirmed")."

\n"; - echo $OUTPUT->button(html_form::make_button("$CFG->wwwroot/course/", null, get_string('courses'))); + echo $OUTPUT->single_button("$CFG->wwwroot/course/", get_string('courses')); echo $OUTPUT->box_end(); echo $OUTPUT->footer(); exit; diff --git a/message/lib.php b/message/lib.php index 779e0566dab40..1da4e1d9adabb 100644 --- a/message/lib.php +++ b/message/lib.php @@ -179,7 +179,7 @@ function message_print_contacts() { echo $OUTPUT->container_end(); echo $OUTPUT->container_start('messagejsmanualrefresh aligncenter'); - echo $OUTPUT->button(html_form::make_button('index.php', false, get_string('refresh'))); + echo $OUTPUT->single_button('index.php', get_string('refresh')); echo $OUTPUT->container_end(); } @@ -518,7 +518,7 @@ function message_print_search_results($frm) { } echo '
'; - echo $OUTPUT->button(html_form::make_button('index.php', array( 'tab' => 'search'), get_string('newsearch', 'message'))); + echo $OUTPUT->single_button(new moodle_url('index.php', array('tab' => 'search')), get_string('newsearch', 'message')); echo '
'; } diff --git a/mod/assignment/type/online/assignment.class.php b/mod/assignment/type/online/assignment.class.php index 9a219fb145f03..63d15c12ccfe4 100644 --- a/mod/assignment/type/online/assignment.class.php +++ b/mod/assignment/type/online/assignment.class.php @@ -126,8 +126,7 @@ function view() { echo $OUTPUT->box_end(); if (!$editmode && $editable) { echo "
"; - echo $OUTPUT->button(html_form::make_button('view.php', array('id'=>$this->cm->id,'edit'=>'1'), - get_string('editmysubmission', 'assignment'))); + echo $OUTPUT->single_button(new moodle_url('view.php', array('id'=>$this->cm->id, 'edit'=>'1')), get_string('editmysubmission', 'assignment')); echo "
"; } diff --git a/mod/assignment/type/upload/assignment.class.php b/mod/assignment/type/upload/assignment.class.php index 7bbf5c8ef1dcd..e9385e030d8a3 100644 --- a/mod/assignment/type/upload/assignment.class.php +++ b/mod/assignment/type/upload/assignment.class.php @@ -180,7 +180,7 @@ function view_notes() { if ($this->can_update_notes($submission)) { $options = array ('id'=>$this->cm->id, 'action'=>'editnotes'); echo '
'; - echo $OUTPUT->button(html_form::make_button('upload.php', $options, get_string('edit'))); + echo $OUTPUT->single_button(new moodle_url('upload.php', $options), get_string('edit')); echo '
'; } } @@ -376,10 +376,10 @@ function print_user_files($userid=0, $return=false) { if ($this->drafts_tracked() and $this->isopen() and has_capability('mod/assignment:grade', $this->context) and $mode != '') { // we do not want it on view.php page if ($this->can_unfinalize($submission)) { $options = array ('id'=>$this->cm->id, 'userid'=>$userid, 'action'=>'unfinalize', 'mode'=>$mode, 'offset'=>$offset); - $output .= $OUTPUT->button(html_form::make_button('upload.php', $options, get_string('unfinalize', 'assignment'))); + $output .= $OUTPUT->single_button(new moodle_url('upload.php', $options), get_string('unfinalize', 'assignment')); } else if ($this->can_finalize($submission)) { $options = array ('id'=>$this->cm->id, 'userid'=>$userid, 'action'=>'finalizeclose', 'mode'=>$mode, 'offset'=>$offset); - $output .= $OUTPUT->button(html_form::make_button('upload.php', $options, get_string('finalize', 'assignment'))); + $output .= $OUTPUT->single_button(new moodle_url('upload.php', $options), get_string('finalize', 'assignment')); } } diff --git a/mod/choice/report.php b/mod/choice/report.php index 7428ac58f4a1a..d52ba36558e7b 100644 --- a/mod/choice/report.php +++ b/mod/choice/report.php @@ -224,13 +224,13 @@ $options = array(); $options["id"] = "$cm->id"; $options["download"] = "ods"; - echo $OUTPUT->button(html_form::make_button("report.php", $options, get_string("downloadods"))); + echo $OUTPUT->single_button(new moodle_url("report.php", $options), get_string("downloadods")); echo ""; $options["download"] = "xls"; - echo $OUTPUT->button(html_form::make_button("report.php", $options, get_string("downloadexcel"))); + echo $OUTPUT->single_button(new moodle_url("report.php", $options), get_string("downloadexcel")); echo ""; $options["download"] = "txt"; - echo $OUTPUT->button(html_form::make_button("report.php", $options, get_string("downloadtext"))); + echo $OUTPUT->single_button(new moodle_url("report.php", $options), get_string("downloadtext")); echo ""; } diff --git a/mod/choice/view.php b/mod/choice/view.php index a2ed7ec55774b..67a855d02e502 100644 --- a/mod/choice/view.php +++ b/mod/choice/view.php @@ -141,7 +141,7 @@ echo $OUTPUT->box_start('generalbox', 'notice'); echo '

'. get_string('noguestchoose', 'choice') .'

'; echo $OUTPUT->container_start('continuebutton'); - echo $OUTPUT->button(html_form::make_button($CFG->wwwroot.'/course/enrol.php?id='.$course->id, NULL, get_string('enrolme', '', format_string($course->shortname)))); + echo $OUTPUT->single_button(new moodle_url($CFG->wwwroot.'/course/enrol.php?', array('id'=>$course->id)), get_string('enrolme', '', format_string($course->shortname))); echo $OUTPUT->container_end(); echo $OUTPUT->box_end(); diff --git a/mod/data/preset.php b/mod/data/preset.php index 863b47ef3860c..d9f93a7e7aebe 100644 --- a/mod/data/preset.php +++ b/mod/data/preset.php @@ -339,7 +339,7 @@ $options['sesskey'] = sesskey(); $options['action'] = 'export'; $options['d'] = $data->id; -echo $OUTPUT->button(html_form::make_button('preset.php', $options, $strexport)); +echo $OUTPUT->single_button(new moodle_url('preset.php', $options), $strexport); echo ''; echo ''; @@ -349,7 +349,7 @@ $options['sesskey'] = sesskey(); $options['action'] = 'save1'; $options['d'] = $data->id; -echo $OUTPUT->button(html_form::make_button('preset.php', $options, $strsave)); +echo $OUTPUT->single_button(new moodle_url('preset.php', $options), $strsave); echo ''; echo '

'.$strimport.'

'; echo ''; diff --git a/mod/feedback/analysis.php b/mod/feedback/analysis.php index 950a4f0767d48..ce63c0a9ef7a8 100644 --- a/mod/feedback/analysis.php +++ b/mod/feedback/analysis.php @@ -87,10 +87,8 @@ //echo '
'; // echo '"; echo $OUTPUT->box_end(); @@ -241,12 +241,12 @@ $options['action'] = "add"; echo ""; echo "
"; - echo $OUTPUT->button(html_form::make_button("editcategories.php", $options, get_string("add") . " " . get_string("category","glossary"))); + echo $OUTPUT->single_button(new moodle_url("editcategories.php", $options), get_string("add") . " " . get_string("category","glossary")); echo ""; unset($options['action']); $options['mode'] = 'cat'; $options['hook'] = $hook; - echo $OUTPUT->button(html_form::make_button("view.php", $options, get_string("back","glossary"))); + echo $OUTPUT->single_button(new moodle_url("view.php", $options), get_string("back","glossary")); echo "
"; diff --git a/mod/glossary/lib.php b/mod/glossary/lib.php index 57b8fd38cfa93..9e69d6b716c85 100644 --- a/mod/glossary/lib.php +++ b/mod/glossary/lib.php @@ -1492,7 +1492,7 @@ function glossary_print_categories_menu($cm, $glossary, $hook, $category) { $options['id'] = $cm->id; $options['mode'] = 'cat'; $options['hook'] = $hook; - echo $OUTPUT->button(html_form::make_button("editcategories.php", $options, get_string("editcategories","glossary"), "get")); + echo $OUTPUT->single_button(new moodle_url("editcategories.php", $options), get_string("editcategories","glossary"), "get"); } echo ''; diff --git a/mod/hotpot/review.php b/mod/hotpot/review.php index 894a3a8d688ac..a4ae2113b6e01 100644 --- a/mod/hotpot/review.php +++ b/mod/hotpot/review.php @@ -138,12 +138,12 @@ function hotpot_print_review_buttons(&$course, &$hotpot, &$attempt, $context) { print "\n".''; print "\n\n".'\n".'\n".'
'; - echo $OUTPUT->button(html_form::make_button("report.php?hp=$hotpot->id", NULL, get_string('continue'))); + echo $OUTPUT->single_button(new moodle_url("report.php", array('hp'=>$hotpot->id)), get_string('continue')); if (has_capability('mod/hotpot:viewreport',$context) && $DB->record_exists('hotpot_details', array('attempt'=>$attempt->id))) { print "'; - echo $OUTPUT->button(html_form::make_button("review.php?hp=$hotpot->id&attempt=$attempt->id&action=showxmlsource", NULL, get_string('showxmlsource', 'hotpot'))); + echo $OUTPUT->single_button(new moodle_url("review.php", array('hp'=>$hotpot->id, 'attempt'=>$attempt->id, 'action'=>'showxmlsource')), get_string('showxmlsource', 'hotpot')); print "'; - echo $OUTPUT->button(html_form::make_button("review.php?hp=$hotpot->id&attempt=$attempt->id&action=showxmltree", NULL, get_string('showxmltree', 'hotpot'))); + echo $OUTPUT->single_button(new moodle_url("review.php", array('hp'=>$hotpot->id,'attempt'=>$attempt->id, 'action'=>'showxmltree')), get_string('showxmltree', 'hotpot')); $colspan = 3; } else { $colspan = 1; diff --git a/mod/lesson/continue.php b/mod/lesson/continue.php index b38517f7c2ea2..175c42721f645 100644 --- a/mod/lesson/continue.php +++ b/mod/lesson/continue.php @@ -186,14 +186,13 @@ echo $OUTPUT->form($form); } -$url = $CFG->wwwroot.'/mod/lesson/view.php'; -$options = array('id'=>$cm->id, 'pageid'=>$result->newpageid); +$url = new moodle_url($CFG->wwwroot.'/mod/lesson/view.php', array('id'=>$cm->id, 'pageid'=>$result->newpageid)); if ($lesson->review && !$result->correctanswer && !$result->noanswer && !$result->isessayquestion) { // Review button continue - $form = html_form::make_button($url, $options, get_string('reviewquestioncontinue', 'lesson')); + echo $OUTPUT->single_button($url, get_string('reviewquestioncontinue', 'lesson')); } else { // Normal continue button - $form = html_form::make_button($url, $options, get_string('continue', 'lesson')); + echo $OUTPUT->single_button($url, get_string('continue', 'lesson')); } -echo $OUTPUT->button($form); + echo $lessonoutput->footer(); \ No newline at end of file diff --git a/mod/lesson/locallib.php b/mod/lesson/locallib.php index 2f4ff0c0ce4e9..06b71a1e92a1f 100644 --- a/mod/lesson/locallib.php +++ b/mod/lesson/locallib.php @@ -567,9 +567,8 @@ function lesson_add_header_buttons($cm, $context, $extraeditbuttons=false, $less print_error('invalidpageid', 'lesson'); } if (!empty($lessonpageid) && $lessonpageid != LESSON_EOL) { - $options = array('id'=>$cm->id, 'redirect'=>'navigation', 'pageid'=>$lessonpageid); - $buttonform = html_form::make_button($CFG->wwwroot.'/mod/lesson/lesson.php', $options, get_string('editpagecontent', 'lesson')); - $PAGE->set_button($OUTPUT->button($buttonform)); + $url = new moodle_url($CFG->wwwroot.'/mod/lesson/lesson.php', array('id'=>$cm->id, 'redirect'=>'navigation', 'pageid'=>$lessonpageid)); + $PAGE->set_button($OUTPUT->single_button($url, get_string('editpagecontent', 'lesson'))); } } -} \ No newline at end of file +} diff --git a/mod/lesson/view.php b/mod/lesson/view.php index e73f5595b8b1f..56830f66a460d 100644 --- a/mod/lesson/view.php +++ b/mod/lesson/view.php @@ -507,9 +507,8 @@ } if (!$highscores or $madeit) { $lessoncontent .= $lessonoutput->paragraph(get_string("youmadehighscore", "lesson", $lesson->maxhighscores), 'center'); - $params = array('id'=>$PAGE->cm->id, 'sesskey'=>sesskey()); - $highscoresbutton = html_form::make_button($CFG->wwwroot.'/mod/lesson/highscores.php', $params, get_string('clicktopost', 'lesson')); - $lessoncontent .= $OUTPUT->button($highscoresbutton); + $aurl = new moodle_url($CFG->wwwroot.'/mod/lesson/highscores.php', array('id'=>$PAGE->cm->id, 'sesskey'=>sesskey())); + $lessoncontent .= $OUTPUT->single_button($aurl, get_string('clicktopost', 'lesson')); } else { $lessoncontent .= get_string("nothighscore", "lesson", $lesson->maxhighscores)."
"; } diff --git a/mod/quiz/accessrules.php b/mod/quiz/accessrules.php index d8621cd910078..3cc1d45a1367e 100644 --- a/mod/quiz/accessrules.php +++ b/mod/quiz/accessrules.php @@ -224,7 +224,7 @@ public function print_start_attempt_button($canpreview, $buttontext, $unfinished if ($strconfirmstartattempt) { $form->button->add_confirm_action($strconfirmstartattempt); } - echo $OUTPUT->button($form); + echo $OUTPUT->single_button($form); } echo "\n"; } @@ -750,7 +750,7 @@ public function make_review_link($linktext, $attemptid) { $form->button->title = $form->button->text; $form->url = $this->_quizobj->review_url($attemptid); $form->button->add_action(new popup_action('click', $form->url, 'quizpopup', $this->windowoptions)); - return $OUTPUT->button($form); + return $OUTPUT->single_button($form); } /** diff --git a/mod/quiz/attemptlib.php b/mod/quiz/attemptlib.php index a69f8db102b66..5dbd38319ec66 100644 --- a/mod/quiz/attemptlib.php +++ b/mod/quiz/attemptlib.php @@ -742,8 +742,8 @@ public function get_question_html_head_contributions($questionid) { public function print_restart_preview_button() { global $CFG, $OUTPUT; echo $OUTPUT->container_start('controls'); - $options = array('cmid' => $this->cm->id, 'forcenew' => true); - echo $OUTPUT->button(html_form::make_button($this->start_attempt_url(), $options, get_string('startagain', 'quiz'))); + $url = new moodle_url($this->start_attempt_url(), array('cmid' => $this->cm->id, 'forcenew' => true)); + echo $OUTPUT->single_button($url, get_string('startagain', 'quiz')); echo $OUTPUT->container_end(); } diff --git a/mod/quiz/editlib.php b/mod/quiz/editlib.php index 9b784237e3c41..530a8c08a9f42 100644 --- a/mod/quiz/editlib.php +++ b/mod/quiz/editlib.php @@ -603,15 +603,8 @@ function quiz_print_question_list($quiz, $pageurl, $allowdelete = true, if (!$reordertool && !$quiz->shufflequestions) { echo $OUTPUT->container_start('addpage'); - $form = html_form::make_button($pageurl->out(true), - array('cmid' => $quiz->cmid, - 'courseid' => $quiz->course, - 'addpage' => $count, - 'sesskey' => sesskey()), - get_string('addpagehere', 'quiz'), - 'get'); - $form->button->disabled = $hasattempts; - echo $OUTPUT->button($form); + $url = new moodle_url($pageurl->out(true), array('cmid' => $quiz->cmid, 'courseid' => $quiz->course, 'addpage' => $count, 'sesskey' => sesskey())); + echo $OUTPUT->single_button($url, get_string('addpagehere', 'quiz'), 'get', $hasattempts); echo $OUTPUT->container_end(); } $pageopen = false; diff --git a/mod/quiz/lib.php b/mod/quiz/lib.php index 24b536978069f..6dcc4ec354cad 100644 --- a/mod/quiz/lib.php +++ b/mod/quiz/lib.php @@ -554,8 +554,8 @@ function quiz_grade_item_update($quiz, $grades=NULL) { echo $OUTPUT->box_start('generalbox', 'notice'); echo '

'. $message .'

'; echo $OUTPUT->container_start('buttons'); - echo $OUTPUT->button(html_form::make_button($regrade_link, null, get_string('regradeanyway', 'grades'))); - echo $OUTPUT->button(html_form::make_button($back_link, null, get_string('cancel'))); + echo $OUTPUT->single_button($regrade_link, get_string('regradeanyway', 'grades')); + echo $OUTPUT->single_button($back_link, get_string('cancel')); echo $OUTPUT->container_end(); echo $OUTPUT->box_end(); diff --git a/mod/quiz/report/statistics/report.php b/mod/quiz/report/statistics/report.php index 1ea18cdd39269..fc40d0c0a0c95 100644 --- a/mod/quiz/report/statistics/report.php +++ b/mod/quiz/report/statistics/report.php @@ -409,8 +409,8 @@ function output_quiz_info_table($course, $cm, $quiz, $quizstats, $usingattemptss } $quizinformationtablehtml .= $OUTPUT->box_start('boxaligncenter generalbox boxwidthnormal mdl-align'); $quizinformationtablehtml .= get_string('lastcalculated', 'quiz_statistics', $a); - $quizinformationtablehtml .= $OUTPUT->button(html_form::make_button($reporturl->out(true), $reporturl->params()+array('recalculate'=>1), - get_string('recalculatenow', 'quiz_statistics'))); + $aurl = new moodle_url($reporturl->out(true), $reporturl->params()+array('recalculate'=>1)); + $quizinformationtablehtml .= $OUTPUT->single_button($aurl, get_string('recalculatenow', 'quiz_statistics')); $quizinformationtablehtml .= $OUTPUT->box_end(); } $downloadoptions = $this->table->get_download_menu(); diff --git a/mod/quiz/summary.php b/mod/quiz/summary.php index 0f918e4ee4975..275da221d3f51 100644 --- a/mod/quiz/summary.php +++ b/mod/quiz/summary.php @@ -128,7 +128,7 @@ $form->id = 'responseform'; $form->button->add_confirm_action(get_string('confirmclose', 'quiz')); -echo $OUTPUT->button($form); +echo $OUTPUT->single_button($form); echo $OUTPUT->container_end(); /// Finish the page diff --git a/mod/survey/report.php b/mod/survey/report.php index 72d51eae7bc9b..a2b5890325777 100644 --- a/mod/survey/report.php +++ b/mod/survey/report.php @@ -484,13 +484,13 @@ $options["group"] = $currentgroup; $options["type"] = "ods"; - echo $OUTPUT->button(html_form::make_button("download.php", $options, get_string("downloadods"))); + echo $OUTPUT->single_button(new moodle_url("download.php", $options), get_string("downloadods")); $options["type"] = "xls"; - echo $OUTPUT->button(html_form::make_button("download.php", $options, get_string("downloadexcel"))); + echo $OUTPUT->single_button(new moodle_url("download.php", $options), get_string("downloadexcel")); $options["type"] = "txt"; - echo $OUTPUT->button(html_form::make_button("download.php", $options, get_string("downloadtext"))); + echo $OUTPUT->single_button(new moodle_url("download.php", $options), get_string("downloadtext")); echo $OUTPUT->container_end(); break; diff --git a/my/index.php b/my/index.php index 46dfad0854d4d..13597c395eefc 100644 --- a/my/index.php +++ b/my/index.php @@ -37,10 +37,8 @@ $edit = '1'; } - $form = new html_form(); - $form->url = new moodle_url("$CFG->wwwroot/my/index.php", array('edit' => $edit)); - $form->button->text = $string; - $button = $OUTPUT->button($form); + $url = new moodle_url("$CFG->wwwroot/my/index.php", array('edit' => $edit)); + $button = $OUTPUT->single_button($url, $string); $header = $SITE->shortname . ': ' . $strmymoodle; $PAGE->navbar->add($strmymoodle); diff --git a/question/editlib.php b/question/editlib.php index 937d1fd9d00da..eb1443c790afa 100644 --- a/question/editlib.php +++ b/question/editlib.php @@ -1927,10 +1927,8 @@ function create_new_question_button($categoryid, $params, $caption, $tooltip = ' global $CFG, $PAGE, $OUTPUT; static $choiceformprinted = false; $params['category'] = $categoryid; - $form = html_form::make_button($CFG->wwwroot . '/question/addquestion.php', $params, $caption,'get'); - $form->button->title = $tooltip; - $form->button->disabled = $disabled; - echo $OUTPUT->button($form); + $url = new moodle_url($CFG->wwwroot . '/question/addquestion.php', $params); + echo $OUTPUT->single_button($url, $caption, 'get', array('disabled'=>$disabled, 'title'=>$tooltip)); echo $OUTPUT->help_icon('types', get_string('createnewquestion', 'question'), 'question'); $PAGE->requires->yui2_lib('dragdrop'); diff --git a/theme/index.php b/theme/index.php index 70bac97979f03..3a00b4a379a82 100644 --- a/theme/index.php +++ b/theme/index.php @@ -59,7 +59,7 @@ admin_externalpage_print_header('themeselector'); echo $OUTPUT->heading(get_string('themes')); -echo $OUTPUT->button(html_form::make_button('index.php', array('sesskey'=>sesskey(),'reset'=>1), get_string('themeresetcaches', 'admin'))); +echo $OUTPUT->single_button(new moodle_url('index.php', array('sesskey'=>sesskey(),'reset'=>1)), get_string('themeresetcaches', 'admin')); $table = new html_table(); $table->id = 'adminthemeselector'; @@ -95,7 +95,7 @@ // Contents of the second cell. $infocell = $OUTPUT->heading($themename, 3); if ($themename != $CFG->theme) { - $infocell .= $OUTPUT->button(html_form::make_button('index.php', array('choose' => $themename, 'sesskey' => sesskey()), get_string('choose'), 'get')); + $infocell .= $OUTPUT->single_button(new moodle_url('index.php', array('choose' => $themename, 'sesskey' => sesskey())), get_string('choose'), 'get'); } $row[] = $infocell; diff --git a/user/profile/index.php b/user/profile/index.php index a32dc56dae4f5..6b5bdc5f4e6aa 100644 --- a/user/profile/index.php +++ b/user/profile/index.php @@ -151,7 +151,7 @@ /// Create a new category link $options = array('action'=>'editcategory'); -echo $OUTPUT->button(html_form::make_button('index.php', $options, get_string('profilecreatecategory', 'admin'))); +echo $OUTPUT->single_button(new moodle_url('index.php', $options), get_string('profilecreatecategory', 'admin')); echo ''; diff --git a/webservice/renderer.php b/webservice/renderer.php index 25c47fd1155e7..83dca26b227f8 100644 --- a/webservice/renderer.php +++ b/webservice/renderer.php @@ -278,13 +278,8 @@ public function documentation_html($functions, $username, $password, $printablef /// Print button $form = new html_form(); $parameters = array ('wsusername' => $username, 'wspassword' => $password, 'print' => true); - $form->url = new moodle_url($CFG->wwwroot.'/webservice/wsdoc.php', $parameters); // Required - $form->button = new html_button(); - $form->button->text = get_string('print','webservice'); // Required - $form->button->disabled = false; - $form->button->title = get_string('print','webservice'); - $form->method = 'post'; - $documentationhtml .= $OUTPUT->button($form); + $url = new moodle_url($CFG->wwwroot.'/webservice/wsdoc.php', $parameters); // Required + $documentationhtml .= $OUTPUT->single_button($url, get_string('print','webservice')); $documentationhtml .= $this->output_empty_tag('br', array());