aboutsummaryrefslogtreecommitdiff
path: root/app/class/Media.php
diff options
context:
space:
mode:
authorvincent-peugnet <v.peugnet@free.fr>2020-03-22 16:55:06 +0100
committervincent-peugnet <v.peugnet@free.fr>2020-03-26 17:42:01 +0100
commit633076d7c9275b33b722d9a7989e63839f8c38d2 (patch)
treeb1ca9757d512da3669d6419b653cdc7a1d5c5bd0 /app/class/Media.php
parentcfd04f2ecedf57f01cbb3c47a3ee0578d07ccec4 (diff)
downloadwcms-633076d7c9275b33b722d9a7989e63839f8c38d2.tar.gz
wcms-633076d7c9275b33b722d9a7989e63839f8c38d2.zip
media date display
Diffstat (limited to 'app/class/Media.php')
-rw-r--r--app/class/Media.php34
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)) {