You are here

function styles_ui_menu in Styles 6

Same name and namespace in other branches
  1. 7.2 contrib/styles_ui/styles_ui.module \styles_ui_menu()
  2. 7 contrib/styles_ui/styles_ui.module \styles_ui_menu()

Implementation of hook_menu().

File

contrib/styles_ui/styles_ui.module, line 13
styles_ui.module Styles UI

Code

function styles_ui_menu() {

  // Each field type Style may choose to allow the Styles module to manage its
  // UI. To do so, they'll need to create an 'admin' array in its definition
  // at hook_styles_containers that will contain the path info:
  //  'path' => The path to the overview listing page,
  //  'title' => The title for the overview listing page,
  //  'description' => The description for the overview listing page,
  //  'access callback' => The access callback for the overview listing pages,
  //  'access arguments' => The access arguments for the overview listing pages,
  //  'add' => an optional array with the info for adding a new container:
  //    'title' => The title to add a new container for this field,
  //    'description' => The discription to add a new container for this field,
  $items = array();
  $presets = styles_presets();
  $styles_containers = styles_containers();
  $field_types = _content_field_types();
  foreach (styles_containers() as $field_type => $containers) {
    if (isset($containers['admin']) && isset($containers['admin']['path'])) {
      $field_label = $field_types[$field_type]['label'];
      $title = $field_label . ' styles';
      $description = 'Configure ' . $field_label . ' styles.';
      $access_callback = isset($containers['admin']['access callback']) ? $containers['admin']['access callback'] : 'user_access';
      $access_arguments = isset($containers['admin']['access arguments']) ? $containers['admin']['access arguments'] : array(
        'administer site configuration',
      );
      $items[$containers['admin']['path']] = array(
        'title' => $title,
        'description' => $description,
        'access callback' => $access_callback,
        'access arguments' => $access_arguments,
        'page callback' => 'styles_ui_containers_overview',
        'page arguments' => array(
          $field_type,
        ),
        'file' => 'includes/styles_ui.admin.inc',
      );
      $items[$containers['admin']['path'] . '/list'] = array(
        'title' => 'List',
        'type' => MENU_DEFAULT_LOCAL_TASK,
        'weight' => -10,
      );
      $title = 'Add ' . $field_label . ' style preset';
      $description = '';
      $items[$containers['admin']['path'] . '/add'] = array(
        'title' => $title,
        'description' => $description,
        'page callback' => 'drupal_get_form',
        'page arguments' => array(
          'styles_ui_preset_add_form',
          $field_type,
        ),
        'access callback' => $access_callback,
        'access arguments' => $access_arguments,
        'type' => MENU_LOCAL_ACTION,
        'file' => 'includes/styles_ui.admin.inc',
      );
      $count = substr_count($containers['admin']['path'] . '/edit/%', '/');
      $items[$containers['admin']['path'] . '/edit/%'] = array(
        'page callback' => 'drupal_get_form',
        'page arguments' => array(
          'styles_ui_preset_edit_form',
          $field_type,
          $count,
        ),
        'access callback' => $access_callback,
        'access arguments' => $access_arguments,
        'type' => MENU_CALLBACK,
        'file' => 'includes/styles_ui.admin.inc',
      );
      $items['styles-ui/preview/' . $field_type . '/%/%'] = array(
        'page callback' => 'styles_ui_preview_ajax',
        'page arguments' => array(
          2,
          3,
          4,
        ),
        'access callback' => $access_callback,
        'access arguments' => $access_arguments,
        'file' => 'includes/styles_ui.admin.inc',
        'type' => MENU_CALLBACK,
      );
    }
  }
  return $items;
}