Esempio n. 1
0
 public function detailsAction()
 {
     $numberOfImagesPerPage = 5;
     $numberOfImagesPerColumn = 4;
     $gallery = new GalleryObject();
     $blockID = $this->_getParam('BlockID');
     $blockParameters = Cible_FunctionsBlocks::getBlockParameters($blockID);
     $regularDetailsShow = true;
     if (isset($blockParameters[1]['P_Value'])) {
         if ($blockParameters[1]['P_Number'] != 999) {
             if ($blockParameters[1]['P_Value'] != 0) {
                 $regularDetailsShow = false;
             }
         }
     }
     /*if(!empty($_SERVER['HTTP_REFERER'])){
           $this->view->assign('pagePrecedente', $_SERVER['HTTP_REFERER']);
       }
       else{
            $this->view->assign('pagePrecedente','');
       }*/
     //$this->view->assign('pagePrecedente','');
     $listall_page = Cible_FunctionsCategories::getPagePerCategoryView(9001, 'list');
     $this->view->assign('listall_page_gallery', $listall_page);
     if ($regularDetailsShow == false) {
         $id = 0;
         $idGallery = $blockParameters[1]['P_Value'];
         $titleUrl = Cible_FunctionsGeneral::getTitleFromPath($this->_request->getPathInfo(), true);
         $baseDir = $this->view->baseUrl();
         $config = Zend_Registry::get('config')->toArray();
         $imageId = $idGallery;
         // $this->view->headLink()->appendStylesheet($baseDir . '/themes/default/css/prettyPhoto.css', 'screen');
         $galleryID = $idGallery;
         $db = Zend_Registry::get('db');
         $gallerySelect = new GalleriesIndex();
         $select = $db->select()->distinct()->from('GalleriesIndex')->joinRight('Galleries', 'GI_GalleryID = G_ID AND GI_LanguageID = ' . Zend_Registry::get("languageID"))->where('GI_GalleryID = ?', $galleryID);
         $galleryData = $db->fetchRow($select);
         //var_dump($galleryData);
         if (count($galleryData) > 0) {
             $this->view->headTitle($galleryData['GI_Title']);
             $originalMaxHeight = $config['gallery']['image']['original']['maxHeight'];
             $originalMaxWidth = $config['gallery']['image']['original']['maxWidth'];
             $thumbMaxHeight = $config['gallery']['image']['thumb']['maxHeight'];
             $thumbMaxWidth = $config['gallery']['image']['thumb']['maxWidth'];
             $imagesSelect = new GalleriesImages();
             $select = $imagesSelect->select()->setIntegrityCheck(false)->from('Galleries_Images')->join('Images', 'I_ID = GI_ImageID')->joinLeft('ImagesIndex', 'II_ImageID = I_ID AND II_LanguageID = ' . Zend_Registry::get("languageID"))->where('GI_GalleryID = ?', $galleryID)->where('GI_Online = 1')->order('GI_Position');
             $imagesData = $imagesSelect->fetchAll($select)->toArray();
             $i = 0;
             foreach ($imagesData as $image) {
                 $imagesData[$i]['thumbName'] = str_replace($image['I_OriginalLink'], $thumbMaxWidth . 'x' . $thumbMaxHeight . '_' . $image['I_OriginalLink'], $image['I_OriginalLink']);
                 $imagesData[$i]['originalName'] = str_replace($image['I_OriginalLink'], $originalMaxWidth . 'x' . $originalMaxHeight . '_' . $image['I_OriginalLink'], $image['I_OriginalLink']);
                 $i++;
             }
             $this->view->assign('galleryData', $galleryData);
             $this->view->assign('imagesData', $imagesData);
             $paginator = new Zend_Paginator(new Zend_Paginator_Adapter_Array($imagesData));
             $paginator->setItemCountPerPage($numberOfImagesPerPage);
             $pageNum = $this->_request->getParam('page');
             if ($pageNum == "") {
                 $pageNum = Cible_FunctionsGeneral::getPageNumberWithoutParamOrder($this->_request->getPathInfo());
             }
             //var_dump($paginator);
             $paginator->setCurrentPageNumber($pageNum);
             $this->view->assign('paginator', $paginator);
             $this->view->assign('numberItemPerColumn', $numberOfImagesPerColumn);
         }
     } else {
         $id = 0;
         $idGallery = 0;
         $titleUrl = Cible_FunctionsGeneral::getTitleFromPath($this->_request->getPathInfo(), true);
         if ($titleUrl != "") {
             $idGallery = $gallery->getIdByName($titleUrl);
         }
         $baseDir = $this->view->baseUrl();
         $config = Zend_Registry::get('config')->toArray();
         $imageId = $idGallery;
         // $this->view->headLink()->appendStylesheet($baseDir . '/themes/default/css/prettyPhoto.css', 'screen');
         $galleryID = $idGallery;
         $db = Zend_Registry::get('db');
         $gallerySelect = new GalleriesIndex();
         $select = $db->select()->distinct()->from('GalleriesIndex')->joinRight('Galleries', 'GI_GalleryID = G_ID AND GI_LanguageID = ' . Zend_Registry::get("languageID"))->where('GI_GalleryID = ?', $galleryID);
         $galleryData = $db->fetchRow($select);
         //echo $select;
         //var_dump($galleryData);
         if (count($galleryData) > 0) {
             $this->view->headTitle($galleryData['GI_Title']);
             $originalMaxHeight = $config['gallery']['image']['original']['maxHeight'];
             $originalMaxWidth = $config['gallery']['image']['original']['maxWidth'];
             $thumbMaxHeight = $config['gallery']['image']['thumb']['maxHeight'];
             $thumbMaxWidth = $config['gallery']['image']['thumb']['maxWidth'];
             $imagesSelect = new GalleriesImages();
             $select = $imagesSelect->select()->setIntegrityCheck(false)->from('Galleries_Images')->join('Images', 'I_ID = GI_ImageID')->joinLeft('ImagesIndex', 'II_ImageID = I_ID AND II_LanguageID = ' . Zend_Registry::get("languageID"))->where('GI_GalleryID = ?', $galleryID)->where('GI_Online = 1')->order('GI_Position');
             $imagesData = $imagesSelect->fetchAll($select)->toArray();
             $i = 0;
             foreach ($imagesData as $image) {
                 $imagesData[$i]['thumbName'] = str_replace($image['I_OriginalLink'], $thumbMaxWidth . 'x' . $thumbMaxHeight . '_' . $image['I_OriginalLink'], $image['I_OriginalLink']);
                 $imagesData[$i]['originalName'] = str_replace($image['I_OriginalLink'], $originalMaxWidth . 'x' . $originalMaxHeight . '_' . $image['I_OriginalLink'], $image['I_OriginalLink']);
                 $i++;
             }
             $this->view->assign('galleryData', $galleryData);
             $this->view->assign('imagesData', $imagesData);
             $paginator = new Zend_Paginator(new Zend_Paginator_Adapter_Array($imagesData));
             $paginator->setItemCountPerPage($numberOfImagesPerPage);
             $pageNum = $this->_request->getParam('page');
             if ($pageNum == "") {
                 $pageNum = Cible_FunctionsGeneral::getPageNumberWithoutParamOrder($this->_request->getPathInfo());
             }
             //var_dump($paginator);
             $paginator->setCurrentPageNumber($pageNum);
             $this->view->assign('paginator', $paginator);
             $this->view->assign('numberItemPerColumn', $numberOfImagesPerColumn);
         }
     }
 }
Esempio n. 2
0
 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);
                 }
             }
         }
     }
     //}
 }
Esempio n. 3
0
 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);
         }
     }
     //}
 }