function display_add_field($recordid = 0, $formdata = null) { global $CFG, $DB, $OUTPUT; if ($formdata) { $fieldname = 'field_' . $this->field->id; if (isset($formdata->$fieldname)) { $content = $formdata->$fieldname; } else { $content = ''; } } else if ($recordid) { $content = trim($DB->get_field('data_content', 'content', array('fieldid'=>$this->field->id, 'recordid'=>$recordid))); } else { $content = ''; } $str = '<div title="' . s($this->field->description) . '">'; $str .= '<fieldset><legend><span class="accesshide">' . $this->field->name; if ($this->field->required) { $str .= ' ' . get_string('requiredelement', 'form') . '</span></legend>'; $image = html_writer::img($OUTPUT->pix_url('req'), get_string('requiredelement', 'form'), array('class' => 'req', 'title' => get_string('requiredelement', 'form'))); $str .= html_writer::div($image, 'inline-req'); } else { $str .= '</span></legend>'; } $i = 0; $requiredstr = ''; $options = explode("\n", $this->field->param1); foreach ($options as $radio) { $radio = trim($radio); if ($radio === '') { continue; // skip empty lines } $str .= '<input type="radio" id="field_'.$this->field->id.'_'.$i.'" name="field_' . $this->field->id . '" '; $str .= 'value="' . s($radio) . '" class="mod-data-input m-r-1" '; if ($content == $radio) { // Selected by user. $str .= 'checked />'; } else { $str .= '/>'; } $str .= '<label for="field_'.$this->field->id.'_'.$i.'">'.$radio.'</label><br />'; $i++; } $str .= '</fieldset>'; $str .= '</div>'; return $str; }
public function notification($message, $classes = 'notifyproblem') { $message = clean_text($message); if ($classes == 'notifyproblem') { return html_writer::div($message, 'alert alert-danger'); } if ($classes == 'notifywarning') { return html_writer::div($message, 'alert alert-warning'); } if ($classes == 'notifysuccess') { return html_writer::div($message, 'alert alert-success'); } if ($classes == 'notifymessage') { return html_writer::div($message, 'alert alert-info'); } if ($classes == 'redirectmessage') { return html_writer::div($message, 'alert alert-block alert-info'); } return html_writer::div($message, $classes); }
public function display($discussion) { $button = false; $script = 'feature/flagdiscussion/flag.php'; if ($discussion->is_flagged()) { $flag = 0; $name = get_string('removeflag', 'forumngfeature_flagdiscussion'); $button = true; } else { if (!$discussion->is_deleted()) { $flag = 1; $name = get_string('flagdiscussion', 'forumngfeature_flagdiscussion'); $button = true; } } if ($button) { $html = parent::get_button($discussion, $name, $script, false, array('d' => $discussion->get_id(), 'flag' => $flag)); return html_writer::div($html, "forumng_flagdis fngflg{$flag}"); } }
/** * Form definition */ public function definition() { $mform =& $this->_form; $orphanedfiles = $this->_customdata['orphanedfiles']; $filecount = count($orphanedfiles); $directory = html_writer::span(get_string('directory', 'report_filetrash'), 'bold trashheader'); $name = html_writer::span(get_string('filename', 'report_filetrash'), 'bold trashheader'); $size = html_writer::span(get_string('filesize', 'report_filetrash'), 'bold trashheader'); $extensionheader = html_writer::span(get_string('extension', 'report_filetrash'), 'bold trashheader'); if ($filecount > 0) { $i = 0; $mform->addElement('checkbox', 'selectall', get_string('selectall', 'report_filetrash')); foreach ($orphanedfiles as $file) { $i++; $filepath = $file['filepath']; $filename = $file['filename']; $filekey = $file['filekey']; $filesize = $file['filesize']; $extension = $file['extension']; $link = new moodle_url('/report/filetrash/file.php', array('filepath' => $filepath, 'filename' => $filename)); $filelink = html_writer::link($link, $filename); $header = html_writer::div($directory . $filepath); $body = html_writer::div($name . $filelink); if (empty($extension)) { $extensiondetails = ''; } else { $extensiondetails = html_writer::div($extensionheader . $extension); } $footer = html_writer::div($size . $filesize); $filedetails = html_writer::div($header . $body . $extensiondetails . $footer, 'filetrashdetails'); $mform->addElement('checkbox', 'orphan_' . $filekey, $i . '. ', $filedetails); } $mform->addElement('submit', 'submit', get_string('delete'), 'submit', null); } else { $mform->addElement('static', 'nofiles', '', get_string('nofiles', 'report_filetrash')); } }
/** * Updating output to include javascript to initiate a lightbox effect on drawing type questions * so that the images are smaller unless clicked on for review * * @param \mod_activequiz\activequiz_question $question The realtime quiz question * @param array $attempts An array of \mod_activequiz\activequiz_attempt classes * @param string $output The current output from getting the results * @return string Return the updated output to be passed to the client */ public function modify_questionresults_duringquiz($question, $attempts, $output) { global $DB; // if no attempts just return the output if (empty($attempts)) { return $output; } // get the question definition to determine response format reset($attempts); $attempt = current($attempts); /** @var \mod_activequiz\activequiz_attempt $attempt */ $quba = $attempt->get_quba(); $slot = $attempt->get_question_slot($question); $qa = $quba->get_question_attempt($slot); // now get question definition $questiondef = $qa->get_question(); if ($questiondef->responseformat == 'picture') { // if the response format is a picture, meaning drawing type add the js for lightbox stuff $picturejs = \html_writer::start_tag('script', array('type' => 'text/javascript', 'id' => 'poodllrecording_js')); $picturejs .= ' activequiz.questionmodifiers.poodllrecording.lightbox_images(); '; $picturejs .= \html_writer::end_tag('script'); $newoutput = $output . $picturejs; $newoutput = \html_writer::div($newoutput, '', array('id' => 'poodllrecording-picture')); } else { $newoutput = $output; } return $newoutput; }
/** * Render the header. * * @param ratingallocate_header $header * @return string */ public function render_ratingallocate_header(ratingallocate_header $header) { $o = ''; $this->page->set_heading($this->page->course->fullname); $this->page->requires->css('/mod/ratingallocate/styles.css'); $o .= $this->output->header(); $heading = format_string($header->ratingallocate->name, false, array('context' => $header->context)); $o .= $this->output->heading($heading); if ($header->showintro) { $intro_text = format_module_intro('ratingallocate', $header->ratingallocate, $header->coursemoduleid); if ($intro_text) { $o .= $this->output->box_start('generalbox boxaligncenter', 'intro'); $o .= $intro_text; $o .= $this->output->box_end(); } } //$o .= $this->notifications; if (!empty($this->notifications)) { $o .= $this->output->box_start('box generalbox boxaligncenter'); foreach ($this->notifications as $elem) { $o .= html_writer::div(format_text($elem)); } $o .= $this->output->box_end(); } return $o; }
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); }
function display_add_field($recordid = 0, $formdata = null) { global $DB, $OUTPUT; if ($formdata) { $fieldname = 'field_' . $this->field->id; $content = $formdata->{$fieldname}; } else { if ($recordid) { $content = $DB->get_field('data_content', 'content', array('fieldid' => $this->field->id, 'recordid' => $recordid)); $content = trim($content); } else { $content = ''; } } $str = '<div title="' . s($this->field->description) . '">'; $options = array(); $rawoptions = explode("\n", $this->field->param1); foreach ($rawoptions as $option) { $option = trim($option); if (strlen($option) > 0) { $options[$option] = $option; } } $str .= '<label for="' . 'field_' . $this->field->id . '">'; $str .= html_writer::span($this->field->name, 'accesshide'); if ($this->field->required) { $image = html_writer::img($OUTPUT->pix_url('req'), get_string('requiredelement', 'form'), array('class' => 'req', 'title' => get_string('requiredelement', 'form'))); $str .= html_writer::div($image, 'inline-req'); } $str .= '</label>'; $str .= html_writer::select($options, 'field_' . $this->field->id, $content, array('' => get_string('menuchoose', 'data')), array('id' => 'field_' . $this->field->id, 'class' => 'mod-data-input custom-select')); $str .= '</div>'; return $str; }
protected function detail_pair($key, $value, $class = '') { $html = html_writer::start_div('detail-pair row ' . preg_replace('#[^a-zA-Z0-9_\\-]#', '-', $class)); $html .= html_writer::div(html_writer::span($key), 'pair-key col-sm-3'); $html .= html_writer::div(html_writer::span($value), 'pair-value col-sm-9'); $html .= html_writer::end_div(); return $html; }
/** * Renderers a key value pair of information for display. * * @param string $key * @param string $value * @param string $class * @return string */ protected function detail_pair($key, $value, $class = '') { $html = html_writer::start_div('detail-pair row yui3-g ' . preg_replace('#[^a-zA-Z0-9_\\-]#', '-', $class)); $html .= html_writer::div(html_writer::span($key), 'pair-key span4 yui3-u-1-4'); $html .= html_writer::div(html_writer::span($value), 'pair-value span8 yui3-u-3-4'); $html .= html_writer::end_div(); return $html; }
protected function specific_definition($mform) { // Fields for editing HTML block title and contents. $mform->addElement('header', 'configheader', get_string('blocksettings', 'block')); $mform->addElement('text', 'config_title', get_string('configtitle', 'block_databasetags')); $mform->setType('config_title', PARAM_TEXT); $mform->setDefault('config_title', get_string('pluginname', 'block_databasetags')); $numberofdatabasetags = array(); for ($i = 1; $i <= 200; $i++) { $numberofdatabasetags[$i] = $i; } $mform->addElement('select', 'config_numberofdatabasetags', get_string('numberoftags', 'block_databasetags'), $numberofdatabasetags); $mform->setDefault('config_numberofdatabasetags', 80); $cloudablefields = $this->get_cloudablefields(); $lastcloudablefield = null; $mform->addElement('header', 'fieldstodisplay', get_string('fieldstodisplay', 'block_databasetags')); $mform->addElement('html', html_writer::div(get_string('fieldsintro', 'block_databasetags'))); $mform->addElement('html', '<ul>'); foreach ($cloudablefields as $checkbox) { if (isset($lastcheckbox) && $lastcheckbox->categoryname != $checkbox->categoryname && !empty($lastcheckbox->categoryname)) { $mform->addElement('html', "</ul>"); } if (isset($lastcheckbox) && $lastcheckbox->coursename != $checkbox->coursename) { $mform->addElement('html', "</ul>"); } if (isset($lastcheckbox) && $lastcheckbox->activityname != $checkbox->activityname) { $mform->addElement('html', "</ul>"); } if (!isset($lastcheckbox) && !empty($lastcheckbox->categoryname)) { $mform->addElement('html', "<li class='categoryname'>{$checkbox->categoryname}</li><ul>"); } else { if (isset($lastcheckbox) && $lastcheckbox->categoryname != $checkbox->categoryname) { $mform->addElement('html', "<li class='categoryname'>{$checkbox->categoryname}</li><ul>"); } } if (!isset($lastcheckbox)) { $mform->addElement('html', "<li class='coursename'>{$checkbox->coursename}</li><ul>"); } else { if ($lastcheckbox->coursename != $checkbox->coursename) { $mform->addElement('html', "<li class='coursename'>{$checkbox->coursename}</li><ul>"); } } if (!isset($lastcheckbox)) { $mform->addElement('html', "<li class='activityname'>{$checkbox->activityname}</li><ul>"); } else { if ($lastcheckbox->activityname != $checkbox->activityname) { $mform->addElement('html', "<li class='activityname'>{$checkbox->activityname}</li><ul>"); } } $mform->addElement('html', '<li class=\'fieldname\'>'); $mform->addElement('checkbox', 'config_field_' . $checkbox->fieldid, $checkbox->fieldname); $mform->addElement('html', '</li>'); $lastcheckbox = $checkbox; } $mform->addElement('html', '</ul></ul>'); }
function fetchSWFWidgetCode($widget, $params, $width, $height, $bgcolor = "#FFFFFF") { global $CFG; $widgetid = html_writer::random_id('laszlobase'); $widgetjson = \filter_poodll\poodlltools::fetchSWFWidgetJSON($widget, $params, $width, $height, $bgcolor = "#FFFFFF", $widgetid); $retcode = html_writer::div('', '', array('id' => $widgetid . 'Container')); $retcode .= '<script type="text/javascript" src="' . $CFG->httpswwwroot . '/filter/poodll/flash/embed-compressed.js"></script> <script type="text/javascript"> lz.embed.swf(' . $widgetjson . ')</script>'; return $retcode; }
public function full_header() { $html = html_writer::start_tag('header', array('id' => 'page-header', 'class' => 'clearfix')); $html .= html_writer::start_div('clearfix', array('id' => 'page-navbar')); $html .= html_writer::tag('nav', $this->navbar(), array('class' => 'breadcrumb-nav')); $html .= html_writer::div($this->page_heading_button(), 'breadcrumb-button'); $html .= html_writer::end_div(); $html .= html_writer::tag('div', $this->course_header(), array('id' => 'course-header')); $html .= html_writer::end_tag('header'); return $html; }
/** * Form definition. */ protected function definition() { global $USER; $mform =& $this->_form; $mform->addElement('html', \html_writer::tag('h2', get_string('ucp_onenote_title', 'local_o365'))); $mform->addElement('html', \html_writer::div(get_string('ucp_onenote_desc', 'local_o365'))); $mform->addElement('html', '<br />'); $mform->addElement('html', \html_writer::tag('b', get_string('ucp_options', 'local_o365'))); $mform->addElement('advcheckbox', 'disableo365onenote', get_string('ucp_onenote_disable', 'local_o365')); $this->add_action_buttons(); }
/** * Produces a table to visually compare roles and capabilities. * * @param array $capabilities An array of capabilities to show comparison for. * @param int $contextid The context we are displaying for. * @param array $roles An array of roles to show comparison for. * @return string */ public function capability_comparison_table(array $capabilities, $contextid, array $roles) { $strpermissions = $this->get_permission_strings(); $permissionclasses = $this->get_permission_classes(); if ($contextid === context_system::instance()->id) { $strpermissions[CAP_INHERIT] = new lang_string('notset', 'role'); } $table = new html_table(); $table->attributes['class'] = 'comparisontable'; $table->head = array(' '); foreach ($roles as $role) { $url = new moodle_url('/admin/roles/define.php', array('action' => 'view', 'roleid' => $role->id)); $table->head[] = html_writer::div(html_writer::link($url, $role->localname)); } $table->data = array(); foreach ($capabilities as $capability) { $contexts = tool_capability_calculate_role_data($capability, $roles); $captitle = new html_table_cell(get_capability_string($capability) . html_writer::span($capability)); $captitle->header = true; $row = new html_table_row(array($captitle)); foreach ($roles as $role) { if (isset($contexts[$contextid]->rolecapabilities[$role->id])) { $permission = $contexts[$contextid]->rolecapabilities[$role->id]; } else { $permission = CAP_INHERIT; } $cell = new html_table_cell($strpermissions[$permission]); $cell->attributes['class'] = $permissionclasses[$permission]; $row->cells[] = $cell; } $table->data[] = $row; } // Start the list item, and print the context name as a link to the place to make changes. if ($contextid == context_system::instance()->id) { $url = new moodle_url('/admin/roles/manage.php'); $title = get_string('changeroles', 'tool_capability'); } else { $url = new moodle_url('/admin/roles/override.php', array('contextid' => $contextid)); $title = get_string('changeoverrides', 'tool_capability'); } $context = context::instance_by_id($contextid); $html = $this->output->heading(html_writer::link($url, $context->get_context_name(), array('title' => $title)), 3); $html .= html_writer::table($table); // If there are any child contexts, print them recursively. if (!empty($contexts[$contextid]->children)) { foreach ($contexts[$contextid]->children as $childcontextid) { $html .= $this->capability_comparison_table($capabilities, $childcontextid, $roles, true); } } return $html; }
function display_add_field($recordid = 0, $formdata = null) { global $CFG, $DB, $OUTPUT; $content = array(); if ($formdata) { $fieldname = 'field_' . $this->field->id; $content = $formdata->$fieldname; } else if ($recordid) { $content = $DB->get_field('data_content', 'content', array('fieldid'=>$this->field->id, 'recordid'=>$recordid)); $content = explode('##', $content); } else { $content = array(); } $str = '<div title="' . s($this->field->description) . '">'; $str .= '<fieldset><legend><span class="accesshide">'.$this->field->name; if ($this->field->required) { $str .= '$nbsp;' . get_string('requiredelement', 'form'); $str .= '</span></legend>'; $image = html_writer::img($OUTPUT->pix_url('req'), get_string('requiredelement', 'form'), array('class' => 'req', 'title' => get_string('requiredelement', 'form'))); $str .= html_writer::div($image, 'inline-req'); } else { $str .= '</span></legend>'; } $i = 0; foreach (explode("\n", $this->field->param1) as $checkbox) { $checkbox = trim($checkbox); if ($checkbox === '') { continue; // skip empty lines } $str .= '<input type="hidden" name="field_' . $this->field->id . '[]" value="" />'; $str .= '<input type="checkbox" id="field_'.$this->field->id.'_'.$i.'" name="field_' . $this->field->id . '[]" '; $str .= 'value="' . s($checkbox) . '" class="mod-data-input m-r-1" '; if (array_search($checkbox, $content) !== false) { $str .= 'checked />'; } else { $str .= '/>'; } $str .= '<label for="field_'.$this->field->id.'_'.$i.'">'.$checkbox.'</label><br />'; $i++; } $str .= '</fieldset>'; $str .= '</div>'; return $str; }
public function fetch_revealjs_flashcards($dataset) { $card_div_array = array(); foreach ($dataset as $data) { $qsection = html_writer::tag('section', html_writer::tag('h2', $data->questiontext), array('data-background' => '', 'class' => 'filter_poodll_revealjs_section filter_poodll_revealjs_section_front')); $asection = html_writer::tag('section', html_writer::tag('h2', $data->answertext), array('data-transition' => 'flip', 'data-background' => '', 'class' => 'filter_poodll_revealjs_section filter_poodll_revealjs_section_back')); $cardsection = html_writer::tag('section', $qsection . $asection, array()); $card_div_array[] = $cardsection; } $carddivs = implode(' ', $card_div_array); $slides = html_writer::div($carddivs, 'slides'); $previousbutton = html_writer::tag('a', 'previous', array('class' => 'filter_poodll_revealjs_previous btn btn-primary')); $nextbutton = html_writer::tag('a', 'next', array('class' => 'filter_poodll_revealjs_next btn btn-primary')); $buttons = html_writer::div($previousbutton . $nextbutton, 'filter_poodll_revealjs_buttons'); $reveal = html_writer::div($slides, 'reveal filter_poodll_revealjs_container'); return $reveal . $buttons; }
/** * Returns a string indicating how long ago something happened * * @param int $time * in unixtime * @param string $small * indicates if the time should be enclosed in a div with a small font * @return string */ function emarking_time_ago($time, $small = false) { $time = time() - $time; // to get the time since that moment $tokens = array(31536000 => get_string('year'), 2592000 => get_string('month'), 604800 => get_string('week'), 86400 => get_string('day'), 3600 => get_string('hour'), 60 => get_string('minute'), 1 => get_string('second', 'mod_emarking')); foreach ($tokens as $unit => $text) { if ($time < $unit) { continue; } $numberOfUnits = floor($time / $unit); $message = core_text::strtotitle(get_string('ago', 'core_message', $numberOfUnits . ' ' . $text . ($numberOfUnits > 1 ? 's' : ''))); if ($small) { $message = html_writer::div($message, "timeago"); } return $message; } }
public function display_intro() { global $OUTPUT; if ($this->show_intro()) { if ($this->instance->intro) { echo $OUTPUT->box_start('generalbox boxaligncenter', 'intro'); echo $this->instance->intro; echo $OUTPUT->box_end(); } } else { if ($this->alwaysshowdescription) { $message = get_string('allowsubmissionsfromdatesummary', 'publication', userdate($this->instance->allowsubmissionsfromdate)); } else { $message = get_string('allowsubmissionsanddescriptionfromdatesummary', 'publication', userdate($this->instance->allowsubmissionsfromdate)); } echo html_writer::div($message, '', array('id' => 'intro')); } }
/** * Form definition. */ protected function definition() { global $USER; $authconfig = get_config('auth_oidc'); $opname = !empty($authconfig->opname) ? $authconfig->opname : get_string('pluginname', 'auth_oidc'); $mform =& $this->_form; $mform->addElement('html', \html_writer::tag('h4', get_string('ucp_disconnect_title', 'auth_oidc', $opname))); $mform->addElement('html', \html_writer::div(get_string('ucp_disconnect_details', 'auth_oidc', $opname))); $mform->addElement('html', '<br />'); $mform->addElement('header', 'userdetails', get_string('userdetails')); $newmethod = []; $attributes = []; $manualenabled = is_enabled_auth('manual') === true ? true : false; if ($manualenabled === true) { $newmethod[] =& $mform->createElement('radio', 'newmethod', '', 'manual', 'manual', $attributes); } if (!empty($this->_customdata['prevmethod'])) { $prevmethod = $this->_customdata['prevmethod']; $newmethod[] =& $mform->createElement('radio', 'newmethod', '', $prevmethod, $prevmethod, $attributes); } $mform->addGroup($newmethod, 'newmethodar', get_string('errorauthdisconnectnewmethod', 'auth_oidc'), [' '], false); if (!empty($this->_customdata['prevmethod'])) { $mform->setDefault('newmethod', $this->_customdata['prevmethod']); } else { if ($manualenabled === true) { $mform->setDefault('newmethod', 'manual'); } } if ($manualenabled === true) { $mform->addElement('html', \html_writer::div(get_string('errorauthdisconnectifmanual', 'auth_oidc'))); $mform->addElement('text', 'username', get_string('username')); $mform->addElement('passwordunmask', 'password', get_string('password')); $mform->setType('username', PARAM_USERNAME); $mform->disabledIf('username', 'newmethod', 'neq', 'manual'); $mform->disabledIf('password', 'newmethod', 'neq', 'manual'); // If the user cannot choose a username, set it to their current username and freeze. if (isset($this->_customdata['canchooseusername']) && $this->_customdata['canchooseusername'] == false) { $mform->setDefault('username', $USER->username); $element = $mform->getElement('username'); $element->freeze(); } } $this->add_action_buttons(); }
/** * @param $instance * @param $plugin * @param $context * * @throws coding_exception */ protected function add_general_section($instance, $plugin, $context) { global $CFG, $OUTPUT; $this->_form->addElement('header', 'generalsection', get_string('general', 'enrol_autoenrol')); $this->_form->setExpanded('generalsection'); $img = html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('logo', 'enrol_autoenrol'), 'alt' => 'AutoEnrol Logo', 'title' => 'AutoEnrol Logo')); $img = html_writer::div($img, null, array('style' => 'text-align:center;margin: 1em 0;')); $this->_form->addElement('html', $img); $this->_form->addElement('static', 'description', html_writer::tag('strong', get_string('warning', 'enrol_autoenrol')), get_string('warning_message', 'enrol_autoenrol')); $this->_form->addElement('text', 'customchar2', get_string('instancename', 'enrol_autoenrol')); $this->_form->setType('customchar2', PARAM_TEXT); $this->_form->setDefault('customchar2', ''); $this->_form->addHelpButton('customchar2', 'instancename', 'enrol_autoenrol'); if ($instance->id) { $roles = get_default_enrol_roles($context, $instance->roleid); } else { $roles = get_default_enrol_roles($context, $plugin->get_config('roleid')); } $this->_form->addElement('select', 'customint3', get_string('role', 'enrol_autoenrol'), $roles); $this->_form->setAdvanced('customint3'); $this->_form->addHelpButton('customint3', 'role', 'enrol_autoenrol'); if (!has_capability('enrol/autoenrol:method', $context)) { $this->_form->disabledIf('customint3', 'customint2'); } $this->_form->setDefault('customint3', $plugin->get_config('defaultrole')); $this->_form->setType('customint3', PARAM_INT); $method = array(get_string('m_course', 'enrol_autoenrol'), get_string('m_site', 'enrol_autoenrol')); $this->_form->addElement('select', 'customint1', get_string('method', 'enrol_autoenrol'), $method); if (!has_capability('enrol/autoenrol:method', $context)) { $this->_form->disabledIf('customint1', 'customint2'); } $this->_form->setAdvanced('customint1'); $this->_form->setType('customint1', PARAM_INT); $this->_form->addHelpButton('customint1', 'method', 'enrol_autoenrol'); $this->_form->addElement('selectyesno', 'customint8', get_string('alwaysenrol', 'enrol_autoenrol')); $this->_form->setAdvanced('customint8'); $this->_form->setType('customint8', PARAM_INT); $this->_form->setDefault('customint8', 0); $this->_form->addHelpButton('customint8', 'alwaysenrol', 'enrol_autoenrol'); }
public function definition() { global $DB, $USER; $mform = $this->_form; $instance = $this->_customdata; $userid = $instance['0']; $cid = $instance['1']; $teachercoursessql = "SELECT c.id AS courseid,\n\t\t\t\tcc.name AS categoryname,\n\t\t\t\tc.shortname AS coursename,\n\t\t\t\tCONCAT (u.firstname, ' ', u.lastname)AS name\n\t\t\t\tFROM {user} AS u\n\t\t\t\tINNER JOIN {role_assignments} AS ra ON (ra.userid = u.id AND u.id=?)\n\t\t\t\tINNER JOIN {context} AS ct ON (ct.id = ra.contextid)\n\t\t\t\tINNER JOIN {course} AS c ON (c.id = ct.instanceid)\n\t\t\t\tINNER JOIN {course_categories} AS cc ON (cc.id = c.category)\n\t\t\t\tINNER JOIN {role} AS r ON (r.id = ra.roleid AND r.shortname IN ('teacher', 'editingteacher'))\n\t\t\t\tINNER JOIN {emarking_exams} AS ee ON (ee.course = c.id)\n GROUP BY courseid"; $teachercourses = $DB->get_records_sql($teachercoursessql, array($USER->id)); $categories = array('Seleccione'); foreach ($teachercourses as $coursedata) { $categories[$coursedata->categoryname] = $coursedata->categoryname; } $categories = array_unique($categories); $out = html_writer::div('<h2>' . get_string('filters', 'mod_emarking') . '</h2>'); echo $out; $mform->addElement('select', 'category', get_string('category', 'mod_emarking'), $categories); $mform->setType('category', PARAM_TEXT); $mform->addElement("hidden", "course", $cid); $mform->setType("course", PARAM_INT); $this->add_action_buttons(false, get_string('searchcourses', 'mod_emarking')); }
/** * Form definition. */ protected function definition() { global $USER; $mform =& $this->_form; $mform->addElement('html', \html_writer::tag('h2', get_string('ucp_calsync_title', 'local_o365'))); $mform->addElement('html', \html_writer::div(get_string('ucp_calsync_desc', 'local_o365'))); $mform->addElement('html', '<br />'); $mform->addElement('html', \html_writer::tag('b', get_string('ucp_calsync_availcal', 'local_o365'))); $checkboxattrs = ['class' => 'calcheckbox', 'group' => '1']; $sitecalcustom = $this->_customdata; $sitecalcustom['cansyncin'] = $this->_customdata['cancreatesiteevents']; $mform->addElement('localo365calendar', 'sitecal', '', get_string('calendar_site', 'local_o365'), $checkboxattrs, $sitecalcustom); $usercalcustom = $this->_customdata; $usercalcustom['cansyncin'] = true; $mform->addElement('localo365calendar', 'usercal', '', get_string('calendar_user', 'local_o365'), $checkboxattrs, $usercalcustom); foreach ($this->_customdata['usercourses'] as $courseid => $course) { $coursecalcustom = $this->_customdata; $coursecalcustom['cansyncin'] = !empty($this->_customdata['cancreatecourseevents'][$courseid]) ? true : false; $mform->addElement('localo365calendar', 'coursecal[' . $course->id . ']', '', $course->fullname, $checkboxattrs, $coursecalcustom); } $this->add_action_buttons(); }
// Chart only works if more than 1 record. $PAGE->requires->yui_module('moodle-forumngfeature_usage-usagegraph', 'M.mod_forumng.forumngfeature_usage_chart.output', array($data, $axes, $options)); } $usageoutput .= html_writer::start_div('forumng_usage_usagechart'); $help = $OUTPUT->help_icon('usagechartpoststot', 'forumngfeature_usage'); $usageoutput .= $OUTPUT->heading(get_string('usagechartpoststotal', 'forumngfeature_usage', $postcount) . $help, 4); $usageoutput .= $dateform->render(); // Accessible table of chart. $charttable = new html_table(); $charttable->head = array($datelabel, $postslabel, $totallabel); $charttable->data = $data; $charttable->summary = get_string('usagechartpoststable', 'forumngfeature_usage'); if (count($data) > 1) { // Show table hidden for screenreaders (also keyboard focus toggled by css). $usageoutput .= get_accesshide(html_writer::table($charttable), 'div', 'skip', 'tabindex = 0'); $usageoutput .= html_writer::div('', 'forumng_usage_chart', array('id' => 'usagechart')); } else { // Show table instead of chart. $usageoutput .= html_writer::table($charttable); } $usageoutput .= html_writer::end_div(); } if ($forum->can_view_subscribers()) { // View subscriber info. $subs = $forum->get_subscribers($groupid); $discussioncount = 0; $groupcount = 0; $wholecount = 0; foreach ($subs as $subscriber) { if (!empty($subscriber->wholeforum)) { $wholecount++;
public function test_div() { // All options. $this->assertSame('<div class="frog" id="kermit">ribbit</div>', html_writer::div('ribbit', 'frog', array('id' => 'kermit'))); // Combine class from attributes and $class. $this->assertSame('<div class="amphibian frog">ribbit</div>', html_writer::div('ribbit', 'frog', array('class' => 'amphibian'))); // Class only. $this->assertSame('<div class="frog">ribbit</div>', html_writer::div('ribbit', 'frog')); // Attributes only. $this->assertSame('<div id="kermit">ribbit</div>', html_writer::div('ribbit', '', array('id' => 'kermit'))); // No options. $this->assertSame('<div>ribbit</div>', html_writer::div('ribbit')); }
/** * Helper method to render the information about the available plugin update * * @param core_plugin_manager $pluginman plugin manager instance * @param \core\update\info $updateinfo information about the available update for the plugin */ protected function plugin_available_update_info(core_plugin_manager $pluginman, \core\update\info $updateinfo) { $boxclasses = 'pluginupdateinfo'; $info = array(); if (isset($updateinfo->release)) { $info[] = html_writer::div(get_string('updateavailable_release', 'core_plugin', $updateinfo->release), 'info release'); } if (isset($updateinfo->maturity)) { $info[] = html_writer::div(get_string('maturity' . $updateinfo->maturity, 'core_admin'), 'info maturity'); $boxclasses .= ' maturity' . $updateinfo->maturity; } if (isset($updateinfo->download)) { $info[] = html_writer::div(html_writer::link($updateinfo->download, get_string('download')), 'info download'); } if (isset($updateinfo->url)) { $info[] = html_writer::div(html_writer::link($updateinfo->url, get_string('updateavailable_moreinfo', 'core_plugin')), 'info more'); } $box = html_writer::start_div($boxclasses); $box .= html_writer::div(get_string('updateavailable', 'core_plugin', $updateinfo->version), 'version'); $box .= html_writer::div(implode(html_writer::span(' ', 'separator'), $info), 'infos'); if ($pluginman->is_remote_plugin_installable($updateinfo->component, $updateinfo->version, $reason)) { $box .= $this->output->single_button(new moodle_url($this->page->url, array('installupdate' => $updateinfo->component, 'installupdateversion' => $updateinfo->version)), get_string('updateavailableinstall', 'core_admin'), 'post', array('class' => 'singlebutton updateavailableinstall')); } else { $reasonhelp = $this->info_remote_plugin_not_installable($reason); if ($reasonhelp) { $box .= html_writer::div($reasonhelp, 'reasonhelp updateavailableinstall'); } } $box .= html_writer::end_div(); return $box; }
/** * Generate the HTML that displayes the question in its current state, with * the appropriate display options. * * @param int $slot identifies the question in the attempt. * @param bool $reviewing is the being printed on an attempt or a review page. * @param mod_quiz_renderer $renderer the quiz renderer. * @param moodle_url $thispageurl the URL of the page this question is being printed on. * @return string HTML for the question in its current state. */ public function render_question($slot, $reviewing, mod_quiz_renderer $renderer, $thispageurl = null) { if ($this->is_blocked_by_previous_question($slot)) { $placeholderqa = $this->make_blocked_question_placeholder($slot); $displayoptions = $this->get_display_options($reviewing); $displayoptions->manualcomment = question_display_options::HIDDEN; $displayoptions->history = question_display_options::HIDDEN; $displayoptions->readonly = true; return html_writer::div($placeholderqa->render($displayoptions, $this->get_question_number($this->get_original_slot($slot))), 'mod_quiz-blocked_question_warning'); } return $this->render_question_helper($slot, $reviewing, $thispageurl, $renderer, null); }
$rowclasses = array(); // Set up bools whether this theme is chosen either main or legacy. $ischosentheme = $themename == core_useragent::get_device_type_theme($device); if ($ischosentheme) { // Is the chosen main theme. $rowclasses[] = 'selectedtheme'; } // Link to the screenshot, now mandatory - the image path is hardcoded because we need image from other themes, // not the current one. $screenshotpath = new moodle_url('/theme/image.php', array('theme' => $themename, 'image' => 'screenshot', 'component' => 'theme')); // Contents of the first screenshot/preview cell. $row[] = html_writer::empty_tag('img', array('src' => $screenshotpath, 'alt' => $strthemename)); // Contents of the second cell. $infocell = $OUTPUT->heading($strthemename, 3); if ($themelocked) { $infocell .= html_writer::div(get_string('configoverride', 'admin'), 'alert alert-info'); } // Button to choose this as the main theme or unset this theme for devices other then default. if (!$themelocked) { if ($ischosentheme && $device != 'default') { $unsetthemestr = get_string('unsettheme', 'admin'); $unsetthemeurl = new moodle_url('/theme/index.php', array('device' => $device, 'unsettheme' => true, 'sesskey' => sesskey())); $unsetbutton = new single_button($unsetthemeurl, $unsetthemestr, 'get'); $infocell .= $OUTPUT->render($unsetbutton); } else { if (!$ischosentheme) { $setthemestr = get_string('usetheme'); $setthemeurl = new moodle_url('/theme/index.php', array('device' => $device, 'choose' => $themename, 'sesskey' => sesskey())); $setthemebutton = new single_button($setthemeurl, $setthemestr, 'get'); $infocell .= $OUTPUT->render($setthemebutton); }
/** * Displays pagination for search results. * * @param int $totalcourses The total number of courses to be displayed. * @param int $page The current page. * @param int $perpage The number of courses being displayed. * @param bool $showtotals Whether or not to print total information. * @return string */ protected function search_pagination($totalcourses, $page, $perpage, $showtotals = false) { $html = ''; $totalpages = ceil($totalcourses / $perpage); if ($showtotals) { if ($totalpages == 1) { $str = get_string('showingacourses', 'moodle', $totalcourses); } else { $a = new stdClass(); $a->start = $page * $perpage + 1; $a->end = min(($page + 1) * $perpage, $totalcourses); $a->total = $totalcourses; $str = get_string('showingxofycourses', 'moodle', $a); } $html .= html_writer::div($str, 'listing-pagination-totals dimmed'); } if ($totalcourses < $perpage) { return $html; } $aside = 2; $span = $aside * 2 + 1; $start = max($page - $aside, 0); $end = min($page + $aside, $totalpages - 1); if ($end - $start < $span) { if ($start == 0) { $end = min($totalpages - 1, $span - 1); } else { if ($end == $totalpages - 1) { $start = max(0, $end - $span + 1); } } } $items = array(); $baseurl = $this->page->url; if ($page > 0) { $items[] = $this->action_button(new moodle_url($baseurl, array('page' => 0)), get_string('first')); $items[] = $this->action_button(new moodle_url($baseurl, array('page' => $page - 1)), get_string('prev')); $items[] = '...'; } for ($i = $start; $i <= $end; $i++) { $class = ''; if ($page == $i) { $class = 'active-page'; } $items[] = $this->action_button(new moodle_url($baseurl, array('page' => $i)), $i + 1, null, $class); } if ($page < $totalpages - 1) { $items[] = '...'; $items[] = $this->action_button(new moodle_url($baseurl, array('page' => $page + 1)), get_string('next')); $items[] = $this->action_button(new moodle_url($baseurl, array('page' => $totalpages - 1)), get_string('last')); } $html .= html_writer::div(join('', $items), 'listing-pagination'); return $html; }
public function navbar() { $items = $this->page->navbar->get_items(); $breadcrumbs = array(); foreach ($items as $item) { $item->hideicon = true; /* * Trying to replace the 'My home' breadcrumb * not very elegant; another solution may be considered later */ $ismyhome = strcasecmp($item->text, get_string('myhome')) == 0; if ($ismyhome) { $breadcrumbs[] = '<a href="/" id="moo-home-button"> <i class="fa fa-home fa-lg"></i></a>'; continue; // go to next element } /**/ $a = $this->render($item); if (strpos($a, "/course/view.php") !== false) { $breadcrumbs[] = html_writer::div($a, 'coursetitle'); } else { $breadcrumbs[] = $a; } } // ADD ELLIPSES ... $new_breadcrumbs = array(); $counter = 0; foreach ($breadcrumbs as $breadcrumb) { //add ellipses in second position if ($counter == 1) { $new_breadcrumbs[] = "<span id='ellipses'>...</span>"; } $new_breadcrumbs[] = $breadcrumb; $counter++; } // $divider = '<span class="divider">' . get_separator() . '</span>'; $list_items = '<li>' . join(" {$divider}</li><li>", $new_breadcrumbs) . '</li>'; $title = '<span class="accesshide">' . get_string('pagepath') . '</span>'; return $title . "<ul id=\"bc1\" class=\"breadcrumb\">{$list_items}</ul>"; }