diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..86d36cf Binary files /dev/null and b/.DS_Store differ diff --git a/.gitignore b/.gitignore index c64b096..0351d89 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ config/admin.ini config/database.config.ini public/img/header +public/img/page diff --git a/application/controller/AdminPageController.php b/application/controller/AdminPageController.php index ce1923a..4c37b28 100644 --- a/application/controller/AdminPageController.php +++ b/application/controller/AdminPageController.php @@ -26,19 +26,22 @@ class AdminPageController extends Katharsis_Controller_Abstract $type = 'page'; } - $path = getcwd().'/img/' . $type . '/'; + $path = getcwd().'/public/img/' . $type . '/'; if(isset($_FILES['myfile'])) { $upload = new Upload(); if($type == 'header') { - $upload->header($_FILES['myfile']); + $imagePath = $upload->header($_FILES['myfile']); } else { - $upload->page($_FILES['myfile']); + $imagePath = $upload->page($_FILES['myfile']); } - echo 'Das Hochladen war erfolgreich.

'; + $this->_view->imagePath = $imagePath; + + echo $this->_view->render('AdminPage/uploadsuccess'); + die(); } @@ -51,7 +54,7 @@ class AdminPageController extends Katharsis_Controller_Abstract } $ar = array(); - if (is_readable($path) && $handle = opendir()) + if (is_readable($path) && $handle = opendir($path)) { while (false !== ($file = readdir($handle))) { if(is_dir($file)) continue; @@ -60,6 +63,7 @@ class AdminPageController extends Katharsis_Controller_Abstract closedir($handle); } + $this->_view->type = $type; $this->_view->files = $ar; echo $this->_view->render('AdminPage/image'); diff --git a/application/controller/PageController.php b/application/controller/PageController.php index d844d41..946894b 100644 --- a/application/controller/PageController.php +++ b/application/controller/PageController.php @@ -18,7 +18,7 @@ class PageController extends Katharsis_Controller_Abstract $url = substr($method, 0, -6); // remove Action from urlAction - $pageId = $this->_page->getIdByUrl($url); + $pageId = $this->_page->getIdByUrl($url, $preview); if(!$pageId) { throw new DidgeridooArtwork_Exception('Page konnte nicht geladen werden.'); diff --git a/application/model/Upload.php b/application/model/Upload.php index 2b1091e..296a629 100644 --- a/application/model/Upload.php +++ b/application/model/Upload.php @@ -8,13 +8,13 @@ class Upload extends Katharsis_Model_Abstract public function header($file) { - $dir = getcwd() . '/img/header'; + $dir = getcwd() . '/public/img/header'; return $this->_uploadFile(null, $file, $dir); } public function page($file) { - $dir = getcwd() . '/img/page'; + $dir = getcwd() . '/public/img/page'; return $this->_uploadFile(null, $file, $dir, $file['name'] . '-' . time()); } @@ -22,7 +22,7 @@ class Upload extends Katharsis_Model_Abstract { if($name === null) { - $name = $id . '-' . time(); + $name = time(); } else { @@ -31,25 +31,35 @@ class Upload extends Katharsis_Model_Abstract $name = $nameparts[0]; } } - - $handle = new Verot_Upload($file); - return; - $handle->file_new_name_body = $name; - - if ($handle->uploaded) - { - $handle->Process($dir); - if (!$handle->processed) - { - throw new DidgeridooArtwork_Exception('Datei konnte nicht verschoben werden (' . $handle->error . ').'); - } - $handle->Clean(); + + if (!is_dir($dir)) { + mkdir($dir); } - else + + $typeAccepted = array("image/jpeg", "image/gif", "image/png"); + if(!in_array($file['type'], $typeAccepted)) { + throw new DidgeridooArtwork_Exception('Hochladen fehlgeschlagen. Dateityp nicht akzeptiert. Nur jpeg, gif und png möglich'); + return false; + } + + $ext = ''; + switch($file['type']) { + case "image/jpeg": + $ext = '.jpg'; + break; + case "image/gif": + $ext = '.gif'; + break; + case "image/png": + $ext = '.png'; + break; + } + + if (!move_uploaded_file($file['tmp_name'], $dir . '/' . $name . $ext)) { - throw new DidgeridooArtwork_Exception('Datei konnte nicht hochgeladen werden (' . $handle->error . ').'); + throw new DidgeridooArtwork_Exception('Hochladen fehlgeschlagen. (move_uploaded_file: false)'); + return false; } - $returnName = $handle->file_dst_name; - return $returnName; + return $name . $ext; } } \ No newline at end of file diff --git a/application/view/AdminPage/image.phtml b/application/view/AdminPage/image.phtml index 29efa22..a834ffa 100644 --- a/application/view/AdminPage/image.phtml +++ b/application/view/AdminPage/image.phtml @@ -1,9 +1,8 @@ - Swiss Didgeridoo Artwork + Seinheit - @@ -18,8 +17,8 @@