public function editAction()
 {
     // web page title
     $this->view->title = "Édition d'une sous-catégorie";
     // variables
     $recordID = $this->_getParam($this->_paramId);
     $returnAction = $this->_getParam('return');
     $baseDir = $this->view->baseUrl();
     $lang = $this->_getParam('lang');
     if (!$lang) {
         $this->_registry->currentEditLanguage = $this->_defaultEditLanguage;
     }
     $langId = $this->_registry->currentEditLanguage;
     if ($this->view->aclIsAllowed($this->_moduleTitle, 'edit', true)) {
         $cancelUrl = $baseDir . "/" . $this->_moduleTitle . "/" . $this->_name . "/" . $this->_defaultAction . "/";
         if ($returnAction) {
             $returnUrl = $this->_moduleTitle . "/" . $this->_name . "/" . $returnAction;
         } else {
             $returnUrl = $this->_moduleTitle . "/" . $this->_name . "/" . $this->_defaultAction . "/";
         }
         // get event details
         $oSubCategories = new SubCategoriesObject();
         $data = $oSubCategories->populate($recordID, $langId);
         // image src.
         $config = Zend_Registry::get('config')->toArray();
         $imageSrc = "";
         // generate the form
         $form = new FormSubCategories(array('moduleName' => $this->_moduleTitle . '/' . $this->_name, 'baseDir' => $baseDir, 'cancelUrl' => $cancelUrl, 'imageSrc' => $imageSrc, 'imgField' => $this->_imageSrc, 'dataId' => $recordID, 'isNewImage' => true));
         $this->view->form = $form;
         // action
         if (!$this->_request->isPost()) {
             $form->populate($data);
         } else {
             $formData = $this->_request->getPost();
             if ($form->isValid($formData)) {
                 $formattedName = Cible_FunctionsGeneral::formatValueForUrl($formData['SCI_Name']);
                 $formData['SCI_ValUrl'] = $formattedName;
                 if ($formData['isNewImage'] == 'true' && $form->getValue($this->_imageSrc) != '') {
                     $config = Zend_Registry::get('config')->toArray();
                     $srcOriginal = $this->_imageFolder . $recordID . "/tmp/" . $form->getValue($this->_imageSrc);
                     $originalMaxHeight = $config[$this->_moduleTitle]['image']['original']['maxHeight'];
                     $originalMaxWidth = $config[$this->_moduleTitle]['image']['original']['maxWidth'];
                     $originalName = str_replace($form->getValue($this->_imageSrc), $originalMaxWidth . 'x' . $originalMaxHeight . '_' . $form->getValue($this->_imageSrc), $form->getValue($this->_imageSrc));
                     $srcMedium = $this->_imageFolder . $recordID . "/tmp/medium_" . $form->getValue($this->_imageSrc);
                     $mediumMaxHeight = $config[$this->_moduleTitle]['image']['medium']['maxHeight'];
                     $mediumMaxWidth = $config[$this->_moduleTitle]['image']['medium']['maxWidth'];
                     if ($mediumMaxHeight > 0 && $mediumMaxWidth > 0) {
                         $mediumName = str_replace($form->getValue($this->_imageSrc), $mediumMaxWidth . 'x' . $mediumMaxHeight . '_' . $form->getValue($this->_imageSrc), $form->getValue($this->_imageSrc));
                         copy($srcOriginal, $srcMedium);
                     }
                     $srcThumb = $this->_imageFolder . $recordID . "/tmp/thumb_" . $form->getValue($this->_imageSrc);
                     $thumbMaxHeight = $config[$this->_moduleTitle]['image']['thumb']['maxHeight'];
                     $thumbMaxWidth = $config[$this->_moduleTitle]['image']['thumb']['maxWidth'];
                     $thumbName = str_replace($form->getValue($this->_imageSrc), $thumbMaxWidth . 'x' . $thumbMaxHeight . '_' . $form->getValue($this->_imageSrc), $form->getValue($this->_imageSrc));
                     copy($srcOriginal, $srcThumb);
                     Cible_FunctionsImageResampler::resampled(array('src' => $srcOriginal, 'maxWidth' => $originalMaxWidth, 'maxHeight' => $originalMaxHeight));
                     Cible_FunctionsImageResampler::resampled(array('src' => $srcThumb, 'maxWidth' => $thumbMaxWidth, 'maxHeight' => $thumbMaxHeight));
                     if ($mediumMaxHeight > 0 && $mediumMaxWidth > 0) {
                         Cible_FunctionsImageResampler::resampled(array('src' => $srcMedium, 'maxWidth' => $mediumMaxWidth, 'maxHeight' => $mediumMaxHeight));
                         rename($srcMedium, $this->_imageFolder . $recordID . "/" . $mediumName);
                     }
                     rename($srcOriginal, $this->_imageFolder . $recordID . "/" . $originalName);
                     rename($srcThumb, $this->_imageFolder . $recordID . "/" . $thumbName);
                 }
                 $oSubCategories->save($recordID, $formData, $langId);
                 // redirect
                 if (!empty($pageID)) {
                     $this->_redirect($this->_moduleTitle . "/" . $this->_name . "/" . $this->_defaultAction . "/blockID/{$blockID}/pageID/{$pageID}");
                 } else {
                     $this->_redirect($returnUrl);
                 }
             }
         }
     }
 }
Beispiel #2
0
 public function editAction()
 {
     $this->view->title = "Modification d'une galerie";
     //if ($this->view->aclIsAllowed('gallery','manage',true)){
     // variables
     $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("currentEditLanguage"));
     $imageObject = new ImageObject();
     $imageData = $imageObject->populate($galleryData['G_ImageID'], Zend_Registry::get("currentEditLanguage"));
     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);
         $config = Zend_Registry::get('config')->toArray();
         $thumbMaxHeight = $config['gallery']['image']['thumb']['maxHeight'];
         $thumbMaxWidth = $config['gallery']['image']['thumb']['maxWidth'];
         $thumbName = str_replace($imageData['ImageSrc'], $thumbMaxWidth . 'x' . $thumbMaxHeight . '_' . $imageData['ImageSrc'], $imageData['ImageSrc']);
         if ($this->_request->isPost()) {
             $formData = $this->_request->getPost();
             $isNewImage = $formData['isNewImage'];
             if ($isNewImage == 'true') {
                 $imageSrc = Zend_Registry::get("www_root") . "/data/images/gallery/" . $galleryID . "/tmp/mcith/mcith_" . $formData['ImageSrc'];
             } else {
                 $imageSrc = Zend_Registry::get("www_root") . "/data/images/gallery/{$galleryID}/" . $galleryData['G_ImageID'] . "/" . $thumbName;
             }
         } else {
             //$imageData['ImageSrc_preview'] = Zend_Registry::get("www_root")."/data/images/gallery/$galleryID/".$galleryData['G_ImageID']."/".$thumbName;
             $imageSrc = Zend_Registry::get("www_root") . "/data/images/gallery/{$galleryID}/" . $galleryData['G_ImageID'] . "/" . $thumbName;
             //$this->view->assign('imageUrl', $imageData['ImageSrc_preview']);
             $this->view->assign('imageUrl', $imageSrc);
             $isNewImage = 'false';
             //$imageSrc   = $imageData['ImageSrc_preview'];
         }
         // generate the form
         if ($blockID != '') {
             $cancelUrl = "{$baseDir}/gallery/index/list/blockID/{$blockID}/pageID/{$pageID}";
         } elseif ($this->_categoryID != '') {
             $cancelUrl = "{$baseDir}/gallery/index/list/catID/{$this->_categoryID}";
         } else {
             $cancelUrl = "{$baseDir}/gallery/index/list/";
         }
         $form = new FormGallery(array('baseDir' => $baseDir, 'cancelUrl' => '', 'galleryID' => $galleryID, 'imageSrc' => $imageSrc, 'isNewImage' => $isNewImage, 'requiredTitle' => true, 'requiredPosition' => false, 'requiredDescription' => false));
         if ($this->_request->isPost()) {
             $formData = $this->_request->getPost();
             if ($form->isValid($formData)) {
                 $galleryObject = new GalleryObject();
                 $formattedName = Cible_FunctionsGeneral::formatValueForUrl($formData['GI_Title']);
                 $formData['GI_ValUrl'] = $formattedName;
                 if ($blockID != '') {
                     $blockParameters = Cible_FunctionsBlocks::getBlockParameters($blockID);
                     $formData['G_CategoryID'] = $blockParameters[0]['P_Value'];
                 } elseif ($this->_categoryID != '') {
                     $formData['G_CategoryID'] = $this->_categoryID;
                 }
                 if ($formData['isNewImage'] == 'true') {
                     // create the image
                     $imageObject = new ImageObject();
                     $formData['II_Title'] = $formData['GI_Title'];
                     $formData['II_Description'] = $formData['GI_Description'];
                     $imageID = $imageObject->insert($formData, Zend_Registry::get("currentEditLanguage"));
                     // update the galery
                     $formData['G_CreationDate'] = $galleryData['G_CreationDate'];
                     $formData['G_ImageID'] = $imageID;
                     $galleryObject->save($galleryID, $formData, Zend_Registry::get("currentEditLanguage"));
                     $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);
                 } else {
                     $formData['G_CreationDate'] = $galleryData['G_CreationDate'];
                     $formData['G_ImageID'] = $galleryData['G_ImageID'];
                     $galleryObject->save($galleryID, $formData, Zend_Registry::get("currentEditLanguage"));
                 }
                 if ($blockID != '') {
                     $indexData['pageID'] = $blockParameters[0]['P_Value'];
                     $indexData['moduleID'] = $this->_moduleID;
                     $indexData['contentID'] = $galleryID;
                     $indexData['languageID'] = Zend_Registry::get("currentEditLanguage");
                     $indexData['title'] = $formData['GI_Title'];
                     $indexData['text'] = '';
                     $indexData['link'] = 'gallery';
                     $indexData['contents'] = $formData['GI_Title'] . " " . $formData['GI_Description'];
                     if ($formData['G_Online'] == 1) {
                         $indexData['action'] = 'update';
                     } else {
                         $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 = ?', Zend_Registry::get("currentEditLanguage"));
                 $imageData = $imageSelect->fetchAll($select)->toArray();
                 $cpt = count($imageData);
                 for ($i = 0; $i < $cpt; $i++) {
                     $indexData['pageID'] = $galleryID;
                     $indexData['moduleID'] = $this->_moduleID;
                     $indexData['contentID'] = $imageData[$i]['II_ImageID'];
                     $indexData['languageID'] = $imageData[$i]['II_LanguageID'];
                     $indexData['title'] = $imageData[$i]['II_Title'];
                     $indexData['text'] = '';
                     $indexData['link'] = 'image';
                     $indexData['contents'] = $imageData[$i]['II_Title'] . " " . $imageData[$i]['II_Description'];
                     if ($formData['G_Online'] == 1) {
                         $indexData['action'] = 'update';
                         if ($imageData[$i]['GI_Online'] == 1) {
                             Cible_FunctionsIndexation::indexation($indexData);
                         }
                     } else {
                         $indexData['action'] = 'delete';
                         Cible_FunctionsIndexation::indexation($indexData);
                     }
                 }
                 if (!$this->_isXmlHttpRequest) {
                     if ($blockID != '') {
                         $this->_redirect("/gallery/index/list/blockID/{$blockID}/pageID/{$pageID}");
                     } else {
                         $this->_redirect("/gallery/index/list/catID/{$this->_categoryID}");
                     }
                 } else {
                     $buttonAction = $formData['buttonAction'];
                     $this->view->assign('buttonAction', $buttonAction);
                     $this->view->assign('success', true);
                     $this->view->assign('galleryID', $galleryID);
                     $this->view->assign('galleryTitle', $form->getValue('GI_Title'));
                     $this->view->assign('galleryDescription', $form->getValue('GI_Description'));
                     $this->view->assign('galleryLanguage', Zend_Registry::get("currentEditLanguage"));
                 }
             } else {
                 $this->view->form = $form;
             }
         } else {
             $form->populate($galleryData);
             $form->populate($imageData);
             $this->view->form = $form;
         }
     }
     //}
 }
Beispiel #3
0
 public function editAction()
 {
     // variables
     $eventID = $this->_getParam('eventID');
     $pageID = $this->_getParam('pageID');
     $returnAction = $this->_getParam('return');
     $blockID = $this->_getParam('blockID');
     $baseDir = $this->view->baseUrl();
     if ($this->view->aclIsAllowed('events', 'edit', true)) {
         if ($returnAction) {
             $returnUrl = "/events/index/{$returnAction}";
         } elseif ($blockID) {
             $returnUrl = "/events/index/list/blockID/{$blockID}/pageID/{$pageID}";
         } else {
             $returnUrl = "/events/index/list-all/";
         }
         // get event details
         $eventsObject = new EventsObject();
         $event = $eventsObject->populate($eventID, $this->getCurrentEditLanguage());
         // image src.
         $config = Zend_Registry::get('config')->toArray();
         $thumbMaxHeight = $config['event']['image']['thumb']['maxHeight'];
         $thumbMaxWidth = $config['event']['image']['thumb']['maxWidth'];
         //$this->view->assign('imageUrl', $event['ImageSrc']);
         $this->view->assign('imageUrl', Zend_Registry::get("www_root") . "/data/images/event/{$eventID}/" . str_replace($event['ImageSrc'], $thumbMaxWidth . 'x' . $thumbMaxHeight . '_' . $event['ImageSrc'], $event['ImageSrc']));
         $isNewImage = 'false';
         if ($this->_request->isPost()) {
             $formData = $this->_request->getPost();
             if ($formData['ImageSrc'] != $event['ImageSrc']) {
                 if ($formData['ImageSrc'] == "") {
                     $imageSrc = $this->view->baseUrl() . "/icons/image_non_ disponible.jpg";
                 } else {
                     $imageSrc = Zend_Registry::get("www_root") . "/data/images/event/{$eventID}/tmp/mcith/mcith_" . $formData['ImageSrc'];
                 }
                 $isNewImage = 'true';
             } else {
                 if ($event['ImageSrc'] == "") {
                     $imageSrc = $this->view->baseUrl() . "/icons/image_non_ disponible.jpg";
                 } else {
                     $imageSrc = Zend_Registry::get("www_root") . "/data/images/event/{$eventID}/" . str_replace($event['ImageSrc'], $thumbMaxWidth . 'x' . $thumbMaxHeight . '_' . $event['ImageSrc'], $event['ImageSrc']);
                 }
             }
         } else {
             if (empty($event['ImageSrc'])) {
                 $imageSrc = $this->view->baseUrl() . "/icons/image_non_ disponible.jpg";
             } else {
                 $imageSrc = Zend_Registry::get("www_root") . "/data/images/event/{$eventID}/" . str_replace($event['ImageSrc'], $thumbMaxWidth . 'x' . $thumbMaxHeight . '_' . $event['ImageSrc'], $event['ImageSrc']);
             }
         }
         // generate the form
         $form = new FormEvents(array('baseDir' => $baseDir, 'imageSrc' => $imageSrc, 'cancelUrl' => "{$baseDir}{$returnUrl}", 'categoriesList' => "false", 'eventID' => $eventID, 'isNewImage' => $isNewImage));
         $this->view->form = $form;
         // action
         if (!$this->_request->isPost()) {
             if (isset($event['Status']) && $event['Status'] == 2) {
                 $event['Status'] = 0;
             }
             $form->populate($event);
         } else {
             $formData = $this->_request->getPost();
             if ($form->isValid($formData)) {
                 if ($formData['isNewImage'] == 'true' && $form->getValue('ImageSrc') != '') {
                     $config = Zend_Registry::get('config')->toArray();
                     $srcOriginal = "../../{$this->_config->document_root}/data/images/event/{$eventID}/tmp/" . $form->getValue('ImageSrc');
                     $originalMaxHeight = $config['event']['image']['original']['maxHeight'];
                     $originalMaxWidth = $config['event']['image']['original']['maxWidth'];
                     $originalName = str_replace($form->getValue('ImageSrc'), $originalMaxWidth . 'x' . $originalMaxHeight . '_' . $form->getValue('ImageSrc'), $form->getValue('ImageSrc'));
                     $srcMedium = "../../{$this->_config->document_root}/data/images/event/{$eventID}/tmp/medium_{$form->getValue('ImageSrc')}";
                     $mediumMaxHeight = $config['event']['image']['medium']['maxHeight'];
                     $mediumMaxWidth = $config['event']['image']['medium']['maxWidth'];
                     $mediumName = str_replace($form->getValue('ImageSrc'), $mediumMaxWidth . 'x' . $mediumMaxHeight . '_' . $form->getValue('ImageSrc'), $form->getValue('ImageSrc'));
                     $srcThumb = "../../{$this->_config->document_root}/data/images/event/{$eventID}/tmp/thumb_{$form->getValue('ImageSrc')}";
                     $thumbMaxHeight = $config['event']['image']['thumb']['maxHeight'];
                     $thumbMaxWidth = $config['event']['image']['thumb']['maxWidth'];
                     $thumbName = str_replace($form->getValue('ImageSrc'), $thumbMaxWidth . 'x' . $thumbMaxHeight . '_' . $form->getValue('ImageSrc'), $form->getValue('ImageSrc'));
                     copy($srcOriginal, $srcMedium);
                     copy($srcOriginal, $srcThumb);
                     Cible_FunctionsImageResampler::resampled(array('src' => $srcOriginal, 'maxWidth' => $originalMaxWidth, 'maxHeight' => $originalMaxHeight));
                     Cible_FunctionsImageResampler::resampled(array('src' => $srcMedium, 'maxWidth' => $mediumMaxWidth, 'maxHeight' => $mediumMaxHeight));
                     Cible_FunctionsImageResampler::resampled(array('src' => $srcThumb, 'maxWidth' => $thumbMaxWidth, 'maxHeight' => $thumbMaxHeight));
                     rename($srcOriginal, "../../{$this->_config->document_root}/data/images/event/{$eventID}/{$originalName}");
                     rename($srcMedium, "../../{$this->_config->document_root}/data/images/event/{$eventID}/{$mediumName}");
                     rename($srcThumb, "../../{$this->_config->document_root}/data/images/event/{$eventID}/{$thumbName}");
                 }
                 if (!empty($pageID)) {
                     //$blockData  = Cible_FunctionsBlocks::getBlockDetails($blockID);
                     //$blockStatus    = $blockData['B_Online'];
                     $indexData['pageID'] = $event['CategoryID'];
                     $indexData['moduleID'] = $this->_moduleID;
                     $indexData['contentID'] = $eventID;
                     $indexData['languageID'] = Zend_Registry::get("currentEditLanguage");
                     $indexData['title'] = $formData['Title'];
                     $indexData['text'] = '';
                     $indexData['link'] = '';
                     $indexData['contents'] = $formData['Title'] . " " . $formData['Brief'] . " " . $formData['Text'] . " " . $formData['ImageAlt'];
                     //Cible_FunctionsIndexation::indexation($indexData);
                     if ($formData['Status'] == 1) {
                         $indexData['action'] = 'update';
                     } else {
                         $indexData['action'] = 'delete';
                     }
                     Cible_FunctionsIndexation::indexation($indexData);
                 }
                 if ($formData['Status'] == 0) {
                     $formData['Status'] = 2;
                 }
                 $formattedName = Cible_FunctionsGeneral::formatValueForUrl($formData['Title']);
                 $formData['ValUrl'] = $formattedName;
                 // echo $formData['ValUrl'];
                 // exit;
                 $eventsObject->save($eventID, $formData, $this->getCurrentEditLanguage());
                 // redirect
                 if (!empty($pageID)) {
                     $this->_redirect("/events/index/list/blockID/{$blockID}/pageID/{$pageID}");
                 } else {
                     $this->_redirect($returnUrl);
                 }
             }
         }
     }
 }
 public function buildCatalogMenu($menuCatalog, $options = array())
 {
     $tree = array();
     $langId = Zend_Registry::get('languageID');
     $defaultCat = "";
     $link = "";
     //        $oCategories = new CatalogCategoriesObject();
     //
     //        if(Zend_Registry::isRegistered('defaultCategory')
     //            && !is_null(Zend_Registry::get('defaultCategory')))
     //        {
     //            $defaultCatId = Zend_Registry::get('defaultCategory');
     //            $tmpCat       = $oCategories->populate($defaultCatId, $langId);
     //            if(empty ($tmpCat['CI_ValUrl']))
     //                $tmpCat['CI_ValUrl'] = "";
     //            $defaultCat   = $tmpCat['CI_ValUrl'];
     //        }
     //        $categories = $oCategories->getAll($langId);
     //        $catalog    = Array(
     //            'ID'     => $menuCatalog['ID'],
     //            'Title'  => $menuCatalog['Title'],
     //            'PageID' => '',
     //            'Link'   => $link . $defaultCat,
     //            'Placeholder' => 0,
     //            'menuImage' => '',
     //            'loadImage' => '',
     //            'menuImgAndTitle' => '',
     //            'child' => array()
     //        );
     //        foreach ($categories as $category)
     //        {
     //            $childs  = array();
     //            $id      = $category['CC_ID'];
     //            $name    = Cible_FunctionsGeneral::formatValueForUrl($category['CCI_Name']);
     //            $linkCat = $link . $name;
     //
     //            $menu['ID']          = $category['CC_ID'];
     //            $menu['Title']       = $category['CCI_Name'];
     //            $menu['PageID']      = '';
     //            $menu['Link']        = $linkCat;
     //            $menu['menuImage']   = $category['CC_imageCat'];
     //            $menu['loadImage']   = 1;
     //            $menu['menuImgAndTitle'] = 1;
     //
     //            $menu['Placeholder'] = '2';
     $subCategories = $this->getAll($langId);
     //            var_dump($subCategories);
     //            exit;
     //            if ($options['nesting'] > 1)
     //            {
     foreach ($subCategories as $subCat) {
         $name = "/" . Cible_FunctionsGeneral::formatValueForUrl($subCat['SCI_Name']);
         //                    $linkSubCat = $linkCat . $name;
         $linkSubCat = $name;
         $child['ID'] = $subCat['SC_ID'];
         $child['Title'] = $subCat['SCI_Name'];
         $child['PageID'] = '';
         $child['Link'] = $linkSubCat;
         $child['menuImage'] = '';
         $child['loadImage'] = 0;
         $child['menuImgAndTitle'] = 0;
         $child['Placeholder'] = '2';
         $childs[] = $child;
         $name = '';
     }
 }
Beispiel #5
0
 public function buildCatalogMenu($options = array())
 {
     $menuCatalogId = 0;
     $defaultCat = '';
     if (isset($options['menu'])) {
         $oMenu = new MenuObject($options['menu']);
         $menuCatalog = $oMenu->getMenuItemByPageId(null, 'catalog');
         //            if ($this->view->currentPageID)
         //            {
         //                $parentPage = Cible_FunctionsPages::findParentPageID($this->view->currentPageID);
         //                while ($parentPage['P_ParentID'] != 0 )
         //                {
         //                   $parentPage = Cible_FunctionsPages::findParentPageID($parentPage['P_ParentID']);
         //                }
         //
         //                $pageId      = $parentPage['P_ID'];
         //                $menuCatalog = $oMenu->getMenuItemByPageId($pageId);
         //            }
         //            else
         //            {
         //                $menuCatalog = $oMenu->getMenuItemByPageId();
         $parentPage = Cible_FunctionsPages::findParentPageID($menuCatalog['MII_PageID']);
         //            }
     }
     if ($this->view->controller != $parentPage['PI_PageIndex']) {
         $link = $parentPage['PI_PageIndex'] . "/";
     } else {
         $link = $this->view->selectedPage . "/";
     }
     $tree = array();
     $langId = Zend_Registry::get('languageID');
     $oCategories = new CatalogCategoriesObject();
     if (Zend_Registry::isRegistered('defaultCategory') && !is_null(Zend_Registry::get('defaultCategory'))) {
         $defaultCatId = Zend_Registry::get('defaultCategory');
         $tmpCat = $oCategories->populate($defaultCatId, $langId);
         if (empty($tmpCat['CI_ValUrl'])) {
             $tmpCat['CI_ValUrl'] = "";
         }
         $defaultCat = $tmpCat['CI_ValUrl'];
     }
     $categories = $oCategories->getAll($langId);
     $oSubCategories = new SubCategoriesObject();
     $catalog = array('ID' => $menuCatalog['MID_ID'], 'Title' => $menuCatalog['MII_Title'], 'PageID' => '', 'Link' => $link . $defaultCat, 'Placeholder' => 0, 'child' => array());
     foreach ($categories as $category) {
         $childs = array();
         $id = $category['C_ID'];
         $name = Cible_FunctionsGeneral::formatValueForUrl($category['CI_Name']);
         $linkCat = $link . $name;
         $menu['ID'] = $category['C_ID'];
         $menu['Title'] = $category['CI_Name'];
         $menu['PageID'] = '';
         $menu['Link'] = $linkCat;
         $menu['Placeholder'] = '2';
         $subCategories = $oSubCategories->getSubCatByCategory($id, true, $langId);
         if ($options['nesting'] > 1) {
             foreach ($subCategories as $subCat) {
                 $name = "/" . Cible_FunctionsGeneral::formatValueForUrl($subCat['SCI_Name']);
                 $linkSubCat = $linkCat . $name;
                 $child['ID'] = $subCat['SC_ID'];
                 $child['Title'] = $subCat['SCI_Name'];
                 $child['PageID'] = '';
                 $child['Link'] = $linkSubCat;
                 $child['Placeholder'] = '2';
                 $childs[] = $child;
                 $name = '';
             }
         }
         $menu['child'] = $childs;
         $catalog['child'][] = $menu;
     }
     $oMenu = new MenuObject($options['menu']);
     $first = $oMenu->populate($menuCatalog['MID_ID']);
     $childCombined = array();
     if (isset($options['merge']) && $options['merge']) {
         $childCombined = array_merge($catalog['child'], $first);
         $catalog['child'] = $childCombined;
     }
     $tree[] = $catalog;
     return $tree;
 }
Beispiel #6
0
 function editAction()
 {
     $this->view->title = "'Modification d'un article à une parution";
     $this->view->assign('isXmlHttpRequest', $this->_isXmlHttpRequest);
     $this->view->assign('success', false);
     if ($this->view->aclIsAllowed('newsletter', 'manage', true)) {
         $pageID = $this->_getParam('pageID');
         $newsletterID = $this->_getParam('newsletterID');
         $articleID = $this->_getParam('articleID');
         $baseDir = $this->view->baseUrl();
         $newsletterArticleSelect = new NewsletterArticles();
         $select = $newsletterArticleSelect->select();
         $select->where('NA_ID = ?', $articleID);
         $newsletterArticleData = $newsletterArticleSelect->fetchRow($select);
         // generate the form
         $config = Zend_Registry::get('config')->toArray();
         $thumbMaxHeight = $config['newsletter']['image']['thumb']['maxHeight'];
         $thumbMaxWidth = $config['newsletter']['image']['thumb']['maxWidth'];
         $this->view->assign('imageUrl', $imageSrc = Zend_Registry::get("www_root") . "/data/images/newsletter/{$newsletterID}/{$newsletterArticleData['NA_ID']}/" . str_replace($newsletterArticleData['NA_ImageSrc'], $thumbMaxWidth . 'x' . $thumbMaxHeight . '_' . $newsletterArticleData['NA_ImageSrc'], $newsletterArticleData['NA_ImageSrc']));
         $isNewImage = 'false';
         if ($this->_request->isPost()) {
             $formData = $this->_request->getPost();
             if ($formData['ImageSrc'] != $newsletterArticleData['NA_ImageSrc']) {
                 if ($formData['ImageSrc'] == "") {
                     $imageSrc = $this->view->baseUrl() . "/icons/image_non_ disponible.jpg";
                 } else {
                     $imageSrc = Zend_Registry::get("www_root") . "/data/images/newsletter/{$newsletterID}/tmp/mcith/mcith_" . $formData['ImageSrc'];
                 }
                 $isNewImage = 'true';
             } else {
                 if ($newsletterArticleData['NA_ImageSrc'] == "") {
                     $imageSrc = $this->view->baseUrl() . "/icons/image_non_ disponible.jpg";
                 } else {
                     $imageSrc = Zend_Registry::get("www_root") . "/data/images/newsletter/{$newsletterID}/{$newsletterArticleData['NA_ID']}/" . str_replace($newsletterArticleData['NA_ImageSrc'], $thumbMaxWidth . 'x' . $thumbMaxHeight . '_' . $newsletterArticleData['NA_ImageSrc'], $newsletterArticleData['NA_ImageSrc']);
                 }
             }
         } else {
             if ($newsletterArticleData['NA_ImageSrc'] == '') {
                 $imageSrc = $this->view->baseUrl() . "/icons/image_non_ disponible.jpg";
             } else {
                 $imageSrc = Zend_Registry::get("www_root") . "/data/images/newsletter/{$newsletterID}/{$newsletterArticleData['NA_ID']}/" . str_replace($newsletterArticleData['NA_ImageSrc'], $thumbMaxWidth . 'x' . $thumbMaxHeight . '_' . $newsletterArticleData['NA_ImageSrc'], $newsletterArticleData['NA_ImageSrc']);
             }
         }
         $cancelUrl = $this->view->baseUrl() . "/newsletter/index/edit/newsletterID/{$newsletterID}";
         $form = new FormNewsletterArticle(array('baseDir' => $baseDir, 'cancelUrl' => $cancelUrl, 'newsletterID' => $newsletterID, 'imageSrc' => $imageSrc, 'isNewImage' => $isNewImage));
         if ($this->_request->isPost()) {
             $formData = $this->_request->getPost();
             if ($form->isValid($formData)) {
                 $newsletterArticleData['NA_ImageAlt'] = $form->getValue('NA_ImageAlt');
                 if ($formData['isNewImage'] == 'true' && $form->getValue('ImageSrc') != '') {
                     $srcOriginal = "../../{$this->_config->document_root}/data/images/newsletter/{$newsletterID}/tmp/" . $form->getValue('ImageSrc');
                     $originalMaxHeight = $config['newsletter']['image']['original']['maxHeight'];
                     $originalMaxWidth = $config['newsletter']['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/newsletter/{$newsletterID}/tmp/thumb_{$form->getValue('ImageSrc')}";
                     $thumbMaxHeight = $config['newsletter']['image']['thumb']['maxHeight'];
                     $thumbMaxWidth = $config['newsletter']['image']['thumb']['maxWidth'];
                     $thumbName = str_replace($form->getValue('ImageSrc'), $thumbMaxWidth . 'x' . $thumbMaxHeight . '_' . $form->getValue('ImageSrc'), $form->getValue('ImageSrc'));
                     copy($srcOriginal, $srcThumb);
                     Cible_FunctionsImageResampler::resampled(array('src' => $srcOriginal, 'maxWidth' => $originalMaxWidth, 'maxHeight' => $originalMaxHeight));
                     Cible_FunctionsImageResampler::resampled(array('src' => $srcThumb, 'maxWidth' => $thumbMaxWidth, 'maxHeight' => $thumbMaxHeight));
                     if (!is_dir("../../{$this->_config->document_root}/data/images/newsletter/{$newsletterID}/{$articleID}")) {
                         mkdir("../../{$this->_config->document_root}/data/images/newsletter/{$newsletterID}/{$articleID}") or die("Could not make directory");
                     } else {
                         foreach (glob("../../{$this->_config->document_root}/data/images/newsletter/{$newsletterID}/{$articleID}/*.*") as $v) {
                             unlink($v);
                         }
                     }
                     rename($srcOriginal, "../../{$this->_config->document_root}/data/images/newsletter/{$newsletterID}/{$articleID}/{$originalName}");
                     rename($srcThumb, "../../{$this->_config->document_root}/data/images/newsletter/{$newsletterID}/{$articleID}/{$thumbName}");
                     $newsletterArticleData['NA_ImageSrc'] = $form->getValue('ImageSrc');
                 } elseif ($formData['isNewImage'] == 'true' && $form->getValue('ImageSrc') == '') {
                     if (is_dir("../../{$this->_config->document_root}/data/images/newsletter/{$newsletterID}/{$articleID}")) {
                         foreach (glob("../../{$this->_config->document_root}/data/images/newsletter/{$newsletterID}/{$articleID}/*.*") as $v) {
                             unlink($v);
                         }
                     }
                     $newsletterArticleData['NA_ImageSrc'] = '';
                     $newsletterArticleData['NA_ImageAlt'] = '';
                 }
                 $newsletterArticleData['NA_Title'] = $form->getValue('NA_Title');
                 $newsletterArticleData['NA_ValUrl'] = Cible_FunctionsGeneral::formatValueForUrl($form->getValue('NA_Title'));
                 $newsletterArticleData['NA_Resume'] = $form->getValue('NA_Resume');
                 $newsletterArticleData['NA_Text'] = $form->getValue('NA_Text');
                 $newsletterArticleData['NA_URL'] = $form->getValue('NA_URL');
                 $newsletterArticleData['NA_TextLink'] = $form->getValue('NA_TextLink');
                 $newsletterArticleData->save();
                 $this->_redirect("/newsletter/index/edit/newsletterID/{$newsletterID}");
             } else {
                 $this->view->form = $form;
             }
         } else {
             $form->populate($newsletterArticleData->toArray());
             $this->view->form = $form;
         }
     }
 }
Beispiel #7
0
 public function editInfoAction()
 {
     // web page title
     $this->view->title = "Modification d'une infolettre";
     if ($this->view->aclIsAllowed('newsletter', 'manage', true)) {
         // variables
         $pageID = $this->_getParam('pageID');
         $blockID = $this->_getParam('blockID');
         $newsletterID = $this->_getParam('newsletterID');
         $baseDir = $this->view->baseUrl();
         $newsletterSelect = new NewsletterReleases();
         $select = $newsletterSelect->select();
         $select->where('NR_ID = ?', $newsletterID);
         $newsletterData = $newsletterSelect->fetchRow($select);
         // generate the form
         $cancelUrl = "/newsletter/index/edit/blockID/{$blockID}/pageID/{$pageID}/newsletterID/{$newsletterID}";
         $form = new FormNewsletter(array('baseDir' => $baseDir, 'cancelUrl' => $baseDir . $cancelUrl));
         if ($this->_request->isPost()) {
             $formData = $this->_request->getPost();
             if ($form->isValid($formData)) {
                 $newsletterData['NR_LanguageID'] = $form->getValue('NR_LanguageID');
                 $newsletterData['NR_CategoryID'] = $form->getValue('NR_CategoryID');
                 $newsletterData['NR_ModelID'] = $form->getValue('NR_ModelID');
                 $newsletterData['NR_Title'] = $form->getValue('NR_Title');
                 $newsletterData['NR_AdminEmail'] = $form->getValue('NR_AdminEmail');
                 $newsletterData['NR_ValUrl'] = Cible_FunctionsGeneral::formatValueForUrl($form->getValue('NR_Title'));
                 $newsletterData['NR_Date'] = $form->getValue('NR_Date');
                 $newsletterData['NR_TextIntro'] = $form->getValue('NR_TextIntro');
                 $newsletterData['NR_Online'] = $formData['NR_Online'] == 0 ? 2 : 1;
                 $newsletterData['NR_AfficherTitre'] = $form->getValue('NR_AfficherTitre');
                 $newsletterData->save();
                 $blockData = Cible_FunctionsBlocks::getBlockDetails($blockID);
                 $status = $blockData['B_Online'];
                 if ($newsletterData['NR_Online'] == 1 && $status == 1 || $newsletterData['NR_Online'] == 0) {
                     // get all article in the release
                     $articlesSelect = new NewsletterArticles();
                     $select = $articlesSelect->select()->where('NA_ReleaseID = ?', $newsletterID);
                     $articlesData = $articlesSelect->fetchAll($select);
                     $indexData['pageID'] = $pageID;
                     $indexData['moduleID'] = 8;
                     $indexData['languageID'] = $newsletterData['NR_LanguageID'];
                     foreach ($articlesData as $article) {
                         $indexData['contentID'] = $article['NA_ID'];
                         if ($newsletterData['NR_Online'] == 1) {
                             $indexData['title'] = $article['NA_Title'];
                             $indexData['text'] = Cible_FunctionsGeneral::stripTextWords(Cible_FunctionsGeneral::html2text($article['NA_Resume']));
                             $indexData['link'] = '';
                             $indexData['contents'] = Cible_FunctionsGeneral::html2text($article['NA_Resume'] . "<br/>" . $article['NA_Text']);
                             $indexData['action'] = 'update';
                         } elseif ($newsletterData['NR_Online'] == 0) {
                             $indexData['action'] = 'delete';
                         }
                         Cible_FunctionsIndexation::indexation($indexData);
                     }
                 }
             }
             $this->_redirect($cancelUrl);
         } else {
             $data = $newsletterData->toArray();
             if ($data['NR_Online'] == 2) {
                 $data['NR_Online'] = 0;
             }
             $form->populate($data);
             $this->view->form = $form;
         }
     }
 }
Beispiel #8
0
 public function formatProductNameAction()
 {
     $oProduct = new ProductsObject();
     $select = $oProduct->getAll(null, false);
     $select->where('PI_ValUrl is NULL');
     $db = Zend_Registry::get('db');
     $products = $db->fetchAll($select);
     foreach ($products as $product) {
         $name = $product['PI_Name'];
         $formatted = Cible_FunctionsGeneral::formatValueForUrl($name);
         $data = array('PI_ValUrl' => $formatted);
         $oProduct->save($product['P_ID'], $data, $product['PI_LanguageID']);
     }
 }