diff --git a/_admin.php b/_admin.php
index 6fc9b54..1fa7a86 100644
--- a/_admin.php
+++ b/_admin.php
@@ -25,6 +25,10 @@ $core->addBehavior(
'adminBeforeBlogSettingsUpdate',
['adminPeriodical', 'adminBeforeBlogSettingsUpdate']
);
+$core->addBehavior(
+ 'adminFiltersLists',
+ ['adminPeriodical', 'adminFiltersLists']
+);
if ($core->blog->settings->periodical->periodical_active) {
@@ -79,6 +83,15 @@ class adminPeriodical
{
public static $combo_period = null;
+ public static function sortbyCombo()
+ {
+ return [
+ __('Next update') => 'periodical_curdt',
+ __('End date') => 'periodical_enddt',
+ __('Frequence') => 'periodical_pub_int'
+ ];
+ }
+
/**
* Add settings to blog preference
*
@@ -87,32 +100,20 @@ class adminPeriodical
*/
public static function adminBlogPreferencesForm(dcCore $core, dcSettings $blog_settings)
{
- $sortby_combo = [
- __('Create date') => 'post_creadt',
- __('Date') => 'post_dt',
- __('Id') => 'post_id'
- ];
- $order_combo = [
- __('Descending') => 'desc',
- __('Ascending') => 'asc'
- ];
-
$s_active = (boolean) $blog_settings->periodical->periodical_active;
$s_upddate = (boolean) $blog_settings->periodical->periodical_upddate;
$s_updurl = (boolean) $blog_settings->periodical->periodical_updurl;
- $e_order = (string) $blog_settings->periodical->periodical_pub_order;
- $e_order = explode(' ', $e_order);
- $s_sortby = in_array($e_order[0], $sortby_combo) ? $e_order[0] : 'post_dt';
- $s_order = isset($e_order[1]) && strtolower($e_order[1]) == 'desc' ? 'desc' : 'asc';
echo
- '
' . __('Periodical') . '
' .
+ '
' . __('Periodical') . '
' .
'
' .
'
' .
'
' . __('Activation') . '
' .
'
' .
+ '
' .
+ '
' .
'
' . __('Dates of published entries') . '
' .
'
' .
'
' .
- '
' .
- '
' . __('Order of publication of entries') . '
' .
- '
' .
- form::combo('periodical_sortby', $sortby_combo, $s_sortby) . '
' .
- '
' .
- form::combo('periodical_order', $order_combo, $s_order) . '
' .
- '
' .
'
' .
'
' .
'
';
@@ -143,7 +137,17 @@ class adminPeriodical
$blog_settings->periodical->put('periodical_active', !empty($_POST['periodical_active']));
$blog_settings->periodical->put('periodical_upddate', !empty($_POST['periodical_upddate']));
$blog_settings->periodical->put('periodical_updurl', !empty($_POST['periodical_updurl']));
- $blog_settings->periodical->put('periodical_pub_order', $_POST['periodical_sortby'] . ' ' . $_POST['periodical_order']);
+ }
+
+ public static function adminFiltersLists(dcCore $core, $sorts)
+ {
+ $sorts['periodical'] = [
+ __('Periodical'),
+ self::sortbyCombo(),
+ 'periodical_curdt',
+ 'desc',
+ [__('periods per page'), 10]
+ ];
}
/**
diff --git a/index.php b/index.php
index ca5def4..cdc1751 100644
--- a/index.php
+++ b/index.php
@@ -442,13 +442,11 @@ if ($part == 'period') {
';
echo
- dcPage::breadcrumb(
- [
+ dcPage::breadcrumb([
html::escapeHTML($core->blog->name) => '',
__('Periodical') => $p_url . '&part=periods',
(null === $period_id ? __('New period') : __('Edit period')) => ''
- ]
- ) .
+ ]) .
dcPage::notices();
# Period form
@@ -655,49 +653,16 @@ if ($part == 'period') {
}
}
- # Combos
- $sortby_combo = [
- __('Next update') => 'periodical_curdt',
- __('End date') => 'periodical_enddt',
- __('Frequence') => 'periodical_pub_int'
+ $combo_action = [
+ __('empty periods') => 'emptyperiods',
+ __('delete periods') => 'deleteperiods'
];
- $order_combo = [
- __('Descending') => 'desc',
- __('Ascending') => 'asc'
- ];
-
- $combo_action = [];
- $combo_action[__('empty periods')] = 'emptyperiods';
- $combo_action[__('delete periods')] = 'deleteperiods';
-
# Filters
- $sortby = !empty($_GET['sortby']) ? $_GET['sortby'] : 'periodical_curdt';
- $order = !empty($_GET['order']) ? $_GET['order'] : 'desc';
+ $p_filter = new adminGenericFilter($core, 'periodical');
+ $p_filter->add('part', 'period');
- $show_filters = false;
-
- $page = !empty($_GET['page']) ? (integer) $_GET['page'] : 1;
- $nb_per_page = 30;
-
- if (!empty($_GET['nb']) && (integer) $_GET['nb'] > 0) {
- if ($nb_per_page != $_GET['nb']) {
- $show_filters = true;
- }
- $nb_per_page = (integer) $_GET['nb'];
- }
-
- $params['limit'] = [(($page-1)*$nb_per_page), $nb_per_page];
-
- if ($sortby !== '' && in_array($sortby, $sortby_combo)) {
- if ($order !== '' && in_array($order, $order_combo)) {
- $params['order'] = $sortby . ' ' . $order;
- }
-
- if ($sortby != 'periodical_curdt' || $order != 'desc') {
- $show_filters = true;
- }
- }
+ $params = $p_filter->params();
# Get periods
try {
@@ -711,25 +676,8 @@ if ($part == 'period') {
# Display
echo
'
' . __('Periodical') . '' .
- dcPage::jsLoad(
- 'index.php?pf=periodical/js/periodsfilter.js'
- ) .
- '\n" .
+ //dcPage::jsLoad('index.php?pf=periodical/js/periodsfilter.js') .
+ $p_filter->js($core->adminurl->get('admin.plugin.periodical', ['part' => 'periods'])) .
'' .
'' .
@@ -745,44 +693,11 @@ if ($part == 'period') {
' . __('New period') . '
';
- # Filter
- echo
- '
';
+ # Filters
+ $p_filter->display('admin.plugin.periodical', form::hidden('p', 'periodical') . form::hidden('part', 'periods'));
# Posts list
- echo $period_list->periodDisplay($page, $nb_per_page,
+ echo $period_list->periodDisplay($p_filter->page, $p_filter->nb,
'
' .
''
@@ -808,10 +718,4 @@ if ($part == 'period') {
dcPage::helpBlock('periodical');
-# Page footer
-echo
-'
-periodical - '. $core->plugins->moduleInfo('periodical', 'version') . '
-
-
-';
\ No newline at end of file
+echo '