add custom 4xx and 5xx error pages
This commit is contained in:
@@ -27,8 +27,6 @@ class AppController extends Controller {
|
||||
|
||||
// JS main file
|
||||
$f3->set('jsView', 'landingpage');
|
||||
|
||||
$this->setTemplate( $f3->get('PATHFINDER.VIEW.INDEX') );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -50,7 +50,6 @@ class Controller {
|
||||
* @param $f3
|
||||
*/
|
||||
function beforeroute($f3) {
|
||||
|
||||
$this->getF3($f3);
|
||||
|
||||
// initiate DB connection
|
||||
@@ -59,20 +58,27 @@ class Controller {
|
||||
// init user session
|
||||
$this->initSession();
|
||||
|
||||
// check if user is in game
|
||||
$f3->set('isIngame', self::isIGB() );
|
||||
if( !$f3->get('AJAX') ){
|
||||
// set page parameters for static page render
|
||||
// check if user is in game (IGB active)
|
||||
$f3->set('isIngame', self::isIGB() );
|
||||
|
||||
// js path (build/minified or raw uncompressed files)
|
||||
$f3->set('pathJs', 'public/js/' . $f3->get('PATHFINDER.VERSION') );
|
||||
// js path (build/minified or raw uncompressed files)
|
||||
$f3->set('pathJs', 'public/js/' . $f3->get('PATHFINDER.VERSION') );
|
||||
|
||||
$this->setTemplate( $f3->get('PATHFINDER.VIEW.INDEX') );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* event handler after routing
|
||||
* -> render view
|
||||
*/
|
||||
public function afterroute($f3) {
|
||||
if($this->template){
|
||||
echo \Template::instance()->render( $this->template );
|
||||
public function afterroute($f3){
|
||||
if($this->getTemplate()){
|
||||
// Ajax calls don´t need a page render..
|
||||
// this happens on client side
|
||||
echo \Template::instance()->render( $this->getTemplate() );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,7 +96,9 @@ class Controller {
|
||||
*/
|
||||
protected function initSession(){
|
||||
// init DB Session (not file based)
|
||||
new \DB\SQL\Session($this->getDB('PF'));
|
||||
if( $this->getDB('PF') instanceof \DB\SQL){
|
||||
new \DB\SQL\Session($this->getDB('PF'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -337,8 +345,35 @@ class Controller {
|
||||
return self::getEnvironment() == 'PRODUCTION';
|
||||
}
|
||||
|
||||
/**
|
||||
* get a program URL by alias
|
||||
* -> if no $alias given -> get "default" route (index.php)
|
||||
* @param null $alias
|
||||
* @return bool
|
||||
*/
|
||||
protected function getRouteUrl($alias = null){
|
||||
$url = false;
|
||||
|
||||
if(!empty($alias)){
|
||||
// check given alias is a valid (registered) route
|
||||
if(array_key_exists($alias, $this->getF3()->get('ALIASES'))){
|
||||
$url = $this->getF3()->alias($alias);
|
||||
}
|
||||
}elseif($this->getF3()->get('ALIAS')){
|
||||
// get current URL
|
||||
$url = $this->getF3()->alias( $this->getF3()->get('ALIAS') );
|
||||
}else{
|
||||
// get main (index.php) URL
|
||||
$url = $this->getF3()->alias('landing');
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* onError() callback function
|
||||
* -> on AJAX request -> return JSON with error information
|
||||
* -> on HTTP request -> render error page
|
||||
* @param $f3
|
||||
*/
|
||||
public function showError($f3){
|
||||
@@ -377,8 +412,19 @@ class Controller {
|
||||
header('Content-type: application/json');
|
||||
echo json_encode($return);
|
||||
}else{
|
||||
// render error in template
|
||||
$f3->set('errorData', [$error]);
|
||||
// set error data for template rendering
|
||||
$error->redirectUrl = $this->getRouteUrl();
|
||||
$f3->set('errorData', $error);
|
||||
|
||||
if( preg_match('/^4[0-9]{2}$/', $error->code) ){
|
||||
// 4xx error -> render error page
|
||||
$f3->set('pageContent', $f3->get('PATHFINDER.STATUS.4XX'));
|
||||
}elseif( preg_match('/^5[0-9]{2}$/', $error->code) ){
|
||||
$f3->set('pageContent', $f3->get('PATHFINDER.STATUS.5XX'));
|
||||
}
|
||||
|
||||
echo \Template::instance()->render( $f3->get('PATHFINDER.VIEW.INDEX') );
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,8 +22,6 @@ class MapController extends \Controller\AccessController {
|
||||
|
||||
// JS main file
|
||||
$this->f3->set('jsView', 'mappage');
|
||||
|
||||
$this->setTemplate( $f3->get('PATHFINDER.VIEW.INDEX') );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -81,9 +81,7 @@ class Setup extends Controller {
|
||||
function beforeroute($f3) {
|
||||
// load "requirements" info in "setup" route only
|
||||
$f3->config('app/requirements.ini');
|
||||
}
|
||||
|
||||
public function afterroute($f3) {
|
||||
// body element class
|
||||
$f3->set('bodyClass', 'pf-body pf-landing');
|
||||
|
||||
@@ -92,7 +90,9 @@ class Setup extends Controller {
|
||||
|
||||
// js path (build/minified or raw uncompressed files)
|
||||
$f3->set('pathJs', 'public/js/' . $f3->get('PATHFINDER.VERSION') );
|
||||
}
|
||||
|
||||
public function afterroute($f3) {
|
||||
// js view (file)
|
||||
$f3->set('jsView', 'setup');
|
||||
|
||||
@@ -123,20 +123,6 @@ class Setup extends Controller {
|
||||
$f3->reroute('@setup');
|
||||
return;
|
||||
}elseif(
|
||||
isset($params['export']) &&
|
||||
isset($params['table']) &&
|
||||
!empty($params['table'])
|
||||
){
|
||||
$f3->set('errorData', $this->exportTableData($params['table']));
|
||||
}elseif(
|
||||
isset($params['import']) &&
|
||||
isset($params['table']) &&
|
||||
!empty($params['table'])
|
||||
){
|
||||
$f3->set('successData', $this->importTableData($params['table']));
|
||||
}
|
||||
|
||||
if(
|
||||
isset($params['fixCols']) &&
|
||||
!empty($params['fixCols'])
|
||||
){
|
||||
|
||||
@@ -41,6 +41,12 @@ INDEX = templates/view/index.html
|
||||
SETUP = templates/view/setup.html
|
||||
LANDINGPAGE = templates/view/landingpage.html
|
||||
|
||||
; HTTP status pages ===============================================================================
|
||||
[PATHFINDER.STATUS]
|
||||
; error pages
|
||||
4XX = templates/status/4xx.html
|
||||
5XX = templates/status/5xx.html
|
||||
|
||||
; MAP =============================================================================================
|
||||
[PATHFINDER.MAP.PRIVATE]
|
||||
LIFETIME = 7
|
||||
|
||||
@@ -80,7 +80,6 @@ define([
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
// login buttons ------------------------------------------------
|
||||
var loginForm = $('#' + config.loginFormId);
|
||||
|
||||
@@ -108,7 +107,6 @@ define([
|
||||
data: loginData,
|
||||
dataType: 'json'
|
||||
}).done(function(data){
|
||||
|
||||
// login error
|
||||
if(data.error !== undefined){
|
||||
$('.' + config.splashOverlayClass).hideSplashOverlay();
|
||||
@@ -517,7 +515,6 @@ define([
|
||||
}, false);
|
||||
}
|
||||
|
||||
|
||||
setPageObserver();
|
||||
|
||||
});
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
15
public/templates/status/4xx.html
Normal file
15
public/templates/status/4xx.html
Normal file
@@ -0,0 +1,15 @@
|
||||
<div class="pf-splash">
|
||||
<div class="pf-color-line warning"></div>
|
||||
<div class="pf-splash-title">
|
||||
<h1>
|
||||
<span class="txt-color txt-color-warning">
|
||||
<i class="fa fa-fw fa-warning"></i> Error - {{ @errorData->code }}
|
||||
</span>
|
||||
</h1>
|
||||
<p class="lead">
|
||||
Status: "<b>{{ @errorData->status }}</b>".
|
||||
Use your browsers Back button to navigate to the page you have previously come
|
||||
<a href="{{ @errorData->redirectUrl }}">from</a>.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
15
public/templates/status/5xx.html
Normal file
15
public/templates/status/5xx.html
Normal file
@@ -0,0 +1,15 @@
|
||||
<div class="pf-splash">
|
||||
<div class="pf-color-line danger"></div>
|
||||
<div class="pf-splash-title">
|
||||
<h1>
|
||||
<span class="txt-color txt-color-danger">
|
||||
<i class="fa fa-fw fa-exclamation-circle"></i> Error - {{ @errorData->code }}
|
||||
</span>
|
||||
</h1>
|
||||
<p class="lead">
|
||||
Status: "<b>{{ @errorData->status }}</b>".
|
||||
Oooops, Something went wrong!
|
||||
You have experienced a technical error. We apologize.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -2,7 +2,7 @@
|
||||
<div class="pf-color-line"></div>
|
||||
<div class="pf-splash-title">
|
||||
<h1>PATHFINDER - System Mapping Tool</h1>
|
||||
<p>
|
||||
<p class="lead">
|
||||
<em class="pf-brand">pathfinder</em> is an open source mapping tool for <em class="pf-brand"><a href="http://www.eveonline.com/" target="_blank">EVE ONLINE</a></em>.
|
||||
</p>
|
||||
<img src="public/img/loading-bars.svg" width="48" height="48">
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{* splash page *}
|
||||
<include href="templates/ui/splash.html"/>
|
||||
|
||||
<section >
|
||||
<section>
|
||||
<div class="container">
|
||||
|
||||
<div class="row text-center">
|
||||
@@ -15,13 +15,11 @@
|
||||
|
||||
{* Errors *}
|
||||
<check if="{{ @errorData }}">
|
||||
<repeat group="{{ @errorData }}" value="{{ @error }}">
|
||||
<div class="alert alert-danger">
|
||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><i class="fa fa-close"></i></button>
|
||||
<span class="txt-color txt-color-danger">({{ @error->code }}) {{ @error->status }}</span>
|
||||
<small> {{ @error->message }}</small>
|
||||
<span class="txt-color txt-color-danger">({{ @errorData->code }}) {{ @errorData->status }}</span>
|
||||
<small> {{ @errorData->message }}</small>
|
||||
</div>
|
||||
</repeat>
|
||||
</check>
|
||||
|
||||
{* Success *}
|
||||
|
||||
@@ -13,6 +13,14 @@
|
||||
width: 100%;
|
||||
height: 3px;
|
||||
@include background-image(linear-gradient(to right, $green-light, $green-light 100%));
|
||||
|
||||
&.warning{
|
||||
@include background-image(linear-gradient(to right, $brand-warning, $brand-warning 100%));
|
||||
}
|
||||
|
||||
&.danger{
|
||||
@include background-image(linear-gradient(to right, $brand-danger, $brand-danger 100%));
|
||||
}
|
||||
}
|
||||
|
||||
.pf-splash{
|
||||
|
||||
Reference in New Issue
Block a user