MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
mhtmlpainter.class
Ir para a documentação deste ficheiro.
1
<?php
2
3
class
MHtmlPainter
extends
MBasePainter
4
{
5
public
$BR
=
"<br/>"
;
6
private
$control;
7
8
private
function
getAttribute( $name, $value )
9
{
10
return
" $name=\"$value\""
;
11
}
12
13
14
private
function
getId()
15
{
16
try
17
{
18
if
( ! is_object($this->control) )
19
{
20
throw
new
Exception;
21
}
22
}
23
catch
( Exception $e )
24
{
25
echo $e->getTraceAsString();
26
}
27
28
return
$this->getAttribute(
'id'
, $this->control->getId() );
29
}
30
31
32
private
function
getClass($addClass =
null
)
33
{
34
return
$this->getAttribute(
'class'
, $this->control->getClass() . $addClass );
35
}
36
37
38
private
function
getName()
39
{
40
return
$this->getAttribute(
'name'
, $this->control->getName() );
41
}
42
43
44
private
function
getValue()
45
{
46
return
$this->getAttribute(
'value'
, $this->control->getValue() );
47
}
48
49
50
public
function
div
( $control )
51
{
52
$this->control = $control;
53
54
try
55
{
56
if
(!is_object($this->control))
throw
new
Exception;
57
}
58
catch
(Exception $e)
59
{
60
echo $e->GetTraceAsString();
61
}
62
63
return
"\n<div"
. $this->getId() . $this->getClass() . $control->getAttributes(
true
) .
">"
. $control->getInnerToString() .
"</div>"
;
64
}
65
66
67
public
function
span
( $control )
68
{
69
$this->control = $control;
70
71
return
" <span"
. $this->getId() . $this->getClass() . $control->getAttributes(
true
) .
">"
. $control->getInnerToString() .
"</span>"
;
72
}
73
74
75
public
function
text
( $control )
76
{
77
$this->control = $control;
78
79
return
"\n<span"
. $this->getId() . $this->getClass() . $control->getAttributes(
true
) .
">"
. $control->value .
"</span>"
;
80
}
81
82
83
public
function
inputHidden
( $control )
84
{
85
$this->control = $control;
86
87
return
"\n<input type=\"hidden\""
. $this->getName() . $this->getValue() . $this->getId( ) .
">"
;
88
}
89
90
91
public
function
inputButton
( $control )
92
{
93
$this->control = $control;
94
95
return
"\n<input type=\"button\""
. $this->getId() . $this->getClass() .
' btn btn-default'
. $this->getName() . $this->getValue() . $this->getAttribute(
'onclick'
,$control->onclick) . $control->getAttributes(
true
) .
">"
;
96
}
97
98
99
public
function
inputText
( $control )
100
{
101
$this->control = $control;
102
103
return
"\n<input "
. $this->getAttribute(
'type'
, $control->type) . $this->getId() . $this->getClass(
" form-control"
) . $this->getName() . $this->getValue() . $this->getAttribute(
'size'
,$control->size) . $control->getAttributes(
true
) .
">"
;
104
}
105
106
107
public
function
inputCheck
( $control )
108
{
109
$this->control = $control;
110
111
return
"\n<input "
. $this->getAttribute(
'type'
,$control->type) . $this->getId() . $this->getName() . $this->getValue() . (($control->checked !=
''
) ?
" checked "
:
""
) . $control->getAttributes(
true
) .
"><label "
. $this->getAttribute(
'for'
,$control->id) . $this->getClass() .
">"
. $control->text .
"</label>"
;
112
}
113
114
115
public
function
inputTextArea
( $control )
116
{
117
$this->control = $control;
118
119
return
"\n<textarea "
. $this->getId() . $this->getClass(
" form-control"
) . $this->getName() . $this->getAttribute(
'rows'
,$control->rows) . $this->getAttribute(
'cols'
,$control->cols) . $control->getAttributes(
true
) .
">"
. $control->getValue() .
"</textarea>"
;
120
}
121
122
123
public
function
button
( $control )
124
{
125
$this->control = $control;
126
$html =
"\n<button "
. $this->getId() . $this->getAttribute(
'type'
,$control->type) . $this->getClass() .
' btn btn-default'
. $this->getName() . $this->getValue() . $this->getAttribute(
'onclick'
,$control->onclick) . $control->getAttributes(
true
) .
">"
;
127
$image = (($control->image !=
''
) ?
"<img src=\"{$control->image}\" alt=\"\"> "
:
""
);
128
$text = (($control->text !=
''
) ?
"{$control->text}"
:
"{$control->value}"
);
129
$html .= $image . $text;
130
$html .=
"</button>"
;
131
132
return
$html;
133
}
134
135
136
public
function
label
( $control )
137
{
138
$this->control = $control;
139
140
return
"\n<label "
. $this->getClass() . $this->getAttribute(
'for'
,$control->getId()) . $control->getAttributes(
true
) .
">"
. $control->getValue() .
"</label>"
;
141
}
142
143
144
public
function
fieldSet
( $control )
145
{
146
$this->control = $control;
147
$legend = (($control->caption !=
''
) ?
"<legend>{$control->caption}</legend>"
:
""
);
148
149
return
"\n<fieldset "
. $this->getId() . $this->getClass() . $control->getAttributes(
true
) .
">"
. $legend . $control->GetInnerToString() .
"</fieldset>"
;
150
}
151
152
153
public
function
select
( $control )
154
{
155
$this->control = $control;
156
157
return
"\n<select "
. $this->getId() . $this->getClass(
" form-control"
) . $this->getName() . $control->getAttributes(
true
) .
">"
. $this->generateToString($control->content) .
"</select>"
;
158
}
159
160
161
public
function
optionGroup
( $control )
162
{
163
$this->control = $control;
164
165
return
"\n<optgroup "
. $this->getId() . $this->getClass() . $this->getAttribute(
'label'
,$control->label) .
">"
. $this->generateToString($control->content) .
"</optgroup>"
;
166
}
167
168
169
public
function
option
( $control )
170
{
171
$this->control = $control;
172
$label = ( $control->showValues ? $control->value .
' - '
:
''
) . $control->label;
173
174
return
"\n<option"
. $this->getValue() . ( ($control->checked !=
''
) ?
" selected "
:
""
) .
">$label</option>"
;
175
}
176
177
178
public
function
anchor
( $control )
179
{
180
$this->control = $control;
181
182
return
"\n<a "
. $this->getClass() . $this->getAttribute(
'href'
,$control->href) . $control->getAttributes(
true
) .
">"
. $control->caption .
"</a>"
;
183
}
184
185
186
public
function
comment
( $control )
187
{
188
$this->control = $control;
189
190
return
"\n<!-- {$control->value} -->\n"
;
191
}
192
193
194
public
function
header
( $control )
195
{
196
$this->control = $control;
197
198
return
"\n<h"
. $control->level . $this->getClass() . $control->getAttributes(
true
) .
">"
. $control->value .
"</h"
. $control->level .
">"
;
199
}
200
201
202
public
function
image
( $control )
203
{
204
$this->control = $control;
205
206
return
"\n<img"
. $this->getAttribute(
'src'
,$control->location) . $this->getId() . $this->getClass() . $this->getAttribute(
'title'
,$control->label) . $this->getAttribute(
'alt'
,$control->label) . $control->getAttributes(
true
) .
">"
;
207
}
208
209
210
public
function
table
( $control )
211
{
212
$this->control = $control;
213
$table = $control->table;
214
$attributes = str_replace(
'class="m-grid-body"'
,
'class="m-grid-body table"'
, $control->getAttributes(
true
));
215
216
$html =
"\n<table "
. $attributes . $this->getId( ) . $this->getName( ) .
">"
;
217
218
$n = count($table);
219
220
for
($i=0; $i<$n; $i++)
221
{
222
$html .=
"\n<tr "
. $control->rowAttr[$i] .
">"
;
223
$k = count($table[$i]);
224
225
for
($j=0; $j<$k; $j++)
226
{
227
$html .=
"<td "
. $control->cellAttr[$i][$j] .
">"
;
228
$html .= $table[$i][$j];
229
$html .=
"</td>"
;
230
}
231
232
$html .=
"\n</tr>"
;
233
}
234
235
$html .=
"\n</table>"
;
236
237
return
$html;
238
}
239
240
241
public
function
unorderedList
( $control )
242
{
243
return
$control->content ?
"\n<ul>"
. $control->content .
"\n</ul>"
:
""
;
244
}
245
246
247
public
function
unorderedListItem
( $control )
248
{
249
return
($type = $control->type) ?
"\n <li"
. (($type !=
'circle'
) ?
"type={$type}>"
:
">"
) . $control->value .
" </li>"
:
''
;
250
}
251
252
253
public
function
orderedList
( $control )
254
{
255
return
$control->content ?
"\n<ol>"
. $control->content .
"\n</ol>"
:
""
;
256
}
257
258
259
public
function
orderedListItem
( $control )
260
{
261
return
($type = $control->type) ?
"\n <li> "
. $control->value .
" </li>"
:
''
;
262
}
263
264
265
public
function
iFrame
( $control )
266
{
267
return
"\n<iframe name=\"{$control->name}\" src=\"{$control->src}\""
. $control->getAttributes(
true
).
">\n</iframe>"
;
268
}
269
270
public
function
generateHeader
( $page )
271
{
272
$colapsed = (version_compare(SAGU_VERSION,
"3.74.0"
) >= 0) ?
''
:
'sidebar-collapse'
;
273
274
$compliant = $page->compliant ?
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">"
:
""
;
275
$metas = $page->getMetas()->getValueText(
''
,chr(13));
276
$title
= $page->getTitle();
277
$favicon
= $page->getFavicon();
278
279
$html =
280
<<< HERE
281
$compliant
282
<html>
283
<head>
284
<title>
$title
</title>
285
$metas
286
$favicon
287
</head>
288
<body
class
=
"m-theme-body skin-blue sidebar-mini {$colapsed}"
>
289
HERE;
290
291
return
$html;
292
293
}
294
295
public
function
page
( $page )
296
{
297
if
(
MUtil::getBooleanValue
( $page->manager->getConf(
'options.performance.enable_ajax'
) ) )
298
{
299
$enable_ajax =
'var enable_ajax = true; '
;
300
$this->generateMethod =
'generateAJAX'
;
301
}
302
else
303
{
304
$enable_ajax =
'var enable_ajax = false; '
;
305
}
306
307
//$compliant = $page->compliant ? "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">" : "";
308
$theme = $page->theme->generate();
309
$onload = $page->getOnLoad()->getValueText(
''
,chr(13));
310
$scripts = $page->getScripts()->getTextByTemplate(
"<script type=\"text/javascript\" src=\"/:v/\"></script>\n"
);
311
312
$conditionalScripts = $page->getConditionalScripts()->getValueText(
''
, chr(13));
313
314
if
(
MUtil::getBooleanValue
($page->manager->getConf(
'options.loading.show'
)) )
315
{
316
$jsCode =
'return miolo_onSubmit() && showLoading()'
;
317
}
318
else
319
{
320
$jsCode =
'return miolo_onSubmit()'
;
321
}
322
323
$form =
"\n<form name=\"$page->name\" method=\"post\" action=\"$page->action\" "
. ($page->enctype !=
''
?
" enctype=\"$page->enctype\""
:
''
) .
" onSubmit=\"$jsCode\" > $theme \n</form>\n"
;
324
$onsubmit = $page->getOnSubmit()->getValueText(
''
,
' && '
. chr(13));
325
326
if
($onsubmit !=
''
)
327
{
328
$onsubmit .=
' && '
;
329
}
330
$jscode = $page->getJsCode()->getValueText(
''
,chr(13));
331
332
$styleCode = json_encode($page->getStyleCode()->items);
333
334
$styles = json_encode($page->getStyles()->items);
335
$fixCss =
336
"<script type=\"text/javascript\">
337
var items = {$styles};
338
var codeItems = {$styleCode};
339
var head = document.getElementsByTagName('head')[0];
340
341
// Referência dos arquivos css
342
for( var i = 0; i < items.length; i++ )
343
{
344
var link = document.createElement('link');
345
link.rel = 'stylesheet';
346
link.type = 'text/css';
347
link.href = items[i];
348
349
head.appendChild(link);
350
351
}
352
353
// Css definido nas tags style
354
for( var i = 0; i < codeItems.length; i++ )
355
{
356
var style = document.createElement('style');
357
358
style.innerHTML = codeItems[i];
359
360
head.appendChild(style);
361
362
}
363
364
</script>\n"
;
365
366
$html =
367
<<< HERE
368
$scripts
369
<script type=
"text/javascript"
>
370
<!--
371
$enable_ajax
372
373
function
miolo_onload()
374
{
375
$onload
376
}
377
onload = miolo_onload;
378
//-->
379
</script>
380
$fixCss
381
$form
382
<script type=
"text/javascript"
>
383
<!--
384
function
miolo_onSubmit()
385
{
386
var form = document.$page->name;
387
388
if
( form[
'__ISPOSTBACK'
] )
389
{
390
form[
'__ISPOSTBACK'
].value =
'yes'
;
391
}
392
393
return
$onsubmit true ;
394
}
395
$jscode;
396
//-->
397
</script>
398
$conditionalScripts
399
</body>
400
</html>
401
HERE;
402
403
return
$html;
404
}
405
406
}
407
408
?>
MBasePainter
Definição
mbasepainter.class:7
MHtmlPainter
Definição
mhtmlpainter.class:4
MHtmlPainter\inputHidden
inputHidden( $control)
Definição
mhtmlpainter.class:83
MHtmlPainter\orderedListItem
orderedListItem( $control)
Definição
mhtmlpainter.class:259
MHtmlPainter\inputTextArea
inputTextArea( $control)
Definição
mhtmlpainter.class:115
MHtmlPainter\table
table( $control)
Definição
mhtmlpainter.class:210
MHtmlPainter\header
header( $control)
Definição
mhtmlpainter.class:194
MHtmlPainter\select
select( $control)
Definição
mhtmlpainter.class:153
MHtmlPainter\inputText
inputText( $control)
Definição
mhtmlpainter.class:99
MHtmlPainter\text
text( $control)
Definição
mhtmlpainter.class:75
MHtmlPainter\orderedList
orderedList( $control)
Definição
mhtmlpainter.class:253
MHtmlPainter\$BR
$BR
Definição
mhtmlpainter.class:5
MHtmlPainter\comment
comment( $control)
Definição
mhtmlpainter.class:186
MHtmlPainter\span
span( $control)
Definição
mhtmlpainter.class:67
MHtmlPainter\unorderedListItem
unorderedListItem( $control)
Definição
mhtmlpainter.class:247
MHtmlPainter\button
button( $control)
Definição
mhtmlpainter.class:123
MHtmlPainter\image
image( $control)
Definição
mhtmlpainter.class:202
MHtmlPainter\fieldSet
fieldSet( $control)
Definição
mhtmlpainter.class:144
MHtmlPainter\generateHeader
generateHeader( $page)
Definição
mhtmlpainter.class:270
MHtmlPainter\option
option( $control)
Definição
mhtmlpainter.class:169
MHtmlPainter\unorderedList
unorderedList( $control)
Definição
mhtmlpainter.class:241
MHtmlPainter\anchor
anchor( $control)
Definição
mhtmlpainter.class:178
MHtmlPainter\page
page( $page)
Definição
mhtmlpainter.class:295
MHtmlPainter\optionGroup
optionGroup( $control)
Definição
mhtmlpainter.class:161
MHtmlPainter\label
label( $control)
Definição
mhtmlpainter.class:136
MHtmlPainter\div
div( $control)
Definição
mhtmlpainter.class:50
MHtmlPainter\inputCheck
inputCheck( $control)
Definição
mhtmlpainter.class:107
MHtmlPainter\inputButton
inputButton( $control)
Definição
mhtmlpainter.class:91
MHtmlPainter\iFrame
iFrame( $control)
Definição
mhtmlpainter.class:265
MUtil\getBooleanValue
static getBooleanValue($value)
Definição
mutil.class:100
$favicon
$favicon
Definição
base.php:8
$title
$title
Definição
base.php:3
classes
ui
painter
mhtmlpainter.class
Gerado por
1.10.0