3 class tsFile
extends Output
{
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
)){
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
;
53 // return BASE_URL.'/st/img/'.basename($this->type).'.png';
54 $fType = basename($this->type
);
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 () {}