You are here

function _ds_ui_menu in Display Suite 6.3

Same name and namespace in other branches
  1. 6 includes/ds.registry.inc \_ds_ui_menu()
  2. 6.2 includes/ds.registry.inc \_ds_ui_menu()

Return menu items and import default settings.

1 call to _ds_ui_menu()
ds_ui_menu in ./ds_ui.module
Implementation of hook_menu().

File

includes/ds.registry.inc, line 29
Registry functions.

Code

function _ds_ui_menu() {
  $items = array();
  $all_build_modes = ds_get_build_modes(NULL, TRUE);

  // Display suite main menu block.
  $items[DS_PATH_BASE] = array(
    'title' => 'Display suite',
    'description' => 'Manage your site display.',
    'page callback' => 'ds_general_page',
    'access arguments' => array(
      'access display suite',
    ),
    'file' => 'includes/ds.admin.inc',
  );

  // Layouts
  $items[DS_PATH_LAYOUT] = array(
    'title' => 'Layouts',
    'description' => 'Go to the overview screen of all the objects in your Drupal site to theme.',
    'page callback' => 'ds_layout_overview',
    'access arguments' => array(
      'access display suite',
    ),
    'file' => 'includes/ds.display.inc',
    'weight' => -5,
  );
  $items[DS_PATH_LAYOUT . '/overview'] = array(
    'title' => 'Overview',
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'weight' => 0,
  );

  // Modules
  $items[DS_PATH_MODULES] = array(
    'title' => 'Module display settings',
    'description' => 'Settings for modules which provide displays.',
    'page callback' => 'ds_module_list',
    'access arguments' => array(
      'access display suite',
    ),
    'file' => 'includes/ds.modules.inc',
    'weight' => 3,
  );
  foreach (module_implements('ds_api') as $module) {
    $api_info = ds_api_info($module);
    $module = $api_info['module'];
    $title = $api_info['title'];

    // Displays.
    $build_modes = $all_build_modes[$module];
    $first_title = '';
    $first_build_mode = key($build_modes);
    if (!empty($build_modes)) {
      foreach ($api_info['types']() as $tkey => $type) {
        $type_name = $type->type;
        $type_url_str = str_replace('_', '-', $type_name);

        // Global exclude.
        if (variable_get($module . '_type_' . $type->type, FALSE)) {
          continue;
        }
        $first = 0;
        $weight = 20;
        $build_modes_found = FALSE;
        $local_task_items = array();
        $exclude_build_modes = variable_get($module . '_buildmodes_exclude', array());
        foreach ($build_modes as $key => $value) {

          // Check if build mode is excluded for this object type.
          $excluded = isset($exclude_build_modes[$type_name][$key]) && $exclude_build_modes[$type_name][$key] == TRUE ? TRUE : FALSE;
          if ($excluded) {
            continue;
          }
          $build_modes_found = TRUE;

          // Tabs.
          $local_task_items[DS_PATH_LAYOUT . '/' . $type_url_str . '/' . $key] = array(
            'title' => $value['title'],
            'page callback' => 'drupal_get_form',
            'page arguments' => array(
              'ds_display_overview_form',
              $type_name,
              "{$key}",
              $module,
            ),
            'access arguments' => array(
              'configure layout for ' . $module,
            ),
            'type' => MENU_CALLBACK,
            //$first == 0 ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK,
            'file' => 'includes/ds.display.inc',
            'weight' => isset($value['weight']) && !empty($value['weight']) ? $value['weight'] : $weight++,
          );

          // Store the first build_mode
          if ($first == 0) {
            $first++;
            $first_title = $type->name;
            $first_build_mode = $key;
          }
        }

        // Default callback.
        if ($build_modes_found) {
          $items[DS_PATH_LAYOUT . '/' . $type_url_str] = array(
            'title' => drupal_ucfirst($first_title),
            'page callback' => 'drupal_get_form',
            'page arguments' => array(
              'ds_display_overview_form',
              $type_name,
              "{$first_build_mode}",
              $module,
            ),
            'access arguments' => array(
              'configure layout for ' . $module,
            ),
            'file' => 'includes/ds.display.inc',
            'type' => MENU_NORMAL_ITEM,
            'weight' => 2,
          );
          $items += $local_task_items;
        }
      }
    }

    // Info.
    $items[DS_PATH_MODULES . '/' . $module] = array(
      'title' => $title,
      'description' => 'Find help, configure build modes, fields, fieldgroups, plugins and possibly other settings for ' . $title . '.',
      'page callback' => 'ds_info',
      'page arguments' => array(
        $module,
      ),
      'access arguments' => array(
        'administer ' . $module,
      ),
      'file' => 'includes/ds.modules.inc',
    );
    $items[DS_PATH_MODULES . '/' . $module . '/info'] = array(
      'title' => 'Info',
      'type' => MENU_DEFAULT_LOCAL_TASK,
      'weight' => 0,
    );

    // Fields.
    $items[DS_PATH_MODULES . '/' . $module . '/fields'] = array(
      'title' => 'Fields',
      'page callback' => 'ds_fields',
      'page arguments' => array(
        $module,
      ),
      'access callback' => '_ds_ui_menu_access',
      'access arguments' => array(
        'administer ' . $module,
        'use PHP in custom fields',
      ),
      'file' => 'includes/ds.fields.inc',
      'type' => MENU_LOCAL_TASK,
      'weight' => 1,
    );

    // Fields examples.
    if (!isset($api_info['no_fields_examples'])) {
      $items[DS_PATH_MODULES . '/' . $module . '/fields-examples'] = array(
        'title' => 'Field examples',
        'page callback' => 'ds_fields_examples',
        'page arguments' => array(
          $module,
        ),
        'access callback' => '_ds_ui_menu_access',
        'access arguments' => array(
          'administer ' . $module,
          'use PHP in custom fields',
        ),
        'file' => 'includes/ds.fields.inc',
        'type' => MENU_CALLBACK,
        'weight' => 1,
      );
    }

    // Field groups
    $items[DS_PATH_MODULES . '/' . $module . '/fieldgroups'] = array(
      'title' => 'Fieldgroups',
      'page callback' => 'ds_fieldgroups',
      'page arguments' => array(
        $module,
      ),
      'access arguments' => array(
        'administer ' . $module,
      ),
      'file' => 'includes/ds.groups.inc',
      'type' => MENU_LOCAL_TASK,
      'weight' => 2,
    );

    // Build modes.
    $items[DS_PATH_MODULES . '/' . $module . '/buildmodes'] = array(
      'title' => 'Build modes',
      'page callback' => 'ds_build_modes_page',
      'page arguments' => array(
        $module,
      ),
      'access arguments' => array(
        'administer ' . $module,
      ),
      'file' => 'includes/ds.buildmodes.inc',
      'type' => MENU_LOCAL_TASK,
      'weight' => 3,
    );
  }

  // Styles
  $items[DS_PATH_STYLES] = array(
    'title' => 'Styles',
    'description' => 'Configure generic CSS class settings for fields and regions.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'ds_styles_form',
    ),
    'access arguments' => array(
      'administer styles',
    ),
    'file' => 'includes/ds.display.inc',
    'weight' => 5,
  );

  // Tools
  $items[DS_PATH_EXPORT] = array(
    'title' => 'Import/export',
    'description' => 'Import and export settings and get a skeleton of your stylesheet depending on your configuration.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'ds_import',
    ),
    'access arguments' => array(
      'export and import settings',
    ),
    'file' => 'includes/ds.tools.inc',
    'weight' => 7,
  );
  $items[DS_PATH_EXPORT . '/import'] = array(
    'title' => 'Import settings',
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'weight' => 0,
  );
  $items[DS_PATH_EXPORT . '/export'] = array(
    'title' => 'Export settings',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'ds_export',
    ),
    'access arguments' => array(
      'export and import settings',
    ),
    'file' => 'includes/ds.tools.inc',
    'type' => MENU_LOCAL_TASK,
    'weight' => 1,
  );
  $items[DS_PATH_EXPORT . '/revert'] = array(
    'title' => 'Revert',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'ds_revert_form',
    ),
    'access arguments' => array(
      'revert overridden settings',
    ),
    'file' => 'includes/ds.tools.inc',
    'type' => MENU_CALLBACK,
  );

  // Plugins.
  $items[DS_PATH_PLUGINS] = array(
    'title' => 'Plugins',
    'page callback' => 'ds_plugins_page',
    'access arguments' => array(
      'access display suite',
    ),
    'file' => 'includes/ds.admin.inc',
    'type' => MENU_NORMAL_ITEM,
    'weight' => 9,
  );
  return $items;
}