From b7c3892eeb053f33f32a6a46c75fa1c55e2d219a Mon Sep 17 00:00:00 2001 From: Lester Caine Date: Mon, 18 May 2026 09:41:49 +0100 Subject: Rework to use browser based calendar pop-up --- includes/classes/BitBlogPost.php | 62 ++++++++++++---------------------------- templates/blog_post.tpl | 20 ++++++------- 2 files changed, 28 insertions(+), 54 deletions(-) diff --git a/includes/classes/BitBlogPost.php b/includes/classes/BitBlogPost.php index 5058278..9f353d9 100755 --- a/includes/classes/BitBlogPost.php +++ b/includes/classes/BitBlogPost.php @@ -324,54 +324,28 @@ class BitBlogPost extends LibertyMime { $pParamHash['title'] = substr( $pParamHash['title'], 0, 160 ); } - if( !empty( $pParamHash['publish_Month'] ) ) { - //$dateString = $pParamHash['publish_Year'].'-'.$pParamHash['publish_Month'].'-'.$pParamHash['publish_Day'].' '.$pParamHash['publish_Hour'].':'.$pParamHash['publish_Minute']; - - //old way - //$timestamp = $gBitSystem->mServerTimestamp->getUTCFromDisplayDate( strtotime( $dateString ) ); - //new way - $this->mDate = new BitDate(0); - $offset = $this->mDate->get_display_offset(); - - $dateString = $this->mDate->gmmktime( - $pParamHash['publish_Hour'], - $pParamHash['publish_Minute'], - $pParamHash['publish_Second'] ?? 0, - $pParamHash['publish_Month'], - $pParamHash['publish_Day'], - $pParamHash['publish_Year'], - ); - - $timestamp = $this->mDate->getUTCFromDisplayDate( $dateString ); - - if( $timestamp !== -1 ) { - $pParamHash['publish_date'] = $timestamp; + if( !empty( $pParamHash['publish_dt'] ) ) { + $parts = date_parse( $pParamHash['publish_dt'] ); + if( $parts !== false && empty( $parts['errors'] ) ) { + $this->mDate = new BitDate(0); + $ts = $this->mDate->gmmktime( $parts['hour'], $parts['minute'], 0, $parts['month'], $parts['day'], $parts['year'] ); + $timestamp = $this->mDate->getUTCFromDisplayDate( $ts ); + if( $timestamp !== -1 ) { + $pParamHash['publish_date'] = $timestamp; + } } } $pParamHash['post_store']['publish_date'] = !empty( $pParamHash['publish_date'] ) ? $pParamHash['publish_date'] : $gBitSystem->getUTCTime(); - if( !empty( $pParamHash['expire_Month'] ) ) { - $dateString = $pParamHash['expire_Year'].'-'.$pParamHash['expire_Month'].'-'.$pParamHash['expire_Day'].' '.$pParamHash['expire_Hour'].':'.$pParamHash['expire_Minute']; - - //old way - //$timestamp = $gBitSystem->mServerTimestamp->getUTCFromDisplayDate( strtotime( $dateString ) ); - //new way - $this->mDate = new BitDate(0); - $offset = $this->mDate->get_display_offset(); - - $dateString = $this->mDate->gmmktime( - $pParamHash['expire_Hour'], - $pParamHash['expire_Minute'], - $pParamHash['expire_Second'] ?? 0, - $pParamHash['expire_Month'], - $pParamHash['expire_Day'], - $pParamHash['expire_Year'], - ); - - $timestamp = $this->mDate->getUTCFromDisplayDate( $dateString ); - - if( $timestamp !== -1 ) { - $pParamHash['expire_date'] = $timestamp; + if( !empty( $pParamHash['expire_dt'] ) ) { + $parts = date_parse( $pParamHash['expire_dt'] ); + if( $parts !== false && empty( $parts['errors'] ) ) { + $this->mDate = new BitDate(0); + $ts = $this->mDate->gmmktime( $parts['hour'], $parts['minute'], 0, $parts['month'], $parts['day'], $parts['year'] ); + $timestamp = $this->mDate->getUTCFromDisplayDate( $ts ); + if( $timestamp !== -1 ) { + $pParamHash['expire_date'] = $timestamp; + } } } $pParamHash['post_store']['expire_date'] = !empty( $pParamHash['expire_date'] ) diff --git a/templates/blog_post.tpl b/templates/blog_post.tpl index c6b8932..d79a620 100755 --- a/templates/blog_post.tpl +++ b/templates/blog_post.tpl @@ -96,22 +96,22 @@ {jstab title="Advanced Options"} {legend legend="Publication and Expiration Dates"}
- - {formlabel label="Publish Date" for=""} + {formlabel label="Publish Date" for="publish_dt"} {forminput} - {html_select_date prefix="publish_" time=$post_info.publish_date|default:0 start_year="-1" end_year="+10"} at  - {html_select_time prefix="publish_" time=$post_info.publish_date|default:0 display_seconds=false} {$siteTimeZone} - {formhelp note="This post will not be displayed before this date."} + +  {$siteTimeZone} + {formhelp note="This post will not be displayed before this date. Leave blank to publish immediately."} {/forminput}
- - {formlabel label="Expiration Date" for=""} + {formlabel label="Expiration Date" for="expire_dt"} {forminput} - {html_select_date prefix="expire_" time=$post_info.expire_date|default:0 start_year="+5" end_year="+10"} at  - {html_select_time prefix="expire_" time=$post_info.expire_date|default:0 display_seconds=false} {$siteTimeZone} - {formhelp note="If this date is set after the publish date, this post will not be displayed after the expiration date."} + +  {$siteTimeZone} + {formhelp note="If set, this post will not be displayed after this date."} {/forminput}
{/legend} -- cgit v1.3