From 5d0aa3956179948cd016291b9bb1df1a4432f92e Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Wed, 27 Apr 2022 11:16:43 +0200 Subject: [PATCH] fix browser date picker, fix sql query (fix #1 ) --- CHANGELOG.md | 5 +++++ README.md | 2 +- _define.php | 4 ++-- _install.php | 2 +- dcstore.xml | 6 +++--- inc/class.periodical.php | 7 +++++-- inc/index.period.php | 22 ++++++++++++++-------- 7 files changed, 31 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d609b8..880fe83 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +2022.04.27 +- require Dotclear 2.21.3 +- fix browser date picker +- fix sql query on posts + 2021.10.30 - required Dotclear 2.20 - add user pref filters for periods list diff --git a/README.md b/README.md index a19ab78..6163216 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ and they will be publish ones after the others every week. * admin permissions to configure plugin * usage,contentadmin permissions to link feeds - * Dotclear 2.19 + * Dotclear 2.21.3 ## NOTICE diff --git a/_define.php b/_define.php index 7f9e2c5..c2f5636 100644 --- a/_define.php +++ b/_define.php @@ -19,9 +19,9 @@ $this->registerModule( 'Periodical', 'Published periodically entries', 'Jean-Christian Denis and contributors', - '2021.10.30', + '2022.04.27', [ - 'requires' => [['core', '2.20']], + 'requires' => [['core', '2.21']], 'permissions' => 'usage,contentadmin', 'type' => 'plugin', 'support' => 'https://github.com/JcDenis/periodical', diff --git a/_install.php b/_install.php index adaaec6..f45f0c0 100644 --- a/_install.php +++ b/_install.php @@ -15,7 +15,7 @@ if (!defined('DC_CONTEXT_ADMIN')) { return null; } -$dc_min = '2.19'; +$dc_min = '2.21'; $new_version = $core->plugins->moduleInfo('periodical', 'version'); $old_version = $core->getVersion('periodical'); diff --git a/dcstore.xml b/dcstore.xml index 22a641a..62c3222 100644 --- a/dcstore.xml +++ b/dcstore.xml @@ -1,11 +1,11 @@ Periodical -2021.10.30 +2022.04.27 Jean-Christian Denis and contributors Published periodically entries -https://github.com/JcDenis/periodical/releases/download/v2021.10.30/plugin-periodical.zip -2.20 +https://github.com/JcDenis/periodical/releases/download/v2022.04.27/plugin-periodical.zip +2.21 https://plugins.dotaddict.org/dc2/details/periodical https://github.com/JcDenis/periodical diff --git a/inc/class.periodical.php b/inc/class.periodical.php index 8fa3844..bfc0e65 100644 --- a/inc/class.periodical.php +++ b/inc/class.periodical.php @@ -198,6 +198,9 @@ class periodical if (!isset($params['from'])) { $params['from'] = ''; } + if (!isset($params['join'])) { + $params['join'] = ''; + } if (!isset($params['sql'])) { $params['sql'] = ''; } @@ -211,8 +214,8 @@ class periodical $params['columns'][] = 'T.periodical_pub_int'; $params['columns'][] = 'T.periodical_pub_nb'; - $params['from'] .= 'LEFT JOIN ' . $this->core->prefix . 'meta R ON P.post_id = R.post_id '; - $params['from'] .= 'LEFT JOIN ' . $this->table . ' T ON CAST(T.periodical_id as char)=R.meta_id '; + $params['join'] .= 'LEFT JOIN ' . $this->core->prefix . 'meta R ON P.post_id = R.post_id '; + $params['join'] .= 'LEFT JOIN ' . $this->table . ' T ON CAST(T.periodical_id as char) = CAST(R.meta_id as char) '; $params['sql'] .= "AND R.meta_type = 'periodical' "; $params['sql'] .= "AND T.periodical_type = 'post' "; diff --git a/inc/index.period.php b/inc/index.period.php index 952ace3..dbc72ae 100644 --- a/inc/index.period.php +++ b/inc/index.period.php @@ -30,8 +30,8 @@ $period_id = null; $period_title = __('One post per day'); $period_pub_nb = 1; $period_pub_int = 'day'; -$period_curdt = date('Y-m-d H:i:00', time()); -$period_enddt = date('Y-m-d H:i:00', time() + 31536000); //one year +$period_curdt = time(); +$period_enddt = time() + 31536000; //one year # Get period if (!empty($_REQUEST['period_id'])) { @@ -46,8 +46,8 @@ if (!empty($_REQUEST['period_id'])) { $period_title = $rs->periodical_title; $period_pub_nb = $rs->periodical_pub_nb; $period_pub_int = $rs->periodical_pub_int; - $period_curdt = date('Y-m-d H:i', strtotime($rs->periodical_curdt)); - $period_enddt = date('Y-m-d H:i', strtotime($rs->periodical_enddt)); + $period_curdt = strtotime($rs->periodical_curdt); + $period_enddt = strtotime($rs->periodical_enddt); } } @@ -66,10 +66,10 @@ if ($action == 'setperiod') { $period_pub_int = $_POST['period_pub_int']; } if (!empty($_POST['period_curdt'])) { - $period_curdt = date('Y-m-d H:i:00', strtotime($_POST['period_curdt'])); + $period_curdt = strtotime($_POST['period_curdt']); } if (!empty($_POST['period_enddt'])) { - $period_enddt = date('Y-m-d H:i:00', strtotime($_POST['period_enddt'])); + $period_enddt = strtotime($_POST['period_enddt']); } # Check period title and dates @@ -247,10 +247,16 @@ form::field('period_title', 60, 255, html::escapeHTML($period_title), 'maximal')

' . -form::field('period_curdt', 16, 16, date('Y-m-d H:i', strtotime($period_curdt))) . '

+form::datetime('period_curdt', [ + 'default' => html::escapeHTML(dt::str('%Y-%m-%dT%H:%M', strtotime($period_curdt))), + 'class' => (!$period_curdt ? 'invalid' : ''), +]) . '

' . -form::field('period_enddt', 16, 16, date('Y-m-d H:i', strtotime($period_enddt))) . '

+form::datetime('period_enddt', [ + 'default' => html::escapeHTML(dt::str('%Y-%m-%dT%H:%M', strtotime($period_enddt))), + 'class' => (!$period_enddt ? 'invalid' : ''), +]) .'