aboutsummaryrefslogtreecommitdiff
path: root/app/class/controllermedia.php
diff options
context:
space:
mode:
authorvincent-peugnet <v.peugnet@free.fr>2018-12-17 15:34:20 +0100
committervincent-peugnet <v.peugnet@free.fr>2018-12-17 15:34:20 +0100
commit1a7a60ea3efde53ac2c3b07ca914483cfc25a827 (patch)
treeac1f09d4d041c19501dd211df451d8d35ef55c47 /app/class/controllermedia.php
parent300cf1cc8399d29f61052c0ad09ba1cca2d04d4d (diff)
downloadwcms-1a7a60ea3efde53ac2c3b07ca914483cfc25a827.tar.gz
wcms-1a7a60ea3efde53ac2c3b07ca914483cfc25a827.zip
media
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);
+
+ }
+
}