dir = BASEDIR.'data/'.$dirname.'/'; $this->projname = $projname; // Identify resources in folder $ls = scandir($this->dir); foreach($ls as $file) { if ($file[0] == '.') continue; if ($file == 'README.txt') { $this->longdesc = file_get_contents($this->dir.'README.txt'); $this->shortdesc = array_shift(explode("\n", $this->longdesc)); continue; } if (is_image($file)) { $this->images[] = $file; } else { $this->downloads[] = $file; } } } public function write() { // Generate image thumbnails foreach($this->images as $idx => $image) { $outfile = BASEDIR.'wwwroot/srv/'.$this->projname.'_'.$idx; copy($this->dir.$image, $outfile.'.'.str_ext($image)); mkthumbnail($outfile.'.'.str_ext($image), $outfile.'_thumb.jpg', PAGE_THUMB_W, PAGE_THUMB_H); } // Copy downloads to wwwroot foreach($this->downloads as $idx => $filename) { copy($this->dir.$filename, BASEDIR.'wwwroot/srv/'.$filename); } // Generate index page ob_start(); $this->index(); $idxfile = ob_get_clean(); file_put_contents(BASEDIR.'wwwroot/'.$this->projname.'.html', $idxfile); } public function index() { ?>
=nl2br(hesc($this->longdesc))?>
images)) { ?>