public function getDetails($id, $itemId = 0, $resume = false) { $products = array(); $originalId = 0; $oProduct = new ProductsObject(); $oItem = new ItemsObject(); if ($resume) { $oItem->setRenderResume($resume); } $products['data'] = $oProduct->populate($id, Zend_Registry::get('languageID')); $hasBonus = $products['data']['P_CumulPoint']; if (!$this->_bonus && $hasBonus) { $this->_bonus = $hasBonus; } if ($itemId) { $products['items'] = $oItem->populate($itemId, Zend_Registry::get('languageID')); } return $products; }
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); } } } }
/** * Build the breadcrumd for the catalog page. * * @param int $lang <Optional> Id of the current language * * @return string */ public function breadcrumbCatalog($level = 1, $showHome = true, $langId = null) { if ($langId == null) { $langId = Zend_Registry::get('languageID'); } $_baseUrl = Zend_Registry::get('baseUrl'); $_breadcrumb = array(); $_first = true; $pathInfo = $this->view->request->getPathInfo(); $oProducts = new ProductsCollection(); $oProducts->setActions($pathInfo); $oProducts->getDataByName(); $catId = $oProducts->getCatId(); $subCatId = $oProducts->getSubCatId(); $prodId = $oProducts->getProdId(); if ($catId == null && $subCatId == null && $prodId == null) { $_breadcrumb = $this->view->breadcrumb(true) . "<b>" . $this->view->selectedPage . "</b>"; return $_breadcrumb; } else { $pathElemts = $oProducts->getActions(); if ($prodId) { $_class = ''; $product = new ProductsObject(); $details = $product->populate($prodId, $langId); if ($_first) { $_class = 'current_page'; } $link = $_first ? "<b>" . $details['PI_Name'] . "</b>" : "<a href='{$_baseUrl}/{$this->view->selectedPage}/{$pathElemts[0]}/{$pathElemts[1]}/{$pathElemts[2]}' class='{$_class}'>{$details['PI_Name']}</a>"; array_push($_breadcrumb, $link); if ($_first) { $_first = false; } } if ($subCatId) { $_class = ''; $object = new SubCategoriesObject(); $details = $object->populate($subCatId, $langId); if ($_first) { $_class = 'current_page'; } $link = $_first ? "<b>" . $details['SCI_Name'] . "</b>" : "<a href='{$_baseUrl}/{$this->view->selectedPage}/{$pathElemts[0]}/{$pathElemts[1]}' class='{$_class}'>{$details['SCI_Name']}</a>"; array_push($_breadcrumb, $link); if ($_first) { $_first = false; } } if ($catId) { $_class = ''; $object = new CatalogCategoriesObject(); $details = $object->populate($catId, $langId); if ($_first) { $_class = 'current_page'; } $link = $_first ? "<b>" . $details['CCI_Name'] . "</b>" : "<a href='{$_baseUrl}/{$this->view->selectedPage}/{$pathElemts[0]}' class='{$_class}'>{$details['CCI_Name']}</a>"; array_push($_breadcrumb, $link); if ($_first) { $_first = false; } } $details = Cible_FunctionsPages::getPageDetails($this->view->currentPageID, $langId); $link = $_first ? '' : "<a href='{$_baseUrl}/{$details['PI_PageIndex']}' class='{$_class}'>{$details['PI_PageTitle']}</a>"; array_push($_breadcrumb, $link); if ($showHome) { $homeDetails = Cible_FunctionsPages::getHomePageDetails(); $link = "<a href='{$_baseUrl}/{$homeDetails['PI_PageIndex']}' class='{$_class}'>" . $homeDetails['PI_PageTitle'] . "</a>"; array_push($_breadcrumb, $link); } $_breadcrumb = array_reverse($_breadcrumb); //var_dump($_breadcrumb); // for($i=0;$i<$level;$i++){ // array_splice($_breadcrumb,$i+1,1); // } // add the > after the breadcrumb when only on item is found if (count($_breadcrumb) == 1) { return "{$_breadcrumb[0]} > "; } else { return implode(' > ', $_breadcrumb); } } }