Projet

Général

Profil

Révision b720ea3e

Ajouté par Assos Assos il y a plus de 8 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/date/date_repeat_field/date_repeat_field.module
77 77
          $path = field_collection_field_get_path($field);
78 78
          $count = count(explode('/', $path));
79 79
          $items[$path . '/%field_collection_item/repeats'] = array(
80
           'title' => 'Repeats',
81
           'page callback' => 'date_repeat_field_page',
82
           'page arguments' => array($entity_type, $count),
83
           'access callback' => 'date_repeat_field_show',
84
           'access arguments' => array($entity_type, $count),
85
           'type' => MENU_LOCAL_TASK,
86
           'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
80
            'title' => 'Repeats',
81
            'page callback' => 'date_repeat_field_page',
82
            'page arguments' => array($entity_type, $count),
83
            'access callback' => 'date_repeat_field_show',
84
            'access arguments' => array($entity_type, $count),
85
            'type' => MENU_LOCAL_TASK,
86
            'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
87 87
          );
88 88
        }
89 89
      }
......
91 91
    else {
92 92
      $path = $entity_type . '/%' . $entity_type;
93 93
      $items[$path . '/repeats'] = array(
94
       'title' => 'Repeats',
95
       'page callback' => 'date_repeat_field_page',
96
       'page arguments' => array($entity_type, 1),
97
       'access callback' => 'date_repeat_field_show',
98
       'access arguments' => array($entity_type, 1),
99
       'type' => MENU_LOCAL_TASK,
100
       'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
94
        'title' => 'Repeats',
95
        'page callback' => 'date_repeat_field_page',
96
        'page arguments' => array($entity_type, 1),
97
        'access callback' => 'date_repeat_field_show',
98
        'access arguments' => array($entity_type, 1),
99
        'type' => MENU_LOCAL_TASK,
100
        'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
101 101
      );
102 102
    }
103 103
  }
......
108 108
 * Implements hook_permission().
109 109
 */
110 110
function date_repeat_field_permission() {
111
  return array('view date repeats' => array(
112
    'title' => t('View Repeating Dates'),
113
    'description' => t('Allow user to see a page with all the times a date repeats.'),
114
  ));
111
  return array(
112
    'view date repeats' => array(
113
      'title' => t('View Repeating Dates'),
114
      'description' => t('Allow user to see a page with all the times a date repeats.'),
115
    ),
116
  );
115 117
}
116 118

  
117 119
/**
......
195 197
  return $values;
196 198
}
197 199

  
200
/**
201
 * Check field is repeat.
202
 */
198 203
function date_is_repeat_field($field, $instance = NULL) {
199 204
  if (is_string($field)) {
200 205
    $field = field_info_field($field);
......
215 220
  }
216 221
}
217 222

  
218
/*
223
/**
219 224
 * Implements hook_date_field_insert_alter().
220 225
 */
221 226
function date_repeat_field_date_field_insert_alter(&$items, $context) {
......
239 244
  }
240 245
}
241 246

  
242
/*
247
/**
243 248
 * Implements hook_date_field_update_alter().
244 249
 */
245 250
function date_repeat_field_date_field_update_alter(&$items, $context) {
......
279 284
        '#suffix' => '</div>',
280 285
        '#default_value' => isset($items[$delta]['rrule']) && !empty($items[$delta]['rrule']) ? 1 : 0,
281 286
      );
287

  
288
      // Make changes if instance is set to be rendered as a regular field.
289
      if (!empty($instance['widget']['settings']['no_fieldset'])) {
290
        $element['#title'] = check_plain($instance['label']);
291
        $element['#description'] = field_filter_xss($instance['description']);
292
        $element['#theme_wrappers'] = array('date_form_element');
293
      }
282 294
    }
283 295
  }
284 296
}
......
340 352
  // The RRULE has already been created by this point, so go back
341 353
  // to the posted values to see if this was filled out.
342 354
  $error_field_base = implode('][', $element['#parents']);
343
  $error_field_until =  $error_field_base . '][rrule][until_child][datetime][';
355
  $error_field_until = $error_field_base . '][rrule][until_child][datetime][';
344 356
  if (!empty($item['rrule']) && $rrule_values['range_of_repeat'] === 'UNTIL' && empty($rrule_values['UNTIL']['datetime'])) {
345 357
    switch ($instance['widget']['type']) {
346 358
      case 'date_text':
347 359
      case 'date_popup':
348 360
        form_set_error($error_field_until . 'date', t("Missing value in 'Range of repeat'. (UNTIL).", array(), array('context' => 'Date repeat')));
349 361
        break;
362

  
350 363
      case 'date_select':
351 364
        form_set_error($error_field_until . 'year', t("Missing value in 'Range of repeat': Year (UNTIL)", array(), array('context' => 'Date repeat')));
352 365
        form_set_error($error_field_until . 'month', t("Missing value in 'Range of repeat': Month (UNTIL)", array(), array('context' => 'Date repeat')));
......
382 395
    // We only collect a date for UNTIL, but we need it to be inclusive,
383 396
    // so force it to a full datetime element at the last possible second of the day.
384 397
    if (!empty($rrule_values['UNTIL'])) {
398
      $gran = array('year', 'month', 'day', 'hour', 'minute', 'second');
385 399
      $rrule_values['UNTIL']['datetime'] .= ' 23:59:59';
386
      $rrule_values['UNTIL']['granularity'] = serialize(drupal_map_assoc(array('year', 'month', 'day', 'hour', 'minute', 'second')));
400
      $rrule_values['UNTIL']['granularity'] = serialize(drupal_map_assoc($gran));
387 401
      $rrule_values['UNTIL']['all_day'] = 0;
388 402
    }
389 403
    $value = date_repeat_build_dates($rrule, $rrule_values, $field, $item);
......
418 432
 * Pass in either the RRULE or the $form_values array for the RRULE,
419 433
 * whichever is missing will be created when needed.
420 434
 */
435
// @codingStandardsIgnoreStart
421 436
function date_repeat_build_dates($rrule = NULL, $rrule_values = NULL, $field, $item) {
422

  
423
  include_once(DRUPAL_ROOT . '/' . drupal_get_path('module', 'date_api') . '/date_api_ical.inc');
437
// @codingStandardsIgnoreEnd
438
  include_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'date_api') . '/date_api_ical.inc';
424 439
  $field_name = $field['field_name'];
425 440

  
426 441
  if (empty($rrule)) {
......
497 512
      'offset2' => date_offset_get($date_end),
498 513
      'timezone' => $timezone,
499 514
      'rrule' => $rrule,
500
      );
515
    );
501 516
  }
517

  
502 518
  return $value;
503 519
}
504 520

  
......
681 697
      '#title' => t('Repeat display', array(), array('context' => 'Date repeat')),
682 698
      '#description' => t("Should the repeat options form start out expanded or collapsed? Set to 'Collapsed' to make those options less obtrusive.", array(), array('context' => 'Date repeat')),
683 699
      '#fieldset' => 'date_format',
684
      );
700
    );
685 701
  }
686

  
687 702
}
688 703

  
689 704
/**

Formats disponibles : Unified diff