From febd8f08837963d706c44f554fbc6ea637276f5d Mon Sep 17 00:00:00 2001 From: Logsol Date: Wed, 10 Jul 2013 14:27:24 +0200 Subject: [PATCH] resoving --- .DS_Store | Bin 0 -> 12292 bytes .../controller/AdminPageController.php | 9 ++- application/controller/PageController.php | 2 +- application/model/Upload.php | 52 +++++++++++------- .../view/AdminPage/uploadsuccess.phtml | 10 ++++ .../Controller/Plugin/Navigation.php | 2 +- .../Controller/Plugin/Autorender.php | 39 +++++++------ public/index.php | 2 - 8 files changed, 69 insertions(+), 47 deletions(-) create mode 100644 .DS_Store create mode 100644 application/view/AdminPage/uploadsuccess.phtml diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..86d36cf28738eb0995c9b05781f95657c9ae533a GIT binary patch literal 12292 zcmeI1&2Jk;6u{q0(sWH4x=oul1yNSb1*uk*?=%vE#S}rrAyFN*iIS4;dNzCGapuCkZ$9k0Htqq5io%;{=Z)sQH#6_2d9$7k0AQ&e z%mPdSfJKj#_83)vQKVizePzh>NIxWhfCwt!K~7TiS#t*yU;<2l2`~XB@NXbM?`&DD z0q=dS<(dgFf&V1|c|JJwNa-5c(o!8ARH-Wf$r0*Sh1zrvP(F^4u8}P*l`D;@Zx3i( z(OfZ5yOZ9L<|JJsTUu&&KQBQ(wySy)s%25#dUV2-# zb1$!FB`;N)buZs1jcRWQ5mS4|Sl^0*e1F%z*l5hIEX^04xtXPA(P^wKEEJvPx!Gp3 zU=<4Xx7Ot4tM7iY;WfYdx^-U%g61%Q@t(jQ4vs3wDzQ%skRAg9k1B^IaQwX;_;0q| z3H`OPQ{%6nw$DtQJvVv&!qmk#-kh9x>(bl1_F3Pn+^wdP$A=;oX(_IUyY}gf$gEaG zvYv*AQFyeOho9%==nGO!^f=rIgU_CIZ5-Fg=G?OmHR#7_7$)1*Gz!-C_OdYFlrvOP z5y$Hyi}FY$TV2|%9W{F%9;_yNqR*6^C*+#eYSJ;g8KxP@+p*_|@mf+6c`gpNyfpQa zYFIknj3^4Zay3D@=2fDkI{p41ntoy0eMh%CT{d)@(^>`4->^Deg^k2J2&dh3GmiVI z@v`6wd;n$GfqT$`Z{R!l34VrO;0gSR!#IxT@iJb)A}->4=;A8gz-0y^ho=U0@byX3 z#o+swz~DloF+WcX7MEXidNd>hMPM)jdAf|!dDw}h4M6XJE=5oHdR(rVz$-yuSg&$Q z{s#DH@b~{$A{JgG6JP>=j{uHbFJCW_Z~OOA?=bSN?a*_F9$BPaOH1WKl{At4>N-xc z^AAI6J4WXk+0v3UR9^ar0Dk`~?p!eeCcp%k025#WOn?b60Vco%m;e)C0!)Aj{I>}_ E1(Dco`v3p{ literal 0 HcmV?d00001 diff --git a/application/controller/AdminPageController.php b/application/controller/AdminPageController.php index ce1923a..d580fa3 100644 --- a/application/controller/AdminPageController.php +++ b/application/controller/AdminPageController.php @@ -33,12 +33,15 @@ class AdminPageController extends Katharsis_Controller_Abstract $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(); } 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..e327650 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,37 @@ 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; + } + + $fullName = $dir . '/' . $name . $ext; + + if (!move_uploaded_file($file['tmp_name'], $fullName)) { - 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 $fullName; } } \ No newline at end of file diff --git a/application/view/AdminPage/uploadsuccess.phtml b/application/view/AdminPage/uploadsuccess.phtml new file mode 100644 index 0000000..f42e23e --- /dev/null +++ b/application/view/AdminPage/uploadsuccess.phtml @@ -0,0 +1,10 @@ +

Das Hochladen war erfolgreich.

+ + \ No newline at end of file diff --git a/library/DidgeridooArtwork/Controller/Plugin/Navigation.php b/library/DidgeridooArtwork/Controller/Plugin/Navigation.php index 1d685b7..1baaea4 100644 --- a/library/DidgeridooArtwork/Controller/Plugin/Navigation.php +++ b/library/DidgeridooArtwork/Controller/Plugin/Navigation.php @@ -4,7 +4,7 @@ class DidgeridooArtwork_Controller_Plugin_Navigation extends Katharsis_Controlle public function preController() { $view = Katharsis_View::getInstance(); - $sql = "SELECT id, name, controller, action, link FROM navigation WHERE parent_id IS NULL ORDER BY sorting"; + $sql = "SELECT id, name, controller, action, link FROM navigation WHERE parent_id IS NULL AND active = 1 ORDER BY sorting"; $view->mainNavigationItems = $this->_con->fetchAll($sql); $sql = "SELECT id, parent_id, controller, action FROM navigation WHERE (action = :action AND controller = :controller) OR (action IS NULL AND controller = :controller)"; diff --git a/library/Katharsis/Controller/Plugin/Autorender.php b/library/Katharsis/Controller/Plugin/Autorender.php index 4b72b9a..de70c8a 100644 --- a/library/Katharsis/Controller/Plugin/Autorender.php +++ b/library/Katharsis/Controller/Plugin/Autorender.php @@ -1,20 +1,19 @@ -stageContent = false; - - $templateName = ucfirst(Katharsis_Request::getControllerName()) . DIRECTORY_SEPARATOR . strtolower(Katharsis_Request::getActionName()); - - if(file_exists(getcwd() . '/application/view' . DIRECTORY_SEPARATOR . $templateName . '.phtml')) - { - $view->stageContent = $view->render($templateName); - } - - echo $view->render('main'); - } -} -?> \ No newline at end of file +stageContent = false; + + $templateName = ucfirst(Katharsis_Request::getControllerName()) . DIRECTORY_SEPARATOR . strtolower(Katharsis_Request::getActionName()); + + if(file_exists(getcwd() . '/application/view' . DIRECTORY_SEPARATOR . $templateName . '.phtml')) + { + $view->stageContent = $view->render($templateName); + } + + echo $view->render('main'); + } +} diff --git a/public/index.php b/public/index.php index 469fe40..de542d2 100644 --- a/public/index.php +++ b/public/index.php @@ -12,7 +12,6 @@ chdir('..'); require_once('library/Katharsis/Bootstrap.php'); Katharsis_Autoload::init(); - Katharsis_Controller_Plugin::registerPlugin(new DidgeridooArtwork_Controller_Plugin_SetNames()); Katharsis_Controller_Plugin::registerPlugin(new Katharsis_Controller_Plugin_StartSession()); Katharsis_Controller_Plugin::registerPlugin(new DidgeridooArtwork_Controller_Plugin_Notice()); @@ -22,7 +21,6 @@ Katharsis_Controller_Plugin::registerPlugin(new Katharsis_Controller_Plugin_Auto Katharsis_Controller_Plugin::registerPlugin(new DidgeridooArtwork_Controller_Plugin_Access()); Katharsis_Controller_Plugin::registerPlugin(new DidgeridooArtwork_Controller_Plugin_Navigation()); - try { Katharsis_Bootstrap::init(); Katharsis_Bootstrap::run();