/** * Retrieves a message, removes it from the session and prints it - will not print if no content * * The message will be printed in a `p` tag if it does not contain * any block level HTML, otherwise it will be printed in a `div` tag. * * @param mixed $name The name or array of names of the message(s) to show, or `'*'` to show all * @param string $recipient The intended recipient * @param string $css_class Overrides using the `$name` as the CSS class when displaying the message - only used if a single `$name` is specified * @return boolean If one or more messages was shown */ public static function show($name, $recipient = NULL, $css_class = NULL) { if ($recipient === NULL) { $recipient = '{default}'; } // Find all messages if * is specified if (is_string($name) && $name == '*') { fSession::open(); $prefix = __CLASS__ . '::' . $recipient . '::'; $keys = array_keys($_SESSION); $name = array(); foreach ($keys as $key) { if (strpos($key, $prefix) === 0) { $name[] = substr($key, strlen($prefix)); } } } // Handle showing multiple messages if (is_array($name)) { $shown = FALSE; $names = $name; foreach ($names as $name) { $class = trim(self::$class . ' ' . $name); $class = $css_class === NULL ? $class : $css_class; $shown = fHTML::show(self::retrieve($name, $recipient), $class, TRUE) || $shown; } return $shown; } $class = self::$class . ' ' . $name; $class = $css_class === NULL ? $class : $css_class; // Handle a single message return fHTML::show(self::retrieve($name, $recipient), $class, TRUE); }