Example #1
0
 /**
  * Makes the list view for the current categorys.
  *
  * @return string the content for the list view
  */
 public function makeListView()
 {
     /*
      * Category LIST
      */
     $categoryOutput = '';
     $this->template = $this->templateCode;
     if ($this->category->hasSubcategories()) {
         /**
          * Category.
          *
          * @var Category $oneCategory
          */
         foreach ($this->category->getChildCategories() as $oneCategory) {
             $oneCategory->loadData();
             $this->currentCategory =& $oneCategory;
             if ($this->conf['hideEmptyCategories'] == 1) {
                 // First check TS setting (ceap)
                 // afterwards do the recursive call (expensive)
                 if (!$oneCategory->hasProductsInSubCategories() || $this->conf['useStockHandling'] && !$oneCategory->hasProductsWithStock()) {
                     // This category is empty, so
                     // skip this iteration and do next
                     continue;
                 }
             }
             $linkArray = array();
             $linkArray['catUid'] = $oneCategory->getUid();
             $linkArray['showUid'] = '';
             if ($this->useRootlineInformationToUrl == 1) {
                 $linkArray['path'] = $this->getPathCat($oneCategory);
                 $linkArray['mDepth'] = $this->mDepth;
             } else {
                 $linkArray['mDepth'] = '';
                 $linkArray['path'] = '';
             }
             if ($this->basketHashValue) {
                 $linkArray['basketHashValue'] = $this->basketHashValue;
             }
             /*
              *  Build TS for Linking the Catergory Images
              */
             $localTs = $this->conf['categoryListView.']['categories.'];
             if ($this->conf['listPid']) {
                 $typoLinkConf['parameter'] = $this->conf['listPid'];
             } elseif ($this->conf['overridePid']) {
                 $typoLinkConf['parameter'] = $this->conf['overridePid'];
             } else {
                 $typoLinkConf['parameter'] = $this->pid;
             }
             $typoLinkConf['useCacheHash'] = 1;
             $typoLinkConf['additionalParams'] = $this->argSeparator . $this->prefixId . '[catUid]=' . $oneCategory->getUid();
             $productArray = $oneCategory->getProducts((int) $this->conf['groupProductsByCategoryMaxDepth']);
             if ($this->conf['displayProductIfOneProduct'] == 1 && count($productArray) == 1) {
                 $typoLinkConf['additionalParams'] .= $this->argSeparator . $this->prefixId . '[showUid]=' . $productArray[0];
             } else {
                 $typoLinkConf['additionalParams'] .= $this->argSeparator . $this->prefixId . '[showUid]=';
             }
             if ($this->useRootlineInformationToUrl == 1) {
                 $typoLinkConf['additionalParams'] .= $this->argSeparator . $this->prefixId . '[path]=' . $this->getPathCat($oneCategory);
                 $typoLinkConf['additionalParams'] .= $this->argSeparator . $this->prefixId . '[mDepth]=' . $this->mDepth;
             }
             if ($this->basketHashValue) {
                 $typoLinkConf['additionalParams'] .= $this->argSeparator . $this->prefixId . '[basketHashValue]=' . $this->basketHashValue;
             }
             $localTs['fields.']['images.']['stdWrap.']['typolink.'] = $typoLinkConf;
             $localTs['fields.']['teaserimages.']['stdWrap.']['typolink.'] = $typoLinkConf;
             $localTs = $this->addTypoLinkToTypoScript($localTs, $typoLinkConf);
             $tmpCategory = $this->renderCategory($oneCategory, '###CATEGORY_LIST_ITEM###', $localTs, 'ITEM');
             /*
              * Build the link
              *
              * @deprecated
              * Please use TYPOLINK instead
              */
             $linkContent = $this->cObj->getSubpart($tmpCategory, '###CATEGORY_ITEM_DETAILLINK###');
             if ($linkContent) {
                 $link = $this->pi_linkTP_keepPIvars($linkContent, $linkArray, true, 0, $this->conf['overridePid']);
             } else {
                 $link = '';
             }
             $tmpCategory = $this->cObj->substituteSubpart($tmpCategory, '###CATEGORY_ITEM_DETAILLINK###', $link);
             if ($this->conf['groupProductsByCategory'] && !$this->conf['hideProductsInList'] && !$this->conf['hideProductsInSubcategories']) {
                 if ($this->conf['useStockHandling'] == 1) {
                     $productArray = \CommerceTeam\Commerce\Utility\GeneralUtility::removeNoStockProducts($productArray, $this->conf['products.']['showWithNoStock']);
                 }
                 $productArray = array_slice($productArray, 0, $this->conf['numberProductsInSubCategory']);
                 $productList = $this->renderProductsForList($productArray, $this->conf['templateMarker.']['categoryProductList.'], $this->conf['templateMarker.']['categoryProductListIterations']);
                 /*
                  * Insert the Productlist
                  */
                 $tmpCategory = $this->cObj->substituteMarker($tmpCategory, '###CATEGORY_ITEM_PRODUCTLIST###', $productList);
             } else {
                 $tmpCategory = $this->cObj->substituteMarker($tmpCategory, '###CATEGORY_ITEM_PRODUCTLIST###', '');
             }
             $categoryOutput .= $tmpCategory;
         }
     }
     $categoryListSubpart = $this->cObj->getSubpart($this->template, '###CATEGORY_LIST###');
     $markerArray['CATEGORY_SUB_LIST'] = $this->cObj->substituteSubpart($categoryListSubpart, '###CATEGORY_LIST_ITEM###', $categoryOutput);
     $startPoint = $this->piVars['pointer'] ? $this->internal['results_at_a_time'] * $this->piVars['pointer'] : 0;
     // Display TopProducts???
     // for this, make a few basicSettings for pageBrowser
     $internalStartPoint = $startPoint;
     $internalResults = $this->internal['results_at_a_time'];
     // set Empty default
     $markerArray['SUBPART_CATEGORY_ITEMS_LISTVIEW_TOP'] = '';
     if (!$this->conf['groupProductsByCategory'] && $this->conf['displayTopProducts'] && $this->conf['numberOfTopproducts']) {
         $this->top_products = array_slice($this->category_products, $startPoint, $this->conf['numberOfTopproducts']);
         $internalStartPoint = $startPoint + $this->conf['numberOfTopproducts'];
         $internalResults = $this->internal['results_at_a_time'] - $this->conf['numberOfTopproducts'];
         $markerArray['SUBPART_CATEGORY_ITEMS_LISTVIEW_TOP'] = $this->renderProductsForList($this->top_products, $this->conf['templateMarker.']['categoryProductListTop.'], $this->conf['templateMarker.']['categoryProductListTopIterations'], $this->conf['topProductTSMarker']);
     }
     // ###################### product list ######################
     if (is_array($this->category_products)) {
         $this->category_products = array_slice($this->category_products, $internalStartPoint, $internalResults);
     }
     if (!$this->conf['hideProductsInList']) {
         if (isset($this->piVars['showUid'])) {
             $this->piVars['showUid'] = '';
         }
         // Write the current page to The session to have a back to last product link
         $this->getFrontendUser()->setKey('ses', 'tx_commerce_lastproducturl', $this->pi_linkTP_keepPIvars_url(array(), 1));
         $markerArray['SUBPART_CATEGORY_ITEMS_LISTVIEW'] = $this->renderProductsForList($this->category_products, (array) $this->conf['templateMarker.']['categoryProductList.'], $this->conf['templateMarker.']['categoryProductListIterations']);
     }
     $templateMarker = '###' . strtoupper($this->conf['templateMarker.']['categoryView']) . '###';
     $markerArrayCat = $this->generateMarkerArray($this->category->returnAssocArray(), (array) $this->conf['singleView.']['categories.'], 'category_', 'tx_commerce_categories');
     $markerArray = array_merge($markerArrayCat, $markerArray);
     if ($this->conf['showPageBrowser'] == 1 && count($this->category_products) > $this->conf['maxRecords'] && is_array($this->conf['pageBrowser.']['wraps.'])) {
         $this->internal['pagefloat'] = (int) $this->piVars['pointer'];
         $this->internal['dontLinkActivePage'] = $this->conf['pageBrowser.']['dontLinkActivePage'];
         $this->internal['showFirstLast'] = $this->conf['pageBrowser.']['showFirstLast'];
         $this->internal['showRange'] = $this->conf['pageBrowser.']['showRange'];
         $hscText = !($this->conf['pageBrowser.']['hscText'] != 1);
         $markerArray['CATEGORY_BROWSEBOX'] = $this->pi_list_browseresults($this->conf['pageBrowser.']['showItemCount'], $this->conf['pageBrowser.']['tableParams.'], $this->conf['pageBrowser.']['wraps.'], 'pointer', $hscText);
     } else {
         $markerArray['CATEGORY_BROWSEBOX'] = '';
     }
     $hooks = HookFactory::getHooks('Controller/BaseController', 'makeListView');
     foreach ($hooks as $hook) {
         if (method_exists($hook, 'additionalMarker')) {
             $markerArray = $hook->additionalMarker($markerArray, $this);
         }
     }
     $markerArray = $this->addFormMarker($markerArray);
     $template = $this->cObj->getSubpart($this->templateCode, $templateMarker);
     $content = $this->cObj->substituteMarkerArray($template, $markerArray, '###|###', 1);
     $content = $this->cObj->substituteMarkerArray($content, $this->languageMarker);
     return $content;
 }