function conditional_fields_menu in Conditional Fields 7.3
Same name and namespace in other branches
- 5 conditional_fields.module \conditional_fields_menu()
- 6.2 conditional_fields.module \conditional_fields_menu()
- 6 conditional_fields.module \conditional_fields_menu()
Implements hook_menu().
File
- ./
conditional_fields.module, line 101 - Define dependencies between fields based on their states and values.
Code
function conditional_fields_menu() {
$items = array();
// Ensure the following is not executed until field_bundles is working and
// tables are updated. Needed to avoid errors on initial installation.
if (defined('MAINTENANCE_MODE')) {
return $items;
}
$items['admin/structure/dependencies'] = array(
'title' => 'Field dependencies',
'description' => 'Administer field dependencies for the site.',
'page callback' => 'conditional_fields_dependencies_overview_page',
'access arguments' => array(
'administer dependencies',
),
'file' => 'includes/conditional_fields.admin.inc',
);
$items['admin/structure/dependencies/overview'] = array(
'title' => 'Overview',
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => 1,
);
$items['admin/structure/dependencies/edit/%conditional_fields_dependency'] = array(
'title' => 'Edit dependency',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'conditional_fields_dependency_edit_form',
4,
),
'access arguments' => array(
'administer dependencies',
),
'file' => 'includes/conditional_fields.admin.inc',
);
$items['admin/structure/dependencies/delete/%conditional_fields_dependency'] = array(
'title' => 'Delete dependency',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'conditional_fields_dependency_delete_form',
4,
),
'access arguments' => array(
'administer dependencies',
),
'file' => 'includes/conditional_fields.admin.inc',
);
// Some of the following code is copied from field_ui_menu().
// Create tabs for all possible bundles.
foreach (entity_get_info() as $entity_type => $entity_info) {
if ($entity_info['fieldable']) {
$items["admin/structure/dependencies/{$entity_type}"] = array(
'title' => $entity_info['label'],
'page arguments' => array(
NULL,
3,
),
'access arguments' => array(
'administer dependencies',
),
'type' => MENU_LOCAL_TASK,
'weight' => 2,
);
foreach ($entity_info['bundles'] as $bundle_name => $bundle_info) {
if (module_exists('field_ui') && isset($bundle_info['admin'])) {
// Extract path information from the bundle and replace any "magic"
// wildcard with a normal one.
$path = preg_replace('/(%[a-z0-9_]*)/', '%', $bundle_info['admin']['path']);
if (isset($bundle_info['admin']['bundle argument'])) {
$bundle_pos = $bundle_info['admin']['bundle argument'];
}
else {
$bundle_pos = $bundle_name;
}
$items["{$path}/dependencies"] = array(
'title' => $entity_type == 'comment' ? 'Comment dependencies' : 'Manage dependencies',
'page callback' => 'conditional_fields_dependencies_overview_page',
'page arguments' => array(
$bundle_pos,
$entity_type,
),
'type' => MENU_LOCAL_TASK,
'weight' => $entity_type == 'comment' ? 4 : 2,
'file' => 'includes/conditional_fields.admin.inc',
'access arguments' => array(
'administer dependencies',
),
);
}
}
}
}
return $items;
}