You are here

function replicate_ui_menu in Replicate UI 7

Implements hook_menu().

File

./replicate_ui.module, line 41
Provide a user interface for the Replicate API.

Code

function replicate_ui_menu() {
  $items['replicate/%/%'] = array(
    'title' => 'Replicate',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'replicate_ui_confirm',
      1,
      2,
    ),
    'access callback' => 'replicate_ui_access',
    'access arguments' => array(
      1,
      2,
    ),
  );
  $items['node/%node/replicate'] = array(
    'title' => 'Replicate',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'replicate_ui_confirm',
      0,
      1,
    ),
    'access callback' => 'replicate_ui_access',
    'access arguments' => array(
      0,
      1,
    ),
    'type' => MENU_LOCAL_TASK,
  );

  // support for user entity though this might not do what you think without
  // some kind of clean up module: see https://www.drupal.org/node/2394779
  $items['user/%user/replicate'] = array(
    'title' => 'Replicate',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'replicate_ui_confirm',
      0,
      1,
    ),
    'access callback' => 'replicate_ui_access',
    'access arguments' => array(
      0,
      1,
    ),
    'type' => MENU_LOCAL_TASK,
  );

  // ewwwww, taxonomy support
  if (module_exists('taxonomy')) {
    $items['taxonomy/term/%taxonomy_term/replicate'] = array(
      'title' => 'Replicate',
      'page callback' => 'drupal_get_form',
      'page arguments' => array(
        'replicate_ui_confirm',
        'taxonomy_term',
        2,
      ),
      'access callback' => 'replicate_ui_access',
      'access arguments' => array(
        'taxonomy_term',
        2,
      ),
      'type' => MENU_LOCAL_TASK,
    );
  }

  // optional support based on modules being installed
  // entityform support, we don't check for the submodule directly because
  // people might want to use another, completely valid, approach
  if (module_exists('entityform')) {
    $items['entityform/%entityform/replicate'] = array(
      'title' => 'Replicate',
      'page callback' => 'drupal_get_form',
      'page arguments' => array(
        'replicate_ui_confirm',
        0,
        1,
      ),
      'access callback' => 'replicate_ui_access',
      'access arguments' => array(
        0,
        1,
      ),
      'type' => MENU_LOCAL_TASK,
    );
  }

  // field_collection support, we don't check for the submodule directly
  // because people might want to use another, completely valid, approach
  if (module_exists('field_collection')) {

    // Add menu paths for viewing/editing/deleting field collection items.
    foreach (field_info_fields() as $field) {
      if ($field['type'] == 'field_collection') {
        $path = field_collection_field_get_path($field);
        $items[$path . '/%field_collection_item/replicate'] = array(
          'title' => 'Replicate',
          'page callback' => 'drupal_get_form',
          'page arguments' => array(
            'replicate_ui_confirm',
            'field_collection_item',
            2,
          ),
          'access callback' => 'replicate_ui_access',
          'access arguments' => array(
            'field_collection_item',
            2,
          ),
          'type' => MENU_LOCAL_TASK,
          'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
        );
      }
    }
  }
  return $items;
}