Skip to content
Snippets Groups Projects
Commit 78910b97 authored by Andrew Rudenets's avatar Andrew Rudenets
Browse files

1. Теперь обработчик HTTP-исключений ловит абсолютно все исключения и выводит их в красивом окошке

2. Ссылка деавторизации изменена с logout на sign/out, дабы следовать общей логике ссылок
parent 08847b42
Branches
Tags
No related merge requests found
...@@ -158,7 +158,7 @@ Route::set('remind', 'remind') ...@@ -158,7 +158,7 @@ Route::set('remind', 'remind')
'action' => 'remind', 'action' => 'remind',
)); ));
Route::set('logout', 'logout') Route::set('sign/out', 'logout')
->defaults(array( ->defaults(array(
'controller' => 'authentication', 'controller' => 'authentication',
'action' => 'logout', 'action' => 'logout',
......
...@@ -12,11 +12,7 @@ class Controller_Twig extends Controller { ...@@ -12,11 +12,7 @@ class Controller_Twig extends Controller {
$this->response->body($twig); $this->response->body($twig);
} }
else else
{ throw HTTP_Exception::factory (404, 'Искомый шаблон не найден');
$twig = Twig::factory('errors/404');
$twig->message = 'Шаблончик-то не найден!';
$this->response->status(404)->body($twig);
}
} }
} // End Welcome } // End Welcome
...@@ -21,7 +21,7 @@ class Controller_UserEnvi extends Controller { ...@@ -21,7 +21,7 @@ class Controller_UserEnvi extends Controller {
unset($this->UserInfo['Type']); unset($this->UserInfo['Type']);
$directory = $this->request->directory(); $directory = $this->request->directory();
if(!empty($directory) && UTF8::strcasecmp($this->request->directory(), $user['Type'])) if(!empty($directory) && UTF8::strcasecmp($this->request->directory(), $user['Type']))
throw HTTP_Exception::factory(404, 'Не пытайтесь попасть туда, куда попадать не следует.'); throw HTTP_Exception::factory(403, 'Не пытайтесь попасть туда, куда попадать не следует.');
} }
} }
......
...@@ -14,21 +14,15 @@ class HTTP_Exception extends Kohana_HTTP_Exception { ...@@ -14,21 +14,15 @@ class HTTP_Exception extends Kohana_HTTP_Exception {
{ {
// Lets log the Exception, Just in case it's important! // Lets log the Exception, Just in case it's important!
Kohana_Exception::log($this); Kohana_Exception::log($this);
if (Kohana::$environment >= Kohana::DEVELOPMENT) $twig = Twig::factory('errors/http');
{ $twig->code = $this->getCode();
// Show the normal Kohana error page. $twig->message = $this->getMessage();
return parent::get_response(); $twig->link = URL::site('');
} $response = Response::factory()
else ->status($this->getCode())
{ ->body($twig);
// Generate a nicer looking "Oops" page.
$twig = Twig::factory('errors/default'); return $response;
$response = Response::factory()
->status($this->getCode())
->body($twig);
return $response;
}
} }
} }
\ No newline at end of file
<?php defined('SYSPATH') or die('No direct script access.');
class HTTP_Exception_404 extends Kohana_HTTP_Exception_404 {
/**
* Generate a Response for the 404 Exception.
*
* The user should be shown a nice 404 page.
*
* @return Response
*/
public function get_response()
{
$twig = Twig::factory('errors/404');
// Remembering that `$this` is an instance of HTTP_Exception_404
$twig->message = $this->getMessage();
$response = Response::factory()
->status(404)
->body($twig);
return $response;
}
}
\ No newline at end of file
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
<div class="top_user"> <div class="top_user">
{{ User.FirstName }} {{ User.LastName }} {{ User.FirstName }} {{ User.LastName }}
{{ HTML.anchor('settings', 'Настройки', {'title': 'Настройки аккаунта'})|raw }} {{ HTML.anchor('settings', 'Настройки', {'title': 'Настройки аккаунта'})|raw }}
{{ HTML.anchor('logout', 'Выход', {'title': 'Выход из системы'})|raw }} {{ HTML.anchor('sign/out', 'Выход', {'title': 'Выход из системы'})|raw }}
</div> </div>
</div> </div>
</div> </div>
......
<!DOCTYPE html>
<html>
<head>
<title>{% block pagename %}Ошибочка вышла!{% endblock %}</title>
{{ HTML.style('media/css/error.css')|raw }}
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<div class='page_layout'>
<div class='content_box'>
<div class='error'>404</div>
<div class='message'>{{ message }}</div>
</div>
<div class='footer'>
Создано отборными рабами<br>Южного Федерального Университета &copy; 2014
</div>
</div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>{% block pagename %}Вход в систему | MM'Rate{% endblock %}</title>
{{ HTML.style('media/css/error.css')|raw }}
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<div class='layout'>
<div class='generalXYNTA'>
<div class='XYNTA'>
<div class='box'>
<div class='error'>Беда!</div>
<div class='message'>{{ message }}</div>
</div>
</div>
<div class='footer'>
Создано отборными рабами<br>Южного Федерального Университета &copy; 2014
</div>
</div>
</div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>{% block pagename %}Ошибка{% endblock %} | {{ System.Title }}</title>
{{ HTML.style('media/css/sign.css')|raw }}
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<div class="header_wrapper">
<div class="header">
<div class="top_logo">
{{ System.Title }}
</div>
<div class="top_name_faculty">
{{ User.FacultyName }}
</div>
<div class="top_user">
Ошибка
</div>
</div>
</div>
<div class='auth_layout'>
<div class="sign_form">
<div class="main">
<div class="top">
<div class="top_title">Ошибка</div>
</div>
<div class="content_wrapper">
<div class="content" style="text-align: center;">
<div style="font-size: 100px;">{{ code }}</div>
<div style="color: #999; font-size: 12px;">{{ message }}</div>
<div><a href="{{ link }}" style='font-size: 12px; color: #0183ce; text-decoration: none;'>Вернуться на главную страницу</a></div>
</div>
</div>
</div>
</div>
<div class='footer'>
<a href='http://vk.com/itlab_mmcs'>IT-лаборатория мехмата ЮФУ &copy; 2014</a>
</div>
</div>
</body>
</html>
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment