本文整理汇总了PHP中print_section_add_menus函数的典型用法代码示例。如果您正苦于以下问题:PHP print_section_add_menus函数的具体用法?PHP print_section_add_menus怎么用?PHP print_section_add_menus使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了print_section_add_menus函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_content
//.........这里部分代码省略.........
return $this->content;
}
$course = $this->page->course;
require_once $CFG->dirroot . '/course/lib.php';
$context = context_course::instance($course->id);
$isediting = $this->page->user_is_editing() && has_capability('moodle/course:manageactivities', $context);
$modinfo = get_fast_modinfo($course);
/// extra fast view mode
if (!$isediting) {
if (!empty($modinfo->sections[0])) {
$options = array('overflowdiv' => true);
foreach ($modinfo->sections[0] as $cmid) {
$cm = $modinfo->cms[$cmid];
if (!$cm->uservisible) {
continue;
}
list($content, $instancename) = get_print_section_cm_text($cm, $course);
if (!($url = $cm->get_url())) {
$this->content->items[] = $content;
$this->content->icons[] = '';
} else {
$linkcss = $cm->visible ? '' : ' class="dimmed" ';
//Accessibility: incidental image - should be empty Alt text
$icon = '<img src="' . $cm->get_icon_url() . '" class="icon" alt="" /> ';
$this->content->items[] = '<a title="' . $cm->modplural . '" ' . $linkcss . ' ' . $cm->extra . ' href="' . $url . '">' . $icon . $instancename . '</a>';
}
}
}
return $this->content;
}
/// slow & hacky editing mode
$ismoving = ismoving($course->id);
$section = get_course_section(0, $course->id);
get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused);
$groupbuttons = $course->groupmode;
$groupbuttonslink = !$course->groupmodeforce;
if ($ismoving) {
$strmovehere = get_string('movehere');
$strmovefull = strip_tags(get_string('movefull', '', "'{$USER->activitycopyname}'"));
$strcancel = get_string('cancel');
$stractivityclipboard = $USER->activitycopyname;
}
/// Casting $course->modinfo to string prevents one notice when the field is null
$editbuttons = '';
if ($ismoving) {
$this->content->icons[] = '<img src="' . $OUTPUT->pix_url('t/move') . '" class="iconsmall" alt="" />';
$this->content->items[] = $USER->activitycopyname . ' (<a href="' . $CFG->wwwroot . '/course/mod.php?cancelcopy=true&sesskey=' . sesskey() . '">' . $strcancel . '</a>)';
}
if (!empty($section->sequence)) {
$sectionmods = explode(',', $section->sequence);
$options = array('overflowdiv' => true);
foreach ($sectionmods as $modnumber) {
if (empty($mods[$modnumber])) {
continue;
}
$mod = $mods[$modnumber];
if (!$ismoving) {
if ($groupbuttons) {
if (!($mod->groupmodelink = $groupbuttonslink)) {
$mod->groupmode = $course->groupmode;
}
} else {
$mod->groupmode = false;
}
$editbuttons = '<div class="buttons">' . make_editing_buttons($mod, true, true) . '</div>';
} else {
$editbuttons = '';
}
if ($mod->visible || has_capability('moodle/course:viewhiddenactivities', $context)) {
if ($ismoving) {
if ($mod->id == $USER->activitycopy) {
continue;
}
$this->content->items[] = '<a title="' . $strmovefull . '" href="' . $CFG->wwwroot . '/course/mod.php?moveto=' . $mod->id . '&sesskey=' . sesskey() . '">' . '<img style="height:16px; width:80px; border:0px" src="' . $OUTPUT->pix_url('movehere') . '" alt="' . $strmovehere . '" /></a>';
$this->content->icons[] = '';
}
list($content, $instancename) = get_print_section_cm_text($modinfo->cms[$modnumber], $course);
$linkcss = $mod->visible ? '' : ' class="dimmed" ';
if (!($url = $mod->get_url())) {
$this->content->items[] = $content . $editbuttons;
$this->content->icons[] = '';
} else {
//Accessibility: incidental image - should be empty Alt text
$icon = '<img src="' . $mod->get_icon_url() . '" class="icon" alt="" /> ';
$this->content->items[] = '<a title="' . $mod->modfullname . '" ' . $linkcss . ' ' . $mod->extra . ' href="' . $url . '">' . $icon . $instancename . '</a>' . $editbuttons;
}
}
}
}
if ($ismoving) {
$this->content->items[] = '<a title="' . $strmovefull . '" href="' . $CFG->wwwroot . '/course/mod.php?movetosection=' . $section->id . '&sesskey=' . sesskey() . '">' . '<img style="height:16px; width:80px; border:0px" src="' . $OUTPUT->pix_url('movehere') . '" alt="' . $strmovehere . '" /></a>';
$this->content->icons[] = '';
}
if (!empty($modnames)) {
$this->content->footer = print_section_add_menus($course, 0, $modnames, true, true);
} else {
$this->content->footer = '';
}
return $this->content;
}
示例2: strip_tags
$stractivityclipboard = strip_tags(get_string('activityclipboard', '', addslashes($USER->activitycopyname)));
echo '<p><font size="2">';
echo "{$stractivityclipboard} (<a href=\"course/mod.php?cancelcopy=true&sesskey={$USER->sesskey}\">" . get_string('cancel') . '</a>)';
echo '</font></p>';
}
$options = NULL;
$options->noclean = true;
echo format_text($section->summary, FORMAT_HTML, $options);
if ($editing) {
$streditsummary = get_string('editsummary');
echo "<a title=\"{$streditsummary}\" " . " href=\"course/editsection.php?id={$section->id}\"><img src=\"{$CFG->pixpath}/t/edit.gif\" " . " class=\"iconsmall\" alt=\"{$streditsummary}\" /></a><br /><br />";
}
get_all_mods($SITE->id, $mods, $modnames, $modnamesplural, $modnamesused);
print_section($SITE, $section, $mods, $modnamesused, true);
if ($editing) {
print_section_add_menus($SITE, $section->section, $modnames);
}
print_box_end();
}
}
if (isloggedin() and !isguest() and isset($CFG->frontpageloggedin)) {
$frontpagelayout = $CFG->frontpageloggedin;
} else {
$frontpagelayout = $CFG->frontpage;
}
foreach (explode(',', $frontpagelayout) as $v) {
switch ($v) {
/// Display the main part of the front page.
case FRONTPAGENEWS:
if ($SITE->newsitems) {
// Print forums only when needed
示例3: render_subpage
//.........这里部分代码省略.........
if ($section->stealth) {
$content .= html_writer::start_tag('form', array('method' => 'post', 'action' => 'stealth.php'));
$content .= html_writer::start_tag('div');
$content .= html_writer::empty_tag('input', array('name' => 'id', 'value' => $subpage->get_course_module()->id, 'type' => 'hidden'));
$content .= html_writer::empty_tag('input', array('name' => 'sesskey', 'value' => sesskey(), 'type' => 'hidden'));
$content .= html_writer::empty_tag('input', array('name' => 'unstealth', 'value' => $section->id, 'type' => 'hidden'));
$content .= html_writer::empty_tag('input', array('name' => 'icon', 'src' => $OUTPUT->pix_url('unstealth', 'mod_subpage'), 'type' => 'image', 'title' => $strunstealth, 'alt' => $strunstealth));
$content .= html_writer::end_tag('div');
$content .= html_writer::end_tag('form');
} else {
$content .= html_writer::start_tag('form', array('method' => 'post', 'action' => 'stealth.php'));
$content .= html_writer::start_tag('div');
$content .= html_writer::empty_tag('input', array('name' => 'id', 'value' => $subpage->get_course_module()->id, 'type' => 'hidden'));
$content .= html_writer::empty_tag('input', array('name' => 'sesskey', 'value' => sesskey(), 'type' => 'hidden'));
$content .= html_writer::empty_tag('input', array('name' => 'stealth', 'value' => $section->id, 'type' => 'hidden'));
$content .= html_writer::empty_tag('input', array('name' => 'icon', 'src' => $OUTPUT->pix_url('stealth', 'mod_subpage'), 'type' => 'image', 'title' => $strstealth, 'alt' => $strstealth));
$content .= html_writer::end_tag('div');
$content .= html_writer::end_tag('form');
}
$content .= html_writer::empty_tag('br', array());
if ($movesection) {
$content .= html_writer::start_tag('span', array('class' => 'section_move_commands'));
if ($section->pageorder > 1) {
// Add a arrow to move section up
$content .= html_writer::start_tag('a', array('href' => 'view.php?id=' . $subpage->get_course_module()->id . '&random=' . rand(1, 10000) . '§ion=' . $section->id . '&move=-1&sesskey=' . sesskey() . '#section-' . ($section->id - 1), 'title' => $strmoveup));
$content .= html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('t/up'), 'class' => 'icon up', 'alt' => $strmoveup));
$content .= html_writer::end_tag('a');
$content .= html_writer::empty_tag('br', array());
}
if ($section->pageorder < $lastpageorder) {
// Add an arrow to move section down
$content .= html_writer::start_tag('a', array('href' => 'view.php?id=' . $subpage->get_course_module()->id . '&random=' . rand(1, 10000) . '§ion=' . $section->id . '&move=1&sesskey=' . sesskey() . '#section-' . ($section->id + 1), 'title' => $strmovedown));
$content .= html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('t/down'), 'class' => 'icon down', 'alt' => $strmovedown));
$content .= html_writer::end_tag('a');
$content .= html_writer::empty_tag('br', array());
}
$content .= html_writer::end_tag('span');
}
}
$content .= html_writer::end_tag('div');
$content .= html_writer::start_tag('div', array('class' => 'content'));
// Only show the section if visible and not stealthed or to users with permission
if (($section->visible && !$section->stealth || has_capability('moodle/course:viewhiddensections', $coursecontext)) && ($editing || !$section->autohide)) {
if ($section->stealth) {
$content .= html_writer::start_tag('div', array('class' => 'stealthed'));
}
if (!empty($section->name)) {
$content .= html_writer::tag('h3', format_string($section->name), array('class' => 'sectionname'));
}
$summary = '';
if ($section->summary) {
$summarytext = file_rewrite_pluginfile_urls($section->summary, 'pluginfile.php', $coursecontext->id, 'course', 'section', $section->id);
$summaryformatoptions = new stdClass();
$summaryformatoptions->noclean = true;
$summaryformatoptions->overflowdiv = true;
$summary .= format_text($summarytext, $section->summaryformat, $summaryformatoptions);
}
if ($editing && has_capability('moodle/course:update', $coursecontext)) {
$summary .= html_writer::start_tag('a', array('href' => $CFG->wwwroot . '/course/editsection.php?id=' . $section->id . '&returnurl=' . urlencode($CFG->wwwroot . '/mod/subpage/view.php?id=' . $subpage->get_course_module()->id . '&recache=1&sesskey=' . sesskey()), 'title' => $streditsummary));
$summary .= html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('t/edit'), 'class' => 'icon edit', 'alt' => $streditsummary));
$summary .= html_writer::end_tag('a');
$summary .= html_writer::empty_tag('br', array());
$summary .= html_writer::start_tag('a', array('href' => $CFG->wwwroot . '/mod/subpage/view.php?id=' . $subpage->get_course_module()->id . '&delete=' . $section->id . '&sesskey=' . sesskey(), 'title' => $strdelete));
if (empty($section->sequence)) {
$summary .= html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('t/delete'), 'class' => 'icon delete', 'alt' => $strdelete));
}
$summary .= html_writer::end_tag('a');
$summary .= html_writer::empty_tag('br', array());
$summary .= html_writer::empty_tag('br', array());
}
if ($summary !== '') {
$content .= html_writer::tag('div', $summary, array('class' => 'summary'));
}
$content .= $this->render_section($subpage, $modinfo, $section, $editing, $moveitem, $mods, $modnamesused);
if ($editing) {
$content .= print_section_add_menus($subpage->get_course(), $section->section, $modnames, false, true);
if (!empty($CFG->enablecourseajax) and $PAGE->theme->enablecourseajax) {
// hacky way to add list to empty section to allow drag/drop into
// empty sections
$content = str_replace('</div><div class="section_add_menus">', '</div><ul class="section img-text"><li></li></ul>' . '<div class="section_add_menus">', $content);
}
}
//now add returnto links to editing links:
$pattern = '/mod.php\\?[A-Za-z0-9-&;=%:\\/\\-.]+/';
$content = preg_replace_callback($pattern, 'mod_subpage_renderer::subpage_url_regex', $content);
if ($section->stealth) {
$content .= html_writer::end_tag('div');
}
}
$content .= html_writer::end_tag('div');
//end of div class=content
$content .= html_writer::end_tag('li');
}
$content .= html_writer::end_tag('ul');
if ($editing) {
$content .= $this->render_add_button($subpage);
$content .= $this->render_bulkmove_buttons($subpage);
}
return $content;
}
示例4: print_heading
echo '<td class="content">';
if (!has_capability('moodle/course:viewhiddensections', $context) and !$thissection->visible) {
// Hidden for students
print_heading($weekperiod . ' (' . get_string('notavailable') . ')', null, 3, 'weekdates');
} else {
print_heading($weekperiod, null, 3, 'weekdates');
echo '<div class="summary">';
$summaryformatoptions->noclean = true;
echo format_text($thissection->summary, FORMAT_HTML, $summaryformatoptions);
if (isediting($course->id) && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
echo ' <a title="' . $streditsummary . '" href="editsection.php?id=' . $thissection->id . '">' . '<img src="' . $CFG->pixpath . '/t/edit.gif" class="iconsmall edit" alt="' . $streditsummary . '" /></a><br /><br />';
}
echo '</div>';
print_section($course, $thissection, $mods, $modnamesused);
if (isediting($course->id)) {
print_section_add_menus($course, $section, $modnames);
}
}
echo '</td>';
echo '<td class="right side">';
if ($displaysection == $section) {
echo '<a href="view.php?id=' . $course->id . '&week=0#section-' . $section . '" title="' . $strshowallweeks . '">' . '<img src="' . $CFG->pixpath . '/i/all.gif" class="icon wkall" alt="' . $strshowallweeks . '" /></a><br />';
} else {
$strshowonlyweek = get_string("showonlyweek", "", $section);
echo '<a href="view.php?id=' . $course->id . '&week=' . $section . '" title="' . $strshowonlyweek . '">' . '<img src="' . $CFG->pixpath . '/i/one.gif" class="icon wkone" alt="' . $strshowonlyweek . '" /></a><br />';
}
if (isediting($course->id) && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
if ($thissection->visible) {
// Show the hide/show eye
echo '<a href="view.php?id=' . $course->id . '&hide=' . $section . '&sesskey=' . $USER->sesskey . '#section-' . $section . '" title="' . $strweekhide . '">' . '<img src="' . $CFG->pixpath . '/i/hide.gif" class="icon hide" alt="' . $strweekhide . '" /></a><br />';
} else {
示例5: print_single_section_page
public function print_single_section_page($course, $sections, $mods, $modnames, $modnamesused, $displaysection)
{
global $PAGE;
$modinfo = get_fast_modinfo($course);
$course = course_get_format($course)->get_course();
// Can we view the section in question?
if (!($sectioninfo = $modinfo->get_section_info($displaysection))) {
// This section doesn't exist
print_error('unknowncoursesection', 'error', null, $course->fullname);
return;
}
if (!$sectioninfo->uservisible) {
if (!$course->hiddensections) {
echo $this->start_section_list();
echo $this->section_hidden($displaysection);
echo $this->end_section_list();
}
// Can't view this section.
return;
}
// Copy activity clipboard..
echo $this->course_activity_clipboard($course, $displaysection);
// General section if non-empty.
$thissection = $sections[0];
//if ($thissection->summary or $thissection->sequence or $PAGE->user_is_editing()) {
echo $this->start_section_list();
echo $this->section_header($thissection, $course, true, $displaysection);
$this->print_noticeboard($course);
if ($PAGE->user_is_editing() && is_siteadmin($USER)) {
print_section($course, $thissection, $mods, $modnamesused, true, "100%", false, $displaysection);
print_section_add_menus($course, 0, $modnames, false, false, $displaysection);
}
echo $this->section_footer();
echo $this->end_section_list();
//}
// Start single-section div
echo html_writer::start_tag('div', array('class' => 'single-section'));
// The requested section page.
$thissection = $modinfo->get_section_info($displaysection);
// Title with section navigation links.
$sectionnavlinks = $this->get_nav_links($course, $modinfo->get_section_info_all(), $displaysection);
$sectiontitle = '';
$sectiontitle .= html_writer::start_tag('div', array('class' => 'section-navigation header headingblock'));
// Title attributes
$titleattr = 'title';
if (!$thissection->visible) {
$titleattr .= ' dimmed_text';
}
$sectiontitle .= html_writer::tag('div', get_section_name($course, $displaysection), array('class' => $titleattr));
$sectiontitle .= html_writer::end_tag('div');
echo $sectiontitle;
// Now the list of sections..
echo $this->start_section_list();
echo $this->section_header($thissection, $course, true, $displaysection);
// Show completion help icon.
$completioninfo = new completion_info($course);
echo $completioninfo->display_help_icon();
echo $this->courserenderer->course_section_cm_list($course, $thissection, $displaysection);
echo $this->courserenderer->course_section_add_cm_control($course, $displaysection, $displaysection);
echo $this->section_footer();
echo $this->end_section_list();
// Display section bottom navigation.
$sectionbottomnav = '';
$sectionbottomnav .= html_writer::start_tag('nav', array('id' => 'section_footer', 'class' => 'clearfix'));
$sectionbottomnav .= $sectionnavlinks['previous'];
$sectionbottomnav .= $sectionnavlinks['next'];
// $sectionbottomnav .= html_writer::tag('div', $this->section_nav_selection($course, $sections, $displaysection), array('class' => 'mdl-align'));
$sectionbottomnav .= html_writer::end_tag('nav');
echo $sectionbottomnav;
// Close single-section div.
echo html_writer::end_tag('div');
}
示例6: print_multiple_section_page
/**
* Output the html for a multiple section page
*
* @param stdClass $course The course entry from DB
* @param array $sections (argument not used)
* @param array $mods (argument not used)
* @param array $modnames (argument not used)
* @param array $modnamesused (argument not used)
*/
public function print_multiple_section_page($course, $sections, $mods, $modnames, $modnamesused)
{
global $PAGE;
$modinfo = get_fast_modinfo($course);
$course = course_get_format($course)->get_course();
$context = context_course::instance($course->id);
// Title with completion help icon.
$completioninfo = new completion_info($course);
echo $completioninfo->display_help_icon();
echo $this->output->heading($this->page_title(), 2, 'accesshide');
// Copy activity clipboard..
echo $this->course_activity_clipboard($course, 0);
// Now the list of sections..
echo $this->start_section_list();
foreach ($modinfo->get_section_info_all() as $section => $thissection) {
if ($section == 0) {
// 0-section is displayed a little different then the others
if ($thissection->summary or !empty($modinfo->sections[0]) or $PAGE->user_is_editing()) {
echo $this->section_header($thissection, $course, false, 0);
print_section($course, $thissection, null, null, true, "100%", false, 0);
if ($PAGE->user_is_editing()) {
print_section_add_menus($course, 0, null, false, false, 0);
}
echo $this->section_footer();
}
continue;
}
if ($section > $course->numsections) {
// activities inside this section are 'orphaned', this section will be printed as 'stealth' below
continue;
}
// Show the section if the user is permitted to access it, OR if it's not available
// but showavailability is turned on
$showsection = $thissection->uservisible || $thissection->visible && !$thissection->available && $thissection->showavailability;
if (!$showsection) {
// Hidden section message is overridden by 'unavailable' control
// (showavailability option).
if (!$course->hiddensections && $thissection->available) {
if ($course->coursedisplay == COURSE_DISPLAY_MULTIPAGE) {
echo $this->section_summary($thissection, $course, $mods);
} else {
echo $this->section_hidden($section);
}
}
continue;
}
if (!$PAGE->user_is_editing() && $course->coursedisplay == COURSE_DISPLAY_MULTIPAGE) {
// Display section summary only.
echo $this->section_summary($thissection, $course, null);
} else {
echo $this->section_header($thissection, $course, false, 0);
if ($thissection->uservisible) {
print_section($course, $thissection, null, null, true, "100%", false, 0);
if ($PAGE->user_is_editing()) {
print_section_add_menus($course, $section, null, false, false, 0);
}
}
echo $this->section_footer();
}
}
if ($PAGE->user_is_editing() and has_capability('moodle/course:update', $context)) {
// Print stealth sections if present.
foreach ($modinfo->get_section_info_all() as $section => $thissection) {
if ($section <= $course->numsections or empty($modinfo->sections[$section])) {
// this is not stealth section or it is empty
continue;
}
echo $this->stealth_section_header($section);
print_section($course, $thissection, null, null, true, "100%", false, 0);
echo $this->stealth_section_footer();
}
echo $this->end_section_list();
echo html_writer::start_tag('div', array('id' => 'changenumsections', 'class' => 'mdl-right'));
// Increase number of sections.
$straddsection = get_string('increasesections', 'moodle');
$url = new moodle_url('/course/changenumsections.php', array('courseid' => $course->id, 'increase' => true, 'sesskey' => sesskey()));
$icon = $this->output->pix_icon('t/switch_plus', $straddsection);
echo html_writer::link($url, $icon . get_accesshide($straddsection), array('class' => 'increase-sections'));
if ($course->numsections > 0) {
// Reduce number of sections sections.
$strremovesection = get_string('reducesections', 'moodle');
$url = new moodle_url('/course/changenumsections.php', array('courseid' => $course->id, 'increase' => false, 'sesskey' => sesskey()));
$icon = $this->output->pix_icon('t/switch_minus', $strremovesection);
echo html_writer::link($url, $icon . get_accesshide($strremovesection), array('class' => 'reduce-sections'));
}
echo html_writer::end_tag('div');
} else {
echo $this->end_section_list();
}
}
示例7: fn_display_category_content
//.........这里部分代码省略.........
$section->course = $course->id;
$section->section = $sectnum;
$section->summary = $category->name;
$section->sequence = '';
$section->visible = 1;
if (!($section->id = insert_record('course_sections', $section))) {
error('Could not create section for category ' . $category->name);
}
}
if (!empty($section) || $isediting) {
get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused);
}
$groupbuttons = $course->groupmode;
$groupbuttonslink = !$course->groupmodeforce;
if ($ismoving) {
$strmovehere = get_string('movehere');
$strmovefull = strip_tags(get_string('movefull', '', "'{$USER->activitycopyname}'"));
$strcancel = get_string('cancel');
$stractivityclipboard = $USER->activitycopyname;
}
$modinfo = unserialize($course->modinfo);
$editbuttons = '';
print_simple_box_start("center", "100%", '', 5, "coursebox");
echo '<table class="topics" width="100%">';
echo '<tr id="section-' . $section . '" class="section main">';
echo '<td class="content">';
print_heading_block('<div align="center">' . $category->name . '</div>');
echo '<table class="section" width="100%">';
if (!empty($section) && !empty($section->sequence)) {
$sectionmods = explode(',', $section->sequence);
foreach ($sectionmods as $modnumber) {
if (empty($mods[$modnumber])) {
continue;
}
$mod = $mods[$modnumber];
if ($isediting && !$ismoving) {
if ($groupbuttons) {
if (!($mod->groupmodelink = $groupbuttonslink)) {
$mod->groupmode = $course->groupmode;
}
} else {
$mod->groupmode = false;
}
$editbuttons = '<br />' . make_editing_buttons($mod, true, true);
} else {
$editbuttons = '';
}
if ($mod->visible || $isteacher) {
echo '<tr><td class="activity ' . $mod->modname . '">';
if ($ismoving) {
if ($mod->id == $USER->activitycopy) {
continue;
}
echo '<a title="' . $strmovefull . '" href="' . $CFG->wwwroot . '/course/mod.php?moveto=' . $mod->id . '&sesskey=' . $USER->sesskey . '">' . '<img height="16" width="80" src="' . $CFG->pixpath . '/movehere.gif" alt="' . $strmovehere . '" border="0" /></a>';
}
$instancename = urldecode($modinfo[$modnumber]->name);
$instancename = format_string($instancename, true, $course->id);
$linkcss = $mod->visible ? '' : ' class="dimmed" ';
if (!empty($modinfo[$modnumber]->extra)) {
$extra = urldecode($modinfo[$modnumber]->extra);
} else {
$extra = '';
}
if (!empty($modinfo[$modnumber]->icon)) {
$icon = $CFG->pixpath . '/' . urldecode($modinfo[$modnumber]->icon);
} else {
$icon = $CFG->modpixpath . '/' . $mod->modname . '/icon.gif';
}
if ($mod->modname == 'label') {
echo format_text($extra, FORMAT_HTML) . $editbuttons;
} else {
echo '<img src="' . $icon . '" height="16" width="16" alt="' . $mod->modfullname . '" /> ' . '<a title="' . $mod->modfullname . '" ' . $linkcss . ' ' . $extra . ' href="' . $CFG->wwwroot . '/mod/' . $mod->modname . '/view.php?id=' . $mod->id . '">' . $instancename . '</a>' . $editbuttons;
}
echo "</td>";
echo "</tr>";
}
}
} else {
echo "<tr><td></td></tr>";
// needed for XHTML compatibility
}
if ($ismoving) {
echo '<tr><td><a title="' . $strmovefull . '" href="' . $CFG->wwwroot . '/course/mod.php?movetosection=' . $section->id . '&sesskey=' . $USER->sesskey . '">' . '<img height="16" width="80" src="' . $CFG->pixpath . '/movehere.gif" alt="' . $strmovehere . '" border="0" /></a></td></tr>';
}
if ($isediting && $modnames) {
echo '<tr><td>';
print_section_add_menus($course, $section->section, $modnames, true);
echo '</td></tr>';
}
echo "</table>\n\n";
echo '</td></tr></table>';
print_simple_box_end();
if (empty($courses)) {
print_heading(FN_translate_course_string(get_string("nocoursesyet")));
} else {
foreach ($courses as $course) {
print_course($course);
}
}
}
示例8: print_multiple_section_page
/**
* Output the html for a multiple section page
*
* @param stdClass $course The course entry from DB
* @param array $sections The course_sections entries from the DB
* @param array $mods used for print_section()
* @param array $modnames used for print_section()
* @param array $modnamesused used for print_section()
*/
public function print_multiple_section_page($course, $sections, $mods, $modnames, $modnamesused)
{
global $PAGE;
$context = context_course::instance($course->id);
// Title with completion help icon.
$completioninfo = new completion_info($course);
echo $completioninfo->display_help_icon();
echo $this->output->heading($this->page_title(), 2, 'accesshide');
// Copy activity clipboard..
echo $this->course_activity_clipboard($course);
// Now the list of sections..
echo $this->start_section_list();
// General section if non-empty.
$thissection = $sections[0];
unset($sections[0]);
if ($thissection->summary or $thissection->sequence or $PAGE->user_is_editing()) {
echo $this->section_header($thissection, $course, true);
print_section($course, $thissection, $mods, $modnamesused, true);
if ($PAGE->user_is_editing()) {
print_section_add_menus($course, 0, $modnames);
}
echo $this->section_footer();
}
$canviewhidden = has_capability('moodle/course:viewhiddensections', $context);
for ($section = 1; $section <= $course->numsections; $section++) {
if (!empty($sections[$section])) {
$thissection = $sections[$section];
} else {
// This will create a course section if it doesn't exist..
$thissection = get_course_section($section, $course->id);
// The returned section is only a bare database object rather than
// a section_info object - we will need at least the uservisible
// field in it.
$thissection->uservisible = true;
$thissection->availableinfo = null;
$thissection->showavailability = 0;
}
// Show the section if the user is permitted to access it, OR if it's not available
// but showavailability is turned on
$showsection = $thissection->uservisible || $thissection->visible && !$thissection->available && $thissection->showavailability;
if (!$showsection) {
// Hidden section message is overridden by 'unavailable' control
// (showavailability option).
if (!$course->hiddensections && $thissection->available) {
echo $this->section_hidden($section);
}
unset($sections[$section]);
continue;
}
if (!$PAGE->user_is_editing() && $course->coursedisplay == COURSE_DISPLAY_MULTIPAGE) {
// Display section summary only.
echo $this->section_summary($thissection, $course);
} else {
echo $this->section_header($thissection, $course, false);
if ($thissection->uservisible) {
print_section($course, $thissection, $mods, $modnamesused);
if ($PAGE->user_is_editing()) {
print_section_add_menus($course, $section, $modnames);
}
}
echo $this->section_footer();
}
unset($sections[$section]);
}
if ($PAGE->user_is_editing() and has_capability('moodle/course:update', $context)) {
// Print stealth sections if present.
$modinfo = get_fast_modinfo($course);
foreach ($sections as $section => $thissection) {
if (empty($modinfo->sections[$section])) {
continue;
}
echo $this->stealth_section_header($section);
print_section($course, $thissection, $mods, $modnamesused);
echo $this->stealth_section_footer();
}
echo $this->end_section_list();
echo html_writer::start_tag('div', array('id' => 'changenumsections', 'class' => 'mdl-right'));
// Increase number of sections.
$straddsection = get_string('increasesections', 'moodle');
$url = new moodle_url('/course/changenumsections.php', array('courseid' => $course->id, 'increase' => true, 'sesskey' => sesskey()));
$icon = $this->output->pix_icon('t/switch_plus', $straddsection);
echo html_writer::link($url, $icon . get_accesshide($straddsection), array('class' => 'increase-sections'));
if ($course->numsections > 0) {
// Reduce number of sections sections.
$strremovesection = get_string('reducesections', 'moodle');
$url = new moodle_url('/course/changenumsections.php', array('courseid' => $course->id, 'increase' => false, 'sesskey' => sesskey()));
$icon = $this->output->pix_icon('t/switch_minus', $strremovesection);
echo html_writer::link($url, $icon . get_accesshide($strremovesection), array('class' => 'reduce-sections'));
}
echo html_writer::end_tag('div');
} else {
//.........这里部分代码省略.........
示例9: get_content
function get_content()
{
global $USER, $CFG;
if ($this->content !== NULL) {
return $this->content;
}
$this->content = new stdClass();
$this->content->items = array();
$this->content->icons = array();
$this->content->footer = '';
if (empty($this->instance)) {
return $this->content;
}
$course = get_record('course', 'id', $this->instance->pageid);
$context = get_context_instance(CONTEXT_COURSE, $course->id);
$isediting = isediting($this->instance->pageid) && has_capability('moodle/course:manageactivities', $context);
$ismoving = ismoving($this->instance->pageid);
$sections = get_all_sections($this->instance->pageid);
if (!empty($sections) && isset($sections[0])) {
$section = $sections[0];
}
if (!empty($section) || $isediting) {
get_all_mods($this->instance->pageid, $mods, $modnames, $modnamesplural, $modnamesused);
}
$groupbuttons = $course->groupmode;
$groupbuttonslink = !$course->groupmodeforce;
if ($ismoving) {
$strmovehere = get_string('movehere');
$strmovefull = strip_tags(get_string('movefull', '', "'{$USER->activitycopyname}'"));
$strcancel = get_string('cancel');
$stractivityclipboard = $USER->activitycopyname;
}
/// Casting $course->modinfo to string prevents one notice when the field is null
$modinfo = unserialize((string) $course->modinfo);
$editbuttons = '';
if ($ismoving) {
$this->content->icons[] = '<img src="' . $CFG->pixpath . '/t/move.gif" class="iconsmall" alt="" />';
$this->content->items[] = $USER->activitycopyname . ' (<a href="' . $CFG->wwwroot . '/course/mod.php?cancelcopy=true&sesskey=' . $USER->sesskey . '">' . $strcancel . '</a>)';
}
if (!empty($section) && !empty($section->sequence)) {
$sectionmods = explode(',', $section->sequence);
foreach ($sectionmods as $modnumber) {
if (empty($mods[$modnumber])) {
continue;
}
$mod = $mods[$modnumber];
if ($isediting && !$ismoving) {
if ($groupbuttons) {
if (!($mod->groupmodelink = $groupbuttonslink)) {
$mod->groupmode = $course->groupmode;
}
} else {
$mod->groupmode = false;
}
$editbuttons = '<div class="buttons">' . make_editing_buttons($mod, true, true) . '</div>';
} else {
$editbuttons = '';
}
if ($mod->visible || has_capability('moodle/course:viewhiddenactivities', $context)) {
if ($ismoving) {
if ($mod->id == $USER->activitycopy) {
continue;
}
$this->content->items[] = '<a title="' . $strmovefull . '" href="' . $CFG->wwwroot . '/course/mod.php?moveto=' . $mod->id . '&sesskey=' . $USER->sesskey . '">' . '<img style="height:16px; width:80px; border:0px" src="' . $CFG->pixpath . '/movehere.gif" alt="' . $strmovehere . '" /></a>';
$this->content->icons[] = '';
}
$instancename = urldecode($modinfo[$modnumber]->name);
$instancename = format_string($instancename, true, $this->instance->pageid);
$linkcss = $mod->visible ? '' : ' class="dimmed" ';
if (!empty($modinfo[$modnumber]->extra)) {
$extra = urldecode($modinfo[$modnumber]->extra);
} else {
$extra = '';
}
if (!empty($modinfo[$modnumber]->icon)) {
$icon = $CFG->pixpath . '/' . urldecode($modinfo[$modnumber]->icon);
} else {
$icon = $CFG->modpixpath . '/' . $mod->modname . '/icon.gif';
}
if ($mod->modname == 'label') {
$this->content->items[] = format_text($extra, FORMAT_HTML) . $editbuttons;
$this->content->icons[] = '';
} else {
$this->content->items[] = '<a title="' . $mod->modfullname . '" ' . $linkcss . ' ' . $extra . ' href="' . $CFG->wwwroot . '/mod/' . $mod->modname . '/view.php?id=' . $mod->id . '">' . $instancename . '</a>' . $editbuttons;
//Accessibility: incidental image - should be empty Alt text
$this->content->icons[] = '<img src="' . $icon . '" class="icon" alt="" />';
}
}
}
}
if ($ismoving) {
$this->content->items[] = '<a title="' . $strmovefull . '" href="' . $CFG->wwwroot . '/course/mod.php?movetosection=' . $section->id . '&sesskey=' . $USER->sesskey . '">' . '<img style="height:16px; width:80px; border:0px" src="' . $CFG->pixpath . '/movehere.gif" alt="' . $strmovehere . '" /></a>';
$this->content->icons[] = '';
}
if ($isediting && $modnames) {
$this->content->footer = print_section_add_menus($course, 0, $modnames, true, true);
} else {
$this->content->footer = '';
}
return $this->content;
//.........这里部分代码省略.........
示例10: page_frontpage_settings
/**
* Called from {@link page_print_position()} and it is
* supposed to print the front page settings in the
* center column for the site course and only for
* the default page (EG: the landing page).
*
* @return boolean
**/
function page_frontpage_settings()
{
global $CFG, $SESSION, $SITE, $PAGE, $COURSE;
// Cheap check first - course ID
if ($COURSE->id != SITEID) {
return false;
}
// More expensive check - make sure we are viewing default page
$default = page_get_default_page();
$current = $PAGE->get_formatpage();
if (empty($default->id) or empty($current->id) or $default->id != $current->id) {
return false;
}
$editing = $PAGE->user_is_editing();
/// START COPY/PASTE FROM INDEX.PHP
print_container_start();
/// Print Section
if ($SITE->numsections > 0) {
if (!($section = get_record('course_sections', 'course', $SITE->id, 'section', 1))) {
delete_records('course_sections', 'course', $SITE->id, 'section', 1);
// Just in case
$section->course = $SITE->id;
$section->section = 1;
$section->summary = '';
$section->sequence = '';
$section->visible = 1;
$section->id = insert_record('course_sections', $section);
}
if (!empty($section->sequence) or !empty($section->summary) or $editing) {
print_box_start('generalbox sitetopic');
/// If currently moving a file then show the current clipboard
if (ismoving($SITE->id)) {
$stractivityclipboard = strip_tags(get_string('activityclipboard', '', addslashes($USER->activitycopyname)));
echo '<p><font size="2">';
echo "{$stractivityclipboard} (<a href=\"course/mod.php?cancelcopy=true&sesskey={$USER->sesskey}\">" . get_string('cancel') . '</a>)';
echo '</font></p>';
}
$options = NULL;
$options->noclean = true;
echo format_text($section->summary, FORMAT_HTML, $options);
if ($editing) {
$streditsummary = get_string('editsummary');
echo "<a title=\"{$streditsummary}\" " . " href=\"course/editsection.php?id={$section->id}\"><img src=\"{$CFG->pixpath}/t/edit.gif\" " . " class=\"iconsmall\" alt=\"{$streditsummary}\" /></a><br /><br />";
}
get_all_mods($SITE->id, $mods, $modnames, $modnamesplural, $modnamesused);
print_section($SITE, $section, $mods, $modnamesused, true);
if ($editing) {
print_section_add_menus($SITE, $section->section, $modnames);
}
print_box_end();
}
}
if (isloggedin() and !isguest() and isset($CFG->frontpageloggedin)) {
$frontpagelayout = $CFG->frontpageloggedin;
} else {
$frontpagelayout = $CFG->frontpage;
}
foreach (explode(',', $frontpagelayout) as $v) {
switch ($v) {
/// Display the main part of the front page.
case FRONTPAGENEWS:
if ($SITE->newsitems) {
// Print forums only when needed
require_once $CFG->dirroot . '/mod/forum/lib.php';
if (!($newsforum = forum_get_course_forum($SITE->id, 'news'))) {
error('Could not find or create a main news forum for the site');
}
if (!empty($USER->id)) {
$SESSION->fromdiscussion = $CFG->wwwroot;
if (forum_is_subscribed($USER->id, $newsforum)) {
$subtext = get_string('unsubscribe', 'forum');
} else {
$subtext = get_string('subscribe', 'forum');
}
print_heading_block($newsforum->name);
echo '<div class="subscribelink"><a href="mod/forum/subscribe.php?id=' . $newsforum->id . '">' . $subtext . '</a></div>';
} else {
print_heading_block($newsforum->name);
}
forum_print_latest_discussions($SITE, $newsforum, $SITE->newsitems, 'plain', 'p.modified DESC');
}
break;
case FRONTPAGECOURSELIST:
if (isloggedin() and !has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM)) and !isguest() and empty($CFG->disablemycourses)) {
print_heading_block(get_string('mycourses'));
print_my_moodle();
} else {
if (!has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM)) and !isguest() or count_records('course') <= FRONTPAGECOURSELIMIT) {
// admin should not see list of courses when there are too many of them
print_heading_block(get_string('availablecourses'));
print_courses(0);
}
//.........这里部分代码省略.........
示例11: display
function display()
{
global $CFG, $PAGE, $COURSE;
require_capability('moodle/course:manageactivities', $this->context);
get_all_mods($COURSE->id, $mods, $modnames, $modnamesplural, $modnamesused);
// Right now storing modules in a section corresponding to the current
// page - probably should all be section 0 though
if ($COURSE->id == SITEID) {
$section = 1;
// Front page only has section 1 - so use 1 as default
} else {
if (isset($page->id)) {
$section = $page->id;
} else {
$section = 0;
}
}
$PAGE->print_tabs('activities');
print_box_start('boxwidthwide boxaligncenter pageeditingtable', 'editing-table');
print_section_add_menus($COURSE, $section, $modnames);
if (!empty($modnamesused)) {
$modinfo = get_fast_modinfo($COURSE);
$vars = new stdClass();
$vars->delete = get_string("delete");
$vars->update = get_string("update");
$vars->sesskey = sesskey();
foreach ($modnamesused as $module => $modnamestr) {
$orderby = 'i.name';
$fields = 'i.id, i.name, m.name ' . sql_as() . ' module, c.id ' . sql_as() . 'cmid, c.visible';
// Going to be executing SQL that could fail on purpose - avoid debug messages
$debug = $CFG->debug;
// Store current value
$CFG->debug = false;
// disable_debugging() doesn't seem to work
// Check for field named type
if (execute_sql("SELECT type FROM {$CFG->prefix}{$module} WHERE 1 = 2", false)) {
// Has type - incorperate it into the sql
$orderby = "i.type, {$orderby}";
$fields = "{$fields}, i.type";
}
// Restore debug value
$CFG->debug = $debug;
$instances = get_records_sql("SELECT {$fields}\n FROM {$CFG->prefix}course_modules c,\n {$CFG->prefix}modules m,\n {$CFG->prefix}{$module} i\n WHERE i.course = {$COURSE->id}\n AND m.name = '{$module}'\n AND c.instance = i.id\n AND c.module = m.id\n ORDER BY {$orderby}");
if (!empty($instances)) {
$lasttype = '';
print "<h2><a href=\"{$CFG->wwwroot}/mod/{$module}/index.php?id={$COURSE->id}\">{$modnamestr}</a></h2>\n";
print "<ul class=\"activity-list\">\n";
foreach ($instances as $instance) {
if (!empty($instance->type) and $lasttype != $instance->type) {
if (!empty($lasttype)) {
// Switching types and it isn't the first time, close previously opened list
print "</ul>\n</li>\n";
}
// Try to get a name for the type (check module first)
$strtype = get_string($instance->type, $module);
if (strpos($strtype, '[') !== false) {
$strtype = get_string($module . ':' . $instance->type, 'format_page');
}
print "<li><div class=\"plus-minus\"><p><span class=\"no-space\"><strong>{$strtype}</strong></span></p></div>\n<ul>\n";
$lasttype = $instance->type;
}
if (!empty($modinfo->cms[$instance->cmid]->icon)) {
$icon = "{$CFG->pixpath}/" . urldecode($modinfo->cms[$instance->cmid]->icon);
} else {
$icon = "{$CFG->modpixpath}/{$module}/icon.gif";
}
if (empty($instance->visible)) {
$linkclass = ' class="dimmed"';
} else {
$linkclass = '';
}
print '<li>';
print '<img src="' . $icon . '" class="icon" />';
print "<a{$linkclass} href=\"{$CFG->wwwroot}/mod/{$module}/view.php?id={$instance->cmid}\">" . format_string(strip_tags($instance->name), true, $COURSE->id) . '</a> ';
print '<span class="commands">';
print "<a title=\"{$vars->update}\" href=\"{$CFG->wwwroot}/course/mod.php?update={$instance->cmid}&sesskey={$vars->sesskey}\">";
print "<img src=\"{$CFG->pixpath}/t/edit.gif\" class=\"icon-edit\" alt=\"{$vars->update}\" /></a> ";
print "<a title=\"{$vars->delete}\" href=\"{$CFG->wwwroot}/course/format/page/format.php?id={$COURSE->id}&action=deletemod&sesskey={$vars->sesskey}&cmid={$instance->cmid}\">";
print "<img src=\"{$CFG->pixpath}/t/delete.gif\" class=\"icon-edit\" alt=\"{$vars->delete}\" /></a></span>";
print "</li>\n";
}
if (!empty($lasttype)) {
// Close type list since we know it was opened
print "</ul>\n</li>\n";
}
print "</ul>\n";
}
}
} else {
print_box(get_string('noacivitiesfound', 'format_page'));
}
print_box_end();
}
示例12: print_section_add_menus
/**
* If used, this will just call the library function (for now). Replace this with your own to make it
* do what you want.
*
*/
function print_section_add_menus($course, $section, $modnames, $vertical = false, $return = false)
{
return print_section_add_menus($course, $section, $modnames, $vertical, $return);
}
示例13: _make_block_topics
function _make_block_topics()
{
global $OUTPUT, $course, $sections, $editing, $has_cap_update, $has_cap_vishidsect, $mods, $modnames, $modnamesused, $str_edit_summary, $url_pic_edit;
$summaryformatoptions = new stdClass();
$summaryformatoptions->noclean = true;
$summaryformatoptions->overflowdiv = true;
$str_hidden_topic = get_string('hidden_topic', 'format_grid');
if ($editing && $has_cap_update) {
$str_move_up = get_string('moveup');
$str_move_down = get_string('movedown');
$str_topic_hide = get_string('hidefromothers', 'format_grid');
$str_topic_show = get_string('showfromothers', 'format_grid');
$url_pic_move_up = $OUTPUT->pix_url('t/up');
$url_pic_move_down = $OUTPUT->pix_url('t/down');
$url_pic_topic_hide = $OUTPUT->pix_url('i/hide');
$url_pic_topic_show = $OUTPUT->pix_url('i/show');
}
for ($section = 1; $section <= $course->numsections; $section++) {
if (empty($sections[$section])) {
//Section should have been created in the icons section above. If it's empty then its an error.
throw new coding_exception('Error, section ' . $section . ' not found!');
}
$thissection = $sections[$section];
if (!$has_cap_vishidsect && !$thissection->visible && $course->hiddensections) {
continue;
}
$sectionstyle = 'section main';
if (!$thissection->visible) {
$sectionstyle .= ' hidden';
}
$sectionstyle .= ' grid_section';
echo html_writer::start_tag('li', array('id' => 'section-' . $section, 'class' => $sectionstyle));
// Note, 'right side' is BEFORE content.
echo html_writer::tag('div', ' ', array('class' => 'left side'));
echo html_writer::start_tag('div', array('class' => 'right side'));
if ($editing && $has_cap_update) {
// Show the hide/show eye
if ($thissection->visible) {
$op_topic_visible = 'hide';
$str_topic_visible_text = $str_topic_hide;
$url_pic_topic_visible = $url_pic_topic_hide;
} else {
$op_topic_visible = 'show';
$str_topic_visible_text = $str_topic_show;
$url_pic_topic_visible = $url_pic_topic_show;
}
echo html_writer::link(new moodle_url('/course/view.php#section-' . $section, array('id' => $course->id, $op_topic_visible => $section, 'sesskey' => sesskey())), html_writer::empty_tag('img', array('src' => $url_pic_topic_visible, 'class' => 'icon ' . $op_topic_visible, 'alt' => $str_topic_visible_text)), array('title' => $str_topic_visible_text, 'class' => 'editing_showhide'));
// Add a arrow to move section up
if ($section > 1) {
echo _move_section_arrow($section, $course, -1, 'up', $str_move_up, $url_pic_move_up, 'moveup');
}
// Add a arrow to move section down
if ($section < $course->numsections) {
echo _move_section_arrow($section, $course, -1, 'down', $str_move_down, $url_pic_move_down, 'movedown');
}
}
echo html_writer::end_tag('div');
echo html_writer::start_tag('div', array('class' => 'content'));
if ($has_cap_vishidsect || $thissection->visible) {
//if visible
if (!empty($thissection->name)) {
echo format_text($OUTPUT->heading($thissection->name, 3, 'sectionname'), FORMAT_HTML);
}
echo html_writer::start_tag('div', array('class' => 'summary'));
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
$summarytext = file_rewrite_pluginfile_urls($thissection->summary, 'pluginfile.php', $coursecontext->id, 'course', 'section', $thissection->id);
echo format_text($summarytext, FORMAT_HTML, $summaryformatoptions);
if ($editing && $has_cap_update) {
echo html_writer::link(new moodle_url('editsection.php', array('id' => $thissection->id)), html_writer::empty_tag('img', array('src' => $url_pic_edit, 'alt' => $str_edit_summary, 'class' => 'icon edit')), array('title' => $str_edit_summary));
}
echo html_writer::end_tag('div');
print_section($course, $thissection, $mods, $modnamesused);
if ($editing) {
print_section_add_menus($course, $section, $modnames);
}
} else {
$str_title = _get_title($thissection->summary);
echo html_writer::tag('h2', $str_title);
echo html_writer::tag('p', $str_hidden_topic);
}
echo html_writer::end_tag('div');
echo html_writer::end_tag('li');
}
}