예제 #1
0
 public function createAction()
 {
     $form = new Admin_Form_SlideshowCreate();
     $form->rendition->setMultiOptions($this->_helper->service('image.rendition')->getOptions());
     $request = $this->getRequest();
     $postParams = $request->getPost();
     $image = isset($postParams['image']) ? $postParams['image'] : null;
     $checkedImages = isset($postParams['checked-images']) ? $postParams['checked-images'] : array();
     if ($request->isPost() && $form->isValid($postParams)) {
         $values = $form->getValues();
         $values['rendition'] = $this->_helper->service('image.rendition')->getRendition($values['rendition']);
         $slideshow = $this->_helper->service('package')->save($values);
         if ($this->_getParam('article_number', false)) {
             $slideshows = $this->_helper->service('package')->findByArticle($this->_getParam('article_number'));
             $slideshows[] = $slideshow;
             $this->_helper->service('package')->saveArticle(array('id' => $this->_getParam('article_number'), 'slideshows' => array_map(function ($slideshow) {
                 return array('id' => $slideshow->getId());
             }, $slideshows)));
         }
         if (!empty($checkedImages)) {
             foreach ($checkedImages as $key => $value) {
                 $this->addItemToPackage($value, $slideshow);
             }
         }
         if (!is_null($image) && $image !== "") {
             $this->addItemToPackage(array_pop(explode('-', $image)), $slideshow);
         }
         $this->_helper->redirector('edit', 'slideshow', 'admin', array('article_number' => $this->_getParam('article_number'), 'slideshow' => $slideshow->getId()));
     }
     $this->view->form = $form;
     $this->view->images = $this->_helper->service('image')->findByArticle($this->_getParam('article_number'));
 }
예제 #2
0
 public function createAction()
 {
     $form = new Admin_Form_SlideshowCreate();
     $form->rendition->setMultiOptions($this->_helper->service('image.rendition')->getOptions());
     $request = $this->getRequest();
     if ($request->isPost() && $form->isValid($request->getPost())) {
         $values = $form->getValues();
         $values['rendition'] = $this->_helper->service('image.rendition')->getRendition($values['rendition']);
         $slideshow = $this->_helper->service('package')->save($values);
         if ($this->_getParam('article_number', false)) {
             $slideshows = $this->_helper->service('package')->findByArticle($this->_getParam('article_number'));
             $slideshows[] = $slideshow;
             $this->_helper->service('package')->saveArticle(array('id' => $this->_getParam('article_number'), 'slideshows' => array_map(function ($slideshow) {
                 return array('id' => $slideshow->getId());
             }, $slideshows)));
         }
         $this->_helper->redirector('edit', 'slideshow', 'admin', array('article_number' => $this->_getParam('article_number'), 'slideshow' => $slideshow->getId()));
     }
     $this->view->form = $form;
 }