/** * Renders the given Basket to the Template * This Method will not replace the Subpart, you have to replace your * subpart in your template by you own. * * @param Basket $basketObj Basket * @param string $subpartTemplate Subpart Template Subpart * @param array|bool $articletypes Articletypes * @param string $lineTemplate Line templates * * @return string $content HTML-Ccontent from the given Subpart */ public function makeBasketView(Basket $basketObj, $subpartTemplate, array $articletypes = array(), $lineTemplate = '###LISTING_ARTICLE###') { $template = $this->cObj->getSubpart($this->templateCode, $subpartTemplate); if (!is_array($lineTemplate)) { $temp = $lineTemplate; $lineTemplate = array(); $lineTemplate[] = $temp; } else { /* * Check if the subpart is existing, and if not, remove from array */ $tmpArray = array(); foreach ($lineTemplate as $subpartMarker) { $subpartContent = $this->cObj->getSubpart($template, $subpartMarker); if (!empty($subpartContent)) { $tmpArray[] = $subpartMarker; } } $lineTemplate = $tmpArray; unset($tmpArray); } $templateElements = count($lineTemplate); if ($templateElements) { /* * Get All Articles in this basket and genarte HTMl-Content per row */ $articleLines = ''; $count = 0; /** * Item. * * @var BasketItem $basketItem */ foreach ($basketObj->getBasketItems() as $basketItem) { $part = $count % $templateElements; if (is_array($articletypes) && !empty($articletypes)) { if (in_array($basketItem->getArticleTypeUid(), $articletypes)) { $articleLines .= $this->makeLineView($basketItem, $lineTemplate[$part]); } } else { $articleLines .= $this->makeLineView($basketItem, $lineTemplate[$part]); } ++$count; } $content = $this->cObj->substituteSubpart($template, '###LISTING_ARTICLE###', $articleLines); // Unset Subparts, if not used foreach ($lineTemplate as $subpartMarker) { $content = $this->cObj->substituteSubpart($content, $subpartMarker, ''); } } else { $content = $this->cObj->substituteSubpart($template, '###LISTING_ARTICLE###', ''); } $hooks = HookFactory::getHooks('Controller/BaseController', 'makeBasketView'); foreach ($hooks as $hook) { if (method_exists($hook, 'postBasketView')) { $content = $hook->postBasketView($content, $articletypes, $lineTemplate, $template, $basketObj, $this); } } $content = $this->cObj->substituteSubpart($content, '###LISTING_BASKET_WEB###', $this->makeBasketInformation($basketObj, '###LISTING_BASKET_WEB###')); return $content; }