function file_entity_menu in File Entity (fieldable files) 7
Same name and namespace in other branches
- 7.3 file_entity.module \file_entity_menu()
- 7.2 file_entity.module \file_entity_menu()
Implements hook_menu().
File
- ./
file_entity.module, line 39 - Extends Drupal file entities to be fieldable and viewable.
Code
function file_entity_menu() {
// File Configuration
$items['admin/config/media/file-types'] = array(
'title' => 'File types',
'description' => 'Manage settings for the type of files used on your site.',
'page callback' => 'file_entity_list_types_page',
'access arguments' => array(
'administer site configuration',
),
'file' => 'file_entity.admin.inc',
);
$items['admin/config/media/file-types/manage/%'] = array(
'title' => 'Manage file types',
'description' => 'Manage settings for the type of files used on your site.',
);
$items['admin/content/file'] = array(
'title' => 'Files',
'description' => 'Manage files used on your site.',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'file_entity_admin_files',
),
'access arguments' => array(
'administer files',
),
'type' => MENU_LOCAL_TASK | MENU_NORMAL_ITEM,
'file' => 'file_entity.admin.inc',
);
$items['admin/content/file/list'] = array(
'title' => 'List',
'type' => MENU_DEFAULT_LOCAL_TASK,
);
// general view, edit, delete for files
$items['file/%file'] = array(
'page callback' => 'file_entity_view_page',
'page arguments' => array(
1,
),
'access callback' => 'file_entity_access',
'access arguments' => array(
'view',
),
'file' => 'file_entity.pages.inc',
);
$items['file/%file/view'] = array(
'title' => 'View',
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => -10,
);
$items['file/%file/edit'] = array(
'title' => 'Edit',
'page callback' => 'file_entity_page_edit',
'page arguments' => array(
1,
),
'access callback' => 'file_entity_access',
'access arguments' => array(
'edit',
),
'weight' => 0,
'type' => MENU_LOCAL_TASK,
'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
'file' => 'file_entity.pages.inc',
);
$items['file/%file/delete'] = array(
'title' => 'Delete',
'page callback' => 'file_entity_page_delete',
'page arguments' => array(
1,
),
'access callback' => 'file_entity_access',
'access arguments' => array(
'edit',
),
'weight' => 1,
'type' => MENU_LOCAL_TASK,
'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
'file' => 'file_entity.pages.inc',
);
// Attach a "Manage file display" tab to each file type in the same way that
// Field UI attaches "Manage fields" and "Manage display" tabs. Note that
// Field UI does not have to be enabled; we're just using the same IA pattern
// here for attaching the "Manage file display" page.
$entity_info = entity_get_info('file');
foreach ($entity_info['bundles'] as $file_type => $bundle_info) {
if (isset($bundle_info['admin'])) {
// Get the base path and access.
$path = $bundle_info['admin']['path'];
$access = array_intersect_key($bundle_info['admin'], drupal_map_assoc(array(
'access callback',
'access arguments',
)));
$access += array(
'access callback' => 'user_access',
'access arguments' => array(
'administer site configuration',
),
);
// The file type must be passed to the page callbacks. It might be
// configured as a wildcard (multiple file types sharing the same menu
// router path).
$file_type_argument = isset($bundle_info['admin']['bundle argument']) ? $bundle_info['admin']['bundle argument'] : $file_type;
// Add the 'Manage file display' tab.
$items["{$path}/file-display"] = array(
'title' => 'Manage file display',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'file_entity_file_display_form',
$file_type_argument,
'default',
),
'type' => MENU_LOCAL_TASK,
'weight' => 3,
'file' => 'file_entity.admin.inc',
) + $access;
// Add a secondary tab for each view mode.
$weight = 0;
$view_modes = array(
'default' => array(
'label' => t('Default'),
),
) + $entity_info['view modes'];
foreach ($view_modes as $view_mode => $view_mode_info) {
$items["{$path}/file-display/{$view_mode}"] = array(
'title' => $view_mode_info['label'],
'page arguments' => array(
'file_entity_file_display_form',
$file_type_argument,
$view_mode,
),
'type' => $view_mode == 'default' ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK,
'weight' => $view_mode == 'default' ? -10 : $weight++,
'file' => 'file_entity.admin.inc',
// View modes for which the 'custom settings' flag isn't TRUE are
// disabled via this access callback. This needs to extend, rather
// than override normal $access rules.
'access callback' => '_file_entity_view_mode_menu_access',
'access arguments' => array_merge(array(
$file_type_argument,
$view_mode,
$access['access callback'],
), $access['access arguments']),
);
}
}
}
return $items;
}