Welcome to your new lab, here's the instructions for each exercise :
You must try to find documentation and solution by yourself. The course contains links to references and a lot of other interesting websites. Don't forget : the web is your friend ;-)
Bon courage...
Like always, wikipedia has the answer ;-)
In this lab we'll create a file browser displaying infos as miller columns.
You can have a look at the existing files before starting...
Because our file browser file have to manipulate files and directories, we'll create an abstract class that can represent both. We'll call it a MillerPath
.
Config
class correctly and set the value of $rootPath
in public/index.php at line 11. Change the value in config.json if you need to.MillerPath
in model/MillerPath.class.php.path
, it will represent the absolute path of the directory or the file.parentPath
, it will represent the absolute path of the parent directory of the directory or the file.name
, it will represent name (last part of the path) of the directory or the file.path
, parentPath
and name
properties correctly.You'll have to retrieve the last part of the path to get the name. Parent path will also be quick to retrieve.getPath
, getParentPath
and getName
. If you use a decent IDE, it should be able to generate them ;-)__toString
method and return the name.Now that we have a MillerPath
, we can create a MillerFile
that inherits from it.
MillerFile
in model/MillerFile.class.php that inherits from the MillerPath
class.mimeType
, it will contain the mime type of the file.getMimeType
.Now that we have a MillerPath
, we can create a MillerDirectory
that inherits from it.
MillerDirectory
in model/MillerDirectory.class.php that inherits from the MillerPath
class.directories
, it will contain an array of MillerDirectory
.files
, it will contain an array of MillerFile
.readDir
that initializes the directories
and files
. Just iterate over the contents of the current directory. Detect if it's a directory or an item, create a new MillerDirectory
or a new MillerFile
and add it to the correct private array directories
or files
.directories
or files
. Sort them by name. Your sort must be case insensitive and should not be troubled by hidden dirs and files. This means that .gnome
should be treated as gnome
.getDirectories
and getFiles
. If the private properties aren't already set up, just call the readDir
function in this getters.This is a "be awesome" exercise!
We now have a basic file tree browser displayed as Miller columns. Here's some ideas to improve it.