Newer
Older

Dries Buytaert
committed
rsort($masks);
if ($save) {
$path_roots = array_values($path_roots);
// Update the path roots variable and reset the path alias whitelist cache
// if the list has changed.
if ($path_roots != \Drupal::state()->get('menu_path_roots')) {
\Drupal::state()->set('menu_path_roots', array_values($path_roots));

Angie Byron
committed
\Drupal::service('path.alias_manager')->cacheClear();
}
_menu_router_save($menu, $masks);
}

Dries Buytaert
committed
return array($menu, $masks);
}
/**

Jennifer Hodgdon
committed
* Saves data from menu_router_build() to the router table.

Dries Buytaert
committed
*/
function _menu_router_save($menu, $masks) {
// Delete the existing router since we have some data to replace it.
db_truncate('menu_router')->execute();

Dries Buytaert
committed

Dries Buytaert
committed
// Prepare insert object.
$insert = db_insert('menu_router')
->fields(array(
'path',
'load_functions',
'to_arg_functions',
'access_callback',
'access_arguments',
'page_callback',
'page_arguments',
'fit',
'number_parts',

Angie Byron
committed
'context',

Dries Buytaert
committed
'tab_parent',
'tab_root',
'title',
'title_callback',
'title_arguments',
'type',
'description',

catch
committed
'description_callback',
'description_arguments',

Dries Buytaert
committed
'position',
'weight',

Dries Buytaert
committed
'include_file',

Angie Byron
committed
'route_name',

Dries Buytaert
committed
));
$num_records = 0;
foreach ($menu as $item) {

Dries Buytaert
committed
// Fill in insert object values.
$insert->values(array(
'path' => $item['path'],
'load_functions' => $item['load_functions'],
'to_arg_functions' => $item['to_arg_functions'],
'access_callback' => $item['access callback'],
'access_arguments' => serialize($item['access arguments']),
'page_callback' => $item['page callback'],
'page_arguments' => serialize($item['page arguments']),
'fit' => $item['_fit'],
'number_parts' => $item['_number_parts'],

Angie Byron
committed
'context' => $item['context'],

Dries Buytaert
committed
'tab_parent' => $item['tab_parent'],
'tab_root' => $item['tab_root'],
'title' => $item['title'],
'title_callback' => $item['title callback'],
'title_arguments' => ($item['title arguments'] ? serialize($item['title arguments']) : ''),
'type' => $item['type'],
'description' => $item['description'],

catch
committed
'description_callback' => $item['description callback'],
'description_arguments' => ($item['description arguments'] ? serialize($item['description arguments']) : ''),

Dries Buytaert
committed
'position' => $item['position'],
'weight' => $item['weight'],

Dries Buytaert
committed
'include_file' => $item['include file'],

Angie Byron
committed
'route_name' => $item['route_name'],

Dries Buytaert
committed
));
// Execute in batches to avoid the memory overhead of all of those records
// in the query object.
if (++$num_records == 20) {
$insert->execute();
$num_records = 0;
}

Dries Buytaert
committed
}
// Insert any remaining records.

Dries Buytaert
committed
$insert->execute();

Dries Buytaert
committed
// Store the masks.
\Drupal::state()->set('menu.masks', $masks);

Dries Buytaert
committed
return $menu;
}
* Checks whether the site is in maintenance mode.

Gábor Hojtsy
committed
*
* This function will log the current user out and redirect to front page
* if the current user has no 'access site in maintenance mode' permission.

Gábor Hojtsy
committed
*

Dries Buytaert
committed
* @param $check_only
* If this is set to TRUE, the function will perform the access checks and
* return the site offline status, but not log the user out or display any
* messages.

Dries Buytaert
committed
*

Gábor Hojtsy
committed
* @return
* FALSE if the site is not in maintenance mode, the user login page is
* displayed, or the user has the 'access site in maintenance mode'
* permission. TRUE for anonymous users not being on the login page when the
* site is in maintenance mode.

Dries Buytaert
committed
function _menu_site_is_offline($check_only = FALSE) {
// Check if site is in maintenance mode.
if (\Drupal::state()->get('system.maintenance_mode')) {
if (user_access('access site in maintenance mode')) {
// Ensure that the maintenance mode message is displayed only once
// (allowing for page redirects) and specifically suppress its display on
// the maintenance mode settings page.

Dries Buytaert
committed
if (!$check_only && current_path() != 'admin/config/development/maintenance') {
if (user_access('administer site configuration')) {
drupal_set_message(t('Operating in maintenance mode. <a href="@url">Go online.</a>', array('@url' => url('admin/config/development/maintenance'))), 'status', FALSE);
}
else {
drupal_set_message(t('Operating in maintenance mode.'), 'status', FALSE);
}

Dries Buytaert
committed
}

Gábor Hojtsy
committed
}
else {

Angie Byron
committed
return TRUE;
}
}
return FALSE;
}

Gábor Hojtsy
committed
/**
* @} End of "defgroup menu".
*/