修改了错误控制器,使用Layout控制错误显示、增加了权限错误提示页面
This commit is contained in:
parent
141a6b3cd2
commit
54b357b701
|
@ -2,33 +2,45 @@
|
||||||
|
|
||||||
class ErrorController extends Zend_Controller_Action
|
class ErrorController extends Zend_Controller_Action
|
||||||
{
|
{
|
||||||
|
function preDispatch()
|
||||||
|
{
|
||||||
|
$this->view->config = Zend_Registry::get('config');
|
||||||
|
$this->db=Zend_Registry::get('db');
|
||||||
|
}
|
||||||
|
|
||||||
public function errorAction()
|
public function errorAction()
|
||||||
{
|
{
|
||||||
$errors = $this->_getParam('error_handler');
|
$errors = $this->_getParam('error_handler');
|
||||||
|
|
||||||
switch ($errors->type) {
|
switch ($errors->type) {
|
||||||
|
|
||||||
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
|
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
|
||||||
|
|
||||||
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
|
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
|
||||||
|
|
||||||
// 404 error -- controller or action not found
|
// 404 error -- controller or action not found
|
||||||
$this->getResponse()->setRawHeader('HTTP/1.1 404 Not Found');
|
$this->getResponse()->setRawHeader('HTTP/1.1 404 Not Found');
|
||||||
|
$title = "您所访问的页面未找到";
|
||||||
$content =<<<EOH
|
$content = '您所访问的页面未找到<br />
|
||||||
<h1>Error!</h1>
|
The page you requested was not found.';
|
||||||
<p>The page you requested was not found.</p>
|
|
||||||
EOH;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// application error
|
// application error
|
||||||
$content =<<<EOH
|
$title = "服务器内部错误";
|
||||||
<h1>Error!</h1>
|
$content = '服务器开了小差,请稍后再试或联系管理员<br />
|
||||||
<p>An unexpected error occurred. Please try again later.</p>
|
An unexpected error occurred. Please try again later.';
|
||||||
EOH;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear previous content
|
// Clear previous content
|
||||||
$this->getResponse()->clearBody();
|
$this->getResponse()->clearBody();
|
||||||
|
|
||||||
|
$this->view->title = $title;
|
||||||
$this->view->content = $content;
|
$this->view->content = $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function authorityAction(){
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
<?php
|
||||||
|
$this->headTitle($this->config->title->site);
|
||||||
|
$this->headTitle()->setSeparator(' - ');
|
||||||
|
$this->headTitle('权限错误');
|
||||||
|
?>
|
||||||
|
<div id="page">
|
||||||
|
<div class="wrapper">
|
||||||
|
<h1>您没有权限进行此操作</h1>
|
||||||
|
<hr />
|
||||||
|
<p>
|
||||||
|
您所在的用户组没有进行此操作的权限,如过需要获取该权限需要联系管理员
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -1,3 +1,16 @@
|
||||||
|
<?php
|
||||||
|
$this->headTitle($this->config->title->site);
|
||||||
|
$this->headTitle()->setSeparator(' - ');
|
||||||
|
$this->headTitle($this->title);
|
||||||
|
?>
|
||||||
|
<div id="page">
|
||||||
|
<div class="wrapper">
|
||||||
|
<h1>错误提示 - 服务器错误</h1>
|
||||||
|
<hr />
|
||||||
|
<p>
|
||||||
<?php
|
<?php
|
||||||
echo $this->content;
|
echo $this->content;
|
||||||
?>
|
?>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
Loading…
Reference in New Issue