Projet

Général

Profil

Paste
Télécharger (2,39 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / views / plugins / views_plugin_style_grid.inc @ 5d12d676

1
<?php
2

    
3
/**
4
 * @file
5
 * Definition of views_plugin_style_grid.
6
 */
7

    
8
/**
9
 * Style plugin to render each item in a grid cell.
10
 *
11
 * @ingroup views_style_plugins
12
 */
13
class views_plugin_style_grid extends views_plugin_style {
14

    
15
  /**
16
   * Set default options.
17
   */
18
  public function option_definition() {
19
    $options = parent::option_definition();
20

    
21
    $options['columns'] = array('default' => '4');
22
    $options['alignment'] = array('default' => 'horizontal');
23
    $options['fill_single_line'] = array('default' => TRUE, 'bool' => TRUE);
24
    $options['summary'] = array('default' => '');
25
    $options['caption'] = array('default' => '');
26

    
27
    return $options;
28
  }
29

    
30
  /**
31
   * Render the given style.
32
   */
33
  public function options_form(&$form, &$form_state) {
34
    parent::options_form($form, $form_state);
35
    $form['columns'] = array(
36
      '#type' => 'textfield',
37
      '#title' => t('Number of columns'),
38
      '#default_value' => $this->options['columns'],
39
      '#required' => TRUE,
40
      '#element_validate' => array('views_element_validate_integer'),
41
    );
42
    $form['alignment'] = array(
43
      '#type' => 'radios',
44
      '#title' => t('Alignment'),
45
      '#options' => array('horizontal' => t('Horizontal'), 'vertical' => t('Vertical')),
46
      '#default_value' => $this->options['alignment'],
47
      '#description' => t('Horizontal alignment will place items starting in the upper left and moving right. Vertical alignment will place items starting in the upper left and moving down.'),
48
    );
49

    
50
    $form['fill_single_line'] = array(
51
      '#type' => 'checkbox',
52
      '#title' => t('Fill up single line'),
53
      '#description' => t('If you disable this option, a grid with only one row will have the same number of table cells (<TD>) as items. Disabling it can cause problems with your CSS.'),
54
      '#default_value' => !empty($this->options['fill_single_line']),
55
    );
56

    
57
    $form['caption'] = array(
58
      '#type' => 'textfield',
59
      '#title' => t('Short description of table'),
60
      '#description' => t('Include a caption for better accessibility of your table.'),
61
      '#default_value' => $this->options['caption'],
62
    );
63

    
64
    $form['summary'] = array(
65
      '#type' => 'textfield',
66
      '#title' => t('Table summary'),
67
      '#description' => t('This value will be displayed as table-summary attribute in the html. Use this to give a summary of complex tables.'),
68
      '#default_value' => $this->options['summary'],
69
    );
70
  }
71

    
72
}