mirror of
https://github.com/friendica/friendica
synced 2024-11-10 05:42:54 +00:00
The datepicker is now localised
This commit is contained in:
parent
8395f67351
commit
8a79e1afb3
1 changed files with 45 additions and 30 deletions
|
@ -210,6 +210,18 @@ function timesel($format, $h, $m, $id='timepicker') {
|
|||
if(! function_exists('datetimesel')) {
|
||||
function datetimesel($format, $min, $max, $default, $id = 'datetimepicker', $pickdate = true, $picktime = true, $minfrom = '', $maxfrom = '', $required = false) {
|
||||
|
||||
$a = get_app();
|
||||
|
||||
// First day of the week (0 = Sunday)
|
||||
$firstDay = get_pconfig(local_user(),'system','first_day_of_week');
|
||||
if ($firstDay === false) $firstDay=0;
|
||||
|
||||
$lang = substr(get_browser_language(), 0, 2);
|
||||
|
||||
// Check if the detected language is supported by the picker
|
||||
if (!in_array($lang, array("ar", "ro", "id", "bg", "fa", "ru", "uk", "en", "el", "de", "nl", "tr", "fr", "es", "th", "pl", "pt", "ch", "se", "kr", "it", "da", "no", "ja", "vi", "sl", "cs", "hu")))
|
||||
$lang = ((isset($a->config['system']['language'])) ? $a->config['system']['language'] : 'en');
|
||||
|
||||
$o = '';
|
||||
$dateformat = '';
|
||||
if($pickdate) $dateformat .= 'Y-m-d';
|
||||
|
@ -224,6 +236,7 @@ function datetimesel($format, $min, $max, $default, $id = 'datetimepicker', $pic
|
|||
if(!$pickdate) $pickers .= ',datepicker: false';
|
||||
if(!$picktime) $pickers .= ',timepicker: false';
|
||||
$extra_js = '';
|
||||
$pickers .= ",dayOfWeekStart: ".$firstDay.",lang:'".$lang."'";
|
||||
if($minfrom != '')
|
||||
$extra_js .= "\$('#$minfrom').data('xdsoft_datetimepicker').setOptions({onChangeDateTime: function (currentDateTime) { \$('#$id').data('xdsoft_datetimepicker').setOptions({minDate: currentDateTime})}})";
|
||||
if($maxfrom != '')
|
||||
|
@ -236,7 +249,9 @@ function datetimesel($format, $min, $max, $default, $id = 'datetimepicker', $pic
|
|||
$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 .= '</div>';
|
||||
$o .= "<script type='text/javascript'>\$(function () {var picker = \$('#$id').datetimepicker({step:5,format:'$dateformat' $minjs $maxjs $pickers $defaultdatejs}); $extra_js})</script>";
|
||||
$o .= "<script type='text/javascript'>";
|
||||
$o .= "\$(function () {var picker = \$('#$id').datetimepicker({step:5,format:'$dateformat' $minjs $maxjs $pickers $defaultdatejs}); $extra_js})";
|
||||
$o .= "</script>";
|
||||
return $o;
|
||||
}}
|
||||
|
||||
|
@ -252,7 +267,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 === '0000-00-00 00:00:00' || $abs === False) {
|
||||
return t('never');
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue