/
MessageHelper.class.php
106 lines (101 loc) · 3.21 KB
/
MessageHelper.class.php
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?php
/*##################################################
* MessageHelper.class.php
* -------------------
* begin : Januar 07, 2011
* copyright : (C) 2011 Régis Viarre
* email : crowkait@phpboost.com
*
*
###################################################
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
###################################################*/
/**
* @desc Message Helper
* @author Régis Viarre <crowkait@phpboost.com>
* @package {@package}
*/
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_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;
}
}
?>