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D1=81=20logout=20=D0=BD?=
 =?UTF-8?q?=D0=B0=20sign/out,=20=D0=B4=D0=B0=D0=B1=D1=8B=20=D1=81=D0=BB?=
 =?UTF-8?q?=D0=B5=D0=B4=D0=BE=D0=B2=D0=B0=D1=82=D1=8C=20=D0=BE=D0=B1=D1=89?=
 =?UTF-8?q?=D0=B5=D0=B9=20=D0=BB=D0=BE=D0=B3=D0=B8=D0=BA=D0=B5=20=D1=81?=
 =?UTF-8?q?=D1=81=D1=8B=D0=BB=D0=BE=D0=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 application/bootstrap.php                   |  2 +-
 application/classes/Controller/Twig.php     |  6 +--
 application/classes/Controller/UserEnvi.php |  2 +-
 application/classes/HTTP/Exception.php      | 26 +++++-------
 application/classes/HTTP/Exception/404.php  | 24 -----------
 application/views/base.twig                 |  2 +-
 application/views/errors/404.twig           | 20 ----------
 application/views/errors/default.twig       | 24 -----------
 application/views/errors/http.twig          | 44 +++++++++++++++++++++
 9 files changed, 58 insertions(+), 92 deletions(-)
 delete mode 100644 application/classes/HTTP/Exception/404.php
 delete mode 100644 application/views/errors/404.twig
 delete mode 100644 application/views/errors/default.twig
 create mode 100644 application/views/errors/http.twig

diff --git a/application/bootstrap.php b/application/bootstrap.php
index 6b2aab5e1..d07975eba 100644
--- a/application/bootstrap.php
+++ b/application/bootstrap.php
@@ -158,7 +158,7 @@ Route::set('remind', 'remind')
 		'action'     => 'remind',
 	));
 
-Route::set('logout', 'logout')
+Route::set('sign/out', 'logout')
 	->defaults(array(
 		'controller' => 'authentication',
 		'action'     => 'logout',
diff --git a/application/classes/Controller/Twig.php b/application/classes/Controller/Twig.php
index 198f8745b..5f1a70883 100644
--- a/application/classes/Controller/Twig.php
+++ b/application/classes/Controller/Twig.php
@@ -12,11 +12,7 @@ class Controller_Twig extends Controller {
                     $this->response->body($twig);
                 }
                 else
-                {
-                    $twig = Twig::factory('errors/404');
-                    $twig->message = 'Шаблончик-то не найден!';
-                    $this->response->status(404)->body($twig);
-                }       
+                    throw HTTP_Exception::factory (404, 'Искомый шаблон не найден');
         }
 
 } // End Welcome
diff --git a/application/classes/Controller/UserEnvi.php b/application/classes/Controller/UserEnvi.php
index 0f33b0ba9..9e9510472 100644
--- a/application/classes/Controller/UserEnvi.php
+++ b/application/classes/Controller/UserEnvi.php
@@ -21,7 +21,7 @@ class Controller_UserEnvi extends Controller {
             unset($this->UserInfo['Type']);
             $directory = $this->request->directory();
             if(!empty($directory) && UTF8::strcasecmp($this->request->directory(), $user['Type']))
-                    throw HTTP_Exception::factory(404, 'Не пытайтесь попасть туда, куда попадать не следует.');
+                    throw HTTP_Exception::factory(403, 'Не пытайтесь попасть туда, куда попадать не следует.');
         }
     }
     
diff --git a/application/classes/HTTP/Exception.php b/application/classes/HTTP/Exception.php
index 3e4cd91ad..96feb7353 100644
--- a/application/classes/HTTP/Exception.php
+++ b/application/classes/HTTP/Exception.php
@@ -14,21 +14,15 @@ class HTTP_Exception extends Kohana_HTTP_Exception {
     {
         // Lets log the Exception, Just in case it's important!
         Kohana_Exception::log($this);
- 
-        if (Kohana::$environment >= Kohana::DEVELOPMENT)
-        {
-            // Show the normal Kohana error page.
-            return parent::get_response();
-        }
-        else
-        {
-            // Generate a nicer looking "Oops" page.
-            $twig = Twig::factory('errors/default');
-            $response = Response::factory()
-                ->status($this->getCode())
-                ->body($twig);
- 
-            return $response;
-        }
+
+        $twig = Twig::factory('errors/http');
+        $twig->code = $this->getCode();
+        $twig->message = $this->getMessage();
+        $twig->link = URL::site('');
+        $response = Response::factory()
+            ->status($this->getCode())
+            ->body($twig);
+
+        return $response;
     }
 }
\ No newline at end of file
diff --git a/application/classes/HTTP/Exception/404.php b/application/classes/HTTP/Exception/404.php
deleted file mode 100644
index 5710071fc..000000000
--- a/application/classes/HTTP/Exception/404.php
+++ /dev/null
@@ -1,24 +0,0 @@
-<?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
diff --git a/application/views/base.twig b/application/views/base.twig
index a429e58bf..707bf4bdc 100644
--- a/application/views/base.twig
+++ b/application/views/base.twig
@@ -20,7 +20,7 @@
 			<div class="top_user">
 				{{ User.FirstName }} {{ User.LastName }}
 				{{ HTML.anchor('settings', 'Настройки', {'title': 'Настройки аккаунта'})|raw }}
-				{{ HTML.anchor('logout', 'Выход', {'title': 'Выход из системы'})|raw }}
+				{{ HTML.anchor('sign/out', 'Выход', {'title': 'Выход из системы'})|raw }}
 			</div>
 		</div>
 	</div>
diff --git a/application/views/errors/404.twig b/application/views/errors/404.twig
deleted file mode 100644
index 1094832f2..000000000
--- a/application/views/errors/404.twig
+++ /dev/null
@@ -1,20 +0,0 @@
-<!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>
diff --git a/application/views/errors/default.twig b/application/views/errors/default.twig
deleted file mode 100644
index 0cf45b335..000000000
--- a/application/views/errors/default.twig
+++ /dev/null
@@ -1,24 +0,0 @@
-<!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>
diff --git a/application/views/errors/http.twig b/application/views/errors/http.twig
new file mode 100644
index 000000000..7d6ba22f8
--- /dev/null
+++ b/application/views/errors/http.twig
@@ -0,0 +1,44 @@
+<!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
-- 
GitLab