aboutsummaryrefslogtreecommitdiffstats
path: root/include/datetime.php
diff options
context:
space:
mode:
authorMario Vavti <mario@mariovavti.com>2015-11-24 14:15:28 +0100
committerMario Vavti <mario@mariovavti.com>2015-11-24 14:15:28 +0100
commit987619130b99bf4548d5d31ac453cdf48c818eff (patch)
treec9a00e4dbea487a93725d539c04d78fa1cadd38f /include/datetime.php
parente485ecb3b453a50a1974992b5ccf5122e154a5dc (diff)
downloadvolse-hubzilla-987619130b99bf4548d5d31ac453cdf48c818eff.tar.gz
volse-hubzilla-987619130b99bf4548d5d31ac453cdf48c818eff.tar.bz2
volse-hubzilla-987619130b99bf4548d5d31ac453cdf48c818eff.zip
some event heavy lifting - please test and report issues
Diffstat (limited to 'include/datetime.php')
-rw-r--r--include/datetime.php23
1 files changed, 12 insertions, 11 deletions
diff --git a/include/datetime.php b/include/datetime.php
index 63287d023..22232fe24 100644
--- a/include/datetime.php
+++ b/include/datetime.php
@@ -198,7 +198,7 @@ function timesel($format, $h, $m, $id='timepicker') {
* @todo Once browser support is better this could probably be replaced with
* native HTML5 date picker.
*/
-function datetimesel($format, $min, $max, $default, $id = 'datetimepicker', $pickdate = true, $picktime = true, $minfrom = '', $maxfrom = '', $required = false, $first_day = 0) {
+function datetimesel($format, $min, $max, $default = 'bla', $label, $id = 'datetimepicker', $pickdate = true, $picktime = true, $minfrom = '', $maxfrom = '', $required = false, $first_day = 0) {
$o = '';
$dateformat = '';
@@ -207,11 +207,11 @@ function datetimesel($format, $min, $max, $default, $id = 'datetimepicker', $pic
if($pickdate && $picktime) $dateformat .= ' ';
if($picktime) $dateformat .= 'H:i';
- $minjs = $min ? ",minDate: new Date({$min->getTimestamp()}*1000), yearStart: " . $min->format('Y') : '';
- $maxjs = $max ? ",maxDate: new Date({$max->getTimestamp()}*1000), yearEnd: " . $max->format('Y') : '';
+ $minjs = $min->getTimestamp() ? ",minDate: new Date({$min->getTimestamp()}*1000), yearStart: " . $min->format('Y') : '';
+ $maxjs = $max->getTimestamp() ? ",maxDate: new Date({$max->getTimestamp()}*1000), yearEnd: " . $max->format('Y') : '';
- $input_text = $default ? 'value="' . date($dateformat, $default->getTimestamp()) . '"' : '';
- $defaultdatejs = $default ? ",defaultDate: new Date({$default->getTimestamp()}*1000)" : '';
+ $input_text = $default->getTimestamp() ? date($dateformat, $default->getTimestamp()) : '';
+ $defaultdatejs = $default->getTimestamp() ? ",defaultDate: new Date({$default->getTimestamp()}*1000)" : '';
$pickers = '';
if(!$pickdate) $pickers .= ',datepicker: false';
@@ -219,10 +219,10 @@ function datetimesel($format, $min, $max, $default, $id = 'datetimepicker', $pic
$extra_js = '';
if($minfrom != '')
- $extra_js .= "\$('#$minfrom').data('xdsoft_datetimepicker').setOptions({onChangeDateTime: function (currentDateTime) { \$('#$id').data('xdsoft_datetimepicker').setOptions({minDate: currentDateTime})}})";
+ $extra_js .= "\$('#id_$minfrom').data('xdsoft_datetimepicker').setOptions({onChangeDateTime: function (currentDateTime) { \$('#id_$id').data('xdsoft_datetimepicker').setOptions({minDate: currentDateTime})}})";
if($maxfrom != '')
- $extra_js .= "\$('#$maxfrom').data('xdsoft_datetimepicker').setOptions({onChangeDateTime: function (currentDateTime) { \$('#$id').data('xdsoft_datetimepicker').setOptions({maxDate: currentDateTime})}})";
+ $extra_js .= "\$('#id_$maxfrom').data('xdsoft_datetimepicker').setOptions({onChangeDateTime: function (currentDateTime) { \$('#id_$id').data('xdsoft_datetimepicker').setOptions({maxDate: currentDateTime})}})";
$readable_format = $dateformat;
$readable_format = str_replace('Y','yyyy',$readable_format);
@@ -231,10 +231,11 @@ function datetimesel($format, $min, $max, $default, $id = 'datetimepicker', $pic
$readable_format = str_replace('H','HH',$readable_format);
$readable_format = str_replace('i','MM',$readable_format);
- $o .= "<div class='date'><input type='text' placeholder='$readable_format' name='$id' id='$id' $input_text />";
- $o .= (($required) ? '<span class="required" title="' . t('Required') . '" >*</span>' : '');
- $o .= '</div>';
- $o .= "<script type='text/javascript'>\$(function () {var picker = \$('#$id').datetimepicker({step:5,format:'$dateformat' $minjs $maxjs $pickers $defaultdatejs,dayOfWeekStart:$first_day}); $extra_js})</script>";
+ $tpl = get_markup_template('field_input.tpl');
+ $o .= replace_macros($tpl,array(
+ '$field' => array($id, $label, $input_text, (($required) ? t('Required') : ''), (($required) ? '*' : ''), 'placeholder="' . $readable_format . '"'),
+ ));
+ $o .= "<script>\$(function () {var picker = \$('#id_$id').datetimepicker({step:5,format:'$dateformat' $minjs $maxjs $pickers $defaultdatejs,dayOfWeekStart:$first_day}); $extra_js})</script>";
return $o;
}