MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
mpage.class
Ir para a documentação deste ficheiro.
1<?php
2
3define('PAGE_ISPOSTBACK', '__ISPOSTBACK');
4
5class MPage extends MWindow
6{
7 public $compliant;
8 public $styles;
9 public $styleCode;
10 public $scripts;
12 public $metas;
13 public $favicon;
14 public $title;
15 public $action;
16 public $enctype;
17 public $isPostBack = false;
18 public $onload;
19 public $onsubmit;
20 public $hasReport;
21 public $state;
22 public $jscode;
23 public $goto;
24 public $generateMethod = 'GenerateDefault';
25 public $theme;
26
27 function __construct()
28 {
29 global $state;
30
31 parent::__construct('frm' . uniqid());
32 $this->compliant = true;
33 $this->enctype = '';
34 $this->onsubmit = new MStringList();
35 $this->onload = new MStringList();
36 $this->jscode = new MStringList();
37 $this->styles = new MStringList(false);
38 $this->styleCode = new MStringList();
39 $this->scripts = new MStringList(false);
40 $this->metas = new MStringList();
41
42 $busTransaction = MIOLO::getInstance()->getBusiness('admin', 'transaction');
43 $nameTransaction = $busTransaction->getByAction(MIOLO::_REQUEST('action'), MIOLO::_REQUEST('module'));
44 $pageTitle = $this->manager->GetConf('theme.title');
45 if (MIOLO::getInstance()->getConf('theme.main') != 'smodern')
46 {
47 if (strlen($nameTransaction) > 0 )
48 {
49 $pageTitle = $nameTransaction . ' - ' . $pageTitle;
50 }
51 else if (MIOLO::_REQUEST('action') == 'main' || strlen(MIOLO::_REQUEST('action')) == 0)
52 {
53 $pageTitle = 'Home - ' . $pageTitle;
54 }
55 }
56 $this->title = $pageTitle;
57
58 $state = new MState();
59 $this->state = $state;
60 $this->action = $this->manager->GetCurrentURL();
61
62 $this->conditionalScripts = new MStringList(false);
63
64 if ( MIOLO::_REQUEST('renderMethod') == 'ajax' )
65 {
66 $this->generateMethod = 'GenerateAJAX';
67 }
68
69 $back = $this->manager->GetHistory()->Back('context');
70 $top = $this->manager->GetHistory()->Top('context');
71 $this->isPostBack = ($back === $top) && (MIOLO::_REQUEST(PAGE_ISPOSTBACK) != '');
72 $this->LoadViewState();
73 $this->LoadPostData();
74 $this->AddScript('m_common.js');
75 }
76
77 function AddStyle($url, $value = null)
78 {
79 $url = $this->manager->GetThemeURL($url);
80 $this->styles->add($url);
81 }
82
83 function AddStyleURL($url)
84 {
85 $this->styles->add($url);
86 }
87
88 function AddStyleCode($code)
89 {
90 $this->styleCode->add($code);
91 }
92
99 public function addScript($url, $module=NULL)
100 {
101 if ( $module )
102 {
103 $url = $this->manager->getActionURL($module, 'html:scripts:' . $url);
104 }
105 else
106 {
107 $url = $this->manager->getAbsoluteURL('scripts/' . $url);
108 }
109
110 $this->scripts->add($url);
111 }
112
119 public function addScriptForOlderIEs($url, $module=NULL)
120 {
121 if ( $module )
122 {
123 $url = $this->manager->getActionURL($module, 'html:scripts:' . $url);
124 }
125 else
126 {
127 $url = $this->manager->getAbsoluteURL('scripts/' . $url);
128 }
129
130 $this->conditionalScripts->add("<!--[if lt IE 9]><script language=\"javascript\" type=\"text/javascript\" src=\"$url\"></script><![endif]-->");
131 }
132
133 function AddMeta($name, $content)
134 {
135 $this->metas->add("<meta name=\"$name\" content=\"$content\">");
136 }
137
138 function AddHttpEquiv($name, $content)
139 {
140 $this->metas->add("<meta http-equiv=\"$name\" content=\"$content\">");
141 }
142
143 function GetStyles()
144 {
145 return $this->styles;
146 }
147
148 function GetStyleCode()
149 {
150 return $this->styleCode;
151 }
152
153 function SetStyles($value)
154 {
155 $this->styles->items = is_array($value) ? $value : array( $this->manager->GetThemeURL($value) );
156 }
157
158 function GetScripts()
159 {
160 return $this->scripts;
161 }
162
163 public function getConditionalScripts()
164 {
166 }
167
168 function GetMetas()
169 {
170 return $this->metas;
171 }
172
173 function GetOnLoad()
174 {
175 return $this->onload;
176 }
177
178 function GetOnSubmit()
179 {
180 return $this->onsubmit;
181 }
182
183 function GetJsCode()
184 {
185 return $this->jscode;
186 }
187
188 function GetTitle()
189 {
190 return $this->title;
191 }
192
193 function SetTitle($title)
194 {
195 $this->title = $title;
196 }
197
199 {
200 $this->onsubmit->add($jscode);
201 }
202
203 function OnLoad($jscode)
204 {
205 $this->onload->add($jscode);
206 }
207
209 {
210 $this->jscode->add($jscode);
211 }
212
213 function isPostBack()
214 {
215 return $this->isPostBack;
216 }
217
218 function SetPostBack($postback)
219 {
220 $this->isPostBack = $postback;
221 }
222
224 {
225 $this->action = $action;
226 }
227
229 {
230 $this->enctype = $enctype;
231 }
232
233 function SetCompliant($value = true)
234 {
235 $this->compliant = $value;
236 }
237
238 function GetFavicon()
239 {
240 $favicon = "";
241
242 $path = "{$this->manager->getConf('theme.favicon')}";
243
244 if( file_exists($path) )
245 {
246 $favicon = "<link rel='icon' href='$path' />";
247 }
248 else
249 {
250 $path = "{$this->manager->getConf('home.html')}/themes/{$this->id}/images/favicon.ico";
251
252 if( file_exists($path) )
253 {
254 $url = $this->manager->GetThemeURL("images/favicon.ico");
255
256 $favicon = "<link rel='icon' href='$url' />";
257 }
258 }
259 return $favicon;
260 }
261
262 function Request($vars, $component_name = '', $from = 'ALL')
263 {
264 $value = '';
265 if ( ($vars != '' ) )
266 {
267 $value = MIOLO::_REQUEST($vars, $from);
268 if ( !isset($value) )
269 {
270 if ( !$component_name )
271 {
272 $value = $this->state->get($vars);
273 }
274 else
275 {
276 $value = $this->state->get($vars, $component_name);
277 }
278 }
279 }
280 return $value;
281 }
282
283 function SetViewState($var, $value, $component_name = '')
284 {
285 if ( !$component_name )
286 {
287 $this->state->set($var, $value);
288 }
289 else
290 {
291 $this->state->set($var, $value, $component_name);
292 }
293 }
294
295 function GetViewState($var, $component_name = '')
296 {
297 if ( !$component_name )
298 {
299 return $this->state->get($var);
300 }
301 else
302 {
303 return $this->state->get($var, $component_name);
304 }
305 }
306
307 function LoadViewState()
308 {
309 $this->state->LoadViewState();
310 }
311
312 function SaveViewState()
313 {
314 $this->state->SaveViewState();
315 }
316
317 function LoadPostData()
318 {
319
320 }
321
322 // Set a value for a client element, using DOM
323 // This method use a javascript code that is execute on response
324 public function setElementValue($element, $value, $ajax = true)
325 {
326 $jsCode = "document.getElementById('{$element}').value = \"{$value}\";";
327 $this->addAJAXJsCode($jsCode);
328 }
329
330 public function addAJAXJsCode($jsCode)
331 {
332 echo "<script type=\"text/javascript\"> {$jsCode} </script>";
333 }
334
335 function Transfer($module, $action, $item = '')
336 {
337 global $MIOLO, $context;
338
339 $this->isPostBack = false;
340 $context->Create($module, $action, $item);
341 $result = $MIOLO->InvokeHandler($module, $action, $item);
342 return $result;
343 }
344
348 function _GoTo($url)
349 {
350 $this->manager->GetSession()->freeze();
351 $this->goto = str_replace('&amp;', '&', $url);
352 $this->generateMethod = 'GenerateRedirect';
353 }
354
355 function Redirect($url)
356 {
357 $this->manager->GetSession()->freeze();
358 $this->goto = str_replace('&amp;', '&', $url);
359 $this->generateMethod = 'GenerateRedirect';
360 }
361
362 function Refresh()
363 {
364 $this->OnLoad('document.' . $this->name . '.submit();');
365 }
366
367 function Generate()
368 {
369 $this->theme = $this->manager->GetTheme();
370 $this->SaveViewState();
371 $this->{$this->generateMethod}();
372 }
373
375 {
376 header('Location:' . $this->goto);
377 }
378
379 function GenerateHeader()
380 {
381 $this->manager->Trace('Page::Generate');
382 $this->manager->ProfileEnter("Page::Generate");
383 $this->AddHttpEquiv('Content-Type', 'text/html; charset=UTF-8');
384 $this->AddMeta('Generator', 'MIOLO Version ' . MIOLO_VERSION . '; http://www.miolo.org.br');
385
386 echo $this->painter->GenerateHeader($this);
387
388 }
389
391 {
392 // Se não é informado para gerar o header anteriormente
393 $generateHeadersFirst = $_REQUEST["__GENERATEHEADERFIRST"] ?? null;
394 if( $generateHeadersFirst !== "yes" )
395 {
396 $this->GenerateHeader();
397 }
398
399 $this->AddStyle('m_common.css');
400
401 if ( $this->manager->getConf('options.performance.uri_images') == 'true' )
402 {
403 $themesDir = $this->manager->getConf('home.themes');
404 $theme = $this->manager->theme->getId();
405 $uriImagesCSS = 'm_uriimages.css';
406
407 if ( file_exists("$themesDir/$theme/$uriImagesCSS") )
408 {
409 $this->addStyle($uriImagesCSS);
410 }
411 }
412 $this->OnLoad(" MIOLO_SetTitle('" . $this->title . "');");
413 $this->OnLoad(" MIOLO_SetBoxPositions( );");
414
415 $VIEWSTATE = new MHiddenField('__VIEWSTATE', $this->state->GetViewState());
416 $this->theme->AppendContent($VIEWSTATE);
417
418 $ISPOSTBACK = new MHiddenField('__ISPOSTBACK');
419 $this->theme->AppendContent($ISPOSTBACK);
420
421 $EVENTTARGETVALUE = new MHiddenField('__EVENTTARGETVALUE');
422 $this->theme->AppendContent($EVENTTARGETVALUE);
423
424 $EVENTARGUMENT = new MHiddenField('__EVENTARGUMENT');
425 $this->theme->AppendContent($EVENTARGUMENT);
426
427 echo $this->painter->Page($this);
428 $this->manager->ProfileExit("Page::Generate");
429 $this->manager->ProfileDump();
430 }
431
432 function GenerateAJAX()
433 {
434 if ( $this->request('cpaint_returnxml') == "true" )
435 {
436 header("Content-Type: text/xml");
437 print($this->theme->getContent()->generate());
438 }
439 elseif ( $this->theme->getContent() != '' )
440 {
441 $this->theme->SetElementId('content', '');
442 print($this->theme->GenerateElement('content'));
443 }
444 }
445}
446
447?>
addStyle($name, $value)
Definição mcontrol.class:427
static _REQUEST( $vars, $from='ALL')
Definição miolo.class:1109
static getInstance()
Definição miolo.class:134
Definição mpage.class:6
addScriptForOlderIEs($url, $module=NULL)
Definição mpage.class:119
GetStyles()
Definição mpage.class:143
__construct()
Definição mpage.class:27
isPostBack()
Definição mpage.class:213
AddStyleCode($code)
Definição mpage.class:88
GenerateDefault()
Definição mpage.class:390
AddMeta($name, $content)
Definição mpage.class:133
$jscode
Definição mpage.class:22
SetAction($action)
Definição mpage.class:223
SetStyles($value)
Definição mpage.class:153
$favicon
Definição mpage.class:13
$theme
Definição mpage.class:25
_GoTo($url)
Definição mpage.class:348
GetViewState($var, $component_name='')
Definição mpage.class:295
$scripts
Definição mpage.class:10
OnLoad($jscode)
Definição mpage.class:203
OnSubmit($jscode)
Definição mpage.class:198
GetJsCode()
Definição mpage.class:183
$goto
Definição mpage.class:23
Request($vars, $component_name='', $from='ALL')
Definição mpage.class:262
GenerateHeader()
Definição mpage.class:379
Generate()
Definição mpage.class:367
GetFavicon()
Definição mpage.class:238
$metas
Definição mpage.class:12
SaveViewState()
Definição mpage.class:312
$generateMethod
Definição mpage.class:24
LoadViewState()
Definição mpage.class:307
GetOnLoad()
Definição mpage.class:173
GetMetas()
Definição mpage.class:168
GenerateRedirect()
Definição mpage.class:374
$hasReport
Definição mpage.class:20
GetStyleCode()
Definição mpage.class:148
Redirect($url)
Definição mpage.class:355
SetViewState($var, $value, $component_name='')
Definição mpage.class:283
$compliant
Definição mpage.class:7
GetScripts()
Definição mpage.class:158
getConditionalScripts()
Definição mpage.class:163
AddStyle($url, $value=null)
Definição mpage.class:77
GetTitle()
Definição mpage.class:188
$styles
Definição mpage.class:8
Transfer($module, $action, $item='')
Definição mpage.class:335
SetCompliant($value=true)
Definição mpage.class:233
SetTitle($title)
Definição mpage.class:193
addScript($url, $module=NULL)
Definição mpage.class:99
setElementValue($element, $value, $ajax=true)
Definição mpage.class:324
$action
Definição mpage.class:15
$conditionalScripts
Definição mpage.class:11
GenerateAJAX()
Definição mpage.class:432
Refresh()
Definição mpage.class:362
addAJAXJsCode($jsCode)
Definição mpage.class:330
GetOnSubmit()
Definição mpage.class:178
$onsubmit
Definição mpage.class:19
$onload
Definição mpage.class:18
$enctype
Definição mpage.class:16
SetPostBack($postback)
Definição mpage.class:218
$title
Definição mpage.class:14
$isPostBack
Definição mpage.class:17
SetEnctype($enctype)
Definição mpage.class:228
$state
Definição mpage.class:21
$styleCode
Definição mpage.class:9
AddHttpEquiv($name, $content)
Definição mpage.class:138
AddJsCode($jscode)
Definição mpage.class:208
LoadPostData()
Definição mpage.class:317
AddStyleURL($url)
Definição mpage.class:83
const MIOLO_VERSION
Definição miolo.class:3
const PAGE_ISPOSTBACK
Definição mpage.class:3
$url
Definição base.php:2