Пример #1
0
 public static function MatchAll($Pattern, $Subject, $FixArray = false)
 {
     preg_match_all($Pattern, $Subject, $Matches);
     if ($FixArray) {
         return LuaFixArrayRecursive($Matches[0]);
     } else {
         return $Matches[0];
     }
 }
Пример #2
0
function LuaFixArrayRecursive(array $Array)
{
    $Array = LuaFixArray($Array);
    foreach (array_keys($Array) as $Key) {
        if (is_array($Array[$Key])) {
            $Array[$Key] = LuaFixArrayRecursive($Array[$Key]);
        }
    }
    return $Array;
}
Пример #3
0
 public function AssignVariable($Key, $Value)
 {
     if (is_scalar($Value)) {
         if (is_object($this->Assign($Key, $Value))) {
             return true;
         }
     } elseif (is_array($Value)) {
         if (is_object($this->Assign($Key, LuaFixArrayRecursive($Value)))) {
             return true;
         }
     }
     Std::Out("[Warning] [Lua] Can't assign a non-scalar/array value (\${$Key}, " . gettype($Value) . ')');
     return false;
 }
Пример #4
0
 public static function Get($Filename, $Throw = false, $FixArray = false)
 {
     if (isset(self::$Config[$Filename])) {
         if ($FixArray) {
             return LuaFixArrayRecursive(self::$Config[$Filename]);
         } else {
             return self::$Config[$Filename];
         }
     }
     Std::Out("[Warning] [Config] config/{$Filename}.json does not exists or is not decodeable. Try to Config::Load()");
     if ($Throw) {
         throw new Exception("No such file config/{$Filename}.json");
     }
     return false;
 }
Пример #5
0
 public static function Decode($Filename, $FixArray = false)
 {
     if (is_readable($Filename)) {
         $Data = file_get_contents($Filename);
         if ($Data !== false) {
             $Data = json_decode($Data, true);
             if ($Data !== null) {
                 if ($FixArray) {
                     return LuaFixArrayRecursive($Data);
                 } else {
                     return $Data;
                 }
             } else {
                 Std::Out("[Warning] [Json] Can't decode {$Filename}");
             }
         }
     } else {
         Std::Out("[Warning] [Json] No such file {$Filename}");
     }
     return false;
 }