public function apply($request, $response) { $response->status = MStatusCode::INTERNAL_ERROR; $format = $request->format; $response->setContentType($response->getMimeType("xx." + format)); $this->tracestack = str_replace('#', '<br>#', $this->exception->trace); $errorHtml = "Not found"; try { $template = new MTemplate(); $template->context('result', $this->exception); $language = Manager::getOptions('language'); $errorHtml = $template->fetch("errors/{$language}/" . $response->status . "." . ($format == null ? "html" : $format)); if ($request->isAjax() && $format == "html") { if ($this->ajax->isEmpty()) { $this->ajax->setId('error'); $this->ajax->setType('page'); $this->ajax->setData($errorHtml); } $response->out = $this->ajax->returnData(); } else { $response->out = $errorHtml; } } catch (Exception $e) { throw new EMException($e); } }
public function apply($request, $response) { $response->status = MStatusCode::NOT_FOUND; $format = $request->format; if ($request->isAjax() && $format == "html") { $format = "json"; } $response->setContentType($response->getMimeType("xx." + format)); $errorHtml = "Not found"; try { $template = new MTemplate(); $template->context('result', $this); $language = Manager::getOptions('language'); $errorHtml = $template->fetch("errors/{$language}/404.html"); if ($request->isAjax()) { $this->ajax->setResponse('html', $errorHtml); $response->out = $this->ajax->returnData(); } else { $response->out = $errorHtml; } } catch (EMException $e) { } }
public function fetch($template = '') { $template = $template ?: $this->getTemplateName(); $html = $template != '' ? $this->template->fetch($template . '.html') : $this->generate(); return $html; }
public function generate() { if (!count($this->columnWidth)) { return ''; } // default code for row selection if ($this->select != '') { $select = MActionControl::getHref($this->select); $this->addCode("{$this->tableId}.customSelect = function() { " . "var cells = this.get(this.rowSelected);" . "var url = '{$select}'; " . "for (c = 0; c < cells.length; ++c) {" . " url = url.replace('%' + c + '%', cells[c]);" . "}" . "manager.doLinkButton(url,'','','{$this->tableId}'); " . "};"); } $data = json_encode($this->value); $cols = json_encode($this->title); foreach ($this->columnStyle as $i => $style) { $cssCode .= ".field-" . $this->title[$i] . ' ' . ($style ?: '{}') . ' '; } $cssCode .= '.dgrid-row-even {background-color: #EEE}'; Manager::getPage()->addStyleSheetCode($cssCode); $template = new MTemplate(__DIR__); $template->context('manager', Manager::getInstance()); $template->context('data', $data); $template->context('cols', $cols); $template->context('id', $this->id); $js = $template->fetch('mtexttable.js'); $this->page->onLoad($js); $div = new MContentpane($this->id); $div->setWidth($this->width); $div->setHeight($this->scrollHeight); return $div->generate(); }