/** * 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'; } } }
/** * Return the HTML for the page. * * @return string */ public function html() { global $OUTPUT; $html = ''; $types = gradereport_singleview::valid_screens(); foreach ($types as $type) { $classname = "gradereport_singleview\\local\\screen\\{$type}"; $screen = new $classname($this->courseid, null, $this->groupid); if (!$screen instanceof selectable_items) { continue; } $options = $screen->options(); if (empty($options)) { continue; } $params = array('id' => $this->courseid, 'item' => $screen->item_type(), 'group' => $this->groupid); $url = new moodle_url('/grade/report/singleview/index.php', $params); $select = new \single_select($url, 'itemid', $options); $select->set_label($screen->description()); $html .= $OUTPUT->render($select); } if (empty($html)) { $OUTPUT->notification(get_string('noscreens', 'gradereport_singleview')); } return $html; }
/** * Prints/return reader selector * * @param report_log_renderable $reportlog log report. */ public function reader_selector(report_log_renderable $reportlog) { $readers = $reportlog->get_readers(true); if (empty($readers)) { $readers = array(get_string('nologreaderenabled', 'report_log')); } $select = new single_select($reportlog->url, 'logreader', $readers, $reportlog->selectedlogreader, null); $select->set_label(get_string('selectlogreader', 'report_log')); echo $this->output->render($select); }
/** * Renders the active method selector at the grading method management screen * * @param grading_manager $gradingman * @param moodle_url $targeturl * @return string */ public function management_method_selector(grading_manager $manager, moodle_url $targeturl) { $method = $manager->get_active_method(); $methods = $manager->get_available_methods(false); $methods['none'] = get_string('gradingmethodnone', 'core_grading'); $selector = new single_select(new moodle_url($targeturl, array('sesskey' => sesskey())), 'setmethod', $methods, empty($method) ? 'none' : $method, null, 'activemethodselector'); $selector->set_label(get_string('changeactivemethod', 'core_grading')); $selector->set_help_icon('gradingmethod', 'core_grading'); return $this->output->render($selector); }
/** * Prints/return reader selector * * @param report_loglive_renderable $reportloglive log report. * * @return string Returns rendered widget */ public function reader_selector(report_loglive_renderable $reportloglive) { $readers = $reportloglive->get_readers(true); if (count($readers) <= 1) { // One or no readers found, no need of this drop down. return ''; } $select = new single_select($reportloglive->url, 'logreader', $readers, $reportloglive->selectedlogreader, null); $select->set_label(get_string('selectlogreader', 'report_loglive')); return $this->output->render($select); }
function report_stats_mode_menu($course, $mode, $time, $url) { global $CFG, $OUTPUT; /* $reportoptions = stats_get_report_options($course->id, $mode); $timeoptions = report_stats_timeoptions($mode); if (empty($timeoptions)) { print_error('nostatstodisplay', '', $CFG->wwwroot.'/course/view.php?id='.$course->id); } */ $options = array(); $options[STATS_MODE_GENERAL] = get_string('statsmodegeneral'); $options[STATS_MODE_DETAILED] = get_string('statsmodedetailed'); if (has_capability('report/stats:view', context_system::instance())) { $options[STATS_MODE_RANKED] = get_string('reports'); } $popupurl = $url . "?course={$course->id}&time={$time}"; $select = new single_select(new moodle_url($popupurl), 'mode', $options, $mode, null); $select->set_label(get_string('reports'), array('class' => 'accesshide')); $select->formid = 'switchmode'; return $OUTPUT->render($select); }
/** * Print the drop down that allows the user to select how they want to have * the discussion displayed. * * @param int $id forum id if $forumtype is 'single', * discussion id for any other forum type * @param mixed $mode forum layout mode * @param string $forumtype optional */ function forum_print_mode_form($id, $mode, $forumtype='') { global $OUTPUT; if ($forumtype == 'single') { $select = new single_select(new moodle_url("/mod/forum/view.php", array('f'=>$id)), 'mode', forum_get_layout_modes(), $mode, null, "mode"); $select->set_label(get_string('displaymode', 'forum'), array('class' => 'accesshide')); $select->class = "forummode"; } else { $select = new single_select(new moodle_url("/mod/forum/discuss.php", array('d'=>$id)), 'mode', forum_get_layout_modes(), $mode, null, "mode"); $select->set_label(get_string('displaymode', 'forum'), array('class' => 'accesshide')); } echo $OUTPUT->render($select); }
echo '</div>'; if ($programid) { echo '<div style="margin-bottom: 10px;">'; $modules = $hierarchy->get_records_cobaltselect_menu('local_module', "programid=$programid AND visible=1", null, '', 'id,fullname', 'Select Module',0,0,0); $select2 = new single_select(new moodle_url('/local/curriculum/assigncourses.php?id=' . $plan->id . '&mode=' . $mode . '&cid=' . $cid . '&pid=' . $programid . ''), 'moduleid', $modules, $moduleid, null, 'switchcategory'); $select2->set_label(get_string('selectmodule', 'local_modules') . ':    '); echo $OUTPUT->render($select2); echo '</div>'; if(count($modules)<=1) echo $hierarchy->cobalt_navigation_msg(get_string('navigation_info','local_collegestructure'),get_string('createmodule', 'local_modules'),$CFG->wwwroot.'/local/modules/module.php'); } echo '</div>'; echo '<div id="d" style="margin-bottom: 10px;' . $display2 . '">'; $select3 = new single_select(new moodle_url('/local/curriculum/assigncourses.php?id=' . $plan->id . '&mode=' . $mode . '&cid=' . $cid . ''), 'did', $d, $departmentid, null, 'switchcategory'); $select3->set_label(get_string('selectdepartment', 'local_cobaltcourses') . ':    '); echo $OUTPUT->render($select3); // navigation handling if(count($d)<=1){ echo $hierarchy->cobalt_navigation_msg(get_string('navigation_info','local_collegestructure'),get_string('create_department', 'local_departments'),$CFG->wwwroot.'/local/departments/departments.php'); } echo '</div>'; $checkcount = $cplan->course_count($id, $cid, $moduleid, $departmentid); $disable = ($checkcount) ? 'disabled="disabled"' : ''; //Display the list of courses in the module to assign. if ($moduleid || $departmentid) { //If all the courses are assigned to the plan, Disable the button.
/** * Gets a list of courses where the current user can subscribe to rules as a dropdown. * * @param bool $choose A flag for whether to show the 'choose...' option in the select box. * @return \single_select|bool returns the list of courses, or false if the select box * should not be displayed. */ public function get_user_courses_select($choose = false) { $options = tool_monitor_get_user_courses(); // If we have no options then don't create a select element. if (!$options) { return false; } $selected = $this->courseid; $nothing = array(); if ($choose) { $selected = null; $nothing = array('choosedots'); } $url = new \moodle_url('/admin/tool/monitor/index.php'); $select = new \single_select($url, 'courseid', $options, $selected, $nothing); $select->set_label(get_string('selectacourse', 'tool_monitor')); return $select; }
/** * Return a {@link block_contents} representing the add a new block UI, if * this user is allowed to see it. * * @return block_contents an appropriate block_contents, or null if the user * cannot add any blocks here. */ function block_add_block_ui($page, $output) { global $CFG, $OUTPUT; if (!$page->user_is_editing() || !$page->user_can_edit_blocks()) { return null; } $bc = new block_contents(); $bc->title = get_string('addblock'); $bc->add_class('block_adminblock'); $missingblocks = $page->blocks->get_addable_blocks(); if (empty($missingblocks)) { $bc->content = get_string('noblockstoaddhere'); return $bc; } $menu = array(); foreach ($missingblocks as $block) { $blockobject = block_instance($block->name); if ($blockobject !== false && $blockobject->user_can_addto($page)) { $menu[$block->name] = $blockobject->get_title(); } } collatorlib::asort($menu); $actionurl = new moodle_url($page->url, array('sesskey' => sesskey())); $select = new single_select($actionurl, 'bui_addblock', $menu, null, array('' => get_string('adddots')), 'add_block'); $select->set_label(get_string('addblock'), array('class' => 'accesshide')); $bc->content = $OUTPUT->render($select); return $bc; }
/** * Displays a course filter selector * * @param moodle_url $returnurl The URL that the user should be taken too upon selecting a course. * @param string $label The label to use for the course select. * @return string */ protected function course_filter_selector(moodle_url $returnurl, $label = null) { global $USER, $SESSION, $CFG; if (!isloggedin() or isguestuser()) { return ''; } if (has_capability('moodle/calendar:manageentries', context_system::instance()) && !empty($CFG->calendar_adminseesall)) { $courses = get_courses('all', 'c.shortname', 'c.id,c.shortname'); } else { $courses = enrol_get_my_courses(); } unset($courses[SITEID]); $courseoptions = array(); $courseoptions[SITEID] = get_string('fulllistofcourses'); foreach ($courses as $course) { $coursecontext = context_course::instance($course->id); $courseoptions[$course->id] = format_string($course->shortname, true, array('context' => $coursecontext)); } if ($this->page->course->id !== SITEID) { $selected = $this->page->course->id; } else { $selected = ''; } $courseurl = new moodle_url($returnurl); $courseurl->remove_params('course'); $select = new single_select($courseurl, 'course', $courseoptions, $selected, null); $select->class = 'cal_courses_flt'; if ($label !== null) { $select->set_label($label); } else { $select->set_label(get_string('listofcourses'), array('class' => 'accesshide')); } return $this->output->render($select); }
function print_category_edit($category, $displaylist, $parentslist, $depth = -1, $up = false, $down = false) { /// Recursive function to print all the categories ready for editing global $CFG, $USER, $OUTPUT; static $str = NULL; if (is_null($str)) { $str = new stdClass(); $str->edit = get_string('edit'); $str->delete = get_string('delete'); $str->moveup = get_string('moveup'); $str->movedown = get_string('movedown'); $str->edit = get_string('editthiscategory'); $str->hide = get_string('hide'); $str->show = get_string('show'); $str->cohorts = get_string('cohorts', 'cohort'); $str->spacer = $OUTPUT->spacer() . ' '; } if (!empty($category)) { if (!isset($category->context)) { $category->context = context_coursecat::instance($category->id); } echo '<tr><td align="left" class="name">'; for ($i = 0; $i < $depth; $i++) { echo ' '; } $linkcss = $category->visible ? '' : ' class="dimmed" '; echo '<a ' . $linkcss . ' title="' . $str->edit . '" ' . ' href="category.php?id=' . $category->id . '&categoryedit=on&sesskey=' . sesskey() . '">' . format_string($category->name, true, array('context' => $category->context)) . '</a>'; echo '</td>'; echo '<td class="count">' . $category->coursecount . '</td>'; echo '<td class="icons">'; /// Print little icons if (has_capability('moodle/category:manage', $category->context)) { echo '<a title="' . $str->edit . '" href="editcategory.php?id=' . $category->id . '"><img' . ' src="' . $OUTPUT->pix_url('t/edit') . '" class="iconsmall" alt="' . $str->edit . '" /></a> '; echo '<a title="' . $str->delete . '" href="index.php?delete=' . $category->id . '&sesskey=' . sesskey() . '"><img' . ' src="' . $OUTPUT->pix_url('t/delete') . '" class="iconsmall" alt="' . $str->delete . '" /></a> '; if (!empty($category->visible)) { echo '<a title="' . $str->hide . '" href="index.php?hide=' . $category->id . '&sesskey=' . sesskey() . '"><img' . ' src="' . $OUTPUT->pix_url('t/hide') . '" class="iconsmall" alt="' . $str->hide . '" /></a> '; } else { echo '<a title="' . $str->show . '" href="index.php?show=' . $category->id . '&sesskey=' . sesskey() . '"><img' . ' src="' . $OUTPUT->pix_url('t/show') . '" class="iconsmall" alt="' . $str->show . '" /></a> '; } if (has_capability('moodle/cohort:manage', $category->context) or has_capability('moodle/cohort:view', $category->context)) { echo '<a title="' . $str->cohorts . '" href="' . $CFG->wwwroot . '/cohort/index.php?contextid=' . $category->context->id . '"><img' . ' src="' . $OUTPUT->pix_url('i/cohort') . '" class="iconsmall" alt="' . $str->cohorts . '" /></a> '; } if ($up) { echo '<a title="' . $str->moveup . '" href="index.php?moveup=' . $category->id . '&sesskey=' . sesskey() . '"><img' . ' src="' . $OUTPUT->pix_url('t/up') . '" class="iconsmall" alt="' . $str->moveup . '" /></a> '; } else { echo $str->spacer; } if ($down) { echo '<a title="' . $str->movedown . '" href="index.php?movedown=' . $category->id . '&sesskey=' . sesskey() . '"><img' . ' src="' . $OUTPUT->pix_url('t/down') . '" class="iconsmall" alt="' . $str->movedown . '" /></a> '; } else { echo $str->spacer; } } echo '</td>'; echo '<td align="left">'; if (has_capability('moodle/category:manage', $category->context)) { $tempdisplaylist = $displaylist; unset($tempdisplaylist[$category->id]); foreach ($parentslist as $key => $parents) { if (in_array($category->id, $parents)) { unset($tempdisplaylist[$key]); } } $popupurl = new moodle_url("index.php?move={$category->id}&sesskey=" . sesskey()); $select = new single_select($popupurl, 'moveto', $tempdisplaylist, $category->parent, null, "moveform{$category->id}"); $select->set_label(get_string('frontpagecategorynames'), array('class' => 'accesshide')); echo $OUTPUT->render($select); } echo '</td>'; echo '</tr>'; } else { $category = new stdClass(); $category->id = '0'; } if ($categories = get_categories($category->id)) { // Print all the children recursively $countcats = count($categories); $count = 0; $first = true; $last = false; foreach ($categories as $cat) { $count++; if ($count == $countcats) { $last = true; } $up = $first ? false : true; $down = $last ? false : true; $first = false; print_category_edit($cat, $displaylist, $parentslist, $depth + 1, $up, $down); } } }
echo html_writer::tag('p', 'A standalone single button. This is still wrapped in a form so you can submit it. There are a couple of ways to generate, via a function call:'); echo $OUTPUT->single_button($continueurl, 'A disabled button', 'post', array('disabled' => true)); echo html_writer::tag('p', 'Or manually create object then render. Note this uses a confirm dialog, try pressing to see popup (needs styling)'); // render directly $button = new single_button($continueurl, 'Manually rendered button', 'post'); $button->tooltip = 'This is the tooltip'; $button->formid = 'canbeset'; $button->class = 'classonbutton'; $button->add_confirm_action('This message appears to confirm when you push the button'); echo $OUTPUT->render($button); echo html_writer::tag('p', 'A single select form. Quick way using a function:'); $url = new moodle_url('index.php', array('urlparams' => 'become', 'hidden' => 'fields')); $options = array(1 => 'one', 2 => 'two', 3 => 'three', 4 => 'four'); echo $OUTPUT->single_select($url, 'youpicked', $options, '', array('' => 'choose'), 'formid'); echo html_writer::tag('p', 'A single select form. Manually rendered:'); $select = new single_select($url, 'youpicked', $options); $select->set_label('This is a label for the select'); $select->tooltip = 'This is the tooltip'; //this doesn't seem to work - moodle bug? //$select->add_confirm_action('Confirm you want to do this'); $select->set_help_icon('activities', 'moodle'); echo $OUTPUT->render($select); echo html_writer::tag('p', 'A url select form. Typically used for navigation.'); $urls = array('/admin/tool/elementlibrary/' => 'Index', '/admin/tool/elementlibrary/common.php' => 'Common elements', '/admin/tool/elementlibrary/mform.php' => 'Moodle form elements', '/admin/tool/elementlibrary/tables.php' => 'Tables', '/admin/tool/elementlibrary/tabs.php' => 'Tabs'); echo $OUTPUT->url_select($urls, '', array('' => 'choose'), 'formid'); /* * This never loads and isn't called this way anywhere else? echo html_writer::tag('p', 'A stand-alone file picker:'); $options = new stdClass(); echo $OUTPUT->file_picker($options); */
public function editing_bar_head($max = 0) { global $OUTPUT, $USER; $output = $OUTPUT->box_start('notice'); $options = array('0' => get_string('alwaysshowall', 'block_my_course_overview')); for ($i = 1; $i <= $max; $i++) { $options[$i] = $i; } $url = new moodle_url('/my/index.php'); $select = new single_select($url, 'mynumber', $options, $USER->profile['mynumber'], array()); $select->set_label(get_string('numtodisplay', 'block_my_course_overview')); $output .= $OUTPUT->render($select); $output .= $OUTPUT->box_end(); return $output; }
/** * Display tag filter as a link or dropdown * @param array $taglist is array of tags * @param mod_forumng $forum * @param string $selectid of tag if selected * @return string for printing out */ public function render_tag_filter($taglist, $forum, $selectid = null) { $baseurl = 'view.php?' . $forum->get_link_params(mod_forumng::PARAM_HTML); if (isset($selectid)) { $tagname = htmlspecialchars($taglist[$selectid]->displayname); $taglink = get_string('removefiltering', 'forumng', $tagname); $taglink .= ' ('; $taglink .= html_writer::tag('a', get_string('show_all', 'forumng'), array('href' => $baseurl)); $taglink .= ')'; $out = html_writer::tag('div', $taglink, array('class' => 'forumng_discuss_tagfilter')); } else { // Display dropdown. foreach ($taglist as $tag) { $options[$tag->id] = htmlspecialchars($tag->displayname) . ' (' . $tag->count . ')'; } $tagurl = new moodle_url('/mod/forumng/view.php?', $forum->get_link_params_array(mod_forumng::PARAM_PLAIN)); $select = new single_select($tagurl, 'tag', $options, ''); $select->label = get_string('filterdiscussions', 'forumng'); $select->set_help_icon('forumngdiscusstagfilter', 'forumng'); $output = $this->render($select); $out = '<div class="forumng_discuss_tagfilter">' . $output . '</div>'; } return $out; }
/** * Constructs header in editing mode * * @param int $max maximum number of courses * @return string html of header bar. */ public function editing_bar_head($max = 0) { $output = $this->output->box_start('notice'); $options = array('0' => get_string('alwaysshowall', 'block_course_overview')); for ($i = 1; $i <= $max; $i++) { $options[$i] = $i; } $url = new moodle_url('/my/index.php'); $select = new single_select($url, 'mynumber', $options, block_course_overview_get_max_user_courses(), array()); $select->set_label(get_string('numtodisplay', 'block_course_overview')); $output .= $this->output->render($select); $output .= $this->output->box_end(); return $output; }
} } print_collapsible_region_end(); } break; case workshop::PHASE_EVALUATION: if (has_capability('mod/workshop:viewallassessments', $PAGE->context)) { $perpage = get_user_preferences('workshop_perpage', 10); $groupid = groups_get_activity_group($workshop->cm, true); $data = $workshop->prepare_grading_report_data($USER->id, $groupid, $page, $perpage, $sortby, $sorthow); if ($data) { $showauthornames = has_capability('mod/workshop:viewauthornames', $workshop->context); $showreviewernames = has_capability('mod/workshop:viewreviewernames', $workshop->context); if (has_capability('mod/workshop:overridegrades', $PAGE->context)) { // Print a drop-down selector to change the current evaluation method. $selector = new single_select($PAGE->url, 'eval', workshop::available_evaluators_list(), $workshop->evaluation, false, 'evaluationmethodchooser'); $selector->set_label(get_string('evaluationmethod', 'mod_workshop')); $selector->set_help_icon('evaluationmethod', 'mod_workshop'); $selector->method = 'post'; echo $output->render($selector); // load the grading evaluator $evaluator = $workshop->grading_evaluation_instance(); $form = $evaluator->get_settings_form(new moodle_url($workshop->aggregate_url(), compact('sortby', 'sorthow', 'page'))); $form->display(); } // prepare paging bar $baseurl = new moodle_url($PAGE->url, array('sortby' => $sortby, 'sorthow' => $sorthow)); $pagingbar = new paging_bar($data->totalcount, $page, $perpage, $baseurl, 'page'); // grading report display options $reportopts = new stdclass(); $reportopts->showauthornames = $showauthornames;
/** * prints a form to choose categories */ protected function display_category_form($contexts, $pageurl, $current) { global $CFG, $OUTPUT; /// Get all the existing categories now echo '<div class="choosecategory">'; $catmenu = question_category_options($contexts, false, 0, true); $select = new single_select($this->baseurl, 'category', $catmenu, $current, null, 'catmenu'); $select->set_label(get_string('selectacategory', 'question')); echo $OUTPUT->render($select); echo "</div>\n"; }
/** * Print a select box allowing the user to choose to view new messages, course participants etc. * * Called by message_print_contact_selector() * @param int $viewing What page is the user viewing ie MESSAGE_VIEW_UNREAD_MESSAGES, MESSAGE_VIEW_RECENT_CONVERSATIONS etc * @param array $courses array of course objects. The courses the user is enrolled in. * @param array $coursecontexts array of course contexts. Keyed on course id. * @param int $countunreadtotal how many unread messages does the user have? * @param int $countblocked how many users has the current user blocked? * @param stdClass $user1 The user whose messages we are viewing. * @param string $strunreadmessages a preconstructed message about the number of unread messages the user has * @return void */ function message_print_usergroup_selector($viewing, $courses, $coursecontexts, $countunreadtotal, $countblocked, $strunreadmessages, $user1 = null) { global $PAGE; $options = array(); if ($countunreadtotal>0) { //if there are unread messages $options[MESSAGE_VIEW_UNREAD_MESSAGES] = $strunreadmessages; } $str = get_string('contacts', 'message'); $options[MESSAGE_VIEW_CONTACTS] = $str; $options[MESSAGE_VIEW_RECENT_CONVERSATIONS] = get_string('mostrecentconversations', 'message'); $options[MESSAGE_VIEW_RECENT_NOTIFICATIONS] = get_string('mostrecentnotifications', 'message'); if (!empty($courses)) { $courses_options = array(); foreach($courses as $course) { if (has_capability('moodle/course:viewparticipants', $coursecontexts[$course->id])) { //Not using short_text() as we want the end of the course name. Not the beginning. $shortname = format_string($course->shortname, true, array('context' => $coursecontexts[$course->id])); if (core_text::strlen($shortname) > MESSAGE_MAX_COURSE_NAME_LENGTH) { $courses_options[MESSAGE_VIEW_COURSE.$course->id] = '...'.core_text::substr($shortname, -MESSAGE_MAX_COURSE_NAME_LENGTH); } else { $courses_options[MESSAGE_VIEW_COURSE.$course->id] = $shortname; } } } if (!empty($courses_options)) { $options[] = array(get_string('courses') => $courses_options); } } if ($countblocked>0) { $str = get_string('blockedusers','message', $countblocked); $options[MESSAGE_VIEW_BLOCKED] = $str; } $select = new single_select($PAGE->url, 'viewing', $options, $viewing, false); $select->set_label(get_string('messagenavigation', 'message')); $renderer = $PAGE->get_renderer('core'); echo $renderer->render($select); }
function get_table_row($filterinfo, $isfirstrow, $islastactive, $applytostrings) { global $CFG, $OUTPUT, $activechoices, $applytochoices, $filternames; //TODO: this is sloppy coding style!! $row = array(); $filter = $filterinfo->filter; // Filter name if (!empty($filternames[$filter])) { $row[] = $filternames[$filter]; } else { $row[] = '<span class="error">' . get_string('filemissing', '', $filter) . '</span>'; } // Disable/off/on $select = new single_select(filters_action_url($filter, 'setstate'), 'newstate', $activechoices, $filterinfo->active, null, 'active' . $filter); $select->set_label(get_string('isactive', 'filters'), array('class' => 'accesshide')); $row[] = $OUTPUT->render($select); // Re-order $updown = ''; $spacer = '<img src="' . $OUTPUT->pix_url('spacer') . '" class="iconsmall" alt="" />'; if ($filterinfo->active != TEXTFILTER_DISABLED) { if (!$isfirstrow) { $updown .= $OUTPUT->action_icon(filters_action_url($filter, 'up'), new pix_icon('t/up', get_string('up'), '', array('class' => 'iconsmall'))); } else { $updown .= $spacer; } if (!$islastactive) { $updown .= $OUTPUT->action_icon(filters_action_url($filter, 'down'), new pix_icon('t/down', get_string('down'), '', array('class' => 'iconsmall'))); } else { $updown .= $spacer; } } $row[] = $updown; // Apply to strings. $select = new single_select(filters_action_url($filter, 'setapplyto'), 'stringstoo', $applytochoices, $applytostrings, null, 'applyto' . $filter); $select->set_label(get_string('applyto', 'filters'), array('class' => 'accesshide')); $select->disabled = $filterinfo->active == TEXTFILTER_DISABLED; $row[] = $OUTPUT->render($select); // Settings link, if required if (filter_has_global_settings($filter)) { $row[] = '<a href="' . $CFG->wwwroot . '/' . $CFG->admin . '/settings.php?section=filtersetting' . $filter . '">' . get_string('settings') . '</a>'; } else { $row[] = ''; } // Delete $row[] = '<a href="' . filters_action_url($filter, 'delete') . '">' . get_string('delete') . '</a>'; return $row; }
/** * Returns a form with a single select widget. * * Theme developers: DO NOT OVERRIDE! Please override function * {@link core_renderer::render_single_select()} instead. * * @param moodle_url $url form action target, includes hidden fields * @param string $name name of selection field - the changing parameter in url * @param array $options list of options * @param string $selected selected element * @param array $nothing * @param string $formid * @param array $attributes other attributes for the single select * @return string HTML fragment */ public function single_select($url, $name, array $options, $selected = '', $nothing = array('' => 'choosedots'), $formid = null, $attributes = array()) { if (!($url instanceof moodle_url)) { $url = new moodle_url($url); } $select = new single_select($url, $name, $options, $selected, $nothing, $formid); if (array_key_exists('label', $attributes)) { $select->set_label($attributes['label']); unset($attributes['label']); } $select->attributes = $attributes; return $this->render($select); }
} else { $site = get_site(); $PAGE->set_title("$site->shortname: $category->name"); $PAGE->set_heading($site->fullname); $PAGE->set_button(print_course_search('', true, 'navbar')); $PAGE->set_pagelayout('coursecategory'); echo $OUTPUT->header(); } /// Print the category selector $displaylist = array(); $notused = array(); make_categories_list($displaylist, $notused); echo '<div class="categorypicker">'; $select = new single_select(new moodle_url('/course/category.php'), 'id', $displaylist, $category->id, null, 'switchcategory'); $select->set_label(get_string('categories').':'); echo $OUTPUT->render($select); echo '</div>'; /// Print current category description if (!$editingon && $category->description) { echo $OUTPUT->box_start(); $options = new stdClass; $options->noclean = true; $options->para = false; $options->overflowdiv = true; if (!isset($category->descriptionformat)) { $category->descriptionformat = FORMAT_MOODLE; } $text = file_rewrite_pluginfile_urls($category->description, 'pluginfile.php', $context->id, 'coursecat', 'description', null);
$PAGE->navbar->add($settingsnode->text, $settingsnode->action); } echo $OUTPUT->header(); } else { $PAGE->set_title("{$site->shortname}: {$category->name}"); $PAGE->set_heading($site->fullname); $PAGE->set_button(print_course_search('', true, 'navbar')); $PAGE->set_pagelayout('coursecategory'); echo $OUTPUT->header(); } /// Print the category selector $displaylist = array(); $notused = array(); make_categories_list($displaylist, $notused); echo '<div class="categorypicker">'; $select = new single_select(new moodle_url('category.php'), 'id', $displaylist, $category->id, null, 'switchcategory'); $select->set_label($strcategories . ':'); echo $OUTPUT->render($select); echo '</div>'; /// Print current category description if (!$editingon && $category->description) { echo $OUTPUT->box_start(); $options = new stdClass(); $options->noclean = true; $options->para = false; $options->overflowdiv = true; if (!isset($category->descriptionformat)) { $category->descriptionformat = FORMAT_MOODLE; } $text = file_rewrite_pluginfile_urls($category->description, 'pluginfile.php', $context->id, 'coursecat', 'description', null); echo format_text($text, $category->descriptionformat, $options);
/** * @global object * @global object * @param object $cm * @param object $glossary * @param string $hook * @param object $category */ function glossary_print_categories_menu($cm, $glossary, $hook, $category) { global $CFG, $DB, $OUTPUT; $context = context_module::instance($cm->id); // Prepare format_string/text options $fmtoptions = array( 'context' => $context); echo '<table border="0" width="100%">'; echo '<tr>'; echo '<td align="center" style="width:20%">'; if (has_capability('mod/glossary:managecategories', $context)) { $options['id'] = $cm->id; $options['mode'] = 'cat'; $options['hook'] = $hook; echo $OUTPUT->single_button(new moodle_url("editcategories.php", $options), get_string("editcategories","glossary"), "get"); } echo '</td>'; echo '<td align="center" style="width:60%">'; echo '<b>'; $menu = array(); $menu[GLOSSARY_SHOW_ALL_CATEGORIES] = get_string("allcategories","glossary"); $menu[GLOSSARY_SHOW_NOT_CATEGORISED] = get_string("notcategorised","glossary"); $categories = $DB->get_records("glossary_categories", array("glossaryid"=>$glossary->id), "name ASC"); $selected = ''; if ( $categories ) { foreach ($categories as $currentcategory) { $url = $currentcategory->id; if ( $category ) { if ($currentcategory->id == $category->id) { $selected = $url; } } $menu[$url] = format_string($currentcategory->name, true, $fmtoptions); } } if ( !$selected ) { $selected = GLOSSARY_SHOW_NOT_CATEGORISED; } if ( $category ) { echo format_string($category->name, true, $fmtoptions); } else { if ( $hook == GLOSSARY_SHOW_NOT_CATEGORISED ) { echo get_string("entrieswithoutcategory","glossary"); $selected = GLOSSARY_SHOW_NOT_CATEGORISED; } elseif ( $hook == GLOSSARY_SHOW_ALL_CATEGORIES ) { echo get_string("allcategories","glossary"); $selected = GLOSSARY_SHOW_ALL_CATEGORIES; } } echo '</b></td>'; echo '<td align="center" style="width:20%">'; $select = new single_select(new moodle_url("/mod/glossary/view.php", array('id'=>$cm->id, 'mode'=>'cat')), 'hook', $menu, $selected, null, "catmenu"); $select->set_label(get_string('categories', 'glossary'), array('class' => 'accesshide')); echo $OUTPUT->render($select); echo '</td>'; echo '</tr>'; echo '</table>'; }
$conform_msg = get_string('eassign_mentor', 'local_assignmentor', $temp_lang); $options = array('style' => 'notifyproblem'); } $hier->set_confirmation($conform_msg, $currenturl, $options); } } try { /* ----school filter----- */ $schoolids = $assignee_ob->check_loginuser_registrar_admin(); $schoollist = $hier->get_school_parent($schoolids, '', true); $school_select = new single_select(new moodle_url('/local/assignmentor/assign_mentor.php'), 'sid', $schoollist, $sid, null, null); $school_select->set_label(get_string('select', 'local_collegestructure')); echo '<div>' . $OUTPUT->render($school_select) . '</div>'; $programlist = $hier->get_records_cobaltselect_menu('local_program', "schoolid=$sid AND visible=1", null, '', 'id,fullname', '--Select--'); $prg_select = new single_select(new moodle_url('/local/assignmentor/assign_mentor.php', array('sid' => $sid)), 'pid', $programlist, $programid, null); $prg_select->set_label(get_string('selectprogram', 'local_programs')); echo '<div style="margin-top:10px;">' . $OUTPUT->render($prg_select) . '</div>'; echo '<br/><br/>'; $currentyear = date("Y", time()); /* ----fetching students of perticular program and students---- */ $sql1 = "SELECT u.id,u.firstname,u.lastname,u.email ,from_unixtime(ud.timecreated,'%Y') as year From {$CFG->prefix}local_userdata AS ud INNER JOIN {$CFG->prefix}user AS u ON u.id=ud.userid where ud.schoolid=$sid and ud.programid=$programid and from_unixtime(ud.timecreated,'%Y')=$currentyear"; $student_list = $DB->get_records_sql($sql1); /* ---used to remove already assigned student id 's--- */ foreach ($student_list as $stu => $stu_value) { $exists = $DB->get_record('local_assignmentor_tostudent', array('studentid' => $stu_value->id, 'schoolid' => $sid, 'programid' => $programid)); if ($exists)
/** * Recursive function to print all the categories ready for editing. * * @param html_table $table The table to add data to. * @param coursecat $category The category to render * @param int $depth The depth of the category. * @param bool $up True if this category can be moved up. * @param bool $down True if this category can be moved down. */ function print_category_edit(html_table $table, coursecat $category, $depth = -1, $up = false, $down = false) { global $OUTPUT; static $str = null; if (is_null($str)) { $str = new stdClass; $str->edit = new lang_string('edit'); $str->delete = new lang_string('delete'); $str->moveup = new lang_string('moveup'); $str->movedown = new lang_string('movedown'); $str->edit = new lang_string('editthiscategory'); $str->hide = new lang_string('hide'); $str->show = new lang_string('show'); $str->cohorts = new lang_string('cohorts', 'cohort'); $str->spacer = $OUTPUT->spacer().' '; } if ($category->id) { $categorycontext = context_coursecat::instance($category->id); $attributes = array(); $attributes['class'] = $category->visible ? '' : 'dimmed'; $attributes['title'] = $str->edit; $categoryurl = new moodle_url('/course/manage.php', array('categoryid' => $category->id, 'sesskey' => sesskey())); $categoryname = $category->get_formatted_name(); $categorypadding = str_repeat(' ', $depth); $categoryname = $categorypadding . html_writer::link($categoryurl, $categoryname, $attributes); $icons = array(); if (has_capability('moodle/category:manage', $categorycontext)) { // Edit category. $icons[] = $OUTPUT->action_icon( new moodle_url('/course/editcategory.php', array('id' => $category->id)), new pix_icon('t/edit', $str->edit, 'moodle', array('class' => 'iconsmall')), null, array('title' => $str->edit) ); // Delete category. $icons[] = $OUTPUT->action_icon( new moodle_url('/course/manage.php', array('deletecat' => $category->id, 'sesskey' => sesskey())), new pix_icon('t/delete', $str->delete, 'moodle', array('class' => 'iconsmall')), null, array('title' => $str->delete) ); // Change visibility. if (!empty($category->visible)) { $icons[] = $OUTPUT->action_icon( new moodle_url('/course/manage.php', array('hidecat' => $category->id, 'sesskey' => sesskey())), new pix_icon('t/hide', $str->hide, 'moodle', array('class' => 'iconsmall')), null, array('title' => $str->hide) ); } else { $icons[] = $OUTPUT->action_icon( new moodle_url('/course/manage.php', array('showcat' => $category->id, 'sesskey' => sesskey())), new pix_icon('t/show', $str->show, 'moodle', array('class' => 'iconsmall')), null, array('title' => $str->show) ); } // Cohorts. if (has_any_capability(array('moodle/cohort:manage', 'moodle/cohort:view'), $categorycontext)) { $icons[] = $OUTPUT->action_icon( new moodle_url('/cohort/index.php', array('contextid' => $categorycontext->id)), new pix_icon('t/cohort', $str->cohorts, 'moodle', array('class' => 'iconsmall')), null, array('title' => $str->cohorts) ); } // Move up/down. if ($up) { $icons[] = $OUTPUT->action_icon( new moodle_url('/course/manage.php', array('moveupcat' => $category->id, 'sesskey' => sesskey())), new pix_icon('t/up', $str->moveup, 'moodle', array('class' => 'iconsmall')), null, array('title' => $str->moveup) ); } else { $icons[] = $str->spacer; } if ($down) { $icons[] = $OUTPUT->action_icon( new moodle_url('/course/manage.php', array('movedowncat' => $category->id, 'sesskey' => sesskey())), new pix_icon('t/down', $str->movedown, 'moodle', array('class' => 'iconsmall')), null, array('title' => $str->movedown) ); } else { $icons[] = $str->spacer; } } $actions = ''; if (has_capability('moodle/category:manage', $categorycontext)) { $popupurl = new moodle_url('/course/manage.php', array('movecat' => $category->id, 'sesskey' => sesskey())); $tempdisplaylist = array(0 => get_string('top')) + coursecat::make_categories_list('moodle/category:manage', $category->id); $select = new single_select($popupurl, 'movetocat', $tempdisplaylist, $category->parent, null, "moveform$category->id"); $select->set_label(get_string('frontpagecategorynames'), array('class' => 'accesshide')); $actions = $OUTPUT->render($select); } $table->data[] = new html_table_row(array( // Category name. new html_table_cell($categoryname), // Course count. new html_table_cell($category->coursecount), // Icons. new html_table_cell(join(' ', $icons)), // Actions. new html_table_cell($actions) )); } if ($categories = $category->get_children()) { // Print all the children recursively. $countcats = count($categories); $count = 0; $first = true; $last = false; foreach ($categories as $cat) { $count++; if ($count == $countcats) { $last = true; } $up = $first ? false : true; $down = $last ? false : true; $first = false; print_category_edit($table, $cat, $depth+1, $up, $down); } } }
/** * Gets the enrolment type filter control for this table * * @return single_select */ public function get_enrolment_type_filter() { $selector = new single_select($this->moodlepage->url, 'ifilter', array(0 => get_string('all')) + (array) $this->manager->get_enrolment_instance_names(), $this->manager->get_enrolment_filter(), array()); $selector->set_label(get_string('enrolmentinstances', 'enrol')); return $selector; }
/** * Renders HTML to display particular course category - list of it's subcategories and courses * * Invoked from /course/index.php * * @param int|stdClass|coursecat $category */ public function course_category($category) { global $CFG; require_once $CFG->libdir . '/coursecatlib.php'; $coursecat = coursecat::get(is_object($category) ? $category->id : $category); $site = get_site(); $output = ''; if (can_edit_in_category($coursecat->id)) { // Add 'Manage' button if user has permissions to edit this category. $managebutton = $this->single_button(new moodle_url('/course/management.php', array('categoryid' => $coursecat->id)), get_string('managecourses'), 'get'); $this->page->set_button($managebutton); } if (!$coursecat->id) { if (coursecat::count_all() == 1) { // There exists only one category in the system, do not display link to it $coursecat = coursecat::get_default(); $strfulllistofcourses = get_string('fulllistofcourses'); $this->page->set_title("{$site->shortname}: {$strfulllistofcourses}"); } else { $strcategories = get_string('categories'); $this->page->set_title("{$site->shortname}: {$strcategories}"); } } else { $this->page->set_title("{$site->shortname}: " . $coursecat->get_formatted_name()); // Print the category selector $output .= html_writer::start_tag('div', array('class' => 'categorypicker')); $select = new single_select(new moodle_url('/course/index.php'), 'categoryid', coursecat::make_categories_list(), $coursecat->id, null, 'switchcategory'); $select->set_label(get_string('categories') . ':'); $output .= $this->render($select); $output .= html_writer::end_tag('div'); // .categorypicker } // Print current category description $chelper = new coursecat_helper(); if ($description = $chelper->get_category_formatted_description($coursecat)) { $output .= $this->box($description, array('class' => 'generalbox info')); } // Prepare parameters for courses and categories lists in the tree $chelper->set_show_courses(self::COURSECAT_SHOW_COURSES_AUTO)->set_attributes(array('class' => 'category-browse category-browse-' . $coursecat->id)); $coursedisplayoptions = array(); $catdisplayoptions = array(); $browse = optional_param('browse', null, PARAM_ALPHA); $perpage = optional_param('perpage', $CFG->coursesperpage, PARAM_INT); $page = optional_param('page', 0, PARAM_INT); $baseurl = new moodle_url('/course/index.php'); if ($coursecat->id) { $baseurl->param('categoryid', $coursecat->id); } if ($perpage != $CFG->coursesperpage) { $baseurl->param('perpage', $perpage); } $coursedisplayoptions['limit'] = $perpage; $catdisplayoptions['limit'] = $perpage; if ($browse === 'courses' || !$coursecat->has_children()) { $coursedisplayoptions['offset'] = $page * $perpage; $coursedisplayoptions['paginationurl'] = new moodle_url($baseurl, array('browse' => 'courses')); $catdisplayoptions['nodisplay'] = true; $catdisplayoptions['viewmoreurl'] = new moodle_url($baseurl, array('browse' => 'categories')); $catdisplayoptions['viewmoretext'] = new lang_string('viewallsubcategories'); } else { if ($browse === 'categories' || !$coursecat->has_courses()) { $coursedisplayoptions['nodisplay'] = true; $catdisplayoptions['offset'] = $page * $perpage; $catdisplayoptions['paginationurl'] = new moodle_url($baseurl, array('browse' => 'categories')); $coursedisplayoptions['viewmoreurl'] = new moodle_url($baseurl, array('browse' => 'courses')); $coursedisplayoptions['viewmoretext'] = new lang_string('viewallcourses'); } else { // we have a category that has both subcategories and courses, display pagination separately $coursedisplayoptions['viewmoreurl'] = new moodle_url($baseurl, array('browse' => 'courses', 'page' => 1)); $catdisplayoptions['viewmoreurl'] = new moodle_url($baseurl, array('browse' => 'categories', 'page' => 1)); } } $chelper->set_courses_display_options($coursedisplayoptions)->set_categories_display_options($catdisplayoptions); // Add course search form. $output .= $this->course_search_form(); // Display course category tree. $output .= $this->coursecat_tree($chelper, $coursecat); // Add action buttons $output .= $this->container_start('buttons'); $context = get_category_or_system_context($coursecat->id); if (has_capability('moodle/course:create', $context)) { // Print link to create a new course, for the 1st available category. if ($coursecat->id) { $url = new moodle_url('/course/edit.php', array('category' => $coursecat->id, 'returnto' => 'category')); } else { $url = new moodle_url('/course/edit.php', array('category' => $CFG->defaultrequestcategory, 'returnto' => 'topcat')); } $output .= $this->single_button($url, get_string('addnewcourse'), 'get'); } ob_start(); if (coursecat::count_all() == 1) { print_course_request_buttons(context_system::instance()); } else { print_course_request_buttons($context); } $output .= ob_get_contents(); ob_end_clean(); $output .= $this->container_end(); return $output; }
} // Try a year. if (strtotime('-1 year', $now) >= $minlastaccess) { $timeoptions[strtotime('-1 year', $now)] = get_string('lastyear'); } if (!empty($lastaccess0exists)) { $timeoptions[-1] = get_string('never'); } if (count($timeoptions) > 1) { $select = new single_select($baseurl, 'accesssince', $timeoptions, $accesssince, null, 'timeoptions'); $select->set_label(get_string('usersnoaccesssince')); $controlstable->data[0]->cells[] = $OUTPUT->render($select); } } $formatmenu = array('0' => get_string('brief'), '1' => get_string('userdetails')); $select = new single_select($baseurl, 'mode', $formatmenu, $mode, null, 'formatmenu'); $select->set_label(get_string('userlist')); $userlistcell = new html_table_cell(); $userlistcell->attributes['class'] = 'right'; $userlistcell->text = $OUTPUT->render($select); $controlstable->data[0]->cells[] = $userlistcell; echo html_writer::table($controlstable); if ($currentgroup and (!$isseparategroups or has_capability('moodle/site:accessallgroups', $context))) { // Display info about the group. if ($group = groups_get_group($currentgroup)) { if (!empty($group->description) or !empty($group->picture) and empty($group->hidepicture)) { $groupinfotable = new html_table(); $groupinfotable->attributes['class'] = 'groupinfobox'; $picturecell = new html_table_cell(); $picturecell->attributes['class'] = 'left side picture'; $picturecell->text = print_group_picture($group, $course->id, true, true, false);
$PAGE->navbar->add(get_string('manual', 'local_admission')); echo $OUTPUT->header(); echo $OUTPUT->heading(get_string('manual', 'local_admission')); if (isset($CFG->allowframembedding) and !$CFG->allowframembedding) { echo $OUTPUT->box(get_string('helpmanual', 'local_admission')); echo '<div style="float:right;"><a href="upload.php"><button>' . get_string('back_upload', 'local_admission') . '</button></a></div>'; } if (isset($CFG->allowframembedding) and !$CFG->allowframembedding) { echo '<b >' . $OUTPUT->box('<p style="color:red;">' . get_string('delimited', 'local_scheduleexam') . '</p>') . '</b>'; } $country = get_string_manager()->get_list_of_countries(); $countries = array(); foreach ($country as $key => $value) { $countries[] = $key . ' => ' . $value; } echo get_string('help_table1', 'local_admission'); $select = new single_select(new moodle_url('#'), 'proid', $countries, null, ''); $select->set_label(''); echo $OUTPUT->render($select); echo get_string('help_table2', 'local_admission'); $select = new single_select(new moodle_url('#'), 'proid', $countries, null, ''); $select->set_label(''); echo $OUTPUT->render($select); echo get_string('help_table3', 'local_admission'); $select = new single_select(new moodle_url('#'), 'proid', $countries, null, ''); $select->set_label(''); echo $OUTPUT->render($select); echo get_string('help_table4', 'local_admission'); echo $OUTPUT->footer(); ?>