From fbda59abe3ccc8f045ba2ef2f16296b304f6e2cf Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Wed, 29 Sep 2021 01:01:25 +0200 Subject: [PATCH] add user pref on filters options --- CHANGELOG.md | 3 ++- README.md | 2 +- _admin.php | 37 +++++++++++++++++++++++++++++++------ index.php | 27 +++++++++++++++++---------- 4 files changed, 51 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eb68659..8960274 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,10 @@ 0.8.1 - dev - [ ] update public templates - [ ] fix javascript +- add user pref on sort filters (dc 2.20) 0.9 - 2021.09.11 -- add user pref on cinecturlink list +- add user pref on table columns - fix typo in admin menu 0.8 - 2021.09.09 diff --git a/README.md b/README.md index 9cfb201..4e8945b 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![Release version](https://img.shields.io/github/v/release/JcDenis/cinecturlink2)](https://github.com/JcDenis/cinecturlink2/releases) [![Release date](https://img.shields.io/github/release-date/JcDenis/cinecturlink2)](https://github.com/JcDenis/cinecturlink2/releases) -[![Issue tracking](https://img.shields.io/github/issues/JcDenis/cinecturlink2)](https://github.com/JcDenis/pacKman/issues) +[![Issue tracking](https://img.shields.io/github/issues/JcDenis/cinecturlink2)](https://github.com/JcDenis/cinecturlink2/issues) [![Dotclear version](https://img.shields.io/badge/dotclear-v2.19-blue.svg)](https://fr.dotclear.org/download) [![License](https://img.shields.io/badge/license-GPL%20v2-blue.svg)](https://github.com/JcDenis/cinecturlink2/blob/master/LICENSE) diff --git a/_admin.php b/_admin.php index c0c3ab9..e9210b8 100644 --- a/_admin.php +++ b/_admin.php @@ -32,6 +32,11 @@ $core->addBehavior( 'adminColumnsLists', ['cinecturlink2AdminBehaviors', 'adminColumnsLists'] ); + +$core->addBehavior( + 'adminSortsLists', + ['cinecturlink2AdminBehaviors', 'adminSortsLists'] +); $core->addBehavior( 'adminDashboardFavorites', ['cinecturlink2AdminBehaviors', 'adminDashboardFavorites'] @@ -42,17 +47,37 @@ class cinecturlink2AdminBehaviors public static function adminColumnsLists($core, $cols) { $cols['c2link'] = [ - __('Cinecturlink'), [ - 'date' => [true, __('Date')], - 'cat' => [true, __('Category')], + __('Cinecturlink'), + [ + 'date' => [true, __('Date')], + 'cat' => [true, __('Category')], 'author' => [true, __('Author')], - 'desc' => [false, _('Category')], - 'link' => [true, _('Liens')], - 'note' => [true, __('Rating')], + 'desc' => [false, __('Description')], + 'link' => [true, __('Liens')], + 'note' => [true, __('Rating')], ] ]; } + public static function adminSortsLists($core, $sorts) + { + $sorts['c2link'] = [ + __('Cinecturlink'), + [ + __('Date') => 'link_upddt', + __('Title') => 'link_title', + __('Category') => 'cat_id', + __('Author') => 'link_author', + __('Description') => 'link_desc', + __('Link') => 'link_url', + __('Rating') => 'link_note' + ], + 'link_upddt', + 'desc', + null + ]; + } + public static function adminDashboardFavorites($core, $favs) { $favs->register('cinecturlink2', [ diff --git a/index.php b/index.php index 4978b87..d89f487 100644 --- a/index.php +++ b/index.php @@ -137,10 +137,13 @@ if ($part == 'updlinkscat') { if ($part == 'links') { $sortby_combo = [ - __('Date') => 'link_upddt', - __('Title') => 'link_title', - __('Category') => 'cat_title', - __('Rating') => 'link_note', + __('Date') => 'link_upddt', + __('Title') => 'link_title', + __('Category') => 'cat_id', + __('Author') => 'link_author', + __('Description') => 'link_desc', + __('Liens') => 'link_url', + __('Rating') => 'link_note' ]; $order_combo = [ __('Descending') => 'desc', @@ -154,9 +157,13 @@ if ($part == 'links') { $show_filters = false; $page = !empty($_GET['page']) ? max(1, (integer) $_GET['page']) : 1; - $nb_per_page = $core->auth->user_prefs->interface->nb_posts_per_page ?: 30; - $default_sortby = 'link_upddt'; - $default_order = 'desc'; + + $core->auth->user_prefs->addWorkspace('interface'); + $sorts_user = @$core->auth->user_prefs->interface->sorts; + $default_sortby = $sorts_user['c2link'][0] ?? 'link_upddt'; + $default_order = $sorts_user['c2link'][1] ?? 'desc'; + $nb_per_page = !empty($sorts_user['c2link'][2]) ? $sorts_user['c2link'][2] : 30; + $sortby = !empty($_GET['sortby']) ? $_GET['sortby'] : $default_sortby; $order = !empty($_GET['order']) ? $_GET['order'] : $default_order; @@ -562,12 +569,12 @@ if ($part == "links") { form::combo('order', $order_combo, $order) . '

' . '
' . '

' . __('Show') . '

' . form::hidden('p', 'cinecturlink2') . form::hidden('part', 'links') . - //form::hidden('filters-options-id', 'c2links') . - //'

' . __('Save current options') . '

' . + form::hidden('filters-options-id', 'c2link') . + '

' . __('Save current options') . '

' . '
' . '' .