/** * 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); } } }