Skip to content

Commit f9174db

Browse files
authored
Add Hidefiles property check for media browser
1 parent 6a0d422 commit f9174db

File tree

1 file changed

+44
-40
lines changed

1 file changed

+44
-40
lines changed

core/components/awss3mediasource/model/awss3mediasource/awss3mediasource.class.php

Lines changed: 44 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ public function getContainerList($path)
115115
$useMultiByte = $this->ctx->getOption('use_multibyte', false);
116116
$encoding = $this->ctx->getOption('modx_charset', 'UTF-8');
117117
$hideTooltips = !empty($this->properties['hideTooltips']) && $this->properties['hideTooltips'] != 'false' ? true : false;
118+
$hideFiles = !empty($this->properties['hideFiles']) && $this->properties['hideFiles'] != 'false' ? true : false;
118119

119120
$imageExtensions = $this->getOption('imageExtensions', $this->properties, 'jpg,jpeg,png,gif');
120121
$imageExtensions = explode(',', $imageExtensions);
@@ -150,46 +151,49 @@ public function getContainerList($path)
150151
$directories[$currentPath]['menu'] = array('items' => $this->getDirectoriesContextMenu());
151152
}
152153

153-
foreach ($listFiles as $idx => $currentPath) {
154-
if ($currentPath == $path) continue;
155-
156-
$fileName = basename($currentPath);
157-
158-
$ext = pathinfo($fileName, PATHINFO_EXTENSION);
159-
$ext = $useMultiByte ? mb_strtolower($ext, $encoding) : strtolower($ext);
160-
161-
$cls = array();
162-
163-
$encoded = explode('/', $currentPath);
164-
$encoded = array_map('urlencode', $encoded);
165-
$encoded = implode('/', $encoded);
166-
$encoded = rtrim($this->properties['url'], '/') . '/' . $encoded;
167-
168-
$url = rtrim($this->properties['url'], '/') . '/' . $currentPath;
169-
$page = '?a=' . $editAction . '&file=' . $currentPath . '&wctx=' . $this->ctx->get('key') . '&source=' . $this->get('id');
170-
171-
if ($this->hasPermission('file_remove')) $cls[] = 'premove';
172-
if ($this->hasPermission('file_update')) $cls[] = 'pupdate';
173-
174-
$fileNames[] = strtoupper($fileName);
175-
$files[$currentPath] = array(
176-
'id' => $currentPath,
177-
'text' => $fileName,
178-
'cls' => implode(' ', $cls),
179-
'iconCls' => 'icon icon-file icon-' . $ext,
180-
'type' => 'file',
181-
'leaf' => true,
182-
'path' => $currentPath,
183-
'page' => $this->isBinary($encoded) ? $page : null,
184-
'pathRelative' => $url,
185-
'directory' => $currentPath,
186-
'url' => $url,
187-
'file' => $currentPath,
188-
);
189-
$files[$currentPath]['menu'] = array('items' => $this->getFilesContextMenu($files[$currentPath]));
190-
191-
if (!$hideTooltips) {
192-
$files[$currentPath]['qtip'] = in_array($ext, $imageExtensions) ? '<img src="' . $url . '" alt="' . $fileName . '" />' : '';
154+
//Skip if media browser file tree
155+
if(!$hideFiles){
156+
foreach ($listFiles as $idx => $currentPath) {
157+
if ($currentPath == $path) continue;
158+
159+
$fileName = basename($currentPath);
160+
161+
$ext = pathinfo($fileName, PATHINFO_EXTENSION);
162+
$ext = $useMultiByte ? mb_strtolower($ext, $encoding) : strtolower($ext);
163+
164+
$cls = array();
165+
166+
$encoded = explode('/', $currentPath);
167+
$encoded = array_map('urlencode', $encoded);
168+
$encoded = implode('/', $encoded);
169+
$encoded = rtrim($this->properties['url'], '/') . '/' . $encoded;
170+
171+
$url = rtrim($this->properties['url'], '/') . '/' . $currentPath;
172+
$page = '?a=' . $editAction . '&file=' . $currentPath . '&wctx=' . $this->ctx->get('key') . '&source=' . $this->get('id');
173+
174+
if ($this->hasPermission('file_remove')) $cls[] = 'premove';
175+
if ($this->hasPermission('file_update')) $cls[] = 'pupdate';
176+
177+
$fileNames[] = strtoupper($fileName);
178+
$files[$currentPath] = array(
179+
'id' => $currentPath,
180+
'text' => $fileName,
181+
'cls' => implode(' ', $cls),
182+
'iconCls' => 'icon icon-file icon-' . $ext,
183+
'type' => 'file',
184+
'leaf' => true,
185+
'path' => $currentPath,
186+
'page' => $this->isBinary($encoded) ? $page : null,
187+
'pathRelative' => $url,
188+
'directory' => $currentPath,
189+
'url' => $url,
190+
'file' => $currentPath,
191+
);
192+
$files[$currentPath]['menu'] = array('items' => $this->getFilesContextMenu($files[$currentPath]));
193+
194+
if (!$hideTooltips) {
195+
$files[$currentPath]['qtip'] = in_array($ext, $imageExtensions) ? '<img src="' . $url . '" alt="' . $fileName . '" />' : '';
196+
}
193197
}
194198
}
195199

0 commit comments

Comments
 (0)