Go to the documentation of this file.00001 <?php
00002
00008 class oxcmp_categories extends oxView
00009 {
00010
00016 protected $_oMoreCat = null;
00017
00023 protected $_blIsComponent = true;
00024
00030 protected $_oCategoryTree = null;
00031
00037 protected $_oManufacturerTree = null;
00038
00048 public function init()
00049 {
00050 parent::init();
00051
00052
00053 $myConfig = $this->getConfig();
00054 if ($myConfig->getConfigParam('blDisableNavBars') &&
00055 $myConfig->getTopActiveView()->getIsOrderStep()
00056 ) {
00057 return;
00058 }
00059
00060 $sActCat = $this->_getActCat();
00061
00062 if ($myConfig->getConfigParam('bl_perfLoadManufacturerTree')) {
00063
00064 $sActManufacturer = oxRegistry::getConfig()->getRequestParameter('mnid');
00065 $this->_loadManufacturerTree($sActManufacturer);
00066 }
00067
00068
00069 $this->_loadCategoryTree($sActCat);
00070 }
00071
00077 public function getProduct()
00078 {
00079 if (($sActProduct = oxRegistry::getConfig()->getRequestParameter('anid'))) {
00080 $oParentView = $this->getParent();
00081 if (($oProduct = $oParentView->getViewProduct())) {
00082 return $oProduct;
00083 } else {
00084 $oProduct = oxNew('oxarticle');
00085 if ($oProduct->load($sActProduct)) {
00086
00087 $oParentView->setViewProduct($oProduct);
00088
00089 return $oProduct;
00090 }
00091 }
00092 }
00093 }
00094
00100 protected function _getActCat()
00101 {
00102 $sActManufacturer = oxRegistry::getConfig()->getRequestParameter('mnid');
00103 $sActTag = oxRegistry::getConfig()->getRequestParameter('searchtag');
00104 $sActCat = $sActManufacturer ? null : oxRegistry::getConfig()->getRequestParameter('cnid');
00105
00106
00107 $oProduct = $this->getProduct();
00108 if ($oProduct) {
00109 $myConfig = $this->getConfig();
00110
00111 $sActManufacturer = $myConfig->getConfigParam('bl_perfLoadManufacturerTree') ? $sActManufacturer : null;
00112
00113 $sActVendor = (getStr()->preg_match('/^v_.?/i', $sActCat)) ? $sActCat : null;
00114
00115 $sActCat = $this->_addAdditionalParams($oProduct, $sActCat, $sActManufacturer, $sActTag, $sActVendor);
00116 }
00117
00118
00119 if ($sActCat === null && !$oProduct && !$sActManufacturer && !$sActTag) {
00120
00121 $sActCat = $this->getConfig()->getActiveShop()->oxshops__oxdefcat->value;
00122 if ($sActCat == 'oxrootid') {
00123
00124 $sActCat = null;
00125 }
00126 }
00127
00128 return $sActCat;
00129 }
00130
00136 protected function _loadCategoryTree($sActCat)
00137 {
00138 $oCategoryTree = oxNew('oxCategoryList');
00139 $oCategoryTree->buildTree($sActCat);
00140
00141 $oParentView = $this->getParent();
00142
00143
00144 $oParentView->setCategoryTree($oCategoryTree);
00145 $this->setCategoryTree($oCategoryTree);
00146
00147
00148 $oParentView->setActiveCategory($oCategoryTree->getClickCat());
00149 }
00150
00156 protected function _loadManufacturerTree($sActManufacturer)
00157 {
00158 $myConfig = $this->getConfig();
00159 if ($myConfig->getConfigParam('bl_perfLoadManufacturerTree')) {
00160 $oManufacturerTree = oxNew('oxmanufacturerlist');
00161 $shopHomeURL = $myConfig->getShopHomeURL();
00162 $oManufacturerTree->buildManufacturerTree('manufacturerlist', $sActManufacturer, $shopHomeURL);
00163
00164 $oParentView = $this->getParent();
00165
00166
00167 $oParentView->setManufacturerTree($oManufacturerTree);
00168 $this->setManufacturerTree($oManufacturerTree);
00169
00170
00171 if (($oManufacturer = $oManufacturerTree->getClickManufacturer())) {
00172 $oParentView->setActManufacturer($oManufacturer);
00173 }
00174 }
00175 }
00176
00183 public function render()
00184 {
00185 parent::render();
00186
00187
00188 $myConfig = $this->getConfig();
00189 $oParentView = $this->getParent();
00190
00191 if ($myConfig->getConfigParam('bl_perfLoadManufacturerTree') && $this->_oManufacturerTree) {
00192 $oParentView->setManufacturerlist($this->_oManufacturerTree);
00193 $oParentView->setRootManufacturer($this->_oManufacturerTree->getRootCat());
00194 }
00195
00196 if ($this->_oCategoryTree) {
00197 return $this->_oCategoryTree;
00198 }
00199 }
00200
00212 protected function _addAdditionalParams($oProduct, $sActCat, $sActManufacturer, $sActTag, $sActVendor)
00213 {
00214 $sSearchPar = oxRegistry::getConfig()->getRequestParameter('searchparam');
00215 $sSearchCat = oxRegistry::getConfig()->getRequestParameter('searchcnid');
00216 $sSearchVnd = oxRegistry::getConfig()->getRequestParameter('searchvendor');
00217 $sSearchMan = oxRegistry::getConfig()->getRequestParameter('searchmanufacturer');
00218 $sListType = oxRegistry::getConfig()->getRequestParameter('listtype');
00219
00220
00221 if ((!$sListType || $sListType == 'search') && ($sSearchPar || $sSearchCat || $sSearchVnd || $sSearchMan)) {
00222
00223 $sListType = 'search';
00224 } else {
00225
00226
00227 if ($sActManufacturer && ($sActManufacturer == $oProduct->getManufacturerId())) {
00228
00229 $sListType = 'manufacturer';
00230 $sActCat = $sActManufacturer;
00231 } elseif ($sActVendor && (substr($sActVendor, 2) == $oProduct->getVendorId())) {
00232
00233 $sListType = 'vendor';
00234 $sActCat = $sActVendor;
00235 } elseif ($sActTag) {
00236
00237 $sListType = 'tag';
00238 } elseif ($sActCat && $oProduct->isAssignedToCategory($sActCat)) {
00239
00240 } else {
00241 list($sListType, $sActCat) = $this->_getDefaultParams($oProduct);
00242 }
00243 }
00244
00245 $oParentView = $this->getParent();
00246
00247 $oParentView->setListType($sListType);
00248 $oParentView->setCategoryId($sActCat);
00249
00250 return $sActCat;
00251 }
00252
00260 protected function _getDefaultParams($oProduct)
00261 {
00262 $sListType = null;
00263 $aArticleCats = $oProduct->getCategoryIds(true);
00264 if (is_array($aArticleCats) && count($aArticleCats)) {
00265 $sActCat = reset($aArticleCats);
00266 } elseif (($sActCat = $oProduct->getManufacturerId())) {
00267
00268 $sListType = 'manufacturer';
00269 } elseif (($sActCat = $oProduct->getVendorId())) {
00270
00271 $sListType = 'vendor';
00272 } else {
00273 $sActCat = null;
00274 }
00275
00276 return array($sListType, $sActCat);
00277 }
00278
00284 public function setCategoryTree($oCategoryTree)
00285 {
00286 $this->_oCategoryTree = $oCategoryTree;
00287 }
00288
00294 public function setManufacturerTree($oManufacturerTree)
00295 {
00296 $this->_oManufacturerTree = $oManufacturerTree;
00297 }
00298 }