If no path given, if there is 1 storage area, default to it otherwise list available storage areas
parent
b6a49bef00
commit
3c6ba77be9
|
@ -23,23 +23,34 @@ if (!canView('Events')) {
|
|||
return;
|
||||
}
|
||||
|
||||
$path = (!empty($_REQUEST['path'])) ? detaintPathAllowAbsolute($_REQUEST['path']) : ZM_DIR_EVENTS;
|
||||
$storage_areas = ZM\Storage::find();
|
||||
$is_ok_path = false;
|
||||
foreach (ZM\Storage::find() as $storage) {
|
||||
$rc = strstr($path, $storage->Path(), true);
|
||||
ZM\Debug("rc from strstr ($rc) $path ".$storage->Path());
|
||||
if ((false !== $rc) and ($rc == '')) {
|
||||
# Must be at the beginning
|
||||
$is_ok_path = true;
|
||||
$path = (!empty($_REQUEST['path'])) ? detaintPathAllowAbsolute($_REQUEST['path']) : '';
|
||||
if (!$path) {
|
||||
if (count($storage_areas)==0) {
|
||||
$path = ZM_DIR_EVENTS;
|
||||
} else if (count($storage_areas)==0) {
|
||||
$path = $storage_areas[0]->Path();
|
||||
}
|
||||
}
|
||||
$path_parts = pathinfo($path);
|
||||
|
||||
if (@is_file($path)) {
|
||||
if (output_file($path))
|
||||
return;
|
||||
$path = $path_parts['dirname'];
|
||||
}
|
||||
if ($path) {
|
||||
foreach ($storage_areas as $storage) {
|
||||
$rc = strstr($path, $storage->Path(), true);
|
||||
if ((false !== $rc) and ($rc == '')) {
|
||||
# Must be at the beginning
|
||||
$is_ok_path = true;
|
||||
}
|
||||
}
|
||||
$path_parts = pathinfo($path);
|
||||
|
||||
if (@is_file($path)) {
|
||||
if (output_file($path))
|
||||
return;
|
||||
$path = $path_parts['dirname'];
|
||||
}
|
||||
} # end if path
|
||||
|
||||
$show_hidden = isset($_REQUEST['show_hidden']) ? $_REQUEST['show_hidden'] : 0;
|
||||
|
||||
function guess_material_icon($file) {
|
||||
|
@ -63,24 +74,30 @@ xhtmlHeaders(__FILE__, translate('Files'));
|
|||
<div id="content">
|
||||
<form id="filesForm" name="filesForm" method="post" action="?view=files&path=<?php echo urlencode($path); ?>">
|
||||
<?php
|
||||
if (!$is_ok_path) {
|
||||
echo '<div class="error">Path is not valid. Path must be below a designated Storage area.<br/></div>';
|
||||
} else {
|
||||
$exploded = explode('/', $path);
|
||||
ZM\Debug(print_r($exploded, true));
|
||||
$array = array();
|
||||
$files = array();
|
||||
$folders = array();
|
||||
$parent = '';
|
||||
for ($i = 0; $i < count($exploded); $i++) {
|
||||
if ($exploded[$i])
|
||||
$parent = $parent . '/' . $exploded[$i];
|
||||
$parent_enc = urlencode($parent);
|
||||
$array[] = "<a href='?view=files&path={$parent_enc}'>" . validHtmlStr($exploded[$i]) . '</a>';
|
||||
}
|
||||
array_pop($exploded);
|
||||
|
||||
$parent = implode('/', $exploded);
|
||||
$sep = '<i class="bread-crumb"> / </i>';
|
||||
echo implode($sep, $array).'<br/>';
|
||||
if ($path) {
|
||||
if (!$is_ok_path) {
|
||||
echo '<div class="error">Path is not valid. Path must be below a designated Storage area.<br/></div>';
|
||||
$path = '';
|
||||
} else {
|
||||
$exploded = explode('/', $path);
|
||||
$array = array();
|
||||
for ($i = 0; $i < count($exploded); $i++) {
|
||||
if ($exploded[$i])
|
||||
$parent = $parent . '/' . $exploded[$i];
|
||||
$parent_enc = urlencode($parent);
|
||||
$array[] = "<a href='?view=files&path={$parent_enc}'>" . validHtmlStr($exploded[$i]) . '</a>';
|
||||
}
|
||||
array_pop($exploded);
|
||||
|
||||
$parent = implode('/', $exploded);
|
||||
$sep = '<i class="bread-crumb"> / </i>';
|
||||
echo implode($sep, $array).'<br/>';
|
||||
}
|
||||
} # end if path
|
||||
?>
|
||||
<table id="contentTable" class="major">
|
||||
<thead class="thead-highlight">
|
||||
|
@ -91,21 +108,25 @@ echo implode($sep, $array).'<br/>';
|
|||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$files = array();
|
||||
$folders = array();
|
||||
$entries = is_readable($path) ? scandir($path) : array();
|
||||
foreach ($entries as $file) {
|
||||
if ($file == '.' || $file == '..') {
|
||||
continue;
|
||||
if ($path) {
|
||||
$entries = is_readable($path) ? scandir($path) : array();
|
||||
foreach ($entries as $file) {
|
||||
if ($file == '.' || $file == '..') {
|
||||
continue;
|
||||
}
|
||||
if (!$show_hidden && substr($file, 0, 1) === '.') {
|
||||
continue;
|
||||
}
|
||||
$full_path = $path.'/'.$file;
|
||||
if (@is_file($full_path)) {
|
||||
$files[] = $file;
|
||||
} else if (@is_dir($full_path)) {
|
||||
$folders[] = $file;
|
||||
}
|
||||
}
|
||||
if (!$show_hidden && substr($file, 0, 1) === '.') {
|
||||
continue;
|
||||
}
|
||||
$full_path = $path.'/'.$file;
|
||||
if (@is_file($full_path)) {
|
||||
$files[] = $file;
|
||||
} else if (@is_dir($full_path)) {
|
||||
$folders[] = $file;
|
||||
} else { # ! path
|
||||
foreach ($storage_areas as $storage) {
|
||||
$folders[] = $storage->Path();
|
||||
}
|
||||
}
|
||||
natcasesort($files);
|
||||
|
@ -118,7 +139,7 @@ if ($parent != '') {
|
|||
</tr>';
|
||||
}
|
||||
foreach ($folders as $folder) {
|
||||
$url = urlencode($path.'/'.$folder);
|
||||
$url = urlencode(($path?$path.'/':'').$folder);
|
||||
echo '
|
||||
<tr>
|
||||
<td class="colSelect"><input type="checkbox" name="files[]" value="'.validHtmlStr($folder).'"/></td>
|
||||
|
@ -135,9 +156,6 @@ foreach ($files as $file) {
|
|||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php
|
||||
} # end if is_ok_path
|
||||
?>
|
||||
<div id="contentButtons">
|
||||
<button type="submit" name="action" value="delete" disabled="disabled">
|
||||
<?php echo translate('Delete') ?>
|
||||
|
|
Loading…
Reference in New Issue