diff options
Diffstat (limited to 'app/class/Media.php')
-rw-r--r-- | app/class/Media.php | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/app/class/Media.php b/app/class/Media.php index 5d61bf1..ad36b8e 100644 --- a/app/class/Media.php +++ b/app/class/Media.php @@ -2,16 +2,21 @@ namespace Wcms; +use DateTime; +use DateTimeImmutable; +use DateTimeZone; + class Media extends Item { - private $id; - private $path; - private $extension; - private $type; - private $size; - private $width; - private $height; - private $length; + Protected $id; + Protected $path; + Protected $extension; + Protected $type; + Protected $size; + Protected $date; + Protected $width; + Protected $height; + Protected $length; const IMAGE = array('jpg', 'jpeg', 'gif', 'png'); const SOUND = array('mp3', 'flac', 'wav', 'ogg'); @@ -31,6 +36,8 @@ class Media extends Item { $this->settype(); + $this->setdate(); + $filepath = $this->path . $this->id . '.' . $this->extension; $this->size = filesize($filepath); @@ -167,6 +174,11 @@ class Media extends Item } } + public function date($option = 'string') + { + return $this->datetransform('date', $option); + } + public function width() { return $this->width; @@ -221,6 +233,12 @@ class Media extends Item } } + public function setdate() + { + $timestamp = filemtime($this->getfulldir()); + $this->date = new DateTimeImmutable("@$timestamp"); + } + public function setwidth($width) { if (is_int($width)) { |