mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-03 16:51:40 +09:00
Add function aliases for URL and path conversion
This commit is contained in:
parent
9d2fe0270b
commit
f983335833
1 changed files with 41 additions and 0 deletions
|
|
@ -133,6 +133,19 @@ function class_basename($class)
|
|||
return basename(str_replace('\\', '/', is_object($class) ? get_class($class) : $class));
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean a path to remove ./, ../, trailing slashes, etc.
|
||||
*
|
||||
* This function is an alias to Rhymix\Framework\Filters\FilenameFilter::cleanPath().
|
||||
*
|
||||
* @param string $path
|
||||
* @return string
|
||||
*/
|
||||
function clean_path($path)
|
||||
{
|
||||
return Rhymix\Framework\Filters\FilenameFilter::cleanPath($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is a shortcut to htmlspecialchars().
|
||||
*
|
||||
|
|
@ -337,6 +350,34 @@ function base64_decode_urlsafe($str)
|
|||
return @base64_decode(str_pad(strtr($str, '-_', '+/'), ceil(strlen($str) / 4) * 4, '=', STR_PAD_RIGHT));
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a server-side path to a URL.
|
||||
*
|
||||
* This function is an alias to Rhymix\Framework\URL::fromServerPath().
|
||||
* It returns false if the path cannot be converted.
|
||||
*
|
||||
* @param string $path
|
||||
* @return string|false
|
||||
*/
|
||||
function path2url($path)
|
||||
{
|
||||
return Rhymix\Framework\URL::fromServerPath($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a URL to a server-side path.
|
||||
*
|
||||
* This function is an alias to Rhymix\Framework\URL::toServerPath().
|
||||
* It returns false if the URL cannot be converted.
|
||||
*
|
||||
* @param string $url
|
||||
* @return string|false
|
||||
*/
|
||||
function url2path($url)
|
||||
{
|
||||
return Rhymix\Framework\URL::toServerPath($url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert hexadecimal color codes to an array of R, G, B values.
|
||||
* This function can handle both 6-digit and 3-digit notations, optionally prefixed with '#'.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue