1.20.x file.module file_menu()

Implements hook_menu().

File

modules/file/file.module, line 197
Defines a "managed_file" Form API field and a "file" field for Field module.

Code

function file_menu() {
  $items = array();

  // File Configuration
  $items['admin/structure/file-types'] = array(
    'title' => 'File types',
    'description' => 'Manage settings for the type of files used on your site.',
    'page callback' => 'file_list_types_page',
    'access arguments' => array('administer file types'),
    'file' => 'file.admin.inc',
  );
  // File Configuration
  $items['admin/structure/file-types/list'] = array(
    'title' => 'File types',
    'description' => 'Manage settings for the type of files used on your site.',
    'page callback' => 'file_list_types_page',
    'access arguments' => array('administer file types'),
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'file' => 'file.admin.inc',
  );
  $items['admin/structure/file-types/settings'] = array(
    'title' => 'File settings',
    'description' => 'Configure allowed file extensions and the file upload wizard.',
    'page callback' => 'backdrop_get_form',
    'page arguments' => array('file_settings_form'),
    'access arguments' => array('administer file types'),
    'type' => MENU_LOCAL_TASK,
    'weight' => 10,
    'file' => 'file.admin.inc',
  );
  $items['admin/structure/file-types/add'] = array(
    'title' => 'Add file type',
    'page callback' => 'backdrop_get_form',
    'page arguments' => array('file_type_form'),
    'access arguments' => array('administer file types'),
    'type' => MENU_LOCAL_ACTION,
    'file' => 'file.admin.inc',
  );
  $items['admin/structure/file-types/manage/%file_type'] = array(
    'title' => 'Manage file types',
    'description' => 'Manage settings for the type of files used on your site.',
  );
  $items['admin/structure/file-types/manage/%file_type/revert'] = array(
    'title' => 'Revert',
    'page callback' => 'backdrop_get_form',
    'page arguments' => array('file_type_revert_confirm', 4),
    'access arguments' => array('administer file types'),
    'file' => 'file.admin.inc',
    'type' => MENU_CALLBACK,
  );
  $items['admin/structure/file-types/manage/%file_type/enable'] = array(
    'title' => 'Enable file type',
    'page callback' => 'file_type_toggle_enable',
    'page arguments' => array(4, '1'),
    'access arguments' => array('administer file types'),
    'file' => 'file.admin.inc',
    'type' => MENU_VISIBLE_IN_BREADCRUMB,
  );
  $items['admin/structure/file-types/manage/%file_type/disable'] = array(
    'title' => 'Disable file type',
    'page callback' => 'file_type_toggle_enable',
    'page arguments' => array(4, '0'),
    'access arguments' => array('administer file types'),
    'file' => 'file.admin.inc',
    'type' => MENU_VISIBLE_IN_BREADCRUMB,
  );
  $items['admin/structure/file-types/manage/%file_type/delete'] = array(
    'title' => 'Delete',
    'page callback' => 'backdrop_get_form',
    'page arguments' => array('file_type_delete_confirm', 4),
    'access arguments' => array('administer file types'),
    'file' => 'file.admin.inc',
    'type' => MENU_CALLBACK,
  );

  // 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'], backdrop_map_assoc(array('access callback', 'access arguments')));
      $access += array(
        'access callback' => 'user_access',
        'access arguments' => array('administer file types'),
      );

      // 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;

      $items[$path] = array(
        'title' => 'Configure file type',
        'title callback' => 'file_type_get_name',
        'title arguments' => array(4),
        'page callback' => 'backdrop_get_form',
        'page arguments' => array('file_type_form', $file_type_argument),
        'file' => 'file.admin.inc',
      ) + $access;

      // Add the 'File type settings' tab.
      $items["$path/configure"] = array(
        'title' => 'Configure',
        'type' => MENU_DEFAULT_LOCAL_TASK,
      );

      // Add the 'Manage file display' tab.
      $items["$path/file-display"] = array(
        'title' => 'Manage file display',
        'page callback' => 'backdrop_get_form',
        'page arguments' => array('file_display_form', $file_type_argument, 'default'),
        'type' => MENU_LOCAL_TASK,
        'weight' => 3,
        'file' => 'file.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_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.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_view_mode_menu_access',
          'access arguments' => array_merge(array($file_type_argument, $view_mode, $access['access callback']), $access['access arguments']),
        );
      }
    }
  }

  $items['file/ajax'] = array(
    'page callback' => 'file_ajax_upload',
    'delivery callback' => 'ajax_deliver',
    'access arguments' => array('access content'),
    'theme callback' => 'ajax_base_page_theme',
    'type' => MENU_CALLBACK,
  );

  // @deprecated. Remove in Backdrop 2.0.
  $items['file/progress'] = array(
    'page callback' => 'file_ajax_progress',
    'delivery callback' => 'backdrop_json_deliver',
    'access arguments' => array('access content'),
    'theme callback' => 'ajax_base_page_theme',
    'type' => MENU_CALLBACK,
  );
  $items['file/add'] = array(
    'title' => 'Add a file',
    'page callback' => 'backdrop_get_form',
    'page arguments' => array('file_add_form'),
    'access arguments' => array('create files'),
    'type' => MENU_LOCAL_ACTION,
    'file' => 'file.pages.inc',
    'weight' => -10,
  );
  $items['file/%file'] = array(
    'title callback' => 'entity_label',
    'title arguments' => array('file', 1),
    // The page callback also invokes backdrop_set_title() in case
    // the menu router's title is overridden by a menu link.
    'page callback' => 'file_view_page',
    'page arguments' => array(1),
    'access callback' => 'file_access',
    'access arguments' => array('view', 1),
    'file' => 'file.pages.inc',
  );
  $items['file/%file/view'] = array(
    'title' => 'View',
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'weight' => -10,
  );
  $items['file/%file/usage'] = array(
    'title' => 'Usage',
    'page callback' => 'file_usage_page',
    'page arguments' => array(1),
    'access callback' => 'file_access',
    'access arguments' => array('update', 1),
    'type' => MENU_LOCAL_TASK,
    'context' => MENU_CONTEXT_PAGE,
    'file' => 'file.pages.inc',
  );
  $items['file/%file/download'] = array(
    'title' => 'Download',
    'page callback' => 'file_download_page',
    'page arguments' => array(1),
    'access callback' => 'file_access',
    'access arguments' => array('download', 1),
    'file' => 'file.pages.inc',
    'type' => MENU_CALLBACK,
  );
  $items['file/%file/manage'] = array(
    'title' => 'Manage',
    'page callback' => 'backdrop_get_form',
    'page arguments' => array('file_manage_form', 1),
    'access callback' => 'file_access',
    'access arguments' => array('update', 1),
    'weight' => 0,
    'type' => MENU_LOCAL_TASK,
    'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
    'file' => 'file.pages.inc',
  );
  $items['file/%file/delete'] = array(
    'title' => 'Delete',
    'page callback' => 'backdrop_get_form',
    'page arguments' => array('file_delete_form', 1),
    'access callback' => 'file_access',
    'access arguments' => array('delete', 1),
    'weight' => 1,
    'type' => MENU_CALLBACK,
    'file' => 'file.pages.inc',
  );
  $items['admin/content/files/delete'] = array(
    'title' => 'Confirm deleting multiple files',
    'type' => MENU_VISIBLE_IN_BREADCRUMB,
    'page callback' => 'backdrop_get_form',
    'page arguments' => array('file_multiple_delete_confirm'),
    'access arguments' => array('delete files'),
    'file' => 'file.pages.inc',
  );

  return $items;
}