Example #1
0
 function deleteAction()
 {
     $this->view->title = "Suppression d'une image";
     //if ($this->view->aclIsAllowed('gallery','manage',true)){
     $this->view->assign('isXmlHttpRequest', $this->_isXmlHttpRequest);
     $this->view->assign('success', false);
     $pageID = (int) $this->_getParam('pageID');
     $blockID = (int) $this->_getParam('blockID');
     $galleryID = (int) $this->_getParam('galleryID');
     $imageID = (int) $this->_getParam('imageID');
     $imageIndexSelect = new ImagesIndex();
     $select = $imageIndexSelect->select()->where('II_ImageID = ?', $imageID);
     $imageIndexData = $imageIndexSelect->fetchRow($select);
     if (!$imageIndexData) {
         if ($this->_request->isPost()) {
             $this->view->assign('success', true);
         }
         $this->view->assign('deleted', true);
         $this->view->assign('imageID', $imageID);
     } else {
         $imageObject = new ImageObject();
         $imageIndexData = $imageObject->populate($imageID, Zend_Registry::get("languageID"));
         //$imageIndexData = $imageObject->populate($imageID,$this->_defaultEditLanguage);
         $this->view->assign('deleted', false);
         $return = "/gallery/index/list/blockID/{$blockID}/pageID/{$pageID}";
         $this->view->return = $this->view->baseUrl() . $return;
         $this->view->image = $imageIndexData;
         if ($this->_request->isPost()) {
             //$del = $this->_request->getPost('delete');
             //if ($del && $imageIndexData) {
             if ($imageIndexData) {
                 $imageSelect = new ImagesIndex();
                 $select = $imageSelect->select()->where('II_ImageID = ?', $imageID);
                 $imageData = $imageSelect->fetchAll($select)->toArray();
                 $cpt = count($imageData);
                 for ($i = 0; $i < $cpt; $i++) {
                     $indexData['moduleID'] = $this->_moduleID;
                     $indexData['contentID'] = $imageData[$i]['II_ImageID'];
                     $indexData['languageID'] = $imageData[$i]['II_LanguageID'];
                     $indexData['action'] = 'delete';
                     Cible_FunctionsIndexation::indexation($indexData);
                 }
                 $imageObject->delete($imageID);
                 $galleryImageDelete = new GalleriesImages();
                 $where = 'GI_GalleryID = ' . $galleryID . " and GI_ImageID = " . $imageID;
                 $galleryImageDelete->delete($where);
                 //delete the gallery folder
                 Cible_FunctionsGeneral::delFolder("../../{$this->_config->document_root}/data/images/gallery/" . $galleryID . "/" . $imageID);
                 if (!$this->_isXmlHttpRequest) {
                     $this->_redirect("/gallery/index/list/blockID/{$blockID}/pageID/{$pageID}");
                 } else {
                     $this->view->assign('success', true);
                     $this->view->assign('imageID', $imageID);
                 }
             }
             //$this->_redirect($return);
         }
     }
     //}
 }