*/ class LSerror { /** * Ajoute une erreur * * @author Benjamin Renard * * @param[in] $code numeric Le code de l'erreur * @param[in] $msg mixed Un tableau ou une chaine pour la construction du message d'erreur * Tableau : '[clef]' => 'valeur' * La clef sera utilisé dans le format de message d'erreur * dans le fichier 'error_code.php'. * * @retval void */ static function addErrorCode($code=-1,$msg='') { $_SESSION['LSerror'][] = array($code,$msg); } /** * Affiche les erreurs * * @author Benjamin Renard * * @param[in] $return boolean True pour que le texte d'erreurs soit retourné * * @retval void */ static function display($return=False) { $errors = self::getErrors(); if ($errors) { if ($return) { return $errors; } $GLOBALS['Smarty'] -> assign('LSerrors',$errors); } } /** * Print errors and stop LdapSaisie * * @author Benjamin Renard * * @param[in] $code Error code (Goto : addErrorCode()) * @param[in] $msg Error msg (Goto : addErrorCode()) * * @retval void */ static function stop($code=-1,$msg='') { if(!empty($_SESSION['LSerror'])) { print "

"._('Errors')."

\n"; print self::display(true); } print "

"._('Stop')."

\n"; exit (self::getError(array($code,$msg))); } /** * Retourne le texte des erreurs * * @author Benjamin Renard * * @retvat string Le texte des erreurs */ static function getErrors() { if(!empty($_SESSION['LSerror'])) { foreach ($_SESSION['LSerror'] as $error) { $txt.=self::getError($error); } self::resetError(); return $txt; } return; } /** * Retourne le texte d'une erreur * * @author Benjamin Renard * * @retvat string Le texte des erreurs */ static function getError($error) { return "(Code ".$error[0].") ".getFData($GLOBALS['LSerror_code'][$error[0]]['msg'],$error[1])."
\n"; } /** * Définir si il y a des erreurs * * @author Benjamin Renard * * @retvat boolean */ static function errorsDefined() { return !empty($_SESSION['LSerror']); } /** * Efface les erreurs sotckés * * @author Benjamin Renard * * @retvat void */ static function resetError() { unset ($_SESSION['LSerror']); } } /* * Error Codes */ $GLOBALS['LSerror_code']['-1'] = array ( 'msg' => _("Unknow error!") ); $GLOBALS['LSerror_code'][0] = array ( 'msg' => "%{msg}" ); ?>