aboutsummaryrefslogtreecommitdiff
path: root/app/class/controllermedia.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/class/controllermedia.php')
-rw-r--r--app/class/controllermedia.php41
1 files changed, 33 insertions, 8 deletions
diff --git a/app/class/controllermedia.php b/app/class/controllermedia.php
index f156b35..4421f65 100644
--- a/app/class/controllermedia.php
+++ b/app/class/controllermedia.php
@@ -2,18 +2,31 @@
class Controllermedia extends Controller
{
+ /**
+ * @var Modelmedia
+ */
protected $mediamanager;
- public function __construct($render) {
+ public function __construct($render)
+ {
parent::__construct($render);
-
+
$this->mediamanager = new Modelmedia;
}
public function desktop()
{
- if($this->user->iseditor()) {
+ if ($this->user->iseditor()) {
+
+ if (!$this->mediamanager->basedircheck()) {
+ throw new Exception("Error : Cant create /media folder");
+ }
+ if (!$this->mediamanager->favicondircheck()) {
+ throw new Exception("Error : Cant create /media/favicon folder");
+ }
+
+
$dir = rtrim($_GET['path'] ?? Model::MEDIA_DIR, DIRECTORY_SEPARATOR);
$medialist = $this->mediamanager->getlistermedia($dir . DIRECTORY_SEPARATOR);
@@ -29,16 +42,28 @@ class Controllermedia extends Controller
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);
+ if ($this->user->iseditor()) {
+ $target = $_POST['dir'] ?? Model::MEDIA_DIR;
+ if (!empty($_FILES['file']['name'][0])) {
+ $this->mediamanager->upload($target);
+ }
+ $this->redirect($this->router->generate('media') . '?path=' . $target);
} else {
$this->routedirect('home');
}
}
+ public function folder()
+ {
+ if ($this->user->iseditor()) {
+ $dir = $_POST['dir'] ?? Model::MEDIA_DIR;
+ $name = $_POST['foldername'] ?? 'new folder';
+ $this->mediamanager->adddir($dir, $name);
+ }
+ $this->redirect($this->router->generate('media') . '?path=' . $dir . DIRECTORY_SEPARATOR . $name);
+
+ }
+
}