示例#1
0
 /**
  * @return string path to the error message file
  */
 protected function getErrorMessageFile()
 {
     $lang = Prado::getPreferredLanguage();
     $msgFile = Prado::getFrameworkPath() . '/Exceptions/messages/messages-' . $lang . '.txt';
     if (!is_file($msgFile)) {
         $msgFile = Prado::getFrameworkPath() . '/Exceptions/messages/messages.txt';
     }
     return $msgFile;
 }
示例#2
0
 /**
  * @return string path to the error message file
  */
 protected function getErrorMessageFile()
 {
     $lang = Prado::getPreferredLanguage();
     $dir = dirname(__FILE__);
     $msgFile = $dir . '/messages-' . $lang . '.txt';
     if (!is_file($msgFile)) {
         $msgFile = $dir . '/messages.txt';
     }
     return $msgFile;
 }
示例#3
0
 /**
  * Retrieves the template used for displaying external exceptions.
  * External exceptions are those displayed to end-users. They do not contain
  * error source code. Therefore, you might want to override this method
  * to provide your own error template for displaying certain external exceptions.
  * The following tokens in the template will be replaced with corresponding content:
  * %%StatusCode%% : the status code of the exception
  * %%ErrorMessage%% : the error message (HTML encoded).
  * %%ServerAdmin%% : the server admin information (retrieved from Web server configuration)
  * %%Version%% : the version information of the Web server.
  * %%Time%% : the time the exception occurs at
  *
  * @param integer status code (such as 404, 500, etc.)
  * @param Exception the exception to be displayed
  * @return string the template content
  */
 protected function getErrorTemplate($statusCode, $exception)
 {
     $base = $this->getErrorTemplatePath() . DIRECTORY_SEPARATOR . self::ERROR_FILE_NAME;
     $lang = Prado::getPreferredLanguage();
     if (is_file("{$base}{$statusCode}-{$lang}.html")) {
         $errorFile = "{$base}{$statusCode}-{$lang}.html";
     } else {
         if (is_file("{$base}{$statusCode}.html")) {
             $errorFile = "{$base}{$statusCode}.html";
         } else {
             if (is_file("{$base}-{$lang}.html")) {
                 $errorFile = "{$base}-{$lang}.html";
             } else {
                 $errorFile = "{$base}.html";
             }
         }
     }
     if (($content = @file_get_contents($errorFile)) === false) {
         die("Unable to open error template file '{$errorFile}'.");
     }
     return $content;
 }