From 5019671cf2bba2202c0024f3bd309fe674251226 Mon Sep 17 00:00:00 2001 From: vincent-peugnet Date: Thu, 26 Mar 2020 18:07:28 +0100 Subject: sort media by date and ext fix #67 --- app/class/Media.php | 2 +- app/class/Medialist.php | 5 ++--- app/class/Model.php | 8 ++++++++ app/class/Modelmedia.php | 4 ---- 4 files changed, 11 insertions(+), 8 deletions(-) (limited to 'app/class') diff --git a/app/class/Media.php b/app/class/Media.php index ad36b8e..f29d2c9 100644 --- a/app/class/Media.php +++ b/app/class/Media.php @@ -174,7 +174,7 @@ class Media extends Item } } - public function date($option = 'string') + public function date($option = 'date') { return $this->datetransform('date', $option); } diff --git a/app/class/Medialist.php b/app/class/Medialist.php index 2141d40..ca42f4b 100644 --- a/app/class/Medialist.php +++ b/app/class/Medialist.php @@ -31,7 +31,6 @@ class Medialist extends Item /** @var string display the file name of the file */ protected $filename = 0; - const SORT_BY_FILTER = ['id', 'size', 'type', 'date']; const TYPES = ['image', 'sound', 'video', 'other']; @@ -95,7 +94,7 @@ class Medialist extends Item */ public function getsortbyadress(string $sortby) : string { - if(!in_array($sortby, self::SORT_BY_FILTER)) { + if(!in_array($sortby, Model::MEDIA_SORTBY)) { $sortby = 'id'; } if ($this->sortby === $sortby) { @@ -201,7 +200,7 @@ class Medialist extends Item public function setsortby(string $sortby) { - if (in_array($sortby, self::SORT_BY_FILTER)) { + if (in_array($sortby, Model::MEDIA_SORTBY)) { $this->sortby = $sortby; } } diff --git a/app/class/Model.php b/app/class/Model.php index 9e66af4..ea75da8 100644 --- a/app/class/Model.php +++ b/app/class/Model.php @@ -21,6 +21,14 @@ abstract class Model const DATABASE_DIR = '.' . DIRECTORY_SEPARATOR . 'database' . DIRECTORY_SEPARATOR; const PAGES_DIR = self::DATABASE_DIR . 'pages' . DIRECTORY_SEPARATOR; + const MEDIA_SORTBY = [ + 'id' => 'id', + 'size' => 'size', + 'type' => 'type', + 'date' => 'date', + 'extension' => 'extension' + ]; + const MAP_LAYOUTS = [ 'cose' => 'cose', 'cose-bilkent' => 'cose-bilkent', diff --git a/app/class/Modelmedia.php b/app/class/Modelmedia.php index 567e659..079a5f7 100644 --- a/app/class/Modelmedia.php +++ b/app/class/Modelmedia.php @@ -5,10 +5,6 @@ namespace Wcms; class Modelmedia extends Model { - const MEDIA_SORTBY = ['id', 'size', 'type']; - - - /** * Get the Media Object * -- cgit v1.2.3