2) { $viewsvn->trigger->error('invalid path management type'); } $this->type = (int)$type; } /** * Constructs a repository browser link * * @access public * * @param string Base path * @param string Browser path, separated using '/' * * @return string Link path */ function out($base, $addpath) { global $viewsvn; $url = $this->fetch_arguments($base); $addpath = $this->sanitize($addpath); // standard URL type if ($this->type == 1) { return $url[0] . '?path=' . $addpath . ($url[1] ? '&' . $url[1] : ''); } // advanced path system else if ($this->type == 2) { return $url[0] . '/' . $viewsvn->fetch_sourcepath($addpath) . ($url[1] ? '?' . $url[1] : ''); } } /** * Fetches any URL parameters a link has * * @access public * * @param string Original URL * * @return array Two-element array: base path (no trailing '?'), arguments */ function fetch_arguments($url) { $return = array(); if (($pos = strpos($url, '?')) !== false) { $return[0] = substr($url, 0, strlen($url) - $pos + 1); $return[1] = substr($url, $pos + 1); } else { $return[0] = $url; $return[1] = ''; } return $return; } /** * Sanitizes a path for passing * * @access private * * @param string Path * * @return string Cleaned string */ function sanitize($path) { return preg_replace('#[^a-z0-9\.]*#i', '', $path); } } /*=====================================================================*\ || ################################################################### || # $HeadURL$ || # $Id$ || ################################################################### \*=====================================================================*/ ?>