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;
 }
 public function editAction()
 {
     $form = new Show_Form();
     $mdlShow = new Slideshow_Show();
     if ($this->_request->isPost() && $form->isValid($_POST) && $this->_request->getParam('isInsert') != true) {
         $values = $form->getValues();
         $results = $mdlShow->updateShow($values['id'], $values['name'], $values['description']);
         $show = $results->page;
     } else {
         $id = $this->_request->getParam('id');
         $show = $mdlShow->find($id)->current();
         $form->populate($show->toArray());
     }
     $form->setAction($this->baseUrl . '/mod_slideshow/show/edit');
     $submit = $form->getElement('submit');
     $submit->setLabel($this->view->getTranslation('Update Slideshow'));
     $this->view->form = $form;
     $this->view->show = $show;
     $mdlSlide = new Slideshow_Slide();
     $this->view->slides = $mdlSlide->getSlides($show->id);
     $slideForm = new Slide_Form();
     $slideForm->removeElement('image');
     $slideForm->removeElement('imagepath');
     $slideForm->removeElement('previewpath');
     $slideForm->removeElement('image_preview');
     $slideForm->removeElement('caption');
     $slideFormValues['show_id'] = $show->id;
     $slideForm->populate($slideFormValues);
     $slideForm->setAction($this->baseUrl . '/mod_slideshow/slide/create');
     $submit = $slideForm->getElement('submit');
     $submit->setLabel($this->view->getTranslation('Add New Slide'));
     $this->view->slideForm = $slideForm;
     $this->view->breadcrumbs[$show->name] = $this->baseUrl . '/mod_slideshow/show/edit/id/' . $show->id;
     $this->view->toolbarLinks['Add to my bookmarks'] = $this->baseUrl . '/admin/index/bookmark/url/mod_slideshow/show/edit/id/' . $show->id;
     $this->view->toolbarLinks['Delete'] = $this->baseUrl . '/mod_slideshow/show/delete/id/' . $show->id;
 }