public static function resampled($image)
 {
     $image['ext'] = strtolower(substr($image['src'], strrpos($image['src'], '.') + 1));
     list($image['width'], $image['height'], $image['type'], $image['attr']) = getimagesize($image['src']);
     $image['width'] >= $image['height'] ? $image['format'] = 'landscape' : ($image['format'] = 'portrait');
     $newDimensions = Cible_FunctionsImageResampler::newDimensions($image);
     if ($image['ext'] == 'jpeg' || $image['ext'] == 'jpg') {
         // returns an image identifier representing the image obtained from the given filename.
         $newImage = imagecreatefromjpeg($image['src']);
         // returns an image identifier representing a black image of the specified size.
         $thumb = imagecreatetruecolor($newDimensions['width'], $newDimensions['height']);
         // copies a rectangular portion of one image to another image, smoothly interpolating pixel values so that, in particular, reducing the size of an image still retains a great deal of clarity.
         imagecopyresampled($thumb, $newImage, 0, 0, 0, 0, $newDimensions['width'], $newDimensions['height'], $image['width'], $image['height']);
         // creates a JPEG file from the given image
         imagejpeg($thumb, $image['src'], 80);
         // frees any memory associated with newImage
         imagedestroy($newImage);
     } elseif ($image['ext'] == 'gif') {
         // returns an image identifier representing the image obtained from the given filename.
         $newImage = imagecreatefromgif($image['src']);
         // returns an image identifier representing a black image of the specified size.
         $thumb = imagecreate($newDimensions['width'], $newDimensions['height']);
         // returns a color identifier representing the color composed of the given RGB components.
         $trans_color = imagecolorallocate($thumb, 255, 0, 0);
         // sets the transparent color in the given image .
         imagecolortransparent($thumb, $trans_color);
         // copies a rectangular portion of one image to another image, smoothly interpolating pixel values so that, in particular, reducing the size of an image still retains a great deal of clarity.
         imagecopyresampled($thumb, $newImage, 0, 0, 0, 0, $newDimensions['width'], $newDimensions['height'], $image['width'], $image['height']);
         // creates the GIF  file in filename from the image image
         imagegif($thumb, $image['src']);
         // détruit une image
         imagedestroy($newImage);
     } elseif ($image['ext'] == 'png') {
         $image_source = imagecreatefrompng($image['src']);
         $new_image = imagecreatetruecolor($newDimensions['width'], $newDimensions['height']);
         if (function_exists('imagecolorallocatealpha')) {
             imagealphablending($new_image, false);
             imagesavealpha($new_image, true);
             $transparent = imagecolorallocatealpha($new_image, 255, 255, 255, 127);
             imagefilledrectangle($new_image, 0, 0, $newDimensions['width'], $newDimensions['height'], $transparent);
         }
         imagecolortransparent($new_image, $transparent);
         imagecopyresampled($new_image, $image_source, 0, 0, 0, 0, $newDimensions['width'], $newDimensions['height'], $image['width'], $image['height']);
         imagepng($new_image, $image['src']);
         imagedestroy($new_image);
     }
 }
Example #2
0
 /**
  * Get the action type sent via ajax and update the total of items in the
  * cart.
  * Gets parameters from POST
  *
  * @return void
  */
 public function ajaxAction()
 {
     $this->getHelper('viewRenderer')->setNoRender();
     $action = $this->_getParam('actionAjax');
     $langId = $this->_getParam('langId');
     if ($action == 'updateCart') {
         $cart = new Cart();
         $cartItems = $cart->getTotalItem();
         $nbItems = $cartItems['Quantity'];
         $subTotal = $cartItems['Subtotal'];
         echo json_encode($cart->getTotalItem());
     } elseif ($action == 'addToCart') {
         $cart = new Cart();
         if (!$this->_isXmlHttpRequest) {
             $itemID = $this->_getParam('p_id');
             $session = new Zend_Session_Namespace();
             $langId = $session->languageId;
             $srcOriginal = "../www/" . "data/images/catalog/originals/" . $itemID . ".png";
             $width = $this->_config->cart->image->thumb->maxWidth;
             $height = $this->_config->cart->image->thumb->maxHeight;
             Cible_FunctionsImageResampler::resampled(array('src' => $srcOriginal, 'maxWidth' => $width, 'maxHeight' => $height));
         } else {
             $itemID = $this->_getParam('itemID');
         }
         if ($itemID != '') {
             $cart->addItem($itemID, 1, array('langId' => $langId));
         }
     } elseif ($action == 'update') {
         $cart = new Cart();
         $itemId = $this->_getParam('itemId');
         $id = $this->_getParam('cartItemsId');
         $cartItem = $cart->getItem($id, $itemId);
         echo json_encode($cartItem['Total']);
     } else {
         echo 'null';
     }
     if (!$this->_isXmlHttpRequest) {
         $config = Zend_Registry::get('config');
         $pageId = $config->cartPageId;
         $url = $this->_registry->absolute_web_root . "/" . Cible_FunctionsPages::getPageNameByID($pageId, $langId);
         $this->_redirect($url);
     }
 }
 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);
                 }
             }
         }
     }
 }
Example #4
0
 /**
  * Edit action for the current object.
  *
  * @access public
  *
  * @return void
  */
 public function editAction()
 {
     $imageSrc = "";
     $id = (int) $this->_getParam($this->_ID);
     $page = (int) $this->_getParam('page');
     $baseDir = $this->view->baseUrl() . "/";
     $returnAction = $this->_getParam('return');
     $cancelUrl = $baseDir . "/" . $this->_moduleTitle . "/" . $this->_name . "/" . $this->_currentAction . "/page/" . $page;
     $oDataName = $this->_objectList[$this->_currentAction];
     $oData = new $oDataName();
     if ($this->view->aclIsAllowed($this->_moduleTitle, 'edit', true)) {
         $returnUrl = $this->_moduleTitle . "/" . $this->_name . "/" . $this->_currentAction . "/" . "page/" . $page;
         // Get data details
         $data = $oData->populate($id, $this->_defaultEditLanguage);
         // image src.
         if (!empty($data[$this->_imageSrc])) {
             $config = Zend_Registry::get('config')->toArray();
             $thumbMaxHeight = $config[$this->_moduleTitle]['image']['thumb']['maxHeight'];
             $thumbMaxWidth = $config[$this->_moduleTitle]['image']['thumb']['maxWidth'];
             $this->view->assign('imageUrl', $this->_rootImgPath . $id . "/" . str_replace($data[$this->_imageSrc], $thumbMaxWidth . 'x' . $thumbMaxHeight . '_' . $data[$this->_imageSrc], $data[$this->_imageSrc]));
             $isNewImage = 'false';
             if ($this->_request->isPost()) {
                 $formData = $this->_request->getPost();
                 if ($formData[$this->_imageSrc] != $data[$this->_imageSrc]) {
                     if ($formData[$this->_imageSrc] == "") {
                         $imageSrc = $this->view->baseUrl() . "/icons/image_non_ disponible.jpg";
                     } else {
                         $imageSrc = $this->_rootImgPath . $id . "/tmp/mcith/mcith_" . $formData[$this->_imageSrc];
                     }
                     $isNewImage = 'true';
                 } else {
                     if ($data[$this->_imageSrc] == "") {
                         $imageSrc = $this->view->baseUrl() . "/icons/image_non_ disponible.jpg";
                     } else {
                         $imageSrc = $this->_rootImgPath . $id . "/" . str_replace($data[$this->_imageSrc], $thumbMaxWidth . 'x' . $thumbMaxHeight . '_' . $data[$this->_imageSrc], $data[$this->_imageSrc]);
                     }
                 }
             } else {
                 if (empty($data[$this->_imageSrc])) {
                     $imageSrc = $this->view->baseUrl() . "/icons/image_non_ disponible.jpg";
                 } else {
                     $imageSrc = $this->_rootImgPath . $id . "/" . str_replace($data[$this->_imageSrc], $thumbMaxWidth . 'x' . $thumbMaxHeight . '_' . $data[$this->_imageSrc], $data[$this->_imageSrc]);
                 }
             }
         }
         // generate the form
         $form = new $this->_formName(array('moduleName' => $this->_moduleTitle . "/" . $this->_objectList[$this->_currentAction], 'baseDir' => $baseDir, 'cancelUrl' => $cancelUrl, 'imageSrc' => $imageSrc, 'imgField' => $this->_imageSrc, 'dataId' => $id, 'data' => $data, 'isNewImage' => 'true'));
         $this->view->form = $form;
         // action
         if (!$this->_request->isPost()) {
             $form->populate($data);
         } else {
             $formData = $this->_request->getPost();
             if ($form->isValid($formData)) {
                 $formData = $this->_mergeFormData($formData);
                 if ($formData['isNewImage'] == 'true' && $form->getValue($this->_imageSrc) != '') {
                     $config = Zend_Registry::get('config')->toArray();
                     $srcOriginal = $this->_imageFolder . $id . "/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 . $id . "/tmp/medium_" . $form->getValue($this->_imageSrc);
                     $mediumMaxHeight = $config[$this->_moduleTitle]['image']['medium']['maxHeight'];
                     $mediumMaxWidth = $config[$this->_moduleTitle]['image']['medium']['maxWidth'];
                     $mediumName = str_replace($form->getValue($this->_imageSrc), $mediumMaxWidth . 'x' . $mediumMaxHeight . '_' . $form->getValue($this->_imageSrc), $form->getValue($this->_imageSrc));
                     $srcThumb = $this->_imageFolder . $id . "/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, $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->_imageFolder . $id . "/" . $originalName);
                     rename($srcMedium, $this->_imageFolder . $id . "/" . $mediumName);
                     rename($srcThumb, $this->_imageFolder . $id . "/" . $thumbName);
                 }
                 $oData->save($id, $formData, $this->getCurrentEditLanguage());
                 // redirect
                 $this->_redirect($returnUrl);
             }
         }
     }
 }
Example #5
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);
                 }
             }
         }
     }
 }
Example #6
0
 function editMenuAction()
 {
     $this->view->assign('isXmlHttpRequest', $this->_isXmlHttpRequest);
     $this->view->assign('success', false);
     $_parentId = (int) $this->_request->getParam('parentID');
     $_menuId = (int) $this->_request->getParam('menuID');
     // image src.
     $config = Zend_Registry::get('config')->toArray();
     $thumbMaxHeight = $config[$this->_folderMenu]['image']['thumb']['maxHeight'];
     $thumbMaxWidth = $config[$this->_folderMenu]['image']['thumb']['maxWidth'];
     $menuItem = new MenuObject($_menuId);
     $menuData = $menuItem->loadItem($_parentId);
     if (isset($menuData['menuImage'])) {
         $this->view->assign('imageUrl', $this->_rootMenuImgPath . "{$_parentId}/" . str_replace($menuData['menuImage'], $thumbMaxWidth . 'x' . $thumbMaxHeight . '_' . $menuData['menuImage'], $menuData['menuImage']));
     }
     if (!is_dir($this->_imgMenuFolder . "{$_parentId}/")) {
         mkdir($this->_imgMenuFolder . $_parentId) or die("Could not make directory");
         mkdir($this->_imgMenuFolder . $_parentId . "/tmp") or die("Could not make directory");
     }
     $isNewImage = 'false';
     if ($this->_request->isPost()) {
         $formData = $this->_request->getPost();
         if ($formData['menuImage'] != $menuData['menuImage']) {
             if ($formData['menuImage'] == "") {
                 $imageSrc = $this->view->baseUrl() . "/icons/image_non_ disponible.jpg";
             } else {
                 $imageSrc = $this->_rootMenuImgPath . "{$_parentId}/tmp/mcith/mcith_" . $formData['menuImage'];
             }
             $isNewImage = 'true';
         } else {
             if ($menuData['menuImage'] == "") {
                 $imageSrc = $this->view->baseUrl() . "/icons/image_non_ disponible.jpg";
             } else {
                 $imageSrc = $this->_rootMenuImgPath . "{$_parentId}/" . str_replace($menuData['menuImage'], $thumbMaxWidth . 'x' . $thumbMaxHeight . '_' . $menuData['menuImage'], $menuData['menuImage']);
             }
         }
     } else {
         if (empty($menuData['menuImage'])) {
             $imageSrc = $this->view->baseUrl() . "/icons/image_non_ disponible.jpg";
         } else {
             $imageSrc = $this->_rootMenuImgPath . "{$_parentId}/" . str_replace($menuData['menuImage'], $thumbMaxWidth . 'x' . $thumbMaxHeight . '_' . $menuData['menuImage'], $menuData['menuImage']);
         }
     }
     // create a new formpage object
     $form = new FormMenu(array('baseDir' => $this->view->baseUrl(), 'pageID' => 0, 'menuId' => $_parentId, 'imageSrc' => $imageSrc, 'isNewImage' => $isNewImage));
     $this->view->assign('form', $form);
     if ($this->_request->isPost()) {
         $formData = $this->_request->getPost();
         $isPlaceholder = 0;
         if ($formData['menuItemType'] == 'page') {
             $form->disableElementValidation('MenuLink');
             $form->getDisplayGroup('externalLinkSelectionGroup')->setAttrib('style', 'display: none');
             $form->getDisplayGroup('pageSelectionGroup')->setAttrib('style', 'display: block');
         } else {
             if ($formData['menuItemType'] == 'external') {
                 $form->disableElementValidation('pagePicker');
                 $form->disableElementValidation('ControllerName');
                 $form->getDisplayGroup('pageSelectionGroup')->setAttrib('style', 'display: none');
                 $form->getDisplayGroup('externalLinkSelectionGroup')->setAttrib('style', 'display: block');
             } else {
                 $form->disableElementValidation('MenuLink');
                 $form->getDisplayGroup('externalLinkSelectionGroup')->setAttrib('style', 'display: none');
                 $form->getDisplayGroup('pageSelectionGroup')->setAttrib('style', 'display: none');
                 $form->disableElementValidation('pagePicker');
                 $form->disableElementValidation('ControllerName');
                 $form->getDisplayGroup('pageSelectionGroup')->setAttrib('style', 'display: none');
                 $form->getDisplayGroup('externalLinkSelectionGroup')->setAttrib('style', 'display: none');
                 $formData['MenuLink'] = '';
                 $isPlaceholder = 1;
             }
         }
         if ($form->isValid($formData)) {
             // saving the entry
             $menuItem = new MenuObject($_menuId);
             $menuItem->updateItem($_parentId, array('menuItemSecured' => $formData['menuItemSecured'], 'loadImage' => $formData['loadImage'], 'menuImage' => $formData['menuImage'], 'menuImgAndTitle' => $formData['menuImgAndTitle'], 'languageID' => $this->_currentEditLanguage, 'Title' => $formData['MenuTitle'], 'MID_Show' => $formData['MID_Show'], 'Link' => $formData['MenuLink'], 'PageID' => $formData['pagePicker'], 'Style' => $formData['MenuTitleStyle'], 'Placeholder' => $isPlaceholder));
             /* IMAGES */
             if ($form->getValue('menuImage') != '' && $isNewImage == 'true') {
                 $config = Zend_Registry::get('config')->toArray();
                 $srcOriginal = $this->_imgMenuFolder . $_parentId . "/tmp/" . $form->getValue('menuImage');
                 $originalMaxHeight = $config[$this->_folderMenu]['image']['original']['maxHeight'];
                 $originalMaxWidth = $config[$this->_folderMenu]['image']['original']['maxWidth'];
                 $originalName = str_replace($form->getValue('menuImage'), $originalMaxWidth . 'x' . $originalMaxHeight . '_' . $form->getValue('menuImage'), $form->getValue('menuImage'));
                 $srcMedium = $this->_imgMenuFolder . $_parentId . "/tmp/medium_{$form->getValue('menuImage')}";
                 $mediumMaxHeight = $config[$this->_folderMenu]['image']['medium']['maxHeight'];
                 $mediumMaxWidth = $config[$this->_folderMenu]['image']['medium']['maxWidth'];
                 $mediumName = str_replace($form->getValue('menuImage'), $mediumMaxWidth . 'x' . $mediumMaxHeight . '_' . $form->getValue('menuImage'), $form->getValue('menuImage'));
                 $srcThumb = $this->_imgMenuFolder . $_parentId . "/tmp/thumb_{$form->getValue('menuImage')}";
                 $thumbMaxHeight = $config[$this->_folderMenu]['image']['thumb']['maxHeight'];
                 $thumbMaxWidth = $config[$this->_folderMenu]['image']['thumb']['maxWidth'];
                 $thumbName = str_replace($form->getValue('menuImage'), $thumbMaxWidth . 'x' . $thumbMaxHeight . '_' . $form->getValue('menuImage'), $form->getValue('menuImage'));
                 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->_imgMenuFolder . "{$_parentId}/{$originalName}");
                 rename($srcMedium, $this->_imgMenuFolder . "{$_parentId}/{$mediumName}");
                 rename($srcThumb, $this->_imgMenuFolder . "{$_parentId}/{$thumbName}");
             }
             if (!$this->_isXmlHttpRequest) {
                 $this->_redirect('/');
             } else {
                 $buttonAction = $formData['buttonAction'];
                 $this->view->assign('buttonAction', $buttonAction);
                 $this->view->assign('success', true);
                 $this->view->assign('menuID', $_parentId);
             }
         } else {
             $form->populate($formData);
         }
     } else {
         $form->populate($menuData);
         $menuData['menuItemType'] = isset($menuData['menuItemType']) ? $menuData['menuItemType'] : 'page';
         if ($menuData['menuItemType'] == 'page') {
             $form->disableElementValidation('MenuLink');
             $form->getDisplayGroup('externalLinkSelectionGroup')->setAttrib('style', 'display: none');
             $form->getDisplayGroup('pageSelectionGroup')->setAttrib('style', 'display: block');
         } else {
             if ($menuData['menuItemType'] == 'external') {
                 $form->disableElementValidation('pagePicker');
                 $form->getDisplayGroup('pageSelectionGroup')->setAttrib('style', 'display: none');
                 $form->getDisplayGroup('externalLinkSelectionGroup')->setAttrib('style', 'display: block');
             } else {
                 $form->disableElementValidation('MenuLink');
                 $form->getDisplayGroup('externalLinkSelectionGroup')->setAttrib('style', 'display: none');
                 $form->getDisplayGroup('pageSelectionGroup')->setAttrib('style', 'display: none');
                 $form->disableElementValidation('pagePicker');
                 $form->getDisplayGroup('pageSelectionGroup')->setAttrib('style', 'display: none');
                 $form->getDisplayGroup('externalLinkSelectionGroup')->setAttrib('style', 'display: none');
             }
         }
     }
 }
Example #7
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;
         }
     }
     //}
 }
Example #8
0
 private function _setImage($source, $form, $newData, $recordID)
 {
     $config = Zend_Registry::get('config')->toArray();
     if ($this->_editMode) {
         $srcOriginal = $this->_imagesFolder . $recordID . "/tmp/" . $newData[$source];
     } else {
         $srcOriginal = $this->_imagesFolder . "tmp/" . $newData[$source];
     }
     $originalMaxHeight = $config[$this->_moduleTitle][$this->_imgIndex]['original']['maxHeight'];
     $originalMaxWidth = $config[$this->_moduleTitle][$this->_imgIndex]['original']['maxWidth'];
     $originalName = str_replace($newData[$source], $originalMaxWidth . 'x' . $originalMaxHeight . '_' . $newData[$source], $newData[$source]);
     $srcMedium = $this->_imagesFolder . "tmp/medium_" . $newData[$source];
     $mediumMaxHeight = $config[$this->_moduleTitle][$this->_imgIndex]['medium']['maxHeight'];
     $mediumMaxWidth = $config[$this->_moduleTitle][$this->_imgIndex]['medium']['maxWidth'];
     if ($mediumMaxHeight > 0 && $mediumMaxWidth > 0) {
         $mediumName = str_replace($newData[$source], $mediumMaxWidth . 'x' . $mediumMaxHeight . '_' . $newData[$source], $newData[$source]);
     }
     $srcThumb = $this->_imagesFolder . "tmp/thumb_" . $newData[$source];
     $thumbMaxHeight = $config[$this->_moduleTitle][$this->_imgIndex]['thumb']['maxHeight'];
     $thumbMaxWidth = $config[$this->_moduleTitle][$this->_imgIndex]['thumb']['maxWidth'];
     $thumbName = str_replace($newData[$source], $thumbMaxWidth . 'x' . $thumbMaxHeight . '_' . $newData[$source], $newData[$source]);
     copy($srcOriginal, $srcMedium);
     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->_imagesFolder . $recordID . "/" . $mediumName);
     }
     rename($srcOriginal, $this->_imagesFolder . $recordID . "/" . $originalName);
     rename($srcThumb, $this->_imagesFolder . $recordID . "/" . $thumbName);
 }
Example #9
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;
         }
     }
 }
Example #10
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);
         }
     }
     //}
 }
Example #11
0
 /**
  * Edit action for the current object.
  *
  * @access public
  *
  * @return void
  */
 public function editAction()
 {
     $this->view->headScript()->appendFile($this->view->locateFile('profile.js'));
     $imageSrc = "";
     $id = (int) $this->_getParam($this->_ID);
     $page = (int) $this->_getParam('page');
     $baseDir = $this->view->baseUrl() . "/";
     $cancelUrl = $baseDir;
     $returnModule = $this->_getParam('returnModule');
     $returnAction = $this->_getParam('returnAction');
     if (!empty($returnModule)) {
         $cancelUrl .= $returnModule . '/';
     } else {
         $cancelUrl .= $this->_moduleTitle . "/";
     }
     $cancelUrl .= $this->_name . "/";
     if (!empty($returnAction)) {
         $cancelUrl .= $returnAction . '/';
     } else {
         $cancelUrl .= 'general/';
     }
     $cancelUrl .= "page/" . $page;
     $config = Zend_Registry::get('config');
     $current_state = $config->address->default->states;
     $currentCity = '';
     $this->view->assign('selectedState', $current_state);
     $oDataName = $this->_objectList[$this->_currentAction];
     $oData = new $oDataName();
     if ($this->view->aclIsAllowed($this->_moduleTitle, 'edit', true)) {
         $this->view->id = $id;
         if ($this->_isXmlHttpRequest) {
             $this->disableLayout();
         } else {
             if (!empty($returnModule)) {
                 Cible_View_Helper_LastVisited::emptyUrls();
             }
             $url = $this->view->absolute_web_root . $this->getRequest()->getPathInfo();
             Cible_View_Helper_LastVisited::saveThis($url);
             $urls = Cible_View_Helper_LastVisited::getLastVisited();
             if (count($urls) > 1) {
                 $this->view->urlBack = $this->view->baseUrl() . $urls[1];
             }
         }
         $returnUrl = $this->_moduleTitle . "/" . $this->_name . "/" . $this->_currentAction . "/" . "page/" . $page;
         // Get data details
         $data = $oData->populate($id, $this->_defaultEditLanguage);
         // image src.
         if (!empty($data[$this->_imageSrc])) {
             $config = Zend_Registry::get('config')->toArray();
             $thumbMaxHeight = $config[$this->_moduleTitle]['image']['thumb']['maxHeight'];
             $thumbMaxWidth = $config[$this->_moduleTitle]['image']['thumb']['maxWidth'];
             $this->view->assign('imageUrl', $this->_rootImgPath . $id . "/" . str_replace($data[$this->_imageSrc], $thumbMaxWidth . 'x' . $thumbMaxHeight . '_' . $data[$this->_imageSrc], $data[$this->_imageSrc]));
             $isNewImage = 'false';
             if ($this->_request->isPost()) {
                 $formData = $this->_request->getPost();
                 if ($formData[$this->_imageSrc] != $data[$this->_imageSrc]) {
                     if ($formData[$this->_imageSrc] == "") {
                         $imageSrc = $this->view->baseUrl() . "/icons/image_non_ disponible.jpg";
                     } else {
                         $imageSrc = $this->_rootImgPath . $id . "/tmp/mcith/mcith_" . $formData[$this->_imageSrc];
                     }
                     $isNewImage = 'true';
                 } else {
                     if ($data[$this->_imageSrc] == "") {
                         $imageSrc = $this->view->baseUrl() . "/icons/image_non_ disponible.jpg";
                     } else {
                         $imageSrc = $this->_rootImgPath . $id . "/" . str_replace($data[$this->_imageSrc], $thumbMaxWidth . 'x' . $thumbMaxHeight . '_' . $data[$this->_imageSrc], $data[$this->_imageSrc]);
                     }
                 }
             } else {
                 if (empty($data[$this->_imageSrc])) {
                     $imageSrc = $this->view->baseUrl() . "/icons/image_non_ disponible.jpg";
                 } else {
                     $imageSrc = $this->_rootImgPath . $id . "/" . str_replace($data[$this->_imageSrc], $thumbMaxWidth . 'x' . $thumbMaxHeight . '_' . $data[$this->_imageSrc], $data[$this->_imageSrc]);
                 }
             }
         }
         // generate the form
         $options = array('moduleName' => $this->_moduleTitle . "/" . $this->_objectList[$this->_currentAction], 'baseDir' => $baseDir, 'cancelUrl' => $cancelUrl, 'imageSrc' => $imageSrc, 'imgField' => $this->_imageSrc, 'dataId' => $id, 'data' => $data, 'mode' => 'edit', 'isNewImage' => 'true');
         if ($this->_isXmlHttpRequest) {
             $options['object'] = $oData;
         }
         $form = new $this->_formName($options);
         //            if (!empty($this->_oMember))
         //            {
         //                $memberData = $this->_oMember->getAll(null, true, $id);
         //                if (!empty($memberData))
         //                {
         //                    $memberForm = new FormMembersProfile();
         //                    $memberForm->populate($memberData[0]);
         //                    $form->addSubForm($memberForm, 'memberForm');
         //                    $form->getSubForm('memberForm')->setAttrib('class','DtDdWrapper');
         //
         //                    if ($this->_request->isPost())
         //                    {
         //                        $form->getSubForm('memberForm')->populate($data);
         //                    }
         //                }
         //            }
         $this->view->form = $form;
         // Load data from profiles to build the tabs
         $tabsList = array();
         if (!$this->_isXmlHttpRequest) {
             $objects = $this->_objectList;
             unset($objects[$this->_currentAction]);
             $tabForm = null;
             foreach ($objects as $key => $objName) {
                 $obj = new $objName();
                 $isActive = $obj->findData(array($obj->getForeignKey() => $id));
                 $status = null;
                 if (isset($isActive['MP_Status'])) {
                     $status = $isActive['MP_Status'];
                 }
                 if (count($isActive) > 0 && $status != -2) {
                     $action = $key . 'Action';
                     $params = $this->{$action}(true);
                     //                        $this->getLogData($id, $key);
                     //                        $this->view->assign('log', $logData);
                     $tabForm = new $params['formName'](array('moduleName' => $this->_moduleTitle . "/" . $key, 'baseDir' => $baseDir, 'cancelUrl' => $cancelUrl, 'imageSrc' => $imageSrc, 'imgField' => $this->_imageSrc, 'dataId' => $id, 'object' => $obj, 'data' => $data, 'mode' => 'edit', 'isNewImage' => 'true'));
                     $tabForm->populate($isActive);
                     array_push($tabsList, array($key, $tabForm));
                 }
             }
         }
         $this->view->assign('tabsList', $tabsList);
         // action
         if (!$this->_request->isPost()) {
             $form->populate($data);
             if ($this->_isXmlHttpRequest) {
                 $form->getElement('submitSave')->setAttrib('disabled', true);
                 $render = $this->_name . '/formRenderer.phtml';
                 echo $this->view->render($render);
                 exit;
             }
         } else {
             $addrOne = array();
             $addrTwo = array();
             $formData = $this->_request->getParams();
             if ($this->_formatData && isset($formData['data'])) {
                 $formData = $formData['data'];
                 $formData = $this->_mergeFormData($formData);
             }
             if (isset($formData[$oData->getFormDataName()])) {
                 $addrOne = $formData[$oData->getFormDataName()];
                 if (!empty($data[$oData->getAddressField()])) {
                     $formData[$oData->getAddressField()] = $data[$oData->getAddressField()];
                 } else {
                     $formData[$oData->getAddressField()] = '';
                 }
             }
             if (isset($formData['parentFormTwo']['duplicate'])) {
                 $addrTwo = $formData['parentFormTwo'];
                 if ($formData['parentFormTwo']['duplicate'] == 1) {
                     $subFormShip = $form->getSubForm('parentFormTwo');
                     foreach ($subFormShip as $key => $value) {
                         $value->clearValidators()->setRequired(false);
                     }
                     unset($formData['parentFormTwo']);
                 }
             }
             if ($form->isValid($formData)) {
                 if (empty($addrOne) && !$this->_formatData && !isset($formData['parentForm'])) {
                     $formData = $this->_mergeFormData($formData);
                 } else {
                     $formData['parentFormTwo'] = $addrTwo;
                 }
                 if (isset($formData['isNewImage']) && $formData['isNewImage'] == 'true' && $form->getValue($this->_imageSrc) != '') {
                     $config = Zend_Registry::get('config')->toArray();
                     $srcOriginal = $this->_imageFolder . $id . "/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 . $id . "/tmp/medium_" . $form->getValue($this->_imageSrc);
                     $mediumMaxHeight = $config[$this->_moduleTitle]['image']['medium']['maxHeight'];
                     $mediumMaxWidth = $config[$this->_moduleTitle]['image']['medium']['maxWidth'];
                     $mediumName = str_replace($form->getValue($this->_imageSrc), $mediumMaxWidth . 'x' . $mediumMaxHeight . '_' . $form->getValue($this->_imageSrc), $form->getValue($this->_imageSrc));
                     $srcThumb = $this->_imageFolder . $id . "/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, $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->_imageFolder . $id . "/" . $originalName);
                     rename($srcMedium, $this->_imageFolder . $id . "/" . $mediumName);
                     rename($srcThumb, $this->_imageFolder . $id . "/" . $thumbName);
                 }
                 $oData->save($id, $formData, $this->getCurrentEditLanguage());
                 if (!empty($this->_oMember)) {
                     $memberForm = $form->getSubForm('memberForm');
                     if (!empty($formData['MP_Password'])) {
                         $formData['MP_Password'] = md5($formData['MP_Password']);
                     } else {
                         $formData['MP_Password'] = $memberData[0]['MP_Password'];
                     }
                     $this->_oMember->save($id, $formData, $this->_currentEditLanguage);
                 }
                 if ($this->_isXmlHttpRequest) {
                     $this->disableView();
                     echo json_encode(true);
                 }
                 // redirect
                 //                    $this->_redirect($returnUrl);
             } else {
                 //                    $currentCity  = $formData['retailerForm[A_CityId]'][''];
                 if (isset($data['addressFact[A_StateId]'])) {
                     $current_state = $data['addressFact[A_StateId]'] . $this->_separ;
                     $current_state .= $data['addressShipping[A_StateId]'] . $this->_separ;
                     $current_state .= $data['retailerForm[A_StateId]'];
                     $this->view->assign('selectedSate', $current_state);
                 }
                 $this->disableView();
                 echo json_encode(false);
             }
         }
     }
 }
Example #12
0
 public function editAction()
 {
     // web page title
     $this->view->title = "Modification d'un produit";
     // variables
     $recordID = (int) $this->_getParam($this->_paramId);
     $returnAction = $this->_getParam('return');
     $baseDir = $this->view->baseUrl();
     $lang = $this->_getParam('lang');
     if (!$lang) {
         $this->_registry->currentEditLanguage = $this->_defaultEditLanguage;
     }
     $langId = (int) $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 . "/";
         }
         $oCollections = new ProductsObject();
         $collectionData = $oCollections->getAll($langId, true);
         $this->view->assign('collectionData', $collectionData);
         // get products details
         $oData = new ProductsObject();
         $record = $oData->populate($recordID, $langId);
         // image src.
         $config = Zend_Registry::get('config')->toArray();
         $thumbMaxHeight = $config[$this->_moduleTitle]['image']['thumb']['maxHeight'];
         $thumbMaxWidth = $config[$this->_moduleTitle]['image']['thumb']['maxWidth'];
         if (!empty($record[$this->_imageSrc])) {
             $this->view->assign('imageUrl', $this->_rootImgPath . $recordID . "/" . str_replace($record[$this->_imageSrc], $thumbMaxWidth . 'x' . $thumbMaxHeight . '_' . $record[$this->_imageSrc], $record[$this->_imageSrc]));
             $isNewImage = 'false';
         }
         if ($this->_request->isPost()) {
             $formData = $this->_request->getPost();
             if ($formData[$this->_imageSrc] != $record[$this->_imageSrc]) {
                 if ($formData[$this->_imageSrc] == "") {
                     $imageSrc = $this->view->baseUrl() . "/icons/image_non_ disponible.jpg";
                 } else {
                     $imageSrc = $this->_rootImgPath . $recordID . "/tmp/mcith/mcith_" . $formData[$this->_imageSrc];
                 }
                 $isNewImage = 'true';
             } else {
                 if ($record[$this->_imageSrc] == "") {
                     $imageSrc = $this->view->baseUrl() . "/icons/image_non_ disponible.jpg";
                 } else {
                     $imageSrc = $this->_rootImgPath . $recordID . "/" . str_replace($record[$this->_imageSrc], $thumbMaxWidth . 'x' . $thumbMaxHeight . '_' . $record[$this->_imageSrc], $record[$this->_imageSrc]);
                 }
             }
         } else {
             if (empty($record[$this->_imageSrc])) {
                 $imageSrc = $this->view->baseUrl() . "/icons/image_non_ disponible.jpg";
             } else {
                 $imageSrc = $this->_rootImgPath . $recordID . "/" . str_replace($record[$this->_imageSrc], $thumbMaxWidth . 'x' . $thumbMaxHeight . '_' . $record[$this->_imageSrc], $record[$this->_imageSrc]);
             }
         }
         // generate the form
         $form = new FormProducts(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()) {
             $association = new ProductsAssociationData();
             $selectAssociation = $association->select();
             $selectAssociation->where("AP_MainProductID = ?", $recordID);
             $associationFind = $association->fetchAll($selectAssociation)->toArray();
             $collectionChoice = array();
             foreach ($associationFind as $association) {
                 $collectionChoice[] = $association['AP_RelatedProductID'];
             }
             $this->view->assign('collectionChoice', $collectionChoice);
             $oItem = new ItemsObject();
             $itemList = $oItem->getAssociatedItems($recordID, $langId);
             $this->view->assign('renderItemsList', $itemList);
             $form->populate($record);
         } else {
             $formData = $this->_request->getPost();
             if ($form->isValid($formData)) {
                 $oData = new ProductsObject();
                 $newData = array_merge($formData['productFormLeft'], $formData['productFormRight'], $formData['productFormBotPub'], $formData['productFormBotPro']);
                 $formattedName = Cible_FunctionsGeneral::formatValueForUrl($newData['PI_Name']);
                 $newData['PI_ValUrl'] = $formattedName;
                 $oData->save($recordID, $newData, $langId);
                 // DELETE ASSOCIATION
                 $association = new ProductsAssociationData();
                 $where = "AP_MainProductID = " . $recordID;
                 $association->delete($where);
                 // ADD Association
                 if (array_key_exists("collectionSet", $formData)) {
                     foreach ($formData['collectionSet'] as $collectionID) {
                         $oAssociation = new ProductsAssociationData();
                         $associateData = $oAssociation->createRow();
                         $associateData->AP_MainProductID = $recordID;
                         $associateData->AP_RelatedProductID = $collectionID;
                         $associateData->save();
                     }
                 }
                 $newImage = $form->getSubForm('productFormRight')->getValue('isNewImage');
                 if ($newImage && $newData[$this->_imageSrc] != '') {
                     $config = Zend_Registry::get('config')->toArray();
                     $srcOriginal = $this->_imageFolder . $recordID . "/tmp/" . $newData[$this->_imageSrc];
                     $originalMaxHeight = $config[$this->_moduleTitle]['image']['original']['maxHeight'];
                     $originalMaxWidth = $config[$this->_moduleTitle]['image']['original']['maxWidth'];
                     $originalName = str_replace($newData[$this->_imageSrc], $originalMaxWidth . 'x' . $originalMaxHeight . '_' . $newData[$this->_imageSrc], $newData[$this->_imageSrc]);
                     $srcMedium = $this->_imageFolder . $recordID . "/tmp/medium_" . $newData[$this->_imageSrc];
                     $mediumMaxHeight = $config[$this->_moduleTitle]['image']['medium']['maxHeight'];
                     $mediumMaxWidth = $config[$this->_moduleTitle]['image']['medium']['maxWidth'];
                     $mediumName = str_replace($newData[$this->_imageSrc], $mediumMaxWidth . 'x' . $mediumMaxHeight . '_' . $newData[$this->_imageSrc], $newData[$this->_imageSrc]);
                     $srcThumb = $this->_imageFolder . $recordID . "/tmp/thumb_" . $newData[$this->_imageSrc];
                     $thumbMaxHeight = $config[$this->_moduleTitle]['image']['thumb']['maxHeight'];
                     $thumbMaxWidth = $config[$this->_moduleTitle]['image']['thumb']['maxWidth'];
                     $thumbName = str_replace($newData[$this->_imageSrc], $thumbMaxWidth . 'x' . $thumbMaxHeight . '_' . $newData[$this->_imageSrc], $newData[$this->_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->_imageFolder . $recordID . "/" . $originalName);
                     rename($srcMedium, $this->_imageFolder . $recordID . "/" . $mediumName);
                     rename($srcThumb, $this->_imageFolder . $recordID . "/" . $thumbName);
                 }
                 if ($formData['Status'] == 0) {
                     $formData['Status'] = 2;
                 }
                 // redirect
                 if (isset($formData['submitSaveClose'])) {
                     $this->_redirect($returnUrl);
                 } else {
                     $this->_redirect($this->_moduleTitle . "/" . $this->_name . "/edit/productID/" . $recordID);
                 }
             } else {
                 if (array_key_exists("collectionSet", $formData)) {
                     $this->view->assign('collectionChoice', $formData['collectionSet']);
                 } else {
                     $this->view->assign('collectionChoice', array());
                 }
                 $form->populate($record);
             }
         }
     }
 }