You are here

function date_repeat_field_menu in Date 7.3

Same name and namespace in other branches
  1. 8 date_repeat_field/date_repeat_field.module \date_repeat_field_menu()
  2. 7.2 date_repeat_field/date_repeat_field.module \date_repeat_field_menu()

Implements hook_menu().

File

date_repeat_field/date_repeat_field.module, line 66
Creates the option of Repeating Date fields and manages Date Repeat fields.

Code

function date_repeat_field_menu() {

  // Add menu tabs to display pages with details about repeating date values.
  $items = array();
  $values = date_repeat_field_bundles();
  foreach ($values as $entity_type => $bundles) {
    if (module_exists('field_collection') && $entity_type == 'field_collection_item') {
      foreach ($bundles as $bundle => $fields) {
        $field = field_info_field($bundle);
        if ($field['type'] == 'field_collection') {
          $path = field_collection_field_get_path($field);
          $count = count(explode('/', $path));
          $items[$path . '/%field_collection_item/repeats'] = array(
            'title' => 'Repeats',
            'page callback' => 'date_repeat_field_page',
            'page arguments' => array(
              $entity_type,
              $count,
            ),
            'access callback' => 'date_repeat_field_show',
            'access arguments' => array(
              $entity_type,
              $count,
            ),
            'type' => MENU_LOCAL_TASK,
            'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
          );
        }
      }
    }
    else {
      $path = $entity_type . '/%' . $entity_type;
      $items[$path . '/repeats'] = array(
        'title' => 'Repeats',
        'page callback' => 'date_repeat_field_page',
        'page arguments' => array(
          $entity_type,
          1,
        ),
        'access callback' => 'date_repeat_field_show',
        'access arguments' => array(
          $entity_type,
          1,
        ),
        'type' => MENU_LOCAL_TASK,
        'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
      );
    }
  }
  return $items;
}