Example #1
0
 /**
  * Method for generating the rootlineMenu to use in TS.
  *
  * @param string $content Passed to method
  * @param array $conf TS Array
  *
  * @return array for the menurendering of TYPO3
  */
 public function renderRootline($content, array $conf)
 {
     $this->mConf = $this->processConf($conf);
     $this->pid = (int) ($this->mConf['overridePid'] ? $this->mConf['overridePid'] : $this->getFrontendController()->id);
     $this->entryLevel = (int) $this->mConf['entryLevel'];
     $this->gpVars = GeneralUtility::_GPmerged($this->prefixId);
     \CommerceTeam\Commerce\Utility\GeneralUtility::initializeFeUserBasket();
     $this->gpVars['basketHashValue'] = $this->getBasket()->getBasketHashValue();
     if (!is_object($this->category)) {
         $this->category = GeneralUtility::makeInstance('CommerceTeam\\Commerce\\Domain\\Model\\Category', $this->mConf['category'], $this->getFrontendController()->sys_language_uid);
         $this->category->loadData();
     }
     $returnArray = array();
     $returnArray = $this->getCategoryRootlineforTypoScript((int) $this->gpVars['catUid'], $returnArray);
     /*
      * Add product to rootline, if a product is displayed and showProducts
      * is set via TS
      */
     if ($this->mConf['showProducts'] == 1 && $this->gpVars['showUid'] > 0) {
         /**
          * Product.
          *
          * @var \CommerceTeam\Commerce\Domain\Model\Product $product
          */
         $product = GeneralUtility::makeInstance('CommerceTeam\\Commerce\\Domain\\Model\\Product', $this->gpVars['showUid'], $this->getFrontendController()->sys_language_uid);
         $product->loadData();
         /**
          * Category.
          *
          * @var \CommerceTeam\Commerce\Domain\Model\Category $category
          */
         $category = GeneralUtility::makeInstance('CommerceTeam\\Commerce\\Domain\\Model\\Category', $this->gpVars['catUid'], $this->getFrontendController()->sys_language_uid);
         $category->loadData();
         $addGetvars = $this->separator . $this->prefixId . '[showUid]=' . $product->getUid() . $this->separator . $this->prefixId . '[catUid]=' . $category->getUid();
         if (is_string($this->gpVars['basketHashValue'])) {
             $addGetvars .= $this->separator . $this->prefixId . '[basketHashValue]=' . $this->gpVars['basketHashValue'];
         }
         $cHash = $this->generateChash($addGetvars . $this->getFrontendController()->linkVars);
         /*
          * Currently no Navtitle in tx_commerce_products
          * 'nav_title' => $ProductObject->get_navtitle(),
          */
         if ($product->getUid() == $this->gpVars['showUid']) {
             $itemState = 'CUR';
             $itemStateList = 'CUR,NO';
         } else {
             $itemState = 'NO';
             $itemStateList = 'NO';
         }
         $returnArray[] = array('uid' => $this->pid, '_ADD_GETVARS' => $addGetvars . $this->separator . 'cHash=' . $cHash, 'ITEM_STATE' => $itemState, 'ITEM_STATES_LIST' => $itemStateList, 'title' => $product->getTitle(), '_PAGES_OVERLAY' => $product->getTitle());
     }
     if ($this->entryLevel) {
         for ($i = 0; $i < $this->entryLevel; $i++) {
             array_shift($returnArray);
         }
     }
     return $returnArray;
 }
Example #2
0
 /**
  * Inits the main params for using in the script.
  *
  * @param array $conf Configuration
  *
  * @return void
  */
 public function init(array $conf = array())
 {
     parent::init($conf);
     // Merge default vars, if other prefix_id
     if ($this->prefixId != 'tx_commerce_pi1') {
         $generellRequestVars = GeneralUtility::_GP('tx_commerce');
         if (is_array($generellRequestVars)) {
             foreach ($generellRequestVars as $key => $value) {
                 if (empty($this->piVars[$key])) {
                     $this->piVars[$key] = $value;
                 }
             }
         }
     }
     $hooks = HookFactory::getHooks('Controller/ListController', 'init');
     foreach ($hooks as $hook) {
         if (method_exists($hook, 'preInit')) {
             $hook->preInit($this);
         }
     }
     $this->conf['singleProduct'] = (int) $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'product_id', 's_product');
     if ($this->conf['singleProduct'] > 0) {
         // product UID was set by Plugin or TS
         $this->singleViewAsPlugin = true;
     }
     // Unset variable, if smaller than 0, as -1 is returend
     // when no product is selcted in form.
     if ($this->conf['singleProduct'] < 0) {
         $this->conf['singleProduct'] = false;
     }
     $this->piVars['showUid'] = intval($this->piVars['showUid']) ?: 0;
     $this->piVars['showUid'] = $this->piVars['showUid'] ?: $this->conf['singleProduct'];
     $this->handle = $this->piVars['showUid'] ? 'singleView' : 'listView';
     // Define the currency
     // Use of curency is depricated as it was only a typo :-)
     if ($this->conf['curency'] > '') {
         $this->currency = $this->conf['curency'];
     }
     if ($this->conf['currency'] > '') {
         $this->currency = $this->conf['currency'];
     }
     if (empty($this->currency)) {
         $this->currency = 'EUR';
     }
     // Set some flexform values
     $this->master_cat = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'StartCategory', 's_product');
     if (!$this->master_cat) {
         $this->master_cat = $this->conf['catUid'];
     }
     if ($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'listPid', 's_template')) {
         $this->conf['listPid'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'listPid', 's_template');
     }
     if ($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'singlePid', 's_template')) {
         $this->conf['singlePid'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'singlePid', 's_template');
     }
     // @deprecated flexform value to be removed in 5.0.0
     if ($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'displayPID', 's_template')) {
         $this->conf['overridePid'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'displayPID', 's_template');
     }
     if ($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'numberOfTopproducts', 's_product')) {
         $this->conf['numberOfTopproducts'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'numberOfTopproducts', 's_product');
     }
     if ($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'showPageBrowser', 's_template')) {
         $this->conf['showPageBrowser'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'showPageBrowser', 's_template');
     }
     if ($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'maxRecords', 's_template')) {
         $this->conf['maxRecords'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'maxRecords', 's_template');
     }
     if ($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'maxPages', 's_template')) {
         $this->conf['maxPages'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'maxPages', 's_template');
     }
     if ($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'basketPid', 's_template')) {
         $this->conf['basketPid'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'basketPid', 's_template');
     }
     if ($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'dontLinkActivePage', 's_template')) {
         $this->conf['pageBrowser.']['dontLinkActivePage'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'dontLinkActivePage', 's_template');
     }
     if ($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'showFirstLast', 's_template')) {
         $this->conf['pageBrowser.']['showFirstLast'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'showFirstLast', 's_template');
     }
     if ($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'showRange', 's_template')) {
         $this->conf['pageBrowser.']['showRange'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'showRange', 's_template');
     }
     if ($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'showItemCount', 's_template')) {
         $this->conf['pageBrowser.']['showItemCount'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'showItemCount', 's_template');
     }
     if ($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'hscText', 's_template')) {
         $this->conf['pageBrowser.']['hscText'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'hscText', 's_template');
     }
     if ($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'template', 's_template') && file_exists($this->templateFolder . $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'template', 's_template'))) {
         $this->conf['templateFile'] = $this->templateFolder . $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'template', 's_template');
         if ($this->cObj->fileResource($this->conf['templateFile'])) {
             $this->templateCode = $this->cObj->fileResource($this->conf['templateFile']);
         }
     }
     $accessible = false;
     /**
      * Temporary category.
      *
      * @var Category
      */
     $tmpCategory = null;
     if ($this->piVars['catUid']) {
         $this->cat = (int) $this->piVars['catUid'];
         $tmpCategory = GeneralUtility::makeinstance('CommerceTeam\\Commerce\\Domain\\Model\\Category', $this->cat, $this->getFrontendController()->sys_language_uid);
         $accessible = $tmpCategory->isAccessible();
     }
     // Validate given catUid, if it's given and accessible
     if (!$this->piVars['catUid'] || !$accessible) {
         $this->cat = (int) $this->master_cat;
         $tmpCategory = GeneralUtility::makeinstance('CommerceTeam\\Commerce\\Domain\\Model\\Category', $this->cat, $this->getFrontendController()->sys_language_uid);
     }
     if (!isset($this->piVars['catUid'])) {
         $this->piVars['catUid'] = $this->master_cat;
     }
     if (is_object($tmpCategory)) {
         $tmpCategory->loadData();
     }
     $this->category = $tmpCategory;
     $categorySubproducts = $this->category->getProductUids();
     $frontend = $this->getFrontendController();
     if (!$this->conf['singleProduct'] && (int) $this->piVars['showUid'] && !$this->getFrontendController()->beUserLogin) {
         if (is_array($categorySubproducts)) {
             if (!in_array($this->piVars['showUid'], $categorySubproducts)) {
                 $categoryAllSubproducts = $this->category->getProducts();
                 if (!in_array((int) $this->piVars['showUid'], $categoryAllSubproducts)) {
                     // The requested product is not beblow the selected category
                     // So exit with page not found
                     $frontend->pageNotFoundAndExit($this->pi_getLL('error.productNotFound', 'Product not found', 1));
                 }
             }
         } else {
             $categoryAllSubproducts = $this->category->getProducts();
             if (!in_array($this->piVars['showUid'], $categoryAllSubproducts)) {
                 // The requested product is not beblow the selected category
                 // So exit with page not found
                 $frontend->pageNotFoundAndExit($this->pi_getLL('error.productNotFound', 'Product not found', 1));
             }
         }
     }
     if ($this->piVars['catUid'] && $this->conf['checkCategoryTree'] == 1) {
         // Validate given CAT UID, if is below master_cat
         $this->masterCategoryObj = GeneralUtility::makeinstance('CommerceTeam\\Commerce\\Domain\\Model\\Category', $this->master_cat, $this->getFrontendController()->sys_language_uid);
         $this->masterCategoryObj->loadData();
         /*
          * Master category
          *
          * @var Category masterCategoryObj
          */
         $masterCategorySubCategories = $this->masterCategoryObj->getChildCategoriesUidlist();
         if (in_array($this->piVars['catUid'], $masterCategorySubCategories)) {
             $this->cat = (int) $this->piVars['catUid'];
         } else {
             // Wrong UID, so start with page not found
             $frontend->pageNotFoundAndExit($this->pi_getLL('error.categoryNotFound', 'Product not found', 1));
         }
     } elseif (!isset($this->piVars['catUid'])) {
         $this->cat = (int) $this->master_cat;
     }
     if ($this->cat != $this->category->getUid()) {
         // Only, if the category has been changed
         unset($this->category);
         /*
          * Category
          *
          * @var Category category
          */
         $this->category = GeneralUtility::makeinstance('CommerceTeam\\Commerce\\Domain\\Model\\Category', $this->cat, $this->getFrontendController()->sys_language_uid);
         $this->category->loadData();
     }
     $this->internal['results_at_a_time'] = $this->conf['maxRecords'];
     $this->internal['maxPages'] = $this->conf['maxPages'];
     // Going the long way ??? Just for list view
     $long = 1;
     switch ($this->handle) {
         case 'singleView':
             if ($this->initSingleView($this->piVars['showUid'])) {
                 $long = 0;
             }
             break;
         default:
     }
     if ($this->cat > 0) {
         $this->category_array = $this->category->returnAssocArray();
         $catConf = $this->category->getTyposcriptConfig();
         if (is_array($catConf['catTS.'])) {
             \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($this->conf, $catConf['catTS.']);
         }
         if ($long) {
             $this->category->setPageTitle();
             $this->category->getChildCategories();
             if ($this->conf['groupProductsByCategory']) {
                 $this->category_products = $this->category->getProducts(0);
             } elseif ($this->conf['showProductsRecLevel']) {
                 $this->category_products = $this->category->getProducts($this->conf['showProductsRecLevel']);
             } else {
                 $this->category_products = $this->category->getProducts(0);
             }
             if ($this->conf['useStockHandling'] == 1) {
                 $this->category_products = \CommerceTeam\Commerce\Utility\GeneralUtility::removeNoStockProducts($this->category_products, $this->conf['products.']['showWithNoStock']);
             }
             $this->internal['res_count'] = count($this->category_products);
         }
     } else {
         $this->content = $this->cObj->stdWrap($this->conf['emptyCOA'], $this->conf['emptyCOA.']);
         $this->handle = false;
     }
     foreach ($hooks as $hook) {
         if (method_exists($hook, 'postInit')) {
             $hook->postInit($this);
         }
     }
 }