Initial skeleton.
[av.git] / av / includes / alignment.inc
blob74e891cf039740f6318e0be8929d03572befe755
1 <?php
2 class Formats
4         public function __construct($dir) {
5                 $this->prefix = $dir;
6                 $this->filenames = array();
7                 $d = dir($dir);
9                 while (($entry = $d->read()) !== false) {
10                         if (!is_dir($this->prefix.'/'.$entry)) {
11                                 $this->filenames[] = explode('.', $entry, 2);
12                         }
13                 }
15                 $d->close();
17                 $this->__file_load();
18         }
20         public function instantiate($name) {
21                 if (class_exists($name)) {
22                         return new $name;
23                 }
24         }
26         // Private
28         private function __file_load() {
29                 $this->formats = array();
31                 if ($this->filenames) {
32                         foreach ($this->filenames as $filename) {
33                                 if ($this->prefix) {
34                                         $path = $this->prefix.'/';
35                                 }
36                                 $path .= $filename[0].'.'.$filename[1];
38                                 if (is_file($path)) {
39                                         include_once $path;
40                                 }
41                         }
42                 }
43         }
45         private $prefix;
46         private $filenames;