function authcache_menu_preprocess_page in Authenticated User Page Caching (Authcache) 7.2
Implements hook_preprocess_page().
Personalize tabs and action links if necessary.
File
- modules/
authcache_menu/ authcache_menu.module, line 96 - Authcache support for menu, tabs and local actions.
Code
function authcache_menu_preprocess_page(&$variables) {
if (authcache_page_is_cacheable()) {
drupal_add_js(drupal_get_path('module', 'authcache_menu') . '/authcache_menu.js');
$router_item = menu_get_item();
if (!authcache_element_is_cacheable($variables['tabs'])) {
$tab_blacklist = authcache_menu_tab_root_blacklist(MENU_IS_LOCAL_TASK);
if (!empty($router_item['tab_root']) && !empty($tab_blacklist[$router_item['tab_root']])) {
authcache_p13n_attach($variables['tabs'], array(
'#theme' => 'authcache_p13n_fragment',
'#fragment' => 'menu-local-tabs',
'#fallback' => 'cancel',
));
}
authcache_element_set_cacheable($variables['tabs']);
}
if (!authcache_element_is_cacheable($variables['action_links'])) {
$action_blacklist = authcache_menu_tab_root_blacklist(MENU_IS_LOCAL_ACTION);
if (!empty($router_item['tab_root']) && !empty($action_blacklist[$router_item['tab_root']])) {
authcache_p13n_attach($variables['action_links'], array(
'#theme' => 'authcache_p13n_fragment',
'#fragment' => 'menu-local-actions',
'#fallback' => 'cancel',
));
}
authcache_element_set_cacheable($variables['action_links']);
}
if (!empty($variables['main_menu'])) {
foreach ($variables['main_menu'] as &$link) {
_authcache_menu_substitute_menu_link($link);
}
}
if (!empty($variables['secondary_menu'])) {
foreach ($variables['secondary_menu'] as &$link) {
_authcache_menu_substitute_menu_link($link);
}
}
}
}