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); } } } } //} }
function addAction() { $this->view->title = "Ajout d'une image à une galerie"; //if ($this->view->aclIsAllowed('gallery','manage',true)){ $this->view->assign('isXmlHttpRequest', $this->_isXmlHttpRequest); $this->view->assign('success', false); $pageID = $this->_getParam('pageID'); $blockID = $this->_getParam('blockID'); $galleryID = $this->_getParam('galleryID'); $baseDir = $this->view->baseUrl(); $galleryObject = new GalleryObject(); $galleryData = $galleryObject->populate($galleryID, Zend_Registry::get("languageID")); if ($this->_request->isPost()) { $formData = $this->_request->getPost(); if ($formData['ImageSrc'] != '') { $imageSrc = Zend_Registry::get("www_root") . "/data/images/gallery/{$galleryID}/tmp/mcith/mcith_" . $formData['ImageSrc']; } else { $imageSrc = $this->view->baseUrl() . "/icons/image_non_ disponible.jpg"; } } else { $imageSrc = $this->view->baseUrl() . "/icons/image_non_ disponible.jpg"; } if (!$galleryData) { 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); $cancelUrl = "/gallery/index/list/blockID/{$blockID}/pageID/{$pageID}"; $form = new FormImage(array('baseDir' => $baseDir, 'cancelUrl' => "", 'galleryID' => $galleryID, 'imageID' => 0, 'addAction' => true)); $this->view->form = $form; if ($this->_request->isPost()) { $formData = $this->_request->getPost(); if ($form->isValid($formData)) { if ($form->getValue('ImageSrc') == "") { $form->getElement('ImageSrc')->addError('Vous devez choisir une image'); } else { $imageObject = new ImageObject(); //$this->view->dump($formData); die(); $imageID = $imageObject->insert($formData, $this->_config->defaultEditLanguage); $galleryImage = new GalleriesImages(); $galleryImageData = $galleryImage->createRow(); $galleryImageData->GI_GalleryID = $galleryID; $galleryImageData->GI_ImageID = $imageID; $galleryImageData->GI_Online = $form->getValue('GI_Online'); $galleryImageData->GI_Position = $form->getValue('GI_Position'); //$galleryImageData->GI_LinkOriginal = $form->getValue('ImageSrc'); $galleryImageData->save(); $config = Zend_Registry::get('config')->toArray(); $srcOriginal = "../../{$this->_config->document_root}/data/images/gallery/" . $galleryID . "/tmp/" . $form->getValue('ImageSrc'); $originalMaxHeight = $config['gallery']['image']['original']['maxHeight']; $originalMaxWidth = $config['gallery']['image']['original']['maxWidth']; $originalName = str_replace($form->getValue('ImageSrc'), $originalMaxWidth . 'x' . $originalMaxHeight . '_' . $form->getValue('ImageSrc'), $form->getValue('ImageSrc')); $srcThumb = "../../{$this->_config->document_root}/data/images/gallery/" . $galleryID . "/tmp/mcith/mcith_" . $form->getValue('ImageSrc'); $thumbMaxHeight = $config['gallery']['image']['thumb']['maxHeight']; $thumbMaxWidth = $config['gallery']['image']['thumb']['maxWidth']; $thumbName = str_replace($form->getValue('ImageSrc'), $thumbMaxWidth . 'x' . $thumbMaxHeight . '_' . $form->getValue('ImageSrc'), $form->getValue('ImageSrc')); Cible_FunctionsImageResampler::resampled(array('src' => $srcOriginal, 'maxWidth' => $originalMaxWidth, 'maxHeight' => $originalMaxHeight)); Cible_FunctionsImageResampler::resampled(array('src' => $srcThumb, 'maxWidth' => $thumbMaxWidth, 'maxHeight' => $thumbMaxHeight)); // Attempts to create the directory specified by pathname. mkdir("../../{$this->_config->document_root}/data/images/gallery/" . $galleryID . "/" . $imageID) or die("Could not make directory"); // Rename and move the original image to the specific place rename("../../{$this->_config->document_root}/data/images/gallery/" . $galleryID . "/tmp/" . $form->getValue('ImageSrc'), "../../{$this->_config->document_root}/data/images/gallery/" . $galleryID . "/" . $imageID . "/" . $originalName); // Rename and move the thumbnail image to the specific place rename("../../{$this->_config->document_root}/data/images/gallery/" . $galleryID . "/tmp/mcith/mcith_" . $form->getValue('ImageSrc'), "../../{$this->_config->document_root}/data/images/gallery/" . $galleryID . "/" . $imageID . "/" . $thumbName); if ($formData['GI_Online'] == 1 && $galleryData['G_Online'] == 1 && $blockID > 0) { $blockParameters = Cible_FunctionsBlocks::getBlockParameters($blockID); $categoryID = $blockParameters[0]['P_Value']; $indexData['pageID'] = $categoryID; $indexData['moduleID'] = $this->_moduleID; $indexData['contentID'] = $galleryID; $indexData['languageID'] = Zend_Registry::get("currentEditLanguage"); $indexData['title'] = $formData['II_Title']; $indexData['text'] = ''; $indexData['link'] = 'image'; $indexData['contents'] = $formData['II_Title'] . " " . $formData['II_Description']; $indexData['action'] = 'add'; Cible_FunctionsIndexation::indexation($indexData); } if (!$this->_isXmlHttpRequest) { //$this->_redirect('/'); $this->_redirect("/gallery/index/list/blockID/{$blockID}/pageID/{$pageID}"); } else { $buttonAction = $formData['buttonAction']; $this->view->assign('buttonAction', $buttonAction); $this->view->assign('success', true); $this->view->assign('galleryID', $galleryID); $this->view->assign('imageID', $imageID); $this->view->assign('orginalName', $originalName); $this->view->assign('thumbName', $thumbName); $this->view->assign('imageTitle', $form->getValue('II_Title')); } } } else { $form->populate($formData); $form->getElement('ImageSrc_preview')->setAttrib('src', $imageSrc); } } else { $form->getElement('ImageSrc_preview')->setAttrib('src', $imageSrc); } } //} }