aboutsummaryrefslogtreecommitdiff
path: root/app/class/controllermedia.php
blob: f156b355cb3ecca5a1f1656f4d3c2f03f39dc7f2 (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
<?php

class Controllermedia extends Controller
{
    protected $mediamanager;

    public function __construct($render) {
        parent::__construct($render);
        
        $this->mediamanager = new Modelmedia;

    }

    public function desktop()
    {
        if($this->user->iseditor()) {
            $dir = rtrim($_GET['path'] ?? Model::MEDIA_DIR, DIRECTORY_SEPARATOR);

            $medialist = $this->mediamanager->getlistermedia($dir . DIRECTORY_SEPARATOR);
            $faviconlist = $this->mediamanager->getlistermedia(Model::FAVICON_DIR);

            $dirlist = $this->mediamanager->listdir(Model::MEDIA_DIR);

            $this->showtemplate('media', ['medialist' => $medialist, 'faviconlist' => $faviconlist, 'dirlist' => $dirlist, 'dir' => $dir]);
        } else {
            $this->routedirect('home');
        }
    }

    public function upload()
    {
        if($this->user->iseditor()) {
        $target = $_POST['dir'] ?? Model::MEDIA_DIR;

        $this->mediamanager->upload($target);
        $this->redirect($this->router->generate('media').'?path='.$target);
        } else {
            $this->routedirect('home');
        }
    }


}


?>