Source for file page.php

Documentation is available at page.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Libraries
  4.  * @subpackage  Error
  5.  *
  6.  * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
  7.  * @license     GNU General Public License version 2 or later; see LICENSE.txt
  8.  */
  9.  
  10. defined('JPATH_BASE'or die;
  11.  
  12. /**
  13.  * Displays the custom error page when an uncaught exception occurs.
  14.  *
  15.  * @package     Joomla.Libraries
  16.  * @subpackage  Error
  17.  * @since       3.0
  18.  */
  19. class JErrorPage
  20. {
  21.     /**
  22.      * Render the error page based on an exception.
  23.      *
  24.      * @param   Exception  $error  The exception for which to render the error page.
  25.      *
  26.      * @return  void 
  27.      *
  28.      * @since   3.0
  29.      */
  30.     public static function render(Exception $error)
  31.     {
  32.         try
  33.         {
  34.             $app      JFactory::getApplication();
  35.             $document JDocument::getInstance('error');
  36.  
  37.             if (!$document)
  38.             {
  39.                 // We're probably in an CLI environment
  40.                 exit($error->getMessage());
  41.                 $app->close(0);
  42.             }
  43.  
  44.             $config JFactory::getConfig();
  45.  
  46.             // Get the current template from the application
  47.             $template $app->getTemplate();
  48.  
  49.             // Push the error object into the document
  50.             $document->setError($error);
  51.  
  52.             if (ob_get_contents())
  53.             {
  54.                 ob_end_clean();
  55.             }
  56.             $document->setTitle(JText::_('Error'': ' $error->getCode());
  57.             $data $document->render(
  58.                 false,
  59.                 array('template' => $template,
  60.                 'directory' => JPATH_THEMES,
  61.                 'debug' => $config->get('debug'))
  62.             );
  63.  
  64.             // Failsafe to get the error displayed.
  65.             if (empty($data))
  66.             {
  67.                 exit($error->getMessage());
  68.             }
  69.             else
  70.             {
  71.                 // Do not allow cache
  72.                 $app->allowCache(false);
  73.  
  74.                 $app->setBody($data);
  75.                 echo $app->toString();
  76.             }
  77.         }
  78.         catch (Exception $e)
  79.         {
  80.             exit('Error displaying the error page: ' $e->getMessage());
  81.         }
  82.     }
  83. }

Documentation generated on Tue, 19 Nov 2013 15:10:03 +0100 by phpDocumentor 1.4.3