From f4c0ed5851c3c1a703d35ac746ca124b4279b4d9 Mon Sep 17 00:00:00 2001 From: vincent-peugnet Date: Fri, 17 Jan 2020 17:03:58 +0100 Subject: media ui menu bar --- app/view/templates/media.php | 62 +--------------------------------- app/view/templates/mediamenu.php | 72 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 61 deletions(-) create mode 100644 app/view/templates/mediamenu.php (limited to 'app') diff --git a/app/view/templates/media.php b/app/view/templates/media.php index be1ac7f..f81b507 100644 --- a/app/view/templates/media.php +++ b/app/view/templates/media.php @@ -7,6 +7,7 @@ insert('backtopbar', ['user' => $user, 'tab' => 'media', 'pagelist' => $pagelist]) ?> + insert('mediamenu', ['dir' => $dir, 'user' => $user, 'pathlist' => $pathlist, 'opt' => $opt]) ?>
@@ -54,67 +55,6 @@ treecount($dirlist, 'media', 0, 'media', $dir, $opt);

-
- Print this content on your page - -

- %MEDIA?path=&sortby=&order=% -

- -
- - - -
- - - - -
- -issupereditor()) { ?> - -
- - - - -
- - - - -
- - - - -
- - - -issupereditor()) { ?> - -
- - - - - -
- - - - - diff --git a/app/view/templates/mediamenu.php b/app/view/templates/mediamenu.php new file mode 100644 index 0000000..c335933 --- /dev/null +++ b/app/view/templates/mediamenu.php @@ -0,0 +1,72 @@ + \ No newline at end of file -- cgit v1.2.3 From 2b1f317ed7a4d402a268f62dd65dc0d648b5ad0c Mon Sep 17 00:00:00 2001 From: vincent-peugnet Date: Fri, 17 Jan 2020 18:07:27 +0100 Subject: media filter --- app/class/Controllermedia.php | 3 ++- app/view/templates/media.php | 32 +++++++++++++++++++++++- app/view/templates/mediamenu.php | 14 ++++++++--- app/view/templates/navback.php | 54 ---------------------------------------- 4 files changed, 44 insertions(+), 59 deletions(-) delete mode 100644 app/view/templates/navback.php (limited to 'app') diff --git a/app/class/Controllermedia.php b/app/class/Controllermedia.php index 5958289..b6b90c0 100644 --- a/app/class/Controllermedia.php +++ b/app/class/Controllermedia.php @@ -37,7 +37,8 @@ class Controllermedia extends Controller $dir = rtrim($_GET['path'] ?? Model::MEDIA_DIR, DIRECTORY_SEPARATOR); $sortby = isset($_GET['sortby']) ? $_GET['sortby'] : 'id'; $order = isset($_GET['order']) ? $_GET['order'] : '1'; - $opt = ['dir' => $dir, 'sortby' => $sortby, 'order' => $order]; + $type = $_GET['type'] ?? ['image', 'video', 'sound', 'other']; + $opt = ['dir' => $dir, 'sortby' => $sortby, 'order' => $order, 'type' => $type]; if(is_dir($dir)) { $medialist = $this->mediamanager->getlistermedia($dir . DIRECTORY_SEPARATOR); diff --git a/app/view/templates/media.php b/app/view/templates/media.php index f81b507..7b2fbc1 100644 --- a/app/view/templates/media.php +++ b/app/view/templates/media.php @@ -45,10 +45,38 @@ treecount($dirlist, 'media', 0, 'media', $dir, $opt); +
+ + +

filter

+ +
+
    +
  • >
  • +
  • >
  • +
  • >
  • +
  • >
  • +
+ +
+ > +
+ > +
+ + +
+ + +
@@ -71,12 +99,13 @@ treecount($dirlist, 'media', 0, 'media', $dir, $opt); type(), $opt['type'])) { ?> extension() ?> - type() == 'image' ? 'image 👁' : $media->type() ?> + type() == 'image' ? 'image 👁' : '⧉ ' . $media->type() ?> size('hr') ?> width() ?> height() ?> @@ -84,6 +113,7 @@ foreach ($medialist as $media) { getcode() ?> /"> +
+

Move

-
- + +
+

Delete

+ Delete selected medias +
@@ -64,6 +69,9 @@ Filter diff --git a/app/view/templates/navback.php b/app/view/templates/navback.php deleted file mode 100644 index 8218897..0000000 --- a/app/view/templates/navback.php +++ /dev/null @@ -1,54 +0,0 @@ - \ No newline at end of file -- cgit v1.2.3 From f124114eb1e08c1349396de70abdabfa99f445ca Mon Sep 17 00:00:00 2001 From: vincent-peugnet Date: Fri, 17 Jan 2020 18:19:41 +0100 Subject: css cleaning --- app/view/templates/media.php | 56 ++++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 26 deletions(-) (limited to 'app') diff --git a/app/view/templates/media.php b/app/view/templates/media.php index 7b2fbc1..0d5847e 100644 --- a/app/view/templates/media.php +++ b/app/view/templates/media.php @@ -12,7 +12,9 @@
-
+
+ -
+
+

@@ -105,7 +108,7 @@ foreach ($medialist as $media) { extension() ?> - type() == 'image' ? 'image 👁' : '⧉ ' . $media->type() ?> + type() == 'image' ? 'image 👁' : $media->type() . '⧉' ?> size('hr') ?> width() ?> height() ?> @@ -123,6 +126,7 @@ foreach ($medialist as $media) {
+
-- cgit v1.2.3 From 57ef3a9a12738081b3ab26559076bfb2b43e75db Mon Sep 17 00:00:00 2001 From: vincent-peugnet Date: Fri, 17 Jan 2020 18:42:58 +0100 Subject: css cleaning 2 --- app/view/templates/media.php | 121 ++++++++++++++++++++------------------- app/view/templates/mediamenu.php | 2 +- 2 files changed, 62 insertions(+), 61 deletions(-) (limited to 'app') diff --git a/app/view/templates/media.php b/app/view/templates/media.php index 0d5847e..6b62cbb 100644 --- a/app/view/templates/media.php +++ b/app/view/templates/media.php @@ -12,68 +12,69 @@
-
' . PHP_EOL; - $this->content = $div; + return $div; + } + } + + /** + * Generate link adress for table header + * + * @param string $sortby + * @return string link adress + */ + public function getsortbyadress(string $sortby) : string + { + if(!in_array($sortby, self::SORT_BY_FILTER)) { + $sortby = 'id'; + } + if ($this->sortby === $sortby) { + $order = $this->order * -1; + } else { + $order = $this->order; + } + $query = ['path' => $this->path, 'sortby' => $sortby, 'order' => $order, 'type' => $this->type]; + return '?' . urldecode(http_build_query($query)); + + } + + public function getpathadress(string $path) : string + { + $query = ['path' => '/' . $path, 'sortby' => $this->sortby, 'order' => $this->order, 'type' => $this->type]; + return '?' . urldecode(http_build_query($query)); + } - return true; + public function getquery() + { + $query = ['path' => $this->path, 'sortby' => $this->sortby, 'order' => $this->order]; + if(array_diff( self::TYPES, $this->type) != []) { + $query['type'] = $this->type; } + return '%MEDIA?' . urldecode(http_build_query($query)). '%'; } @@ -106,17 +142,38 @@ class Medialist return $this->fullmatch; } - public function options() + public function filter() { - return $this->options; + return $this->filter; } - public function content() + public function path() { - return $this->content; + return $this->path; } + /** + * @return string formated like `media//` + */ + public function dir() + { + return ltrim($this->path, '/') . '/'; + } + public function sortby() + { + return $this->sortby; + } + + public function order() + { + return $this->order; + } + + public function type() + { + return $this->type; + } // __________________________________________________ S E T ____________________________________________________________ @@ -127,21 +184,25 @@ class Medialist } - public function setoptions(string $options) + public function setfilter(string $filter) { - if (!empty($options)) { - $this->options = $options; + if (!empty($filter)) { + $this->filter = $filter; } } public function setpath(string $path) { - $this->path = $path; + if(preg_match('%^\/' . Model::MEDIA_DIR . '%', $path)) { + $this->path = $path; + } elseif (!preg_match('%^\/%', $path)) { + $this->path = '/' . Model::MEDIA_DIR . $path; + } } public function setsortby(string $sortby) { - if (in_array($sortby, self::SORT_BY_OPTIONS)) { + if (in_array($sortby, self::SORT_BY_FILTER)) { $this->sortby = $sortby; } } @@ -152,4 +213,11 @@ class Medialist $this->order = $order; } } + + public function settype($type) + { + if(is_array($type)) { + $this->type = array_intersect(self::TYPES, array_unique($type)); + } + } } diff --git a/app/class/Model.php b/app/class/Model.php index 81ad626..bb07fea 100644 --- a/app/class/Model.php +++ b/app/class/Model.php @@ -11,8 +11,8 @@ abstract class Model const ICONS_DIR = 'assets' . DIRECTORY_SEPARATOR .'icons' . DIRECTORY_SEPARATOR; const FONT_DIR = 'fonts' . DIRECTORY_SEPARATOR; const MEDIA_DIR = 'media' . DIRECTORY_SEPARATOR; - const FAVICON_DIR = 'media' . DIRECTORY_SEPARATOR . 'favicon' . DIRECTORY_SEPARATOR; - const THUMBNAIL_DIR = 'media' . DIRECTORY_SEPARATOR . 'thumbnail' . DIRECTORY_SEPARATOR; + const FAVICON_DIR = self::MEDIA_DIR . 'favicon' . DIRECTORY_SEPARATOR; + const THUMBNAIL_DIR = self::MEDIA_DIR . 'thumbnail' . DIRECTORY_SEPARATOR; const TEMPLATES_DIR = '.'. DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'view' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR; const RENDER_DIR = 'assets'. DIRECTORY_SEPARATOR . 'render' . DIRECTORY_SEPARATOR; const HTML_RENDER_DIR = 'render' . DIRECTORY_SEPARATOR; diff --git a/app/class/Modelmedia.php b/app/class/Modelmedia.php index 6ac647f..d1da829 100644 --- a/app/class/Modelmedia.php +++ b/app/class/Modelmedia.php @@ -33,16 +33,23 @@ class Modelmedia extends Model } } + public function medialistopt(Medialist $mediaopt) + { + $medialist = $this->getlistermedia($mediaopt->dir(), $mediaopt->type()); + $this->medialistsort($medialist, $mediaopt->sortby(), $mediaopt->order()); + + return $medialist; + } + /** * Display a list of media * * @param string $path - * @param string $sortby - * @param string $order + * @param array $type * * @return array of Media objects */ - public function getlistermedia($dir, $type = "all") + public function getlistermedia($dir, $type = Model::MEDIA_TYPES) { if (is_dir($dir)) { if ($handle = opendir($dir)) { @@ -56,11 +63,7 @@ class Modelmedia extends Model $media->analyse(); - if (in_array($type, self::MEDIA_TYPES)) { - if ($media->type() == $type) { - $list[] = $media; - } - } else { + if (in_array($media->type(), $type)) { $list[] = $media; } } @@ -74,22 +77,6 @@ class Modelmedia extends Model } - - public function mediacompare($media1, $media2, $method = 'id', $order = 1) - { - $result = ($media1->$method() <=> $media2->$method()); - return $result * $order; - } - - public function buildsorter($sortby, $order) - { - return function ($media1, $media2) use ($sortby, $order) { - $result = $this->mediacompare($media1, $media2, $sortby, $order); - return $result; - }; - } - - /** * Sort an array of media * @@ -103,6 +90,21 @@ class Modelmedia extends Model $order = ($order === 1 || $order === -1) ? $order : 1; return usort($medialist, $this->buildsorter($sortby, $order)); } + + public function buildsorter($sortby, $order) + { + return function ($media1, $media2) use ($sortby, $order) { + $result = $this->mediacompare($media1, $media2, $sortby, $order); + return $result; + }; + } + + public function mediacompare($media1, $media2, $method = 'id', $order = 1) + { + $result = ($media1->$method() <=> $media2->$method()); + return $result * $order; + } + diff --git a/app/class/Modelrender.php b/app/class/Modelrender.php index 778b327..593a420 100644 --- a/app/class/Modelrender.php +++ b/app/class/Modelrender.php @@ -437,16 +437,17 @@ class Modelrender extends Modelpage */ public function automedialist(string $text) { - preg_match_all('~\%MEDIA\?([a-zA-Z0-9\&=\-\/\%]*)\%~', $text, $out); + preg_match_all('~\%MEDIA\?([a-zA-Z0-9\[\]\&=\-\/\%]*)\%~', $text, $out); foreach ($out[0] as $key => $match) { - $matches[$key] = ['fullmatch' => $match, 'options' => $out[1][$key]]; + $matches[$key] = ['fullmatch' => $match, 'filter' => $out[1][$key]]; } if(isset($matches)) { foreach ($matches as $match) { $medialist = new Medialist($match); - $text = str_replace($medialist->fullmatch(), $medialist->content(), $text); + $medialist->readfilter(); + $text = str_replace($medialist->fullmatch(), $medialist->generatecontent(), $text); } } return $text; diff --git a/app/fn/fn.php b/app/fn/fn.php index ccccfb9..af02202 100644 --- a/app/fn/fn.php +++ b/app/fn/fn.php @@ -1,5 +1,7 @@ ' . $dirname . ''; + } else { + $folder = '├─📁' . $dirname; + } + echo ''; + echo '' . str_repeat('  ', $deepness) . $folder . ''; + echo '' . $dir['dirfilecount'] . ''; + echo ''; + foreach ($dir as $key => $value) { + if (is_array($value)) { + treecount($value, $key, $deepness + 1, $path . DIRECTORY_SEPARATOR . $key, $currentdir, $mediaopt); + } + } +} + + diff --git a/app/view/templates/media.php b/app/view/templates/media.php index 6b62cbb..12d4a2f 100644 --- a/app/view/templates/media.php +++ b/app/view/templates/media.php @@ -7,7 +7,7 @@ insert('backtopbar', ['user' => $user, 'tab' => 'media', 'pagelist' => $pagelist]) ?> - insert('mediamenu', ['dir' => $dir, 'user' => $user, 'pathlist' => $pathlist, 'opt' => $opt]) ?> + insert('mediamenu', ['user' => $user, 'pathlist' => $pathlist, 'mediaopt' => $mediaopt]) ?>
@@ -21,80 +21,67 @@ ' . $dirname . ''; - } else { - $folder = '├─📁' . $dirname; - } - echo ''; - echo '' . str_repeat('  ', $deepness) . $folder . ''; - echo '' . $dir['dirfilecount'] . ''; - echo ''; - foreach ($dir as $key => $value) { - if (is_array($value)) { - treecount($value, $key, $deepness + 1, $path . DIRECTORY_SEPARATOR . $key, $currentdir, $opt); - } - } - } - - treecount($dirlist, 'media', 0, 'media', $dir, $opt); + + treecount($dirlist, 'media', 0, 'media', $mediaopt->dir(), $mediaopt); ?> + + + +
+

filter

Type
    -
  • >
  • -
  • >
  • -
  • >
  • -
  • >
  • +
  • type()) ? 'checked' : '' ?>>
  • +
  • type()) ? 'checked' : '' ?>>
  • +
  • type()) ? 'checked' : '' ?>>
  • +
  • type()) ? 'checked' : '' ?>>
Sort
- > + order() == 1 ? 'checked' : '' ?>>
- > + order() == -1 ? 'checked' : '' ?>>
- +
- - +
-

+

/dir() ?>

- + - - + + @@ -103,7 +90,6 @@ type(), $opt['type'])) { ?> @@ -117,11 +103,7 @@ foreach ($medialist as $media) {
xidid exttypesizetypesize width height lengh
getcode() ?>
diff --git a/app/view/templates/mediamenu.php b/app/view/templates/mediamenu.php index 9044194..560025a 100644 --- a/app/view/templates/mediamenu.php +++ b/app/view/templates/mediamenu.php @@ -7,14 +7,14 @@
- +

Folder

- +
@@ -29,7 +29,7 @@

Folder

- +
@@ -39,7 +39,7 @@

Move

- +