function _ds_register_build_modes in Display Suite 6
Same name and namespace in other branches
- 6.3 includes/ds.registry.inc \_ds_register_build_modes()
- 6.2 includes/ds.registry.inc \_ds_register_build_modes()
Register build modes.
1 call to _ds_register_build_modes()
- ds_get_build_modes in ./
ds.module - Api function to return all build modes.
File
- includes/
ds.registry.inc, line 411 - Registry functions.
Code
function _ds_register_build_modes() {
$weight = 10;
$build_modes = array();
// Build modes defined in hooks.
foreach (module_implements('content_build_modes') as $module) {
$module_data = array();
$function = $module . '_content_build_modes';
$temp_data = $function();
// We need to do some fiddling existing build modes.
if (!empty($temp_data)) {
foreach ($temp_data as $key => $value) {
// Sane build modes.
foreach ($value['build modes'] as $build_mode => $build_mode_value) {
// If no module key is set, we are adding it ourselves. This hook only applies
// to nodes anyway, so yes, we use nd as the $module key.
$module_name = isset($build_mode_value['module']) ? $build_mode_value['module'] : 'nd';
$build_modes[$module_name][$build_mode] = array(
'weight' => isset($build_mode_value['weight']) ? $build_mode_value['weight'] : $weight++,
'title' => $build_mode_value['title'],
);
}
}
}
}
// Custom build modes via the UI.
foreach (module_implements('ds_api') as $module) {
$weight = 10;
$db_build_modes = variable_get($module . '_build_modes', array());
if (!empty($db_build_modes)) {
foreach ($db_build_modes as $key => $name) {
$build_modes[$module][$key] = array(
'weight' => $weight++,
'title' => check_plain($name),
'build modes' => array(
$key => array(
'title' => check_plain($name),
),
),
);
}
}
asort($build_modes[$module]);
}
// Give modules a change to alter build_modes.
drupal_alter('ds_buildmodes', $build_modes);
// Cache all build modes.
variable_set('ds_all_build_modes', $build_modes);
return $build_modes;
}