1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89:
<?php
class MessageHelper
{
const SUCCESS = 'success';
const NOTICE = 'notice';
const WARNING = 'warning';
const ERROR = 'error';
const QUESTION = 'question';
const MEMBER_ONLY = 'member_only';
const MODERATOR_ONLY = 'moderator_only';
const ADMIN_ONLY = 'admin_only';
const GROUP = 'group_only';
public static function display($content, $type, $timeout = 0, $display_small = false)
{
$tpl = new FileTemplate('framework/helper/message.tpl');
$group_only = false;
switch ($type)
{
case self::SUCCESS:
$css_class = 'success';
$image = 'error_success';
break;
case self::NOTICE:
$css_class = 'notice';
$image = 'error_notice';
break;
case self::WARNING:
$css_class = 'warning';
$image = 'error_warning';
break;
case self::ERROR:
$css_class = 'error';
$image = 'error_fatal';
break;
case self::QUESTION:
$css_class = 'question';
$image = 'error_question';
break;
case self::MEMBER_ONLY:
$css_class = 'member-only';
$image = 'error_member_only';
break;
case self::MODERATOR_ONLY:
$css_class = 'modo-only';
$image = 'error_modo_only';
break;
case self::ADMIN_ONLY:
$css_class = 'admin-only';
$image = 'error_admin_only';
break;
default:
$css_class = $type . ' ' . self::GROUP;
$image = 'error_' . $type . '_' . self::GROUP;
$group_only = true;
}
$tpl->put_all(array(
'ID' => KeyGenerator::generate_key(4),
'MESSAGE_CSS_CLASS' => $css_class . ($display_small ? ' message-helper-small' : ''),
'MESSAGE_IMG' => $image,
'MESSAGE_CONTENT' => $content,
'C_FLOATING' => $timeout != 0,
'C_TIMEOUT' => $timeout > 0,
'TIMEOUT' => $timeout * 1000,
'C_MEMBER_ONLY' => $type == self::MEMBER_ONLY,
'C_MODERATOR_ONLY' => $type == self::MODERATOR_ONLY,
'C_ADMIN_ONLY' => $type == self::ADMIN_ONLY,
'C_GROUP_ONLY' => $group_only
));
return $tpl;
}
}
?>