mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 18:03:17 +00:00
PHRAS-2978 #comment Workzone basket: fix date format and tooltip display
This commit is contained in:
@@ -119,6 +119,59 @@ class phraseadate
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param DateTime $date
|
||||
* @return string
|
||||
*/
|
||||
public function getLocalDate(DateTime $date = null)
|
||||
{
|
||||
if (is_null($date)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$compareTo = new DateTime('now');
|
||||
$diff = $compareTo->format('U') - $date->format('U');
|
||||
$currentYear = $date->format('Y');
|
||||
$dayDiff = floor($diff / 86400);
|
||||
|
||||
if (is_nan($dayDiff) || $dayDiff > 365000) {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
|
||||
$date_string_Y = new IntlDateFormatter($this->app['locale'], NULL, NULL, NULL, NULL, 'dd MMMM yyyy');
|
||||
// $date_string_M = new IntlDateFormatter($this->app['locale'], NULL, NULL, NULL, NULL, 'dd MMMM');
|
||||
|
||||
if ($dayDiff == 0) {
|
||||
if ($diff < 60) {
|
||||
return $this->app->trans('phraseanet::temps:: a l\'instant');
|
||||
} elseif ($diff < 120) {
|
||||
return $this->app->trans('phraseanet::temps:: il y a une minute');
|
||||
} elseif ($diff < 3600) {
|
||||
return $this->app->trans('phraseanet::temps:: il y a %quantity% minutes', ['%quantity%' => floor($diff / 60)]);
|
||||
} elseif ($diff < 7200) {
|
||||
return $this->app->trans('phraseanet::temps:: il y a une heure');
|
||||
} elseif ($diff < 86400) {
|
||||
return $this->app->trans('phraseanet::temps:: il y a %quantity% heures', ['%quantity%' => floor($diff / 3600)]);
|
||||
}
|
||||
} elseif ($dayDiff == 1) {
|
||||
return $this->app->trans('phraseanet::temps:: hier');
|
||||
|
||||
}else {
|
||||
// current year
|
||||
/* if (date('Y')== $currentYear) {
|
||||
return $date_string_M->format($date);
|
||||
}*/
|
||||
//return $date_string_Y->format($date);
|
||||
}
|
||||
|
||||
|
||||
|
||||
return $date_string_Y->format($date);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param DateTime $date
|
||||
|
@@ -8,21 +8,22 @@
|
||||
|
||||
{% block content %}
|
||||
<div class="noToolTipResize" style="margin:5px;width:{{ width - 40 }}px;height:auto !important;height:380px;max-height:380px;min-height:220px;position:relative;">
|
||||
<span class="expiredDate">
|
||||
{% if basket.getValidation() %}
|
||||
{% set dateExpired = app['date-formatter'].getLocalDate(basket.getValidation().getExpires()) %}
|
||||
{{ 'workzone:feedback:expiration' | trans }} : {{ dateExpired }}
|
||||
{% endif %}
|
||||
</span>
|
||||
<div style="margin:5px 0;max-height:160px;overflow:hidden;text-overflow:ellipsis;">
|
||||
{{ basket.getDescription()|nl2br }}
|
||||
</div>
|
||||
<div style="margin:5px 0;font-style:italic;position:relative;width: 100%">
|
||||
{% set nb_records = basket.getElements()|length %}
|
||||
{% set date = app['date-formatter'].getPrettyString(basket.getUpdated()) %}
|
||||
<span class="expiredDate" style="width: 40%; display: inline-block">
|
||||
{% if basket.getValidation() %}
|
||||
{% set dateExpired = app['date-formatter'].getPrettyString(basket.getValidation().getExpires()) %}
|
||||
{{ 'workzone:feedback:expiration' | trans }} : {{ dateExpired }}
|
||||
{% endif %}
|
||||
</span>
|
||||
<div style="text-align:right;width: 50%;display: inline-block">
|
||||
{% set date = app['date-formatter'].getLocalDate(basket.getUpdated()) %}
|
||||
|
||||
<div style="text-align:right">
|
||||
{% trans with {'%nb_records%' : nb_records} %}%nb_records% records{% endtrans %}
|
||||
- {{ date }}
|
||||
- {{ 'prod:workzone:basket:creation-date' | trans }} : {{ date }}
|
||||
</div>
|
||||
<hr/>
|
||||
<div style="position:relative;float:left;width:470px;">
|
||||
|
@@ -89,7 +89,7 @@
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if basket.getValidation() %}
|
||||
{% set dateExpired = app['date-formatter'].getPrettyString(basket.getValidation().getExpires()) %}
|
||||
{% set dateExpired = app['date-formatter'].getLocalDate(basket.getValidation().getExpires()) %}
|
||||
<span class="expiredDate" style="float: right; padding: 8px;margin-top: -39px;">
|
||||
{{ 'workzone:feedback:expiration' | trans }} : {{ dateExpired }}</span>
|
||||
{% endif %}
|
||||
|
Reference in New Issue
Block a user