MDL-75337 core: Single button - core changes

* Change all core calls toward single_button to use single_button::BUTTON_PRIMARY
    when needed
This commit is contained in:
Laurent David 2022-12-14 10:46:40 +01:00
parent 377c962f11
commit fc72a1d7b1
39 changed files with 95 additions and 59 deletions

View File

@ -213,7 +213,7 @@ class core_admin_renderer extends plugin_renderer_base {
$output .= $this->container_end(); $output .= $this->container_end();
} }
$button = new single_button($continueurl, get_string('upgradestart', 'admin'), 'get', true); $button = new single_button($continueurl, get_string('upgradestart', 'admin'), 'get', single_button::BUTTON_PRIMARY);
$button->class = 'continuebutton'; $button->class = 'continuebutton';
$output .= $this->render($button); $output .= $this->render($button);
$output .= $this->footer(); $output .= $this->footer();

View File

@ -77,7 +77,7 @@ if ($action) {
$cancelurl = new moodle_url('/admin/searchareas.php'); $cancelurl = new moodle_url('/admin/searchareas.php');
echo $OUTPUT->header(); echo $OUTPUT->header();
echo $OUTPUT->confirm(get_string('confirm_' . $action, 'search', $a), echo $OUTPUT->confirm(get_string('confirm_' . $action, 'search', $a),
new single_button($actionurl, get_string('continue'), 'post', true), new single_button($actionurl, get_string('continue'), 'post', single_button::BUTTON_PRIMARY),
new single_button($cancelurl, get_string('cancel'), 'get')); new single_button($cancelurl, get_string('cancel'), 'get'));
echo $OUTPUT->footer(); echo $OUTPUT->footer();
exit; exit;

View File

@ -83,7 +83,7 @@ if (optional_param('sesskey', '', PARAM_ALPHANUM)) {
// Display confirmation prompt. // Display confirmation prompt.
echo $OUTPUT->confirm(get_string('gradualreindex_confirm', 'search', html_writer::tag('strong', $areaname)), echo $OUTPUT->confirm(get_string('gradualreindex_confirm', 'search', html_writer::tag('strong', $areaname)),
new single_button(new moodle_url('/admin/searchreindex.php', ['areaid' => $areaid, new single_button(new moodle_url('/admin/searchreindex.php', ['areaid' => $areaid,
'sesskey' => sesskey()]), get_string('continue'), 'post', true), 'sesskey' => sesskey()]), get_string('continue'), 'post', single_button::BUTTON_PRIMARY),
new single_button(new moodle_url('/admin/searchareas.php'), get_string('cancel'), 'get')); new single_button(new moodle_url('/admin/searchareas.php'), get_string('cancel'), 'get'));
} }

View File

@ -170,7 +170,7 @@ class renderer extends plugin_renderer_base {
$link, $link,
get_string('schedule:requestanalysis', manager::PLUGINNAME), get_string('schedule:requestanalysis', manager::PLUGINNAME),
'post', 'post',
true, \single_button::BUTTON_PRIMARY,
['class' => $classname] ['class' => $classname]
); );

View File

@ -148,7 +148,7 @@ echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('managetokens', 'core_webservice')); echo $OUTPUT->heading(get_string('managetokens', 'core_webservice'));
echo html_writer::div($OUTPUT->render(new single_button(new moodle_url($PAGE->url, ['action' => 'create']), echo html_writer::div($OUTPUT->render(new single_button(new moodle_url($PAGE->url, ['action' => 'create']),
get_string('createtoken', 'core_webservice'), 'get', true)), 'my-3'); get_string('createtoken', 'core_webservice'), 'get', single_button::BUTTON_PRIMARY)), 'my-3');
$filter->display(); $filter->display();

View File

@ -60,6 +60,9 @@ class bulk_action extends action {
$this->url = new \moodle_url('/report/insights/action.php', $params); $this->url = new \moodle_url('/report/insights/action.php', $params);
$label = $OUTPUT->render($icon) . $this->text; $label = $OUTPUT->render($icon) . $this->text;
$this->actionlink = new \single_button($this->url, $label, 'get', $primary, $attributes); $this->actionlink = new \single_button($this->url, $label,
'get',
$primary ? \single_button::BUTTON_PRIMARY : \single_button::BUTTON_SECONDARY,
$attributes);
} }
} }

View File

@ -567,7 +567,7 @@ class core_backup_renderer extends plugin_renderer_base {
if ($method != 'post') { if ($method != 'post') {
$method = 'get'; $method = 'get';
} }
$button = new single_button($url, get_string('continue'), $method, true); $button = new single_button($url, get_string('continue'), $method, single_button::BUTTON_PRIMARY);
$button->class = 'continuebutton'; $button->class = 'continuebutton';
return $this->render($button); return $this->render($button);
} }

View File

@ -50,7 +50,7 @@ class recipients_action_bar extends manage_badge_action_bar {
if ($this->badge->has_manual_award_criteria() if ($this->badge->has_manual_award_criteria()
&& has_capability('moodle/badges:awardbadge', $this->page->context) && $this->badge->is_active()) { && has_capability('moodle/badges:awardbadge', $this->page->context) && $this->badge->is_active()) {
$url = new moodle_url('/badges/award.php', ['id' => $this->badge->id]); $url = new moodle_url('/badges/award.php', ['id' => $this->badge->id]);
$button = new single_button($url, get_string('award', 'badges'), 'post', true); $button = new single_button($url, get_string('award', 'badges'), 'post', single_button::BUTTON_PRIMARY);
$elements['awardbutton'] = $button->export_for_template($output); $elements['awardbutton'] = $button->export_for_template($output);
} }
$thirdpartynav = $this->get_third_party_nav_action($output); $thirdpartynav = $this->get_third_party_nav_action($output);

View File

@ -89,7 +89,7 @@ class standard_action_bar extends base_action_bar {
if ($this->showaddbadge && has_capability('moodle/badges:createbadge', $this->page->context)) { if ($this->showaddbadge && has_capability('moodle/badges:createbadge', $this->page->context)) {
$buttons[] = new single_button(new moodle_url('/badges/newbadge.php', $params), $buttons[] = new single_button(new moodle_url('/badges/newbadge.php', $params),
get_string('newbadge', 'core_badges'), 'post', true); get_string('newbadge', 'core_badges'), 'post', single_button::BUTTON_PRIMARY);
} }
foreach ($buttons as $key => $button) { foreach ($buttons as $key => $button) {

View File

@ -155,7 +155,7 @@ class block_accessreview extends block_base {
$button = new single_button( $button = new single_button(
new moodle_url(accessibility::get_plugin_url(), ['action' => 'requestanalysis', 'courseid' => $COURSE->id]), new moodle_url(accessibility::get_plugin_url(), ['action' => 'requestanalysis', 'courseid' => $COURSE->id]),
get_string('schedule:requestanalysis', manager::PLUGINNAME), 'post', true, get_string('schedule:requestanalysis', manager::PLUGINNAME), 'post', single_button::BUTTON_PRIMARY,
['class' => 'block_accessreview_analysisbutton']); ['class' => 'block_accessreview_analysisbutton']);
$this->content->text .= html_writer::tag('div', $OUTPUT->render($button), $this->content->text .= html_writer::tag('div', $OUTPUT->render($button),
['class' => 'block_accessreview_analysisbutton']); ['class' => 'block_accessreview_analysisbutton']);

View File

@ -502,7 +502,7 @@ class main implements renderable, templatable {
new \moodle_url('/course/request.php', ['category' => $category->id]), new \moodle_url('/course/request.php', ['category' => $category->id]),
get_string('requestcourse'), get_string('requestcourse'),
'post', 'post',
true \single_button::BUTTON_PRIMARY
); );
return $this->generate_zero_state_data($nocoursesimg, [$button], 'request'); return $this->generate_zero_state_data($nocoursesimg, [$button], 'request');
} }
@ -523,7 +523,7 @@ class main implements renderable, templatable {
new \moodle_url('/course/edit.php', ['category' => $category->id]), new \moodle_url('/course/edit.php', ['category' => $category->id]),
get_string('createcourse', 'block_myoverview'), get_string('createcourse', 'block_myoverview'),
'post', 'post',
true \single_button::BUTTON_PRIMARY
); );
$buttons[] = $createbutton->export_for_template($output); $buttons[] = $createbutton->export_for_template($output);
return $this->generate_zero_state_data($nocoursesimg, $buttons, 'nocourses'); return $this->generate_zero_state_data($nocoursesimg, $buttons, 'nocourses');
@ -534,7 +534,7 @@ class main implements renderable, templatable {
new \moodle_url('/course/edit.php', ['category' => $categorytocreate->id]), new \moodle_url('/course/edit.php', ['category' => $categorytocreate->id]),
get_string('createcourse', 'block_myoverview'), get_string('createcourse', 'block_myoverview'),
'post', 'post',
true \single_button::BUTTON_PRIMARY
); );
$buttons = [$createbutton->export_for_template($output)]; $buttons = [$createbutton->export_for_template($output)];
if ($categorytomanage = \core_course_category::get_nearest_editable_subcategory($coursecat, ['manage'])) { if ($categorytomanage = \core_course_category::get_nearest_editable_subcategory($coursecat, ['manage'])) {

View File

@ -325,10 +325,10 @@ class core_calendar_renderer extends plugin_renderer_base {
*/ */
public function render_subscriptions_header(): string { public function render_subscriptions_header(): string {
$importcalendarbutton = new single_button(new moodle_url('/calendar/import.php', calendar_get_export_import_link_params()), $importcalendarbutton = new single_button(new moodle_url('/calendar/import.php', calendar_get_export_import_link_params()),
get_string('importcalendar', 'calendar'), 'get', true); get_string('importcalendar', 'calendar'), 'get', single_button::BUTTON_PRIMARY);
$importcalendarbutton->class .= ' float-sm-right float-right'; $importcalendarbutton->class .= ' float-sm-right float-right';
$exportcalendarbutton = new single_button(new moodle_url('/calendar/export.php', calendar_get_export_import_link_params()), $exportcalendarbutton = new single_button(new moodle_url('/calendar/export.php', calendar_get_export_import_link_params()),
get_string('exportcalendar', 'calendar'), 'get', true); get_string('exportcalendar', 'calendar'), 'get', single_button::BUTTON_PRIMARY);
$exportcalendarbutton->class .= ' float-sm-right float-right'; $exportcalendarbutton->class .= ' float-sm-right float-right';
$output = $this->output->heading(get_string('managesubscriptions', 'calendar')); $output = $this->output->heading(get_string('managesubscriptions', 'calendar'));
$output .= html_writer::start_div('header d-flex flex-wrap mt-5'); $output .= html_writer::start_div('header d-flex flex-wrap mt-5');

View File

@ -218,7 +218,7 @@ class enrol_manual_plugin extends enrol_plugin {
$button = new enrol_user_button($link, get_string('enrolusers', 'enrol_manual'), 'get'); $button = new enrol_user_button($link, get_string('enrolusers', 'enrol_manual'), 'get');
$button->class .= ' enrol_manual_plugin'; $button->class .= ' enrol_manual_plugin';
$button->primary = true; $button->type = single_button::BUTTON_PRIMARY;
$context = context_course::instance($instance->courseid); $context = context_course::instance($instance->courseid);
$arguments = array('contextid' => $context->id); $arguments = array('contextid' => $context->id);

View File

@ -98,7 +98,7 @@ echo $OUTPUT->header();
// Check we have a search button to render. // Check we have a search button to render.
$searchbuttonrender = null; $searchbuttonrender = null;
if ($searchbutton = $table->get_user_search_button()) { if ($searchbutton = $table->get_user_search_button()) {
$searchbutton->primary = true; $searchbutton->type = single_button::BUTTON_PRIMARY;
$searchbuttonrender = $OUTPUT->render($searchbutton); $searchbuttonrender = $OUTPUT->render($searchbutton);
} }

View File

@ -37,12 +37,15 @@ class core_enrol_renderer extends plugin_renderer_base {
* @return string XHTML * @return string XHTML
*/ */
protected function render_enrol_user_button(enrol_user_button $button) { protected function render_enrol_user_button(enrol_user_button $button) {
$attributes = array('type' => 'submit', $buttoninfo = $button->export_for_template($this->output);
'value' => $button->label,
'disabled' => $button->disabled ? 'disabled' : null,
'title' => $button->tooltip,
'class' => 'btn ' . ($button->primary ? 'btn-primary' : 'btn-secondary'));
$attributes = [
'type' => 'submit',
'value' => $buttoninfo->label,
'disabled' => $buttoninfo->disabled ? 'disabled' : null,
'title' => $buttoninfo->tooltip,
'class' => 'btn ' . "btn-{$buttoninfo->type}",
];
if ($button->actions) { if ($button->actions) {
$id = html_writer::random_id('single_button'); $id = html_writer::random_id('single_button');
$attributes['id'] = $id; $attributes['id'] = $id;

View File

@ -56,7 +56,7 @@ class course_outcomes_action_bar extends action_bar {
// Add a button to the action bar with a link to the 'manage outcomes' page. // Add a button to the action bar with a link to the 'manage outcomes' page.
$manageoutcomeslink = new moodle_url('/grade/edit/outcome/index.php', ['id' => $courseid]); $manageoutcomeslink = new moodle_url('/grade/edit/outcome/index.php', ['id' => $courseid]);
$manageoutcomesbutton = new \single_button($manageoutcomeslink, get_string('manageoutcomes', 'grades'), $manageoutcomesbutton = new \single_button($manageoutcomeslink, get_string('manageoutcomes', 'grades'),
'get', true); 'get', \single_button::BUTTON_PRIMARY);
$data['manageoutcomesbutton'] = $manageoutcomesbutton->export_for_template($output); $data['manageoutcomesbutton'] = $manageoutcomesbutton->export_for_template($output);
} }

View File

@ -54,7 +54,7 @@ class export_key_manager_action_bar extends action_bar {
// Add a button to the action bar with a link to the 'add user key' page. // Add a button to the action bar with a link to the 'add user key' page.
$adduserkeylink = new moodle_url('/grade/export/key.php', ['courseid' => $courseid]); $adduserkeylink = new moodle_url('/grade/export/key.php', ['courseid' => $courseid]);
$adduserkeybutton = new \single_button($adduserkeylink, get_string('adduserkey', 'userkey'), $adduserkeybutton = new \single_button($adduserkeylink, get_string('adduserkey', 'userkey'),
'get', true); 'get', \single_button::BUTTON_PRIMARY);
$data['adduserkeybutton'] = $adduserkeybutton->export_for_template($output); $data['adduserkeybutton'] = $adduserkeybutton->export_for_template($output);
return $data; return $data;

View File

@ -53,7 +53,7 @@ class grade_letters_action_bar extends action_bar {
} }
// Add a button to the action bar with a link to the 'edit grade letters' page. // Add a button to the action bar with a link to the 'edit grade letters' page.
$editbuttonlink = new moodle_url('/grade/edit/letter/index.php', ['id' => $this->context->id, 'edit' => 1]); $editbuttonlink = new moodle_url('/grade/edit/letter/index.php', ['id' => $this->context->id, 'edit' => 1]);
$editbutton = new \single_button($editbuttonlink, get_string('edit'), 'get', true); $editbutton = new \single_button($editbuttonlink, get_string('edit'), 'get', \single_button::BUTTON_PRIMARY);
$data['editbutton'] = $editbutton->export_for_template($output); $data['editbutton'] = $editbutton->export_for_template($output);
return $data; return $data;

View File

@ -54,7 +54,7 @@ class import_key_manager_action_bar extends action_bar {
// Add a button to the action bar with a link to the 'add user key' page. // Add a button to the action bar with a link to the 'add user key' page.
$adduserkeylink = new moodle_url('/grade/import/key.php', ['courseid' => $courseid]); $adduserkeylink = new moodle_url('/grade/import/key.php', ['courseid' => $courseid]);
$adduserkeybutton = new \single_button($adduserkeylink, get_string('adduserkey', 'userkey'), $adduserkeybutton = new \single_button($adduserkeylink, get_string('adduserkey', 'userkey'),
'get', true); 'get', \single_button::BUTTON_PRIMARY);
$data['adduserkeybutton'] = $adduserkeybutton->export_for_template($output); $data['adduserkeybutton'] = $adduserkeybutton->export_for_template($output);
return $data; return $data;

View File

@ -78,7 +78,7 @@ class manage_outcomes_action_bar extends action_bar {
// Add a button to the action bar with a link to the 'add new outcome' page. // Add a button to the action bar with a link to the 'add new outcome' page.
$addoutcomelink = new moodle_url('/grade/edit/outcome/edit.php', ['courseid' => $courseid]); $addoutcomelink = new moodle_url('/grade/edit/outcome/edit.php', ['courseid' => $courseid]);
$addoutcomebutton = new \single_button($addoutcomelink, get_string('outcomecreate', 'grades'), $addoutcomebutton = new \single_button($addoutcomelink, get_string('outcomecreate', 'grades'),
'get', true); 'get', \single_button::BUTTON_PRIMARY);
$data['addoutcomebutton'] = $addoutcomebutton->export_for_template($output); $data['addoutcomebutton'] = $addoutcomebutton->export_for_template($output);
if ($this->hasoutcomes) { if ($this->hasoutcomes) {

View File

@ -56,7 +56,7 @@ class scales_action_bar extends action_bar {
// Add a button to the action bar with a link to the 'add new scale' page. // Add a button to the action bar with a link to the 'add new scale' page.
$addnewscalelink = new moodle_url('/grade/edit/scale/edit.php', ['courseid' => $courseid]); $addnewscalelink = new moodle_url('/grade/edit/scale/edit.php', ['courseid' => $courseid]);
$addnewscalebutton = new \single_button($addnewscalelink, get_string('scalescustomcreate'), $addnewscalebutton = new \single_button($addnewscalelink, get_string('scalescustomcreate'),
'get', true); 'get', \single_button::BUTTON_PRIMARY);
$data['addnewscalebutton'] = $addnewscalebutton->export_for_template($output); $data['addnewscalebutton'] = $addnewscalebutton->export_for_template($output);
return $data; return $data;

View File

@ -2051,12 +2051,16 @@ class core_renderer extends renderer_base {
$displayoptions['cancelstr'] = $displayoptions['cancelstr'] ?? get_string('cancel'); $displayoptions['cancelstr'] = $displayoptions['cancelstr'] ?? get_string('cancel');
if ($continue instanceof single_button) { if ($continue instanceof single_button) {
// ok // Continue button should be primary if set to secondary type as it is the fefault.
$continue->primary = true; if ($continue->type === single_button::BUTTON_SECONDARY) {
$continue->type = single_button::BUTTON_PRIMARY;
}
} else if (is_string($continue)) { } else if (is_string($continue)) {
$continue = new single_button(new moodle_url($continue), $displayoptions['continuestr'], 'post', true); $continue = new single_button(new moodle_url($continue), $displayoptions['continuestr'], 'post',
$displayoptions['type'] ?? single_button::BUTTON_PRIMARY);
} else if ($continue instanceof moodle_url) { } else if ($continue instanceof moodle_url) {
$continue = new single_button($continue, $displayoptions['continuestr'], 'post', true); $continue = new single_button($continue, $displayoptions['continuestr'], 'post',
$displayoptions['type'] ?? single_button::BUTTON_PRIMARY);
} else { } else {
throw new coding_exception('The continue param to $OUTPUT->confirm() must be either a URL (string/moodle_url) or a single_button instance.'); throw new coding_exception('The continue param to $OUTPUT->confirm() must be either a URL (string/moodle_url) or a single_button instance.');
} }
@ -3120,7 +3124,7 @@ EOD;
if (!($url instanceof moodle_url)) { if (!($url instanceof moodle_url)) {
$url = new moodle_url($url); $url = new moodle_url($url);
} }
$button = new single_button($url, get_string('continue'), 'get', true); $button = new single_button($url, get_string('continue'), 'get', single_button::BUTTON_PRIMARY);
$button->class = 'continuebutton'; $button->class = 'continuebutton';
return $this->render($button); return $this->render($button);
@ -5567,11 +5571,13 @@ class core_renderer_maintenance extends core_renderer {
// We need plain styling of confirm boxes on upgrade because we don't know which stylesheet we have (it could be // We need plain styling of confirm boxes on upgrade because we don't know which stylesheet we have (it could be
// from any previous version of Moodle). // from any previous version of Moodle).
if ($continue instanceof single_button) { if ($continue instanceof single_button) {
$continue->primary = true; $continue->type = single_button::BUTTON_PRIMARY;
} else if (is_string($continue)) { } else if (is_string($continue)) {
$continue = new single_button(new moodle_url($continue), get_string('continue'), 'post', true); $continue = new single_button(new moodle_url($continue), get_string('continue'), 'post',
$displayoptions['type'] ?? single_button::BUTTON_PRIMARY);
} else if ($continue instanceof moodle_url) { } else if ($continue instanceof moodle_url) {
$continue = new single_button($continue, get_string('continue'), 'post', true); $continue = new single_button($continue, get_string('continue'), 'post',
$displayoptions['type'] ?? single_button::BUTTON_PRIMARY);
} else { } else {
throw new coding_exception('The continue param to $OUTPUT->confirm() must be either a URL' . throw new coding_exception('The continue param to $OUTPUT->confirm() must be either a URL' .
' (string/moodle_url) or a single_button instance.'); ' (string/moodle_url) or a single_button instance.');

View File

@ -150,7 +150,7 @@ class override_actionmenu implements templatable, renderable {
} else if ($action === 'adduser' && !$this->show_useroverride()) { } else if ($action === 'adduser' && !$this->show_useroverride()) {
$options = ['disabled' => 'true']; $options = ['disabled' => 'true'];
} }
$overridebutton = new single_button($url, $text, 'post', true, $options); $overridebutton = new single_button($url, $text, 'post', single_button::BUTTON_PRIMARY, $options);
$urlselect = $this->get_select_menu(); $urlselect = $this->get_select_menu();
return [ return [

View File

@ -119,7 +119,12 @@ class user_submission_actionmenu implements templatable, renderable {
'help' => $help->export_for_template($output) 'help' => $help->export_for_template($output)
]; ];
$url = new moodle_url('/mod/assign/view.php', ['id' => $this->cmid, 'action' => 'editsubmission']); $url = new moodle_url('/mod/assign/view.php', ['id' => $this->cmid, 'action' => 'editsubmission']);
$newattemptbutton = new single_button($url, get_string('addnewattempt', 'mod_assign'), 'get', true); $newattemptbutton = new single_button(
$url,
get_string('addnewattempt', 'mod_assign'),
'get',
single_button::BUTTON_PRIMARY
);
$newattempthelp = new help_icon('addnewattempt', 'mod_assign'); $newattempthelp = new help_icon('addnewattempt', 'mod_assign');
$data['edit']['button'] = $newattemptbutton->export_for_template($output); $data['edit']['button'] = $newattemptbutton->export_for_template($output);
$data['edit']['help'] = $newattempthelp->export_for_template($output); $data['edit']['help'] = $newattempthelp->export_for_template($output);
@ -143,7 +148,12 @@ class user_submission_actionmenu implements templatable, renderable {
$data['edit']['begin'] = true; $data['edit']['begin'] = true;
$data['edit']['help'] = ''; $data['edit']['help'] = '';
} else { } else {
$newattemptbutton = new single_button($url, get_string('addsubmission', 'mod_assign'), 'get', true); $newattemptbutton = new single_button(
$url,
get_string('addsubmission', 'mod_assign'),
'get',
single_button::BUTTON_PRIMARY
);
$data['edit']['button'] = $newattemptbutton->export_for_template($output); $data['edit']['button'] = $newattemptbutton->export_for_template($output);
$data['edit']['help'] = ''; $data['edit']['help'] = '';
} }
@ -151,7 +161,7 @@ class user_submission_actionmenu implements templatable, renderable {
} }
if ($this->showsubmit) { if ($this->showsubmit) {
$url = new moodle_url('/mod/assign/view.php', ['id' => $this->cmid, 'action' => 'submit']); $url = new moodle_url('/mod/assign/view.php', ['id' => $this->cmid, 'action' => 'submit']);
$button = new single_button($url, get_string('submitassignment', 'mod_assign'), 'get', true); $button = new single_button($url, get_string('submitassignment', 'mod_assign'), 'get', single_button::BUTTON_PRIMARY);
$help = new help_icon('submitassignment', 'mod_assign'); $help = new help_icon('submitassignment', 'mod_assign');
$data['submit'] = [ $data['submit'] = [
'button' => $button->export_for_template($output), 'button' => $button->export_for_template($output),

View File

@ -587,7 +587,7 @@ class mod_bigbluebuttonbn_mod_form extends moodleform_mod {
$action = new single_button(new moodle_url(qualified_me()), $action = new single_button(new moodle_url(qualified_me()),
get_string('mod_form_field_participant_list_action_add', 'bigbluebuttonbn'), get_string('mod_form_field_participant_list_action_add', 'bigbluebuttonbn'),
'post', 'post',
false, single_button::BUTTON_SECONDARY,
['name' => 'bigbluebuttonbn_participant_selection_add'] ['name' => 'bigbluebuttonbn_participant_selection_add']
); );
$pformcontext = [ $pformcontext = [

View File

@ -58,7 +58,7 @@ class add_entries_action implements templatable, renderable {
if (data_user_can_add_entry($database, $currentgroup, $groupmode, $PAGE->context)) { if (data_user_can_add_entry($database, $currentgroup, $groupmode, $PAGE->context)) {
$addentrylink = new moodle_url('/mod/data/edit.php', ['d' => $this->id, 'backto' => $PAGE->url->out(false)]); $addentrylink = new moodle_url('/mod/data/edit.php', ['d' => $this->id, 'backto' => $PAGE->url->out(false)]);
$button = new \single_button($addentrylink, get_string('add', 'mod_data'), 'get', true); $button = new \single_button($addentrylink, get_string('add', 'mod_data'), 'get', \single_button::BUTTON_PRIMARY);
return $button->export_for_template($output); return $button->export_for_template($output);
} }

View File

@ -60,7 +60,7 @@ class empty_database_action_bar implements templatable, renderable {
$importentrieslink = new moodle_url('/mod/data/import.php', $params); $importentrieslink = new moodle_url('/mod/data/import.php', $params);
$importentriesbutton = new \single_button($importentrieslink, $importentriesbutton = new \single_button($importentrieslink,
get_string('importentries', 'mod_data'), 'get', false); get_string('importentries', 'mod_data'), 'get');
$data['importentriesbutton'] = $importentriesbutton->export_for_template($output); $data['importentriesbutton'] = $importentriesbutton->export_for_template($output);
} }

View File

@ -59,7 +59,7 @@ class zero_state_action_bar implements templatable, renderable {
$usepresetlink = new moodle_url('/mod/data/preset.php', $params); $usepresetlink = new moodle_url('/mod/data/preset.php', $params);
$usepresetbutton = new \single_button($usepresetlink, $usepresetbutton = new \single_button($usepresetlink,
get_string('usestandard', 'mod_data'), 'get', true); get_string('usestandard', 'mod_data'), 'get', \single_button::BUTTON_PRIMARY);
$data['usepresetbutton'] = $usepresetbutton->export_for_template($output); $data['usepresetbutton'] = $usepresetbutton->export_for_template($output);
$actionbar = new \mod_data\output\action_bar($instance->id, $PAGE->url); $actionbar = new \mod_data\output\action_bar($instance->id, $PAGE->url);
@ -68,7 +68,7 @@ class zero_state_action_bar implements templatable, renderable {
$importpresetlink = new moodle_url('/mod/data/preset.php', $params); $importpresetlink = new moodle_url('/mod/data/preset.php', $params);
$importpresetbutton = new \single_button($importpresetlink, $importpresetbutton = new \single_button($importpresetlink,
get_string('importapreset', 'mod_data'), 'get', false, [ get_string('importapreset', 'mod_data'), 'get', \single_button::BUTTON_SECONDARY, [
'data-action' => 'importpresets', 'data-action' => 'importpresets',
'data-dataid' => $cm->id, 'data-dataid' => $cm->id,
]); ]);

View File

@ -60,7 +60,7 @@ class mod_folder_renderer extends plugin_renderer_base {
$canmanagecourseactivities = has_capability('moodle/course:manageactivities', $context); $canmanagecourseactivities = has_capability('moodle/course:manageactivities', $context);
if ($canmanagefolderfiles && ($folder->display != FOLDER_DISPLAY_INLINE || !$canmanagecourseactivities)) { if ($canmanagefolderfiles && ($folder->display != FOLDER_DISPLAY_INLINE || !$canmanagecourseactivities)) {
$editbutton = new single_button(new moodle_url('/mod/folder/edit.php', ['id' => $cm->id]), $editbutton = new single_button(new moodle_url('/mod/folder/edit.php', ['id' => $cm->id]),
get_string('edit'), 'post', true); get_string('edit'), 'post', single_button::BUTTON_PRIMARY);
$editbutton->class = 'navitem'; $editbutton->class = 'navitem';
$buttons .= $this->render($editbutton); $buttons .= $this->render($editbutton);
} }

View File

@ -160,7 +160,7 @@ class standard_action_bar implements renderable, templatable {
return null; return null;
} }
$btn = new single_button(new moodle_url('/mod/glossary/edit.php', ['cmid' => $this->cm->id]), $btn = new single_button(new moodle_url('/mod/glossary/edit.php', ['cmid' => $this->cm->id]),
get_string('addsingleentry', 'glossary'), 'post', true); get_string('addsingleentry', 'glossary'), 'post', single_button::BUTTON_PRIMARY);
return $btn->export_for_template($output); return $btn->export_for_template($output);
} }

View File

@ -90,7 +90,7 @@ class edit_action_buttons implements templatable, renderable {
if ($this->lesson->can_manage()) { if ($this->lesson->can_manage()) {
$url = new moodle_url('/mod/lesson/edit.php', ['id' => $this->lesson->get_cm()->id]); $url = new moodle_url('/mod/lesson/edit.php', ['id' => $this->lesson->get_cm()->id]);
$editbutton = new single_button($url, get_string('editlesson', 'mod_lesson'), 'get', true); $editbutton = new single_button($url, get_string('editlesson', 'mod_lesson'), 'get', single_button::BUTTON_PRIMARY);
$url = new moodle_url('/mod/lesson/essay.php', ['id' => $this->lesson->get_cm()->id]); $url = new moodle_url('/mod/lesson/essay.php', ['id' => $this->lesson->get_cm()->id]);
$essaybutton = new single_button($url, get_string('manualgrading', 'mod_lesson'), 'get'); $essaybutton = new single_button($url, get_string('manualgrading', 'mod_lesson'), 'get');
$data += [ $data += [

View File

@ -77,7 +77,7 @@ class overrides_actions implements renderable, templatable {
$label = get_string('addnewuseroverride', 'quiz'); $label = get_string('addnewuseroverride', 'quiz');
} }
$addoverridebutton = new \single_button($addoverrideurl, $label, 'get', true); $addoverridebutton = new \single_button($addoverrideurl, $label, 'get', \single_button::BUTTON_PRIMARY);
if (!$this->addenabled) { if (!$this->addenabled) {
$addoverridebutton->disabled = true; $addoverridebutton->disabled = true;
} }

View File

@ -823,7 +823,7 @@ class renderer extends plugin_renderer_base {
} }
$this->page->requires->js_call_amd('mod_quiz/submission_confirmation', 'init', [$totalunanswered]); $this->page->requires->js_call_amd('mod_quiz/submission_confirmation', 'init', [$totalunanswered]);
} }
$button->primary = true; $button->type = \single_button::BUTTON_PRIMARY;
$duedate = $attemptobj->get_due_date(); $duedate = $attemptobj->get_due_date();
$message = ''; $message = '';
@ -935,7 +935,7 @@ class renderer extends plugin_renderer_base {
preflight_check_form $preflightcheckform = null, preflight_check_form $preflightcheckform = null,
$popuprequired = false, $popupoptions = null) { $popuprequired = false, $popupoptions = null) {
$button = new single_button($url, $buttontext, 'post', true); $button = new single_button($url, $buttontext, 'post', single_button::BUTTON_PRIMARY);
$button->class .= ' quizstartbuttondiv'; $button->class .= ' quizstartbuttondiv';
if ($popuprequired) { if ($popuprequired) {
$button->class .= ' quizsecuremoderequired'; $button->class .= ' quizsecuremoderequired';

View File

@ -1225,7 +1225,7 @@ class mod_workshop_renderer extends plugin_renderer_base {
if (!$workshop->get_submission_by_author($USER->id)) { if (!$workshop->get_submission_by_author($USER->id)) {
$btnurl = new moodle_url($workshop->submission_url(), ['edit' => 'on']); $btnurl = new moodle_url($workshop->submission_url(), ['edit' => 'on']);
$btntxt = get_string('createsubmission', 'workshop'); $btntxt = get_string('createsubmission', 'workshop');
$output .= $this->single_button($btnurl, $btntxt, 'get', ['primary' => true]); $output .= $this->single_button($btnurl, $btntxt, 'get', ['type' => single_button::BUTTON_PRIMARY]);
} }
} }
break; break;
@ -1236,7 +1236,7 @@ class mod_workshop_renderer extends plugin_renderer_base {
if ($workshop->creating_submission_allowed($USER->id)) { if ($workshop->creating_submission_allowed($USER->id)) {
$btnurl = new moodle_url($workshop->submission_url(), ['edit' => 'on']); $btnurl = new moodle_url($workshop->submission_url(), ['edit' => 'on']);
$btntxt = get_string('createsubmission', 'workshop'); $btntxt = get_string('createsubmission', 'workshop');
$output .= $this->single_button($btnurl, $btntxt, 'get', ['primary' => true]); $output .= $this->single_button($btnurl, $btntxt, 'get', ['type' => single_button::BUTTON_PRIMARY]);
} }
} }
} }

View File

@ -65,7 +65,11 @@ $PAGE->set_secondary_active_tab("modulepage");
// //
echo $OUTPUT->header(); echo $OUTPUT->header();
$continuebtn = new single_button( $continuebtn = new single_button(
new moodle_url($PAGE->url, array('confirm' => 1)), get_string('continue'), 'post', true); new moodle_url($PAGE->url, array('confirm' => 1)),
get_string('continue'),
'post',
single_button::BUTTON_PRIMARY
);
$continuebtn->class .= ' mr-3'; $continuebtn->class .= ' mr-3';
echo $OUTPUT->confirm(get_string('switchphase' . $phase . 'info', 'workshop'), echo $OUTPUT->confirm(get_string('switchphase' . $phase . 'info', 'workshop'),
$continuebtn, $workshop->view_url()); $continuebtn, $workshop->view_url());

View File

@ -243,7 +243,7 @@ class infectedfiles_table extends \table_sql implements \renderable {
// Delete All. // Delete All.
$deleteallparams = ['action' => 'deleteall', 'sesskey' => sesskey()]; $deleteallparams = ['action' => 'deleteall', 'sesskey' => sesskey()];
$deleteallurl = new \moodle_url($managefilepage, $deleteallparams); $deleteallurl = new \moodle_url($managefilepage, $deleteallparams);
$deletebutton = new \single_button($deleteallurl, get_string('deleteall'), 'post', true); $deletebutton = new \single_button($deleteallurl, get_string('deleteall'), 'post', \single_button::BUTTON_PRIMARY);
$deletebutton->add_confirm_action(get_string('confirmdeleteall', 'report_infectedfiles')); $deletebutton->add_confirm_action(get_string('confirmdeleteall', 'report_infectedfiles'));
echo $OUTPUT->render($deletebutton); echo $OUTPUT->render($deletebutton);
@ -252,7 +252,7 @@ class infectedfiles_table extends \table_sql implements \renderable {
// Download All. // Download All.
$downloadallparams = ['action' => 'downloadall', 'sesskey' => sesskey()]; $downloadallparams = ['action' => 'downloadall', 'sesskey' => sesskey()];
$downloadallurl = new \moodle_url($managefilepage, $downloadallparams); $downloadallurl = new \moodle_url($managefilepage, $downloadallparams);
$downloadbutton = new \single_button($downloadallurl, get_string('downloadall'), 'post', true); $downloadbutton = new \single_button($downloadallurl, get_string('downloadall'), 'post', \single_button::BUTTON_PRIMARY);
$downloadbutton->add_confirm_action(get_string('confirmdownloadall', 'report_infectedfiles')); $downloadbutton->add_confirm_action(get_string('confirmdownloadall', 'report_infectedfiles'));
echo $OUTPUT->render($downloadbutton); echo $OUTPUT->render($downloadbutton);
} }

View File

@ -164,7 +164,12 @@ class repository_googledocs extends repository {
$repositoryname = get_string('pluginname', 'repository_googledocs'); $repositoryname = get_string('pluginname', 'repository_googledocs');
$button = new single_button($url, get_string('logintoaccount', 'repository', $repositoryname), 'post', true); $button = new single_button(
$url,
get_string('logintoaccount', 'repository', $repositoryname),
'post',
single_button::BUTTON_PRIMARY
);
$button->add_action(new popup_action('click', $url, 'Login')); $button->add_action(new popup_action('click', $url, 'Login'));
$button->class = 'mdl-align'; $button->class = 'mdl-align';
$button = $OUTPUT->render($button); $button = $OUTPUT->render($button);

View File

@ -857,7 +857,7 @@ class repository_nextcloud extends repository {
echo $OUTPUT->header(); echo $OUTPUT->header();
$button = new single_button($url, get_string('logintoaccount', 'repository', $this->get_name()), $button = new single_button($url, get_string('logintoaccount', 'repository', $this->get_name()),
'post', true); 'post', single_button::BUTTON_PRIMARY);
$button->add_action(new popup_action('click', $url, 'Login')); $button->add_action(new popup_action('click', $url, 'Login'));
$button->class = 'mdl-align'; $button->class = 'mdl-align';
$button = $OUTPUT->render($button); $button = $OUTPUT->render($button);

View File

@ -145,7 +145,12 @@ class repository_onedrive extends repository {
$repositoryname = get_string('pluginname', 'repository_onedrive'); $repositoryname = get_string('pluginname', 'repository_onedrive');
$button = new single_button($url, get_string('logintoaccount', 'repository', $repositoryname), 'post', true); $button = new single_button(
$url,
get_string('logintoaccount', 'repository', $repositoryname),
'post',
single_button::BUTTON_PRIMARY
);
$button->add_action(new popup_action('click', $url, 'Login')); $button->add_action(new popup_action('click', $url, 'Login'));
$button->class = 'mdl-align'; $button->class = 'mdl-align';
$button = $OUTPUT->render($button); $button = $OUTPUT->render($button);