public function editAction() { $form = new Slide_Form(); $mdlShow = new Slideshow_Show(); $mdlSlide = new Slideshow_Slide(); // generate path to save file to $id = $this->_request->getParam('id'); $properties = Digitalus_Module_Property::load('mod_slideshow'); $config = Zend_Registry::get('config'); $path = $config->filepath->media; $directory = $path . '/' . $properties->mediaFolder . '/' . $mdlSlide->getShowBySlide($id); $directoryFull = $directory . '/full'; $directoryPreview = $directory . '/preview'; // create and set file's destination directory Digitalus_Filesystem_dir::makeRecursive(BASE_PATH, $directoryFull); Digitalus_Filesystem_dir::makeRecursive(BASE_PATH, $directoryPreview); $form->image->setDestination($directoryFull); $form->image_preview->setDestination($directoryPreview); if ($this->_request->isPost() && $this->_request->getParam('isInsert') != true) { $formData = $this->_request->getPost(); if ($form->isValid($formData)) { // success - do something with the uploaded file $values = $form->getValues(); $imagePath = $form->image->getFileName(); $previewPath = $form->image_preview->getFileName(); // some servers set different permissions, so set them explicitly here if (!empty($imagePath)) { chmod($imagePath, 0644); } if (!empty($previewPath)) { chmod($previewPath, 0644); } // replace windows path separator $previewPath = str_replace("\\", PATH_SEPARATOR, $previewPath); $imagePath = str_replace("\\", PATH_SEPARATOR, $imagePath); $slide = $mdlSlide->updateSlide($values['id'], $values['title'], $values['caption'], $previewPath, $imagePath); $slide = $mdlSlide->openSlide($values['id']); } } $slide = $mdlSlide->openSlide($id); $slideArray['id'] = $slide->id; $slideArray['blog_id'] = $slide->showId; $slideArray['title'] = $slide->title; $slideArray['previewpath'] = $slide->previewPath; $slideArray['imagepath'] = $slide->imagePath; $slideArray['caption'] = $slide->caption; $form->setAction($this->baseUrl . '/mod_slideshow/slide/edit')->populate($slideArray); $show = $mdlShow->find($slide->showId)->current(); $submit = $form->getElement('submit'); $submit->setLabel($this->view->getTranslation('Update Slide')); $this->view->form = $form; $this->view->show = $show; $this->view->slide = $slide; $this->view->breadcrumbs[$show->name] = $this->baseUrl . '/mod_slideshow/show/edit/id/' . $show->id; $this->view->breadcrumbs[$slide->title] = $this->baseUrl . '/mod_slideshow/slide/edit/id/' . $slide->id; $this->view->toolbarLinks['Add to my bookmarks'] = $this->baseUrl . '/admin/index/bookmark/url/mod_slideshow/slide/edit/id/' . $slide->id; $this->view->toolbarLinks['Delete'] = $this->baseUrl . '/mod_slideshow/slide/delete/id/' . $slide->id; }