fix period dates

master
Jean-Christian Paul Denis 2022-05-16 23:05:40 +02:00
parent 5d0aa39561
commit 09bcd72b54
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
6 changed files with 41 additions and 15 deletions

View File

@ -1,3 +1,7 @@
2022.05.16
- require Dotclear 2.22
- fix period dates
2022.04.27 2022.04.27
- require Dotclear 2.21.3 - require Dotclear 2.21.3
- fix browser date picker - fix browser date picker

View File

@ -22,7 +22,7 @@ and they will be publish ones after the others every week.
* admin permissions to configure plugin * admin permissions to configure plugin
* usage,contentadmin permissions to link feeds * usage,contentadmin permissions to link feeds
* Dotclear 2.21.3 * Dotclear 2.22
## NOTICE ## NOTICE

View File

@ -19,9 +19,9 @@ $this->registerModule(
'Periodical', 'Periodical',
'Published periodically entries', 'Published periodically entries',
'Jean-Christian Denis and contributors', 'Jean-Christian Denis and contributors',
'2022.04.27', '2022.05.16',
[ [
'requires' => [['core', '2.21']], 'requires' => [['core', '2.22']],
'permissions' => 'usage,contentadmin', 'permissions' => 'usage,contentadmin',
'type' => 'plugin', 'type' => 'plugin',
'support' => 'https://github.com/JcDenis/periodical', 'support' => 'https://github.com/JcDenis/periodical',

View File

@ -15,7 +15,7 @@ if (!defined('DC_CONTEXT_ADMIN')) {
return null; return null;
} }
$dc_min = '2.21'; $dc_min = '2.22';
$new_version = $core->plugins->moduleInfo('periodical', 'version'); $new_version = $core->plugins->moduleInfo('periodical', 'version');
$old_version = $core->getVersion('periodical'); $old_version = $core->getVersion('periodical');

View File

@ -1,11 +1,11 @@
<modules xmlns:da="http://dotaddict.org/da/"> <modules xmlns:da="http://dotaddict.org/da/">
<module id="periodical"> <module id="periodical">
<name>Periodical</name> <name>Periodical</name>
<version>2022.04.27</version> <version>2022.05.16</version>
<author>Jean-Christian Denis and contributors</author> <author>Jean-Christian Denis and contributors</author>
<desc>Published periodically entries</desc> <desc>Published periodically entries</desc>
<file>https://github.com/JcDenis/periodical/releases/download/v2022.04.27/plugin-periodical.zip</file> <file>https://github.com/JcDenis/periodical/releases/download/v2022.05.16/plugin-periodical.zip</file>
<da:dcmin>2.21</da:dcmin> <da:dcmin>2.22</da:dcmin>
<da:details>https://plugins.dotaddict.org/dc2/details/periodical</da:details> <da:details>https://plugins.dotaddict.org/dc2/details/periodical</da:details>
<da:support>https://github.com/JcDenis/periodical</da:support> <da:support>https://github.com/JcDenis/periodical</da:support>
</module> </module>

View File

@ -30,8 +30,10 @@ $period_id = null;
$period_title = __('One post per day'); $period_title = __('One post per day');
$period_pub_nb = 1; $period_pub_nb = 1;
$period_pub_int = 'day'; $period_pub_int = 'day';
$period_curdt = time(); $period_curdt = date('Y-m-d H:i', time());
$period_enddt = time() + 31536000; //one year $period_enddt = date('Y-m-d H:i', time() + 31536000); //one year
$bad_period_curdt = false;
$bad_period_enddt = false;
# Get period # Get period
if (!empty($_REQUEST['period_id'])) { if (!empty($_REQUEST['period_id'])) {
@ -46,8 +48,8 @@ if (!empty($_REQUEST['period_id'])) {
$period_title = $rs->periodical_title; $period_title = $rs->periodical_title;
$period_pub_nb = $rs->periodical_pub_nb; $period_pub_nb = $rs->periodical_pub_nb;
$period_pub_int = $rs->periodical_pub_int; $period_pub_int = $rs->periodical_pub_int;
$period_curdt = strtotime($rs->periodical_curdt); $period_curdt = date('Y-m-d H:i', strtotime($rs->periodical_curdt));
$period_enddt = strtotime($rs->periodical_enddt); $period_enddt = date('Y-m-d H:i', strtotime($rs->periodical_enddt));
} }
} }
@ -66,10 +68,30 @@ if ($action == 'setperiod') {
$period_pub_int = $_POST['period_pub_int']; $period_pub_int = $_POST['period_pub_int'];
} }
if (!empty($_POST['period_curdt'])) { if (!empty($_POST['period_curdt'])) {
try {
$period_curdt = strtotime($_POST['period_curdt']); $period_curdt = strtotime($_POST['period_curdt']);
if ($period_curdt == false || $period_curdt == -1) {
$bad_period_curdt = true;
throw new Exception(__('Invalid date'));
}
$period_curdt = date('Y-m-d H:i', $period_curdt);
} catch (Exception $e) {
$core->error->add($e->getMessage());
}
} }
if (!empty($_POST['period_enddt'])) { if (!empty($_POST['period_enddt'])) {
try {
$period_enddt = strtotime($_POST['period_enddt']); $period_enddt = strtotime($_POST['period_enddt']);
if ($period_enddt == false || $period_enddt == -1) {
$bad_period_enddt = true;
throw new Exception(__('Invalid date'));
}
$period_enddt = date('Y-m-d H:i', $period_enddt);
} catch (Exception $e) {
$core->error->add($e->getMessage());
}
} }
# Check period title and dates # Check period title and dates
@ -249,13 +271,13 @@ form::field('period_title', 60, 255, html::escapeHTML($period_title), 'maximal')
<p><label for="period_curdt">' . __('Next update:') . '</label>' . <p><label for="period_curdt">' . __('Next update:') . '</label>' .
form::datetime('period_curdt', [ form::datetime('period_curdt', [
'default' => html::escapeHTML(dt::str('%Y-%m-%dT%H:%M', strtotime($period_curdt))), 'default' => html::escapeHTML(dt::str('%Y-%m-%dT%H:%M', strtotime($period_curdt))),
'class' => (!$period_curdt ? 'invalid' : ''), 'class' => ($bad_period_curdt ? 'invalid' : ''),
]) . '</p> ]) . '</p>
<p><label for="period_enddt">' . __('End date:') . '</label>' . <p><label for="period_enddt">' . __('End date:') . '</label>' .
form::datetime('period_enddt', [ form::datetime('period_enddt', [
'default' => html::escapeHTML(dt::str('%Y-%m-%dT%H:%M', strtotime($period_enddt))), 'default' => html::escapeHTML(dt::str('%Y-%m-%dT%H:%M', strtotime($period_enddt))),
'class' => (!$period_enddt ? 'invalid' : ''), 'class' => ($bad_period_enddt ? 'invalid' : ''),
]) .'</p> ]) .'</p>
</div><div class="two-boxes"> </div><div class="two-boxes">