%s'; const _DEBUG_ = '
%s
'; const _CLASS_ERROR_15_ = 'error'; const _CLASS_WARNING_15_ = 'warn'; const _CLASS_SUCCESS_15_ = 'conf'; const _CLASS_INFO_15_ = 'info hint'; const _CLASS_ERROR_16_ = 'alert alert-danger'; const _CLASS_WARNING_16_ = 'alert alert-warning'; const _CLASS_SUCCESS_16_ = 'alert alert-success'; const _CLASS_INFO_16_ = 'alert alert-info'; protected static $msg_list = array(); protected static $has_error_msg = false; protected static $has_warning_msg = false; protected static $has_success_msg = false; protected static $has_info_msg = false; /** * Generate the HTML code corresponding to an error message * * @param String $msg */ public static function error($msg = 'Error') { $error_msg = null; if (version_compare(_PS_VERSION_, '1.6', '<')) $error_msg = sprintf(self::_MESSAGE_, self::_CLASS_ERROR_15_, $msg); else $error_msg = '
'.sprintf(self::_MESSAGE_, self::_CLASS_ERROR_16_, $msg).'
'; self::$has_error_msg = true; self::$msg_list[] = $error_msg; } /** * Generate the HTML code corresponding to a warning message * * @param String $msg */ public static function warning($msg = 'Warning') { $warning_msg = null; if (version_compare(_PS_VERSION_, '1.6', '<')) $warning_msg = sprintf(self::_MESSAGE_, self::_CLASS_WARNING_15_, $msg); else $warning_msg = '
'.sprintf(self::_MESSAGE_, self::_CLASS_WARNING_16_, $msg).'
'; self::$has_warning_msg = true; self::$msg_list[] = $warning_msg; } /** * Generate the HTML code corresponding to a success message * * @param String $msg */ public static function success($msg = 'Success') { $success_msg = null; if (version_compare(_PS_VERSION_, '1.6', '<')) $success_msg = sprintf(self::_MESSAGE_, self::_CLASS_SUCCESS_15_, $msg); else $success_msg = '
'.sprintf(self::_MESSAGE_, self::_CLASS_SUCCESS_16_, $msg).'
'; self::$has_success_msg = true; self::$msg_list[] = $success_msg; } /** * Generate the HTML code corresponding to an information message * * @param String $msg */ public static function info($msg = 'Success') { $info_msg = null; if (version_compare(_PS_VERSION_, '1.6', '<')) $info_msg = sprintf(self::_MESSAGE_, self::_CLASS_INFO_15_, $msg); else $info_msg = '
'.sprintf(self::_MESSAGE_, self::_CLASS_INFO_16_, $msg).'
'; self::$has_info_msg = true; self::$msg_list[] = $info_msg; } /** * Generate the HTML code corresponding to a debug message * * @param String $msg */ public static function debug($msg = 'Debug') { $info_msg = null; if (version_compare(_PS_VERSION_, '1.6', '<')) $info_msg = sprintf(self::_DEBUG_, self::_CLASS_INFO_15_, $msg); else $info_msg = '
'.sprintf(self::_DEBUG_, self::_CLASS_INFO_16_, $msg).'
'; self::$msg_list[] = $info_msg; } /** * Return the html code of all messages to be displayed * * @return String */ public static function display() { $html = ''; if (count(self::$msg_list)) foreach (self::$msg_list as $msg) $html .= $msg; return ($html); } /** * Return the list of message * * @return Array */ public static function getMessageList() { return (self::$msg_list); } /** * Return true if the message list contain at least 1 error message * * @return Boolean */ public static function hasErrorMessage() { return (self::$has_error_msg); } /** * Return true if the message list contain at least 1 warning message * * @return Boolean */ public static function hasWarningMessage() { return (self::$has_warning_msg); } /** * Return true if the message list contain at least 1 success message * * @return Boolean */ public static function hasSuccessMessage() { return (self::$has_success_msg); } /** * Return true if the message list contain at least 1 information message * * @return Boolean */ public static function hasInfoMessage() { return (self::$has_info_msg); } }