Exemple #1
0
 public static function customErrorPage(&$error)
 {
     // Deprecation warning.
     MLog::add('MError::customErrorPage() is deprecated.', MLog::WARNING, 'deprecated');
     // Initialise variables.
     $app = MFactory::getApplication();
     $document = MDocument::getInstance('error');
     if ($document) {
         $config = MFactory::getConfig();
         // Get the current template from the application
         $template = $app->getTemplate();
         // Push the error object into the document
         $document->setError($error);
         // If site is offline and it's a 404 error, just go to index (to see offline message, instead of 404)
         if ($error->getCode() == '404' && MFactory::getConfig()->get('offline') == 1) {
             MFactory::getApplication()->redirect('index.php');
         }
         @ob_end_clean();
         $document->setTitle(MText::_('Error') . ': ' . $error->get('code'));
         $data = $document->render(false, array('template' => $template, 'directory' => MPATH_THEMES, 'debug' => $config->get('debug')));
         // Failsafe to get the error displayed.
         if (empty($data)) {
             self::handleEcho($error, array());
         } else {
             // Do not allow cache
             MResponse::allowCache(false);
             MResponse::setBody($data);
             echo MResponse::toString();
         }
     } else {
         // Must echo the error since there is no document
         // This is a common use case for Command Line Interface applications.
         self::handleEcho($error, array());
     }
     $app->close(0);
 }