1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-31 20:00:37 +02:00

Error 403/404 templates;

Not Found redirect - set 404 error code;
404/403 actions - send proper HTTP status code;
Front controller now sets render mode to
module-controller-action by default (override from within individual
actions via setRenderMod() still possible)
This commit is contained in:
SecretR
2013-10-23 17:39:44 +03:00
parent c3f9d98898
commit f60b8f6e81
3 changed files with 110 additions and 20 deletions

View File

@@ -18,34 +18,62 @@ class core_system_error_controller extends eController
e107::coreLan('error');
}
/**
* Alias
*/
public function action404()
{
$this->_forward('notfound');
}
public function actionNotfound()
{
$this->getResponse()
->setRenderMod('error404')
->addHeader('HTTP/1.0 404 Not Found');
$this->addTitle(LAN_ERROR_7);
//var_dump($this->getRequest()->getRouteHistory());
$errorText = "<img src='".e_IMAGE_ABS."generic/warning.png' alt='".LAN_ERROR_37."' /> ".LAN_ERROR_21.'<br />'.LAN_ERROR_9."<br /><br />";
if (strlen(vartrue($errFrom))) $errorText .= LAN_ERROR_23." <a href='{$errFrom}' rel='external'>{$errFrom}</a> ".LAN_ERROR_24." -- ".LAN_ERROR_19."<br /><br />";
$template = e107::getCoreTemplate('error', 404);
$vars = new e_vars(array(
'siteUrl' => SITEURL,
'searchUrl' => e107::getUrl()->create('search'),
));
$body = e107::getParser()->parseTemplate($template['start'].$template['body'].$template['end'], true, null, $vars);
$this->addBody($body);
}
$errorText .= "<h3>".LAN_ERROR_45."</h3>";
if(vartrue($errReturnTo))
{
foreach ($errReturnTo as $url => $label)
{
$errorText .= "<a href='{$url}'>".$label."</a><br />";
}
$errorText .= '<br />';
}
$url = e107::getUrl();
/**
* Alias
*/
public function action403()
{
$this->_forward('forbidden');
}
public function actionForbidden()
{
$this->getResponse()
->setRenderMod('error403')
->addHeader('HTTP/1.0 403 Forbidden');
$errorText .= "<a href='".SITEURL."'>".LAN_ERROR_20."</a><br />";
$errorText .= "<a href='".$url->create('search')."'>".LAN_ERROR_22."</a>";
$this->addTitle(LAN_ERROR_7);
$template = e107::getCoreTemplate('error', 403);
$this->addBody($errorText);
$vars = new e_vars(array(
'siteUrl' => SITEURL,
));
$body = e107::getParser()->parseTemplate($template['start'].$template['body'].$template['end'], true, null, $vars);
$this->addBody($body);
}
function actionHelloWorld()
{
$this->addTitle('Hello!');
echo 'Hello World';
//$this->addTitle('Hello!');
//echo 'Hello World';
}
}