/** * Fecth data to set banner values and render it. * * @return string */ public function bannerRenderer($groupId = null, $autoPlay = null, $delais = null, $transition = null, $navi = null, $effect = null) { $imageGroupIndex = 0; $currentLang = Zend_Registry::get('languageID'); $cat_image = ""; $sousCat_image = ""; $page_image = ""; $imageToShow = ""; $textToShow = ""; if (Zend_Registry::isRegistered('subCatId_')) { $sousCat_ID = Zend_Registry::get('subCatId_'); $object = new SubCategoriesObject(); $details = $object->populate($sousCat_ID, $currentLang); if (isset($details['SC_BannerGroupID'])) { $sousCat_image = $details['SC_BannerGroupID']; } } if (Zend_Registry::isRegistered('catId_') && Zend_Registry::get('catId_') > 0) { $cat_ID = Zend_Registry::get('catId_'); $object = new CatalogCategoriesObject(); $details = $object->populate($cat_ID, $currentLang); if (isset($details['C_BannerGroupID'])) { $cat_image = $details['C_BannerGroupID']; } } if (Zend_Registry::isRegistered('bannerGroupImage')) { $page_image = Zend_Registry::get('bannerGroupImage'); } if ($sousCat_image != "") { $imageGroupIndex = $sousCat_image; } else { if ($cat_image != "") { $imageGroupIndex = $cat_image; } else { if ($page_image) { $imageGroupIndex = $page_image; } elseif ($groupId) { $imageGroupIndex = $groupId; } } } $images = array(); if ($imageGroupIndex != 0) { $obj = new BannerImageObject(); $images = $obj->getImageToShow($imageGroupIndex); } if (count($images)) { $imageToShow = $images; } else { $imageToShow[0]['text'] = $this->view->getClientText('banner_default_text'); $imageToShow[0]['img'] = Zend_Registry::get("web_root") . "/themes/default/images/common/bg_home_header.jpg"; } $this->view->assign('imageToShow', $imageToShow); $this->view->assign('textToShow', $textToShow); $this->view->assign('autoPlay', $autoPlay); $this->view->assign('delais', $delais); $this->view->assign('transition', $transition); $this->view->assign('navi', $navi); $this->view->assign('effect', $effect); }
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); } } } } }
/** * List products according given parameters. * This list is only for display purpose. No actions except Excel export. * * @return void */ public function listAction() { $img = $this->_getParam('img'); if (!empty($img)) { $this->downloadAction(); exit; } $this->view->params['actions'] = $this->_request->getPathInfo(); /* List products */ $oProducts = new ProductsCollection($this->view->params); $products = $oProducts->getList(); $searchCount = count($products); /* Params */ $subCategoryId = 0; $blockParams = $oProducts->getBlockParams(); $categorieId = $oProducts->getCatId(); $productId = $oProducts->getProdId(); $url = $this->view->absolute_web_root . $this->getRequest()->getPathInfo(); Cible_View_Helper_LastVisited::saveThis($url); if (!$productId) { if (!$categorieId) { $categorieId = $blockParams[1]; } // Zend_Registry::set('bg-body-id', $categorieId); $subCategoryId = $oProducts->getSubCatId(); if ($subCategoryId) { $oSubCat = new SubCategoriesObject(); $subCat = $oSubCat->populate($subCategoryId, Zend_Registry::get('languageID')); $this->view->subCatName = $subCat['SCI_Name']; } $searchWords = isset($this->view->params['keywords']) && $this->view->params['keywords'] != $this->view->getCibleText('form_search_catalog_keywords_label') ? $this->view->params['keywords'] : ''; /* Search form */ // $searchForm = new FormSearchCatalogue( // array( // 'categorieId' => $categorieId, // 'subCategoryId' => $subCategoryId, // 'keywords' => $searchWords) // ); // // $this->view->assign('searchForm', $searchForm); $oCategory = new CatalogCategoriesObject(); $category = $oCategory->populate($categorieId, $this->_registry->languageID); $this->_registry->set('category', $category); $lastSearch = array(); if (!empty($subCategoryId)) { $lastSearch['sousCatId'] = $subCategoryId; } if (!empty($searchWords)) { $lastSearch['keywords'] = $searchWords; } $this->view->assign('searchUrl', $lastSearch); $page = 1; $paginator = new Zend_Paginator(new Zend_Paginator_Adapter_Array($products)); $paginator->setItemCountPerPage($oProducts->getLimit()); if (isset($this->view->params['productId'])) { $productId = $this->view->params['productId']; $this->view->assign('productId', $productId); foreach ($products as $product) { if ($product['P_ID'] != $productId) { $page++; } else { break; } } } $filter = $oProducts->getFilter(); $paramPage = $this->_request->getParam('page'); $page = isset($paramPage) ? $this->_request->getParam('page') : ceil($page / $paginator->getItemCountPerPage()); $paginator->setCurrentPageNumber($page); $this->view->assign('categoryId', $categorieId); $this->view->assign('params', $oProducts->getBlockParams()); $this->view->assign('paginator', $paginator); $this->view->assign('keywords', $searchWords); $this->view->assign('searchCount', $searchCount); $this->view->assign('filter', $filter); if (isset($category['CCI_ValUrl'])) { echo $this->_registry->set('selectedCatalogPage', $category['CCI_ValUrl']); } } else { $this->_registry->set('category', $this->_registry->get('catId_')); $this->_registry->set('productCase', '1'); $url = $this->view->absolute_web_root . $this->getRequest()->getPathInfo(); Cible_View_Helper_LastVisited::saveThis($url); $this->_registry->set('selectedCatalogPage', $products['CCI_ValUrl']); $this->view->assign('productDetails', $products); $this->renderScript('index/detail-product.phtml'); } }
/** * 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); } } }