function mmenu_list in Mobile sliding menu 7.3
Same name and namespace in other branches
- 8 mmenu.module \mmenu_list()
- 7 mmenu.module \mmenu_list()
- 7.2 mmenu.module \mmenu_list()
Gets a list of available mmenus.
Parameters
string $mmenu_name: A mmenu name if you just want to get a particular mmenu. Leaves empty if you want to get all available mmenus.
Return value
array Particular mmenu if the 'mmenu_name' is given. All available mmenus otherwise.
3 calls to mmenu_list()
- mmenu_admin_settings_form in ./
mmenu.admin.inc - Form constructor for the Mmenu settings form.
- mmenu_menu in ./
mmenu.module - Implements hook_menu().
- mmenu_page_build in ./
mmenu.module - Implements hook_page_build().
File
- ./
mmenu.module, line 630 - Primarily Drupal hooks and global API functions to manipulate mmenus.
Code
function mmenu_list($mmenu_name = '') {
// Gets mmenus from cache if available.
if ($cached = cache_get('mmenus', 'cache')) {
$mmenus = $cached->data;
// Invoke hook_mmenu_alter().
// To allow all modules to alter the mmenus.
// Don't save the altered values into cache.
drupal_alter('mmenu', $mmenus);
if (empty($mmenu_name)) {
return $mmenus;
}
elseif (isset($mmenus[$mmenu_name])) {
return $mmenus[$mmenu_name];
}
else {
return array();
}
}
// Gets mmenus from hook defined.
$mmenus = module_invoke_all('mmenu');
// Gets the default options and configurations.
$default_options = mmenu_get_default_options();
$default_configurations = mmenu_get_default_configurations();
$default_mmenu = array(
'enabled' => FALSE,
'name' => '',
'title' => '',
'blocks' => array(),
'options' => array(),
'configurations' => array(),
'custom' => array(),
);
foreach ($mmenus as $mmenu_key => $mmenu) {
$mmenu += $default_mmenu;
// Merges with the default values.
$mmenu['options'] += $default_options;
// Merges with the default values.
$mmenu['configurations'] += $default_configurations;
// Takes mmenu settings from user self defined if available.
$configurable_mmenu = variable_get('mmenu_item_' . $mmenu['name'], '');
if (!empty($configurable_mmenu)) {
if (!isset($configurable_mmenu['options'])) {
$configurable_mmenu['options'] = array();
}
if (!isset($configurable_mmenu['configurations'])) {
$configurable_mmenu['configurations'] = array();
}
if (!isset($configurable_mmenu['custom'])) {
$configurable_mmenu['custom'] = array();
}
$mmenu = $configurable_mmenu + $mmenu;
$mmenu['options'] = $configurable_mmenu['options'] + $mmenu['options'];
$mmenu['configurations'] = $configurable_mmenu['configurations'] + $mmenu['configurations'];
$mmenu['custom'] = $configurable_mmenu['custom'] + $mmenu['custom'];
}
$mmenus[$mmenu_key] = $mmenu;
// Resets blocks values.
foreach ($mmenu['blocks'] as $block_key => $block) {
$mmenus[$mmenu_key]['blocks'][$block_key]['collapsed'] = isset($block['collapsed']) ? $block['collapsed'] : TRUE;
$mmenus[$mmenu_key]['blocks'][$block_key]['wrap'] = isset($block['wrap']) ? $block['wrap'] : FALSE;
}
}
// Caches the mmenus.
cache_set('mmenus', $mmenus, 'cache');
// Invoke hook_mmenu_alter().
// To allow all modules to alter the mmenus.
// Don't save the altered values into cache.
drupal_alter('mmenu', $mmenus);
if (!empty($mmenu_name)) {
if (isset($mmenus[$mmenu_name])) {
return $mmenus[$mmenu_name];
}
else {
return array();
}
}
return $mmenus;
}