9 public $format =
'[full]?v=[version]';
23 $this->rules[$mask] = array_filter(compact(
'path',
'version',
'format'));
32 $remote = strpos($url,
'//') !==
false;
33 foreach($this->rules as $mask => $params)
35 preg_match(substr($mask,0,1) ==
'/' ? $mask :
'/^\\/' . preg_quote($mask,
'/') .
'\\//i',$url,$match) &&
36 (!$remote || ($params[
'remote'] ?? null))
38 if($path = \
Rsi\Record::get($rule = $params,
'path')) $url = str_replace(array_pop($match),$path,$url);
41 if(is_array($rule) && ($i = strrpos($url,
'.'))){
44 $url = strtr($rule[
'format'],[
'[full]' => $url,
'[base]' => substr($url,0,$i),
'[ext]' => substr($url,$i + 1),
'[version]' => $time
45 ? ($this->_fred->debug ? date(
'Ymd-His',$time) : base_convert($time - 1433116800,10,36))
46 : preg_replace(
'/\\W/',
'-',$rule[
'version'])
$format
Default version format ([full] or [base] and [ext], and [version] are replaced).
version(&$hash=null)
Version without hash.
filemtime($filename)
Filemtime with session cache.
$version
Default version (empty = FRED™ version).
rule($mask, $path, $version=null, $format=null)
Add a rule.
rewrite($url)
Rewrite a location according to the rules.
$rules
Location rules (key = mask, value = array with path, version, and format - all optional).