Пример #1
0
 /**
  * Throw an error
  * @param 	Integer $code 	The HTTP code
  * @param 	String 	$msg 	A message to add to the request
  * @param 	String 	$trace 	The code trace to display
  * @access 	Public
  * @return 	Boolean
  */
 public static function raiseError(int $code, string $msg = '', string $trace = '') : bool
 {
     if (array_key_exists($code, self::$codes)) {
         header($_SERVER['SERVER_PROTOCOL'] . ' ' . $code . ' ' . self::$codes[$code]);
     }
     // Create a new view if there is none set
     if (is_null(self::$view)) {
         self::$view = new JEErrorView($code, $msg, $trace);
     } else {
         self::$view->setCode($code);
         self::$view->setMessage($msg);
         self::$view->setTrace($trace);
     }
     JEEngine::getEvent()->dispatch('jeerror', array($code, $msg, $trace));
     // Enable language features in the error view
     exit(preg_replace_callback('/\\{\\{([a-z_]{1,})\\}\\}/', function ($match) {
         return JELanguage::get($match[1]);
     }, self::$view->display()));
     return true;
 }
Пример #2
0
 /**
  * Parse the given INI file and add it to the translation
  * @param 	String 	$file 	The file to parse
  * @access 	Private
  * @return 	Boolean
  */
 private static function parseFile(string $file) : bool
 {
     if (empty($file) || !is_file($file)) {
         return false;
     }
     $ext = pathinfo($file, PATHINFO_EXTENSION);
     if (strtolower($ext) != 'ini') {
         return false;
     }
     self::$langTags = array_merge(self::$langTags, parse_ini_file($file));
     return true;
 }