本文整理汇总了PHP中admin_get_root函数的典型用法代码示例。如果您正苦于以下问题:PHP admin_get_root函数的具体用法?PHP admin_get_root怎么用?PHP admin_get_root使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了admin_get_root函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_content
/**
* Gets the content for this block
*/
function get_content()
{
global $CFG;
// First check if we have already generated, don't waste cycles
if ($this->contentgenerated === true) {
return $this->content;
}
$this->content = new stdClass();
if (get_user_preferences('admin_bookmarks')) {
require_once $CFG->libdir . '/adminlib.php';
$adminroot = admin_get_root(false, false);
// settings not required - only pages
$bookmarks = explode(',', get_user_preferences('admin_bookmarks'));
/// Accessibility: markup as a list.
$contents = array();
foreach ($bookmarks as $bookmark) {
$temp = $adminroot->locate($bookmark);
if ($temp instanceof admin_settingpage) {
$contenturl = new moodle_url('/admin/settings.php', array('section' => $bookmark));
$contentlink = html_writer::link($contenturl, $temp->visiblename);
$contents[] = html_writer::tag('li', $contentlink);
} else {
if ($temp instanceof admin_externalpage) {
$contenturl = new moodle_url($temp->url);
$contentlink = html_writer::link($contenturl, $temp->visiblename);
$contents[] = html_writer::tag('li', $contentlink);
}
}
}
$this->content->text = html_writer::tag('ol', implode('', $contents), array('class' => 'list'));
} else {
$bookmarks = array();
}
$this->content->footer = '';
$this->page->settingsnav->initialise();
$node = $this->page->settingsnav->get('root', navigation_node::TYPE_SITE_ADMIN);
if (!$node || !$node->contains_active_node()) {
return $this->content;
}
$section = $node->find_active_node()->key;
if ($section == 'search' || empty($section)) {
// the search page can't be properly bookmarked at present
$this->content->footer = '';
} else {
if (in_array($section, $bookmarks)) {
$deleteurl = new moodle_url('/blocks/admin_bookmarks/delete.php', array('section' => $section, 'sesskey' => sesskey()));
$this->content->footer = html_writer::link($deleteurl, get_string('unbookmarkthispage', 'admin'));
} else {
$createurl = new moodle_url('/blocks/admin_bookmarks/create.php', array('section' => $section, 'sesskey' => sesskey()));
$this->content->footer = html_writer::link($createurl, get_string('bookmarkthispage', 'admin'));
}
}
return $this->content;
}
示例2: url_get_path
function url_get_path()
{
global $CFG;
$adminroot = admin_get_root();
$root = $adminroot->locate($this->section);
if (is_a($root, 'admin_externalpage')) {
return $root->url;
} else {
return $CFG->wwwroot . '/' . $CFG->admin . '/settings.php';
}
}
示例3: get_content
function get_content()
{
global $CFG, $USER;
if ($this->content !== NULL) {
return $this->content;
}
$this->content = new stdClass();
$this->content->text = '';
if (get_user_preferences('admin_bookmarks')) {
// this is expensive! Only require when bookmakrs exist..
require_once $CFG->libdir . '/adminlib.php';
$adminroot = admin_get_root(false, false);
// settings not required - only pages
$bookmarks = explode(',', get_user_preferences('admin_bookmarks'));
// hmm... just a liiitle (potentially) processor-intensive
// (recall that $adminroot->locate is a huge recursive call... and we're calling it repeatedly here
/// Accessibility: markup as a list.
$this->content->text .= '<ol class="list">' . "\n";
foreach ($bookmarks as $bookmark) {
$temp = $adminroot->locate($bookmark);
if ($temp instanceof admin_settingpage) {
$this->content->text .= '<li><a href="' . $CFG->wwwroot . '/' . $CFG->admin . '/settings.php?section=' . $bookmark . '">' . $temp->visiblename . "</a></li>\n";
} else {
if ($temp instanceof admin_externalpage) {
$this->content->text .= '<li><a href="' . $temp->url . '">' . $temp->visiblename . "</a></li>\n";
}
}
}
$this->content->text .= "</ol>\n";
} else {
$bookmarks = array();
}
// TODO
if (isset($this->page->section) and $this->page->section == 'search') {
// the search page can't be properly bookmarked at present
$this->content->footer = '';
} else {
if (($section = isset($this->page->section) ? $this->page->section : '') && in_array($section, $bookmarks)) {
$this->content->footer = '<a href="' . $CFG->wwwroot . '/blocks/admin_bookmarks/delete.php?section=' . $section . '&sesskey=' . sesskey() . '">' . get_string('unbookmarkthispage', 'admin') . '</a>';
} else {
if ($section = isset($this->page->section) ? $this->page->section : '') {
$this->content->footer = '<a href="' . $CFG->wwwroot . '/blocks/admin_bookmarks/create.php?section=' . $section . '&sesskey=' . sesskey() . '">' . get_string('bookmarkthispage', 'admin') . '</a>';
} else {
$this->content->footer = '';
}
}
}
return $this->content;
}
示例4: question_type_icon_html
}
} else {
$icons = $OUTPUT->spacer() . ' ';
}
// Move icons.
$icons .= question_type_icon_html('up', $qtypename, 't/up', get_string('up'), '');
$icons .= question_type_icon_html('down', $qtypename, 't/down', get_string('down'), '');
$row[] = $icons;
// Delete link, if available.
if ($needed[$qtypename]) {
$row[] = '';
} else {
$row[] = html_writer::link(new moodle_url($thispageurl, array('delete' => $qtypename, 'sesskey' => sesskey())), get_string('delete'), array('title' => get_string('uninstallqtype', 'question')));
}
// Settings link, if available.
$settings = admin_get_root()->locate('qtypesetting' . $qtypename);
if ($settings instanceof admin_externalpage) {
$row[] = html_writer::link($settings->url, get_string('settings'));
} else {
if ($settings instanceof admin_settingpage) {
$row[] = html_writer::link(new moodle_url('/admin/settings.php', array('section' => 'qtypesetting' . $qtypename)), get_string('settings'));
} else {
$row[] = '';
}
}
$table->add_data($row, $rowclass);
}
$table->finish_output();
echo $OUTPUT->footer();
function question_types_enable_disable_icons($qtypename, $createable)
{
示例5: admin_externalpage_setup
function admin_externalpage_setup($section)
{
global $CFG, $PAGE, $USER;
$adminroot = admin_get_root();
require_once $CFG->libdir . '/blocklib.php';
require_once $CFG->dirroot . '/' . $CFG->admin . '/pagelib.php';
page_map_class(PAGE_ADMIN, 'page_admin');
$PAGE = page_create_object(PAGE_ADMIN, 0);
// there must be any constant id number
$PAGE->init_extra($section);
// hack alert!
$root = $adminroot->locate($PAGE->section);
if ($site = get_site()) {
require_login();
} else {
redirect($CFG->wwwroot . '/' . $CFG->admin . '/index.php');
die;
}
if (!is_a($root, 'admin_externalpage')) {
error(get_string('sectionerror', 'admin'));
die;
}
// this eliminates our need to authenticate on the actual pages
if (!$root->check_access()) {
error(get_string('accessdenied', 'admin'));
die;
}
$adminediting = optional_param('adminedit', -1, PARAM_BOOL);
if (!isset($USER->adminediting)) {
$USER->adminediting = false;
}
if ($PAGE->user_allowed_editing()) {
if ($adminediting == 1) {
$USER->adminediting = true;
} elseif ($adminediting == 0) {
$USER->adminediting = false;
}
}
}
示例6: unset_config
// probably new installation - lets return to frontpage after this step
// remove settings that we want uninitialised
unset_config('registerauth');
redirect('upgradesettings.php?return=site');
}
/// Check if we are returning from moodle.org registration and if so, we mark that fact to remove reminders
if (!empty($id)) {
if ($id == $CFG->siteidentifier) {
set_config('registered', time());
}
}
/// setup critical warnings before printing admin tree block
$insecuredataroot = is_dataroot_insecure(true);
$register_globals_enabled = ini_get_bool('register_globals');
$SESSION->admin_critical_warning = $register_globals_enabled || $insecuredataroot == INSECURE_DATAROOT_ERROR;
$adminroot =& admin_get_root();
/// Check if there are any new admin settings which have still yet to be set
if (any_new_admin_settings($adminroot)) {
redirect('upgradesettings.php');
}
/// Everything should now be set up, and the user is an admin
/// Print default admin page with notifications.
admin_externalpage_setup('adminnotifications');
admin_externalpage_print_header();
/// Deprecated database! Warning!!
if (!empty($CFG->migrated_to_new_db)) {
print_box(print_string('dbmigrationdeprecateddb', 'admin'), 'generalbox adminwarning');
}
/// Check for any special upgrades that might need to be run
if (!empty($CFG->upgrade)) {
print_box(get_string("upgrade{$CFG->upgrade}", "admin", "{$CFG->wwwroot}/{$CFG->admin}/upgrade{$CFG->upgrade}.php"));
示例7: get_site
// check that site is properly customized
$site = get_site();
if (empty($site->shortname)) {
// probably new installation - lets return to frontpage after this step
// remove settings that we want uninitialised
unset_config('registerauth');
redirect('upgradesettings.php?return=site');
}
// Check if we are returning from moodle.org registration and if so, we mark that fact to remove reminders
if (!empty($id) and $id == $CFG->siteidentifier) {
set_config('registered', time());
}
// setup critical warnings before printing admin tree block
$insecuredataroot = is_dataroot_insecure(true);
$SESSION->admin_critical_warning = $insecuredataroot == INSECURE_DATAROOT_ERROR;
$adminroot = admin_get_root();
// Check if there are any new admin settings which have still yet to be set
if (any_new_admin_settings($adminroot)) {
redirect('upgradesettings.php');
}
// Everything should now be set up, and the user is an admin
// Print default admin page with notifications.
$errorsdisplayed = defined('WARN_DISPLAY_ERRORS_ENABLED');
$lastcron = $DB->get_field_sql('SELECT MAX(lastcron) FROM {modules}');
$cronoverdue = $lastcron < time() - 3600 * 24;
$dbproblems = $DB->diagnose();
$maintenancemode = !empty($CFG->maintenance_enabled);
$updateschecker = available_update_checker::instance();
$availableupdates = $updateschecker->get_update_info('core', array('minmaturity' => $CFG->updateminmaturity, 'notifybuilds' => $CFG->updatenotifybuilds));
$availableupdatesfetch = $updateschecker->get_last_timefetched();
admin_externalpage_setup('adminnotifications');
示例8: get_string
if ($data = data_submitted() and confirm_sesskey()) {
if (admin_write_settings($data)) {
$statusmsg = get_string('changessaved');
}
if (empty($adminroot->errors)) {
switch ($return) {
case 'site':
redirect("{$CFG->wwwroot}/");
case 'admin':
redirect("{$CFG->wwwroot}/{$CFG->admin}/");
}
} else {
$errormsg = get_string('errorwithsettings', 'admin');
$firsterror = reset($adminroot->errors);
}
$adminroot = admin_get_root(true);
//reload tree
$settingspage = $adminroot->locate($section, true);
}
if ($PAGE->user_allowed_editing() && $adminediting != -1) {
$USER->editing = $adminediting;
}
/// print header stuff ------------------------------------------------------------
if (empty($SITE->fullname)) {
$PAGE->set_title($settingspage->visiblename);
$PAGE->set_heading($settingspage->visiblename);
echo $OUTPUT->header();
echo $OUTPUT->box(get_string('configintrosite', 'admin'));
if ($errormsg !== '') {
echo $OUTPUT->notification($errormsg);
} else {
示例9: get_content
function get_content()
{
global $CFG;
if ($this->content !== NULL) {
return $this->content;
}
if (isguestuser() or !isloggedin()) {
// these users can not change any settings
$this->content = '';
return '';
}
require_once $CFG->libdir . '/adminlib.php';
$adminroot =& admin_get_root(false, false);
// settings not required - only pages
if ($current = $adminroot->locate($this->section, true)) {
$this->pathtosection = $current->path;
array_pop($this->pathtosection);
}
// we need to do this instead of $this->build_tree($adminroot) because the top-level folder
// is redundant (and ideally ignored). (the top-level folder is "administration".)
$entries = array_keys($adminroot->children);
asort($entries);
foreach ($entries as $entry) {
$this->build_tree($adminroot->children[$entry]);
}
if ($this->tempcontent !== '') {
$closedimg = '<img src="' . $CFG->pixpath . '/i/closed.gif" alt="' . s(get_string('folderclosed')) . '" />';
$openedimg = '<img src="' . $CFG->pixpath . '/i/open.gif" alt="' . s(get_string('folderopened')) . '" />';
$this->content = new object();
$this->content->text = '
<script type="text/javascript">
//<![CDATA[
var vh_numdivs = ' . ($this->divcounter - 1) . ';
var parkplatz = new Array();
for (var i=1; i<=vh_numdivs; i++) {
parkplatz[i] = null;
}
function menu_toggle(i) {
i = parseInt(i);
if (parkplatz[i] === null) {
collapse(i);
} else {
expand(i);
}
}
function collapse(i) {
if (parkplatz[i] !== null) {
return;
}
var obj = document.getElementById("vh_div"+String(i));
if (obj === null) {
return;
}
var nothing = document.createElement("span");
nothing.setAttribute("id", "vh_div"+String(i));
parkplatz[i] = obj;
obj.parentNode.replaceChild(nothing, obj);
var icon = document.getElementById("vh_div"+String(i)+"indicator");
icon.innerHTML = "' . addslashes_js($closedimg) . '";
}
function expand(i) {
if (parkplatz[i] === null) {
return;
}
var nothing = document.getElementById("vh_div"+String(i));
var obj = parkplatz[i];
parkplatz[i] = null;
nothing.parentNode.replaceChild(obj, nothing);
var icon = document.getElementById("vh_div"+String(i)+"indicator");
icon.innerHTML = "' . addslashes_js($openedimg) . '";
}
function expandall() {
for (i=1; i<=vh_numdivs; i++) {
expand(i);
}
}
function collapseall() {
for (var i=vh_numdivs; i>0; i--) {
collapse(i);
}
}
//]]>
</script>
<div class="admintree">
' . $this->tempcontent . '
</div>
<script type="text/javascript">
//<![CDATA[
collapseall();
' . $this->expandjavascript . ';
//]]>
</script>';
//.........这里部分代码省略.........
示例10: stdClass
} else {
$plugin = new stdClass();
$plugin->version = '???';
if (file_exists("{$CFG->dirroot}/blocks/{$blockname}/version.php")) {
include "{$CFG->dirroot}/blocks/{$blockname}/version.php";
}
if (!($blockobject = block_instance($block->name))) {
$incompatible[] = $block;
continue;
}
}
$delete = '<a href="blocks.php?delete=' . $blockid . '&sesskey=' . sesskey() . '">' . $strdelete . '</a>';
$settings = '';
// By default, no configuration
if ($blockobject and $blockobject->has_config()) {
$blocksettings = admin_get_root()->locate('blocksetting' . $block->name);
if ($blocksettings instanceof admin_externalpage) {
$settings = '<a href="' . $blocksettings->url . '">' . get_string('settings') . '</a>';
} else {
if ($blocksettings instanceof admin_settingpage) {
$settings = '<a href="' . $CFG->wwwroot . '/' . $CFG->admin . '/settings.php?section=blocksetting' . $block->name . '">' . $strsettings . '</a>';
} else {
$settings = '<a href="block.php?block=' . $blockid . '">' . $strsettings . '</a>';
}
}
}
// MDL-11167, blocks can be placed on mymoodle, or the blogs page
// and it should not show up on course search page
$totalcount = $DB->count_records('block_instances', array('blockname' => $blockname));
$count = $DB->count_records('block_instances', array('blockname' => $blockname, 'pagetypepattern' => 'course-view-*'));
if ($count > 0) {
示例11: settings_to_php
/**
* Gets a string with PHP code to inject default values to the upgrade processes
*
* @todo Try to respect DRY and unify part of package_ingredients with settings_to_php
* @uses flavours_php_writer
* @param array $selectedsettings
* @returns array PHP code, one line per array element, the caller will make a string or a file
*/
public function settings_to_php($selectedsettings)
{
$phparray = array();
$adminroot = admin_get_root();
$this->get_branch_settings($adminroot->children, $this, true);
foreach ($selectedsettings as $settingspage) {
// Settings page path
$namespace = explode('/', $settingspage);
// The admin settingspage is the last one
$page = array_pop($namespace);
if (!($settings = $this->get_settingspage_settings($namespace, $page, $this))) {
continue;
}
$settingspagetagname = str_replace('/', '.', $settingspage);
// Adding settings
foreach ($settings as $setting) {
// Can\'t refactor the whole 'core' code to 'moodle' to maintain
// backward compatibility with flavours packages
if ($setting->plugin == 'core') {
$setting->plugin = 'moodle';
}
// Restore slashes
$setting->plugin = str_replace('.', '/', $setting->plugin);
// Valu with addslashes only in the single qoute
$value = $this->get_setting_value($setting->name, $setting->plugin);
$value = str_replace("'", "\\'", $value);
$phparray[] = $this->add_setting_php($setting->plugin, $setting->name, $value);
// Adding the extra values of the setting (if present) to the attributes array
if (!empty($setting->attrs)) {
foreach ($setting->attrs as $attrname => $value) {
$phparray[] = $this->add_setting_php($setting->plugin, $attrname, $value);
}
}
}
}
return $phparray;
}
示例12: get_content
function get_content()
{
global $CFG;
if ($this->content !== NULL) {
return $this->content;
}
if (isguestuser() or !isloggedin()) {
// these users can not change any settings
$this->content = '';
return '';
}
require_once $CFG->libdir . '/adminlib.php';
$adminroot = admin_get_root(false, false);
// settings not required - only pages
if ($current = $adminroot->locate($this->section, true)) {
$this->pathtosection = $current->path;
array_pop($this->pathtosection);
}
// we need to do this instead of $this->build_tree($adminroot) because the top-level folder
// is redundant (and ideally ignored). (the top-level folder is "administration".)
$entries = array_keys($adminroot->children);
asort($entries);
foreach ($entries as $entry) {
$this->build_tree($adminroot->children[$entry]);
}
if ($this->tempcontent !== '') {
require_js(array('yui_yahoo', 'yui_event'));
require_js('blocks/admin_tree/admintree.js');
$this->content = new object();
$this->content->text = '<div class="admintree">' . $this->tempcontent . "</div>\n";
$this->content->text .= print_js_call('admin_tree.init', array($this->divcounter - 1, $this->expandnodes, $CFG->pixpath, get_string('folderopened'), get_string('folderclosed')), true);
// only do search if you have moodle/site:config
if (has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM))) {
$this->content->footer = '<div class="adminsearchform">' . '<form action="' . $CFG->wwwroot . '/' . $CFG->admin . '/search.php" method="get"><div>' . '<label for="query" class="accesshide">' . get_string('searchinsettings', 'admin') . '</label>' . '<input type="text" name="query" id="query" size="8" value="' . s($adminroot->search) . '" />' . '<input type="submit" value="' . get_string('search') . '" /></div>' . '</form></div>';
} else {
$this->content->footer = '';
}
} else {
$this->content = new object();
$this->content->text = '';
}
return $this->content;
}
示例13: upgrade_group_db
function upgrade_group_db($continueto)
{
/// This function upgrades the group tables, if necessary
/// It's called from admin/index.php.
global $CFG, $db;
$group_version = '';
// Get code versions
require "{$CFG->dirroot}/group/version.php";
if (empty($CFG->group_version)) {
// New 1.8 groups have never been installed...
$strdatabaseupgrades = get_string('databaseupgrades');
print_header($strdatabaseupgrades, $strdatabaseupgrades, $strdatabaseupgrades, '', upgrade_get_javascript(), false, " ", " ");
upgrade_log_start();
//initialize default group settings now
install_group_db();
$adminroot = admin_get_root();
print_continue($continueto);
print_footer('none');
exit;
}
/// Upgrading code starts here
if ($group_version > $CFG->group_version) {
// Upgrade tables
$strdatabaseupgrades = get_string('databaseupgrades');
print_header($strdatabaseupgrades, $strdatabaseupgrades, $strdatabaseupgrades, '', upgrade_get_javascript());
upgrade_log_start();
print_heading('group');
$db->debug = true;
$status = xmldb_group_upgrade($CFG->group_version);
$db->debug = false;
/// Now analyze upgrade results
if ($status) {
// No upgrading failed
if (set_config('group_version', $group_version)) {
notify(get_string('databasesuccess'), 'green');
notify(get_string('databaseupgradegroups', '', $group_version), 'green');
print_continue($continueto);
print_footer('none');
exit;
} else {
error("Error: Upgrade of group system failed! (Could not update version in config table)");
}
} else {
error("Error: Upgrade failed! See group/upgrade.php");
}
} else {
if ($group_version < $CFG->group_version) {
error("Error: The code you are using is OLDER than the version that made these databases!");
}
}
}
示例14: get_content
/**
* Gets the content for this block
*/
function get_content()
{
global $CFG, $PAGE;
// First check if we have already generated, don't waste cycles
if ($this->contentgenerated === true) {
return $this->content;
}
$this->content = new stdClass();
if (get_user_preferences('user_bookmarks')) {
require_once $CFG->libdir . '/adminlib.php';
$adminroot = admin_get_root(false, false);
// settings not required - only pages
$tempbookmarks = explode(',', get_user_preferences('user_bookmarks'));
/// Accessibility: markup as a list.
$contents = array();
foreach ($tempbookmarks as $bookmark) {
//the bookmarks are in the following format- url;title
//so exploading the bookmark by ";" to get the url and title
$tempBookmark = explode(';', $bookmark);
//making the url for bookmark
$contenturl = new moodle_url($CFG->wwwroot . $tempBookmark[0]);
//now making a link
$contentlink = html_writer::link($contenturl, $tempBookmark[1]);
//this is the url to delete bookmark
$bookmarkdeleteurl = new moodle_url('/blocks/user_bookmarks/delete.php', array('bookmarkurl' => $tempBookmark[0], 'sesskey' => sesskey()));
//this has the link to delete the bookmark
$deleteLink = "<a href='{$bookmarkdeleteurl}'><img alt='Delete Bookmark' title='Delete Bookmark' src='{$CFG->wwwroot}/blocks/user_bookmarks/pix/delete.gif'></a>";
//creating the link to update the title for bookmark
$editLink = '<script type="text/javascript">
function updateBookmark(bookmarkURL, defaultTitle, sesskey, wwwroot) {
var newBookmarkTitle = prompt(\'Edit Bookmark title\',defaultTitle);
if (newBookmarkTitle == "" || newBookmarkTitle == null) {
newBookmarkTitle = defaultTitle;
}else {
var redirectPage = wwwroot + "/blocks/user_bookmarks/update.php?bookmarkurl=" + escape(bookmarkURL) + "&title=" + escape(newBookmarkTitle) + "&sesskey=" + sesskey;
window.location = redirectPage;
}
}
</script>
<a style="cursor: pointer;" onClick="updateBookmark(\'' . $tempBookmark[0] . '\', \'' . $tempBookmark[1] . '\', \'' . sesskey() . '\', \'' . $CFG->wwwroot . '\');">
<img alt="Delete Bookmark" title="Delete Bookmark" src="' . $CFG->wwwroot . '/blocks/user_bookmarks/pix/edit.gif">
</a>';
//setting layout for the bookmark and its delete and edit buttons
$contents[] = html_writer::tag('li', $contentlink . " " . $editLink . " " . $deleteLink);
$bookmarks[] = htmlspecialchars_decode($tempBookmark[0]);
}
$this->content->text = html_writer::tag('ol', implode('', $contents), array('class' => 'list'));
} else {
$bookmarks = array();
}
$this->content->footer = '';
$this->page->settingsnav->initialise();
$node = $this->page->settingsnav->get('root', navigation_node::TYPE_SETTING);
$bookmarkurl = htmlspecialchars_decode(str_replace($CFG->wwwroot, '', $PAGE->url));
$bookmarktitle = $PAGE->title;
if (in_array($bookmarkurl, $bookmarks)) {
//this prints out the link to unbookmark a page
$this->content->footer = '<script type="text/javascript">
function deleteBookmark(bookmarkURL, sesskey, wwwroot) {
var redirectPage = wwwroot + "/blocks/user_bookmarks/delete.php?bookmarkurl=" + escape(bookmarkURL) + "&sesskey=" + sesskey;
window.location = redirectPage;
}
</script>
<form style="cursor: hand;">
<a style="cursor: pointer;" onClick="deleteBookmark(\'' . $bookmarkurl . '\', \'' . sesskey() . '\', \'' . $CFG->wwwroot . '\');">Unbookmark this page</a>
</form>';
} else {
//this prints out link to bookmark a page
$this->content->footer = '<script type="text/javascript">
function addBookmark(bookmarkURL, defaultTitle, sesskey, wwwroot) {
var newBookmarkTitle = prompt(\'Enter a title for the Bookmark\',defaultTitle);
if (newBookmarkTitle == "" || newBookmarkTitle == null) {
newBookmarkTitle = defaultTitle;
} else {
var redirectPage = wwwroot + "/blocks/user_bookmarks/create.php?bookmarkurl=" + escape(bookmarkURL) + "&title=" + newBookmarkTitle + "&sesskey=" + sesskey;
window.location = redirectPage;
}
}
</script>
<form>
<a style="cursor: pointer;" onClick="addBookmark(\'' . $bookmarkurl . '\', \'' . $bookmarktitle . '\', \'' . sesskey() . '\', \'' . $CFG->wwwroot . '\');">bookmark this page</a>
</form>';
}
return $this->content;
}
示例15: output_new_settings_by_page
// page is loaded (i.e. both when we're displaying the form and then when we process the form's input).
// if the return values don't match, we could potentially lose changes that the admin is making.
$newsettingshtml = output_new_settings_by_page(admin_get_root());
// first we deal with the case where there are no new settings to be set
if ($newsettingshtml == '') {
if ($return == 'site') {
redirect("{$CFG->wwwroot}/");
} else {
redirect("{$CFG->wwwroot}/{$CFG->admin}/index.php");
}
}
// now we'll deal with the case that the admin has submitted the form with new settings
if ($data = data_submitted()) {
$unslashed = (array) stripslashes_recursive($data);
if (confirm_sesskey()) {
$newsettings = find_new_settings(admin_get_root());
$errors = '';
foreach ($newsettings as $newsetting) {
if (isset($unslashed['s_' . $newsetting->name])) {
$errors .= $newsetting->write_setting($unslashed['s_' . $newsetting->name]);
} else {
$errors .= $newsetting->write_setting($newsetting->defaultsetting);
}
}
if (empty($errors)) {
// there must be either redirect without message or continue button or else upgrade would be sometimes broken
if ($return == 'site') {
redirect("{$CFG->wwwroot}/");
} else {
redirect("{$CFG->wwwroot}/{$CFG->admin}/index.php");
}