/**
  * Default error page action - show an error message
  *
  */
 public function errorAction()
 {
     $errors = $this->_getParam('error_handler');
     $messages = array();
     switch ((string) $errors->type) {
         case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
         case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
             // 404 error -- controller or action not found
             $this->getResponse()->setRawHeader('HTTP/1.1 404 Not Found');
             $messages[] = Zoo::_("The page you requested was not found.");
             if (ZfApplication::getEnvironment() == "development" || ZfApplication::getEnvironment() == "staging") {
                 $messages[] = $errors->exception->getMessage();
             }
             break;
         case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_OTHER:
         case 0:
             // application error
             //$messages[] = Zoo::_("An unexpected error occurred with your request. Please try again later.");
             $messages[] = $errors->exception->getMessage();
             if (ZfApplication::getEnvironment() == "development" || ZfApplication::getEnvironment() == "staging") {
                 $trace = $errors->exception->getTrace();
                 foreach (array_keys($trace) as $i) {
                     if ($trace[$i]['args']) {
                         foreach ($trace[$i]['args'] as $index => $arg) {
                             if (is_object($arg)) {
                                 $trace[$i]['args'][$index] = get_class($arg);
                             } elseif (is_array($arg)) {
                                 $trace[$i]['args'][$index] = "array";
                             }
                         }
                     }
                     $trace[$i]['file_short'] = ".." . substr($trace[$i]['file'], strrpos(str_replace("\\", DIRECTORY_SEPARATOR, $trace[$i]['file']), DIRECTORY_SEPARATOR));
                 }
                 $this->view->assign('trace', $trace);
             }
             break;
         default:
             // application error
             $this->getResponse()->setRawHeader('HTTP/1.1 ' . $errors->type);
             $messages[] = $errors->exception->getMessage();
             break;
     }
     // Clear previous content
     $this->getResponse()->clearBody();
     $this->view->assign('errormessages', $messages);
 }
Example #2
0
<?php

ini_set("display_errors", 1);
error_reporting(E_ALL);
require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'application.php';
if (!empty($argv[1])) {
    $_SERVER['REQUEST_URI'] = $argv[1];
}
ZfApplication::bootstrap(dirname(__FILE__));
 /**
  * Initialization stage, loads configuration files, sets up includes paths
  * and instantiates the frontController
  *
  * @return Zend_Controller_Front
  */
 public function initialize()
 {
     // Ensure that session cookies are not available to JavaScript
     ini_set("session.cookie_httponly", 1);
     // Set the include path
     set_include_path(self::$_base_path . DIRECTORY_SEPARATOR . 'library' . PATH_SEPARATOR . self::$_base_path . DIRECTORY_SEPARATOR . "app" . PATH_SEPARATOR . get_include_path());
     require_once "Zend/Loader/Autoloader.php";
     $autoloader = Zend_Loader_Autoloader::getInstance();
     $autoloader->setFallbackAutoloader(true);
     $locale = new Zend_Locale();
     Zend_Registry::set('Zend_Locale', $locale);
     /*
      * Create an instance of the frontcontroller
      */
     $frontController = Zend_Controller_Front::getInstance();
     if (file_exists(self::$_data_path . '/etc/config.ini')) {
         /*
          * Load the given stage from our configuration file,
          * and store it into the registry for later usage.
          */
         $config = new Zend_Config_Ini(self::$_data_path . '/etc/config.ini');
         Zend_Registry::set('config', $config);
         $frontController->throwExceptions((bool) $config->mvc->exceptions);
         if (PHP_SAPI != "cli") {
             self::$_environment = $config->mode;
             $frontController->registerPlugin(new Zoo_Plugin_Boot_Http(), 1);
         } else {
             $frontController->throwExceptions(true);
             self::$_environment = "cli";
             $frontController->registerPlugin(new Zoo_Plugin_Boot_Cli(), 1);
             Zend_Registry::set("Zend_Locale", new Zend_Locale("en_US"));
             $frontController->setResponse(new Zend_Controller_Response_Cli());
         }
         // Add plugins from plugins.ini
         if (file_exists(self::$_data_path . '/etc/plugins.ini')) {
             $pluginconfig = new Zend_Config_Ini(self::$_data_path . '/etc/plugins.ini', self::$_environment);
             foreach ($pluginconfig->plugins as $name => $plugin) {
                 $pluginClass = $plugin->class;
                 $frontController->registerPlugin(new $pluginClass(), $plugin->priority);
             }
         }
         if ($config->module->default) {
             $frontController->setDefaultModule($config->module->default);
         } else {
             $frontController->setDefaultModule('zoo');
         }
     } else {
         /**
          * System not installed, go to staging mode, add the default module
          * and register the Http boot plugin
          */
         self::$_environment = "staging";
         $frontController->addControllerDirectory(self::$_base_path . "/app/Zoo/Controllers", "Zoo");
         $frontController->registerPlugin(new Zoo_Plugin_Boot_Http(), 1);
         $frontController->setDefaultModule('Zoo');
     }
     return $frontController;
 }