Projet

Général

Profil

Révision 950416da

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

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/field_collection/field_collection.module
40 40
 */
41 41
function field_collection_form_field_ui_field_overview_form_alter(&$form, &$form_state) {
42 42
  if (count($form['#fields'])) {
43
    foreach($form['fields'] as $fieldname => $field) {
43
    foreach ($form['fields'] as $fieldname => $field) {
44 44
      if (!isset($field['type']['#title'])) {
45 45
        continue;
46 46
      }
......
87 87
      'full' => array(
88 88
        'label' => t('Full content'),
89 89
        'custom settings' => FALSE,
90
       ),
90
      ),
91 91
    ),
92 92
    'access callback' => 'field_collection_item_access',
93 93
    'deletion callback' => 'field_collection_item_delete',
......
145 145
 * @param $entity_type
146 146
 * @param $entity
147 147
 *
148
 * @return
148
 * @return string
149 149
 *   A language code
150 150
 */
151 151
function field_collection_entity_language($entity_type, $entity) {
......
172 172
/**
173 173
 * Loads a field collection item.
174 174
 *
175
 * @return field_collection_item
175
 * @return
176 176
 *   The field collection item entity or FALSE.
177 177
 */
178 178
function field_collection_item_load($item_id, $reset = FALSE) {
......
322 322
 */
323 323
function field_collection_permission() {
324 324
  return array(
325
    'administer field collections' =>  array(
325
    'administer field collections' => array(
326 326
      'title' => t('Administer field collections'),
327 327
      'description' => t('Create and delete fields on field collections.'),
328 328
    ),
......
558 558
          if (!isset($cleared_host_entity_cache)) {
559 559
            list($entity_id) = entity_extract_ids($host_entity_type, $host_entity);
560 560
            entity_get_controller($host_entity_type)->resetCache(array($entity_id));
561
            $cleared_host_entity_cache = true;
561
            $cleared_host_entity_cache = TRUE;
562 562
          }
563 563
          $is_default = entity_revision_is_default($host_entity_type, $host_entity);
564 564
          // If an entity type does not support saving non-default entities,
......
761 761
    'field_collection_list' => array(
762 762
      'label' => t('Links to field collection items'),
763 763
      'field types' => array('field_collection'),
764
      'settings' =>  array(
764
      'settings' => array(
765 765
        'edit' => t('Edit'),
766 766
        'translate' => t('Translate'),
767 767
        'delete' => t('Delete'),
......
772 772
    'field_collection_view' => array(
773 773
      'label' => t('Field collection items'),
774 774
      'field types' => array('field_collection'),
775
      'settings' =>  array(
775
      'settings' => array(
776 776
        'edit' => t('Edit'),
777
        'translate' => t('Translate'),
777 778
        'delete' => t('Delete'),
778 779
        'add' => t('Add'),
779 780
        'description' => TRUE,
......
783 784
    'field_collection_fields' => array(
784 785
      'label' => t('Fields only'),
785 786
      'field types' => array('field_collection'),
786
      'settings' =>  array(
787
      'settings' => array(
787 788
        'view_mode' => 'full',
788 789
      ),
789 790
    ),
......
814 815
    $elements['translate'] = array(
815 816
      '#type' => 'textfield',
816 817
      '#title' => t('Translate link title'),
817
      '#default_value' => $settings['translate'],
818
      '#default_value' => isset($settings['translate']) ? $settings['translate'] : '',
818 819
      '#description' => t('Leave the title empty, to hide the link.'),
819 820
      '#access' => field_collection_item_is_translatable(),
820 821
    );
......
874 875
  if ($display['type'] !== 'field_collection_list') {
875 876
    $entity_type = entity_get_info('field_collection_item');
876 877
    if (!empty($entity_type['view modes'][$settings['view_mode']]['label'])) {
877
      $output[] =  t('View mode: @mode', array('@mode' => $entity_type['view modes'][$settings['view_mode']]['label']));
878
      $output[] = t('View mode: @mode', array('@mode' => $entity_type['view modes'][$settings['view_mode']]['label']));
878 879
    }
879 880
  }
880 881

  
......
915 916
      $view_mode = !empty($display['settings']['view_mode']) ? $display['settings']['view_mode'] : 'full';
916 917
      foreach ($items as $delta => $item) {
917 918
        if ($field_collection = field_collection_field_get_entity($item)) {
918
          $element[$delta]['entity'] = $field_collection->view($view_mode);
919
          $element[$delta]['entity'] = $field_collection->view($view_mode, $langcode);
919 920
          $element[$delta]['#theme_wrappers'] = array('field_collection_view');
920 921
          $element[$delta]['#attributes']['class'][] = 'field-collection-view';
921 922
          $element[$delta]['#attributes']['class'][] = 'clearfix';
......
948 949
      $view_mode = !empty($display['settings']['view_mode']) ? $display['settings']['view_mode'] : 'full';
949 950
      foreach ($items as $delta => $item) {
950 951
        if ($field_collection = field_collection_field_get_entity($item)) {
951
          $element[$delta]['entity'] = $field_collection->view($view_mode);
952
          $element[$delta]['entity'] = $field_collection->view($view_mode, $langcode);
952 953
        }
953 954
      }
954 955
      break;
......
997 998
      $path = field_collection_field_get_path($field);
998 999
      list($id) = entity_extract_ids($entity_type, $entity);
999 1000
      $element['#suffix'] = '';
1000
      if (!empty($settings['description'])) {
1001
      if (!empty($settings['description']) && $entity_type != 'node') {
1001 1002
        $element['#suffix'] .= '<div class="description field-collection-description">' . field_filter_xss($instance['description']) . '</div>';
1002 1003
      }
1003 1004
      $title = entity_i18n_string("field:{$field['field_name']}:{$instance['bundle']}:setting_add", $settings['add']);
......
1177 1178
          '#value' => t('Remove'),
1178 1179
          '#validate' => array(),
1179 1180
          '#submit' => array('field_collection_remove_submit'),
1181
          '#attributes' => array('class' => array('remove-button')),
1180 1182
          '#limit_validation_errors' => array(),
1181 1183
          '#ajax' => array(
1182 1184
            // 'wrapper' is filled in field_collection_field_attach_form().
......
1430 1432
 *   The entity object or FALSE.
1431 1433
 */
1432 1434
function field_collection_field_get_entity(&$item, $field_name = NULL) {
1433
  if (isset($item['entity'])) {
1435
  if (isset($item['entity']) && ($item['entity']->entityType() == 'field_collection_item')) {
1434 1436
    return $item['entity'];
1435 1437
  }
1436 1438
  elseif (isset($item['value'])) {
......
1530 1532

  
1531 1533
      // Copied from _form_validate().
1532 1534
      if (isset($elements['#needs_validation'])) {
1533
        $is_empty_multiple = (!count($elements['#value']));
1535
        $is_countable = is_array($elements['#value']) || $elements['#value'] instanceof Countable;
1536
        $is_empty_multiple = $is_countable && (!count($elements['#value']));
1534 1537
        $is_empty_string = (is_string($elements['#value']) && drupal_strlen(trim($elements['#value'])) == 0);
1535 1538
        $is_empty_value = ($elements['#value'] === 0);
1536 1539
        $is_empty_option = (isset($elements['#options']['_none']) && $elements['#value'] == '_none');

Formats disponibles : Unified diff