function ARC_erdf_parser::calc_abs_iri in Taxonomy import/export via XML 6.2
Same name and namespace in other branches
- 5.2 arc/ARC_erdf_parser.php \ARC_erdf_parser::calc_abs_iri()
- 5 arc/ARC_erdf_parser.php \ARC_erdf_parser::calc_abs_iri()
- 6 arc/ARC_erdf_parser.php \ARC_erdf_parser::calc_abs_iri()
1 call to ARC_erdf_parser::calc_abs_iri()
File
- arc/
ARC_erdf_parser.php, line 79
Class
Code
function calc_abs_iri($path = "") {
$base = $this->base;
$path = preg_replace("/^\\.\\//", "", $path);
if (strpos($path, "/") === 0) {
/* leading slash */
if (preg_match("/([^\\/]*[\\/]{1,2}[^\\/]+)\\//", $base, $matches)) {
return $matches[1] . $path;
}
}
elseif ($path == "") {
return $base;
}
elseif (strpos($path, "#") === 0) {
return $base . $path;
}
elseif (preg_match("/^[a-z0-9]+\\:/i", $path)) {
/* abs path */
return $path;
}
else {
/* rel path (../ or path) */
/* remove stuff after last slash */
$base = substr($base, 0, strrpos($base, "/")) . "/";
if (strpos($path, "../") === 0) {
if (preg_match("/([^\\/]*[\\/]{1,2}[^\\/]+\\/)(.*)\\//", $base, $matches)) {
$server_part = $matches[1];
$path_part = $matches[2];
}
else {
$server_part = $base;
$path_part = "";
}
while (strpos($path, "../") === 0) {
$path = substr($path, 3);
$path_part = strlen($path_part) ? substr($path_part, 0, -1) : "";
/* remove / */
if (strpos($path_part, "/")) {
$path_part = substr($path_part, 0, strrpos($path_part, "/")) . "/";
/* remove stuff after (new) last slash */
}
else {
$path_part = "";
}
}
return $server_part . $path_part . $path;
}
else {
return $base . $path;
}
}
return $path;
}