_sysmsg = $_SESSION['e107_system_messages']; return $this->resetSession(); } return $this->reset(); } /** * Get singleton instance * * @return object eMessage instance * @access public static */ function &getInstance() { static $instance = array(); if(empty($instance)) { $instance[0] = new eMessage('e107_emessage_php4_very_long_hard_to_remember_check'); } return $instance[0]; } /** * Add message to a type stack * * @param string $message * @param string $type * @param bool $session * @return eMessage */ function add($message, $type = E_MESSAGE_INFO, $session = false) { if(empty($message)) return $this; if(!$session) { if($this->isType($type)) $this->_sysmsg[$type][] = $message; return $this; } return $this->addSession($message, $type); } /** * Add message to a _SESSION type stack * * @param string $message * @param string $type * @return eMessage */ function addSession($message, $type = E_MESSAGE_INFO) { if(empty($message)) return $this; if($this->isType($type)) $_SESSION['e107_system_messages'][$type][] = $message; return $this; } /** * Get type title (multi-language) * * @param string $type * @return string title * * @access public static */ function getTitle($type) { return defsettrue('EMESSLAN_TITLE_'.strtoupper($type), ''); } /** * Message getter * * @param string $type valid type * @param bool $raw force array return * @param bool $reset reset message type stack * @return string|array message */ function get($type, $raw = false, $reset = true) { $message = varsettrue($this->_sysmsg[$type], array()); if($reset) $this->reset($type); return (true === $raw ? $message : eMessage::formatMessage($type, $message)); } /** * Session message getter * * @param string $type valid type * @param bool $raw force array return * @param bool $reset reset session message type stack * @return string|array session message */ function getSession($type, $raw = false, $reset = true) { $message = varsettrue($_SESSION['e107_system_messages'][$type], array()); if($reset) $this->resetSession($type); return (true === $raw ? $message : eMessage::formatMessage($type, $message)); } /** * Output all accumulated messages * * @param bool $raw force return type array * @param bool $reset reset all messages * @param bool $session merge with session messages * @return array|string messages */ function render($raw = false, $reset = true, $session = false) { if($session) { $this->_merge(); } $ret = array(); foreach ($this->_get_types() as $type) { $message = $this->get($type, $raw); if(!empty($message)) { $ret[$type] = $message; } } if($reset) $this->reset(false); if(true === $raw || empty($ret)) return ($raw ? $ret : ''); //changed to class return "
".implode("\n", $ret)."
"; } /** * Create message block markup based on its type. * * @param string $type * @param array|string $message * @return string formated message * * @access public static */ function formatMessage($type, $message) { if (empty($message)) return ''; elseif (is_array($message)) { $message = "
".implode("
\n
", $message)."
"; } return "
".eMessage::getTitle($type)."
{$message}
"; } /** * Reset message array * * @param mixed $type false for reset all, or type constant * @param bool $session reset session messages as well * @return eMessage */ function reset($type = false, $session = false) { if(false === $type) $this->_sysmsg = $this->_type_map(); elseif(isset($this->_sysmsg[$type])) $this->_sysmsg[$type] = array(); if($session) $this->resetSession($type); return $this; } /** * Reset _SESSION message array * * @param mixed $type false for reset all, or valid type constant * @return eMessage */ function resetSession($type = false) { if(!$type) $_SESSION['e107_system_messages'] = $this->_type_map(); elseif(isset($_SESSION['e107_system_messages'][$type])) $_SESSION['e107_system_messages'][$type] = array(); return $this; } /** * Merge _SESSION message array with the current messages * * @param bool $reset * @return eMessage */ function _merge($reset = true) { foreach (array_keys($_SESSION['e107_system_messages']) as $type) { if(!$this->isType($type)) continue; $this->_sysmsg[$type] = array_merge($this->_sysmsg[$type], $_SESSION['e107_system_messages'][$type]); } if($reset) $this->resetSession(); return $this; } /** * Check passed type against the type map * * @param mixed $type * @return bool */ function isType($type) { return (array_key_exists($type, $this->_type_map())); } /** * Check for messages * * @param mixed $type * @param bool $session * @return bool */ function hasMessage($type = false, $session = true) { if(false === $type) { foreach ($this->_get_types() as $_type) { if($this->get($_type, true, false) || ($session && $this->getSession($_type, true, false))) { return true; } } } return ($this->get($type, true, false) || ($session && $this->getSession($type, true, false))); } /** * Balnk type array structure * * @return array type map */ function _type_map() { //show them in this order! return array( E_MESSAGE_ERROR => array(), E_MESSAGE_WARNING => array(), E_MESSAGE_SUCCESS => array(), E_MESSAGE_INFO => array(), E_MESSAGE_DEBUG => array() ); } /** * Get all valid message types * * @return array valid message types */ function _get_types() { return array_keys($this->_type_map()); } } function show_emessage($mode, $message, $line = 0, $file = "") { global $tp; if(is_numeric($message)) { include_lan(e_LANGUAGEDIR.e_LANGUAGE."/lan_error.php"); $emessage[1] = "".LAN_ERROR_25.""; $emessage[2] = "".LAN_ERROR_26.""; $emessage[3] = "".LAN_ERROR_27.""; $emessage[4] = "".LAN_ERROR_28.""; $emessage[5] = LAN_ERROR_29; $emessage[6] = "".LAN_ERROR_30.""; $emessage[7] = "".LAN_ERROR_31.""; $emessage[8] = "
".LAN_ERROR_32."

".chr(36)."ADMIN_DIRECTORY = \"e107_admin/\";
".chr(36)."FILES_DIRECTORY = \"e107_files/\";
".chr(36)."IMAGES_DIRECTORY = \"e107_images/\";
".chr(36)."THEMES_DIRECTORY = \"e107_themes/\";
".chr(36)."PLUGINS_DIRECTORY = \"e107_plugins/\";
".chr(36)."HANDLERS_DIRECTORY = \"e107_handlers/\";
".chr(36)."LANGUAGES_DIRECTORY = \"e107_languages/\";
".chr(36)."HELP_DIRECTORY = \"e107_docs/help/\";
".chr(36)."DOWNLOADS_DIRECTORY = \"e107_files/downloads/\";\n
"; } if (class_exists('e107table')) { $ns = new e107table; } switch($mode) { case "CRITICAL_ERROR" : $message = $emessage[$message] ? $emessage[$message] : $message; if (is_readable(e_THEME.'index.html')) { require_once(e_THEME.'index.html'); exit; } echo "
CRITICAL_ERROR:
Line $line $file

Error reported as: ".$message."
"; break; case "MESSAGE": if(strstr(e_SELF, "forum_post.php")) { return; } $ns->tablerender("", "
{$message}
"); break; case "ADMIN_MESSAGE": $ns->tablerender("Admin Message", "
{$message}
"); break; case "ALERT": $message = $emessage[$message] ? $emessage[$message] : $message; echo "\n"; exit; break; case "P_ALERT": echo "\n"; break; case "POPUP": $mtext = "Message
--- Message ---

".$message."

"; echo " "; break; } } ?>