Skip to content

Commit

Permalink
MDL-21198 $OUTPUT->single_button() resurrection, hopefully much easie…
Browse files Browse the repository at this point in the history
…r to use than $OUTPUT->button(); fixed some regressions and code style improvements
  • Loading branch information
skodak committed Jan 3, 2010
1 parent 3cd5305 commit 5c2ed7e
Show file tree
Hide file tree
Showing 62 changed files with 170 additions and 243 deletions.
4 changes: 2 additions & 2 deletions admin/mnet/mnet_themes.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 '</td>';
echo "</tr>";

Expand Down Expand Up @@ -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 '</td>';
echo "</tr>";
}
Expand Down
10 changes: 5 additions & 5 deletions admin/roles/define.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
2 changes: 1 addition & 1 deletion admin/roles/manage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
8 changes: 4 additions & 4 deletions admin/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
14 changes: 4 additions & 10 deletions admin/webservice/service_functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

2 changes: 1 addition & 1 deletion backup/restore_check.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 "</div>";

Expand Down
2 changes: 1 addition & 1 deletion backup/restorelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 "</div>";
}
else {
Expand Down
8 changes: 2 additions & 6 deletions blocks/rss_client/managefeeds.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 '<div class="actionbuttons">' . $OUTPUT->button($button) . '</div>';
$url = $CFG->wwwroot . '/blocks/rss_client/editfeed.php?' . substr($extraparams, 1);
echo '<div class="actionbuttons">' . $OUTPUT->single_button($url, get_string('addnewfeed', 'block_rss_client'), 'get') . '</div>';


if ($returnurl) {
Expand Down
17 changes: 5 additions & 12 deletions calendar/delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '<br /><br />'.$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');
Expand Down
2 changes: 1 addition & 1 deletion calendar/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions course/category.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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) {
Expand Down
16 changes: 4 additions & 12 deletions course/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -265,20 +263,14 @@
echo '<div class="buttons">';
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);
Expand Down
13 changes: 6 additions & 7 deletions course/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}

Expand Down Expand Up @@ -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');
}

/**
Expand Down Expand Up @@ -2146,7 +2145,7 @@ function print_courses($category) {
$options = array();
$options['category'] = $category->id;
echo '<div class="addcoursebutton">';
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 '</div>';
}
}
Expand Down Expand Up @@ -2324,7 +2323,7 @@ function print_my_moodle() {
echo "<table width=\"100%\"><tr><td align=\"center\">";
print_course_search("", false, "short");
echo "</td><td align=\"center\">";
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 "</td></tr></table>\n";
}

Expand Down
8 changes: 4 additions & 4 deletions course/pending.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand All @@ -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();
9 changes: 3 additions & 6 deletions course/search.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}

Expand Down
4 changes: 2 additions & 2 deletions enrol/authorize/enrol.php
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,8 @@ private function cc_submit($form, $course)
echo $OUTPUT->box_start('generalbox notice');
echo '<p>'. get_string('paymentthanks', 'moodle', $course->fullname) .'</p>';
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();
Expand Down
2 changes: 1 addition & 1 deletion enrol/manual/enrol.html
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
?>
6 changes: 3 additions & 3 deletions grade/edit/outcome/import.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) ."<br />". var_export($header, true));
Expand All @@ -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;
Expand Down
Loading

0 comments on commit 5c2ed7e

Please sign in to comment.