$args[1]) throw new Exception("Value ".$val.", not in range(" . $args[0] . "," . $args[1] . ")"); } return $val; } function flt_time($val, $name, $struct, $args) { $str = ""; if(is_string($val)) { if(strlen($val) === 0) throw new Exception("Bad value, string empty, crc28 can't be generated"); $reg = "/^([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})$/"; if(!preg_match($reg, $val, $matches)) throw new Exception("Bad value, pattern 00:00:00"); $h = intval($matches[1]); $m = intval($matches[2]); $s = intval($matches[3]); return $h * 3600 + $m * 60 + $s; } return 0; } function flt_class($val, $name, $struct, $args) { global $GAME_ROOT; if(is_string($val)) { $conf_path = $val; if(strpos($conf_path, '@') === 0) $conf_path = substr($conf_path, 1) . '.conf.js'; $conf_path = \taskman\config_real_path($conf_path); $cce = \taskman\config_fetch_by_path($conf_path); check_config_class($cce, $args); } if(is_numeric($val)) { if($val == 0) return $val; static $configs_cache; if(!isset($configs_cache)) $configs_cache = \taskman\config_fetch_all(); $cce = \taskman\config_find_by_id($configs_cache, $val); check_config_class($cce, $args); } return $val; } function check_config_class($cce, $target_class) { if(is_array($target_class)) $target_class = $target_class[0]; if(!class_exists($target_class)) throw new Exception($val.". Target class \"".$target_class."\" is not valid"); if($cce->class != $target_class && !is_subclass_of($cce->class, $target_class)) throw new Exception($val.". Config class is \"".$cce->class."\". Must be \"".$target_class."\" or it's child"); }