diff --git a/plugins/views_plugin_style_grid.inc b/plugins/views_plugin_style_grid.inc index 9be7ee1..a2e4375 100644 --- a/plugins/views_plugin_style_grid.inc +++ b/plugins/views_plugin_style_grid.inc @@ -21,6 +21,7 @@ class views_plugin_style_grid extends views_plugin_style { $options['alignment'] = array('default' => 'horizontal'); $options['fill_single_line'] = array('default' => TRUE, 'bool' => TRUE); $options['summary'] = array('default' => ''); + $options['caption'] = array('default' => ''); return $options; } @@ -52,10 +53,17 @@ class views_plugin_style_grid extends views_plugin_style { '#default_value' => !empty($this->options['fill_single_line']), ); + $form['caption'] = array( + '#type' => 'textfield', + '#title' => t('Short description of table'), + '#description' => t('Include a caption for better accessibility of your table.'), + '#default_value' => $this->options['caption'], + ); + $form['summary'] = array( '#type' => 'textfield', '#title' => t('Table summary'), - '#description' => t('This value will be displayed as table-summary attribute in the html. Set this for better accessiblity of your site.'), + '#description' => t('This value will be displayed as table-summary attribute in the html. Use this to give a summary of complex tables.'), '#default_value' => $this->options['summary'], ); } diff --git a/plugins/views_plugin_style_table.inc b/plugins/views_plugin_style_table.inc index 98919ab..45ed976 100644 --- a/plugins/views_plugin_style_table.inc +++ b/plugins/views_plugin_style_table.inc @@ -33,6 +33,7 @@ class views_plugin_style_table extends views_plugin_style { $options['override'] = array('default' => TRUE, 'bool' => TRUE); $options['sticky'] = array('default' => FALSE, 'bool' => TRUE); $options['order'] = array('default' => 'asc'); + $options['caption'] = array('default' => '', 'translatable' => TRUE); $options['summary'] = array('default' => '', 'translatable' => TRUE); $options['empty_table'] = array('default' => FALSE, 'bool' => TRUE); @@ -179,10 +180,18 @@ class views_plugin_style_table extends views_plugin_style { '#description' => t('(Sticky header effects will not be active for preview below, only on live output.)'), ); + $form['caption'] = array( + '#type' => 'textfield', + '#title' => t('Short description of table'), + '#description' => t('Include a caption for better accessibility of your table.'), + '#default_value' => $this->options['caption'], + '#maxlength' => 255, + ); + $form['summary'] = array( '#type' => 'textfield', '#title' => t('Table summary'), - '#description' => t('This value will be displayed as table-summary attribute in the html. Set this for better accessiblity of your site.'), + '#description' => t('This value will be displayed as table-summary attribute in the html. Use this to give a summary of complex tables.'), '#default_value' => $this->options['summary'], '#maxlength' => 255, ); diff --git a/theme/theme.inc b/theme/theme.inc index 52598d5..97d5250 100644 --- a/theme/theme.inc +++ b/theme/theme.inc @@ -649,8 +649,17 @@ function template_preprocess_views_view_table(&$vars) { } $vars['classes_array'][] = 'cols-'. count($vars['header']); + // Add the summary to the list if set. if (!empty($handler->options['summary'])) { - $vars['attributes_array'] = array('summary' => $handler->options['summary']); + $vars['attributes_array'] = array('summary' => filter_xss_admin($handler->options['summary'])); + } + + // Add the caption to the list if set. + if (!empty($handler->options['caption'])) { + $vars['caption'] = filter_xss_admin($handler->options['caption']); + } + else { + $vars['caption'] = ''; } } @@ -762,8 +771,18 @@ function template_preprocess_views_view_grid(&$vars) { } $vars['rows'] = $rows; $vars['class'] = 'views-view-grid cols-' . $columns; + + // Add the summary to the list if set. if (!empty($handler->options['summary'])) { - $vars['attributes_array'] = array('summary' => $handler->options['summary']); + $vars['attributes_array'] = array('summary' => filter_xss_admin($handler->options['summary'])); + } + + // Add the caption to the list if set. + if (!empty($handler->options['caption'])) { + $vars['caption'] = filter_xss_admin($handler->options['caption']); + } + else { + $vars['caption'] = ''; } } diff --git a/theme/views-view-grid.tpl.php b/theme/views-view-grid.tpl.php index cd8d39e..09f807a 100644 --- a/theme/views-view-grid.tpl.php +++ b/theme/views-view-grid.tpl.php @@ -14,6 +14,10 @@

> + + + + $columns): ?> > diff --git a/theme/views-view-table.tpl.php b/theme/views-view-table.tpl.php index a9abcd3..4fec9fa 100644 --- a/theme/views-view-table.tpl.php +++ b/theme/views-view-table.tpl.php @@ -6,6 +6,7 @@ * * - $title : The title of this group of rows. May be empty. * - $header: An array of header labels keyed by field id. + * - $caption: The caption for this table. May be empty. * - $header_classes: An array of header classes keyed by field id. * - $fields: An array of CSS IDs to use for each field id. * - $classes: A class or classes to apply to the table, based on settings. @@ -19,8 +20,8 @@ */ ?>
> - - + +