diff options
| author | Lester Caine <lester@lsces.co.uk> | 2026-05-18 09:41:49 +0100 |
|---|---|---|
| committer | Lester Caine <lester@lsces.co.uk> | 2026-05-18 09:41:49 +0100 |
| commit | b7c3892eeb053f33f32a6a46c75fa1c55e2d219a (patch) | |
| tree | 2082181ed136fd8066b4882627fd088b0347a169 | |
| parent | 9c585c0575c3c8488a843b88e6d7f6627819e720 (diff) | |
| download | blogs-b7c3892eeb053f33f32a6a46c75fa1c55e2d219a.tar.gz blogs-b7c3892eeb053f33f32a6a46c75fa1c55e2d219a.tar.bz2 blogs-b7c3892eeb053f33f32a6a46c75fa1c55e2d219a.zip | |
Rework to use browser based calendar pop-up
| -rwxr-xr-x | includes/classes/BitBlogPost.php | 62 | ||||
| -rwxr-xr-x | 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"} <div class="form-group"> - <input type="hidden" name="publishDateInput" value="1" /> - {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 - <span dir="ltr">{html_select_time prefix="publish_" time=$post_info.publish_date|default:0 display_seconds=false} {$siteTimeZone}</span> - {formhelp note="This post will not be displayed <strong>before</strong> this date."} + <input type="datetime-local" name="publish_dt" id="publish_dt" + value="{($post_info.publish_date ?: $smarty.now)|date_format:'%Y-%m-%dT%H:%M'}" /> + {$siteTimeZone} + {formhelp note="This post will not be displayed <strong>before</strong> this date. Leave blank to publish immediately."} {/forminput} </div> <div class="form-group"> - <input type="hidden" name="expireDateInput" value="1" /> - {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 - <span dir="ltr">{html_select_time prefix="expire_" time=$post_info.expire_date|default:0 display_seconds=false} {$siteTimeZone}</span> - {formhelp note="If this date is set after the publish date, this post will not be displayed <strong>after</strong> the expiration date."} + <input type="datetime-local" name="expire_dt" id="expire_dt" + value="{if $post_info.expire_date}{$post_info.expire_date|date_format:'%Y-%m-%dT%H:%M'}{/if}" /> + {$siteTimeZone} + {formhelp note="If set, this post will not be displayed <strong>after</strong> this date."} {/forminput} </div> {/legend} |
