1
|
|
|
<?php |
2
|
|
|
/* Copyright (C) NAVER <http://www.navercorp.com> */ |
3
|
|
|
|
4
|
|
|
class VirtualXMLDisplayHandler |
5
|
|
|
{ |
6
|
|
|
/** |
7
|
|
|
* Produce virtualXML compliant content given a module object.\n |
8
|
|
|
* @param ModuleObject $oModule the module object |
9
|
|
|
* @return string |
10
|
|
|
*/ |
11
|
|
|
function toDoc(&$oModule) |
12
|
|
|
{ |
13
|
|
|
$error = $oModule->getError(); |
14
|
|
|
$message = $oModule->getMessage(); |
15
|
|
|
$redirect_url = $oModule->get('redirect_url'); |
16
|
|
|
$request_uri = Context::get('xeRequestURI'); |
17
|
|
|
$request_url = Context::getRequestUri(); |
18
|
|
|
$output = new stdClass(); |
19
|
|
|
|
20
|
|
|
if(substr_compare($request_url, '/', -1) !== 0) |
21
|
|
|
{ |
22
|
|
|
$request_url .= '/'; |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
if($error === 0) |
26
|
|
|
{ |
27
|
|
|
if($message != 'success') $output->message = $message; |
28
|
|
|
|
29
|
|
|
$output->url = ($redirect_url) ? $redirect_url : $request_uri; |
30
|
|
|
} |
31
|
|
|
else |
32
|
|
|
{ |
33
|
|
|
if($message != 'fail') $output->message = $message; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
$html = array(); |
37
|
|
|
$html[] = '<!DOCTYPE html><html><head><title>Moved...</title><meta charset="utf-8" /><script>'; |
38
|
|
|
|
39
|
|
|
if($output->message) |
40
|
|
|
{ |
41
|
|
|
$html[] = 'alert(' . json_encode($output->message, JSON_UNESCAPED_SLASHES) . ');'; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
if($output->url) |
45
|
|
|
{ |
46
|
|
|
$url = json_encode(preg_replace('/#(.+)$/i', '', $output->url), JSON_UNESCAPED_SLASHES); |
47
|
|
|
$html[] = 'var win = (window.opener) ? window.opener : window.parent;'; |
48
|
|
|
$html[] = 'win.location.href = ' . $url; |
49
|
|
|
$html[] = 'if(window.opener) self.close();'; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
$html[] = '</script></head></html>'; |
53
|
|
|
|
54
|
|
|
return join(PHP_EOL, $html); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
} |
58
|
|
|
/* End of file VirtualXMLDisplayHandler.class.php */ |
59
|
|
|
/* Location: ./classes/display/VirtualXMLDisplayHandler.class.php */ |
60
|
|
|
|