/** * Return an XHTML string for the setting * @return string Returns an XHTML string */ public function output_html($data, $query = '') { $healthcheckurl = new \moodle_url('/local/o365/acp.php', ['mode' => 'healthcheck']); $settinghtml = '<input type="hidden" id="' . $this->get_id() . '" name="' . $this->get_full_name() . '" value="0" />'; $settinghtml .= \html_writer::link($healthcheckurl, get_string('settings_healthcheck_linktext', 'local_o365')); return format_admin_setting($this, $this->visiblename, $settinghtml, $this->description); }
public function output_html($data, $query = '') { if (!isset($data['value'])) { $data['value'] = $this->normalise_data($data); } $return = '<div id="adminquizreviewoptions" class="clearfix">' . "\n"; foreach (admin_setting_quiz_reviewoptions::$times as $timemask => $timestring) { $return .= '<div class="group"><div class="fitemtitle">' . get_string($timestring, 'quiz') . "</div>\n"; $nameprefix = $this->get_full_name() . '[' . $timemask . ']'; $idprefix = $this->get_id() . '_' . $timemask . '_'; foreach (admin_setting_quiz_reviewoptions::$things as $thingmask => $thingstring) { $id = $idprefix . $thingmask; $state = ''; if ($data['value'] & $timemask & $thingmask) { $state = 'checked="checked" '; } $return .= '<span><input type="checkbox" name="' . $nameprefix . '[' . $thingmask . ']" value="1" id="' . $id . '" ' . $state . '/> <label for="' . $id . '">' . get_string($thingstring, 'quiz') . "</label></span>\n"; } $return .= "</div>\n"; } $return .= "</div>\n"; $adv = !empty($data['adv']); $return .= '<input type="checkbox" class="form-checkbox" id="' . $this->get_id() . '_adv" name="' . $this->get_full_name() . '[adv]" value="1" ' . ($adv ? 'checked="checked"' : '') . ' />' . ' <label for="' . $this->get_id() . '_adv">' . get_string('advanced') . '</label> '; return format_admin_setting($this, $this->visiblename, $return, $this->description, true, '', get_string('everythingon', 'quiz'), $query); }
public function output_html($data, $query = '') { global $DB; $defaultinfo = get_string('checkboxno', 'admin'); if ((string) $data === (string) year_tables::ENABLED_ON) { $html = \html_writer::div(get_string('yearsenabled_on', 'local_ousearch'), 'local_ousearch_yearsenabled defaultsnext'); } else { if ((string) $data === (string) year_tables::ENABLED_TRANSFERRING) { // Show transferring progress. This database query only occurs // during the transferring phase. $transferring = get_config('local_ousearch', year_tables::CONFIG_TRANSFERRING_COURSE); if (!$transferring) { $pc = '0'; } else { $progress = $DB->get_record_sql('SELECT (SELECT COUNT(1) FROM {course} WHERE id < ?) AS done, (SELECT COUNT(1) FROM {course}) AS total', array($transferring, $transferring)); $pc = round(100.0 * $progress->done / $progress->total, 1); } $html = \html_writer::div(get_string('yearsenabled_transferring', 'local_ousearch', $pc), 'local_ousearch_yearsenabled defaultsnext'); } else { // This is similar to standard checkbox except I didn't support it // being shown as checked. $html = \html_writer::div(\html_writer::empty_tag('input', array('type' => 'hidden', 'name' => $this->get_full_name(), 'value' => $this->no)) . \html_writer::empty_tag('input', array('type' => 'checkbox', 'name' => $this->get_full_name(), 'value' => $this->yes)), 'form-checkbox defaultsnext'); } } return format_admin_setting($this, $this->visiblename, $html, $this->description, true, '', $defaultinfo, $query); }
/** * Returns an HTML string for the redirect uri display. * * @return string Returns an HTML string. */ public function output_html($data, $query = '') { global $CFG; $wwwroot = !empty($CFG->loginhttps) ? str_replace('http://', 'https://', $CFG->wwwroot) : $CFG->wwwroot; $html = \html_writer::tag('h5', $wwwroot . '/auth/oidc/'); return format_admin_setting($this, $this->visiblename, $html, $this->description, true, '', null, $query); }
public function output_html($data, $query = '') { if ($this->load_choices()) { return parent::output_html($data, $query); } $visiblename = get_string('services_displaylabel', 'block_mhaairs'); $description = get_string('service_down_msg', 'block_mhaairs'); return format_admin_setting($this, $visiblename, '', $description, false, '', ''); }
/** * Return an XHTML string for the setting * @return string Returns an XHTML string */ public function output_html($data, $query = '') { global $CFG; $a = new \stdClass(); $a->callbackurl = \local_msaccount\client::callback_url()->out(false); $settinghtml = get_string('settingredirect', 'local_msaccount', $a); $settinghtml .= '<input type="hidden" id="' . $this->get_id() . '" name="' . $this->get_full_name() . '" value="0" />'; return format_admin_setting($this, $this->visiblename, $settinghtml, $this->description); }
/** * Returns XHTML field(s) as required by choices * * Relies on data being an array should data ever be another valid vartype with * acceptable value this may cause a warning/error * if (!is_array($data)) would fix the problem * * @todo Add vartype handling to ensure $data is an array * * @param array $data An array of checked values * @param string $query * @return string XHTML field */ public function output_html($data, $query = '') { if (!$this->load_choices() or empty($this->choices)) { return ''; } $default = $this->get_defaultsetting(); if (is_null($default)) { $default = array(); } if (is_null($data)) { $data = array(); } $options = array(); $defaults = array(); foreach ($this->choices as $key => $description) { if (!empty($data[$key])) { $checked = 'checked="checked"'; } else { $checked = ''; } if (!empty($default[$key])) { $defaults[] = $description; } // $options[] = '<input type="checkbox" id="'.$this->get_id().'_'.$key.'" name="'.$this->get_full_name().'['.$key.']" value="1" '.$checked.' />' // .'<label for="'.$this->get_id().'_'.$key.'">'.highlightfast($query, $description).'</label>'; $options[] = '<input type="checkbox" id="' . $this->get_id() . '_' . $key . '" name="' . $this->get_full_name() . '[' . $key . ']" value="1" ' . $checked . ' />' . '<label for="' . $this->get_id() . '_' . $key . '">' . $this->icons[$key] . highlightfast($query, $description) . '</label>'; } if (is_null($default)) { $defaultinfo = NULL; } elseif (!empty($defaults)) { $defaultinfo = implode(', ', $defaults); } else { $defaultinfo = get_string('none'); } $return = '<div class="form-multicheckbox">'; $return .= '<input type="hidden" name="' . $this->get_full_name() . '[xxxxx]" value="1" />'; // something must be submitted even if nothing selected if ($options) { $return .= '<ul>'; foreach ($options as $option) { $return .= '<li>' . $option . '</li>'; } $return .= '</ul>'; } $return .= '</div>'; return format_admin_setting($this, $this->visiblename, $return, $this->description, false, '', $defaultinfo, $query); }
/** * Returns XHTML select field and wrapping div(s) * * @see output_select_html() * * @param string $data the option to show as selected * @param string $query * @return string XHTML field and wrapping div */ public function output_html($data, $query = '') { $html = ''; $baseid = $this->get_id(); $inputname = $this->get_full_name(); foreach ($this->flowtypes as $flowtype) { $html .= \html_writer::start_div(); $flowtypeid = $baseid . '_' . $flowtype; $radioattrs = ['type' => 'radio', 'name' => $inputname, 'id' => $flowtypeid, 'value' => $flowtype]; if ($data === $flowtype || empty($data) && $flowtype === $this->get_defaultsetting()) { $radioattrs['checked'] = 'checked'; } $typename = get_string('cfg_loginflow_' . $flowtype, 'auth_oidc'); $typedesc = get_string('cfg_loginflow_' . $flowtype . '_desc', 'auth_oidc'); $html .= \html_writer::empty_tag('input', $radioattrs); $html .= \html_writer::label($typename, $flowtypeid, false); $html .= '<br />'; $html .= \html_writer::span($typedesc); $html .= '<br /><br />'; $html .= \html_writer::end_div(); } return format_admin_setting($this, $this->visiblename, $html, $this->description, true, '', null, $query); }
/** * Return an XHTML string for the setting. * * @return string Returns an XHTML string */ public function output_html($data, $query = '') { global $DB, $OUTPUT; $html = \html_writer::start_tag('div'); $style = 'button.addmapping, .fieldlist select, .fieldlist button {vertical-align:middle;margin:0;}'; $style .= '.fieldlist {margin-bottom:0.5rem;}'; $html .= \html_writer::tag('style', $style); $hiddenattrs = ['type' => 'hidden', 'name' => $this->get_full_name() . '[save]', 'value' => 'save']; $html .= \html_writer::empty_tag('input', $hiddenattrs); $fieldlist = new \html_table(); $fieldlist->attributes['class'] = 'fieldlist'; $fieldlist->head = [get_string('settings_fieldmap_header_remote', 'local_o365'), '', get_string('settings_fieldmap_header_local', 'local_o365'), get_string('settings_fieldmap_header_behavior', 'local_o365')]; $fieldlist->data = []; if ($data === false) { $data = $this->get_defaultsetting(); } if (empty($data) || !is_array($data)) { $data = []; } foreach ($data as $fieldmap) { $fieldmap = explode('/', $fieldmap); if (count($fieldmap) !== 3) { continue; } list($remotefield, $localfield, $behavior) = $fieldmap; if (!isset($this->remotefields[$remotefield])) { continue; } if (!isset($this->localfields[$localfield])) { continue; } if (!isset($this->syncbehavopts[$behavior])) { continue; } $fieldlist->data[] = [\html_writer::select($this->remotefields, $this->get_full_name() . '[remotefield][]', $remotefield, false), \html_writer::tag('span', '→'), \html_writer::select($this->localfields, $this->get_full_name() . '[localfield][]', $localfield, false), \html_writer::select($this->syncbehavopts, $this->get_full_name() . '[behavior][]', $behavior, false), \html_writer::tag('button', 'X', ['class' => 'removerow'])]; } $html .= \html_writer::table($fieldlist); $html .= \html_writer::tag('button', get_string('settings_fieldmap_addmapping', 'local_o365'), ['class' => 'addmapping']); // Add row template. $maptpl = \html_writer::start_tag('tr'); $maptpl .= \html_writer::tag('td', \html_writer::select($this->remotefields, $this->get_full_name() . '[remotefield][]', '')); $maptpl .= \html_writer::tag('td', \html_writer::tag('span', '→')); $maptpl .= \html_writer::tag('td', \html_writer::select($this->localfields, $this->get_full_name() . '[localfield][]', '')); $maptpl .= \html_writer::tag('td', \html_writer::select($this->syncbehavopts, $this->get_full_name() . '[behavior][]', '', false)); $maptpl .= \html_writer::tag('td', \html_writer::tag('button', 'X', ['class' => 'removerow'])); $maptpl .= \html_writer::end_tag('tr'); $html .= \html_writer::tag('textarea', htmlentities($maptpl), ['class' => 'maptpl', 'style' => 'display:none;']); // Using a <script> tag here instead of $PAGE->requires->js() because using $PAGE object loads file too late. $scripturl = new \moodle_url('/local/o365/classes/adminsetting/fieldmap.js'); $html .= \html_writer::script('', $scripturl->out()); $html .= \html_writer::script('$(function() { $("#admin-' . $this->name . '").fieldmap({}); });'); $html .= \html_writer::end_tag('div'); return format_admin_setting($this, $this->visiblename, $html, $this->description, true, '', null, $query); }
/** * Returns an XHTML string for the editor * * @param string $data * @param string $query * @return string XHTML string for the editor */ public function output_html($data, $query='') { global $USER; $default = $this->get_defaultsetting(); $defaultinfo = $default; if (!is_null($default) and $default !== '') { $defaultinfo = "\n".$default; } $ctx = context_user::instance($USER->id); $editor = editors_get_preferred_editor(FORMAT_HTML); $options = $this->get_options(); $draftitemid = file_get_unused_draft_itemid(); $component = is_null($this->plugin) ? 'core' : $this->plugin; $data = file_prepare_draft_area($draftitemid, $options['context']->id, $component, $this->get_full_name().'_draftitemid', $draftitemid, $options, $data); $fpoptions = array(); $args = new stdClass(); // Need these three to filter repositories list. $args->accepted_types = array('web_image'); $args->return_types = $options['return_types']; $args->context = $ctx; $args->env = 'filepicker'; // Advimage plugin. $imageoptions = initialise_filepicker($args); $imageoptions->context = $ctx; $imageoptions->client_id = uniqid(); $imageoptions->maxbytes = $options['maxbytes']; $imageoptions->areamaxbytes = $options['areamaxbytes']; $imageoptions->env = 'editor'; $imageoptions->itemid = $draftitemid; // Moodlemedia plugin. $args->accepted_types = array('video', 'audio'); $mediaoptions = initialise_filepicker($args); $mediaoptions->context = $ctx; $mediaoptions->client_id = uniqid(); $mediaoptions->maxbytes = $options['maxbytes']; $mediaoptions->areamaxbytes = $options['areamaxbytes']; $mediaoptions->env = 'editor'; $mediaoptions->itemid = $draftitemid; // Advlink plugin. $args->accepted_types = '*'; $linkoptions = initialise_filepicker($args); $linkoptions->context = $ctx; $linkoptions->client_id = uniqid(); $linkoptions->maxbytes = $options['maxbytes']; $linkoptions->areamaxbytes = $options['areamaxbytes']; $linkoptions->env = 'editor'; $linkoptions->itemid = $draftitemid; $fpoptions['image'] = $imageoptions; $fpoptions['media'] = $mediaoptions; $fpoptions['link'] = $linkoptions; $editor->use_editor($this->get_id(), $options, $fpoptions); return format_admin_setting($this, $this->visiblename, '<div class="form-textarea"> <textarea rows="'. $this->rows .'" cols="'. $this->cols .'" id="'. $this->get_id() .'" name="'.$this->get_full_name() .'"spellcheck="true">'. s($data) .' </textarea> </div> <input value="'.$draftitemid.'" name="'.$this->get_full_name().'_draftitemid" type="hidden" />', $this->description, true, '', $defaultinfo, $query); }
/** * Return XHTML field(s) for regexes * * @param array $data Array of options to set in HTML * @return string XHTML string for the fields and wrapping div(s) */ public function output_html($data, $query = '') { global $OUTPUT; $out = html_writer::start_tag('table', array('border' => 1, 'class' => 'generaltable')); $out .= html_writer::start_tag('thead'); $out .= html_writer::start_tag('tr'); $out .= html_writer::tag('th', get_string('devicedetectregexexpression', 'admin')); $out .= html_writer::tag('th', get_string('devicedetectregexvalue', 'admin')); $out .= html_writer::end_tag('tr'); $out .= html_writer::end_tag('thead'); $out .= html_writer::start_tag('tbody'); if (empty($data)) { $looplimit = 1; } else { $looplimit = count($data) / 2 + 1; } for ($i = 0; $i < $looplimit; $i++) { $out .= html_writer::start_tag('tr'); $expressionname = 'expression' . $i; if (!empty($data[$expressionname])) { $expression = $data[$expressionname]; } else { $expression = ''; } $out .= html_writer::tag('td', html_writer::empty_tag('input', array('type' => 'text', 'class' => 'form-text', 'name' => $this->get_full_name() . '[expression' . $i . ']', 'value' => $expression)), array('class' => 'c' . $i)); $valuename = 'value' . $i; if (!empty($data[$valuename])) { $value = $data[$valuename]; } else { $value = ''; } $out .= html_writer::tag('td', html_writer::empty_tag('input', array('type' => 'text', 'class' => 'form-text', 'name' => $this->get_full_name() . '[value' . $i . ']', 'value' => $value)), array('class' => 'c' . $i)); $out .= html_writer::end_tag('tr'); } $out .= html_writer::end_tag('tbody'); $out .= html_writer::end_tag('table'); return format_admin_setting($this, $this->visiblename, $out, $this->description, false, '', null, $query); }
/** * Return an XHTML string for the setting. * * @return string Returns an XHTML string. */ public function output_html($data, $query = '') { global $OUTPUT; $settinghtml = ''; $oidcconfig = get_config('auth_oidc'); $clientcredspresent = !empty($oidcconfig->clientid) && !empty($oidcconfig->clientsecret) ? true : false; $endpointspresent = !empty($oidcconfig->authendpoint) && !empty($oidcconfig->tokenendpoint) ? true : false; // Input + detect button. $inputattrs = ['type' => 'text', 'class' => 'maininput', 'size' => 30, 'id' => $this->get_id(), 'name' => $this->get_full_name(), 'value' => s($data)]; $input = \html_writer::empty_tag('input', $inputattrs); if ($clientcredspresent === true && $endpointspresent === true) { $buttonattrs = ['class' => 'detect']; $strdetect = get_string('settings_serviceresourceabstract_detect', 'local_o365'); $detectbutton = \html_writer::tag('button', $strdetect, $buttonattrs); $settinghtml .= \html_writer::div($input . $detectbutton); if (!empty($data)) { $icon = $OUTPUT->pix_icon('t/check', 'valid', 'moodle'); $strvalid = get_string('settings_serviceresourceabstract_valid', 'local_o365', $this->visiblename); $statusmessage = \html_writer::tag('span', $strvalid, ['class' => 'statusmessage']); $settinghtml .= \html_writer::div($icon . $statusmessage, 'alert-success local_o365_statusmessage'); } else { $icon = $OUTPUT->pix_icon('i/warning', 'valid', 'moodle'); $strnocreds = get_string('settings_serviceresourceabstract_empty', 'local_o365'); $statusmessage = \html_writer::tag('span', $strnocreds, ['class' => 'statusmessage']); $settinghtml .= \html_writer::div($icon . $statusmessage, 'alert-info local_o365_statusmessage'); } // Using a <script> tag here instead of $PAGE->requires->js() because using $PAGE object loads file too late. $scripturl = new \moodle_url('/local/o365/classes/adminsetting/serviceresource.js'); $settinghtml .= '<script src="' . $scripturl->out() . '"></script>'; $strvalid = get_string('settings_serviceresourceabstract_valid', 'local_o365', $this->visiblename); $strinvalid = get_string('settings_serviceresourceabstract_invalid', 'local_o365', $this->visiblename); $strerror = get_string('settings_serviceresourceabstract_error', 'local_o365', $this->visiblename); $strdetect = get_string('settings_serviceresourceabstract_detect', 'local_o365', $this->visiblename); $strdetecting = get_string('settings_serviceresourceabstract_detecting', 'local_o365', $this->visiblename); $iconvalid = addslashes($OUTPUT->pix_icon('t/check', 'valid', 'moodle')); $iconinvalid = addslashes($OUTPUT->pix_icon('t/delete', 'invalid', 'moodle')); $iconloading = addslashes($OUTPUT->pix_icon('i/ajaxloader', 'loading', 'moodle')); $ajaxurl = new \moodle_url('/local/o365/ajax.php'); $settinghtml .= '<script> $(function() { var opts = { url: "' . $ajaxurl->out() . '", setting: "' . $this->name . '", strvalid: "' . $strvalid . '", strinvalid: "' . $strinvalid . '", iconvalid: "' . $iconvalid . '", iconinvalid: "' . $iconinvalid . '", iconloading: "' . $iconloading . '", strerror: "' . $strerror . '", strdetecting: "' . $strdetecting . '", strdetect: "' . $strdetect . '" }; $("#admin-' . $this->name . '").serviceresource(opts); }); </script>'; } else { $settinghtml .= \html_writer::div($input); $icon = $OUTPUT->pix_icon('i/warning', 'valid', 'moodle'); $strnocreds = get_string('settings_serviceresourceabstract_nocreds', 'local_o365'); $statusmessage = \html_writer::tag('span', $strnocreds, ['class' => 'statusmessage']); $settinghtml .= \html_writer::div($icon . $statusmessage, 'alert-info local_o365_statusmessage'); } return format_admin_setting($this, $this->visiblename, $settinghtml, $this->description); }
/** * Return an XHTML string for the setting * @return string Returns an XHTML string */ public function output_html($data, $query = '') { global $OUTPUT; $button = \html_writer::tag('button', get_string('settings_detectperms_update', 'local_o365'), ['class' => 'refreshperms']); $results = \html_writer::tag('div', '', ['class' => 'results']); $settinghtml = $button . $results; if (\local_o365\adminsetting\detectoidc::setup_step_complete() === true) { $existingsetting = $this->config_read($this->name); if (!empty($existingsetting)) { $messageattrs = ['class' => 'permmessage']; $message = \html_writer::tag('span', get_string('settings_detectperms_valid', 'local_o365'), $messageattrs); } else { $messageattrs = ['class' => 'permmessage']; $message = \html_writer::tag('span', get_string('settings_detectperms_invalid', 'local_o365'), $messageattrs); } } else { $icon = $OUTPUT->pix_icon('i/warning', 'prerequisite not complete', 'moodle'); $message = \html_writer::tag('span', get_string('settings_detectperms_nocreds', 'local_o365')); $settinghtml .= \html_writer::tag('div', $icon . $message, ['class' => 'alert-info local_o365_statusmessage']); } // Using a <script> tag here instead of $PAGE->requires->js() because using $PAGE object loads file too late. $scripturl = new \moodle_url('/local/o365/classes/adminsetting/azuresetup.js'); $settinghtml .= '<script src="' . $scripturl->out() . '"></script>'; $lastresults = get_config('local_o365', 'azuresetupresult'); if (!empty($lastresults)) { $lastresults = @unserialize($lastresults); $lastresults = !empty($lastresults) && is_object($lastresults) ? $lastresults : false; $lastresults = json_encode(['success' => true, 'data' => $lastresults]); } else { $lastresults = json_encode(false); } $unifiedenabled = \local_o365\rest\unified::is_enabled() === true ? 'true' : 'false'; $ajaxurl = new \moodle_url('/local/o365/ajax.php'); $settinghtml .= '<script> $(function() { var opts = { url: "' . $ajaxurl->out() . '", lastresults: ' . $lastresults . ', iconsuccess: "' . addslashes($OUTPUT->pix_icon('t/check', 'success', 'moodle')) . '", iconinfo: "' . addslashes($OUTPUT->pix_icon('i/warning', 'information', 'moodle')) . '", iconerror: "' . addslashes($OUTPUT->pix_icon('t/delete', 'error', 'moodle')) . '", strupdate: "' . addslashes(get_string('settings_azuresetup_update', 'local_o365')) . '", strchecking: "' . addslashes(get_string('settings_azuresetup_checking', 'local_o365')) . '", strmissingperms: "' . addslashes(get_string('settings_azuresetup_missingperms', 'local_o365')) . '", strpermscorrect: "' . addslashes(get_string('settings_azuresetup_permscorrect', 'local_o365')) . '", strfixperms: "' . addslashes(get_string('settings_detectperms_fixperms', 'local_o365')) . '", strfixprereq: "' . addslashes(get_string('settings_detectperms_fixprereq', 'local_o365')) . '", strerrorfix: "' . addslashes(get_string('settings_detectperms_errorfix', 'local_o365')) . '", strerrorcheck: "' . addslashes(get_string('settings_azuresetup_errorcheck', 'local_o365')) . '", strnoinfo: "' . addslashes(get_string('settings_azuresetup_noinfo', 'local_o365')) . '", showunified: ' . $unifiedenabled . ', strunifiedheader: "' . addslashes(get_string('settings_azuresetup_unifiedheader', 'local_o365')) . '", strunifieddesc: "' . addslashes(get_string('settings_azuresetup_unifieddesc', 'local_o365')) . '", strunifiederror: "' . addslashes(get_string('settings_azuresetup_unifiederror', 'local_o365')) . '", strunifiedpermerror: "' . addslashes(get_string('settings_azuresetup_strunifiedpermerror', 'local_o365')) . '", strunifiedmissing: "' . addslashes(get_string('settings_azuresetup_unifiedmissing', 'local_o365')) . '", strunifiedactive: "' . addslashes(get_string('settings_azuresetup_unifiedactive', 'local_o365')) . '", strlegacyheader: "' . addslashes(get_string('settings_azuresetup_legacyheader', 'local_o365')) . '", strlegacydesc: "' . addslashes(get_string('settings_azuresetup_legacydesc', 'local_o365')) . '", strlegacyerror: "' . addslashes(get_string('settings_azuresetup_legacyerror', 'local_o365')) . '", strtenanterror: "' . addslashes(get_string('settings_azuresetup_strtenanterror', 'local_o365')) . '" }; $("#admin-' . $this->name . '").azuresetup(opts); }); </script>'; return format_admin_setting($this, $this->visiblename, $settinghtml, $this->description, true, '', null, $query); }
/** * Get admin setting HTML. * * @param mixed $data Saved data. * @param string $query * @return string The setting HTML. */ public function output_html($data, $query = '') { global $OUTPUT; $html = '<style> label.iconselect { display: inline-block !important; padding: 0 !important; margin: 5px; } label.iconselect img { width: 25px; height: 25px; padding: 10px; } input.iconselect { display: none; } input[type="radio"].iconselect:checked + label.iconselect { outline: 1px solid #007fec; } body.ie input.iconselect { display: inline-block; } body.ie label.iconselect { margin-left: 0; margin-right: 20px; } body.ie label.iconselect img { padding: 5px; } </style>'; $html .= \html_writer::start_tag('div', ['style' => 'max-width: 390px']); $selected = !empty($data) ? $data : $this->defaultsetting; foreach ($this->choices as $icon) { $id = $icon['component'] . ':' . $icon['pix']; $iconhtml = $OUTPUT->pix_icon($icon['pix'], $icon['alt'], $icon['component']); $inputattrs = ['type' => 'radio', 'id' => $id, 'name' => $this->get_full_name(), 'value' => $id, 'class' => 'iconselect']; if ($id === $selected) { $inputattrs['checked'] = 'checked'; } $html .= \html_writer::empty_tag('input', $inputattrs); $labelattrs = ['class' => 'iconselect']; $html .= \html_writer::label($iconhtml, $id, true, $labelattrs); } $html .= \html_writer::end_tag('div'); return format_admin_setting($this, $this->visiblename, $html, $this->description, true, '', null, $query); }
/** * Returns XHTML field(s) as required by choices * * Relies on data being an array should data ever be another valid vartype with * acceptable value this may cause a warning/error * if (!is_array($data)) would fix the problem * * @todo Add vartype handling to ensure $data is an array * * @param array $data An array of checked values * @param string $query * @return string XHTML field */ public function output_html($data, $query = '') { $return = '<div style="float:left; width:auto; margin-right: 0.5em;">'; $return .= '<div style="height: 2em;">' . get_string('roles', 'role') . '</div>'; foreach ($data as $role) { $return .= '<div style="height: 2em;">' . s($role['name']) . '</div>'; } $return .= '</div>'; $return .= '<div style="float:left; width:auto; margin-right: 0.5em;">'; $return .= '<div style="height: 2em;">' . get_string('contexts', 'enrol_ldap') . '</div>'; foreach ($data as $role) { $contextid = $this->get_id() . '[' . $role['id'] . '][contexts]'; $contextname = $this->get_full_name() . '[' . $role['id'] . '][contexts]'; $return .= '<div style="height: 2em;"><label class="accesshide" for="' . $contextid . '">' . get_string('role_mapping_context', 'enrol_ldap', $role['name']) . '</label>'; $return .= '<input type="text" size="40" id="' . $contextid . '" name="' . $contextname . '" value="' . s($role['contexts']) . '"/></div>'; } $return .= '</div>'; $return .= '<div style="float:left; width:auto; margin-right: 0.5em;">'; $return .= '<div style="height: 2em;">' . get_string('memberattribute', 'enrol_ldap') . '</div>'; foreach ($data as $role) { $memberattrid = $this->get_id() . '[' . $role['id'] . '][memberattribute]'; $memberattrname = $this->get_full_name() . '[' . $role['id'] . '][memberattribute]'; $return .= '<div style="height: 2em;"><label class="accesshide" for="' . $memberattrid . '">' . get_string('role_mapping_attribute', 'enrol_ldap', $role['name']) . '</label>'; $return .= '<input type="text" size="15" id="' . $memberattrid . '" name="' . $memberattrname . '" value="' . s($role['memberattribute']) . '"/></div>'; } $return .= '</div>'; $return .= '<div style="clear:both;"></div>'; return format_admin_setting($this, $this->visiblename, $return, $this->description, true, '', '', $query); }
/** * Output the link to the upload image page. * * @param mixed $data * @param string $query * @return string */ public function output_html($data, $query = '') { // Create a dummy variable for this field to avoid being redirected back to the upgrade settings page. $this->config_write($this->name, ''); return format_admin_setting($this, $this->visiblename, html_writer::link(new moodle_url('/mod/customcert/upload_image.php'), get_string('upload')), $this->description, true, '', null, $query); }
/** * Returns an HTML string for the redirect uri display. * * @return string Returns an HTML string. */ public function output_html($data, $query = '') { global $CFG; $html = \html_writer::tag('h5', $CFG->wwwroot . '/auth/oidc/'); return format_admin_setting($this, $this->visiblename, $html, $this->description, true, '', null, $query); }
function output_html($data, $query = '') { global $CFG; $id = $this->get_id(); $return = "<table id='{$id}' class='flexible generaltable generalbox'>\n <tr><th class='header'>" . get_string('plugin', 'block_yui_menu') . "</th>"; $settings = array('enabled', 'visible', 'order'); foreach ($settings as $s) { $return .= "<th class='header'>" . get_string($s, 'block_yui_menu') . "</th>"; } $return .= "</tr>\n"; $plugins = $this->get_setting(); $i = 0; foreach ($plugins as $plugin => $options) { $id = $this->get_id() . '_' . $plugin; $name = $this->get_full_name(); //.'_'.$plugin; $return .= "<tr><td class='cell'>{$plugin}</td>"; foreach ($settings as $s) { if ($s === 'order') { $return .= "\n <td class='form-text'><input type='text' value='{$i}' id='{$id}_{$s}'\n name='{$name}[{$plugin}][{$s}]' size='2' /></td>\n"; } else { $check = $options[$s] ? ' checked="checked"' : ''; $return .= "\n <td class='form-checkbox'><input type='checkbox' value = '1'\n id='{$id}_{$s}' name='{$name}[{$plugin}][{$s}]'{$check} /></td>"; } } $i++; $return .= "</tr>\n"; } $return .= "</table>\n"; return format_admin_setting($this, $this->visiblename, $return, $this->description, false, '', NULL, $query); }
/** * Generates the HTML for the setting * * @global moodle_page $PAGE * @global core_renderer $OUTPUT * @param string $data * @param string $query */ public function output_html($data, $query = '') { global $PAGE, $OUTPUT; $PAGE->requires->js_init_call('M.util.init_colour_picker', array($this->get_id(), $this->previewconfig)); $content = html_writer::start_tag('div', array('class' => 'form-colourpicker defaultsnext')); $content .= html_writer::tag('div', $OUTPUT->pix_icon('i/loading', get_string('loading', 'admin'), 'moodle', array('class' => 'loadingicon')), array('class' => 'admin_colourpicker clearfix')); $content .= html_writer::empty_tag('input', array('type' => 'text', 'id' => $this->get_id(), 'name' => $this->get_full_name(), 'value' => $this->get_setting(), 'size' => '12')); if (!empty($this->previewconfig)) { $content .= html_writer::empty_tag('input', array('type' => 'button', 'id' => $this->get_id() . '_preview', 'value' => get_string('preview'), 'class' => 'admin_colourpicker_preview')); } $content .= html_writer::end_tag('div'); return format_admin_setting($this, $this->visiblename, $content, $this->description, false, '', $this->get_defaultsetting(), $query); }
/** * Return an XHTML string for the setting * @return string Returns an XHTML string */ public function output_html($data, $query = '') { global $OUTPUT; $settingspage = new \moodle_url('/admin/settings.php?section=authsettingoidc'); if (static::setup_step_complete() === true) { $icon = $OUTPUT->pix_icon('t/check', 'success', 'moodle'); $message = \html_writer::tag('span', get_string('settings_detectoidc_credsvalid', 'local_o365')); $linkstr = get_string('settings_detectoidc_credsvalid_link', 'local_o365'); $link = \html_writer::link($settingspage, $linkstr, ['style' => 'margin-left: 1rem']); $html = \html_writer::tag('div', $icon . $message . $link, ['class' => 'alert-success local_o365_statusmessage']); } else { $icon = $OUTPUT->pix_icon('t/delete', 'success', 'moodle'); $message = \html_writer::tag('span', get_string('settings_detectoidc_credsinvalid', 'local_o365')); $linkstr = get_string('settings_detectoidc_credsinvalid_link', 'local_o365'); $link = \html_writer::link($settingspage, $linkstr, ['style' => 'margin-left: 1rem']); $html = \html_writer::tag('div', $icon . $message . $link, ['class' => 'alert-error local_o365_statusmessage']); } return format_admin_setting($this, $this->visiblename, $html, $this->description, true, '', null, $query); }
function output_html($data, $query = '') { // $default = $this->get_defaultsetting(); $default = NULL; $preVal = $this->get_setting(); $inner_text = '<input type="hidden" id="' . $this->get_id() . '" name="' . $this->get_full_name() . '" value="' . $preVal . '" />'; foreach ($this->choices as $key => $val) { $inner_text .= '<input type="radio" id="' . $this->get_id() . $key . '" name="' . $this->get_full_name() . '_radio" value="' . $key . '" ' . ($preVal == $key ? ' checked="checked" ' : '') . 'onclick="document.getElementById(\'' . $this->get_id() . '\').value=\'' . $key . '\';" />' . $val . '<br />'; } return format_admin_setting($this, $this->visiblename, '<div class="form-text defaultsnext">' . $inner_text . '</div>', $this->description, true, '', $default, $query); }
function output_html($data, $query = '') { $value = $data['value']; $forced = !empty($data['forced']); $adv = !empty($data['adv']); $return = '<select class="form-select" id="' . $this->get_id() . '" name="' . $this->get_full_name() . '[value]">'; foreach ($this->choices as $key => $val) { // the string cast is needed because key may be integer - 0 is equal to most strings! $return .= '<option value="' . $key . '"' . ((string) $key == $value ? ' selected="selected"' : '') . '>' . $val . '</option>'; } $return .= '</select>'; $return .= '<input type="checkbox" class="form-checkbox" id="' . $this->get_id() . 'force" name="' . $this->get_full_name() . '[forced]" value="1" ' . ($forced ? 'checked="checked"' : '') . ' />' . '<label for="' . $this->get_id() . 'force">' . get_string('force') . '</label>'; $return .= '<input type="checkbox" class="form-checkbox" id="' . $this->get_id() . 'adv" name="' . $this->get_full_name() . '[adv]" value="1" ' . ($adv ? 'checked="checked"' : '') . ' />' . '<label for="' . $this->get_id() . 'adv">' . get_string('advanced') . '</label>'; return format_admin_setting($this, $this->visiblename, $return, $this->description, true, '', NULL, $query); }
/** * Return XHTML to display the field and wrapping div * * @todo Add vartype handling to ensure $data is array * @param array $data Associative array of value=>xx, forced=>xx, adv=>xx * @param string $query * @return string XHTML to display control */ public function output_html($data, $query = '') { $value = $data['value']; $forced = !empty($data['forced']); $adv = !empty($data['adv']); $default = $this->get_defaultsetting(); if (!is_null($default)) { $defaultinfo = array(); if (isset($this->choices[$default['value']])) { $defaultinfo[] = $this->choices[$default['value']]; } if (!empty($default['forced'])) { $defaultinfo[] = get_string('force'); } if (!empty($default['adv'])) { $defaultinfo[] = get_string('advanced'); } $defaultinfo = implode(', ', $defaultinfo); } else { $defaultinfo = NULL; } $return = '<div class="form-group">'; $return .= '<select class="form-select" id="' . $this->get_id() . '" name="' . $this->get_full_name() . '[value]">'; foreach ($this->choices as $key => $val) { // the string cast is needed because key may be integer - 0 is equal to most strings! $return .= '<option value="' . $key . '"' . ((string) $key == $value ? ' selected="selected"' : '') . '>' . $val . '</option>'; } $return .= '</select>'; $return .= '<input type="checkbox" class="form-checkbox" id="' . $this->get_id() . 'force" name="' . $this->get_full_name() . '[forced]" value="1" ' . ($forced ? 'checked="checked"' : '') . ' />' . '<label for="' . $this->get_id() . 'force">' . get_string('force') . '</label>'; $return .= '<input type="checkbox" class="form-checkbox" id="' . $this->get_id() . 'adv" name="' . $this->get_full_name() . '[adv]" value="1" ' . ($adv ? 'checked="checked"' : '') . ' />' . '<label for="' . $this->get_id() . 'adv">' . get_string('advanced') . '</label>'; $return .= '</div>'; return format_admin_setting($this, $this->visiblename, $return, $this->description, true, '', $defaultinfo, $query); }
public function output_html($data, $query = '') { if (is_array($data) || empty($data)) { $data = $this->normalise_data($data); } $return = '<div class="group"><input type="hidden" name="' . $this->get_full_name() . '[' . self::DURING . ']" value="0" />'; foreach (self::times() as $timemask => $namestring) { $id = $this->get_id() . '_' . $timemask; $state = ''; if ($data & $timemask) { $state = 'checked="checked" '; } if ($timemask == self::DURING && !is_null($this->duringstate)) { $state = 'disabled="disabled" '; if ($this->duringstate) { $state .= 'checked="checked" '; } } $return .= '<span><input type="checkbox" name="' . $this->get_full_name() . '[' . $timemask . ']" value="1" id="' . $id . '" ' . $state . '/> <label for="' . $id . '">' . $namestring . "</label></span>\n"; } $return .= "</div>\n"; return format_admin_setting($this, $this->visiblename, $return, $this->description, true, '', get_string('everythingon', 'quiz'), $query); }
/** * Returns XHTML time select fields * * @param array $data Must be form 'h'=>xx, 'm'=>xx * @param string $query * @return string XHTML time select fields and wrapping div(s) */ public function output_html($data, $query = '') { $default = $this->get_defaultsetting(); if (is_array($default)) { $defaultinfo = $default['y'] . '-' . $default['M'] . '-' . $default['d'] . ' ' . $default['h'] . ':' . $default['m']; } else { $defaultinfo = NULL; } $return = '<div class="form-datetime defaultsnext">'; $return .= '<select id="' . $this->get_id() . 'y" name="' . $this->get_full_name() . '[y]">'; for ($i = 2010; $i < 2030; $i++) { $return .= '<option value="' . $i . '"' . ($i == $data['y'] ? ' selected="selected"' : '') . '>' . $i . '</option>'; } $return .= '</select><select id="' . $this->get_id() . 'M" name="' . $this->get_full_name() . '[M]">'; for ($i = 1; $i < 12; $i++) { $return .= '<option value="' . $i . '"' . ($i == $data['M'] ? ' selected="selected"' : '') . '>' . sprintf('%02d', $i) . '</option>'; } $return .= '</select><select id="' . $this->get_id() . 'd" name="' . $this->get_full_name() . '[d]">'; for ($i = 1; $i < 31; $i++) { $return .= '<option value="' . $i . '"' . ($i == $data['d'] ? ' selected="selected"' : '') . '>' . sprintf('%02d', $i) . '</option>'; } $return .= '</select><select id="' . $this->get_id() . 'h" name="' . $this->get_full_name() . '[h]">'; for ($i = 0; $i < 24; $i++) { $return .= '<option value="' . $i . '"' . ($i == $data['h'] ? ' selected="selected"' : '') . '>' . $i . '</option>'; } $return .= '</select>:<select id="' . $this->get_id() . 'm" name="' . $this->get_full_name() . '[m]">'; for ($i = 0; $i < 60; $i += 5) { $return .= '<option value="' . $i . '"' . ($i == $data['m'] ? ' selected="selected"' : '') . '>' . $i . '</option>'; } $return .= '</select></div>'; return format_admin_setting($this, $this->visiblename, $return, $this->description, false, '', $defaultinfo, $query); }
/** * Return an XHTML string for the setting * @return string Returns an XHTML string */ public function output_html($data, $query = '') { global $OUTPUT; $tokens = get_config('local_o365', 'systemtokens'); $setuser = ''; if (!empty($tokens)) { $tokens = unserialize($tokens); if (isset($tokens['idtoken'])) { try { $idtoken = \auth_oidc\jwt::instance_from_encoded($tokens['idtoken']); $setuser = $idtoken->claim('upn'); } catch (\Exception $e) { // There is a check below for an empty $setuser. } } } $settinghtml = '<input type="hidden" id="' . $this->get_id() . '" name="' . $this->get_full_name() . '" value="0" />'; $setuserurl = new \moodle_url('/local/o365/acp.php', ['mode' => 'setsystemuser']); if (!empty($setuser)) { $message = \html_writer::tag('span', get_string('settings_systemapiuser_userset', 'local_o365', $setuser)) . ' '; $linkstr = get_string('settings_systemapiuser_change', 'local_o365'); $message .= \html_writer::link($setuserurl, $linkstr, ['class' => 'btn', 'style' => 'margin-left: 0.5rem']); $messageattrs = ['class' => 'local_o365_statusmessage alert-success']; $icon = $OUTPUT->pix_icon('t/check', 'success', 'moodle'); $settinghtml .= \html_writer::tag('div', $icon . $message, $messageattrs); } else { $message = \html_writer::tag('span', get_string('settings_systemapiuser_usernotset', 'local_o365')) . ' '; $linkstr = get_string('settings_systemapiuser_setuser', 'local_o365'); $message .= \html_writer::link($setuserurl, $linkstr, ['class' => 'btn', 'style' => 'margin-left: 0.5rem']); $messageattrs = ['class' => 'local_o365_statusmessage alert-info']; $icon = $OUTPUT->pix_icon('i/warning', 'warning', 'moodle'); $settinghtml .= \html_writer::tag('div', $icon . $message, $messageattrs); } return format_admin_setting($this, $this->visiblename, $settinghtml, $this->description); }
/** * Outputs the html for this setting. * @return string Returns an XHTML string */ public function output_html($data, $query = '') { global $OUTPUT; $o = ''; if (!extension_loaded($this->extension)) { $warning = $OUTPUT->pix_icon('i/warning', '', '', array('role' => 'presentation')) . ' ' . $this->description; $o .= format_admin_setting($this, $this->visiblename, $warning); } return $o; }
function output_html($data, $query = '') { // Create a dummy var for this field $this->config_write($this->name, ''); return format_admin_setting($this, $this->visiblename, html_writer::link(new moodle_url('/mod/iomadcertificate/upload_image.php'), get_string('upload')), $this->description, true, '', null, $query); }
/** * Returns XHTML field(s) as required by choices * * Relies on data being an array should data ever be another valid vartype with * acceptable value this may cause a warning/error * if (!is_array($data)) would fix the problem * * @todo Add vartype handling to ensure $data is an array * * @param array $data An array of checked values * @param string $query * @return string XHTML field */ public function output_html($data, $query = '') { $return = html_writer::start_tag('div', array('style' => 'float:left; width:auto; margin-right: 0.5em;')); $return .= html_writer::tag('div', get_string('roles', 'role'), array('style' => 'height: 2em;')); foreach ($data as $role) { $return .= html_writer::tag('div', s($role['name']), array('style' => 'height: 2em;')); } $return .= html_writer::end_tag('div'); $return .= html_writer::start_tag('div', array('style' => 'float:left; width:auto; margin-right: 0.5em;')); $return .= html_writer::tag('div', get_string('contexts', 'enrol_ldap'), array('style' => 'height: 2em;')); foreach ($data as $role) { $contextid = $this->get_id() . '[' . $role['id'] . '][contexts]'; $contextname = $this->get_full_name() . '[' . $role['id'] . '][contexts]'; $return .= html_writer::start_tag('div', array('style' => 'height: 2em;')); $return .= html_writer::label(get_string('role_mapping_context', 'enrol_ldap', $role['name']), $contextid, false, array('class' => 'accesshide')); $attrs = array('type' => 'text', 'size' => '40', 'id' => $contextid, 'name' => $contextname, 'value' => s($role['contexts'])); $return .= html_writer::empty_tag('input', $attrs); $return .= html_writer::end_tag('div'); } $return .= html_writer::end_tag('div'); $return .= html_writer::start_tag('div', array('style' => 'float:left; width:auto; margin-right: 0.5em;')); $return .= html_writer::tag('div', get_string('memberattribute', 'enrol_ldap'), array('style' => 'height: 2em;')); foreach ($data as $role) { $memberattrid = $this->get_id() . '[' . $role['id'] . '][memberattribute]'; $memberattrname = $this->get_full_name() . '[' . $role['id'] . '][memberattribute]'; $return .= html_writer::start_tag('div', array('style' => 'height: 2em;')); $return .= html_writer::label(get_string('role_mapping_attribute', 'enrol_ldap', $role['name']), $memberattrid, false, array('class' => 'accesshide')); $attrs = array('type' => 'text', 'size' => '15', 'id' => $memberattrid, 'name' => $memberattrname, 'value' => s($role['memberattribute'])); $return .= html_writer::empty_tag('input', $attrs); $return .= html_writer::end_tag('div'); } $return .= html_writer::end_tag('div'); $return .= html_writer::tag('div', '', array('style' => 'clear:both;')); return format_admin_setting($this, $this->visiblename, $return, $this->description, true, '', '', $query); }
public function output_html($data, $query = '') { global $CFG; return format_admin_setting($this, "", '<div class="defaultsnext" >' . '<a href="' . $CFG->wwwroot . '/mod/lti/typessettings.php">' . get_string('filterconfig', 'lti') . '</a>' . '</div>', $this->description, true, '', null, $query); }