les commentaires dans l'historique sont en gras
[bazdig.git] / lib / localresource.php
blob37b01bb50c7c83b4cb203b85bf6fed0ba2153b8a
1 <?php
2 class LocalResource
4 var $url;
5 var $file;
7 function __construct($url, $file)
9 $this->url = absolutize($url);
10 $this->file = absolutize($file);
13 function get($path)
15 $f = $this->file .'/'. $path;
16 if (strpos($this->url, '?')) {
17 $u = str_replace('?', "/$path?", $this->url );
18 } else if (strpos($this->url, '#')) {
19 $u = str_replace('#', "/$path#", $this->url );
20 } else {
21 $u = $this->url .'/'. $path;
23 $r = new LocalResource($u, $f);
24 return $r;
27 function get_file()
29 return $this->file;
32 function get_url()
34 return $this->url;
38 function absolutize($path)
40 $path = ereg_replace('/\./', '/', $path);
41 $path = ereg_replace('/[^/.]+/+\.\./', '/', $path);
43 return $path;