Merge pull request #14737 from MrPetovan/bug/14131-dropzone-error

Account for calendar post edition in editpost()
This commit is contained in:
Tobias Diekershoff 2025-01-27 06:31:10 +01:00 committed by GitHub
commit 73fd2b23a5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 64 additions and 57 deletions

View file

@ -147,7 +147,8 @@ class Temporal
} }
$tpl = Renderer::getMarkupTemplate("field_input.tpl"); $tpl = Renderer::getMarkupTemplate("field_input.tpl");
$o = Renderer::replaceMacros($tpl, $o = Renderer::replaceMacros(
$tpl,
[ [
'$field' => [ '$field' => [
'dob', 'dob',
@ -157,7 +158,8 @@ class Temporal
'', '',
'placeholder="' . DI::l10n()->t('YYYY-MM-DD or MM-DD') . '"' 'placeholder="' . DI::l10n()->t('YYYY-MM-DD or MM-DD') . '"'
] ]
]); ]
);
return $o; return $o;
} }
@ -223,17 +225,19 @@ class Temporal
bool $picktime = true, bool $picktime = true,
string $minfrom = '', string $minfrom = '',
string $maxfrom = '', string $maxfrom = '',
bool $required = false): string bool $required = false
{ ): string {
// First day of the week (0 = Sunday) // First day of the week (0 = Sunday)
$firstDay = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'calendar', 'first_day_of_week', 0); $firstDay = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'calendar', 'first_day_of_week') ?: 0;
$lang = DI::l10n()->toISO6391(DI::l10n()->getCurrentLang()); $lang = DI::l10n()->toISO6391(DI::l10n()->getCurrentLang());
// Check if the detected language is supported by the picker // Check if the detected language is supported by the picker
if (!in_array($lang, if (!in_array(
$lang,
['ar', 'ro', 'id', 'bg', 'fa', 'ru', 'uk', 'en', 'el', 'de', 'nl', 'tr', 'fr', 'es', 'th', 'pl', 'pt', 'ch', 'se', 'kr', ['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'])) { 'it', 'da', 'no', 'ja', 'vi', 'sl', 'cs', 'hu']
)) {
$lang = 'en'; $lang = 'en';
} }
@ -329,7 +333,7 @@ class Temporal
return $compare_time ? DI::l10n()->t('less than a second ago') : DI::l10n()->t('today'); return $compare_time ? DI::l10n()->t('less than a second ago') : DI::l10n()->t('today');
} }
if ($etime < 0){ if ($etime < 0) {
$etime = -$etime; $etime = -$etime;
$isfuture = true; $isfuture = true;
} }
@ -349,10 +353,9 @@ class Temporal
if ($d >= 1) { if ($d >= 1) {
$r = floor($d); $r = floor($d);
// translators - e.g. 22 hours ago, 1 minute ago // translators - e.g. 22 hours ago, 1 minute ago
if($isfuture){ if($isfuture) {
$format = DI::l10n()->t('in %1$d %2$s'); $format = DI::l10n()->t('in %1$d %2$s');
} } else {
else {
$format = DI::l10n()->t('%1$d %2$s ago'); $format = DI::l10n()->t('%1$d %2$s ago');
} }
@ -475,7 +478,7 @@ class Temporal
$str_month = DI::l10n()->getDay($mtab[$m]); $str_month = DI::l10n()->getDay($mtab[$m]);
$o = '<table class="calendar' . $class . '">'; $o = '<table class="calendar' . $class . '">';
$o .= "<caption>$str_month $y</caption><tr>"; $o .= "<caption>$str_month $y</caption><tr>";
for ($a = 0; $a < 7; $a ++) { for ($a = 0; $a < 7; $a++) {
$o .= '<th>' . mb_substr(DI::l10n()->getDay($dn[$a]), 0, 3, 'UTF-8') . '</th>'; $o .= '<th>' . mb_substr(DI::l10n()->getDay($dn[$a]), 0, 3, 'UTF-8') . '</th>';
} }
@ -496,13 +499,13 @@ class Temporal
$o .= $day; $o .= $day;
} }
$d ++; $d++;
} else { } else {
$o .= '&nbsp;'; $o .= '&nbsp;';
} }
$o .= '</td>'; $o .= '</td>';
$dow ++; $dow++;
if (($dow == 7) && ($d <= $l)) { if (($dow == 7) && ($d <= $l)) {
$dow = 0; $dow = 0;
$o .= '</tr><tr>'; $o .= '</tr><tr>';
@ -510,7 +513,7 @@ class Temporal
} }
if ($dow) { if ($dow) {
for ($a = $dow; $a < 7; $a ++) { for ($a = $dow; $a < 7; $a++) {
$o .= '<td>&nbsp;</td>'; $o .= '<td>&nbsp;</td>';
} }
} }

View file

@ -270,12 +270,16 @@ function editpost(url) {
// To make dropzone fileupload work on editing a comment, we need to // To make dropzone fileupload work on editing a comment, we need to
// attach a new dropzone to modal // attach a new dropzone to modal
if ($('#jot-text-wrap').length > 0) {
dzFactory.setupDropzone('#jot-text-wrap', 'profile-jot-text'); dzFactory.setupDropzone('#jot-text-wrap', 'profile-jot-text');
}
modal.show(); modal.show();
$("#jot-popup").show(); $("#jot-popup").show();
if ($("#profile-jot-text").length > 0) {
linkPreview = $("#profile-jot-text").linkPreview(); linkPreview = $("#profile-jot-text").linkPreview();
} }
}
}); });
} }