* further modifications and bug fixings
[vsc.git] / adm / _res / _libs / tsfile.class.php
blob171108a0078a04a13f40e59033471d72072f5c95
1 <?php
3 class tsFile extends Output {
4 public $icon,
5 $type,
6 $name,
7 $path,
8 $URL;
10 private $children;
12 public function __construct ($path) {
13 $this->path = realpath ($path);
14 $this->name = basename($this->path);
16 $this->URL = $this->getURL ();
18 $this->type = $this->getMime ();
20 $this->icon = $this->getIcon ();
22 $this->children = array();
25 public function __destruct () {
28 public function getURL () {
29 return (str_replace (UPLOAD_PATH, UPLOAD_URL, $this->path));
32 public function getChildren ($showHidden = false) {
33 if ( !is_dir ($this->path)){
34 return false;
36 if ( $root = opendir ($this->path) ) {
37 while ($file = readdir ($root)){
38 if ( ($file == '.' || $file == '..') || ($showHidden == false && stripos($file, '.') === 0)){ continue; }
39 $this->children[] = new tsFile ( $this->path.DIRECTORY_SEPARATOR.$file );
42 return $this->children;
45 public function getMime () {
46 return mime_content_type ($this->path);
49 public function getIcon () {
50 if (stristr($this->type, 'image'))
51 return BASE_URL.'/'.$this->URL;
52 else {
53 // return BASE_URL.'/st/img/'.basename($this->type).'.png';
54 $fType = basename($this->type);
55 $fType = 'unknown';
56 // what TODO: about friendly URLs?
57 $fakeUrl = tsPage::setRequest ('image', array('id'=>$fType));
58 return BASE_URL.'/img2.php?id=' . $fType;
62 public function dispatch () {}