/** * Render response body * @param array $env * @param \Exception $exception * @return string */ protected function renderGeneric(&$env, $exception) { $title = 'Ups something was wrong !!'; $html = sprintf('<div style="background-color: #402878 ;color: white;padding: 25px;width:100%s"><h1>%s</h1></div>', "%", $title); $html .= '<div style="background:gray;color:white;margin-top:0;padding:25px;overflow-x:scroll;width:100%">'; $html .= '<p>Please go to your administrator</p>'; $html .= '</div>'; if ($this->app->request()->isXhr()) { $this->app->contentType(\Raptor\Raptor::JSON); $response = new \Raptor\Util\ItemList(); $response->set('cod', 5); $response->set('msg', '<h2>Ups something was wrong !!</h2>'); return $response->toJson(); } return sprintf("<html><head><title>%s</title><style>body{margin:0;padding:30px;font:12px/1.5 Helvetica,Arial,Verdana,sans-serif;}h1{margin:0;font-size:48px;font-weight:normal;line-height:48px;}strong{display:inline-block;width:65px;}</style></head><body>%s</body></html>", $title, $html); }
public function getTutorial($name) { $route = str_replace('.', '/', $name); $lang = \Raptor\Raptor::getInstance()->getLanguage()->getUserCurrentLanguage(); if (isset($this->tags[$name])) { $tutorial = new \Raptor\Util\ItemList($this->tags[$name]); if (!file_exists($this->tags[$name]['bundle'] . "/Tutorials/{$lang}")) { $default = $this->getDefault(); $default['found'] = FALSE; return $default; } if (file_exists($this->tags[$name]['bundle'] . "/Tutorials/{$lang}/docs/{$route}.html")) { $tutorial->set('text', file_get_contents($this->tags[$name]['bundle'] . "/Tutorials/{$lang}/docs/{$route}.html")); $tutorial->set('bundle', ''); } if ($this->tags[$name]['author'] == NULL) { $tutorial->set('author', array('img' => 'Raptor/img/logo.png')); } else { $author = str_replace('.', '/', $this->tags[$name]['author']); $obj = json_decode(file_get_contents($this->tags[$name]['bundle'] . "/Tutorials/{$lang}/authors/{$author}.json")); $result = array(); if ($obj->img == '') { $obj->img = 'Raptor/img/accountblue.png'; } foreach ($obj as $key => $value) { $result[$key] = $value; } $tutorial->set('author', $result); } if ($tutorial->get('next') == NULL) { $tutorial->set('next', $this->getConditionalTutorial($name)); } if ($tutorial->has('pointer')) { $pointerOrig = $tutorial->get('pointer'); $pointer = array(); if (preg_match('/^arrow:((up)|(down)|(left)|(right)) /', $pointerOrig)) { if (count(explode('arrow:up', $pointerOrig)) > 1) { $pointer['arrow'] = 'up'; $pointer['selector'] = str_replace('arrow:up', '', $pointerOrig); } if (count(explode('arrow:down', $pointerOrig)) > 1) { $pointer['arrow'] = 'down'; $pointer['selector'] = str_replace('arrow:down', '', $pointerOrig); } if (count(explode('arrow:left', $pointerOrig)) > 1) { $pointer['arrow'] = 'left'; $pointer['selector'] = str_replace('arrow:left', '', $pointerOrig); } if (count(explode('arrow:right', $pointerOrig)) > 1) { $pointer['arrow'] = 'right'; $pointer['selector'] = str_replace('arrow:right', '', $pointerOrig); } } else { $pointer = array('selector' => $pointerOrig, 'arrow' => 'up'); } $tutorial->set('pointer', $pointer); } return $tutorial; } $default = $this->getDefault(); $default['next'] = $this->getConditionalTutorial($name); return new \Raptor\Util\ItemList($default); }
/** * Default Error handler */ protected function defaultError($e) { $this->getLog()->error($e); if ($this->request()->isXhr()) { $this->contentType(\Raptor\Raptor::JSON); $response = new \Raptor\Util\ItemList(); $response->set('cod', 5); $response->set('msg', "<h2>Error</h2>" . '<h4>A website error has occurred. The website administrator has been notified of the issue. Sorry for the temporary inconvenience.</h4>'); echo $response->toJson(); return; } echo self::generateTemplateMarkup('Error', '<p>A website error has occurred. The website administrator has been notified of the issue. Sorry for the temporary inconvenience.</p>'); }