89 lines
2.6 KiB
PHP
89 lines
2.6 KiB
PHP
<?php
|
|
|
|
|
|
$press_kit_datas = get_field('press_kit_datas', 'option');
|
|
|
|
if (!function_exists('getRessourceIcon')) {
|
|
function getRessourceIcon($ressource_type)
|
|
{
|
|
switch ($ressource_type) {
|
|
case 'image/svg+xml':
|
|
case 'image/png':
|
|
case 'image/jpeg':
|
|
return plugin_dir_url(__DIR__) . "src/img/homegrade_image.svg";
|
|
|
|
case 'application/pdf':
|
|
return plugin_dir_url(__DIR__) . "src/img/homegrade_fiches.svg";
|
|
|
|
default:
|
|
return plugin_dir_url(__DIR__) . "src/img/homegrade_fiches.svg";
|
|
}
|
|
}
|
|
}
|
|
if (!function_exists('getRessourceTypeName')) {
|
|
function getRessourceTypeName($subtype)
|
|
{
|
|
switch ($subtype) {
|
|
case 'svg+xml':
|
|
return "svg";
|
|
default:
|
|
return $subtype;
|
|
}
|
|
}
|
|
}
|
|
?>
|
|
|
|
<section <?php echo get_block_wrapper_attributes(["class" => "homegrade-blocks-kit-presse"]); ?>>
|
|
<?php echo $content; ?>
|
|
|
|
<ul class="homegrade-blocks-kit-presse__press-grid-datas">
|
|
|
|
<div class="table_head" aria-hidden="true">
|
|
<p><?php echo __("Fichier", "homegrade-blocks") ?></p>
|
|
<p><?php echo __("Format", "homegrade-blocks") ?></p>
|
|
<p><?php echo __("Mise à jour", "homegrade-blocks") ?></p>
|
|
</div>
|
|
<?php foreach ($press_kit_datas as $data) : ?>
|
|
<?php
|
|
$ressourceType = $data['mime_type'];
|
|
$ressourceIcon = getRessourceIcon($ressourceType);
|
|
|
|
$currentLanguage = apply_filters('wpml_current_language', NULL);
|
|
$locale = $currentLanguage === "fr" ? 'fr_FR' : 'nl_NL';
|
|
$timezone = 'Europe/Paris';
|
|
$pattern = 'MMMM yyyy';
|
|
|
|
$dateTime = new DateTime($data['modified']);
|
|
|
|
$formatter = new IntlDateFormatter(
|
|
$locale,
|
|
IntlDateFormatter::NONE, // Pas besoin de format de date intégré
|
|
IntlDateFormatter::NONE, // Pas besoin de format de temps
|
|
$timezone,
|
|
IntlDateFormatter::GREGORIAN,
|
|
$pattern // Utiliser le format personnalisé ici
|
|
);
|
|
|
|
$postModifiedDate = $formatter->format($dateTime);
|
|
?>
|
|
|
|
<li class="homegrade-blocks-kit-presse__press-ressource">
|
|
<div class="homegrade-blocks-kit-presse__ressource-typename">
|
|
<div class="homegrade-blocks-kit-presse__ressource-icon">
|
|
<img src="<?php echo $ressourceIcon ?>" alt="">
|
|
</div>
|
|
<p class="homegrade-blocks-kit-presse__ressource-title"><?php echo $data['title'] ?></p>
|
|
</div>
|
|
<p class="homegrade-blocks-kit-presse__ressource-type"><?php echo getRessourceTypeName($data['subtype']) ?></p>
|
|
<p class="homegrade-blocks-kit-presse__ressource-date"><?php echo $postModifiedDate ?></p>
|
|
<a class="homegrade-blocks-kit-presse__ressource-download cta cta--secondary cta--button" href="<?php echo $data['url'] ?>" download><?php echo __('Télécharger', "homegrade-blocks__texte-fonctionnel") ?></a>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
<?php endforeach; ?>
|
|
|
|
</ul>
|
|
|
|
</section>
|