aboutsummaryrefslogtreecommitdiff
path: root/app/view/templates/media.php
blob: b13c58aadbd1d51ff4f87100b2eda144980e059b (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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<?php $this->layout('layout', ['title' => 'media', 'css' => $css . 'home.css']) ?>


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

<body>

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


<main class="media">


<div id="tree">
<h2>Explorer</h2>


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

<?php

function treecount(array $dir, string $dirname, int $deepness, string $path, string $currentdir, array $opt)
{
    if ($path === $currentdir) {
        $folder = '├─📂<strong>' . $dirname . '<strong>';
    } else {
        $folder = '├─📁' . $dirname;
    }
    echo '<tr>';
    echo '<td><a href="?path=' . $path . '&sortby=' . $opt['sortby'] . '&order=' . $opt['order'] . '">' . str_repeat('&nbsp;&nbsp;', $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, $opt);
        }
    }
}

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

?>



</table>
</div>


<div id="explorer">


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


<details>
    <summary>Print this content on your page</summary>
    
    <p>
    <code>%MEDIA?path=<?= substr($dir, 6) ?>&sortby=<?= $opt['sortby'] ?>&order=<?= $opt['order'] ?>%</code>
    </p>

</details>



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

<?php if($user->issupereditor()) { ?>

<form action="<?= $this->url('mediafolderdelete') ?>" id="deletefolder" method="post" class="hidephone">
    <input type="hidden" name="dir" value="<?= $dir ?>/">
    <input type="checkbox" name="deletefolder" id="confirmdeletefolder" value="1">
    <label for="confirmdeletefolder">Delete folder and all it's content</label>
    <input type="submit" value="delete folder" >
</form>


<?php } ?>

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



<?php if($user->issupereditor()) { ?>

<form action="<?= $this->url('mediaedit') ?>" method="post" id="mediaedit">
    <input type="hidden" name="path" value="<?= $dir ?>">
    <label for="moveto">Selected medias :</label>
    <select name="dir" id="moveto" >
        <option selected>---select destination---</option>
        <option value="<?= Model::MEDIA_DIR ?>">/</option>
        <?php
            foreach ($pathlist as $path) {
                echo '<option value="' . Model::MEDIA_DIR . $path . '">' . $path . '</option>';
            }
        ?>
    </select>
    <input type="submit" name="action" value="move" >
    <input type="submit" name="action" value="delete" >
</form>

<?php } ?>




<table id="medialist">
<tr>
    <th>x</th>
    <th><a href="?path=<?= $dir ?>&sortby=id&order=<?php echo ($opt['order'] * -1); ?>">id</a></th>
    <th>ext</th>
    <th><a href="?path=<?= $dir ?>&sortby=type&order=<?php echo ($opt['order'] * -1); ?>">type</a></th>
    <th><a href="?path=<?= $dir ?>&sortby=size&order=<?php echo ($opt['order'] * -1); ?>">size</a></th>
    <th>width</th>
    <th>height</th>
    <th>lengh</th>
    <th>code</th>
</tr>

<?php
foreach ($medialist as $media) {
    ?>
    <tr>
    <td><input type="checkbox" name="id[]" value="<?= $media->getfulldir() ?>" form="mediaedit" id="media_<?= $media->id() ?>"></td>
    <td><label for="media_<?= $media->id() ?>"><?= $media->id() ?></label></td>    
    <td><?= $media->extension() ?></td>
    <td><a href="<?= $media->getfullpath() ?>" target="_blank"><?= $media->type() == 'image' ? '<span class="thumbnail">image 👁<img src="' . $media->getfullpath() . '"></span>' : $media->type() ?></a></td>
    <td><?= $media->size('hr') ?></td>
    <td><?= $media->width() ?></td>
    <td><?= $media->height() ?></td>
    <td><?= $media->length() ?></td>
    <td class="code"><code>
    <?php
        if($media->type() == 'image') {
            ?>
            ![<?= $media->id() ?>](<?= $media->getincludepath() ?>)
            <?php
        } elseif ($media->type() == 'other') {
            ?>
            [<?= $media->id() ?>](<?= $media->getincludepath() ?>)
            <?php
        } else {
            echo $media->getincludepath();
        }
        ?>
    </code></td>
    </tr>
    <?php

}


?>

</table>

</div>

</main>
</body>

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