You are here

function _ds_extras_menu_alter in Display Suite 7

Same name and namespace in other branches
  1. 7.2 modules/ds_extras/includes/ds_extras.registry.inc \_ds_extras_menu_alter()

Implements hook_menu_alter().

1 call to _ds_extras_menu_alter()
ds_extras_menu_alter in modules/ds_extras/ds_extras.module
Implements hook_menu_alter().

File

modules/ds_extras/ds_extras.registry.inc, line 11
Display suite Extras registry file.

Code

function _ds_extras_menu_alter(&$items) {

  // Switch view mode.
  if (variable_get('ds_extras_switch_view_mode', FALSE)) {

    // Check if page manager is overriding.
    $skip_node_override = FALSE;
    if (module_exists('page_manager')) {
      if ($task = page_manager_get_task('node_view')) {
        if (isset($task['disabled']) && !$task['disabled']) {
          $skip_node_override = TRUE;
        }
      }
    }
    if (!$skip_node_override) {
      $items['node/%node']['page callback'] = 'ds_extras_node_page_view';
      $items['node/%node']['file'] = 'ds_extras.pages.inc';
      $items['node/%node']['file path'] = drupal_get_path('module', 'ds_extras');
    }
  }

  // Revision view mode.
  if (variable_get('ds_extras_revision_view_mode', FALSE)) {

    // Do not conflict with the revisioning module.
    if (module_exists('revisioning')) {
      $items['node/%node/revisions/%vid/view']['page callback'] = 'ds_extras_revision_node_show';
      $items['node/%node/revisions/%vid/view']['file'] = 'ds_extras.pages.inc';
      $items['node/%node/revisions/%vid/view']['file path'] = drupal_get_path('module', 'ds_extras');
    }
    else {
      $items['node/%node/revisions/%/view']['page callback'] = 'ds_extras_revision_node_show';
      $items['node/%node/revisions/%/view']['file'] = 'ds_extras.pages.inc';
      $items['node/%node/revisions/%/view']['file path'] = drupal_get_path('module', 'ds_extras');
    }
  }

  // Panel view modes.
  if (variable_get('ds_extras_panel_view_modes')) {
    $ds_panels_path = drupal_get_path('module', 'ds_extras');
    if (module_exists('field_ui')) {

      // Convert all manage display screen callbacks.
      foreach (entity_get_info() as $entity_type => $entity_info) {
        if ($entity_info['fieldable']) {
          foreach ($entity_info['bundles'] as $bundle_name => $bundle_info) {
            if (isset($bundle_info['admin'])) {

              // Extract path information from the bundle.
              $path = $bundle_info['admin']['path'];
              if (isset($bundle_info['admin']['bundle argument'])) {
                $bundle_arg = $bundle_info['admin']['bundle argument'];
                $bundle_pos = (string) $bundle_arg;
              }
              else {
                $bundle_arg = $bundle_name;
                $bundle_pos = '0';
              }

              // People can select whether they're going to use Field UI
              // or the Panels editor. So, we are going to delegate
              // this to a custom function which in that case is going
              // to call the right layout callback.
              $items["{$path}/display"]['page callback'] = 'ds_extras_select_layout_editor';
              $items["{$path}/display"]['page arguments'] = array(
                $entity_type,
                $bundle_arg,
                'default',
              );
              $items["{$path}/display"]['file'] = 'ds_extras.admin.inc';
              $items["{$path}/display"]['file path'] = $ds_panels_path;
              $view_modes = array(
                'default' => array(
                  'label' => t('Default'),
                ),
              ) + $entity_info['view modes'];
              foreach ($view_modes as $view_mode => $view_mode_info) {
                $items["{$path}/display/{$view_mode}"]['page callback'] = 'ds_extras_select_layout_editor';
                $items["{$path}/display/{$view_mode}"]['page arguments'] = array(
                  $entity_type,
                  $bundle_arg,
                  $view_mode,
                );
                $items["{$path}/display/{$view_mode}"]['file'] = 'ds_extras.admin.inc';
                $items["{$path}/display/{$view_mode}"]['file path'] = $ds_panels_path;
              }
            }
          }
        }
      }
    }
  }
}