aboutsummaryrefslogtreecommitdiff
path: root/app/view/templates/media.php
blob: 6bcba5d1c4d90b26f9917f724be0684132f22b00 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php $this->layout('layout', ['title' => 'media', 'css' => $css . 'home.css']) ?>


<?php $this->start('page') ?>

<body>

    <?php $this->insert('backtopbar', ['user' => $user, 'tab' => 'media']) ?>


<section class="media">

<h1>Explorer</h1>


<table id="dirlsit">
<tr><th>folder</th><th>files</th></tr>

<?php

function treecount(array $dir, string $dirname, int $deepness, string $path, string $currentdir) {
    if($path  === $currentdir) {
        $folder = '├─📂<strong>'. $dirname.'<strong>';
    } else {
        $folder = '├─📁'. $dirname;
    }
    echo '<tr>';
    echo '<td><a href="?path='.$path.'">'. str_repeat(' ‎ ‎', $deepness) .$folder.'</a></td>';
    echo '<td>'.$dir['dirfilecount'].'</td>';
    echo '</tr>';
    foreach ($dir as $key => $value) {
        if(is_array($value)) {
            treecount($value, $key, $deepness + 1, $path . DIRECTORY_SEPARATOR . $key, $currentdir);
        }
    }
}

treecount($dirlist, 'media', 0, 'media', $dir);

?>



</table>

<h2><?= $dir ?></h2>

<form id="addfolder" action="<?= $this->url('mediafolder') ?>" method="post">
    <label for="foldername">📂 New folder</label>
    <input type="text" name="foldername" id="foldername" placeholder="folder name" >
    <input type="hidden" name="dir" value="<?= $dir ?>">
    <input type="submit" value="create folder">
</form>

<form id=addmedia action="<?= $this->url('mediaupload') ?>" method="post" enctype="multipart/form-data">
    <label for="file">🚀 Upload files</label>
    <input type='file' id="file" name='file[]' multiple>
    <input type="hidden" name="dir" value="<?= $dir ?>">
    <input type="submit" value="upload">
</form>



<table id="medialist">
<tr><th>id</th><th>ext</th><th>type</th><th>size</th><th>width</th><th>height</th><th>lengh</th></tr>

<?php
foreach ($medialist as $media) {
    ?>
    <tr>
    <td><a href="<?= $media->getfullpath() ?>" target="_blank"><?= $media->id() ?></a></td>
    <td><?= $media->extension() ?></td>

    <td><?= $media->type() == 'image' ? 'image <span class="thumbnail">👁<img src="'.$media->getfullpath().'"></span>' : $media->type() ?></td>
    <td><?= readablesize($media->size()) ?></td>
    <td><?= $media->width() ?></td>
    <td><?= $media->height() ?></td>
    <td><?= $media->length() ?></td>
    </tr>
    <?php
}


?>

</table>

</section>
</body>

<?php $this->stop('page') ?>