diff --git a/composer.json b/composer.json
index 003598f5f1..0e603895d9 100644
--- a/composer.json
+++ b/composer.json
@@ -21,6 +21,7 @@
"ezsystems/ezplatform-admin-ui-modules": "^1.4@dev",
"ezsystems/ez-support-tools": "^1.0@dev",
"ezsystems/ezplatform-design-engine": "^2.0@dev",
+ "ezsystems/ezplatform-user": "^1.0@dev",
"white-october/pagerfanta-bundle": "^1.1",
"knplabs/knp-menu-bundle": "^2.1",
"mck89/peast": "^1.8",
diff --git a/src/bundle/Resources/public/js/scripts/admin.format.date.js b/src/bundle/Resources/public/js/scripts/admin.format.date.js
index f0b7e17881..85b0fd7633 100644
--- a/src/bundle/Resources/public/js/scripts/admin.format.date.js
+++ b/src/bundle/Resources/public/js/scripts/admin.format.date.js
@@ -1,6 +1,36 @@
(function(moment) {
- const formatEx = /[dDjlNSwzWFmMntLoYyaABgGhHisueIOPTZcrU]/g;
- const formatMap = {
+ const formatICUEx = /[GdayLqDeEc]+/g;
+ const formatICUMap = {
+ dd: 'DD',
+ d: 'D',
+ a: 'A',
+ y: 'Y',
+ yy: 'YY',
+ yyyy: 'YYYY',
+ LLLL: 'MMMM',
+ LLL: 'MMM',
+ LL: 'MM',
+ L: 'M',
+ q: 'Q',
+ D: 'DDD',
+ eeeeee: 'dd',
+ eeee: 'dddd',
+ eee: 'ddd',
+ ee: 'E',
+ e: 'E',
+ EEEEEE: 'dd',
+ EEEE: 'dddd',
+ EEE: 'ddd',
+ EE: 'ddd',
+ E: 'ddd',
+ cccccc: 'dd',
+ cccc: 'dddd',
+ ccc: 'ddd',
+ cc: 'E',
+ c: 'E',
+ };
+ const formatPHPEx = /[dDjlNSwzWFmMntLoYyaABgGhHisueIOPTZcrU]/g;
+ const formatPHPMap = {
d: 'DD',
D: 'ddd',
j: 'D',
@@ -57,10 +87,21 @@
};
moment.fn.formatPHP = function(format) {
+ console.warn('[DEPRECATED] formatPHP function is deprecated');
+ console.warn('[DEPRECATED] it will be removed from ezplatform-admin-ui 2.0');
+ console.warn('[DEPRECATED] use formatICU instead');
return this.format(
- format.replace(formatEx, (phpStr) => {
- return typeof formatMap[phpStr] === 'function' ? formatMap[phpStr].call(this) : formatMap[phpStr];
+ format.replace(formatPHPEx, (phpStr) => {
+ return typeof formatPHPMap[phpStr] === 'function' ? formatPHPMap[phpStr].call(this) : formatPHPMap[phpStr];
})
);
};
+
+ moment.fn.formatICU = function(format) {
+ const form = format.replace(formatICUEx, (icuStr) => {
+ return typeof formatICUMap[icuStr] === 'function' ? formatICUMap[icuStr].call(this) : formatICUMap[icuStr];
+ });
+
+ return this.format(form);
+ };
})(window.moment);
diff --git a/src/bundle/Resources/public/js/scripts/helpers/timezone.helper.js b/src/bundle/Resources/public/js/scripts/helpers/timezone.helper.js
index 6714620bd0..60fdde94c4 100644
--- a/src/bundle/Resources/public/js/scripts/helpers/timezone.helper.js
+++ b/src/bundle/Resources/public/js/scripts/helpers/timezone.helper.js
@@ -7,16 +7,16 @@
return moment(date).tz(timezone);
};
const formatDate = (date, format = userPreferedFullDateFormat) => {
- return moment(date).formatPHP(format);
- };
- const formatShortDate = (date, format = userPreferedShortDateFormat) => {
- return moment(date).formatPHP(format);
+ return moment(date).formatICU(format);
};
const formatDateWithTimezone = (date, timezone = userPreferedTimezone, format = userPreferedFullDateFormat) => {
return formatDate(convertDateToTimezone(date, timezone), format);
};
+ const formatShortDate = (date, format = userPreferedShortDateFormat) => {
+ return formatDate(date, format);
+ };
const formatShortDateWithTimezone = (date, timezone = userPreferedTimezone, format = userPreferedShortDateFormat) => {
- return formatDate(convertDateToTimezone(date, timezone), format);
+ return formatDateWithTimezone(date, timezone, format);
};
eZ.addConfig('helpers.timezone', {
diff --git a/src/bundle/Resources/views/admin/content_draft/list.html.twig b/src/bundle/Resources/views/admin/content_draft/list.html.twig
index 96ddc65d20..32037c86d4 100644
--- a/src/bundle/Resources/views/admin/content_draft/list.html.twig
+++ b/src/bundle/Resources/views/admin/content_draft/list.html.twig
@@ -75,7 +75,7 @@
{{ row.content_type.name }} |
{{ admin_ui_config.languages.mappings[row.language].name }} |
{{ row.version }} |
- {{ row.modified|localizeddate('medium', 'short', null, ez_user_settings['timezone']) }} |
+ {{ row.modified|ez_full_datetime }} |
|
{% if lastContributor is not empty %}
@@ -30,7 +30,7 @@
{% else %}
{{ 'tab.details.last_contributor.not_found'|trans|desc('Can’t fetch last contributor') }}
{% endif %}
- ({{ versionInfo.modificationDate|localizeddate('medium', 'short', app.request.locale, ez_user_settings['timezone']) }})
+ ({{ versionInfo.modificationDate|ez_full_datetime }})
|
{{ versionInfo.versionNo }} |
diff --git a/src/bundle/Resources/views/content/tab/versions/table.html.twig b/src/bundle/Resources/views/content/tab/versions/table.html.twig
index 0634a4f134..af481f0d49 100644
--- a/src/bundle/Resources/views/content/tab/versions/table.html.twig
+++ b/src/bundle/Resources/views/content/tab/versions/table.html.twig
@@ -60,11 +60,11 @@
|
{% if not is_draft_conflict %}
- {{ version.creationDate|localizeddate('medium', 'short', app.request.locale, ez_user_settings['timezone']) }}
+ {{ version.creationDate|ez_full_datetime }}
|
{% endif %}
- {{ version.modificationDate|localizeddate('medium', 'short', app.request.locale, ez_user_settings['timezone']) }}
+ {{ version.modificationDate|ez_full_datetime }}
|
{% if is_draft_conflict %}
diff --git a/src/bundle/Resources/views/dashboard/tab/all_content.html.twig b/src/bundle/Resources/views/dashboard/tab/all_content.html.twig
index f53be36942..b597511f3c 100644
--- a/src/bundle/Resources/views/dashboard/tab/all_content.html.twig
+++ b/src/bundle/Resources/views/dashboard/tab/all_content.html.twig
@@ -29,7 +29,7 @@
{{ 'dashboard.table.contributor.not_found'|trans|desc('Can’t fetch contributor') }}
{% endif %}
|
- {{ row.modified|localizeddate('medium', 'short', null, ez_user_settings['timezone']) }} |
+ {{ row.modified|ez_full_datetime }} |
- {{ row.modified|localizeddate('medium', 'short', null, ez_user_settings['timezone']) }} |
+ {{ row.modified|ez_full_datetime }} |
{{ row.name }} |
{{ row.type }} |
- {{ row.modified|localizeddate('medium', 'short', null, ez_user_settings['timezone']) }} |
+ {{ row.modified|ez_full_datetime }} |
{{ row.content_type.name }} |
{{ admin_ui_config.languages.mappings[row.language].name }} |
{{ row.version }} |
- {{ row.modified|localizeddate('medium', 'short', null, ez_user_settings['timezone']) }} |
+ {{ row.modified|ez_full_datetime }} |
{{ row.name }} |
{{ row.type }} |
- {{ row.modified|localizeddate('medium', 'short', null, ez_user_settings['timezone']) }} |
+ {{ row.modified|ez_full_datetime }} |
|
{{ relation.contentInfo.name }} |
{{ relation.contentType.name }} |
- {{ relation.contentInfo.publishedDate|localizeddate('short', 'medium', null, ez_user_settings['timezone']) }} |
+ {{ relation.contentInfo.publishedDate|ez_short_datetime }} |
|
{% endfor %}
diff --git a/src/bundle/Resources/views/fieldtypes/preview/ezobjectrelationlist_row.html.twig b/src/bundle/Resources/views/fieldtypes/preview/ezobjectrelationlist_row.html.twig
index d5af1c69b2..e0df2a1856 100644
--- a/src/bundle/Resources/views/fieldtypes/preview/ezobjectrelationlist_row.html.twig
+++ b/src/bundle/Resources/views/fieldtypes/preview/ezobjectrelationlist_row.html.twig
@@ -12,5 +12,5 @@
{{ contentType.getName() }}
|
- {{ content.versionInfo.creationDate|localizeddate( 'short', 'medium', null, ez_user_settings['timezone'] ) }}
+ {{ content.versionInfo.creationDate|ez_short_datetime }}
|
diff --git a/src/bundle/Resources/views/form_fields.html.twig b/src/bundle/Resources/views/form_fields.html.twig
index d7c24055db..55de55cf29 100644
--- a/src/bundle/Resources/views/form_fields.html.twig
+++ b/src/bundle/Resources/views/form_fields.html.twig
@@ -1,5 +1,10 @@
{% extends 'bootstrap_4_layout.html.twig' %}
+{% block form_label -%}
+ {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' ez-label')|trim}) -%}
+ {{ parent() }}
+{%- endblock form_label %}
+
{% block ezsystems_ezplatform_type_udw_widget %}
{{ form_widget(form.location) }}
{{ form_widget(form.select_content) }}
diff --git a/src/bundle/Resources/views/link_manager/list.html.twig b/src/bundle/Resources/views/link_manager/list.html.twig
index 605b1f6f6c..29203fa20b 100644
--- a/src/bundle/Resources/views/link_manager/list.html.twig
+++ b/src/bundle/Resources/views/link_manager/list.html.twig
@@ -68,12 +68,12 @@
{{ url.isValid ? 'url.status.valid'|trans : 'url.status.invalid'|trans }} |
{% if url.lastChecked %}
- {{ url.lastChecked|localizeddate('medium', 'short', null, ez_user_settings['timezone']) }}
+ {{ url.lastChecked|ez_full_datetime }}
{% else %}
Never
{% endif %}
|
- {{ url.modified|localizeddate('medium', 'short', null, ez_user_settings['timezone']) }} |
+ {{ url.modified|ez_full_datetime }} |
{% if can_edit %}
diff --git a/src/bundle/Resources/views/link_manager/view.html.twig b/src/bundle/Resources/views/link_manager/view.html.twig
index 6116de7eb0..d08df655f5 100644
--- a/src/bundle/Resources/views/link_manager/view.html.twig
+++ b/src/bundle/Resources/views/link_manager/view.html.twig
@@ -50,7 +50,7 @@
| {{ 'url.label.last_checked'|trans }} |
{% if url.lastChecked %}
- {{ url.lastChecked|localizeddate('medium', 'short', null, ez_user_settings['timezone']) }}
+ {{ url.lastChecked|ez_full_datetime }}
{% else %}
{{ 'url.label.last_checked.never'|trans|desc('This URL has not been checked') }}
{% endif %}
@@ -58,11 +58,11 @@
|
{{ 'url.label.created'|trans }} |
- {{ url.created|localizeddate('medium', 'short', null, ez_user_settings['timezone']) }} |
+ {{ url.created|ez_full_datetime }} |
{{ 'url.label.modified'|trans }} |
- {{ url.modified|localizeddate('medium', 'short', null, ez_user_settings['timezone']) }} |
+ {{ url.modified|ez_full_datetime }} |
diff --git a/src/bundle/Resources/views/notifications/notification_row.html.twig b/src/bundle/Resources/views/notifications/notification_row.html.twig
index b4de858fed..888ef41e79 100644
--- a/src/bundle/Resources/views/notifications/notification_row.html.twig
+++ b/src/bundle/Resources/views/notifications/notification_row.html.twig
@@ -29,7 +29,7 @@
{% endblock %}
{% block date %}
- {{ notification.created|localizeddate('medium', 'short', null, ez_user_settings['timezone']) }}
+ {{ notification.created|ez_full_datetime }}
|
{% endblock %}
diff --git a/src/bundle/Resources/views/user/settings/update.html.twig b/src/bundle/Resources/views/user/settings/update.html.twig
index 8fc57ee39a..cba724a3c5 100644
--- a/src/bundle/Resources/views/user/settings/update.html.twig
+++ b/src/bundle/Resources/views/user/settings/update.html.twig
@@ -25,7 +25,7 @@
- {{ form_row(form.value, {'label_attr': {'class': 'ez-label'}}) }}
+ {{ form_row(form.value) }}
{{ form_widget(form.update, {'attr': {'hidden': 'hidden'}}) }}
{{ form_end(form) }}
diff --git a/src/lib/Pagination/Pagerfanta/UserSettingsAdapter.php b/src/lib/Pagination/Pagerfanta/UserSettingsAdapter.php
index 351f894b5e..56bc66708b 100644
--- a/src/lib/Pagination/Pagerfanta/UserSettingsAdapter.php
+++ b/src/lib/Pagination/Pagerfanta/UserSettingsAdapter.php
@@ -8,7 +8,7 @@
namespace EzSystems\EzPlatformAdminUi\Pagination\Pagerfanta;
-use EzSystems\EzPlatformAdminUi\UserSetting\UserSettingService;
+use EzSystems\EzPlatformUser\UserSetting\UserSettingService;
use Pagerfanta\Adapter\AdapterInterface;
/**
diff --git a/src/lib/UI/Config/Provider/DateFormat.php b/src/lib/UI/Config/Provider/DateFormat.php
index c7e0b6f3e4..b8e0fd2392 100644
--- a/src/lib/UI/Config/Provider/DateFormat.php
+++ b/src/lib/UI/Config/Provider/DateFormat.php
@@ -9,22 +9,45 @@
namespace EzSystems\EzPlatformAdminUi\UI\Config\Provider;
use EzSystems\EzPlatformAdminUi\UI\Config\ProviderInterface;
+use EzSystems\EzPlatformAdminUi\UserSetting\UserSettingService;
+use EzSystems\EzPlatformUser\UserSetting\Setting\DateTimeFormatSerializer;
-/**
- * @todo Will be refactored once DateFormat becomes a User Setting in 2.4
- */
class DateFormat implements ProviderInterface
{
+ /** @var \EzSystems\EzPlatformAdminUi\UserSetting\UserSettingService */
+ protected $userSettingService;
+
+ /** @var \EzSystems\EzPlatformUser\UserSetting\Setting\DateTimeFormatSerializer */
+ protected $dateTimeFormatSerializer;
+
+ /**
+ * @param \EzSystems\EzPlatformAdminUi\UserSetting\UserSettingService $userSettingService
+ * @param \EzSystems\EzPlatformUser\UserSetting\Setting\DateTimeFormatSerializer $dateTimeFormatSerializer
+ */
+ public function __construct(UserSettingService $userSettingService, DateTimeFormatSerializer $dateTimeFormatSerializer)
+ {
+ $this->userSettingService = $userSettingService;
+ $this->dateTimeFormatSerializer = $dateTimeFormatSerializer;
+ }
+
/**
* {@inheritdoc}
*
- * @return mixed
+ * @return array
*/
- public function getConfig()
+ public function getConfig(): array
{
+ $fullDateTimeFormat = $this->dateTimeFormatSerializer->deserialize(
+ $this->userSettingService->getUserSetting('full_datetime_format')->value
+ );
+
+ $shortDateTimeFormat = $this->dateTimeFormatSerializer->deserialize(
+ $this->userSettingService->getUserSetting('short_datetime_format')->value
+ );
+
return [
- 'full' => 'M j, Y g:i A',
- 'short' => 'd.m.Y g:i A',
+ 'full' => (string)$fullDateTimeFormat,
+ 'short' => (string)$shortDateTimeFormat,
];
}
}
| |