/** * */ public function get_replacements(array $patterns, $entry = null, array $options = array()) { global $CFG, $OUTPUT; $replacements = parent::get_replacements($patterns, $entry, $options); $view = $this->_view; $df = $view->get_df(); $filter = $view->get_filter(); $baseurl = new moodle_url($view->get_baseurl()); $baseurl->param('sesskey', sesskey()); foreach ($patterns as $pattern) { switch ($pattern) { case '##exportall##': $actionurl = new moodle_url($baseurl, array('pdfexportall' => true)); $label = html_writer::tag('span', get_string('exportall', 'dataformview_pdf')); $replacements[$pattern] = html_writer::link($actionurl, $label, array('class' => 'actionlink exportall')); break; case '##exportpage##': $actionurl = new moodle_url($baseurl, array('pdfexportpage' => true)); $label = html_writer::tag('span', get_string('exportpage', 'dataformview_pdf')); $replacements[$pattern] = html_writer::link($actionurl, $label, array('class' => 'actionlink exportpage')); break; case '##pagebreak##': $replacements[$pattern] = $view::PAGE_BREAK; break; } } return $replacements; }
function get_content() { global $USER,$DB; if ($this->content !== NULL) { return $this->content; } $this->content = new stdClass(); $this->content->items = array(); $is_manager = $DB->record_exists_sql("select cp.* from {local_costcenter_permissions} as cp JOIN {role_assignments} as ra ON ra.userid=cp.userid and cp.userid=$USER->id JOIN {role} as r ON r.id=ra.roleid where r.archetype='manager'"); $is_teammanager = $DB->record_exists('local_teammanager_employee', array('teammanagerid'=>$USER->id)); if($is_manager || is_siteadmin()) $link = array(html_writer::link(new moodle_url('/local/users/index.php'),get_string('pluginname','local_users'))); if(is_siteadmin()) $link[] = html_writer::link(new moodle_url('/local/costcenter/index.php'),get_string('pluginname','local_costcenter')); if($is_manager || is_siteadmin()) $link[] = html_writer::link(new moodle_url('/local/teammanager/index.php'),get_string('pluginname', 'local_teammanager')); if($is_teammanager && !is_siteadmin()) $link[] = html_writer::link(new moodle_url('/local/teammanager/myteam.php'),get_string('viewmyteam', 'local_teammanager')); if($is_manager || is_siteadmin()) $link[] = html_writer::link(new moodle_url('/local/costcenter/courses.php'),get_string('course')); $this->content->items = $link; $this->content->icons = ''; $this->content->footer = ''; return $this->content; }
/** * 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 get_content() { global $CFG, $OUTPUT, $USER, $PAGE, $DB; if ($this->content !== null) { return $this->content; } $output = ''; if (!empty($USER->id) && has_capability('moodle/course:create', context_system::instance())) { if ($CFG->branch <= 25) { $jsurl = new moodle_url($CFG->wwwroot . '/mod/turnitintooltwo/jquery/jquery-1.8.2.min.js'); $PAGE->requires->js($jsurl, true); $jsurl = new moodle_url($CFG->wwwroot . '/mod/turnitintooltwo/jquery/block_turnitin.js'); $PAGE->requires->js($jsurl, true); } else { $PAGE->requires->jquery(); $PAGE->requires->jquery_plugin('turnitintooltwo-block', 'mod_turnitintooltwo'); } $cssurl = new moodle_url($CFG->wwwroot . '/mod/turnitintooltwo/css/styles_block.css'); $PAGE->requires->css($cssurl); $output .= $OUTPUT->box($OUTPUT->pix_icon('loader', '', 'mod_turnitintooltwo'), 'centered_cell', 'block_loading'); $output .= html_writer::link($CFG->wwwroot . '/mod/turnitintooltwo/extras.php?cmd=courses', html_writer::tag('noscript', get_string('coursestomigrate', 'mod_turnitintooltwo', '')), array('id' => 'block_migrate_content')); } $this->content = new stdClass(); $this->content->text = $output; $this->content->footer = ''; return $this->content; }
public function get_content() { global $USER; if ($this->content !== null) { return $this->content; } $this->content = new stdClass(); $this->content->items = array(); $this->content->icons = array(); $managecourses = new moodle_url('/blocks/ps_selfstudy/managecourses.php'); $viewrequests = new moodle_url('/blocks/ps_selfstudy/viewrequests.php'); $myrequests = new moodle_url('/blocks/ps_selfstudy/myrequests.php'); $viewcompletion = new moodle_url('/blocks/ps_selfstudy/viewcompletion.php'); $context = context_system::instance(); if (has_capability('block/ps_selfstudy:managecourses', $context, $USER->id)) { $this->content->items[] = html_writer::link($managecourses, get_string('link_managecourses', 'block_ps_selfstudy')); } if (has_capability('block/ps_selfstudy:viewrequests', $context, $USER->id)) { $this->content->items[] = html_writer::link($viewrequests, get_string('link_requests', 'block_ps_selfstudy')); } if (has_capability('block/ps_selfstudy:viewrequests', $context, $USER->id)) { $this->content->items[] = html_writer::link($viewcompletion, get_string('link_completion', 'block_ps_selfstudy')); } if (has_capability('block/ps_selfstudy:myrequests', $context, $USER->id)) { $this->content->items[] = html_writer::link($myrequests, get_string('link_myrequests', 'block_ps_selfstudy')); } return $this->content; }
/** * Constructor * * @param string|moodle_url $pageurl */ public function __construct($pageurl) { global $OUTPUT; parent::__construct(); $this->attributes['class'] = 'generaltable tag-areas-table'; $this->head = array(get_string('tagareaname', 'core_tag'), get_string('component', 'tag'), get_string('tagareaenabled', 'core_tag'), get_string('tagcollection', 'tag')); $this->data = array(); $this->rowclasses = array(); $tagareas = core_tag_area::get_areas(); $tagcollections = core_tag_collection::get_collections_menu(true); $tagcollectionsall = core_tag_collection::get_collections_menu(); foreach ($tagareas as $itemtype => $it) { foreach ($it as $component => $record) { $areaname = core_tag_area::display_name($record->component, $record->itemtype); $baseurl = new moodle_url($pageurl, array('ta' => $record->id, 'sesskey' => sesskey())); if ($record->enabled) { $enableurl = new moodle_url($baseurl, array('action' => 'areadisable')); $enabled = html_writer::link($enableurl, $OUTPUT->pix_icon('i/hide', get_string('disable'))); } else { $enableurl = new moodle_url($baseurl, array('action' => 'areaenable')); $enabled = html_writer::link($enableurl, $OUTPUT->pix_icon('i/show', get_string('enable'))); } if ($record->enabled && empty($record->locked) && count($tagcollections) > 1) { $changecollurl = new moodle_url($baseurl, array('action' => 'areasetcoll')); $select = new single_select($changecollurl, 'areacollid', $tagcollections, $record->tagcollid, null); $select->set_label(get_string('changetagcoll', 'core_tag', $areaname), array('class' => 'accesshide')); $collectionselect = $OUTPUT->render($select); } else { $collectionselect = $tagcollectionsall[$record->tagcollid]; } $this->data[] = array($areaname, $record->component === 'core' || preg_match('/^core_/', $record->component) ? get_string('coresystem') : get_string('pluginname', $record->component), $enabled, $collectionselect); $this->rowclasses[] = $record->enabled ? '' : 'dimmed_text'; } } }
public function get_content() { global $CFG, $PAGE; ?> <script src="<?php echo $CFG->wwwroot . '/blocks/my_enrolled_courses/js/jquery-1.10.2.js'; ?> "></script> <script src="<?php echo $CFG->wwwroot . '/blocks/my_enrolled_courses/js/jquery-ui.min.js'; ?> "></script> <?php $PAGE->requires->js('/blocks/my_enrolled_courses/js/sorting.js'); $PAGE->requires->data_for_js('wwwroot', $CFG->wwwroot); $PAGE->requires->css('/blocks/my_enrolled_courses/style.css'); if ($this->content !== null) { return $this->content; } $this->content = new stdClass(); $html = block_my_enrolled_courses_visible_in_block(); $this->content->text = $html; $url = new moodle_url($CFG->wwwroot . '/blocks/my_enrolled_courses/showhide.php', array('contextid' => $this->context->id)); $showhidetext = get_string('showhide', 'block_my_enrolled_courses'); $link = html_writer::link($url, $showhidetext); $this->content->footer = $link; return $this->content; }
/** * Internal function - creates htmls structure suitable for YUI tree. */ protected function htmllize_tree($tree, $dir) { global $CFG; if (empty($dir['subdirs']) and empty($dir['files'])) { return ''; } $browser = get_file_browser(); $result = '<ul>'; foreach ($dir['subdirs'] as $subdir) { $image = $this->output->pix_icon(file_folder_icon(24), $subdir['dirname'], 'moodle'); $filename = html_writer::tag('span', $image, array('class' => 'fp-icon')). html_writer::tag('span', s($subdir['dirname']), array('class' => 'fp-filename')); $filename = html_writer::tag('div', $filename, array('class' => 'fp-filename-icon')); $result .= html_writer::tag('li', $filename. $this->htmllize_tree($tree, $subdir)); } foreach ($dir['files'] as $file) { $fileinfo = $browser->get_file_info($tree->context, $file->get_component(), $file->get_filearea(), $file->get_itemid(), $file->get_filepath(), $file->get_filename()); $url = $fileinfo->get_url(true); $filename = $file->get_filename(); if ($imageinfo = $fileinfo->get_imageinfo()) { $fileurl = new moodle_url($fileinfo->get_url()); $image = $fileurl->out(false, array('preview' => 'tinyicon', 'oid' => $fileinfo->get_timemodified())); $image = html_writer::empty_tag('img', array('src' => $image)); } else { $image = $this->output->pix_icon(file_file_icon($file, 24), $filename, 'moodle'); } $filename = html_writer::tag('span', $image, array('class' => 'fp-icon')). html_writer::tag('span', $filename, array('class' => 'fp-filename')); $filename = html_writer::tag('span', html_writer::link($url, $filename), array('class' => 'fp-filename-icon')); $result .= html_writer::tag('li', $filename); } $result .= '</ul>'; return $result; }
private static function replacebookmarkplaceholder($template, $dataid) { $bookmarklink = \html_writer::link('#', get_string('bookmark', 'block_databasebookmarks'), array('class' => 'data_bookmark_link', 'data-moreurl' => '##moreurl##')); $bookmarkspan = \html_writer::span($bookmarklink, 'data_bookmark_wrapper'); $template = str_replace('##bookmark##', $bookmarkspan, $template); return $template; }
/** * Return the toolbar * * @param bool $show_new whether show "New round" button * return alist of links */ public function toolbar($show_new = true) { $output = ''; $toolbuttons = array(); // Print next/prev round bar if ($this->hotquestion->get_prev_round() != null) { $url = new moodle_url('/mod/hotquestion/view.php', array('id' => $this->hotquestion->cm->id, 'round' => $this->hotquestion->get_prev_round()->id)); $toolbuttons[] = html_writer::link($url, $this->pix_icon('t/collapsed_rtl', get_string('previousround', 'hotquestion')), array('class' => 'toolbutton')); } else { $toolbuttons[] = html_writer::tag('span', $this->pix_icon('t/collapsed_empty_rtl', ''), array('class' => 'dis_toolbutton')); } if ($this->hotquestion->get_next_round() != null) { $url = new moodle_url('/mod/hotquestion/view.php', array('id' => $this->hotquestion->cm->id, 'round' => $this->hotquestion->get_next_round()->id)); $toolbuttons[] = html_writer::link($url, $this->pix_icon('t/collapsed', get_string('nextround', 'hotquestion')), array('class' => 'toolbutton')); } else { $toolbuttons[] = html_writer::tag('span', $this->pix_icon('t/collapsed_empty', ''), array('class' => 'dis_toolbutton')); } // Print new round bar if ($show_new) { $options = array(); $options['id'] = $this->hotquestion->cm->id; $options['action'] = 'newround'; $url = new moodle_url('/mod/hotquestion/view.php', $options); $toolbuttons[] = html_writer::link($url, $this->pix_icon('t/add', get_string('newround', 'hotquestion')), array('class' => 'toolbutton')); } // Print refresh button $url = new moodle_url('/mod/hotquestion/view.php', array('id' => $this->hotquestion->cm->id)); $toolbuttons[] = html_writer::link($url, $this->pix_icon('t/reload', get_string('reload')), array('class' => 'toolbutton')); // return all available toolbuttons $output .= html_writer::alist($toolbuttons, array('id' => 'toolbar')); return $output; }
/** * Prints the 'All A B C ...' alphabetical filter bar. * * @param object $moodle_url the moodle url object for the alpha/letter links * @param string $pname the parameter name to be appended to the moodle_url * i.e. 'pname=alpha' * @param string $label optional label - defaults to none */ function pmalphabox($moodle_url, $pname = 'alpha', $label = null) { $alpha = optional_param($pname, null, PARAM_ALPHA); $alphabet = explode(',', get_string('alphabet', 'langconfig')); $strall = get_string('all'); echo html_writer::start_tag('div', array('style' => 'text-align:center')); if (!empty($label)) { echo $label, ' '; // TBD: html_writer::??? } if ($alpha) { $url = clone $moodle_url; // TBD $url->remove_params($pname); echo html_writer::link($url, $strall); } else { echo html_writer::tag('b', $strall); } foreach ($alphabet as $letter) { if ($letter == $alpha) { echo ' ', html_writer::tag('b', $letter); } else { $url = clone $moodle_url; // TBD // Set current page to 0 $url->params(array($pname => $letter, 'page' => 0)); echo ' ', html_writer::link($url, $letter); } } echo html_writer::end_tag('div'); }
/** * Returns course details in an array ready to be printed. * * @global \moodle_database $DB * @param \course_in_list $course * @return array */ public static function get_course_detail_array(\course_in_list $course) { global $DB; $canaccess = $course->can_access(); $format = \course_get_format($course->id); $modinfo = \get_fast_modinfo($course->id); $modules = $modinfo->get_used_module_names(); $sections = array(); if ($format->uses_sections()) { foreach ($modinfo->get_section_info_all() as $section) { if ($section->uservisible) { $sections[] = $format->get_section_name($section); } } } $category = \coursecat::get($course->category); $categoryurl = new \moodle_url('/course/management.php', array('categoryid' => $course->category)); $categoryname = $category->get_formatted_name(); $details = array('fullname' => array('key' => \get_string('fullname'), 'value' => $course->get_formatted_fullname()), 'shortname' => array('key' => \get_string('shortname'), 'value' => $course->get_formatted_shortname()), 'idnumber' => array('key' => \get_string('idnumber'), 'value' => s($course->idnumber)), 'category' => array('key' => \get_string('category'), 'value' => \html_writer::link($categoryurl, $categoryname))); if (has_capability('moodle/site:accessallgroups', $course->get_context())) { $groups = \groups_get_course_data($course->id); $details += array('groupings' => array('key' => \get_string('groupings', 'group'), 'value' => count($groups->groupings)), 'groups' => array('key' => \get_string('groups'), 'value' => count($groups->groups))); } if ($canaccess) { $names = \role_get_names($course->get_context()); $sql = 'SELECT ra.roleid, COUNT(ra.id) AS rolecount FROM {role_assignments} ra WHERE ra.contextid = :contextid GROUP BY ra.roleid'; $rolecounts = $DB->get_records_sql($sql, array('contextid' => $course->get_context()->id)); $roledetails = array(); foreach ($rolecounts as $result) { $a = new \stdClass(); $a->role = $names[$result->roleid]->localname; $a->count = $result->rolecount; $roledetails[] = \get_string('assignedrolecount', 'moodle', $a); } $details['roleassignments'] = array('key' => \get_string('roleassignments'), 'value' => join('<br />', $roledetails)); } if ($course->can_review_enrolments()) { $enrolmentlines = array(); $instances = \enrol_get_instances($course->id, true); $plugins = \enrol_get_plugins(true); foreach ($instances as $instance) { if (!isset($plugins[$instance->enrol])) { // Weird. continue; } $plugin = $plugins[$instance->enrol]; $enrolmentlines[] = $plugin->get_instance_name($instance); } $details['enrolmentmethods'] = array('key' => \get_string('enrolmentmethods'), 'value' => join('<br />', $enrolmentlines)); } if ($canaccess) { $details['format'] = array('key' => \get_string('format'), 'value' => \course_get_format($course)->get_format_name()); $details['sections'] = array('key' => \get_string('sections'), 'value' => join('<br />', $sections)); $details['modulesused'] = array('key' => \get_string('modulesused'), 'value' => join('<br />', $modules)); } return $details; }
/** * Renders a custom menu node as part of a submenu * * The custom menu this method override the render_custom_menu_item function * in outputrenderers.php * * @see render_custom_menu() * * @staticvar int $submenucount * @param custom_menu_item $menunode * @return string */ protected function render_custom_menu_item(custom_menu_item $menunode) { // Required to ensure we get unique trackable id's static $submenucount = 0; $content = html_writer::start_tag('li'); if ($menunode->has_children()) { // If the child has menus render it as a sub menu $submenucount++; if ($menunode->get_url() !== null) { $url = $menunode->get_url(); } else { $url = '#cm_submenu_' . $submenucount; } $content .= html_writer::start_tag('span', array('class' => 'customitem')); $content .= html_writer::link($url, $menunode->get_text(), array('title' => $menunode->get_title())); $content .= html_writer::end_tag('span'); $content .= html_writer::start_tag('ul'); foreach ($menunode->get_children() as $menunode) { $content .= $this->render_custom_menu_item($menunode); } $content .= html_writer::end_tag('ul'); } else { // The node doesn't have children so produce a final menuitem if ($menunode->get_url() !== null) { $url = $menunode->get_url(); } else { $url = '#'; } $content .= html_writer::link($url, $menunode->get_text(), array('title' => $menunode->get_title())); } $content .= html_writer::end_tag('li'); // Return the sub menu return $content; }
public function get_content() { global $CFG, $OUTPUT, $USER, $PAGE, $DB; if ($this->content !== null) { return $this->content; } $config = turnitintooltwo_admin_config(); $output = ''; // Show link to Helpdesk wizard if enabled and the logged in user is an instrutor. if (!empty($USER->id) && $config->helpdeskwizard && has_capability('moodle/course:manageactivities', context_system::instance())) { $output = $OUTPUT->box(html_writer::tag('p', html_writer::link($CFG->wwwroot . '/mod/turnitintooltwo/extras.php?cmd=supportwizard', get_string('helpdesklink', 'block_turnitin')))); } if (!empty($USER->id) && has_capability('moodle/course:create', context_system::instance())) { $PAGE->requires->jquery(); $PAGE->requires->jquery_plugin('block-turnitin', 'block_turnitin'); $cssurl = new moodle_url($CFG->wwwroot . '/mod/turnitintooltwo/css/styles_block.css'); $PAGE->requires->css($cssurl); $output .= $OUTPUT->box($OUTPUT->pix_icon('loader', '', 'mod_turnitintooltwo'), 'centered_cell', 'block_loading'); $output .= html_writer::link($CFG->wwwroot . '/mod/turnitintooltwo/extras.php?cmd=courses', html_writer::tag('noscript', get_string('coursestomigrate', 'block_turnitin', '')), array('id' => 'block_migrate_content')); } $this->content = new stdClass(); $this->content->text = $output; $this->content->footer = ''; return $this->content; }
public function definition() { global $CFG, $OUTPUT, $COURSE; $accepted_types = '.pdf'; if ($CFG->emarking_enabledigitizedzipfile) { $accepted_types .= ',.zip'; } // Options for uploading the zip file within the form. $options = array('subdirs' => 0, 'maxbytes' => get_max_upload_file_size($CFG->maxbytes, $COURSE->maxbytes, $COURSE->maxbytes), 'maxfiles' => 1, 'accepted_types' => $accepted_types, 'return_types' => FILE_INTERNAL); $mform = $this->_form; $instance = $this->_customdata; // Header. $mform->addElement('header', 'digitizedfilepdf', get_string('uploadanswers', 'mod_emarking')); $mform->addHelpButton('digitizedfilepdf', 'digitizedfile', 'mod_emarking'); // The course module id. $mform->addElement('hidden', 'id', $instance['coursemoduleid']); $mform->setType('id', PARAM_INT); // The activity id. $mform->addElement('hidden', 'emarkingid', $instance['emarkingid']); $mform->setType('emarkingid', PARAM_INT); // File picker for the digitized answers. $mform->addElement('filepicker', 'assignment_file', get_string('uploadexamfile', 'mod_emarking'), null, $options); $mform->setType('assignment_file', PARAM_FILE); $mform->addHelpButton('assignment_file', 'filerequiredpdf', 'mod_emarking'); $mform->addRule('assignment_file', get_string('filerequiredpdf', 'mod_emarking'), 'required'); // Header. $mform->addElement('static', 'qrprocessing_help', '', $OUTPUT->heading(get_string('usedigitizedzipfile', 'mod_emarking'), 4)); $mform->setAdvanced('qrprocessing_help'); // Link to desktop tool. $desktoplink = html_writer::link(new moodle_url('/mod/emarking/emarkingdesktop.zip'), get_string('qrprocessing', 'mod_emarking')); $mform->addElement('static', 'qrprocessing', '', $desktoplink); $mform->setAdvanced('qrprocessing'); // Action buttons. $this->add_action_buttons(true, get_string('processtitle', 'mod_emarking')); }
protected function definition_inner($mform) { global $PAGE, $CFG; $PAGE->requires->css('/question/type/easyoselectjs/easyoselectjs_styles.css'); $marvinjsconfig = get_config('qtype_easyoselectjs_options'); $marvinjspath = $marvinjsconfig->path; $protocol = (empty($_SERVER['HTTPS']) or $_SERVER['HTTPS'] == 'off') ? 'http://' : 'https://'; $PAGE->requires->js(new moodle_url($protocol . $_SERVER['HTTP_HOST'] . $marvinjspath . '/js/promise-0.1.1.min.js')); $PAGE->requires->js(new moodle_url($protocol . $_SERVER['HTTP_HOST'] . $marvinjspath . '/js/marvinjslauncher.js')); $mform->addElement('static', 'answersinstruct', get_string('correctanswers', 'qtype_easyoselectjs'), get_string('filloutoneanswer', 'qtype_easyoselectjs')); $mform->closeHeaderBefore('answersinstruct'); $mform->setType('structure', PARAM_RAW); $mform->addElement('hidden', 'structure', "", array('id' => 'id_structure')); $mform->addElement('html', html_writer::start_tag('div', array('id' => 'appletdiv', 'class' => 'easyomechjs resizable'))); $mform->addElement('html', html_writer::start_tag('div', array('style' => 'float: left;font-style: italic ;'))); $mform->addElement('html', html_writer::start_tag('small')); $easyoselectjshomeurl = 'http://www.chemaxon.com'; $mform->addElement('html', html_writer::link($easyoselectjshomeurl, get_string('easyoselectjseditor', 'qtype_easyoselectjs'))); $mform->addElement('html', html_writer::empty_tag('br')); $mform->addElement('html', html_writer::tag('span', get_string('author', 'qtype_easyoselectjs'), array('class' => 'easyoselectjsauthor'))); $mform->addElement('html', html_writer::end_tag('small')); $mform->addElement('html', html_writer::end_tag('div')); $mform->addElement('html', html_writer::end_tag('div')); $marvinconfig = get_config('qtype_easyoselectjs_options'); $marvinpath = $marvinconfig->path; $PAGE->requires->js_init_call('M.qtype_easyoselectjs.insert_applet', array($CFG->wwwroot, $marvinpath)); $this->add_per_answer_fields($mform, get_string('answerno', 'qtype_easyoselectjs', '{no}'), question_bank::fraction_options()); $this->add_interactive_settings(); $PAGE->requires->js_init_call('M.qtype_easyoselectjs.init_getanswerstring', array($CFG->version)); $PAGE->requires->js_init_call('M.qtype_easyoselectjs.init_viewanswerstring', array($CFG->version)); }
function get_content() { if ($this->content !== NULL) { return $this->content; } $context = context_system::instance(); $this->content = new stdClass(); $this->content->footer = ''; $this->content->text = ''; $content = array(); $canview = has_capability('block/enrol_token_manager:viewtokens', $context) === true; $cancreate = has_capability('block/enrol_token_manager:createtokens', $context) === true; $canrevoke = has_capability('block/enrol_token_manager:revoketokens', $context) === true; // view tokens link if ($canview) { $content[] = html_writer::link(new moodle_url('/blocks/enrol_token_manager/viewrevoke_tokens.php'), get_string('linkTextViewTokens', 'block_enrol_token_manager')); } // create tokens link if ($cancreate) { $content[] = html_writer::link(new moodle_url('/blocks/enrol_token_manager/create_tokens.php'), get_string('linkTextCreateTokens', 'block_enrol_token_manager')); } // revoke tokens link if ($canrevoke) { $content[] = html_writer::link(new moodle_url('/blocks/enrol_token_manager/viewrevoke_tokens.php'), get_string('linkTextRevokeTokens', 'block_enrol_token_manager')); } if ($cancreate || $canrevoke || $canview) { $this->content->text = html_writer::alist($content); } return $this->content; }
public function poll_results_link() { $url = new moodle_url('/blocks/poll/tabs.php', array('action' => 'responses', 'pid' => $this->poll->id, 'instanceid' => $this->instance->id)); $html = html_writer::empty_tag('hr'); $html .= html_writer::link($url, get_string('responses', 'block_poll')); return $html; }
/** * Internal function - creates htmls structure suitable for YUI tree. */ protected function htmllize_tree($tree, $dir) { global $CFG; $yuiconfig = array(); $yuiconfig['type'] = 'html'; if (empty($dir['subdirs']) and empty($dir['files'])) { return ''; } $result = '<ul>'; foreach ($dir['subdirs'] as $subdir) { $image = $this->output->pix_icon("f/folder", $subdir['dirname'], 'moodle', array('class' => 'icon')); $result .= '<li yuiConfig=\'' . json_encode($yuiconfig) . '\'><div>' . $image . ' ' . s($subdir['dirname']) . '</div> ' . $this->htmllize_tree($tree, $subdir) . '</li>'; } foreach ($dir['files'] as $file) { $url = file_encode_url("{$CFG->wwwroot}/blocks/csv_enrol/getfile.php", '/' . $tree->context->id . '/user/csvenrol' . $file->get_filepath() . $file->get_filename(), true); $filename = $file->get_filename(); $icon = mimeinfo("icon", $filename); if (strlen($filename) > 10) { $pi = pathinfo($filename); $txt = $pi['filename']; $ext = $pi['extension']; $filename = substr($filename, 0, 14) . '...' . $ext; } $image = $this->output->pix_icon("f/{$icon}", $filename, 'moodle', array('class' => 'icon')); $result .= '<li yuiConfig=\'' . json_encode($yuiconfig) . '\'><div>' . html_writer::link($url, $image . ' ' . $filename) . '</div></li>'; } $result .= '</ul>'; return $result; }
function glossary_show_entry_entrylist($course, $cm, $glossary, $entry, $mode = '', $hook = '', $printicons = 1, $aliases = true) { global $USER, $OUTPUT; $return = false; echo '<table class="glossarypost entrylist" cellspacing="0">'; echo '<tr valign="top">'; echo '<td class="entry">'; if ($entry) { glossary_print_entry_approval($cm, $entry, $mode); $anchortagcontents = glossary_print_entry_concept($entry, true); $link = new moodle_url('/mod/glossary/showentry.php', array('courseid' => $course->id, 'eid' => $entry->id, 'displayformat' => 'dictionary')); $anchor = html_writer::link($link, $anchortagcontents); echo "<div class=\"concept\">{$anchor}</div> "; echo '</td><td align="right" class="entrylowersection">'; if ($printicons) { glossary_print_entry_icons($course, $cm, $glossary, $entry, $mode, $hook, 'print'); } if (!empty($entry->rating)) { echo '<br />'; echo '<span class="ratings">'; $return = glossary_print_entry_ratings($course, $entry); echo '</span>'; } echo '<br />'; } else { echo '<div style="text-align:center">'; print_string('noentry', 'glossary'); echo '</div>'; } echo '</td></tr>'; echo "</table>\n"; return $return; }
/** * Render a series of section links. * * @param stdClass $course The course we are rendering for. * @param array $sections An array of section objects to render. * @param bool|int The section to provide a jump to link for. * @return string The HTML to display. */ public function render_section_links(stdClass $course, array $sections, $jumptosection = false) { $html = html_writer::start_tag('ol', array('class' => 'inline-list')); foreach ($sections as $section) { $attributes = array(); if (!$section->visible) { $attributes['class'] = 'dimmed'; } $html .= html_writer::start_tag('li'); $sectiontext = $section->section; if ($section->highlight) { $sectiontext = html_writer::tag('strong', $sectiontext); } $html .= html_writer::link(course_get_url($course, $section->section), $sectiontext, $attributes); $html .= html_writer::end_tag('li') . ' '; } $html .= html_writer::end_tag('ol'); if ($jumptosection && isset($sections[$jumptosection])) { if ($course->format == 'weeks') { $linktext = new lang_string('jumptocurrentweek', 'block_section_links'); } else { if ($course->format == 'topics') { $linktext = new lang_string('jumptocurrenttopic', 'block_section_links'); } } $attributes = array(); if (!$sections[$jumptosection]->visible) { $attributes['class'] = 'dimmed'; } $html .= html_writer::link(course_get_url($course, $jumptosection), $linktext, $attributes); } return $html; }
protected function specific_definition($mform) { global $COURSE, $DB; // Fields for editing poll block title and contents. $mform->addElement('header', 'configheader', get_string('blocksettings', 'block')); $mform->addElement('text', 'config_customtitle', get_string('configtitle', 'block_html')); $mform->setType('config_customtitle', PARAM_MULTILANG); if ($polls = $DB->get_records('block_poll', array('courseid' => $COURSE->id), '', 'id, name')) { $list = array(0 => get_string('choose', 'block_poll')); foreach ($polls as $poll) { $list[$poll->id] = $poll->name; } $mform->addElement('select', 'config_pollid', get_string('editpollname', 'block_poll'), $list); } else { $mform->addElement('static', 'nopolls', get_string('editpollname', 'block_poll'), get_string('nopollsavailable', 'block_poll')); } $mform->setType('config_maxwidth', PARAM_INT); $mform->addElement('text', 'config_maxwidth', get_string('editmaxbarwidth', 'block_poll')); $tabs = array('editpoll', 'managepolls', 'responses'); foreach ($tabs as $tab) { $params = array('action' => $tab, 'cid' => $COURSE->id, 'instanceid' => $this->block->instance->id); $link = html_writer::link(new moodle_url('/blocks/poll/tabs.php', $params), get_string("tab{$tab}", 'block_poll')); $mform->addElement('static', "linki_{$tab}", '', $link); } }
/** * Returns HTML to display randchoices of option * @param object $options * @param int $coursemoduleid * @param bool $vertical * @return string */ public function display_options($options, $coursemoduleid, $vertical = false, $multiple = false) { $layoutclass = 'horizontal'; if ($vertical) { $layoutclass = 'vertical'; } $target = new moodle_url('/mod/randchoice/view.php'); $attributes = array('method' => 'POST', 'action' => $target, 'class' => $layoutclass); $disabled = empty($options['previewonly']) ? array() : array('disabled' => 'disabled'); $html = html_writer::start_tag('form', $attributes); $html .= html_writer::start_tag('ul', array('class' => 'randchoices')); $availableoption = count($options['options']); $randchoicecount = 0; foreach ($options['options'] as $option) { $randchoicecount++; //$html .= html_writer::start_tag('li', array('class'=>'option')); if ($multiple) { $option->attributes->name = 'answer[]'; $option->attributes->type = 'checkbox'; } else { $option->attributes->name = 'answer'; $option->attributes->type = 'radio'; } $option->attributes->id = 'randchoice_' . $randchoicecount; $labeltext = $option->text; if (!empty($option->attributes->disabled)) { $labeltext .= ' ' . get_string('full', 'randchoice'); $availableoption--; } //$html .= html_writer::empty_tag('input', (array)$option->attributes + $disabled); //$html .= html_writer::tag('label', $labeltext, array('for'=>$option->attributes->id)); //$html .= html_writer::end_tag('li'); } $html .= html_writer::tag('li', '', array('class' => 'clearfloat')); $html .= html_writer::end_tag('ul'); $html .= html_writer::tag('div', '', array('class' => 'clearfloat')); $html .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey())); $html .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'action', 'value' => 'makerandchoice')); $html .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'id', 'value' => $coursemoduleid)); $html .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'answer', 'value' => $availableoption)); if (empty($options['previewonly'])) { if (!empty($options['hascapability']) && $options['hascapability']) { if ($availableoption < 1) { $html .= html_writer::tag('label', get_string('randchoicefull', 'randchoice')); } else { $html .= html_writer::empty_tag('input', array('type' => 'submit', 'value' => get_string('savemyrandchoice', 'randchoice'), 'class' => 'button')); } if (!empty($options['allowupdate']) && $options['allowupdate']) { $url = new moodle_url('view.php', array('id' => $coursemoduleid, 'action' => 'delrandchoice', 'sesskey' => sesskey())); $html .= html_writer::link($url, get_string('removemyrandchoice', 'randchoice')); } } else { $html .= html_writer::tag('label', get_string('havetologin', 'randchoice')); } } $html .= html_writer::end_tag('ul'); $html .= html_writer::end_tag('form'); return $html; }
public function get_nav_links($course, $sections, $sectionno) { // FIXME: This is really evil and should by using the navigation API. $course = \course_get_format($course)->get_course(); $left = 'left'; $right = 'right'; if (\right_to_left()) { $temp = $left; $left = $right; $right = $temp; } $previousarrow = '<i class="fa fa-chevron-circle-' . $left . '"></i>'; $nextarrow = '<i class="fa fa-chevron-circle-' . $right . '"></i>'; $canviewhidden = \has_capability('moodle/course:viewhiddensections', \context_course::instance($course->id)) or !$course->hiddensections; $links = array('previous' => '', 'next' => ''); $back = $sectionno - 1; while ($back > 0 and empty($links['previous'])) { if ($canviewhidden || $sections[$back]->uservisible) { $params = array('id' => 'previous_section'); if (!$sections[$back]->visible) { $params['class'] = 'dimmed_text'; } $previouslink = \html_writer::start_tag('div', array('class' => 'nav_icon')); $previouslink .= $previousarrow; $previouslink .= \html_writer::end_tag('div'); $previouslink .= \html_writer::start_tag('span', array('class' => 'text')); $previouslink .= \html_writer::start_tag('span', array('class' => 'nav_guide')); $previouslink .= \get_string('previoussection', 'theme_essential'); $previouslink .= \html_writer::end_tag('span'); $previouslink .= \html_writer::empty_tag('br'); $previouslink .= \get_section_name($course, $sections[$back]); $previouslink .= \html_writer::end_tag('span'); $links['previous'] = \html_writer::link(course_get_url($course, $back), $previouslink, $params); } $back--; } $forward = $sectionno + 1; while ($forward <= $course->numsections and empty($links['next'])) { if ($canviewhidden || $sections[$forward]->uservisible) { $params = array('id' => 'next_section'); if (!$sections[$forward]->visible) { $params['class'] = 'dimmed_text'; } $nextlink = \html_writer::start_tag('div', array('class' => 'nav_icon')); $nextlink .= $nextarrow; $nextlink .= \html_writer::end_tag('div'); $nextlink .= \html_writer::start_tag('span', array('class' => 'text')); $nextlink .= \html_writer::start_tag('span', array('class' => 'nav_guide')); $nextlink .= \get_string('nextsection', 'theme_essential'); $nextlink .= \html_writer::end_tag('span'); $nextlink .= \html_writer::empty_tag('br'); $nextlink .= \get_section_name($course, $sections[$forward]); $nextlink .= \html_writer::end_tag('span'); $links['next'] = \html_writer::link(course_get_url($course, $forward), $nextlink, $params); } $forward++; } return $links; }
/** * Helper lib * * @package local_linkchecker_robot * @copyright 2016 Brendan Heywood <*****@*****.**> * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ function local_linkchecker_robot_link($url, $label, $redirect = '') { $html = html_writer::link(new moodle_url('url.php', array('url' => $url)), $label) . ' ' . html_writer::link($url, '↗', array('target' => 'link')) . '<br><small>' . $url . '</small>'; if ($redirect) { $html .= "<br>Redirect: " . html_writer::link($redirect, $redirect); } return $html; }
/** * Internal function - creates htmls structure suitable for YUI tree. */ protected function htmllize_tree($tree, $dir) { global $CFG; if (empty($dir['subdirs']) and empty($dir['files'])) { return ''; } $result = '<ul>'; foreach ($dir['subdirs'] as $subdir) { $image = $this->output->pix_icon(file_folder_icon(24), $subdir['dirname'], 'moodle'); $filename = html_writer::tag('span', $image, array('class' => 'fp-icon')). html_writer::tag('span', s($subdir['dirname']), array('class' => 'fp-filename')); $filename = html_writer::tag('div', $filename, array('class' => 'fp-filename-icon')); $result .= html_writer::tag('li', $filename. $this->htmllize_tree($tree, $subdir)); } foreach ($dir['files'] as $file) { $filename = $file->get_filename(); $url = moodle_url::make_pluginfile_url($file->get_contextid(), $file->get_component(), $file->get_filearea(), $file->get_itemid(), $file->get_filepath(), $filename, false); if (file_extension_in_typegroup($filename, 'web_image')) { $image = $url->out(false, array('preview' => 'tinyicon', 'oid' => $file->get_timemodified())); $image = html_writer::empty_tag('img', array('src' => $image)); } else { $image = $this->output->pix_icon(file_file_icon($file, 24), $filename, 'moodle'); } $filename = html_writer::tag('span', $image, array('class' => 'fp-icon')). html_writer::tag('span', $filename, array('class' => 'fp-filename')); $filename = html_writer::tag('span', html_writer::link($url->out(false, array('forcedownload' => 1)), $filename), array('class' => 'fp-filename-icon')); $result .= html_writer::tag('li', $filename); } $result .= '</ul>'; return $result; }
public function display_browse_field($recordid, $template) { global $DB, $CFG; if ($content = $DB->get_record('data_content', array('fieldid' => $this->field->id, 'recordid' => $recordid))) { if (empty($content->content)) { return false; } $options = explode("\n", $this->field->param1); $options = array_map('trim', $options); $contentarray = explode('##', $content->content); $str = ''; foreach ($contentarray as $line) { if (!in_array($line, $options)) { // Somebody edited the field definition. continue; } $params = array("f_{$this->field->id}" => $line, 'd' => $this->data->id, 'advanced' => 1); $url = new moodle_url('/mod/data/view.php', $params); $link = html_writer::link($url, $line); $str .= $link . "<br />\n"; } return $str; } return false; }
/** * Gets the block contents. * * If we can avoid it better not check the server status here as connecting * to the server will slow down the whole page load. * * @return string The block HTML. */ public function get_content() { global $OUTPUT; if ($this->content !== null) { return $this->content; } $this->content = new stdClass(); $this->content->footer = ''; if (\core_search\manager::is_global_search_enabled() === false) { $this->content->text = get_string('globalsearchdisabled', 'search'); return $this->content; } $url = new moodle_url('/search/index.php'); $this->content->footer .= html_writer::link($url, get_string('advancedsearch', 'search')); $this->content->text = html_writer::start_tag('div', array('class' => 'searchform')); $this->content->text .= html_writer::start_tag('form', array('action' => $url->out())); $this->content->text .= html_writer::start_tag('fieldset', array('action' => 'invisiblefieldset')); // Input. $this->content->text .= html_writer::tag('label', get_string('search', 'search'), array('for' => 'searchform_search', 'class' => 'accesshide')); $inputoptions = array('id' => 'searchform_search', 'name' => 'q', 'type' => 'text', 'size' => '15'); $this->content->text .= html_writer::empty_tag('input', $inputoptions); // Search button. $this->content->text .= html_writer::tag('button', get_string('search', 'search'), array('id' => 'searchform_button', 'type' => 'submit', 'title' => 'globalsearch')); $this->content->text .= html_writer::end_tag('fieldset'); $this->content->text .= html_writer::end_tag('form'); $this->content->text .= html_writer::end_tag('div'); return $this->content; }
/** * Generate the edit controls of a section * * @param stdClass $course The course entry from DB * @param stdClass $section The course_section entry from DB * @param bool $onsectionpage true if being printed on a section page * @return array of links with edit controls */ protected function section_edit_controls($course, $section, $onsectionpage = false) { global $PAGE; if (!$PAGE->user_is_editing()) { return array(); } $coursecontext = context_course::instance($course->id); if ($onsectionpage) { $url = course_get_url($course, $section->section); } else { $url = course_get_url($course); } $url->param('sesskey', sesskey()); $controls = array(); if (has_capability('moodle/course:setcurrentsection', $coursecontext)) { if ($course->marker == $section->section) { // Show the "light globe" on/off. $url->param('marker', 0); $controls[] = html_writer::link($url, html_writer::empty_tag('img', array('src' => $this->output->pix_url('i/marked'), 'class' => 'icon ', 'alt' => get_string('markedthistopic'))), array('title' => get_string('markedthistopic'), 'class' => 'editing_highlight')); } else { $url->param('marker', $section->section); $controls[] = html_writer::link($url, html_writer::empty_tag('img', array('src' => $this->output->pix_url('i/marker'), 'class' => 'icon', 'alt' => get_string('markthistopic'))), array('title' => get_string('markthistopic'), 'class' => 'editing_highlight')); } } return array_merge($controls, parent::section_edit_controls($course, $section, $onsectionpage)); }
function attendance_alerts($userid) { global $DB; $sessions_sql = "SELECT ff.*, fsd.*, ffs.id AS sessid\n FROM {facetoface} as ff\n JOIN {facetoface_sessions} as ffs\n ON ffs.facetoface = ff.id\n JOIN {facetoface_sessions_dates} as fsd\n ON fsd.sessionid = ffs.id\n WHERE ff.trainerid = :traineeid\n AND ffs.attendence_status = :status\n LIMIT 5\n "; $sessions = $DB->get_records_sql($sessions_sql, array('traineeid' => $userid, 'status' => 0)); if (empty($sessions)) { return get_string('nosessions', 'block_attendance'); } else { $table = new html_table(); $table->id = 'trainerfeedbak_batches'; $table->width = '100%'; $table->head = array(get_string('sessiondetails', 'block_attendance'), ''); foreach ($sessions as $session) { $row = array(); $sess_data = html_writer::start_tag('ul'); $sess_data .= html_writer::tag('li', $session->name); $session_date = date('d/m/y', $session->timestart) . ' - ' . date('d/m/y', $session->timefinish); $sess_data .= html_writer::tag('li', $session_date); $sess_data .= html_writer::end_tag('ul'); $row[] = $sess_data; $session_url = new moodle_url('/mod/facetoface/attendence.php', array('s' => $session->sessid)); $row[] = html_writer::link($session_url, get_string('view')); $table->data[] = $row; } return html_writer::table($table); } }