コード例 #1
0
ファイル: IndexController.php プロジェクト: anunay/stentors
 public function deleteAction()
 {
     // web page title
     $this->view->title = "Suppression d'une galerie";
     //if ($this->view->aclIsAllowed('gallery','manage',true)){
     // variables
     $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');
     if ($blockID != '') {
         $return = "/gallery/index/list/blockID/{$blockID}/pageID/{$pageID}";
     } elseif ($this->_categoryID) {
         $return = "/gallery/index/list/catID/{$this->_categoryID}";
     } else {
         $return = "/gallery/index/list/";
     }
     $this->view->return = $this->view->baseUrl() . $return;
     $galleryObject = new GalleryObject();
     $galleryDataIndex = $galleryObject->populate($galleryID, $this->_defaultEditLanguage);
     if (!$galleryDataIndex) {
         if ($this->_request->isPost()) {
             $this->view->assign('success', true);
         }
         $this->view->assign('deleted', true);
         $this->view->assign('galleryID', $galleryID);
     } else {
         $this->view->assign('deleted', false);
         $this->view->gallery = $galleryDataIndex;
         if ($this->_request->isPost()) {
             $formData = $this->_request->getPost();
             if ($galleryDataIndex) {
                 $gallerySelect = new GalleriesIndex();
                 $select = $gallerySelect->select()->where('GI_GalleryID = ?', $galleryID);
                 $galleryData = $gallerySelect->fetchAll($select);
                 foreach ($galleryData as $gallery) {
                     $indexData['moduleID'] = $this->_moduleID;
                     $indexData['contentID'] = $galleryID;
                     $indexData['languageID'] = $gallery['GI_LanguageID'];
                     $indexData['action'] = 'delete';
                     Cible_FunctionsIndexation::indexation($indexData);
                     $imageSelect = new GalleriesImages();
                     $select = $imageSelect->select()->setIntegrityCheck(false)->from('Galleries_Images')->where('GI_GalleryID = ?', $galleryID)->join('ImagesIndex', 'II_ImageID = GI_ImageID')->where('II_LanguageID = ?', $gallery['GI_LanguageID']);
                     $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);
                     }
                 }
                 //delete all images associated with the gallery
                 $galleryImagesSelect = new GalleriesImages();
                 $select = $galleryImagesSelect->select()->where('GI_GalleryID = ?', $galleryID);
                 $galleryImagesData = $galleryImagesSelect->fetchAll($select);
                 foreach ($galleryImagesData as $galleryImages) {
                     $imageDelete = new Images();
                     $where = "I_ID = " . $galleryImages['GI_ImageID'];
                     $imageDelete->delete($where);
                     $imageIndexDelete = new ImagesIndex();
                     $where = "II_ImageID = " . $galleryImages['GI_ImageID'];
                     $imageIndexDelete->delete($where);
                 }
                 $galleryImagesDelete = new GalleriesImages();
                 $where = "GI_GalleryID = " . $galleryID;
                 $galleryImagesDelete->delete($where);
                 $galleryObject->delete($galleryID);
                 /*
                  //delete the gallery
                  $galleryDelete = new Galleries();
                  $where = 'G_ID = ' .  $galleryID;
                  $galleryDelete->delete($where);
                 
                  $galleryIndexDelete = new GalleriesIndex();
                  $where = 'GI_GalleryID = ' .  $galleryID;
                  $galleryIndexDelete->delete($where);
                 */
                 //delete the gallery folder
                 Cible_FunctionsGeneral::delFolder("../../{$this->_config->document_root}/data/images/gallery/" . $galleryID);
                 if (!$this->_isXmlHttpRequest) {
                     if ($blockID != '') {
                         $this->_redirect("/gallery/index/list/blockID/{$blockID}/pageID/{$pageID}");
                     } elseif ($this->_categoryID) {
                         $this->_redirect("/gallery/index/list/catID/{$this->_categoryID}");
                     } else {
                         $this->_redirect("/gallery/index/list/");
                     }
                 } else {
                     $buttonAction = $formData['buttonAction'];
                     $this->view->assign('success', true);
                     $this->view->assign('buttonAction', $buttonAction);
                     $this->view->assign('galleryID', $galleryID);
                     $this->view->assign('deleted', true);
                 }
             }
         }
     }
     //}
 }
コード例 #2
0
ファイル: ImageController.php プロジェクト: anunay/stentors
 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);
         }
     }
     //}
 }