Projet

Général

Profil

Révision 3dfa8105

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

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/ds/views/views_plugin_ds_entity_view.inc
10 10
 */
11 11
class views_plugin_ds_entity_view extends views_plugin_row {
12 12

  
13
  protected $group_count;
14

  
13 15
  function init(&$view, &$display, $options = NULL) {
14 16
    parent::init($view, $display, $options);
15 17
    $this->base_table = $view->base_table;
......
18 20
      $this->base_table = 'node';
19 21
    }
20 22
    $this->base_field = $this->ds_views_3_support();
23

  
24
    $this->group_count = 0;
21 25
  }
22 26

  
23 27
  // Return base_field based on base_table. It might not be
......
59 63
    $options['grouping_fieldset'] = array(
60 64
      'contains' => array(
61 65
        'grouping' => array('default' => FALSE, 'bool' => TRUE),
66
        'group_odd_even' => array('default' => FALSE, 'bool' => TRUE),
62 67
        'group_field' => array('default' => ''),
63 68
        'group_field_function' => array('default' => ''),
64 69
      ),
......
241 246
      $form['grouping_fieldset']['grouping']['#description'] = t('Grouping is disabled because you do not have any sort fields.');
242 247
    }
243 248

  
249
    $form['grouping_fieldset']['group_odd_even'] = array(
250
      '#type' => 'checkbox',
251
      '#title' => t('Add odd/even group classes to the individual group elements'),
252
      '#default_value' => FALSE,
253
    );
254

  
244 255
    // Advanced function.
245 256
    $delta_fields = array();
246 257
    $field_api_fields = field_info_instances($this->entity_type);
......
362 373
   * Render each $row.
363 374
   */
364 375
  function render($row) {
365

  
366 376
    // Set a variable to indicate if comments need to be loaded or not.
367 377
    $load_comments = isset($this->options['load_comments']) ? $this->options['load_comments'] : FALSE;
368 378

  
......
440 450
      if (!isset($grouping[$view_name][$group_value])) {
441 451
        $group_value_content = '<h2 class="grouping-title">' . $group_value . '</h2>';
442 452
        $grouping[$view_name][$group_value] = $group_value;
453
        $this->group_count++;
443 454
      }
444 455
    }
445 456

  
......
448 459
      if (!empty($group_value_content)) {
449 460
        $content = $group_value_content . $content;
450 461
      }
451
      $content = '<div class="grouping-content">' . $content . '</div>';
462
      $classes = array('grouping-content');
463
      if ($this->options['grouping_fieldset']['group_odd_even']) {
464
        if ($this->group_count % 2 == 0) {
465
          $classes[] = 'even';
466
        }
467
        else {
468
          $classes[] = 'odd';
469
        }
470
      }
471

  
472
      $content = '<div class="' . implode(' ', $classes) . '">' . $content . '</div>';
452 473
    }
453 474

  
454 475
    // Return the content.

Formats disponibles : Unified diff