Further modules included.
[yaffs-website] / web / modules / contrib / views_responsive_grid / lib / Drupal / views_responsive_grid / Plugin / views / style / ResponsiveGrid.php
1 <?php
2
3 /**
4  * @file
5  * Definition of Drupal\views_responsive_grid\Plugin\views\style\ResponsiveGrid.
6  */
7
8 namespace Drupal\views_responsive_grid\Plugin\views\style;
9
10 use Drupal\views\Plugin\views\style\StylePluginBase;
11 use Drupal\Component\Annotation\Plugin;
12 use Drupal\Core\Annotation\Translation;
13
14 /**
15  * Style plugin to render each item in a responsive grid "cell".
16  *
17  * @ingroup views_style_plugins
18  *
19  * @Plugin(
20  *   id = "responsive_grid",
21  *   module = "views_responsive_grid",
22  *   title = @Translation("Responsive grid"),
23  *   help = @Translation("Displays rows in a responsive grid."),
24  *   theme = "views_view_responsive_grid",
25  *   theme_file = "views_responsive_grid.theme.inc",
26  *   display_types = {"normal"}
27  * )
28  */
29 class ResponsiveGrid extends StylePluginBase {
30
31   /**
32    * Does the style plugin allows to use style plugins.
33    *
34    * @var bool
35    */
36   protected $usesRowPlugin = TRUE;
37
38   /**
39    * Does the style plugin support custom css class for the rows.
40    *
41    * @var bool
42    */
43   protected $usesRowClass = TRUE;
44
45   /**
46    * Set default options
47    */
48   function defineOptions() {
49     $options = parent::defineOptions();
50     $options['columns'] = array('default' => '4');
51     $options['automatic_width'] = array('default' => TRUE, 'bool' => TRUE);
52     $options['alignment'] = array('default' => 'horizontal');
53     $options['col_class'] = array('default' => '');
54     $options['default_col_class'] = array('default' => TRUE, 'bool' => TRUE);
55     $options['col_class_special'] = array('default' => TRUE, 'bool' => TRUE);
56     return $options;
57   }
58
59   /**
60    * Build the options form.
61    */
62   function buildOptionsForm(&$form, &$form_state) {
63     parent::buildOptionsForm($form, $form_state);
64     if (!empty($form['uses_fields'])) {
65       $form['uses_fields']['#weight'] = -10;
66     }
67     $form['default_row_class']['#description'] = t('Add the default row classes like views-row, row-1 and clearfix to the output. You can use this to quickly reduce the amount of markup the view provides by default, at the cost of making it more difficult to apply CSS.');
68     $form['row_class_special']['#description'] = t('Add css classes to the first and last rows, as well as odd/even classes for striping.');
69     $form['columns'] = array(
70       '#type' => 'number',
71       '#title' => t('Number of columns'),
72       '#default_value' => $this->options['columns'],
73       '#required' => TRUE,
74       '#min' => 0,
75       '#weight' => -9,
76     );
77     $form['automatic_width'] = array(
78       '#type' => 'checkbox',
79       '#title' => t('Automatic width'),
80       '#description' => t('The width of each column will be calculated automatically based on the number of columns entered. If additional classes are entered or a theme injects additional classes based on a grid system, disabling this option may prove beneficial.'),
81       '#default_value' => $this->options['automatic_width'],
82       '#weight' => -8,
83     );
84     $form['alignment'] = array(
85       '#type' => 'radios',
86       '#title' => t('Alignment'),
87       '#options' => array('horizontal' => t('Horizontal'), 'vertical' => t('Vertical')),
88       '#default_value' => $this->options['alignment'],
89       '#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.'),
90       '#weight' => -7,
91     );
92     $form['col_class'] = array(
93       '#title' => t('Column class'),
94       '#description' => t('The class to provide on each column.'),
95       '#type' => 'textfield',
96       '#default_value' => $this->options['col_class'],
97     );
98     if ($this->usesFields()) {
99       $form['col_class']['#description'] .= ' ' . t('You may use field tokens from as per the "Replacement patterns" used in "Rewrite the output of this field" for all fields.');
100     }
101     $form['default_col_class'] = array(
102       '#title' => t('Add views column classes'),
103       '#description' => t('Add the default column classes like views-col, col-1 and clearfix to the output. You can use this to quickly reduce the amount of markup the view provides by default, at the cost of making it more difficult to apply CSS.'),
104       '#type' => 'checkbox',
105       '#default_value' => $this->options['default_col_class'],
106     );
107     $form['col_class_special'] = array(
108       '#title' => t('Add striping (odd/even), first/last column classes'),
109       '#description' => t('Add css classes to the first and last columns, as well as odd/even classes for striping.'),
110       '#type' => 'checkbox',
111       '#default_value' => $this->options['col_class_special'],
112     );
113   }
114
115 }