diff options
| author | Greg Roach <fisharebest@webtrees.net> | 2018-07-16 08:20:33 +0100 |
|---|---|---|
| committer | Greg Roach <fisharebest@webtrees.net> | 2018-07-16 08:20:33 +0100 |
| commit | c1010eda29c0909ed4d5d463f32d32bfefdd4dfe (patch) | |
| tree | fbb656ebc014aa1295ac8e6176f41e89f94b91e7 /app/Datatables.php | |
| parent | 782f08d9bd2bfa06635da947ee34f8e1afd65088 (diff) | |
| download | webtrees-c1010eda29c0909ed4d5d463f32d32bfefdd4dfe.tar.gz webtrees-c1010eda29c0909ed4d5d463f32d32bfefdd4dfe.tar.bz2 webtrees-c1010eda29c0909ed4d5d463f32d32bfefdd4dfe.zip | |
Use PSR2 code style
Diffstat (limited to 'app/Datatables.php')
| -rw-r--r-- | app/Datatables.php | 149 |
1 files changed, 84 insertions, 65 deletions
diff --git a/app/Datatables.php b/app/Datatables.php index 11a591f9c5..41ee001a83 100644 --- a/app/Datatables.php +++ b/app/Datatables.php @@ -22,73 +22,92 @@ use Fisharebest\Webtrees\Functions\FunctionsEdit; * * @link https://www.datatables.net */ -class Datatables { - /** - * Generate the HTML attributes for I18N. - * - * @param int[] $lengths - * - * @return string[] - */ - public static function languageAttributes(array $lengths = [10, 25, 100, -1]) { - $length_menu = FunctionsEdit::numericOptions($lengths); +class Datatables +{ + /** + * Generate the HTML attributes for I18N. + * + * @param int[] $lengths + * + * @return string[] + */ + public static function languageAttributes(array $lengths = [ + 10, + 25, + 100, + -1, + ]) + { + $length_menu = FunctionsEdit::numericOptions($lengths); - $language = [ - 'paginate' => [ - 'first' => /* I18N: A button label, first page */ I18N::translate('first'), - 'last' => /* I18N: A button label, last page */ I18N::translate('last'), - 'next' => /* I18N: A button label, next page */ I18N::translate('next'), - 'previous' => /* I18N: A button label, previous page */ I18N::translate('previous'), - ], - 'emptyTable' => I18N::translate('No records to display'), - 'info' => /* I18N: %s are placeholders for numbers */ I18N::translate('Showing %1$s to %2$s of %3$s', '_START_', '_END_', '_TOTAL_'), - 'infoEmpty' => I18N::translate('Showing %1$s to %2$s of %3$s', 0, 0, 0), - 'infoFiltered' => /* I18N: %s is a number */ I18N::translate('(filtered from %s total entries)', '_MAX_'), - 'lengthMenu' => /* I18N: %s is a number of records per page */ I18N::translate('Display %s', '_MENU_'), - 'loadingRecords' => I18N::translate('Loading…'), - 'processing' => I18N::translate('Calculating…'), - 'search' => I18N::translate('Filter'), - 'zeroRecords' => I18N::translate('No records to display'), - ]; + $language = [ + 'paginate' => [ + 'first' => /* I18N: A button label, first page */ + I18N::translate('first'), + 'last' => /* I18N: A button label, last page */ + I18N::translate('last'), + 'next' => /* I18N: A button label, next page */ + I18N::translate('next'), + 'previous' => /* I18N: A button label, previous page */ + I18N::translate('previous'), + ], + 'emptyTable' => I18N::translate('No records to display'), + 'info' => /* I18N: %s are placeholders for numbers */ + I18N::translate('Showing %1$s to %2$s of %3$s', '_START_', '_END_', '_TOTAL_'), + 'infoEmpty' => I18N::translate('Showing %1$s to %2$s of %3$s', 0, 0, 0), + 'infoFiltered' => /* I18N: %s is a number */ + I18N::translate('(filtered from %s total entries)', '_MAX_'), + 'lengthMenu' => /* I18N: %s is a number of records per page */ + I18N::translate('Display %s', '_MENU_'), + 'loadingRecords' => I18N::translate('Loading…'), + 'processing' => I18N::translate('Calculating…'), + 'search' => I18N::translate('Filter'), + 'zeroRecords' => I18N::translate('No records to display'), + ]; - return [ - 'data-language' => json_encode($language), - 'data-length-menu' => json_encode([array_keys($length_menu), array_values($length_menu)]) - ]; - } + return [ + 'data-language' => json_encode($language), + 'data-length-menu' => json_encode([ + array_keys($length_menu), + array_values($length_menu), + ]), + ]; + } - /** - * Generate the HTML attributes for a table of events. - * - * @return string - */ - public static function eventTableAttributes() { - return Html::attributes([ - 'class' => 'table table-bordered table-sm datatables table-event', - //'data-columns' => '[{ type: "text" }, { type: "num" }, { type: "num" }, { type: "text" }]', - 'data-columns' => '[null, null, null, null]', - 'data-info' => 'false', - 'data-paging' => 'false', - 'data-searching' => 'false', - 'data-state-save' => 'true', - ] + self::languageAttributes()); - } + /** + * Generate the HTML attributes for a table of events. + * + * @return string + */ + public static function eventTableAttributes() + { + return Html::attributes([ + 'class' => 'table table-bordered table-sm datatables table-event', + //'data-columns' => '[{ type: "text" }, { type: "num" }, { type: "num" }, { type: "text" }]', + 'data-columns' => '[null, null, null, null]', + 'data-info' => 'false', + 'data-paging' => 'false', + 'data-searching' => 'false', + 'data-state-save' => 'true', + ] + self::languageAttributes()); + } - /** - * Generate the HTML attributes for a table of given names. - * - * @return string - */ - public static function givenNameTableAttributes() { - return Html::attributes([ - 'class' => 'table table-bordered table-sm datatables table-given-name', - //'data-columns' => '[{ type: "text" }, { type: "num" }]', - 'data-columns' => '[null, null]', - 'data-info' => 'false', - 'data-paging' => 'false', - 'data-searching' => 'false', - 'data-state-save' => 'true', - 'data-order' => '[[1, "desc"]]', - ]); - } + /** + * Generate the HTML attributes for a table of given names. + * + * @return string + */ + public static function givenNameTableAttributes() + { + return Html::attributes([ + 'class' => 'table table-bordered table-sm datatables table-given-name', + //'data-columns' => '[{ type: "text" }, { type: "num" }]', + 'data-columns' => '[null, null]', + 'data-info' => 'false', + 'data-paging' => 'false', + 'data-searching' => 'false', + 'data-state-save' => 'true', + 'data-order' => '[[1, "desc"]]', + ]); + } } |
