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 ---- app/view/templates/home.php | 6 +++--- app/view/templates/media.php | 8 +++----- 6 files changed, 17 insertions(+), 16 deletions(-) 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 * diff --git a/app/view/templates/home.php b/app/view/templates/home.php index d1b3421..6c3ad62 100644 --- a/app/view/templates/home.php +++ b/app/view/templates/home.php @@ -163,13 +163,13 @@ linktolink($item->linkto('array')) ?> - + datemodif('dmy') ?> datemodif('ptime') ?>> - + datecreation('dmy') ?> datecreation('ptime') ?>> - + date('dmy') ?> date('ptime') ?>> securelink($item->secure('int') , $item->secure('string')) ?> diff --git a/app/view/templates/media.php b/app/view/templates/media.php index 054022a..50fc0d6 100644 --- a/app/view/templates/media.php +++ b/app/view/templates/media.php @@ -48,9 +48,7 @@ $this->layout('layout', ['title' => 'media', 'stylesheets' => [$css . 'home.css'
Sort
order() == 1 ? 'checked' : '' ?>> @@ -78,7 +76,7 @@ $this->layout('layout', ['title' => 'media', 'stylesheets' => [$css . 'home.css' x id - ext + ext type size date @@ -97,7 +95,7 @@ $this->layout('layout', ['title' => 'media', 'stylesheets' => [$css . 'home.css' extension() ?> type() == 'image' ? '' . $media->getsymbol() . '' : $media->getsymbol() ?> size('hr') ?> - date('hrdi') ?> + date('hrdi') ?> width() ?> height() ?> length() ?> -- cgit v1.2.3