aboutsummaryrefslogtreecommitdiff
path: root/app/class/Media.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/class/Media.php')
-rw-r--r--app/class/Media.php47
1 files changed, 42 insertions, 5 deletions
diff --git a/app/class/Media.php b/app/class/Media.php
index f29d2c9..9213c31 100644
--- a/app/class/Media.php
+++ b/app/class/Media.php
@@ -17,6 +17,8 @@ class Media extends Item
Protected $width;
Protected $height;
Protected $length;
+ Protected $uid;
+ Protected $permissions;
const IMAGE = array('jpg', 'jpeg', 'gif', 'png');
const SOUND = array('mp3', 'flac', 'wav', 'ogg');
@@ -40,14 +42,20 @@ class Media extends Item
$filepath = $this->path . $this->id . '.' . $this->extension;
- $this->size = filesize($filepath);
-
if ($this->type == 'image') {
list($width, $height, $type, $attr) = getimagesize($filepath);
$this->width = $width;
$this->height = $height;
}
+ $stat = stat($filepath);
+
+ $permissions = decoct(fileperms($filepath) & 0777);
+
+ $this->setpermissions($permissions);
+
+ $this->hydrate($stat);
+
}
@@ -168,7 +176,7 @@ class Media extends Item
public function size($display = 'binary')
{
if($display == 'hr') {
- return readablesize($this->size);
+ return readablesize($this->size) . 'o';
} else {
return $this->size;
}
@@ -194,6 +202,27 @@ class Media extends Item
return $this->length;
}
+ public function surface()
+ {
+ $surface = $this->width * $this->height;
+ return readablesize($surface, 1000) . 'px';
+ }
+
+ public function uid($option = 'id')
+ {
+ if($option === 'name') {
+ $userinfo = posix_getpwuid($this->uid);
+ return $userinfo['name'];
+ } else {
+ return $this->uid;
+ }
+ }
+
+ public function permissions()
+ {
+ return $this->permissions;
+ }
+
// ___________________________________________________ S E T __________________________________________________
public function setid($id)
@@ -228,8 +257,8 @@ class Media extends Item
public function setsize($size)
{
- if (40 and is_int($size)) {
- $this->size = strip_tags(strtolower($size));
+ if (is_int($size)) {
+ $this->size = $size;
}
}
@@ -260,7 +289,15 @@ class Media extends Item
}
}
+ public function setuid($uid)
+ {
+ $this->uid = $uid;
+ }
+ public function setpermissions($permissions)
+ {
+ $this->permissions = $permissions;
+ }