public function apply($request, $response) { $response->status = MStatusCode::OK; if (Manager::isAjaxCall()) { $this->page->onLoad("manager.doRedirect('{$this->url}','');"); $json = new MRenderJSON(); $json->apply($request, $response); } else { header('Location:' . $this->url); } }
public function renderHandler() { $view = Manager::getView($this->getApplication(), $this->getModule(), 'handler', $this->getAction()); $page = Manager::getPage(); if ($go = $page->redirectTo) { //mdump('redirecting: ' . $go); $this->setResult(new MRedirect($view, $go)); } else { if ($window = $page->window) { $this->setResult(new MBrowserWindow()); } else { if ($binary = $page->binary) { //mdump('binary: ' . $binary); $this->setResult(new MRenderBinary($binary)); } else { if ($download = $page->download) { //mdump('download: ' . $download); $this->setResult(new MRenderBinary($download, false)); } else { if ($prompt = $page->prompt) { $page->clearContent(); parent::renderPrompt($prompt); } else { if (Manager::isAjaxCall()) { //mdump('mhandler:: renderjson'); $render = new MRenderJSON(); if (!$this->getResult()) { $this->setResult($render); } } else { //mdump('mhandler:: renderpage'); $render = new MRenderPage(); if (!$this->getResult()) { $this->setResult($render); } } } } } } } }
public function addStyleSheetCode($code) { if (Manager::isAjaxCall()) { $fileName = md5($code) . '.css'; $file = Manager::getFrameworkPath('var/files/' . $fileName); file_put_contents($file, $code); $url = Manager::getDownloadURL('cache', $fileName, true); $this->onLoad("dojo.create(\"link\", {href:'{$url}', type:'text/css', rel:'stylesheet'}, document.getElementsByTagName('head')[0]);"); } else { $this->styleSheetCode .= "\n" . $code; } }
public function generate($id) { $isAjax = Manager::isAjaxCall(); $scripts = $this->getArray(); $hasCode = $scripts[0] . $scripts[1] . $scripts[2] . $scripts[3] . $scripts[4]; if ($hasCode != '') { $code = ""; if ($scripts[0] != '') { $code .= <<<HERE {$scripts['0']} HERE; } $code .= "\n<script type=\"text/javascript\">\n"; if ($scripts[1] != '') { $code .= <<<HERE {$scripts['1']} HERE; } if ($isAjax) { if (Manager::isAjaxEvent()) { $code .= <<<HERE {$scripts[2]} HERE; } else { $code .= <<<HERE manager.onLoad["{$id}"] = function() { console.log("inside onload {$id}"); {$scripts[2]} }; HERE; } } else { $code .= <<<HERE require(["dojo/parser", "dojo/ready"], function(parser, ready){ ready(function(){ console.log("inside onload {$id}"); {$scripts[2]} }); }); HERE; } $code .= <<<HERE {$scripts[3]} {$scripts[4]} HERE; $code .= <<<HERE //--> </script> HERE; return "<div id=\"{$id}\" class=\"mScripts\">{$code}</div>"; // return $code; } else { return ''; } }
function shutdown() { $error = error_get_last(); Manager::errorHandler($error['type'], $error['message'], $error['file'], $error['line']); if ($error['type'] & (E_ALL & ~E_NOTICE & ~E_STRICT)) { if (Manager::isAjaxCall()) { $ajax = Manager::getAjax(); $ob = ob_get_clean(); if ($ajax->isEmpty()) { $ajax->setType('page'); $ajax->setData($ob); } $result = $ajax->returnData(); echo $result; } } }
public function handlerComponent() { $module = $this->context->getModule(); $component = $this->context->getComponent(); mtrace('handler component=' . $component); $fileName = $component . '.php'; $file = Manager::getAppPath('components/' . $fileName, $module); $mlabelTemporario = new MFieldLabel(); // remover esta linha if (file_exists($file)) { include_once $file; $control = new $component(); $action = $this->context->getAction(); if ($action) { $content = $control->{$action}(); } else { $content = $control->generate(); } Manager::getPage()->setContent($content); if (Manager::isAjaxCall()) { $this->setResult(new MRenderJSON()); } else { $this->setResult(new MRenderPage()); } } else { throw new ERunTimeException(_M("App: [{$this->context->app}], Module: [{$this->context->module}], Component: [{$component}] not found!")); } }
public function render($viewName = '', $parameters = array()) { $this->renderContent($viewName, $parameters); if (Manager::isAjaxCall()) { $this->setResult(new MRenderJSON()); } else { $this->setResult(new MRenderPage()); } }