function getFullMonthName($month, $lang) { $vowels = str_split("_aeiouy"); $consonant = array('FR' => ' de ', 'EN' => ' of '); $vowel = array('FR' => ' d\'', 'EN' => ' of '); $lMonth = getFullMonth($month, $lang); $firstLetter = substr($lMonth, 0, 1); if (array_search($firstLetter, $vowels) != false) { return $vowel[$lang] . $lMonth; } else { return $consonant[$lang] . $lMonth; } }
$lang = $vars['lang']; $template .= '<h1>Archives</h1><br />'; if (isset($vars['y']) && !empty($vars['y'])) { if (isset($vars['m']) && !empty($vars['m'])) { $month = str_pad($vars['m'], 2, "0", STR_PAD_LEFT); $results = getNews('article_date::' . $vars['y'] . '-' . $month . '%'); if (count($results) == 0) { $lMonth = getFullMonthName($month, $lang); $template .= "<p>Pas d'article trouvé en base pour le mois " . $lMonth . ".</p>"; } else { foreach ($results as $news) { $template .= '<div class="article"><div class="article-header">' . ' <h1>' . $news["title"] . '</h1>' . '</div>' . $news["description"] . '<a href="' . root() . '/' . $news["link"] . '">Lire la suite</a>' . '<div class="social-media-end">' . '</div>' . '</div>'; } } } else { $template .= '<div id="archives">'; for ($i = 12; $i >= 1; $i--) { $month = str_pad($i, 2, "0", STR_PAD_LEFT); $results = getNews('article_date::' . $vars['y'] . '-' . $month . '%'); $template .= '<div class="article">' . ' <p><a href="' . root() . '/archives/' . $vars['y'] . '/' . $month . '">' . ucfirst(getFullMonth($month, $lang)) . '</a> (' . count($results) . ')</p>' . '</div>'; } $template .= '</div>'; } } else { $template .= '<div id="archives">'; for ($i = $current_year; $i >= $open_year; $i--) { $results = getNews('article_date::' . $i . '%'); $template .= '<div class="article">' . ' <p><a href="' . root() . '/archives/' . $i . '">' . $i . '</a> (' . count($results) . ')</p>' . '</div>'; } $template .= '</div>'; }