From c6d07feff575862b5db8d05e02be6375e51034c7 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 8 Sep 2014 20:35:15 -0700 Subject: This is long overdue - use a symblic constant NULL_DATE instead of the easily mis-typed sequence '0000-00-00 00:00:00' --- include/datetime.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/datetime.php') diff --git a/include/datetime.php b/include/datetime.php index 0214b9e4c..84ab1e2fa 100644 --- a/include/datetime.php +++ b/include/datetime.php @@ -271,7 +271,7 @@ function relative_date($posted_date,$format = null) { $abs = strtotime($localtime); - if (is_null($posted_date) || $posted_date === '0000-00-00 00:00:00' || $abs === False) { + if (is_null($posted_date) || $posted_date === NULL_DATE || $abs === False) { return t('never'); } -- cgit v1.2.3 From 7c4f55af9f8e28a761155eaf6d0d379b28d88f23 Mon Sep 17 00:00:00 2001 From: Stefan Parviainen Date: Sat, 18 Oct 2014 22:17:49 +0200 Subject: Oops, forgot one file --- include/datetime.php | 158 +++++++++++++++++++++++++++------------------------ 1 file changed, 85 insertions(+), 73 deletions(-) (limited to 'include/datetime.php') diff --git a/include/datetime.php b/include/datetime.php index 84ab1e2fa..3d0ae0404 100644 --- a/include/datetime.php +++ b/include/datetime.php @@ -134,7 +134,7 @@ function dob($dob) { $f = get_config('system','birthday_input_format'); if(! $f) $f = 'ymd'; - $o = datesel($f,'',1920,$y,true,$year,$month,$day); + $o = datesel($f,'dob',1920,$y,true,$year,$month,$day); return $o; } @@ -169,95 +169,107 @@ function datesel_format($f) { return $o; } +/** + * returns a date selector + * @param $format + * format string, e.g. 'ymd' or 'mdy'. Not currently supported + * @param $id + * id and name of datetimepicker (defaults to "datepicker") + * @param $ymin + * first year shown in selector dropdown + * @param $ymax + * last year shown in selector dropdown + * @param $allow_blank + * allow an empty response on any field. Not currently supported + * @param $y + * already selected year + * @param $m + * already selected month + * @param $d + * already selected day + */ +function datesel($format, $id, $ymin, $ymax, $allow_blank, $y, $m, $d) { + if($ymin > $ymax) list($ymin,$ymax) = array($ymax,$ymin); -// returns a date selector. -// $f = format string, e.g. 'ymd' or 'mdy' -// $pre = prefix (if needed) for HTML name and class fields -// $ymin = first year shown in selector dropdown -// $ymax = last year shown in selector dropdown -// $allow_blank = allow an empty response on any field -// $y = already selected year -// $m = already selected month -// $d = already selected day - - -function datesel($f,$pre,$ymin,$ymax,$allow_blank,$y,$m,$d) { + if($id == '') $id = 'datepicker'; $o = ''; - if(strlen($f)) { - for($z = 0; $z < strlen($f); $z ++) { - if($f[$z] === 'y') { - - $o .= " "; + $o .= "
"; + $o .= ""; return $o; } +/** + * returns a date selector + * @param $format + * format string, e.g. 'ymd' or 'mdy'. Not currently supported + * @param $id + * id and name of datetimepicker (defaults to "timepicker") + * @param $h + * already selected hour + * @param $m + * already selected minute + */ +function timesel($format,$id,$h,$m) { + if($id == '') $id = 'timepicker'; -function timesel($pre,$h,$m) { + $timeformat = 'HH:mm'; $o = ''; - $o .= " : "; + $o .= "
"; + $o .= ""; return $o; } +/** + * returns a datetime selector + * @param $format + * format string, e.g. 'ymd' or 'mdy'. Not currently supported + * @param $id + * id and name of datetimepicker (defaults to "datetimepicker") + * @param $ymin + * first year shown in selector dropdown + * @param $ymax + * last year shown in selector dropdown + * @param $allow_blank + * allow an empty response on any field. Not currently supported + * @param $y + * already selected year + * @param $m + * already selected month + * @param $d + * already selected day + * @param $h + * already selected hour + * @param $min + * already selected minute + */ +function datetimesel($format, $id, $ymin, $ymax, $allow_blank, $y, $m, $d, $h, $min) { + if($ymin > $ymax) list($ymin,$ymax) = array($ymax,$ymin); + if($id == '') $id = 'datetimepicker'; + $o = ''; + $dateformat = 'YYYY-MM-DD HH:mm'; + $mindate = $ymin ? "new Date($ymin,1,1)" : ''; + $maxdate = $ymin ? "new Date($ymax,11,31)" : ''; + + $defaultDate = ($y != 0 && $m != 0 && $d != 0) ? ", defaultDate: new Date($y, $m, $d, $h, $min)" : ''; - - + $o .= "
"; + $o .= ""; + return $o; +} // implements "3 seconds ago" etc. // based on $posted_date, (UTC). @@ -516,4 +528,4 @@ function update_birthdays() { } } } -} \ No newline at end of file +} -- cgit v1.2.3 From 519ef4850021c929764f1175a9aae569d1ae36a6 Mon Sep 17 00:00:00 2001 From: Stefan Parviainen Date: Sun, 19 Oct 2014 10:47:42 +0200 Subject: Changes in the datetimesel api, prevent user from picking event end date earlier than start date --- include/datetime.php | 121 ++++++++++++++++++++++----------------------------- 1 file changed, 51 insertions(+), 70 deletions(-) (limited to 'include/datetime.php') diff --git a/include/datetime.php b/include/datetime.php index 3d0ae0404..76c3ddb25 100644 --- a/include/datetime.php +++ b/include/datetime.php @@ -130,11 +130,12 @@ function datetime_convert($from = 'UTC', $to = 'UTC', $s = 'now', $fmt = "Y-m-d function dob($dob) { list($year,$month,$day) = sscanf($dob,'%4d-%2d-%2d'); - $y = datetime_convert('UTC',date_default_timezone_get(),'now','Y'); $f = get_config('system','birthday_input_format'); if(! $f) $f = 'ymd'; - $o = datesel($f,'dob',1920,$y,true,$year,$month,$day); + + $o = datesel($f,mktime(0,0,0,0,0,1900),mktime(),mktime(0,0,0,$month,$day,$year),'dob'); + return $o; } @@ -173,101 +174,81 @@ function datesel_format($f) { * returns a date selector * @param $format * format string, e.g. 'ymd' or 'mdy'. Not currently supported + * @param $min + * unix timestamp of minimum date + * @param $max + * unix timestap of maximum date + * @param $default + * unix timestamp of default date * @param $id - * id and name of datetimepicker (defaults to "datepicker") - * @param $ymin - * first year shown in selector dropdown - * @param $ymax - * last year shown in selector dropdown - * @param $allow_blank - * allow an empty response on any field. Not currently supported - * @param $y - * already selected year - * @param $m - * already selected month - * @param $d - * already selected day + * id and name of datetimepicker (defaults to "datetimepicker") */ -function datesel($format, $id, $ymin, $ymax, $allow_blank, $y, $m, $d) { - if($ymin > $ymax) list($ymin,$ymax) = array($ymax,$ymin); - - if($id == '') $id = 'datepicker'; - - $o = ''; - - $dateformat = 'YYYY-MM-DD'; - $mindate = $ymin ? "new Date($ymin,1,1)" : ''; - $maxdate = $ymin ? "new Date($ymax,11,31)" : ''; // Yes, JS months really go from 0 to 11. - - $m = $m -1; // Because JavaScript month weirdness - - $defaultDate = ($y != 0 && $m != 0 && $d != 0) ? ", defaultDate: new Date($y,$m,$d)" : ''; - - $o .= "
"; - $o .= ""; - return $o; +function datesel($format, $min, $max, $default,$id = 'datepicker') { + return datetimesel($format,$min,$max,$default,$id,true,false); } /** * returns a date selector * @param $format * format string, e.g. 'ymd' or 'mdy'. Not currently supported - * @param $id - * id and name of datetimepicker (defaults to "timepicker") * @param $h * already selected hour * @param $m * already selected minute + * @param $id + * id and name of datetimepicker (defaults to "timepicker") */ -function timesel($format,$id,$h,$m) { - if($id == '') $id = 'timepicker'; - - $timeformat = 'HH:mm'; - - $o = ''; - $o .= "
"; - $o .= ""; - return $o; +function timesel($format,$h,$m,$id='timepicker') { + return datetimesel($format,mktime(),mktime(),mktime($h,$m),$id,false,true); } /** * returns a datetime selector * @param $format * format string, e.g. 'ymd' or 'mdy'. Not currently supported + * @param $min + * unix timestamp of minimum date + * @param $max + * unix timestap of maximum date + * @param $default + * unix timestamp of default date * @param $id * id and name of datetimepicker (defaults to "datetimepicker") - * @param $ymin - * first year shown in selector dropdown - * @param $ymax - * last year shown in selector dropdown - * @param $allow_blank - * allow an empty response on any field. Not currently supported - * @param $y - * already selected year - * @param $m - * already selected month - * @param $d - * already selected day - * @param $h - * already selected hour - * @param $min - * already selected minute + * @param $pickdate + * true to show date picker (default) + * @param $picktime + * true to show time picker (default) + * @param $minfrom + * set minimum date from picker with id $minfrom (none by default) + * @param $maxfrom + * set maximum date from picker with id $maxfrom (none by default) */ -function datetimesel($format, $id, $ymin, $ymax, $allow_blank, $y, $m, $d, $h, $min) { - if($ymin > $ymax) list($ymin,$ymax) = array($ymax,$ymin); - - if($id == '') $id = 'datetimepicker'; - +function datetimesel($format, $min, $max, $default, $id = 'datetimepicker', $pickdate = true, $picktime = true, $minfrom = '', $maxfrom = '') { $o = ''; - $dateformat = 'YYYY-MM-DD HH:mm'; - $mindate = $ymin ? "new Date($ymin,1,1)" : ''; - $maxdate = $ymin ? "new Date($ymax,11,31)" : ''; + $dateformat = ''; + if($pickdate) $dateformat .= 'YYYY-MM-DD'; + if($pickdate && $picktime) $dateformat .= ' '; + if($picktime) $dateformat .= 'HH:mm'; + + $mindate = $min ? "new Date($min*1000)" : ''; + $maxdate = $max ? "new Date($max*1000)" : ''; - $defaultDate = ($y != 0 && $m != 0 && $d != 0) ? ", defaultDate: new Date($y, $m, $d, $h, $min)" : ''; + $defaultDate = $default ? ", defaultDate: new Date($default*1000)" : ''; + + $pickers = ''; + if(!$pickdate) $pickers .= 'pickDate: false,'; + if(!$picktime) $pickers .= 'pickTime: false,'; + + $extra_js = ''; + if($minfrom != '') + $extra_js .= "\$('#$minfrom').on('dp.change',function (e) { \$('#$id').data('DateTimePicker').setMinDate(e.date); });"; + + if($maxfrom != '') + $extra_js .= "\$('#$maxfrom').on('dp.change',function (e) { \$('#$id').data('DateTimePicker').setMaxDate(e.date); });"; $o .= "
"; - $o .= ""; + $o .= ""; return $o; } -- cgit v1.2.3 From a6c4ae186e9e9962ce9ea364a95b49b5e2cbc81d Mon Sep 17 00:00:00 2001 From: Stefan Parviainen Date: Sun, 19 Oct 2014 11:09:51 +0200 Subject: Don't display date format, it's already in the placeholder text --- include/datetime.php | 30 ------------------------------ 1 file changed, 30 deletions(-) (limited to 'include/datetime.php') diff --git a/include/datetime.php b/include/datetime.php index 76c3ddb25..fe0f29c7a 100644 --- a/include/datetime.php +++ b/include/datetime.php @@ -140,36 +140,6 @@ function dob($dob) { } -function datesel_format($f) { - - $o = ''; - - if(strlen($f)) { - for($x = 0; $x < strlen($f); $x ++) { - switch($f[$x]) { - case 'y': - if(strlen($o)) - $o .= '-'; - $o .= t('year'); - break; - case 'm': - if(strlen($o)) - $o .= '-'; - $o .= t('month'); - break; - case 'd': - if(strlen($o)) - $o .= '-'; - $o .= t('day'); - break; - default: - break; - } - } - } - return $o; -} - /** * returns a date selector * @param $format -- cgit v1.2.3 From d9f2944565f3bc17b21ddbbde85b3083a003f477 Mon Sep 17 00:00:00 2001 From: Stefan Parviainen Date: Fri, 31 Oct 2014 16:09:48 +0100 Subject: Fix problem with default birth date --- include/datetime.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'include/datetime.php') diff --git a/include/datetime.php b/include/datetime.php index fe0f29c7a..00bac8ad1 100644 --- a/include/datetime.php +++ b/include/datetime.php @@ -134,7 +134,10 @@ function dob($dob) { if(! $f) $f = 'ymd'; - $o = datesel($f,mktime(0,0,0,0,0,1900),mktime(),mktime(0,0,0,$month,$day,$year),'dob'); + if ($dob && $dob != '0000-00-00') + $o = datesel($f,mktime(0,0,0,0,0,1900),mktime(),mktime(0,0,0,$month,$day,$year),'dob'); + else + $o = datesel($f,mktime(0,0,0,0,0,1900),mktime(),false,'dob'); return $o; } -- cgit v1.2.3 From 325b269b224615a9c584e0ec631a11d68bb24eb8 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 11 Nov 2014 01:05:29 -0800 Subject: the code is a bit crufty, but this should fix issue #687 --- include/datetime.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'include/datetime.php') diff --git a/include/datetime.php b/include/datetime.php index 00bac8ad1..47c63e51d 100644 --- a/include/datetime.php +++ b/include/datetime.php @@ -134,10 +134,17 @@ function dob($dob) { if(! $f) $f = 'ymd'; - if ($dob && $dob != '0000-00-00') - $o = datesel($f,mktime(0,0,0,0,0,1900),mktime(),mktime(0,0,0,$month,$day,$year),'dob'); + if($dob === '0000-00-00') + $value = ''; else - $o = datesel($f,mktime(0,0,0,0,0,1900),mktime(),false,'dob'); + $value = (($year) ? datetime_convert('UTC','UTC',$dob,'Y-m-d') : datetime_convert('UTC','UTC',$dob,'m-d')); + + $o = ''; + +// if ($dob && $dob != '0000-00-00') +// $o = datesel($f,mktime(0,0,0,0,0,1900),mktime(),mktime(0,0,0,$month,$day,$year),'dob'); +// else +// $o = datesel($f,mktime(0,0,0,0,0,1900),mktime(),false,'dob'); return $o; } -- cgit v1.2.3 From 1a5a5c7edb8697c93f8bababbafa80245378dd7e Mon Sep 17 00:00:00 2001 From: Habeas Codice Date: Thu, 13 Nov 2014 12:21:58 -0800 Subject: PostgreSQL support initial commit There were 11 main types of changes: - UPDATE's and DELETE's sometimes had LIMIT 1 at the end of them. This is not only non-compliant but it would certainly not do what whoever wrote it thought it would. It is likely this mistake was just copied from Friendica. All of these instances, the LIMIT 1 was simply removed. - Bitwise operations (and even some non-zero int checks) erroneously rely on MySQL implicit integer-boolean conversion in the WHERE clauses. This is non-compliant (and bad programming practice to boot). Proper explicit boolean conversions were added. New queries should use proper conventions. - MySQL has a different operator for bitwise XOR than postgres. Rather than add yet another dba_ func, I converted them to "& ~" ("AND NOT") when turning off, and "|" ("OR") when turning on. There were no true toggles (XOR). New queries should refrain from using XOR when not necessary. - There are several fields which the schema has marked as NOT NULL, but the inserts don't specify them. The reason this works is because mysql totally ignores the constraint and adds an empty text default automatically. Again, non-compliant, obviously. In these cases a default of empty text was added. - Several statements rely on a non-standard MySQL feature (http://dev.mysql.com/doc/refman/5.5/en/group-by-handling.html). These queries can all be rewritten to be standards compliant. Interestingly enough, the newly rewritten standards compliant queries run a zillion times faster, even on MySQL. - A couple of function/operator name translations were needed (RAND/RANDOM, GROUP_CONCAT/STRING_AGG, UTC_NOW, REGEXP/~, ^/#) -- assist functions added in the dba_ - INTERVALs: postgres requires quotes around the value, mysql requires that there are not quotes around the value -- assist functions added in the dba_ - NULL_DATE's -- Postgres does not allow the invalid date '0000-00-00 00:00:00' (there is no such thing as year 0 or month 0 or day 0). We use '0001-01-01 00:00:00' for postgres. Conversions are handled in Zot/item packets automagically by quoting all dates with dbescdate(). - char(##) specifications in the schema creates fields with blank spaces that aren't trimmed in the code. MySQL apparently treats char(##) as varchar(##), again, non-compliant. Since postgres works better with text fields anyway, this ball of bugs was simply side-stepped by using 'text' datatype for all text fields in the postgres schema. varchar was used in a couple of places where it actually seemed appropriate (size constraint), but without rigorously vetting that all of the PHP code actually validates data, new bugs might come out from under the rug. - postgres doesn't store nul bytes and a few other non-printables in text fields, even when quoted. bytea fields were used when storing binary data (photo.data, attach.data). A new dbescbin() function was added to handle this transparently. - postgres does not support LIMIT #,# syntax. All databases support LIMIT # OFFSET # syntax. Statements were updated to be standard. These changes require corresponding changes in the coding standards. Please review those before adding any code going forward. Still on my TODO list: - remove quotes from non-reserved identifiers and make reserved identifiers use dba func for quoting - Rewrite search queries for better results (both MySQL and Postgres) --- include/datetime.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'include/datetime.php') diff --git a/include/datetime.php b/include/datetime.php index 00bac8ad1..bfaa8792b 100644 --- a/include/datetime.php +++ b/include/datetime.php @@ -453,7 +453,10 @@ function update_birthdays() { require_once('include/permissions.php'); $r = q("SELECT * FROM abook left join xchan on abook_xchan = xchan_hash - WHERE abook_dob > utc_timestamp() + interval 7 day and abook_dob < utc_timestamp() + interval 14 day"); + WHERE abook_dob > %s + interval %s and abook_dob < %s + interval %s", + db_utcnow(), db_quoteinterval('7 day'), + db_utcnow(), db_quoteinterval('14 day') + ); if($r) { foreach($r as $rr) { @@ -475,7 +478,7 @@ function update_birthdays() { $z = event_store_event($ev); if($z) { $item_id = event_store_item($ev,$z); - q("update abook set abook_dob = '%s' where abook_id = %d limit 1", + q("update abook set abook_dob = '%s' where abook_id = %d", dbesc(intval($rr['abook_dob']) + 1 . substr($rr['abook_dob'],4)), intval($rr['abook_id']) ); -- cgit v1.2.3 From c1b8608940055adabc8bf4bb85b843eb5cb95412 Mon Sep 17 00:00:00 2001 From: Stefan Parviainen Date: Sun, 16 Nov 2014 13:56:45 +0100 Subject: Switch to a better datetime picker widget --- include/datetime.php | 45 ++++++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 17 deletions(-) (limited to 'include/datetime.php') diff --git a/include/datetime.php b/include/datetime.php index 270be5e3d..59dad2045 100644 --- a/include/datetime.php +++ b/include/datetime.php @@ -163,12 +163,12 @@ function dob($dob) { * @param $id * id and name of datetimepicker (defaults to "datetimepicker") */ -function datesel($format, $min, $max, $default,$id = 'datepicker') { - return datetimesel($format,$min,$max,$default,$id,true,false); +function datesel($format, $min, $max, $default, $id = 'datepicker') { + return datetimesel($format,$min,$max,$default,$id,true,false, '',''); } /** - * returns a date selector + * returns a time selector * @param $format * format string, e.g. 'ymd' or 'mdy'. Not currently supported * @param $h @@ -178,8 +178,8 @@ function datesel($format, $min, $max, $default,$id = 'datepicker') { * @param $id * id and name of datetimepicker (defaults to "timepicker") */ -function timesel($format,$h,$m,$id='timepicker') { - return datetimesel($format,mktime(),mktime(),mktime($h,$m),$id,false,true); +function timesel($format, $h, $m, $id='timepicker') { + return datetimesel($format,new DateTime(),new DateTime(),new DateTime("$h:$m"),$id,false,true); } /** @@ -204,31 +204,42 @@ function timesel($format,$h,$m,$id='timepicker') { * set maximum date from picker with id $maxfrom (none by default) */ function datetimesel($format, $min, $max, $default, $id = 'datetimepicker', $pickdate = true, $picktime = true, $minfrom = '', $maxfrom = '') { + // Once browser support is better this could probably be replaced with native HTML5 date picker $o = ''; $dateformat = ''; - if($pickdate) $dateformat .= 'YYYY-MM-DD'; + + if($pickdate) $dateformat .= 'Y-m-d'; if($pickdate && $picktime) $dateformat .= ' '; - if($picktime) $dateformat .= 'HH:mm'; + if($picktime) $dateformat .= 'H:i'; - $mindate = $min ? "new Date($min*1000)" : ''; - $maxdate = $max ? "new Date($max*1000)" : ''; + $minjs = $min ? ",minDate: new Date({$min->getTimestamp()}*1000), yearStart: " . $min->format('Y') : ''; + $maxjs = $max ? ",maxDate: new Date({$max->getTimestamp()}*1000), yearEnd: " . $max->format('Y') : ''; - $defaultDate = $default ? ", defaultDate: new Date($default*1000)" : ''; + $input_text = $default ? 'value="' . date($dateformat, $default->getTimestamp()) . '"' : ''; + $defaultdatejs = $default ? ",defaultDate: new Date({$default->getTimestamp()}*1000)" : ''; $pickers = ''; - if(!$pickdate) $pickers .= 'pickDate: false,'; - if(!$picktime) $pickers .= 'pickTime: false,'; + if(!$pickdate) $pickers .= ',datepicker: false'; + if(!$picktime) $pickers .= ',timepicker: false'; $extra_js = ''; if($minfrom != '') - $extra_js .= "\$('#$minfrom').on('dp.change',function (e) { \$('#$id').data('DateTimePicker').setMinDate(e.date); });"; + $extra_js .= "\$('#$minfrom').data('xdsoft_datetimepicker').setOptions({onChangeDateTime: function (currentDateTime) { \$('#$id').data('xdsoft_datetimepicker').setOptions({minDate: currentDateTime})}})"; if($maxfrom != '') - $extra_js .= "\$('#$maxfrom').on('dp.change',function (e) { \$('#$id').data('DateTimePicker').setMaxDate(e.date); });"; - - $o .= "
"; - $o .= ""; + $extra_js .= "\$('#$maxfrom').data('xdsoft_datetimepicker').setOptions({onChangeDateTime: function (currentDateTime) { \$('#$id').data('xdsoft_datetimepicker').setOptions({maxDate: currentDateTime})}})"; + + $readable_format = $dateformat; + $readable_format = str_replace('Y','yyyy',$readable_format); + $readable_format = str_replace('m','mm',$readable_format); + $readable_format = str_replace('d','dd',$readable_format); + $readable_format = str_replace('H','HH',$readable_format); + $readable_format = str_replace('i','MM',$readable_format); + + $o .= "
"; + $o .= '
'; + $o .= ""; return $o; } -- cgit v1.2.3 From 686b6ee1182c09969e2817b53825a78975c75bf5 Mon Sep 17 00:00:00 2001 From: Stefan Parviainen Date: Thu, 1 Jan 2015 14:44:50 +0100 Subject: Use grouped select field for timezone selection --- include/datetime.php | 47 +++++++++-------------------------------------- 1 file changed, 9 insertions(+), 38 deletions(-) (limited to 'include/datetime.php') diff --git a/include/datetime.php b/include/datetime.php index 59dad2045..346d03bd4 100644 --- a/include/datetime.php +++ b/include/datetime.php @@ -14,25 +14,17 @@ function timezone_cmp($a, $b) { return ( t($a) < t($b)) ? -1 : 1; } -// emit a timezone selector grouped (primarily) by continent - -function select_timezone($current = 'America/Los_Angeles') { - +// Return timezones grouped (primarily) by continent +function get_timezones( ){ $timezone_identifiers = DateTimeZone::listIdentifiers(); - - $o =''; - return $o; -} - -// return a select using 'field_select_raw' template, with timezones -// groupped (primarily) by continent -// arguments follow convetion as other field_* template array: -// 'name', 'label', $value, 'help' -function field_timezone($name='timezone', $label='', $current = 'America/Los_Angeles', $help){ - $options = select_timezone($current); - $options = str_replace('','', $options); - - $tpl = get_markup_template('field_select_raw.tpl'); - return replace_macros($tpl, array( - '$field' => array($name, $label, $current, $help, $options), - )); - + if(!x($continents,$ex[0])) $continents[$ex[0]] = array(); + $continents[$continent][$value] = $city; + } + return $continents; } // General purpose date parse/convert function. -- cgit v1.2.3