aboutsummaryrefslogtreecommitdiff
path: root/app/class/Medialist.php
diff options
context:
space:
mode:
authorvincent-peugnet <v.peugnet@free.fr>2020-01-20 01:56:57 +0100
committervincent-peugnet <v.peugnet@free.fr>2020-01-20 01:56:57 +0100
commit49273cba81ea86639a23dfd5a43bda2f6b01f075 (patch)
tree94da83daa5fa168dab08b8443664fddccf0b47a1 /app/class/Medialist.php
parent227a2a35d64db87d889f7a44101f11a117b8e06a (diff)
downloadwcms-49273cba81ea86639a23dfd5a43bda2f6b01f075.tar.gz
wcms-49273cba81ea86639a23dfd5a43bda2f6b01f075.zip
fix media little problems
Diffstat (limited to 'app/class/Medialist.php')
-rw-r--r--app/class/Medialist.php19
1 files changed, 14 insertions, 5 deletions
diff --git a/app/class/Medialist.php b/app/class/Medialist.php
index d36e5d1..b208fef 100644
--- a/app/class/Medialist.php
+++ b/app/class/Medialist.php
@@ -113,14 +113,20 @@ class Medialist
} else {
$order = $this->order;
}
- $query = ['path' => $this->path, 'sortby' => $sortby, 'order' => $order, 'type' => $this->type];
+ $query = ['path' => $this->path, 'sortby' => $sortby, 'order' => $order];
+ if(array_diff( self::TYPES, $this->type) != []) {
+ $query['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];
+ $query = ['path' => '/' . $path, 'sortby' => $this->sortby, 'order' => $this->order];
+ if(array_diff( self::TYPES, $this->type) != []) {
+ $query['type'] = $this->type;
+ }
return '?' . urldecode(http_build_query($query));
}
@@ -147,6 +153,9 @@ class Medialist
return $this->filter;
}
+ /**
+ * @return string formated like `/media/<folder>`
+ */
public function path()
{
return $this->path;
@@ -193,10 +202,10 @@ class Medialist
public function setpath(string $path)
{
- if(preg_match('%^\/' . Model::MEDIA_DIR . '%', $path)) {
- $this->path = $path;
+ if(preg_match('%^\/' . rtrim(Model::MEDIA_DIR, DIRECTORY_SEPARATOR) . '%', $path)) {
+ $this->path = rtrim($path, DIRECTORY_SEPARATOR);
} elseif (!preg_match('%^\/%', $path)) {
- $this->path = '/' . Model::MEDIA_DIR . $path;
+ $this->path = '/' . Model::MEDIA_DIR . rtrim($path, DIRECTORY_SEPARATOR);
}
}