Repository navigation
Expand file tree
/
Copy pathMessage.php
More file actions
191 lines (169 loc) · 4.42 KB
/
Copy pathMessage.php
File metadata and controls
191 lines (169 loc) · 4.42 KB
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
<?php
/**
* OPEN SOURCE SOLUTIONS LIMITED - CONFIDENTIAL
* ____________________________________________
*
* Copyright (c) 2009-2012 Open Source Solutions Limited
* All rights reserved.
*
* This file is part of Open Source Solutions Limited's "ONLINE
* PAYROLL MANAGEMENT APPLICATION".
*
* Information in this file is strictly confidential and the
* property of Open Source Solutions Limited and may not be
* extracted or distributed, in whole or in part, for any
* purpose whatsoever, without the express written consent
* from Open Source Solutions Limited.
*
* Open Source Solutions Limited is a company registered in Dublin,
* Ireland with the Companies Registration Office (#438231). We
* trade as Open Solutions with registered business name (#329120).
* Our registered office is 147 Stepaside Park, Stepaside,
* Dublin 18, Ireland.
*
* Contact us via http://www.opensolutions.ie/
* or info@opensolutions.ie or +353 1 685 4220.
*/
/**
* A class to encapsulate messages to be displayed on the webpages.
*
* These are the main required elements for this:
*
* 1. The OSS/Message.php class (this file)
* 2. The OSS/Smarty/functions/function.OSS_Message.php (to display the message on the view)
* 3. The relevent CSS classes in public/css/oss.css
*
* To use this, add a message to the view as follows:
*
* public function exampleAction() {
* $this->view->ossAddMessage( new OSS_Message( 'This is a info message!', OSS_Message::INFO ) );
* }
*
* Multiple messages can be added of different kinds (INFO, ALERT, etc).
*
* Then to display these messages in your view (Smarty template) just include the following
* text (i.e. Smarty function):
*
* {OSS_Message}
*
*/
/**
* OSS: Message
*
* @author Barry O'Donovan <barry@opensolutions.ie>
* @author Roland Huszti <roland@opensolutions.ie>
* @author Nerijus Barauskas <nerijus@opensolutions.ie>
* @category OSS
* @package OSS_Message
* @copyright Copyright (c) 2009 - 2012 Open Source Solutions Limited, Dublin, Ireland
*/
class OSS_Message
{
const INFO = 'info';
const WARNING = 'warning';
const ALERT = 'warning';
const SUCCESS = 'success';
const ERROR = 'error';
const TYPE_MESSAGE = 0;
const TYPE_BLOCK = 1;
const TYPE_POP_UP = 2;
/**
* The type of OSS_Message
*
* @var int
*/
protected $type = self::TYPE_MESSAGE;
/**
* A variable to hold the message (either scalar string or array of strings )
*
* @var mixed
*/
protected $message;
/**
* A variable to hold the appropriate HTML class (e.g. error, success, info)
*
* @var string
*/
protected $class = '';
/**
* A variable to indicate whether the message is HTML or not
*
* @var bool
*/
protected $isHTML = true;
/**
* The constructor
*
* @param string $request The message
* @param string $response The HTML div class
* @param bool $invokeArgs Is the message HTML? (default: true)
* @return void
*/
public function __construct( $message = '', $class = '', $isHTML = true )
{
$this->message = $message;
$this->setClass( $class );
$this->isHTML = $isHTML;
}
/**
* Get the message as plaintext - essentially strips the tags from the
* message if it is an HTML message
*
* @return string
*/
public function getPlaintext()
{
if( $this->isHTML )
return( strip_tags( $this->message ) );
else
return( $this->message );
}
/**
* Get the message
*
* @return string
*/
public function getMessage()
{
return( $this->message );
}
/**
* Get the message type
*
* @return int
*/
public function getType()
{
return( $this->type );
}
/**
* Set the message type
*
* @param int $type Message type
* @return void
*/
public function setType( $type )
{
$this->type = $type;
}
/**
* Get the class
*
* @return string the class
*/
public function getClass()
{
return( $this->class );
}
/**
* Set the class
*
* @param string $class the class
*/
public function setClass( $class )
{
if( $class == self::ALERT )
$class = self::WARNING;
$this->class = $class;
}
}