mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-03 16:51:40 +09:00
- 아래에 이미 author 언급이 있으므로 중복되는 저작권 표기는 제거 - 클래스 하단에 불필요한 end of file 표시 제거 (파일 하나에 클래스 하나씩이므로 파일이 중간에 끊겼다면 클래스가 닫히지 않아 쉽게 알 수 있음)
66 lines
1.3 KiB
PHP
66 lines
1.3 KiB
PHP
<?php
|
|
|
|
class VirtualXMLDisplayHandler
|
|
{
|
|
/**
|
|
* Produce virtualXML compliant content given a module object.\n
|
|
* @param ModuleObject $oModule the module object
|
|
* @return string
|
|
*/
|
|
function toDoc(&$oModule)
|
|
{
|
|
$error = $oModule->getError();
|
|
$message = $oModule->getMessage();
|
|
$redirect_url = $oModule->get('redirect_url');
|
|
$request_uri = Context::get('xeRequestURI');
|
|
$request_url = Context::getRequestUri();
|
|
$output = new stdClass();
|
|
|
|
if(substr_compare($request_url, '/', -1) !== 0)
|
|
{
|
|
$request_url .= '/';
|
|
}
|
|
|
|
if($error === 0)
|
|
{
|
|
if($redirect_url)
|
|
{
|
|
$output->url = $redirect_url;
|
|
}
|
|
else
|
|
{
|
|
$output->url = $request_uri;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
$output->message = $message;
|
|
}
|
|
|
|
$html = array();
|
|
$html[] = '<html>';
|
|
$html[] = '<head>';
|
|
$html[] = '<script>';
|
|
|
|
if($output->message)
|
|
{
|
|
$html[] = 'alert(' . json_encode($output->message) . ');';
|
|
}
|
|
|
|
if($output->url)
|
|
{
|
|
$output->url = preg_replace('/#(.+)$/', '', $output->url);
|
|
$html[] = 'if (opener) {';
|
|
$html[] = ' opener.location.href = ' . json_encode($output->url) . ';';
|
|
$html[] = '} else {';
|
|
$html[] = ' parent.location.href = ' . json_encode($output->url) . ';';
|
|
$html[] = '}';
|
|
}
|
|
|
|
$html[] = '</script>';
|
|
$html[] = '</head><body></body></html>';
|
|
|
|
return join("\n", $html);
|
|
}
|
|
|
|
}
|