mirror of
https://github.com/prasathmani/tinyfilemanager
synced 2024-06-08 00:42:19 +02:00
Merge ebdc7e2c91
into ca4b1b1743
This commit is contained in:
commit
7947dcbb07
|
@ -107,6 +107,9 @@ $exclude_items = array();
|
|||
// false => disable online doc viewer
|
||||
$online_viewer = 'google';
|
||||
|
||||
// Display CSV files as HTML table
|
||||
$display_csv_as_table = true;
|
||||
|
||||
// Sticky Nav bar
|
||||
// true => enable sticky header
|
||||
// false => disable sticky header
|
||||
|
@ -1669,6 +1672,7 @@ if (isset($_GET['view'])) {
|
|||
$is_audio = false;
|
||||
$is_video = false;
|
||||
$is_text = false;
|
||||
$is_csv = false;
|
||||
$is_onlineViewer = false;
|
||||
|
||||
$view_title = 'File';
|
||||
|
@ -1692,6 +1696,9 @@ if (isset($_GET['view'])) {
|
|||
} elseif (in_array($ext, fm_get_video_exts())) {
|
||||
$is_video = true;
|
||||
$view_title = 'Video';
|
||||
} elseif ($display_csv_as_table && $ext == 'csv') {
|
||||
$is_csv = true;
|
||||
$view_title = "CSV File";
|
||||
} elseif (in_array($ext, fm_get_text_exts()) || substr($mime_type, 0, 4) == 'text' || in_array($mime_type, fm_get_text_mimes())) {
|
||||
$is_text = true;
|
||||
$content = file_get_contents($file_path);
|
||||
|
@ -1767,7 +1774,7 @@ if (isset($_GET['view'])) {
|
|||
</form>
|
||||
<?php
|
||||
}
|
||||
if ($is_text && !FM_READONLY) {
|
||||
if (!FM_READONLY && ($is_text || $is_csv)) {
|
||||
?>
|
||||
<b class="ms-2"><a href="?p=<?php echo urlencode(trim(FM_PATH)) ?>&edit=<?php echo urlencode($file) ?>" class="edit-file"><i class="fa fa-pencil-square"></i> <?php echo lng('Edit') ?>
|
||||
</a></b>
|
||||
|
@ -1810,6 +1817,15 @@ if (isset($_GET['view'])) {
|
|||
} elseif ($is_video) {
|
||||
// Video content
|
||||
echo '<div class="preview-video"><video src="' . fm_enc($file_url) . '" width="640" height="360" controls preload="metadata"></video></div>';
|
||||
} elseif ($is_csv) {
|
||||
$tableTheme = (FM_THEME == "dark") ? "text-white bg-dark table-dark" : "bg-white";
|
||||
echo '<table class="table table-hover table-sm ' . $tableTheme .'">';
|
||||
$csvFilePointer = fopen($file_path, 'r');
|
||||
while ( ($csvRow = fgetcsv($csvFilePointer) ) !== FALSE ) {
|
||||
echo '<tr><td>'. implode('</td><td>', $csvRow). '</td></tr>';
|
||||
}
|
||||
fclose($csvFilePointer);
|
||||
echo '</table>';
|
||||
} elseif ($is_text) {
|
||||
if (FM_USE_HIGHLIGHTJS) {
|
||||
// highlight
|
||||
|
|
Loading…
Reference in a new issue