function _boost_get_menu_router in Boost 6
Same name and namespace in other branches
- 7 boost.module \_boost_get_menu_router()
Gets menu router contex
Allows for any content type to have its own cache expiration among other things.
$GLOBALS['_boost_router_item'] gets set in this function
Parameters
$path: Internal path
$get_array: $_GET
$reset: Reset static variable
Return value
array Important keys to return 'page_callback' 'page_type' 'page_id' 'page_number'
10 calls to _boost_get_menu_router()
- boost_block in ./
boost.module - Implementation of hook_block().
- boost_block_db_rm_settings_form_submit in ./
boost.module - Removes page specific settings in the boost cache database.
- boost_block_db_settings_form in ./
boost.module - boost_block_flush_form in ./
boost.module - boost_cache_set in ./
boost.module - Replaces/Sets the cached contents of the specified page, if stale.
File
- ./
boost.module, line 5177 - Provides static file caching for Drupal text output. Pages, Feeds, ect...
Code
function _boost_get_menu_router($path = NULL, $get_array = NULL, $reset = FALSE) {
// Store result in static
static $menu_router = array();
if ($reset) {
$menu_router = array();
}
if ($get_array === NULL) {
$get_array = $_GET;
}
// Get query string & page number
$query = array();
$page = 0;
foreach ($get_array as $key => $val) {
if ($key != 'q' && $key != 'destination' && $key != 'page' && !empty($val)) {
$query[$key] = $val;
}
if ($key == 'page' && is_numeric($val)) {
$page = $val;
}
}
$query = str_replace('&', '&', urldecode(http_build_query($query)));
// Static Index
$index = $path ? $path . $query : 0 . $query;
if (!empty($menu_router[$index])) {
return $menu_router[$index];
}
$router_item = array();
// Load the menu item
$item = menu_get_item($path);
if (is_array($item)) {
$router_item = $item;
}
// Declare default array keys if not done.
$router_item['page_callback'] = empty($router_item['page_callback']) ? '' : $router_item['page_callback'];
$router_item['page_type'] = empty($router_item['page_type']) ? '' : $router_item['page_type'];
$router_item['page_id'] = empty($router_item['page_id']) ? '' : $router_item['page_id'];
// Get all args
$args = arg($path);
// Prevent array warnings
$args[0] = empty($args[0]) ? '' : $args[0];
$args[1] = empty($args[1]) ? '' : $args[1];
$args[2] = empty($args[2]) ? '' : $args[2];
$router_item['args'] = $args;
// Get extra arguments
$menu_args = arg(NULL, $router_item['path']);
$diff = array();
foreach ($args as $key => $value) {
if (!empty($value) && !empty($menu_args[$key]) && $value !== $menu_args[$key] && $menu_args[$key] !== '%') {
$diff[] = $value;
}
}
if (!empty($diff)) {
$router_item['extra_arguments'] = implode('/', $diff);
}
else {
$router_item['extra_arguments'] = '';
}
$router_item['query'] = $query;
$router_item['page_number'] = $page;
// Make sure page arguments is set and is an array
// Needed if view throws a 403
if (!is_array($router_item['page_arguments'])) {
$router_item['page_arguments'] = array(
$router_item['page_arguments'],
);
}
// Make sure function for menu callback is loaded.
// See menu_execute_active_handler()
if ($router_item['file']) {
require_once $router_item['file'];
}
// Invoke hook_boost_menu_router($router_item)
$modules = module_implements('boost_menu_router');
// Make boosts built in hook the last one.
$pos = array_search('boost', $modules);
if ($pos !== FALSE) {
$temp = $modules[$pos];
unset($modules[$pos]);
$modules[] = $temp;
}
foreach ($modules as $module) {
if (($result = module_invoke($module, 'boost_menu_router', $router_item)) !== NULL) {
$menu_router[$index] = $result;
if ($path === NULL) {
$GLOBALS['_boost_router_item'] = $menu_router[$index];
}
return $menu_router[$index];
}
}
}