diff --git a/lam/lib/status.inc b/lam/lib/status.inc index 9a2856d4..9892c30f 100644 --- a/lam/lib/status.inc +++ b/lam/lib/status.inc @@ -4,6 +4,7 @@ $Id$ This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) Copyright (C) 2003 - 2006 Michael Duergner + 2011 Roland Gruber This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -46,8 +47,10 @@ $Id$ *
It may be formatted with special color/link/bold tags. This parameter is optional. * @param array $MessageVariables The variables that are used to replace the spacers (%s) in the * submitted text. This parameter is optional. + * @param boolean $returnOutput if set to true this function will return the generated HTML code instead of printing it directly (default: false) + * @return String HTML code if $returnOutput is set to true, otherwise null */ -function StatusMessage($MessageTyp,$MessageHeadline,$MessageText='',$MessageVariables = array()) { +function StatusMessage($MessageTyp,$MessageHeadline,$MessageText='',$MessageVariables = array(), $returnOutput = false) { /* Setting CSS-StyleSheet class depending on the $MessageTyp and rewriting $MessageTyp with a readable string. */ if($MessageTyp == "INFO") { $class = "class=\"statusInfo ui-corner-all\""; @@ -79,18 +82,26 @@ function StatusMessage($MessageTyp,$MessageHeadline,$MessageText='',$MessageVari $MessageHeadline = "

" . $MessageHeadline . "

"; // Format $MessageHeadline $MessageText = "

" . $MessageText . "

"; // Format $MessageText $format = "
\n\n\n\n\n\n
" . $MessageTyp . "" . $MessageHeadline . $MessageText . "
\n
\n"; + $output = ''; if (is_array($MessageVariables)) { if (sizeof($MessageVariables) > 0) { array_unshift($MessageVariables, $format); - call_user_func_array('printf',$MessageVariables); + $output = call_user_func_array('sprintf',$MessageVariables); } else { - echo $format; + $output = $format; } } else { - printf($format, $MessageVariables); + $output = sprintf($format, $MessageVariables); } + if ($returnOutput) { + return $output; + } + else { + echo $output; + } + return null; } /**