diff --git a/core/include/comment.inc.php b/core/include/comment.inc.php index 29a215e..e5165cb 100644 --- a/core/include/comment.inc.php +++ b/core/include/comment.inc.php @@ -7,6 +7,23 @@ // Lexique include('./core/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_core.php'); +// Pour les dates suivant la langue de rédaction du site (langue principale ou langue de traduction rédigée) +if( function_exists('datefmt_create') && function_exists('datefmt_format') && extension_loaded('intl') ){ + if( isset( $_SESSION['langFrontEnd']) && isset( $_SESSION['translationType']) && $_SESSION['translationType'] === 'site' ){ + $lang_date = $_SESSION['langFrontEnd']; + } else { + $lang_date = $this->getData(['config', 'i18n', 'langBase']); + } + $zone = 'Europe/Paris'; + $fmt = datefmt_create( + $lang_date, + IntlDateFormatter::LONG, + IntlDateFormatter::SHORT, + $zone, + IntlDateFormatter::GREGORIAN + ); +} + // Création du brouillon s'il n'existe pas if( !isset($_SESSION['draftPage'])){ $_SESSION['draftPage'] = []; @@ -81,12 +98,16 @@ if($this->isPost() && isset($_POST['commentPageFormSubmit']) ) { // Crée les données, l'indice des messages est la date unix $id = time(); $this->setData(['comment', $this->getUrl(0), 'data', $id , $data]); - // Ajout de la date en clair pour les données dans le json - if( $this->getData(['config', 'i18n', 'langAdmin']) === 'en' ){ - $dateMessage = date('m/d/Y H:i', $id); + // Enregistrement de la date formatée + if( function_exists('datefmt_create') && function_exists('datefmt_format') && extension_loaded('intl') ){ + $dateMessage = datefmt_format($fmt, strtotime( date('Y/m/d H:i:s',$id))); } else { - $dateMessage = date('d/m/Y H:i', $id); - } + if( mb_detect_encoding(date('d/m/Y - H:i', $id), 'UTF-8', true)){ + $dateMessage = date('d/m/Y - H:i', $id); + } else { + $dateMessage = utf8_encode(date('d/m/Y - H:i', $id)); + } + } $this->setData(['comment', $this->getUrl(0), 'data', $id , 'Date' , $dateMessage ]); // Liste des utilisateurs $userIdsFirstnames = helper::arrayCollumn($this->getData(['user']), 'firstname'); @@ -182,7 +203,7 @@ if ( NULL !== $dataPage && is_array($dataPage) && $dataPage !== [] ) { for($i = $pagination['first']; $i < $pagination['last']; $i++) { $content = ''; $dataKeys = array_keys($dataPage[$i]); - $content .= '