2 /*=====================================================================*\
3 || ################################################################### ||
4 || # ViewSVN [#]version[#]
5 || # --------------------------------------------------------------- # ||
6 || # Copyright ©2002-[#]year[#] by Iris Studios, Inc. All Rights Reserved. # ||
7 || # This file may not be reproduced in any way without permission. # ||
8 || # --------------------------------------------------------------- # ||
9 || # User License Agreement at http://www.iris-studios.com/license/ # ||
10 || ################################################################### ||
11 \*=====================================================================*/
14 * Handles the various methods that are used to navigate
21 * Path managing class that constructs and parses input
22 * and output for paths
36 * Constructor: determine the type of linking to use
38 * @param integer Path management type
44 if ($type < 1 OR $type > 2)
46 $viewsvn->trigger
->error('invalid path management type');
49 $this->type
= (int)$type;
53 * Constructs a repository browser link
57 * @param string Base path
58 * @param string Browser path, separated using '/'
60 * @return string Link path
62 function out($base, $addpath)
66 $url = $this->fetch_arguments($base);
67 $addpath = $this->sanitize($addpath);
72 return $url[0] . '?path=' . $addpath . ($url[1] ?
'&' . $url[1] : '');
74 // advanced path system
75 else if ($this->type
== 2)
77 return $url[0] . '/' . $viewsvn->fetch_sourcepath($addpath) . ($url[1] ?
'?' . $url[1] : '');
82 * Fetches any URL parameters a link has
86 * @param string Original URL
88 * @return array Two-element array: base path (no trailing '?'), arguments
90 function fetch_arguments($url)
94 if (($pos = strpos($url, '?')) !== false
)
96 $return[0] = substr($url, 0, strlen($url) - $pos);
97 $return[1] = substr($url, $pos +
1);
109 * Sanitizes a path for passing
115 * @return string Cleaned string
117 function sanitize($path)
119 return preg_replace('#[^a-z0-9\.]*#i', '', $path);
123 /*=====================================================================*\
124 || ###################################################################
127 || ###################################################################
128 \*=====================================================================*/