/** * Prints the "Back to X" where is is the name * of a page format page. * * @return void **/ function page_theme_print_backto_button() { global $CFG, $SESSION, $COURSE; if (page_theme_config('page_backtobutton')) { if (isset($COURSE->format) and $COURSE->format == 'page') { $url = qualified_me(); $url = strip_querystring($url); // URLs where the format could be displayed $locations = array($CFG->wwwroot, $CFG->wwwroot . '/', $CFG->wwwroot . '/index.php', $CFG->wwwroot . '/course/view.php', $CFG->wwwroot . '/course/format/page/format.php'); // See if we aren't on a course format page already if (!in_array($url, $locations)) { require_once $CFG->dirroot . '/course/format/page/lib.php'; // Make sure we have a page to go to if ($page = page_get_current_page($COURSE->id)) { echo '<p><span class="button"><a href="' . $CFG->wwwroot . '/course/view.php?id=' . $page->courseid . '&page=' . $page->id . '">' . get_string('backtopage', 'theme_page', page_get_name($page)) . '</a></span></p>'; } } } } }
/** * Prints or returns the code for the "Back to X" where is is the name * of a page format page. * * @return void **/ function page_theme_print_backto_button($return = false) { global $CFG, $SESSION, $COURSE; if (page_theme_config('page_backtobutton')) { if ($COURSE->format == 'page') { $url = qualified_me(); $url = strip_querystring($url); // URLs where the format could be displayed $locations = array($CFG->wwwroot, $CFG->wwwroot . '/', $CFG->wwwroot . '/index.php', $CFG->wwwroot . '/course/view.php', $CFG->wwwroot . '/course/format/page/format.php'); // See if we aren't on a course format page already if (!in_array($url, $locations)) { require_once $CFG->dirroot . '/course/format/page/lib.php'; // Make sure we have a page to go to if ($page = page_get_current_page($COURSE->id)) { if ($COURSE->id == SITEID) { $baseurl = $CFG->wwwroot . '/index.php'; } else { $baseurl = "{$CFG->wwwroot}/course/view.php"; } $output = print_single_button($baseurl, array('id' => $page->courseid, 'page' => $page->id), get_string('backtopage', 'format_page', page_get_name($page)), 'get', '_self', true); if ($return) { return $output; } print $output; } } } } }