diff --git a/datatables.theme.inc b/datatables.theme.inc index abbda06..44e6307 100644 --- a/datatables.theme.inc +++ b/datatables.theme.inc @@ -1,12 +1,12 @@ FALSE, // Disable filtering of data. * 'bInfo' => TRUE, // Show the table information display. - * 'aaSorting' => array( // Sort by 3rd column first, and then 4th column. - * array(2, 'asc'), - * array(3, 'desc'), - * ), - * ); + * 'aaSorting' => [ // Sort by 3rd column first, and then 4th column. + * [2, 'asc'], + * [3, 'desc'], + * ], + * ]; * @endcode * See http://datatables.net/usage/features and * http://datatables.net/usage/options for a full list of features and options. @@ -37,20 +37,20 @@ use Drupal\Component\Utility\Html; * columns in the $header parameter. * For example: * @code - * $header = array( - * array( + * $header = [ + * [ * 'data' => t('Column 1'), - * 'datatable_options' => array( + * 'datatable_options' => [ * 'bSortable' => TRUE, // Enable sorting on this column. - * ), - * ), - * array( + * ], + * ], + * [ * 'data' => t('Column 2'), - * 'datatable_options' => array( + * 'datatable_options' => [ * 'bSearchable' => FALSE, // Disable filtering on this column. - * ), - * ), - * ); + * ], + * ], + * ]; * @endcode * Note: if the aaColumns option is enabled in $parameters['datatable_options'], * then all datatable_options in the $header parameter will be ignored, since @@ -91,17 +91,18 @@ use Drupal\Component\Utility\Html; * - header: Indicates this cell is a header. * - Any HTML attributes, such as "colspan", to apply to the table cell. * Here's an example for $rows: + * * @code - * $rows = array( + * $rows = [ * // Simple row - * array( + * [ * 'Cell 1', 'Cell 2', 'Cell 3' - * ), + * ], * // Row with attributes on the row and some of its cells. - * array( - * 'data' => array('Cell 1', array('data' => 'Cell 2', 'colspan' => 2)), 'class' => array('funky') - * ), - * ); + * [ + * 'data' => ['Cell 1', ['data' => 'Cell 2', 'colspan' => 2)), 'class' => ['funky') + * ], + * ]; * @endcode * - footer: An array of table rows which will be printed within a
* tag, in the same format as the rows element (see above). @@ -117,23 +118,23 @@ use Drupal\Component\Utility\Html; * associative array of HTML attributes. * Here's an example for $colgroup: * @code - * $colgroup = array( + * $colgroup = [ * // COLGROUP with one COL element. - * array( - * array( - * 'class' => array('funky'), // Attribute for the COL element. - * ), - * ), + * [ + * [ + * 'class' => ['funky'), // Attribute for the COL element. + * ], + * ], * // Colgroup with attributes and inner COL elements. - * array( - * 'data' => array( - * array( - * 'class' => array('funky'), // Attribute for the COL element. - * ), - * ), - * 'class' => array('jazzy'), // Attribute for the COLGROUP element. - * ), - * ); + * [ + * 'data' => [ + * [ + * 'class' => ['funky'), // Attribute for the COL element. + * ], + * ], + * 'class' => ['jazzy'), // Attribute for the COLGROUP element. + * ], + * ]; * @endcode * These optional tags are used to group and set properties on columns * within a table. For example, one may easily group three columns and @@ -177,4 +178,4 @@ function template_preprocess_datatable(array &$variables) { } template_preprocess_table($variables); -} \ No newline at end of file +} diff --git a/src/Plugin/views/style/DataTables.php b/src/Plugin/views/style/DataTables.php index bb6d86f..01bdfb3 100644 --- a/src/Plugin/views/style/DataTables.php +++ b/src/Plugin/views/style/DataTables.php @@ -73,11 +73,10 @@ class DataTables extends Table { ]; $options['filter_columns'] = [ - 'default' => [ - ], + 'default' => [], ]; $options['filter_columns_placeholder'] = [ - 'default' => '- Filter -' + 'default' => '- Filter -', ]; return $options; @@ -192,7 +191,10 @@ class DataTables extends Table { '#type' => 'details', '#title' => $this->t('Searchable / Filterable Columns'), '#open' => FALSE, - '#description' => $this->t('Enable search on specific columns values by input or select in the table header or footer of the selected columns. Requires enabled "Search Filter Box"! To visually hide the search filter box, remove "f" from the sDOM parameter.', ['@inputExampleHref' => 'https://datatables.net/examples/api/multi_filter.html', '@selectExampleHref' => 'https://datatables.net/examples/api/multi_filter_select.html']), + '#description' => $this->t('Enable search on specific columns values by input or select in the table header or footer of the selected columns. Requires enabled "Search Filter Box"! To visually hide the search filter box, remove "f" from the sDOM parameter.', [ + '@inputExampleHref' => 'https://datatables.net/examples/api/multi_filter.html', + '@selectExampleHref' => 'https://datatables.net/examples/api/multi_filter_select.html', + ]), ]; $form['filter_columns']['filter_columns_placeholder'] = [ @@ -217,7 +219,7 @@ class DataTables extends Table { '' => $this->t('Disabled'), 'thead_select' => $this->t('Table Header: Select'), 'thead_input' => $this->t('Table Header: Input'), - // @todo: Drupal tables typically don't have a + // @todo Drupal tables typically don't have a // tfoot, so this doesn't work yet: // 'tfoot_select' => $this->t('Table Footer: Select'), // 'tfoot_input' => $this->t('Table Footer: Input'), @@ -252,7 +254,7 @@ class DataTables extends Table { } /** - * @inheritdoc + * {@inheritdoc} */ public function validateOptionsForm(&$form, FormStateInterface $form_state) { parent::validateOptionsForm($form, $form_state); diff --git a/datatables.module b/datatables.module index 9769b46..67c6737 100644 --- a/datatables.module +++ b/datatables.module @@ -52,7 +52,7 @@ function template_preprocess_views_view_datatables(&$variables) { switch ($options['hidden_columns'][$field]) { case 'expandable': $datatable_options['bExpandable'] = TRUE; - // ... and fall through, since expandable columns are also hidden. + // ... and fall through, since expandable columns are also hidden. case 'hidden': // Hidden or expandable columns get the bVisible init option set to // false. @@ -63,7 +63,7 @@ function template_preprocess_views_view_datatables(&$variables) { // Render the header labels. if ($field == $column && empty($fields[$field]->options['exclude'])) { // Respect the "empty_column" option: - if($options['info'][$field]['empty_column'] && empty($variables['header'][$column])) { + if ($options['info'][$field]['empty_column'] && empty($variables['header'][$column])) { // This column is empty and was already removed. Don't do anything here. continue; } @@ -169,7 +169,7 @@ function template_preprocess_views_view_datatables(&$variables) { 'sInfo' => t('Showing @START to @END of @TOTAL entries', [ '@START' => '_START_', '@END' => '_END_', - '@TOTAL' => '_TOTAL_' + '@TOTAL' => '_TOTAL_', ]), 'sInfoEmpty' => t('Showing 0 to 0 of 0 entries'), 'sInfoFiltered' => t('(filtered from @MAX total entries)', ['@MAX' => '_MAX_']),