file = $file; $this->filename = $src; $this->parent = $parent; } function get($name) { return isset($this->file[$name]) ? $this->file[$name] : null; } function fileStat() { $type = is_dir($this->filename); return array( 'name' => ($this->parent) ? ".." : $this->getName(), 'type' => $type, 'extension' => ($type) ? 'folder' : pathinfo($this->filename, PATHINFO_EXTENSION), 'date' => date("d.m.Y H:i", $this->getTime()), 'access' => 0, 'size' => ($type) ? "" : $this->getSizeString(), 'state' => isset($this->file['state']) ? $this->file['state'] : 'unknown', 'title' => $this->getTitle(), /*'author' => $this->file['author'], 'description' => $this->file['description'], 'keywords' => $this->file['keywords'],*/ ); } function isExpected() { if (isset($this->file['state'])) { return ($this->file['state'] == 'expected'); } return false; } function getSizeString() { $size = $this->getSize(); foreach (array('б ', 'Kб', 'Mб') as $suffix) { if (($size / 1024) <= 1) { return round($size, 0) . ' ' . $suffix; } $size /= 1024; } return round($size, 0) . ' GB'; } function getSize() { return ($this->isExpected()) ? 0 : filesize($this->filename); } function getTime() { return ($this->isExpected()) ? 0 : filemtime($this->filename); } function getName() { return pathinfo($this->filename, PATHINFO_BASENAME); } function getTitle() { return isset($this->file['title']) ? $this->file['title'] : $this->getName(); } } ?>