public function relativeUrl($url)
{
// If string contains ://, it is considered as absolute
if (preg_match('/:\\/\\//mUsi', $url)) {
return $url;
}
// If string begins with "/", the "/" is removed to resolve the
// relative path
if (strlen($url) && $url[0] == '/') {
$url = substr($url, 1);
if ($this->samePrefix($url)) {
// If the prefix is the same, simply returns the file name
$relative = basename($url);
} else {
// Else, returns enough ../ to get upper
$relative = '';
for ($k = 0; $k < $this->getDepth(); $k++) {
$relative .= '../';
}
$relative .= $url;
}
} else {
$relative = $url;
}
return $relative;
}