コード例 #1
0
ファイル: Handler.php プロジェクト: clancats/core
 /**
  * Try to log that something went wrong
  *
  * @return void
  */
 protected function log()
 {
     if (class_exists('CCLog')) {
         try {
             \CCLog::add($this->inspector->exception()->getMessage() . " - " . str_replace(CCROOT, '', $this->inspector->exception()->getFile()) . ":" . $this->inspector->exception()->getLine(), 'exception');
             \CCLog::write();
         } catch (\Exception $e) {
         }
     }
 }
コード例 #2
0
ファイル: CCLang.php プロジェクト: clancats/core
 /**
  * Recive a translated line
  *
  *     __( 'some/path.to.my.label' );
  *     __( 'user.welcome', array( 'name' => 'Jeff' ) )
  *
  * @param string			$key
  * @param array 			$params 
  * @return string
  */
 public static function line($key, $params = array())
 {
     $path = substr($key, 0, strpos($key, '.'));
     $key = substr($key, strpos($key, '.') + 1);
     // if there is a namespace replace the path with it
     if (isset(static::$aliases[$path])) {
         return static::line(static::$aliases[$path] . '.' . $key, $params);
     }
     // find the language file behind the path
     if (!isset(static::$data[static::$current_language][$path])) {
         // Autoload the language file
         // The load function will throw an exception if the
         // file doesnt exists so we dont have to care for that here.
         CCLang::load($path);
     }
     // Does the line exist in the language file?
     if (!isset(static::$data[static::$current_language][$path][$key])) {
         // We simply return the key to the user and log the missing language file line
         CCLog::add('CCLang::line - No such line "' . $key . '" (' . static::$current_language . ') in file: ' . $path, 'warning');
         return $key;
     }
     $line = static::$data[static::$current_language][$path][$key];
     // replace the params inside the line
     foreach ($params as $param => $value) {
         $line = str_replace(':' . $param, $value, $line);
     }
     return $line;
 }