nd.registry.inc in Node displays 6
Registry functions.
File
includes/nd.registry.incView source
<?php
/**
* @file
* Registry functions.
*/
/**
* Return menu items.
*/
function _nd_menu() {
$items = array();
$build_modes = nd_get_build_modes(NULL, TRUE);
if (!empty($build_modes)) {
foreach (node_get_types() as $type) {
$type_name = $type->type;
$type_url_str = str_replace('_', '-', $type_name);
$items['admin/content/node-type/' . $type_url_str . '/display'] = array(
'title' => 'Display fields',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'nd_display_overview_form',
$type_name,
),
'access arguments' => array(
'administer content types',
),
'file' => 'includes/nd.display.inc',
'type' => MENU_LOCAL_TASK,
'weight' => 2,
);
// Add build modes from nd.
$weight = 20;
foreach ($build_modes as $key => $value) {
$items['admin/content/node-type/' . $type_url_str . '/display/' . $key] = array(
'title' => $value['title'],
'page callback' => 'drupal_get_form',
'page arguments' => array(
'nd_display_overview_form',
$type_name,
"{$key}",
),
'access arguments' => array(
'administer content types',
),
'type' => $key == 'full' ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK,
'file' => 'includes/nd.display.inc',
'weight' => isset($value['weight']) && !empty($value['weight']) ? $value['weight'] : $weight++,
);
}
}
// Settings page.
$items['admin/content/types/nd'] = array(
'title' => 'Node displays',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'nd_settings',
),
'access arguments' => array(
'administer content types',
),
'file' => 'includes/nd.admin.inc',
'type' => MENU_LOCAL_TASK,
'weight' => 12,
);
$items['admin/content/types/nd/settings'] = array(
'title' => 'Settings',
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => 0,
);
// Build modes.
$items['admin/content/types/nd/buildmodes'] = array(
'title' => 'Build modes',
'page callback' => 'nd_build_modes',
'access arguments' => array(
'administer content types',
),
'file' => 'includes/nd.buildmodes.inc',
'type' => MENU_LOCAL_TASK,
'weight' => 1,
);
// Fields.
$items['admin/content/types/nd/fields'] = array(
'title' => 'Fields',
'page callback' => 'nd_fields',
'access arguments' => array(
'administer content types',
),
'file' => 'includes/nd.fields.inc',
'type' => MENU_LOCAL_TASK,
'weight' => 2,
);
$items['admin/content/types/nd/plugins'] = array(
'title' => 'Plugins',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'nd_plugins',
),
'access arguments' => array(
'administer content types',
),
'file' => 'includes/nd.plugins.inc',
'type' => MENU_LOCAL_TASK,
'weight' => 3,
);
}
return $items;
}
/**
* Return theme functions.
*/
function _nd_theme() {
$path = drupal_get_path('module', 'nd');
$theme_functions = array(
// Display overview form.
'nd_display_overview_form' => array(
'template' => 'nd-display-overview-form',
'file' => 'theme.inc',
'path' => $path . '/theme',
'arguments' => array(
'form' => NULL,
),
),
// Build modes matrix
'nd_buildmodes_matrix_form' => array(
'file' => 'nd.buildmodes.inc',
'path' => $path . '/includes',
'arguments' => array(
'form' => NULL,
),
),
// Plugins form.
'nd_plugins' => array(
'file' => 'nd.plugins.inc',
'path' => $path . '/includes',
'arguments' => array(
'form' => NULL,
),
),
// Field
'nd_field' => array(
'arguments' => array(
'content' => NULL,
'field_key' => NULL,
'field' => NULL,
),
'file' => 'theme.inc',
'path' => $path . '/theme',
),
);
// Formatter theming functions.
$formatters = array(
'nd_bodyfield',
'nd_title_h1_nolink',
'nd_title_h1_link',
'nd_title_h2_nolink',
'nd_title_h2_link',
'nd_title_h2_block_nolink',
'nd_title_h2_block_link',
'nd_title_p_nolink',
'nd_title_p_link',
'nd_author_link',
'nd_author_nolink',
);
foreach ($formatters as $formatter) {
$theme_functions[$formatter] = array(
'file' => 'theme.inc',
'path' => $path . '/theme',
'arguments' => array(
'node' => NULL,
),
);
}
return $theme_functions;
}
/**
* Register build modes.
*/
function _nd_register_build_modes() {
// Define array with build modes to exclude.
$exclude_build_modes = array(
NODE_BUILD_SEARCH_INDEX,
'token',
);
// Build modes defined in hooks.
$weight = 10;
$build_modes = array();
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.
foreach ($temp_data as $tab_key => $value) {
foreach ($value['build modes'] as $key => $value2) {
// Exclude some build modes.
if (in_array($key, $exclude_build_modes)) {
continue;
}
// Sane build modes.
$module_data[$key] = array(
'weight' => isset($value['weight']) ? $value['weight'] : $weight++,
'title' => $value2['title'],
'build modes' => array(
$key => array(
'title' => $value2['title'],
),
),
);
// Check on Full node for its weight.
if ($value2['title'] == t('Full node')) {
$module_data[$key]['weight'] = -1;
}
}
}
// Merge the result
$build_modes += $module_data;
}
// Give modules a change to alter build_modes.
drupal_alter('nd_buildmodes', $build_modes);
// Let's order.
asort($build_modes);
// Cache all build modes.
variable_set('nd_all_build_modes', $build_modes);
return $build_modes;
}
/**
* Return nd plugins.
*/
function _nd_plugins() {
$path = drupal_get_path('module', 'nd');
return array(
'emptyregionrender' => array(
'title' => t('Empty region'),
'description' => t('Renders a region when there is no content in it.'),
'file' => 'emptyregionrender.inc',
'path' => $path . '/plugins',
),
'cssoverrider' => array(
'title' => t('Simple CSS overrider'),
'description' => t('Override region CSS with inline styles or add extra classes.'),
'file' => 'cssoverrider.inc',
'path' => $path . '/plugins',
),
);
}
/**
* Return nd build modes.
*/
function _nd_content_build_modes() {
$build_modes = array(
'full' => array(
'title' => t('Full node'),
'weight' => -1,
'build modes' => array(
'full' => array(
'title' => t('Full node'),
'views style' => TRUE,
),
),
),
'teaser' => array(
'title' => t('Teaser'),
'weight' => 1,
'build modes' => array(
'teaser' => array(
'title' => t('Teaser'),
'views style' => TRUE,
),
),
),
'nd_sticky' => array(
'title' => t('Sticky'),
'weight' => 2,
'build modes' => array(
'nd_sticky' => array(
'title' => t('Sticky'),
'views style' => TRUE,
),
),
),
);
// Custom build modes through the UI.
$weight = 10;
$db_build_modes = variable_get('nd_build_modes', array());
if (!empty($db_build_modes)) {
foreach ($db_build_modes as $key => $name) {
$build_modes[$key] = array(
'title' => check_plain($name),
'weight' => $weight++,
'build modes' => array(
$key => array(
'title' => check_plain($name),
'views style' => TRUE,
),
),
);
}
}
return $build_modes;
}
Functions
Name | Description |
---|---|
_nd_content_build_modes | Return nd build modes. |
_nd_menu | Return menu items. |
_nd_plugins | Return nd plugins. |
_nd_register_build_modes | Register build modes. |
_nd_theme | Return theme functions. |