" . $value . ""; } return $return; } /** * Enregistre un message d'erreur lié à un champ de formulaire. * * @param string $_string Le champ de formulaire en erreur. * @return void */ public static function recErrorInput(string $_string) { if (empty($_SESSION["alert"]["input"])) { $_SESSION["alert"]["input"] = array(); } array_push($_SESSION["alert"]["input"], $_string); } /** * Vérifie si un champ de formulaire est en erreur. * * @param string $_string Le champ de formulaire à vérifier. * @return bool TRUE si le champ est en erreur, FALSE sinon. */ public static function ifErrorInput(string $_string) { return (in_array($_string, $_SESSION["alert"]["input"])) ? TRUE : FALSE; } /** * Affiche une alerte sous forme de toast. * * @param string $_idAlert L'ID de l'alerte. * @param string $_style Le style CSS de l'alerte. * @param string $_icon L'icône de l'alerte. * @param array|null $_texte Le texte de l'alerte. * @return void */ private static function printToast(string $_idAlert, string $_style, string $_icon, ?array $_texte = NULL) { $text = ($_texte != NULL) ? self::printAlert($_texte) : NULL; echo ' '; } /** * Affiche toutes les alertes enregistrées. * * @return void */ public static function show() { historique::recordLogs(); echo '
'; $idAlert = "printToastSuccess"; $texte1 = (self::getSuccess()) ? self::getSuccess() : NULL; $style = 'background:#d4edda;'; $icon = icon::getFont(["type" => "info", "color" => "green", "size" => "18px"]) . ' Succès'; self::printToast($idAlert, $style, $icon, $texte1); $idAlert = "printToastWarning"; $texte2 = (self::getWarning()) ? self::getWarning() : NULL; $style = 'background:#fff3cd;'; $icon = icon::getFont(["type" => "warning", "color" => "orange", "size" => "18px"]) . ' Attention'; self::printToast($idAlert, $style, $icon, $texte2); $idAlert = "printToastError"; $texte3 = (self::getError()) ? self::getError() : NULL; $style = 'background:#f8d7da;'; $icon = icon::getFont(["type" => "alert", "color" => "red", "size" => "18px"]) . ' Erreur'; self::printToast($idAlert, $style, $icon, $texte3); echo '
'; echo ($texte1 == NULL) ? '' : ''; echo ($texte2 == NULL) ? '' : ''; echo ($texte3 == NULL) ? '' : ''; self::destroyAlert(); } /** * Supprime toutes les alertes enregistrées. * * @return void */ public static function destroyAlert() { unset($_SESSION["alert"]); } }