MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
mprompt.class
Ir para a documentação deste ficheiro.
1
<?php
2
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3
# @title
4
# Dialogs classes
5
#
6
# @description
7
# Implementation of the prompt class for generating common dialogs.
8
#
9
# @see miolo/ui/tabbedform.class,
10
# miolo/ui/themepainter.class
11
#
12
# @topics ui
13
#
14
# @created
15
# 2001/08/14
16
#
17
# @organisation
18
# MIOLO - Miolo Development Team - UNIVATES Centro Universitario
19
#
20
# @legal
21
# CopyLeft (L) 2001-2002 UNIVATES, Lajeado/RS - Brasil
22
# Licensed under GPL (see COPYING.TXT or FSF at www.fsf.org for
23
# further details)
24
#
25
# @contributors
26
# Vilson Cristiano Gartner [author] [vgartner@univates.br]
27
# Thomas Spriestersbach [author] [ts@interact2000.com.br]
28
#
29
# @maintainers
30
# Vilson Cristiano Gartner [author] [vgartner@univates.br]
31
# Thomas Spriestersbach [author] [ts@interact2000.com.br]
32
#
33
# @history
34
# $Log: prompt.class,v $
35
# Revision 1.4 2002/11/16 11:08:56 vgartner
36
# Maintenance code
37
#
38
# Revision 1.3 2002/09/17 18:50:41 vgartner
39
# added 'component' support
40
#
41
# Revision 1.2 2002/09/05 00:59:16 vgartner
42
# project maintenance for CVS
43
#
44
#
45
#
46
# @id $Id: prompt.class,v 1.4 2002/11/16 11:08:56 vgartner Exp $
47
#---------------------------------------------------------------------
48
49
class
MPrompt
extends
MControl
50
{
51
var
$caption
;
52
var
$message
;
53
var
$buttons
;
54
var
$icon
;
55
var
$type
=
'prompt'
;
56
var
$box
;
57
var
$panelCssClass
;
58
59
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
60
# This is the constructor of the class.
61
# Use the <code>SetType</code> method to specify the type of the dialog.
62
# <br/>caption
63
#
64
# @param $caption (string) Title of the box
65
# @patam $message (string) Message for the prompt message
66
# @param $icon (file url) Image to display on the message
67
#
68
# @example
69
#
70
# @returns (nothing)
71
#---------------------------------------------------------------------
72
function
__construct
(
$caption
=
null
,
$message
=
null
,
$icon
=
'/images/error.gif'
)
73
{
74
parent::__construct();
75
$this->caption =
$caption
;
76
$this->message =
$message
;
77
$this->icon =
$icon
;
78
79
if
(!$this->caption)
80
{
81
$this->caption = _M(
'Alert'
);
82
}
83
84
if
(!$this->message)
85
{
86
$this->message = _M(
'Unknown reason'
);
87
}
88
}
89
90
public
static
function
Error
($msg =
''
, $goto =
''
,
$caption
=
''
, $event =
''
)
91
{
92
if
(!
$caption
)
93
{
94
$caption
= _M(
'Error'
);
95
}
96
97
$prompt =
new
Prompt
(
$caption
, $msg);
98
$prompt->SetType(
'error'
);
99
100
if
($goto !=
'NONE'
)
101
{
102
$prompt->AddButton( _M(
' Back '
), $goto, $event);
103
}
104
105
return
$prompt;
106
}
107
108
public
static
function
Information
($msg, $goto =
''
, $event =
''
)
109
{
110
global
$MIOLO
;
111
112
$prompt =
new
Prompt
(_M(
'Information'
), $msg,
$MIOLO
->url_home .
'/images/information.gif'
);
113
$prompt->SetType(
'information'
);
114
115
if
($goto !=
'NONE'
)
116
{
117
$prompt->AddButton(
' OK '
, $goto, $event);
118
}
119
120
return
$prompt;
121
}
122
123
public
static
function
Alert
($msg, $goto =
''
, $event =
''
)
124
{
125
global
$MIOLO
;
126
127
$prompt =
new
Prompt
(_M(
'Alert'
), $msg,
$MIOLO
->url_home .
'/images/alert.gif'
);
128
$prompt->SetType(
'alert'
);
129
130
if
($goto !=
'NONE'
)
131
{
132
$prompt->AddButton(
' OK '
, $goto, $event);
133
}
134
135
return
$prompt;
136
}
137
138
public
static
function
Confirmation
($msg, $gotoOK =
''
, $gotoCancel =
''
, $eventOk =
''
, $eventCancel =
''
)
139
{
140
global
$MIOLO
;
141
142
$prompt =
new
Prompt
(_M(
'Confirmation'
), $msg,
$MIOLO
->url_home .
'/images/attention.gif'
);
143
$prompt->SetType(
'confirmation'
);
144
$prompt->AddButton(
' OK '
, $gotoOK, $eventOk);
145
$prompt->AddButton(_M(
' Cancel '
), $gotoCancel, $eventCancel);
146
147
return
$prompt;
148
}
149
150
public
static
function
Question
($msg, $gotoYes =
''
, $gotoNo =
''
, $eventYes =
''
, $eventNo =
''
)
151
{
152
global
$MIOLO
;
153
154
$prompt =
new
Prompt
(_M(
'Confirmation'
), $msg,
$MIOLO
->url_home .
'/images/question.gif'
);
155
$prompt->SetType(
'question'
);
156
$prompt->AddButton(_M(
' Yes '
), $gotoYes, $eventYes);
157
$prompt->AddButton(_M(
' No '
), $gotoNo, $eventNo);
158
159
return
$prompt;
160
}
161
162
function
SetType
(
$type
)
163
{
164
$this->type =
$type
;
165
166
switch
(
$type
)
167
{
168
case
'error'
:
169
$this->panelCssClass =
'panel-danger border-danger'
;
170
break
;
171
case
'information'
:
172
$this->panelCssClass =
'panel-info border-info'
;
173
break
;
174
case
'alert'
||
'question'
:
175
$this->panelCssClass =
'panel-warning border-warning'
;
176
break
;
177
case
'confirmation'
:
178
$this->panelCssClass =
'panel-success border-success'
;
179
break
;
180
default
:
181
$this->panelCssClass =
'panel-info border-info'
;
182
break
;
183
}
184
}
185
186
function
AddButton
($label, $href, $event =
''
)
187
{
188
$this->buttons[] = array
189
(
190
$label,
191
$href,
192
$event
193
);
194
}
195
196
function
Generate
()
197
{
198
$content =
''
;
199
200
if
(!is_array($this->message))
201
$this->message = array($this->message);
202
203
$content .=
"<ul>\n"
;
204
205
foreach
($this->message as $m)
206
$content .=
"<li>$m</li>"
;
207
208
$content .=
"</ul>\n"
;
209
$textBox =
new
Div
(
''
, $content,
'm-prompt-box-text'
);
210
$content =
' '
;
211
212
if
($this->buttons)
213
{
214
$content =
"<ul>\n"
;
215
216
foreach
($this->buttons as $b)
217
{
218
$label = $b[0];
219
$goto = $b[1];
220
$event = $b[2];
221
$name
= $this->name . trim($label);
222
223
if
($goto !=
''
)
224
{
225
$onclick = $goto . (($event !=
''
) ?
"&event=$event"
:
""
);
226
$button =
new
MButton
(
$name
, $label, $onclick);
227
$button->SetClass(
'button'
);
228
$content .=
'<li>'
. $button->Generate() .
'</li>'
;
229
}
230
else
231
{
232
if
($event !=
''
)
233
{
234
$eventTokens = explode(
';'
, $event);
235
$onclick =
"return _doPostBack('{$eventTokens[0]}','{$eventTokens[1]}')"
;
236
}
237
238
$button =
new
MButton
(
$name
, $label, $onclick);
239
$button->SetClass(
'button'
);
240
$content .=
'<li>'
. $button->Generate() .
'</li>'
;
241
}
242
}
243
244
$content .=
"</ul>\n"
;
245
$buttonBox =
new
MDiv
(
''
, $content,
'm-prompt-box-button'
);
246
}
247
else
248
{
249
$buttonBox =
new
MSpacer
(
'20px'
);
250
}
251
252
$type
= $bootstraptype = strtolower($this->type);
253
switch
(
$type
)
254
{
255
case
'error'
:
256
$bootstraptype =
'danger'
;
257
break
;
258
case
'information'
:
259
$bootstraptype =
'info'
;
260
break
;
261
}
262
$close = $onclick;
263
$this->box =
new
MBox
($this->caption, $close,
''
,
''
,
true
,
false
,
true
, $this->panelCssClass);
264
$this->box->boxTitle->SetBoxClass(
"m-prompt-box-title m-prompt-box-title-{$type} panel-heading card-header text-{$bootstraptype} border-{$bootstraptype} fw-bold"
);
265
$body =
new
MDiv
(
''
,array($textBox, $buttonBox),
"m-prompt-box-{$type} panel-body card-body"
);
266
$this->box->SetControls(array($body));
267
$id
= $this->GetUniqueId();
268
$prompt =
new
MDiv
(
"pb$id"
,
new
MDiv
(
$id
,$this->box,
"m-prompt-box-box"
),
"m-prompt-box"
);
269
return
$prompt->Generate();
270
271
}
272
}
273
?>
Div
Definição
compatibility.class:68
MBox
Definição
boxcontrols.class:156
MButton
Definição
buttoncontrols.class:4
MComponent\$name
$name
Definição
mcomponent.class:17
MControl
Definição
mcontrol.class:35
MControl\$id
$id
Definição
mcontrol.class:69
MDiv
Definição
blockcontrols.class:23
MPrompt
Definição
mprompt.class:50
MPrompt\SetType
SetType($type)
Definição
mprompt.class:162
MPrompt\$panelCssClass
$panelCssClass
Definição
mprompt.class:57
MPrompt\$buttons
$buttons
Definição
mprompt.class:53
MPrompt\Generate
Generate()
Definição
mprompt.class:196
MPrompt\$caption
$caption
Definição
mprompt.class:51
MPrompt\Error
static Error($msg='', $goto='', $caption='', $event='')
Definição
mprompt.class:90
MPrompt\$box
$box
Definição
mprompt.class:56
MPrompt\Question
static Question($msg, $gotoYes='', $gotoNo='', $eventYes='', $eventNo='')
Definição
mprompt.class:150
MPrompt\$type
$type
Definição
mprompt.class:55
MPrompt\Information
static Information($msg, $goto='', $event='')
Definição
mprompt.class:108
MPrompt\$message
$message
Definição
mprompt.class:52
MPrompt\$icon
$icon
Definição
mprompt.class:54
MPrompt\Confirmation
static Confirmation($msg, $gotoOK='', $gotoCancel='', $eventOk='', $eventCancel='')
Definição
mprompt.class:138
MPrompt\__construct
__construct($caption=null, $message=null, $icon='/images/error.gif')
Definição
mprompt.class:72
MPrompt\Alert
static Alert($msg, $goto='', $event='')
Definição
mprompt.class:123
MPrompt\AddButton
AddButton($label, $href, $event='')
Definição
mprompt.class:186
MSpacer
Definição
blockcontrols.class:38
Prompt
Definição
compatibility.class:174
$MIOLO
$MIOLO
Definição
mdatetimefield.class:25
classes
ui
controls
mprompt.class
Gerado por
1.10.0