Initial commit
Working directory listing. Hardcoded sidebar template.
This commit is contained in:
56
source/lib/MediaListing/FileObject.class.php
Normal file
56
source/lib/MediaListing/FileObject.class.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
abstract class MediaListing_FileObject {
|
||||
|
||||
const TYPE_File = 1;
|
||||
const TYPE_Directory = 2;
|
||||
|
||||
protected $type;
|
||||
protected $basename;
|
||||
protected $path;
|
||||
|
||||
public static function create($path, $parent = null, $scan = true) {
|
||||
if ( ! file_exists($path)) {
|
||||
throw new MediaListing_Exception_FileNotFound($path);
|
||||
}
|
||||
|
||||
switch (filetype($path)) {
|
||||
case "file": {
|
||||
return new MediaListing_File($path);
|
||||
} break;
|
||||
|
||||
case "dir": {
|
||||
return new MediaListing_Directory($path, $parent, $scan);
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
protected function __construct($type, $path) {
|
||||
$this->type = $type;
|
||||
$this->path = $path;
|
||||
$this->basename = basename($path);
|
||||
}
|
||||
|
||||
public function isFile() {
|
||||
return $this->type == self::TYPE_File;
|
||||
}
|
||||
|
||||
public function isDirectory() {
|
||||
return $this->type == self::TYPE_Directory;
|
||||
}
|
||||
|
||||
public function type() {
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function path() {
|
||||
return $this->path;
|
||||
}
|
||||
|
||||
public function basename() {
|
||||
return $this->basename;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user