Projet

Général

Profil

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

root / drupal7 / sites / all / modules / views / plugins / views_plugin_style_grid.inc @ 7547bb19

1
<?php
2

    
3
/**
4
 * @file
5
 * Contains the grid style plugin.
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
   * Set default options
16
   */
17
  function option_definition() {
18
    $options = parent::option_definition();
19

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

    
26
    return $options;
27
  }
28

    
29
  /**
30
   * Render the given style.
31
   */
32
  function options_form(&$form, &$form_state) {
33
    parent::options_form($form, $form_state);
34
    $form['columns'] = array(
35
      '#type' => 'textfield',
36
      '#title' => t('Number of columns'),
37
      '#default_value' => $this->options['columns'],
38
      '#required' => TRUE,
39
      '#element_validate' => array('views_element_validate_integer'),
40
    );
41
    $form['alignment'] = array(
42
      '#type' => 'radios',
43
      '#title' => t('Alignment'),
44
      '#options' => array('horizontal' => t('Horizontal'), 'vertical' => t('Vertical')),
45
      '#default_value' => $this->options['alignment'],
46
      '#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.'),
47
    );
48

    
49
    $form['fill_single_line'] = array(
50
      '#type' => 'checkbox',
51
      '#title' => t('Fill up single line'),
52
      '#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.'),
53
      '#default_value' => !empty($this->options['fill_single_line']),
54
    );
55

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

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