From e802d5204b96d645ec3d40b81b4a8bdc6e0ee675 Mon Sep 17 00:00:00 2001 From: n-peugnet Date: Mon, 4 Nov 2019 23:31:31 +0100 Subject: refactor: switch to psr-4 autoloading --- app/class/media.php | 231 ---------------------------------------------------- 1 file changed, 231 deletions(-) delete mode 100644 app/class/media.php (limited to 'app/class/media.php') diff --git a/app/class/media.php b/app/class/media.php deleted file mode 100644 index d458a33..0000000 --- a/app/class/media.php +++ /dev/null @@ -1,231 +0,0 @@ -hydrate($donnees); - } - - public function hydrate(array $donnees) - { - foreach ($donnees as $key => $value) { - $method = 'set' . $key; - - if (method_exists($this, $method)) { - $this->$method($value); - } - } - } - - - public function analyse() - { - $this->settype(); - - $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; - } - - - } - - - public function getfullpath() - { - if(!empty(Config::basepath())) { - $base = '/' . Config::basepath(); - } else { - $base = ''; - } - $fullpath = $base . '/'. $this->path() . $this->id() . '.' . $this->extension(); - $fullpath = str_replace('\\', '/', $fullpath); - return $fullpath; - } - - public function getincludepath() - { - $includepath = $this->path() . $this->id() . '.' . $this->extension(); - $includepath = str_replace('\\', '/', $includepath); - $includepath = substr($includepath, 6); - return $includepath; - } - - public function getfulldir() - { - return $this->path . $this->id . '.' . $this->extension; - } - - /** - * Generate html code depending on media type - * - * @return string html code - */ - public function getcode() : string - { - switch ($this->type) { - case 'image': - $code = '![' . $this->id . '](' . $this->getincludepath() . ')'; - break; - - case 'other': - $code = '[' . $this->id . '](' . $this->getincludepath() . ')'; - break; - - case 'sound': - $code = '<audio controls src="' . $this->getincludepath() . '"></audio>'; - break; - - case 'video': - $code = '<video controls=""><source src="' . $this->getincludepath() . '" type="video/' . $this->extension . '"></video>'; - break; - - } - - return $code; - - } - - - -// _________________________________________________ G E T ____________________________________________________ - - public function id() - { - return $this->id; - } - - public function path() - { - return $this->path; - } - - public function extension() - { - return $this->extension; - } - - public function type() - { - return $this->type; - } - - public function size($display = 'binary') - { - if($display == 'hr') { - return readablesize($this->size); - } else { - return $this->size; - } - } - - public function width() - { - return $this->width; - } - - public function height() - { - return $this->height; - } - - public function length() - { - return $this->length; - } - -// ___________________________________________________ S E T __________________________________________________ - - public function setid($id) - { - if (is_string($id)) { - $this->id = $id; - } - } - - public function setpath($path) - { - if (strlen($path) < 40 and is_string($path)) { - $this->path = strip_tags(strtolower($path)); - } - } - - public function setextension($extension) - { - if (strlen($extension) < 7 and is_string($extension)) { - $this->extension = strip_tags(strtolower($extension)); - } - } - - public function settype() - { - if (isset($this->extension)) { - if (in_array($this->extension, $this::IMAGE)) { - $this->type = "image"; - } elseif (in_array($this->extension, $this::SOUND)) { - $this->type = "sound"; - } elseif (in_array($this->extension, $this::VIDEO)) { - $this->type = "video"; - } else { - $this->type = "other"; - } - } - } - - public function setsize($size) - { - if (40 and is_int($size)) { - $this->size = strip_tags(strtolower($size)); - } - } - - public function setwidth($width) - { - if (is_int($width)) { - $this->width = strip_tags(strtolower($width)); - } - } - - public function setheight($height) - { - if (is_int($height)) { - $this->height = strip_tags(strtolower($height)); - } - } - - public function setlength($length) - { - if ($this->type == 'sound') { - $this->length = $length; - } - } - - - - - - -} -- cgit v1.2.3