summaryrefslogtreecommitdiff
path: root/modules/gallery/libraries
diff options
context:
space:
mode:
authorTim Almdal <tnalmdal@shaw.ca>2010-02-13 13:00:41 -0800
committerTim Almdal <tnalmdal@shaw.ca>2010-02-13 13:00:41 -0800
commitdcd7a8fbb8924665a07582aa53f07a86ef922287 (patch)
treed8c979b9dc72b3de943ec25dc883f25bde1750c6 /modules/gallery/libraries
parent650845eddaad250374330a14c47cda62bf41f20a (diff)
parent36702b1397dcac9ba5a607f62e2a1caeb307ac7a (diff)
Merge branch 'master' into talmdal_dev
Diffstat (limited to 'modules/gallery/libraries')
-rw-r--r--modules/gallery/libraries/MY_Kohana_Exception.php59
-rw-r--r--modules/gallery/libraries/Menu.php13
2 files changed, 71 insertions, 1 deletions
diff --git a/modules/gallery/libraries/MY_Kohana_Exception.php b/modules/gallery/libraries/MY_Kohana_Exception.php
index 1c40091a..d6f1f467 100644
--- a/modules/gallery/libraries/MY_Kohana_Exception.php
+++ b/modules/gallery/libraries/MY_Kohana_Exception.php
@@ -33,6 +33,63 @@ class Kohana_Exception extends Kohana_Exception_Core {
if ($e instanceof ORM_Validation_Exception) {
Kohana_Log::add("error", "Validation errors: " . print_r($e->validation->errors(), 1));
}
- return parent::handle($e);
+ try {
+ $user = identity::active_user();
+ $try_themed_view = $user && !$user->admin;
+ } catch (Exception $e2) {
+ $try_themed_view = false;
+ }
+
+ if ($try_themed_view) {
+ try {
+ return self::_show_themed_error_page($e);
+ } catch (Exception $e3) {
+ Kohana_Log::add("error", "Exception in exception handling code: " . self::text($e3));
+ return parent::handle($e);
+ }
+ } else {
+ return parent::handle($e);
+ }
+ }
+
+ /**
+ * Shows a themed error page.
+ * @see Kohana_Exception::handle
+ */
+ private static function _show_themed_error_page(Exception $e) {
+ // Create a text version of the exception
+ $error = Kohana_Exception::text($e);
+
+ // Add this exception to the log
+ Kohana_Log::add('error', $error);
+
+ // Manually save logs after exceptions
+ Kohana_Log::save();
+
+ if (!headers_sent()) {
+ if ($e instanceof Kohana_Exception) {
+ $e->sendHeaders();
+ } else {
+ header("HTTP/1.1 500 Internal Server Error");
+ }
+ }
+
+ $view = new Theme_View("page.html", "other", "error");
+ if ($e instanceof Kohana_404_Exception) {
+ $view->page_title = t("Dang... Page not found!");
+ $view->content = new View("error_404.html");
+ $user = identity::active_user();
+ $view->content->is_guest = $user && $user->guest;
+ if ($view->content->is_guest) {
+ $view->content->login_form = new View("login_ajax.html");
+ $view->content->login_form->form = auth::get_login_form("login/auth_html");
+ // Avoid anti-phishing protection by passing the url as session variable.
+ Session::instance()->set("continue_url", url::current(true));
+ }
+ } else {
+ $view->page_title = t("Dang... Something went wrong!");
+ $view->content = new View("error.html");
+ }
+ print $view;
}
} \ No newline at end of file
diff --git a/modules/gallery/libraries/Menu.php b/modules/gallery/libraries/Menu.php
index e2b68d1a..7c76ab04 100644
--- a/modules/gallery/libraries/Menu.php
+++ b/modules/gallery/libraries/Menu.php
@@ -216,6 +216,19 @@ class Menu_Core extends Menu_Element {
return null;
}
+ public function is_empty() {
+ foreach ($this->elements as $element) {
+ if ($element instanceof Menu) {
+ if (!$element->is_empty()) {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+ return true;
+ }
+
public function render() {
$view = new View(isset($this->view) ? $this->view : "menu.html");
$view->menu = $this;