diff --git a/application/controller/AdminPageController.php b/application/controller/AdminPageController.php index 602bb00..ce1923a 100644 --- a/application/controller/AdminPageController.php +++ b/application/controller/AdminPageController.php @@ -20,12 +20,23 @@ class AdminPageController extends Katharsis_Controller_Abstract public function imageAction() { + if($this->_getParam('type') == 'header') { + $type = 'header'; + } else { + $type = 'page'; + } + + $path = getcwd().'/img/' . $type . '/'; if(isset($_FILES['myfile'])) { $upload = new Upload(); - - $upload->page($_FILES['myfile']); + + if($type == 'header') { + $upload->header($_FILES['myfile']); + } else { + $upload->page($_FILES['myfile']); + } echo 'Das Hochladen war erfolgreich.

'; } @@ -33,25 +44,25 @@ class AdminPageController extends Katharsis_Controller_Abstract if(isset($_GET['delete'])) { - $deleteFile = getcwd() . '/img/page/' . $_GET['delete']; + $deleteFile = $path . $_GET['delete']; if(file_exists($deleteFile)) { unlink($deleteFile); } } - - if ($handle = opendir(getcwd().'/img/page/')) + $ar = array(); + if (is_readable($path) && $handle = opendir()) { - $ar = array(); while (false !== ($file = readdir($handle))) { if(is_dir($file)) continue; $ar[] = $file; } - $this->_view->files = $ar; + closedir($handle); } - + $this->_view->files = $ar; echo $this->_view->render('AdminPage/image'); + die(); } diff --git a/application/controller/AdminUploadController.php b/application/controller/AdminUploadController.php index 8cc249c..11bd305 100644 --- a/application/controller/AdminUploadController.php +++ b/application/controller/AdminUploadController.php @@ -1,16 +1,5 @@ header($this->_getParam('pageId'), $_FILES); - - DidgeridooArtwork_Notice::add('Das Hochladen war erfolgreich. Dateiname: ' . $filename); - } + // check adminPageController and Upload model } \ No newline at end of file diff --git a/application/controller/PageController.php b/application/controller/PageController.php index a2ef433..da09432 100644 --- a/application/controller/PageController.php +++ b/application/controller/PageController.php @@ -15,11 +15,23 @@ class PageController extends Katharsis_Controller_Abstract { $preview = true; } - $method = substr($method, 0, -6); - $content = $this->_page->render($method, $preview); + $url = substr($method, 0, -6); - $content = DidgeridooArtwork_Page_Plugin::render($content); + $pageId = $this->_page->getIdByUrl($url); + + if(!$pageId) { + throw new DidgeridooArtwork_Exception('Page konnte nicht geladen werden.'); + } + + $pageData = $this->_page->getPage($pageId); + foreach($pageData as $key => $value) { + $this->_view->{$key} = $value; + } + + $this->_view->content = DidgeridooArtwork_Page_Plugin::render($this->_view->content); + + $content = $this->_view->render('page/post'); $this->_view->stageContent = $content; echo $this->_view->render('main'); die(); diff --git a/application/model/Page.php b/application/model/Page.php index ed590a2..4aa375d 100644 --- a/application/model/Page.php +++ b/application/model/Page.php @@ -5,21 +5,18 @@ class Page extends Katharsis_Model_Abstract { } - public function render($url, $preview) + public function getIdByUrl($url, $preview = false) { $activeTerm = ''; if(!$preview) { $activeTerm = 'AND active = 1'; } - $sql = $this->_con->createStatement("SELECT * FROM page WHERE url = :url " . $activeTerm, array("url" => $url)); - if($result = $this->_con->fetchOne($sql)) - { - return $result['content']; - } - else - { - throw new DidgeridooArtwork_Exception('Die von Ihnen angeforderte Seite (Page) "' . $url . '" konnte nicht gefunden werden.'); + + $sql = $this->_con->createStatement("SELECT id FROM page WHERE url = :url " . $activeTerm, array("url" => $url)); + + if($result = $this->_con->fetchOne($sql)){ + return $result['id']; } } diff --git a/application/model/Upload.php b/application/model/Upload.php index 03a1f31..2b1091e 100644 --- a/application/model/Upload.php +++ b/application/model/Upload.php @@ -6,10 +6,10 @@ class Upload extends Katharsis_Model_Abstract } - public function header($id, $file) + public function header($file) { $dir = getcwd() . '/img/header'; - return $this->_uploadFile($id, $file, $dir); + return $this->_uploadFile(null, $file, $dir); } public function page($file) @@ -33,7 +33,9 @@ class Upload extends Katharsis_Model_Abstract } $handle = new Verot_Upload($file); + return; $handle->file_new_name_body = $name; + if ($handle->uploaded) { $handle->Process($dir); diff --git a/application/view/AdminPage/edit.phtml b/application/view/AdminPage/edit.phtml index 4efd068..3dcef7e 100644 --- a/application/view/AdminPage/edit.phtml +++ b/application/view/AdminPage/edit.phtml @@ -79,8 +79,8 @@
Header Bild
- - Auswählen | Hochladen + + Auswählen
diff --git a/application/view/AdminPage/image.phtml b/application/view/AdminPage/image.phtml index 3aa028a..29efa22 100644 --- a/application/view/AdminPage/image.phtml +++ b/application/view/AdminPage/image.phtml @@ -10,7 +10,7 @@

Bild Hochladen

- +

Bild Auswählen

diff --git a/application/view/Page/post.phtml b/application/view/Page/post.phtml new file mode 100644 index 0000000..7910bdd --- /dev/null +++ b/application/view/Page/post.phtml @@ -0,0 +1,3 @@ +this is my site + +Title (title; ?>) \ No newline at end of file