OXID eShop CE  4.9.6
 All Classes Files Functions Variables Pages
oxubase.php
Go to the documentation of this file.
1 <?php
2 
7 // view indexing state for search engines:
8 define('VIEW_INDEXSTATE_INDEX', 0); // index without limitations
9 define('VIEW_INDEXSTATE_NOINDEXNOFOLLOW', 1); // no index / no follow
10 define('VIEW_INDEXSTATE_NOINDEXFOLLOW', 2); // no index / follow
11 
17 class oxUBase extends oxView
18 {
19 
25  protected $_blFbWidgetsOn = null;
26 
32  protected $_sRemoveMetaChars = '.\+*?[^]$(){}=!<>|:&';
33 
39  protected $_oaComponents = array();
40 
46  protected $_blIsOrderStep = false;
47 
53  protected $_sListType = null;
54 
60  protected $_aListDisplayTypes = array('grid', 'line', 'infogrid');
61 
67  protected $_sListDisplayType = null;
68 
74  protected $_sCustomListDisplayType = null;
75 
81  protected $_oActCategory = null;
82 
88  protected $_oActManufacturer = null;
89 
95  protected $_oActVendor = null;
96 
102  protected $_oActiveRecommList = null;
103 
109  protected $_oActSearch = null;
110 
116  protected $_blShowSorting = false;
117 
123  protected $_blLoadCurrency = null;
124 
130  protected $_blLoadManufacturerTree = null;
131 
137  protected $_blDontShowEmptyCats = null;
138 
144  protected $_blLoadLanguage = null;
145 
151  protected $_iTopCatNavItmCnt = null;
152 
158  protected $_aRssLinks = null;
159 
165  protected $_sListOrderBy = null;
166 
172  protected $_sListOrderDir = null;
173 
179  protected $_sMetaDescription = null;
180 
186  protected $_sMetaKeywords = null;
187 
193  protected $_sMetaDescriptionIdent = null;
194 
200  protected $_sMetaKeywordsIdent = null;
201 
207  protected $_sAdditionalParams = null;
208 
214  protected $_oActCurrency = null;
215 
221  protected $_blEnabledPrivateSales = null;
222 
230  protected $_blCommonAdded = false;
231 
239 
246  protected $_blForceNoIndex = false;
247 
253  protected $_iCompItemsCnt = null;
254 
260  protected $_sContentId = null;
261 
267  protected $_oContent = null;
268 
274  protected $_sViewResetID = null;
275 
281  protected $_aMenueList = null;
282 
289  protected $_aComponentNames = array(
290  'oxcmp_user' => 1, // 0 means dont init if cached
291  'oxcmp_lang' => 0,
292  'oxcmp_cur' => 1,
293  'oxcmp_shop' => 1,
294  'oxcmp_categories' => 0,
295  'oxcmp_utils' => 1,
296  'oxcmp_news' => 0,
297  'oxcmp_basket' => 1
298  );
299 
306  protected $_aUserComponentNames = array();
307 
313  protected $_oProduct = null;
314 
320  protected $_iActPage = null;
321 
327  protected $_aArticleList = null;
328 
334  protected $_oManufacturerTree = null;
335 
341  protected $_oCategoryTree = null;
342 
348  protected $_aTop5ArticleList = null;
349 
355  protected $_aBargainArticleList = null;
356 
362  protected $_blLowOrderPrice = null;
363 
369  protected $_sMinOrderPrice = null;
370 
376  protected $_iNewsRealStatus = null;
377 
383  protected $_aBlockRedirectParams = array('fnc', 'stoken', 'force_sid', 'force_admin_sid');
384 
390  protected $_oRootVendor = null;
391 
397  protected $_sVendorId = null;
398 
404  protected $_aManufacturerlist = null;
405 
411  protected $_oRootManufacturer = null;
412 
418  protected $_sManufacturerId = null;
419 
425  protected $_blNewsSubscribed = null;
426 
432  protected $_oDelAddress = null;
433 
439  protected $_sCatTreePath = null;
440 
446  protected $_aContents = array();
447 
453  protected $_blTop5Action = false;
454 
460  protected $_blBargainAction = false;
461 
467  protected $_aMustFillFields = null;
468 
474  protected $_blShowTagCloud = true;
475 
481  protected $_blRootCatChanged = false;
482 
488  protected $_aInvoiceAddress = null;
489 
495  protected $_aDeliveryAddress = null;
496 
502  protected $_sActiveUsername = null;
503 
510  protected static $_aCollectedComponentNames = null;
511 
518  protected $_blLoadComponents = true;
519 
520 
526  protected $_aSortColumns = null;
527 
533  protected function _getComponentNames()
534  {
535  if (self::$_aCollectedComponentNames === null) {
536  self::$_aCollectedComponentNames = array_merge($this->_aComponentNames, $this->_aUserComponentNames);
537 
538  // #1721: custom component handling. At the moment it is not possible to override this variable in oxubase,
539  // so we added this array to config.inc.php file
540  if (($aUserCmps = $this->getConfig()->getConfigParam('aUserComponentNames'))) {
541  self::$_aCollectedComponentNames = array_merge(self::$_aCollectedComponentNames, $aUserCmps);
542  }
543 
544  if (oxRegistry::getConfig()->getRequestParameter('_force_no_basket_cmp')) {
545  unset(self::$_aCollectedComponentNames['oxcmp_basket']);
546  }
547  }
548 
549  // resetting array pointer
550  reset(self::$_aCollectedComponentNames);
551 
553  }
554 
561  protected function _processRequest()
562  {
563  $myUtils = oxRegistry::getUtils();
564 
565  // non admin, request is not empty and was not processed by seo engine
566  if (!isSearchEngineUrl() && $myUtils->seoIsActive() && ($sStdUrl = getRequestUrl('', true))) {
567 
568  // fetching standard url and looking for it in seo table
569  if ($this->_canRedirect() && ($sRedirectUrl = oxRegistry::get("oxSeoEncoder")->fetchSeoUrl($sStdUrl))) {
570  $myUtils->redirect($this->getConfig()->getCurrentShopUrl() . $sRedirectUrl, false);
571  } elseif (VIEW_INDEXSTATE_INDEX == $this->noIndex()) {
572  // forcing to set no index/follow meta
573  $this->_forceNoIndex();
574 
575  if ($this->getConfig()->getConfigParam('blSeoLogging')) {
576  $sShopId = $this->getConfig()->getShopId();
577  $sLangId = oxRegistry::getLang()->getBaseLanguage();
578  $sIdent = md5(strtolower($sStdUrl) . $sShopId . $sLangId);
579 
580  // logging "not found" url
581  $oDb = oxDb::getDb();
582  $oDb->execute(
583  "replace oxseologs ( oxstdurl, oxident, oxshopid, oxlang )
584  values ( " . $oDb->quote($sStdUrl) . ", '{$sIdent}', '{$sShopId}', '{$sLangId}' ) "
585  );
586  }
587  }
588  }
589  }
590 
595  public function init()
596  {
597  $this->_processRequest();
598 
599  // storing current view
600  $blInit = true;
601 
602 
603  // init all components if there are any
604  if ($this->_blLoadComponents) {
605  foreach ($this->_getComponentNames() as $sComponentName => $blNotCacheable) {
606  // do not override initiated components
607  if (!isset($this->_oaComponents[$sComponentName])) {
608  // component objects MUST be created to support user called functions
609  $oComponent = oxNew($sComponentName);
610  $oComponent->setParent($this);
611  $oComponent->setThisAction($sComponentName);
612  $this->_oaComponents[$sComponentName] = $oComponent;
613  }
614 
615  // do we really need to initiate them ?
616  if ($blInit) {
617  $this->_oaComponents[$sComponentName]->init();
618 
619  // executing only is view does not have action method
620  if (!method_exists($this, $this->getFncName())) {
621  $this->_oaComponents[$sComponentName]->executeFunction($this->getFncName());
622  }
623  }
624  }
625  }
626 
627  parent::init();
628  }
629 
636  public function getViewId()
637  {
638  if ($this->_sViewId) {
639  return $this->_sViewId;
640  }
641 
642  $oConfig = $this->getConfig();
643  $iLang = oxRegistry::getLang()->getBaseLanguage();
644  $iCur = (int) $oConfig->getShopCurrency();
645 
646 
647  $this->_sViewId = "ox|$iLang|$iCur";
648 
649  $this->_sViewId .= "|" . ((int) $this->_blForceNoIndex) . '|' . ((int) $this->isRootCatChanged());
650 
651  // #0004798: SSL should be included in viewId
652  if ($oConfig->isSsl()) {
653  $this->_sViewId .= "|ssl";
654  }
655 
656  // #0002866: external global viewID addition
657  if (function_exists('customGetViewId')) {
658  $oExtViewId = customGetViewId();
659 
660  if ($oExtViewId !== null) {
661  $this->_sViewId .= '|' . md5(serialize($oExtViewId));
662  }
663  }
664 
665  return $this->_sViewId;
666  }
667 
668 
674  public function showSorting()
675  {
676  return $this->_blShowSorting && $this->getConfig()->getConfigParam('blShowSorting');
677  }
678 
684  public function setComponents($aComponents = null)
685  {
686  $this->_oaComponents = $aComponents;
687  }
688 
694  public function getComponents()
695  {
696  return $this->_oaComponents;
697  }
698 
706  public function getComponent($sName)
707  {
708  if (isset($sName) && isset($this->_oaComponents[$sName])) {
709  return $this->_oaComponents[$sName];
710  }
711  }
712 
718  public function setIsOrderStep($blIsOrderStep = null)
719  {
720  $this->_blIsOrderStep = $blIsOrderStep;
721  }
722 
728  public function getIsOrderStep()
729  {
730  return $this->_blIsOrderStep;
731  }
732 
733 
739  public function setActiveCategory($oCategory)
740  {
741  $this->_oActCategory = $oCategory;
742  }
743 
749  public function getActiveCategory()
750  {
751  return $this->_oActCategory;
752  }
753 
759  public function getListType()
760  {
761  if ($this->_sListType == null) {
762  if ($sListType = $this->getConfig()->getRequestParameter('listtype')) {
763  $this->_sListType = $sListType;
764  } elseif ($sListType = $this->getConfig()->getGlobalParameter('listtype')) {
765  $this->_sListType = $sListType;
766  }
767  }
768 
769  return $this->_sListType;
770  }
771 
777  public function getListDisplayType()
778  {
779  if ($this->_sListDisplayType == null) {
780  $this->_sListDisplayType = $this->getCustomListDisplayType();
781 
782  if (!$this->_sListDisplayType) {
783  $this->_sListDisplayType = $this->getConfig()->getConfigParam('sDefaultListDisplayType');
784  }
785 
786  $this->_sListDisplayType = in_array(( string ) $this->_sListDisplayType, $this->_aListDisplayTypes) ?
787  $this->_sListDisplayType : 'infogrid';
788 
789  // writing to session
790  if ($this->getConfig()->getRequestParameter('ldtype')) {
791  oxRegistry::getSession()->setVariable('ldtype', $this->_sListDisplayType);
792  }
793  }
794 
796  }
797 
803  public function getCustomListDisplayType()
804  {
805  if ($this->_sCustomListDisplayType == null) {
806  $this->_sCustomListDisplayType = $this->getConfig()->getRequestParameter('ldtype');
807 
808  if (!$this->_sCustomListDisplayType) {
809  $this->_sCustomListDisplayType = oxRegistry::getSession()->getVariable('ldtype');
810  }
811  }
812 
814  }
815 
821  public function setListType($sType)
822  {
823  $this->_sListType = $sType;
824  $this->getConfig()->setGlobalParameter('listtype', $sType);
825  }
826 
832  public function loadCurrency()
833  {
834  if ($this->_blLoadCurrency == null) {
835  $this->_blLoadCurrency = false;
836  if ($blLoadCurrency = $this->getConfig()->getConfigParam('bl_perfLoadCurrency')) {
837  $this->_blLoadCurrency = $blLoadCurrency;
838  }
839  }
840 
841  return $this->_blLoadCurrency;
842  }
843 
849  public function dontShowEmptyCategories()
850  {
851  if ($this->_blDontShowEmptyCats == null) {
852  $this->_blDontShowEmptyCats = false;
853  if ($blDontShowEmptyCats = $this->getConfig()->getConfigParam('blDontShowEmptyCategories')) {
854  $this->_blDontShowEmptyCats = $blDontShowEmptyCats;
855  }
856  }
857 
859  }
860 
866  public function showCategoryArticlesCount()
867  {
868  return $this->getConfig()->getConfigParam('bl_perfShowActionCatArticleCnt');
869  }
870 
876  public function isLanguageLoaded()
877  {
878  if ($this->_blLoadLanguage == null) {
879  $this->_blLoadLanguage = false;
880  if ($blLoadLanguage = $this->getConfig()->getConfigParam('bl_perfLoadLanguages')) {
881  $this->_blLoadLanguage = $blLoadLanguage;
882  }
883  }
884 
885  return $this->_blLoadLanguage;
886  }
887 
893  public function getTopNavigationCatCnt()
894  {
895  if ($this->_iTopCatNavItmCnt == null) {
896  $iTopCatNavItmCnt = $this->getConfig()->getConfigParam('iTopNaviCatCount');
897  $this->_iTopCatNavItmCnt = $iTopCatNavItmCnt ? $iTopCatNavItmCnt : 5;
898  }
899 
901  }
902 
910  public function addRssFeed($sTitle, $sUrl, $key = null)
911  {
912  if (!is_array($this->_aRssLinks)) {
913  $this->_aRssLinks = array();
914  }
915 
916  $sUrl = oxRegistry::get("oxUtilsUrl")->prepareUrlForNoSession($sUrl);
917 
918  if ($key === null) {
919  $this->_aRssLinks[] = array('title' => $sTitle, 'link' => $sUrl);
920  } else {
921  $this->_aRssLinks[$key] = array('title' => $sTitle, 'link' => $sUrl);
922  }
923  }
924 
930  public function getSortOrderByParameterName()
931  {
932  return 'listorderby';
933  }
934 
940  public function getSortOrderParameterName()
941  {
942  return 'listorder';
943  }
944 
945 
951  public function getSortIdent()
952  {
953  return 'alist';
954  }
955 
961  public function getDefaultSorting()
962  {
963  return null;
964  }
965 
971  public function getUserSelectedSorting()
972  {
973  $aSorting = null;
974  $oStr = getStr();
975  $oConfig = oxRegistry::getConfig();
976  $aSortDirections = array('desc', 'asc');
977 
978  $sSortBy = $oConfig->getRequestParameter($this->getSortOrderByParameterName());
979  $sSortDir = $oConfig->getRequestParameter($this->getSortOrderParameterName());
980 
981  if ($sSortBy && oxDb::getInstance()->isValidFieldName($sSortBy) && $sSortDir &&
982  oxRegistry::getUtils()->isValidAlpha($sSortDir) && in_array($oStr->strtolower($sSortDir), $aSortDirections)
983  ) {
984  $aSorting = array('sortby' => $sSortBy, 'sortdir' => $sSortDir);
985  }
986 
987  return $aSorting;
988  }
989 
990 
998  public function getSavedSorting($sSortIdent)
999  {
1000  $aSorting = oxRegistry::getSession()->getVariable('aSorting');
1001  if (isset($aSorting[$sSortIdent])) {
1002  return $aSorting[$sSortIdent];
1003  }
1004  }
1005 
1011  public function setListOrderBy($sColumn)
1012  {
1013  $this->_sListOrderBy = $sColumn;
1014  }
1015 
1021  public function setListOrderDirection($sDirection)
1022  {
1023  $this->_sListOrderDir = $sDirection;
1024  }
1025 
1031  public function getListOrderBy()
1032  {
1033  //if column is with table name split it
1034  $aColumns = explode('.', $this->_sListOrderBy);
1035 
1036  if (is_array($aColumns) && count($aColumns) > 1) {
1037  return $aColumns[1];
1038  }
1039 
1040  return $this->_sListOrderBy;
1041  }
1042 
1048  public function getListOrderDirection()
1049  {
1050  return $this->_sListOrderDir;
1051  }
1052 
1060  public function setMetaDescription($sDescription)
1061  {
1062  return $this->_sMetaDescription = $sDescription;
1063  }
1064 
1072  public function setMetaKeywords($sKeywords)
1073  {
1074  return $this->_sMetaKeywords = $sKeywords;
1075  }
1076 
1084  protected function _getMetaFromSeo($sDataType)
1085  {
1086  $sOxId = $this->_getSeoObjectId();
1087  $iLang = oxRegistry::getLang()->getBaseLanguage();
1088  $sShop = $this->getConfig()->getShopId();
1089 
1090  if ($sOxId && oxRegistry::getUtils()->seoIsActive() &&
1091  ($sKeywords = oxRegistry::get("oxSeoEncoder")->getMetaData($sOxId, $sDataType, $sShop, $iLang))
1092  ) {
1093  return $sKeywords;
1094  }
1095  }
1096 
1104  protected function _getMetaFromContent($sMetaIdent)
1105  {
1106  if ($sMetaIdent) {
1107  $oContent = oxNew('oxContent');
1108  if ($oContent->loadByIdent($sMetaIdent) &&
1109  $oContent->oxcontents__oxactive->value
1110  ) {
1111  return getStr()->strip_tags($oContent->oxcontents__oxcontent->value);
1112  }
1113  }
1114  }
1115 
1121  public function getMetaKeywords()
1122  {
1123  if ($this->_sMetaKeywords === null) {
1124  $this->_sMetaKeywords = false;
1125 
1126  // set special meta keywords ?
1127  if (($sKeywords = $this->_getMetaFromSeo('oxkeywords'))) {
1128  $this->_sMetaKeywords = $sKeywords;
1129  } elseif (($sKeywords = $this->_getMetaFromContent($this->_sMetaKeywordsIdent))) {
1130  $this->_sMetaKeywords = $this->_prepareMetaKeyword($sKeywords, false);
1131  } else {
1132  $this->_sMetaKeywords = $this->_prepareMetaKeyword(false, true);
1133  }
1134  }
1135 
1136  return $this->_sMetaKeywords;
1137  }
1138 
1144  public function getMetaDescription()
1145  {
1146  if ($this->_sMetaDescription === null) {
1147  $this->_sMetaDescription = false;
1148 
1149  // set special meta description ?
1150  if (($sDescription = $this->_getMetaFromSeo('oxdescription'))) {
1151  $this->_sMetaDescription = $sDescription;
1152  } elseif (($sDescription = $this->_getMetaFromContent($this->_sMetaDescriptionIdent))) {
1153  $this->_sMetaDescription = $this->_prepareMetaDescription($sDescription);
1154  } else {
1155  $this->_sMetaDescription = $this->_prepareMetaDescription(false);
1156  }
1157  }
1158 
1159  return $this->_sMetaDescription;
1160  }
1161 
1167  public function getActCurrency()
1168  {
1169  return $this->_oActCurrency;
1170  }
1171 
1177  public function setActCurrency($oCur)
1178  {
1179  $this->_oActCurrency = $oCur;
1180  }
1181 
1187  public function getCompareItemCount()
1188  {
1189  if ($this->_iCompItemsCnt === null) {
1190  $aItems = oxRegistry::getSession()->getVariable('aFiltcompproducts');
1191  $this->_iCompItemsCnt = is_array($aItems) ? count($aItems) : 0;
1192  }
1193 
1194  return $this->_iCompItemsCnt;
1195  }
1196 
1200  protected function _forceNoIndex()
1201  {
1202  $this->_blForceNoIndex = true;
1203  }
1204 
1211  public function noIndex()
1212  {
1213  if ($this->_blForceNoIndex) {
1214  $this->_iViewIndexState = VIEW_INDEXSTATE_NOINDEXFOLLOW;
1215  } elseif ($this->getConfig()->getRequestParameter('cur')) {
1216  $this->_iViewIndexState = VIEW_INDEXSTATE_NOINDEXNOFOLLOW;
1217  } else {
1218  switch ($this->getConfig()->getRequestParameter('fnc')) {
1219  case 'tocomparelist':
1220  case 'tobasket':
1221  $this->_iViewIndexState = VIEW_INDEXSTATE_NOINDEXNOFOLLOW;
1222  break;
1223  }
1224  }
1225 
1226  return $this->_iViewIndexState;
1227  }
1228 
1234  public function getMenueList()
1235  {
1236  return $this->_aMenueList;
1237  }
1238 
1244  public function setMenueList($aMenu)
1245  {
1246  $this->_aMenueList = $aMenu;
1247  }
1248 
1252  protected function _setNrOfArtPerPage()
1253  {
1254  $myConfig = $this->getConfig();
1255 
1256  //setting default values to avoid possible errors showing article list
1257  $iNrofCatArticles = $myConfig->getConfigParam('iNrofCatArticles');
1258 
1259  $iNrofCatArticles = ($iNrofCatArticles) ? $iNrofCatArticles : 10;
1260 
1261  // checking if all needed data is set
1262  switch ($this->getListDisplayType()) {
1263  case 'grid':
1264  $aNrofCatArticles = $myConfig->getConfigParam('aNrofCatArticlesInGrid');
1265  break;
1266  case 'line':
1267  case 'infogrid':
1268  default:
1269  $aNrofCatArticles = $myConfig->getConfigParam('aNrofCatArticles');
1270  }
1271 
1272  if (!is_array($aNrofCatArticles) || !isset($aNrofCatArticles[0])) {
1273  $aNrofCatArticles = array($iNrofCatArticles);
1274  $myConfig->setConfigParam('aNrofCatArticles', $aNrofCatArticles);
1275  } else {
1276  $iNrofCatArticles = $aNrofCatArticles[0];
1277  }
1278 
1279  $oViewConf = $this->getViewConfig();
1280  //value from user input
1281  $oSession = oxRegistry::getSession();
1282  if (($iNrofArticles = (int) oxRegistry::getConfig()->getRequestParameter('_artperpage'))) {
1283  // M45 Possibility to push any "Show articles per page" number parameter
1284  $iNrofCatArticles = (in_array($iNrofArticles, $aNrofCatArticles)) ? $iNrofArticles : $iNrofCatArticles;
1285  $oViewConf->setViewConfigParam('iartPerPage', $iNrofCatArticles);
1286  $oSession->setVariable('_artperpage', $iNrofCatArticles);
1287  } elseif (($iSessArtPerPage = $oSession->getVariable('_artperpage')) && is_numeric($iSessArtPerPage)) {
1288  // M45 Possibility to push any "Show articles per page" number parameter
1289  $iNrofCatArticles = (in_array($iSessArtPerPage, $aNrofCatArticles)) ? $iSessArtPerPage : $iNrofCatArticles;
1290  $oViewConf->setViewConfigParam('iartPerPage', $iSessArtPerPage);
1291  $iNrofCatArticles = $iSessArtPerPage;
1292  } else {
1293  $oViewConf->setViewConfigParam('iartPerPage', $iNrofCatArticles);
1294  }
1295 
1296  //setting number of articles per page to config value
1297  $myConfig->setConfigParam('iNrofCatArticles', $iNrofCatArticles);
1298  }
1299 
1303  protected function _getSeoObjectId()
1304  {
1305  }
1306 
1316  protected function _prepareMetaDescription($sMeta, $iLength = 1024, $blRemoveDuplicatedWords = false)
1317  {
1318  if ($sMeta) {
1319 
1320  $oStr = getStr();
1321  if ($iLength != -1) {
1322  /* *
1323  * performance - we do not need a huge amount of initial text.
1324  * assume that effective text may be double longer than $iLength
1325  * and simple truncate it
1326  */
1327  $iELength = ($iLength * 2);
1328  $sMeta = $oStr->substr($sMeta, 0, $iELength);
1329  }
1330 
1331  // decoding html entities
1332  $sMeta = $oStr->html_entity_decode($sMeta);
1333  // stripping HTML tags
1334  $sMeta = $oStr->strip_tags($sMeta);
1335 
1336  // removing some special chars
1337  $sMeta = $oStr->cleanStr($sMeta);
1338 
1339  // removing duplicate words
1340  if ($blRemoveDuplicatedWords) {
1341  $sMeta = $this->_removeDuplicatedWords($sMeta, $this->getConfig()->getConfigParam('aSkipTags'));
1342  }
1343 
1344  // some special cases
1345  $sMeta = str_replace(' ,', ',', $sMeta);
1346  $aPattern = array("/,[\s\+\-\*]*,/", "/\s+,/");
1347  $sMeta = $oStr->preg_replace($aPattern, ',', $sMeta);
1348  $sMeta = oxRegistry::get("oxUtilsString")->minimizeTruncateString($sMeta, $iLength);
1349  $sMeta = $oStr->htmlspecialchars($sMeta);
1350 
1351  return trim($sMeta);
1352  }
1353  }
1354 
1363  protected function _prepareMetaKeyword($sKeywords, $blRemoveDuplicatedWords = true)
1364  {
1365 
1366  $sString = $this->_prepareMetaDescription($sKeywords, -1, false);
1367 
1368  if ($blRemoveDuplicatedWords) {
1369  $sString = $this->_removeDuplicatedWords($sString, $this->getConfig()->getConfigParam('aSkipTags'));
1370  }
1371 
1372  return trim($sString);
1373  }
1374 
1383  protected function _removeDuplicatedWords($aInput, $aSkipTags = array())
1384  {
1385  $oStr = getStr();
1386  if (is_array($aInput)) {
1387  $aInput = implode(" ", $aInput);
1388  }
1389 
1390  // removing some usually met characters..
1391  $aInput = $oStr->preg_replace("/[" . preg_quote($this->_sRemoveMetaChars, "/") . "]/", " ", $aInput);
1392 
1393  // splitting by word
1394  $aStrings = $oStr->preg_split("/[\s,]+/", $aInput);
1395 
1396  if ($sCount = count($aSkipTags)) {
1397  for ($iNum = 0; $iNum < $sCount; $iNum++) {
1398  $aSkipTags[$iNum] = $oStr->strtolower($aSkipTags[$iNum]);
1399  }
1400  }
1401  $sCount = count($aStrings);
1402  for ($iNum = 0; $iNum < $sCount; $iNum++) {
1403  $aStrings[$iNum] = $oStr->strtolower($aStrings[$iNum]);
1404  // removing in admin defined strings
1405  if (!$aStrings[$iNum] || in_array($aStrings[$iNum], $aSkipTags)) {
1406  unset($aStrings[$iNum]);
1407  }
1408  }
1409 
1410  // duplicates
1411  return implode(', ', array_unique($aStrings));
1412  }
1413 
1421  public function getNavigationParams()
1422  {
1423  $oConfig = $this->getConfig();
1424  $aParams['cnid'] = $this->getCategoryId();
1425  $aParams['mnid'] = $oConfig->getRequestParameter('mnid');
1426 
1427  $aParams['listtype'] = $this->getListType();
1428  $aParams['ldtype'] = $this->getCustomListDisplayType();
1429  $aParams['actcontrol'] = $this->getClassName();
1430 
1431  $aParams['recommid'] = $oConfig->getRequestParameter('recommid');
1432 
1433  $aParams['searchrecomm'] = $oConfig->getRequestParameter('searchrecomm', true);
1434  $aParams['searchparam'] = $oConfig->getRequestParameter('searchparam', true);
1435  $aParams['searchtag'] = $oConfig->getRequestParameter('searchtag', true);
1436 
1437  $aParams['searchvendor'] = $oConfig->getRequestParameter('searchvendor');
1438  $aParams['searchcnid'] = $oConfig->getRequestParameter('searchcnid');
1439  $aParams['searchmanufacturer'] = $oConfig->getRequestParameter('searchmanufacturer');
1440 
1441  return $aParams;
1442  }
1443 
1451  public function setItemSorting($sSortIdent, $sSortBy, $sSortDir = null)
1452  {
1453  $aSorting = oxRegistry::getSession()->getVariable('aSorting');
1454  $aSorting[$sSortIdent]['sortby'] = $sSortBy;
1455  $aSorting[$sSortIdent]['sortdir'] = $sSortDir ? $sSortDir : null;
1456 
1457  oxRegistry::getSession()->setVariable('aSorting', $aSorting);
1458  }
1459 
1467  public function getSorting($sSortIdent)
1468  {
1469  $aSorting = null;
1470 
1471  if ($aSorting = $this->getUserSelectedSorting()) {
1472  $this->setItemSorting($sSortIdent, $aSorting['sortby'], $aSorting['sortdir']);
1473  } elseif (!$aSorting = $this->getSavedSorting($sSortIdent)) {
1474  $aSorting = $this->getDefaultSorting();
1475  }
1476 
1477  if ($aSorting) {
1478  $this->setListOrderBy($aSorting['sortby']);
1479  $this->setListOrderDirection($aSorting['sortdir']);
1480  }
1481 
1482  return $aSorting;
1483  }
1484 
1492  public function getSortingSql($sIdent)
1493  {
1494  $aSorting = $this->getSorting($sIdent);
1495  if (is_array($aSorting)) {
1496  return implode(" ", $aSorting);
1497  }
1498  }
1499 
1505  public function getTitleSuffix()
1506  {
1507  return $this->getConfig()->getActiveShop()->oxshops__oxtitlesuffix->value;
1508  }
1509 
1513  public function getTitlePageSuffix()
1514  {
1515  }
1516 
1522  public function getTitlePrefix()
1523  {
1524  return $this->getConfig()->getActiveShop()->oxshops__oxtitleprefix->value;
1525  }
1526 
1527 
1533  public function getPageTitle()
1534  {
1535  $sTitle = '';
1536 
1537  $aTitleParts = array();
1538  $aTitleParts[] = $this->getTitlePrefix();
1539  $aTitleParts[] = $this->getTitle();
1540  $aTitleParts[] = $this->getTitleSuffix();
1541  $aTitleParts[] = $this->getTitlePageSuffix();
1542 
1543  $aTitleParts = array_filter($aTitleParts);
1544 
1545  if (count($aTitleParts)) {
1546  $sTitle = implode(' | ', $aTitleParts);
1547  }
1548 
1549 
1550  return $sTitle;
1551  }
1552 
1553 
1562  protected function _getSubject($iLang)
1563  {
1564  return null;
1565  }
1566 
1572  public function getDynUrlParams()
1573  {
1574  $sRet = '';
1575  $sListType = $this->getListType();
1576  $oConfig = $this->getConfig();
1577 
1578  switch ($sListType) {
1579  default:
1580  break;
1581  case 'search':
1582  $sRet .= "&amp;listtype={$sListType}";
1583  if ($sSearchParamForLink = rawurlencode($oConfig->getRequestParameter('searchparam', true))) {
1584  $sRet .= "&amp;searchparam={$sSearchParamForLink}";
1585  }
1586 
1587  if (($sVar = $oConfig->getRequestParameter('searchcnid', true))) {
1588  $sRet .= '&amp;searchcnid=' . rawurlencode(rawurldecode($sVar));
1589  }
1590  if (($sVar = $oConfig->getRequestParameter('searchvendor', true))) {
1591  $sRet .= '&amp;searchvendor=' . rawurlencode(rawurldecode($sVar));
1592  }
1593  if (($sVar = $oConfig->getRequestParameter('searchmanufacturer', true))) {
1594  $sRet .= '&amp;searchmanufacturer=' . rawurlencode(rawurldecode($sVar));
1595  }
1596  break;
1597  case 'tag':
1598  $sRet .= "&amp;listtype={$sListType}";
1599  if ($sParam = rawurlencode($oConfig->getRequestParameter('searchtag', true))) {
1600  $sRet .= "&amp;searchtag={$sParam}";
1601  }
1602  break;
1603  }
1604 
1605  return $sRet;
1606  }
1607 
1615  public function getBaseLink($iLang = null)
1616  {
1617  if (!isset($iLang)) {
1618  $iLang = oxRegistry::getLang()->getBaseLanguage();
1619  }
1620 
1621  $oConfig = $this->getConfig();
1622 
1623  if (oxRegistry::getUtils()->seoIsActive()) {
1624  if ($oDisplayObj = $this->_getSubject($iLang)) {
1625  $sUrl = $oDisplayObj->getLink($iLang);
1626  } else {
1627  $oEncoder = oxRegistry::get("oxSeoEncoder");
1628  $sConstructedUrl = $oConfig->getShopHomeURL($iLang) . $this->_getSeoRequestParams();
1629  $sUrl = $oEncoder->getStaticUrl($sConstructedUrl, $iLang);
1630  }
1631  }
1632 
1633  if (!$sUrl) {
1634  $sConstructedUrl = $oConfig->getShopCurrentURL($iLang) . $this->_getRequestParams();
1635  $sUrl = oxRegistry::get("oxUtilsUrl")->processUrl($sConstructedUrl, true, null, $iLang);
1636  }
1637 
1638  return $sUrl;
1639  }
1640 
1641 
1649  public function getLink($iLang = null)
1650  {
1651  return $this->_addPageNrParam($this->getBaseLink($iLang), $this->getActPage(), $iLang);
1652  }
1653 
1657  public function getCanonicalUrl()
1658  {
1659  }
1660 
1667  public function getSimilarRecommListIds()
1668  {
1669  return false;
1670  }
1671 
1676  public function getSearchParamForHtml()
1677  {
1678  }
1679 
1687  protected function _getRequestParams($blAddPageNr = true)
1688  {
1689  $sClass = $this->getClassName();
1690  $sFnc = $this->getFncName();
1691 
1692  $aFnc = array('tobasket', 'login_noredirect', 'addVoucher', 'moveleft', 'moveright');
1693  if (in_array($sFnc, $aFnc)) {
1694  $sFnc = '';
1695  }
1696 
1697  // #680
1698  $sURL = "cl={$sClass}";
1699  if ($sFnc) {
1700  $sURL .= "&amp;fnc={$sFnc}";
1701  }
1702  if ($sVal = oxRegistry::getConfig()->getRequestParameter('cnid')) {
1703  $sURL .= "&amp;cnid={$sVal}";
1704  }
1705  if ($sVal = oxRegistry::getConfig()->getRequestParameter('mnid')) {
1706  $sURL .= "&amp;mnid={$sVal}";
1707  }
1708  if ($sVal = oxRegistry::getConfig()->getRequestParameter('anid')) {
1709  $sURL .= "&amp;anid={$sVal}";
1710  }
1711 
1712  if ($sVal = basename(oxRegistry::getConfig()->getRequestParameter('page'))) {
1713  $sURL .= "&amp;page={$sVal}";
1714  }
1715 
1716  if ($sVal = basename(oxRegistry::getConfig()->getRequestParameter('tpl'))) {
1717  $sURL .= "&amp;tpl={$sVal}";
1718  }
1719 
1720  if ($sVal = oxRegistry::getConfig()->getRequestParameter('oxloadid')) {
1721  $sURL .= "&amp;oxloadid={$sVal}";
1722  }
1723 
1724  $iPgNr = (int) oxRegistry::getConfig()->getRequestParameter('pgNr');
1725  // don't include page number for navigation
1726  // it will be done in oxubase::generatePageNavigation
1727  if ($blAddPageNr && $iPgNr > 0) {
1728  $sURL .= "&amp;pgNr={$iPgNr}";
1729  }
1730 
1731  // #1184M - specialchar search
1732  if ($sVal = rawurlencode(oxRegistry::getConfig()->getRequestParameter('searchparam', true))) {
1733  $sURL .= "&amp;searchparam={$sVal}";
1734  }
1735 
1736  if ($sVal = oxRegistry::getConfig()->getRequestParameter('searchcnid')) {
1737  $sURL .= "&amp;searchcnid={$sVal}";
1738  }
1739 
1740  if ($sVal = oxRegistry::getConfig()->getRequestParameter('searchvendor')) {
1741  $sURL .= "&amp;searchvendor={$sVal}";
1742  }
1743 
1744  if ($sVal = oxRegistry::getConfig()->getRequestParameter('searchmanufacturer')) {
1745  $sURL .= "&amp;searchmanufacturer={$sVal}";
1746  }
1747 
1748  if ($sVal = oxRegistry::getConfig()->getRequestParameter('searchrecomm')) {
1749  $sURL .= "&amp;searchrecomm={$sVal}";
1750  }
1751 
1752  if ($sVal = oxRegistry::getConfig()->getRequestParameter('searchtag')) {
1753  $sURL .= "&amp;searchtag={$sVal}";
1754  }
1755 
1756  if ($sVal = oxRegistry::getConfig()->getRequestParameter('recommid')) {
1757  $sURL .= "&amp;recommid={$sVal}";
1758  }
1759 
1760  return $sURL;
1761  }
1762 
1768  protected function _getSeoRequestParams()
1769  {
1770  $sClass = $this->getClassName();
1771  $sFnc = $this->getFncName();
1772 
1773  // #921 S
1774  $aFnc = array('tobasket', 'login_noredirect', 'addVoucher');
1775  if (in_array($sFnc, $aFnc)) {
1776  $sFnc = '';
1777  }
1778 
1779  // #680
1780  $sURL = "cl={$sClass}";
1781  if ($sFnc) {
1782  $sURL .= "&amp;fnc={$sFnc}";
1783  }
1784  if ($sVal = basename(oxRegistry::getConfig()->getRequestParameter('page'))) {
1785  $sURL .= "&amp;page={$sVal}";
1786  }
1787 
1788  if ($sVal = basename(oxRegistry::getConfig()->getRequestParameter('tpl'))) {
1789  $sURL .= "&amp;tpl={$sVal}";
1790  }
1791 
1792  if ($sVal = oxRegistry::getConfig()->getRequestParameter('oxloadid')) {
1793  $sURL .= "&amp;oxloadid={$sVal}";
1794  }
1795 
1796  $iPgNr = (int) oxRegistry::getConfig()->getRequestParameter('pgNr');
1797  if ($iPgNr > 0) {
1798  $sURL .= "&amp;pgNr={$iPgNr}";
1799  }
1800 
1801  return $sURL;
1802  }
1803 
1809  public function showSearch()
1810  {
1811  $blShow = true;
1812  if ($this->getConfig()->getConfigParam('blDisableNavBars') && $this->getIsOrderStep()) {
1813  $blShow = false;
1814  }
1815 
1816  return (int) $blShow;
1817  }
1818 
1824  public function getRssLinks()
1825  {
1826  return $this->_aRssLinks;
1827  }
1828 
1834  public function getSortColumns()
1835  {
1836  if ($this->_aSortColumns === null) {
1837  $this->setSortColumns($this->getConfig()->getConfigParam('aSortCols'));
1838  }
1839 
1840  return $this->_aSortColumns;
1841  }
1842 
1843 
1849  public function setSortColumns($aSortColumns)
1850  {
1851  $this->_aSortColumns = $aSortColumns;
1852  }
1853 
1857  public function getEditTags()
1858  {
1859  }
1860 
1864  public function getRecommSearch()
1865  {
1866  }
1867 
1871  public function getPaymentList()
1872  {
1873  }
1874 
1880  public function getActiveRecommList()
1881  {
1882  if ($this->_oActiveRecommList === null) {
1883  $this->_oActiveRecommList = false;
1884  if ($sOxId = $this->getConfig()->getRequestParameter('recommid')) {
1885  $this->_oActiveRecommList = oxNew('oxrecommlist');
1886  $this->_oActiveRecommList->load($sOxId);
1887  }
1888  }
1889 
1891  }
1892 
1896  public function getAccessoires()
1897  {
1898  }
1899 
1903  public function getCrossSelling()
1904  {
1905  }
1906 
1910  public function getSimilarProducts()
1911  {
1912  }
1913 
1917  public function getAlsoBoughtTheseProducts()
1918  {
1919  }
1920 
1924  public function getArticleId()
1925  {
1926  }
1927 
1933  public function getTitle()
1934  {
1935  $oLang = oxRegistry::getLang();
1936  $sTranslationName = 'PAGE_TITLE_' . strtoupper($this->getConfig()->getActiveView()->getClassName());
1937  $sTranslated = $oLang->translateString($sTranslationName, oxRegistry::getLang()->getBaseLanguage(), false);
1938 
1939  return $sTranslationName == $sTranslated ? null : $sTranslated;
1940  }
1941 
1947  public function getActiveLangAbbr()
1948  {
1949  // Performance
1950  if (!$this->getConfig()->getConfigParam('bl_perfLoadLanguages')) {
1951  return;
1952  }
1953 
1954  if (!isset($this->_sActiveLangAbbr)) {
1955  $aLanguages = oxRegistry::getLang()->getLanguageArray();
1956  while (list($sKey, $oVal) = each($aLanguages)) {
1957  if ($oVal->selected) {
1958  $this->_sActiveLangAbbr = $oVal->abbr;
1959  break;
1960  }
1961  }
1962  }
1963 
1964  return $this->_sActiveLangAbbr;
1965  }
1966 
1974  public function addGlobalParams($oShop = null)
1975  {
1976  $oViewConf = parent::addGlobalParams($oShop);
1977 
1978  $this->_setNrOfArtPerPage();
1979 
1980  return $oViewConf;
1981  }
1982 
1988  public function getAdditionalParams()
1989  {
1990  if ($this->_sAdditionalParams === null) {
1991  // #1018A
1992  $this->_sAdditionalParams = parent::getAdditionalParams();
1993  $this->_sAdditionalParams .= 'cl=' . $this->getConfig()->getTopActiveView()->getClassName();
1994 
1995  // #1834M - specialchar search
1996  $sSearchParamForLink = rawurlencode(oxRegistry::getConfig()->getRequestParameter('searchparam', true));
1997  if (isset($sSearchParamForLink)) {
1998  $this->_sAdditionalParams .= "&amp;searchparam={$sSearchParamForLink}";
1999  }
2000  if (($sVar = oxRegistry::getConfig()->getRequestParameter('searchtag'))) {
2001  $this->_sAdditionalParams .= '&amp;searchtag=' . rawurlencode(rawurldecode($sVar));
2002  }
2003  if (($sVar = oxRegistry::getConfig()->getRequestParameter('searchcnid'))) {
2004  $this->_sAdditionalParams .= '&amp;searchcnid=' . rawurlencode(rawurldecode($sVar));
2005  }
2006  if (($sVar = oxRegistry::getConfig()->getRequestParameter('searchvendor'))) {
2007  $this->_sAdditionalParams .= '&amp;searchvendor=' . rawurlencode(rawurldecode($sVar));
2008  }
2009  if (($sVar = oxRegistry::getConfig()->getRequestParameter('searchmanufacturer'))) {
2010  $this->_sAdditionalParams .= '&amp;searchmanufacturer=' . rawurlencode(rawurldecode($sVar));
2011  }
2012  if (($sVar = oxRegistry::getConfig()->getRequestParameter('cnid'))) {
2013  $this->_sAdditionalParams .= '&amp;cnid=' . rawurlencode(rawurldecode($sVar));
2014  }
2015  if (($sVar = oxRegistry::getConfig()->getRequestParameter('mnid'))) {
2016  $this->_sAdditionalParams .= '&amp;mnid=' . rawurlencode(rawurldecode($sVar));
2017  }
2018  }
2019 
2021  }
2022 
2028  public function generatePageNavigationUrl()
2029  {
2030  return $this->getConfig()->getShopHomeURL() . $this->_getRequestParams(false);
2031  }
2032 
2042  protected function _addPageNrParam($sUrl, $iPage, $iLang = null)
2043  {
2044  if ($iPage) {
2045  if ((strpos($sUrl, 'pgNr='))) {
2046  $sUrl = preg_replace('/pgNr=[0-9]*/', 'pgNr=' . $iPage, $sUrl);
2047  } else {
2048  $sUrl .= ((strpos($sUrl, '?') === false) ? '?' : '&amp;') . 'pgNr=' . $iPage;
2049  }
2050  } else {
2051  $sUrl = preg_replace('/pgNr=[0-9]*/', '', $sUrl);
2052  $sUrl = preg_replace('/\&amp\;\&amp\;/', '&amp;', $sUrl);
2053  $sUrl = preg_replace('/\?\&amp\;/', '?', $sUrl);
2054  $sUrl = preg_replace('/\&amp\;$/', '', $sUrl);
2055  }
2056 
2057  return $sUrl;
2058  }
2059 
2063  public function getPageNavigation()
2064  {
2065 
2066  }
2067 
2075  public function getPageNavigationLimitedTop($iPositionCount = 7)
2076  {
2077  $this->_oPageNavigation = $this->generatePageNavigation($iPositionCount);
2078 
2079  return $this->_oPageNavigation;
2080  }
2081 
2089  public function getPageNavigationLimitedBottom($iPositionCount = 11)
2090  {
2091  $this->_oPageNavigation = $this->generatePageNavigation($iPositionCount);
2092 
2093  return $this->_oPageNavigation;
2094  }
2095 
2096 
2104  public function generatePageNavigation($iPositionCount = 0)
2105  {
2106  startProfile('generatePageNavigation');
2107 
2108  $pageNavigation = new stdClass();
2109 
2110  $pageNavigation->NrOfPages = $this->_iCntPages;
2111  $iActPage = $this->getActPage();
2112  $pageNavigation->actPage = $iActPage + 1;
2113  $sUrl = $this->generatePageNavigationUrl();
2114 
2115  if ($iPositionCount == 0 || ($iPositionCount >= $pageNavigation->NrOfPages)) {
2116  $iStartNo = 2;
2117  $iFinishNo = $pageNavigation->NrOfPages;
2118  } else {
2119  $iTmpVal = $iPositionCount - 3;
2120  $iTmpVal2 = floor(($iPositionCount - 4) / 2);
2121 
2122  // actual page is at the start
2123  if ($pageNavigation->actPage <= $iTmpVal) {
2124  $iStartNo = 2;
2125  $iFinishNo = $iTmpVal + 1;
2126  // actual page is at the end
2127  } elseif ($pageNavigation->actPage >= $pageNavigation->NrOfPages - $iTmpVal) {
2128  $iStartNo = $pageNavigation->NrOfPages - $iTmpVal;
2129  $iFinishNo = $pageNavigation->NrOfPages - 1;
2130  // actual page is in the middle
2131  } else {
2132  $iStartNo = $pageNavigation->actPage - $iTmpVal2;
2133  $iFinishNo = $pageNavigation->actPage + $iTmpVal2;
2134  }
2135  }
2136 
2137  if ($iActPage > 0) {
2138  $pageNavigation->previousPage = $this->_addPageNrParam($sUrl, $iActPage - 1);
2139  }
2140 
2141  if ($iActPage < $pageNavigation->NrOfPages - 1) {
2142  $pageNavigation->nextPage = $this->_addPageNrParam($sUrl, $iActPage + 1);
2143  }
2144 
2145  if ($pageNavigation->NrOfPages > 1) {
2146 
2147  for ($i = 1; $i < $pageNavigation->NrOfPages + 1; $i++) {
2148 
2149  if ($i == 1 || $i == $pageNavigation->NrOfPages || ($i >= $iStartNo && $i <= $iFinishNo)) {
2150  $page = new stdClass();
2151  $page->url = $this->_addPageNrParam($sUrl, $i - 1);
2152  $page->selected = ($i == $pageNavigation->actPage) ? 1 : 0;
2153  $pageNavigation->changePage[$i] = $page;
2154  }
2155  }
2156 
2157  // first/last one
2158  $pageNavigation->firstpage = $this->_addPageNrParam($sUrl, 0);
2159  $pageNavigation->lastpage = $this->_addPageNrParam($sUrl, $pageNavigation->NrOfPages - 1);
2160  }
2161 
2162  stopProfile('generatePageNavigation');
2163 
2164  return $pageNavigation;
2165  }
2166 
2173  public function render()
2174  {
2175  foreach (array_keys($this->_oaComponents) as $sComponentName) {
2176  $this->_aViewData[$sComponentName] = $this->_oaComponents[$sComponentName]->render();
2177  }
2178 
2179  parent::render();
2180 
2181  if ($this->getIsOrderStep()) {
2182 
2183  // disabling navigation during order ...
2184  if ($this->getConfig()->getConfigParam('blDisableNavBars')) {
2185  $this->_iNewsRealStatus = 1;
2186  $this->setShowNewsletter(0);
2187  }
2188  }
2189 
2190  return $this->_sThisTemplate;
2191  }
2192 
2198  public function getViewProduct()
2199  {
2200  return $this->getProduct();
2201  }
2202 
2208  public function setViewProduct($oProduct)
2209  {
2210  $this->_oProduct = $oProduct;
2211  }
2212 
2218  public function getViewProductList()
2219  {
2220  return $this->_aArticleList;
2221  }
2222 
2228  public function getActPage()
2229  {
2230  if ($this->_iActPage === null) {
2231  $this->_iActPage = ( int ) $this->getConfig()->getRequestParameter('pgNr');
2232  $this->_iActPage = ($this->_iActPage < 0) ? 0 : $this->_iActPage;
2233  }
2234 
2235  return $this->_iActPage;
2236  }
2237 
2245  public function getActTag()
2246  {
2247  if ($this->_oActTag === null) {
2248  $this->_oActTag = new stdClass();
2249  $this->_oActTag->sTag = $sTag = $this->getConfig()->getRequestParameter("searchtag", 1);
2250  $oSeoEncoderTag = oxRegistry::get("oxSeoEncoderTag");
2251 
2252  $sLink = false;
2253  if (oxRegistry::getUtils()->seoIsActive()) {
2254  $sLink = $oSeoEncoderTag->getTagUrl($sTag, oxRegistry::getLang()->getBaseLanguage());
2255  }
2256 
2257  $sConstructedUrl = $this->getConfig()->getShopHomeURL() . $oSeoEncoderTag->getStdTagUri($sTag, false);
2258  $this->_oActTag->link = $sLink ? $sLink : $sConstructedUrl;
2259  }
2260 
2261  return $this->_oActTag;
2262  }
2263 
2271  public function getActVendor()
2272  {
2273  // if active vendor is not set yet - trying to load it from request params
2274  // this may be useful when category component was unable to load active vendor
2275  // and we still need some object to mount navigation info
2276  if ($this->_oActVendor === null) {
2277  $this->_oActVendor = false;
2278  $sVendorId = $this->getConfig()->getRequestParameter('cnid');
2279  $sVendorId = $sVendorId ? str_replace('v_', '', $sVendorId) : $sVendorId;
2280  $oVendor = oxNew('oxVendor');
2281  if ($oVendor->load($sVendorId)) {
2282  $this->_oActVendor = $oVendor;
2283  }
2284  }
2285 
2286  return $this->_oActVendor;
2287  }
2288 
2296  public function getActManufacturer()
2297  {
2298  // if active Manufacturer is not set yet - trying to load it from request params
2299  // this may be useful when category component was unable to load active Manufacturer
2300  // and we still need some object to mount navigation info
2301  if ($this->_oActManufacturer === null) {
2302 
2303  $this->_oActManufacturer = false;
2304  $sManufacturerId = $this->getConfig()->getRequestParameter('mnid');
2305  $oManufacturer = oxNew('oxManufacturer');
2306  if ($oManufacturer->load($sManufacturerId)) {
2307  $this->_oActManufacturer = $oManufacturer;
2308  }
2309  }
2310 
2311  return $this->_oActManufacturer;
2312  }
2313 
2319  public function setActVendor($oVendor)
2320  {
2321  $this->_oActVendor = $oVendor;
2322  }
2323 
2329  public function setActManufacturer($oManufacturer)
2330  {
2331  $this->_oActManufacturer = $oManufacturer;
2332  }
2333 
2339  public function getActSearch()
2340  {
2341  if ($this->_oActSearch === null) {
2342  $this->_oActSearch = new stdClass();
2343  $sUrl = $this->getConfig()->getShopHomeURL();
2344  $this->_oActSearch->link = "{$sUrl}cl=search";
2345  }
2346 
2347  return $this->_oActSearch;
2348  }
2349 
2355  public function getCategoryTree()
2356  {
2357  return $this->_oCategoryTree;
2358  }
2359 
2365  public function setCategoryTree($oCatTree)
2366  {
2367  $this->_oCategoryTree = $oCatTree;
2368  }
2369 
2375  public function getManufacturerTree()
2376  {
2378  }
2379 
2385  public function setManufacturerTree($oManufacturerTree)
2386  {
2387  $this->_oManufacturerTree = $oManufacturerTree;
2388  }
2389 
2393  public function getAddUrlParams()
2394  {
2395  }
2396 
2405  public function getTop5ArticleList($iCount = null)
2406  {
2407  if ($this->_blTop5Action) {
2408  if ($this->_aTop5ArticleList === null) {
2409  $this->_aTop5ArticleList = false;
2410  $myConfig = $this->getConfig();
2411  if ($myConfig->getConfigParam('bl_perfLoadAktion')) {
2412  // top 5 articles
2413  $oArtList = oxNew('oxArticleList');
2414  $oArtList->loadTop5Articles($iCount);
2415  if ($oArtList->count()) {
2416  $this->_aTop5ArticleList = $oArtList;
2417  }
2418  }
2419  }
2420  }
2421 
2422  return $this->_aTop5ArticleList;
2423  }
2424 
2431  public function getBargainArticleList()
2432  {
2433  if ($this->_blBargainAction) {
2434  if ($this->_aBargainArticleList === null) {
2435  $this->_aBargainArticleList = array();
2436  if ($this->getConfig()->getConfigParam('bl_perfLoadAktion')) {
2437  $oArtList = oxNew('oxArticleList');
2438  $oArtList->loadActionArticles('OXBARGAIN');
2439  if ($oArtList->count()) {
2440  $this->_aBargainArticleList = $oArtList;
2441  }
2442  }
2443  }
2444  }
2445 
2447  }
2448 
2457  public function isLowOrderPrice()
2458  {
2459  if ($this->_blLowOrderPrice === null && ($oBasket = $this->getSession()->getBasket())) {
2460  $this->_blLowOrderPrice = $oBasket->isBelowMinOrderPrice();
2461  }
2462 
2463  return $this->_blLowOrderPrice;
2464  }
2465 
2473  public function getMinOrderPrice()
2474  {
2475  if ($this->_sMinOrderPrice === null && $this->isLowOrderPrice()) {
2476  $dMinOrderPrice = oxPrice::getPriceInActCurrency($this->getConfig()->getConfigParam('iMinOrderPrice'));
2477  $this->_sMinOrderPrice = oxRegistry::getLang()->formatCurrency($dMinOrderPrice);
2478  }
2479 
2480  return $this->_sMinOrderPrice;
2481  }
2482 
2488  public function getNewsRealStatus()
2489  {
2490  return $this->_iNewsRealStatus;
2491  }
2492 
2498  protected function _canRedirect()
2499  {
2500  foreach ($this->_aBlockRedirectParams as $sParam) {
2501  if ($this->getConfig()->getRequestParameter($sParam) !== null) {
2502  return false;
2503  }
2504  }
2505 
2506  return true;
2507  }
2508 
2512  public function getProduct()
2513  {
2514  }
2515 
2521  public function getManufacturerlist()
2522  {
2524  }
2525 
2531  public function setManufacturerlist($aList)
2532  {
2533  $this->_aManufacturerlist = $aList;
2534  }
2535 
2541  public function setRootVendor($oVendor)
2542  {
2543  $this->_oRootVendor = $oVendor;
2544  }
2545 
2551  public function getRootVendor()
2552  {
2553  return $this->_oRootVendor;
2554  }
2555 
2561  public function setRootManufacturer($oManufacturer)
2562  {
2563  $this->_oRootManufacturer = $oManufacturer;
2564  }
2565 
2571  public function getRootManufacturer()
2572  {
2574  }
2575 
2581  public function getVendorId()
2582  {
2583  if ($this->_sVendorId === null) {
2584  $this->_sVendorId = false;
2585  if (($oVendor = $this->getActVendor())) {
2586  $this->_sVendorId = $oVendor->getId();
2587  }
2588  }
2589 
2590  return $this->_sVendorId;
2591  }
2592 
2598  public function getManufacturerId()
2599  {
2600  if ($this->_sManufacturerId === null) {
2601  $this->_sManufacturerId = false;
2602  if (($oManufacturer = $this->getActManufacturer())) {
2603  $this->_sManufacturerId = $oManufacturer->getId();
2604  }
2605  }
2606 
2607  return $this->_sManufacturerId;
2608  }
2609 
2615  public function getCatMoreUrl()
2616  {
2617  return $this->getConfig()->getShopHomeURL() . 'cnid=oxmore';
2618  }
2619 
2625  public function getCatTreePath()
2626  {
2627  return $this->_sCatTreePath;
2628  }
2629 
2637  public function getContentByIdent($sIdent)
2638  {
2639  if (!isset($this->_aContents[$sIdent])) {
2640  $this->_aContents[$sIdent] = oxNew('oxContent');
2641  $this->_aContents[$sIdent]->loadByIdent($sIdent);
2642  }
2643 
2644  return $this->_aContents[$sIdent];
2645  }
2646 
2652  public function getContentCategory()
2653  {
2654  return false;
2655  }
2656 
2662  public function getMustFillFields()
2663  {
2664  if ($this->_aMustFillFields === null) {
2665  $this->_aMustFillFields = false;
2666 
2667  // passing must-be-filled-fields info
2668  $aMustFillFields = $this->getConfig()->getConfigParam('aMustFillFields');
2669  if (is_array($aMustFillFields)) {
2670  $this->_aMustFillFields = array_flip($aMustFillFields);
2671  }
2672  }
2673 
2674  return $this->_aMustFillFields;
2675  }
2676 
2684  public function isFieldRequired($sField)
2685  {
2686  if ($aMustFillFields = $this->getMustFillFields()) {
2687  if (isset($aMustFillFields[$sField])) {
2688  return true;
2689  }
2690  }
2691 
2692  return false;
2693  }
2694 
2700  public function getFormId()
2701  {
2702  if ($this->_sFormId === null) {
2703  $this->_sFormId = oxUtilsObject::getInstance()->generateUId();
2704  oxRegistry::getSession()->setVariable('sessionuformid', $this->_sFormId);
2705  }
2706 
2707  return $this->_sFormId;
2708  }
2709 
2715  public function canAcceptFormData()
2716  {
2717  if ($this->_blCanAcceptFormData === null) {
2718  $this->_blCanAcceptFormData = false;
2719 
2720  $sFormId = $this->getConfig()->getRequestParameter("uformid");
2721  $sSessionFormId = oxRegistry::getSession()->getVariable("sessionuformid");
2722 
2723  // testing if form and session ids matches
2724  if ($sFormId && $sFormId === $sSessionFormId) {
2725  $this->_blCanAcceptFormData = true;
2726  }
2727 
2728  // regenerating form data
2729  $this->getFormId();
2730  }
2731 
2732  return $this->_blCanAcceptFormData;
2733  }
2734 
2740  public function getPromoFinishedList()
2741  {
2742  if (isset($this->_oPromoFinishedList)) {
2743  return $this->_oPromoFinishedList;
2744  }
2745  $this->_oPromoFinishedList = oxNew('oxActionList');
2746  $this->_oPromoFinishedList->loadFinishedByCount(2);
2747 
2748  return $this->_oPromoFinishedList;
2749  }
2750 
2756  public function getPromoCurrentList()
2757  {
2758  if (isset($this->_oPromoCurrentList)) {
2759  return $this->_oPromoCurrentList;
2760  }
2761  $this->_oPromoCurrentList = oxNew('oxActionList');
2762  $this->_oPromoCurrentList->loadCurrent();
2763 
2764  return $this->_oPromoCurrentList;
2765  }
2766 
2772  public function getPromoFutureList()
2773  {
2774  if (isset($this->_oPromoFutureList)) {
2775  return $this->_oPromoFutureList;
2776  }
2777  $this->_oPromoFutureList = oxNew('oxActionList');
2778  $this->_oPromoFutureList->loadFutureByCount(2);
2779 
2780  return $this->_oPromoFutureList;
2781  }
2782 
2788  public function getShowPromotionList()
2789  {
2790  if (isset($this->_blShowPromotions)) {
2791  return $this->_blShowPromotions;
2792  }
2793  $this->_blShowPromotions = false;
2794  if (oxNew('oxActionList')->areAnyActivePromotions()) {
2795  $this->_blShowPromotions = (count($this->getPromoFinishedList()) + count($this->getPromoCurrentList()) +
2796  count($this->getPromoFutureList())) > 0;
2797  }
2798 
2799  return $this->_blShowPromotions;
2800  }
2801 
2807  public function isEnabledPrivateSales()
2808  {
2809  if ($this->_blEnabledPrivateSales === null) {
2810  $this->_blEnabledPrivateSales = (bool) $this->getConfig()->getConfigParam('blPsLoginEnabled');
2811  if ($this->_blEnabledPrivateSales && ($blCanPreview = oxRegistry::getUtils()->canPreview()) !== null) {
2812  $this->_blEnabledPrivateSales = !$blCanPreview;
2813  }
2814  }
2815 
2817  }
2818 
2824  public function getFieldValidationErrors()
2825  {
2826  return oxRegistry::get("oxInputValidator")->getFieldValidationErrors();
2827  }
2828 
2834  public function getBreadCrumb()
2835  {
2836  return null;
2837  }
2838 
2844  public function setRootCatChanged($blRootCatChanged)
2845  {
2846  $this->_blRootCatChanged = $blRootCatChanged;
2847  }
2848 
2854  public function isRootCatChanged()
2855  {
2856  return $this->_blRootCatChanged;
2857  }
2858 
2864  public function getInvoiceAddress()
2865  {
2866  if ($this->_aInvoiceAddress == null) {
2867  $aAddress = $this->getConfig()->getRequestParameter('invadr');
2868  if ($aAddress) {
2869  $this->_aInvoiceAddress = $aAddress;
2870  }
2871  }
2872 
2873  return $this->_aInvoiceAddress;
2874  }
2875 
2881  public function getDeliveryAddress()
2882  {
2883  if ($this->_aDeliveryAddress == null) {
2884  $oConfig = $this->getConfig();
2885  //do not show deladr if address was reloaded
2886  if (!$oConfig->getRequestParameter('reloadaddress')) {
2887  $this->_aDeliveryAddress = $oConfig->getRequestParameter('deladr');
2888  }
2889  }
2890 
2891  return $this->_aDeliveryAddress;
2892  }
2893 
2899  public function setDeliveryAddress($aDeliveryAddress)
2900  {
2901  $this->_aDeliveryAddress = $aDeliveryAddress;
2902  }
2903 
2909  public function setInvoiceAddress($aAddress)
2910  {
2911  $this->_aInvoiceAddress = $aAddress;
2912  }
2913 
2919  public function getActiveUsername()
2920  {
2921  if ($this->_sActiveUsername == null) {
2922  $this->_sActiveUsername = false;
2923  $sUsername = $this->getConfig()->getRequestParameter('lgn_usr');
2924  if ($sUsername) {
2925  $this->_sActiveUsername = $sUsername;
2926  } elseif ($oUser = $this->getUser()) {
2927  $this->_sActiveUsername = $oUser->oxuser__oxusername->value;
2928  }
2929  }
2930 
2931  return $this->_sActiveUsername;
2932  }
2933 
2939  public function getWishlistUserId()
2940  {
2941  return $this->getConfig()->getRequestParameter('wishid');
2942  }
2943 
2947  public function getSearchCatId()
2948  {
2949  }
2950 
2954  public function getSearchVendor()
2955  {
2956  }
2957 
2961  public function getSearchManufacturer()
2962  {
2963  }
2964 
2968  public function getLastProducts()
2969  {
2970 
2971  }
2972 
2978  public function getNewBasketItemMsgType()
2979  {
2980  return (int) $this->getConfig()->getConfigParam("iNewBasketItemMessage");
2981  }
2982 
2990  public function isActive($sName)
2991  {
2992  return $this->getConfig()->getConfigParam("bl" . $sName . "Enabled");
2993  }
2994 
3000  public function isFbWidgetVisible()
3001  {
3002  if ($this->_blFbWidgetsOn === null) {
3003  $oUtils = oxRegistry::get("oxUtilsServer");
3004 
3005  // reading ..
3006  $this->_blFbWidgetsOn = (bool) $oUtils->getOxCookie("fbwidgetson");
3007  }
3008 
3009  return $this->_blFbWidgetsOn;
3010  }
3011 
3017  public function isEnabledDownloadableFiles()
3018  {
3019  return (bool) $this->getConfig()->getConfigParam("blEnableDownloads");
3020  }
3021 
3027  public function showRememberMe()
3028  {
3029  return (bool) $this->getConfig()->getConfigParam('blShowRememberMe');
3030  }
3031 
3038  public function isVatIncluded()
3039  {
3040  $blResult = true;
3041  $oUser = $this->getUser();
3042  $oConfig = $this->getConfig();
3043 
3044  $blShowNetPriceParameter = $oConfig->getConfigParam('blShowNetPrice');
3045  $blPerfCalcVatOnlyForBasketOrderParameter = $oConfig->getConfigParam('bl_perfCalcVatOnlyForBasketOrder');
3046  if ($blShowNetPriceParameter || $blPerfCalcVatOnlyForBasketOrderParameter) {
3047  $blResult = false;
3048  } elseif ($oUser && $oUser->isPriceViewModeNetto()) {
3049  $blResult = false;
3050  }
3051 
3052  return $blResult;
3053  }
3054 
3060  public function isPriceCalculated()
3061  {
3062  return (bool) $this->getConfig()->getConfigParam('bl_perfLoadPrice');
3063  }
3064 
3070  public function showTags()
3071  {
3072  return (bool) $this->_blShowTagCloud && $this->getConfig()->getConfigParam("blShowTags");
3073  }
3074 
3080  public function getWishlistName()
3081  {
3082  if ($this->getUser()) {
3083  $sWishId = $this->getConfig()->getRequestParameter('wishid');
3084  $sUserId = ($sWishId) ? $sWishId : oxRegistry::getSession()->getVariable('wishid');
3085  if ($sUserId) {
3086  $oWishUser = oxNew('oxUser');
3087  if ($oWishUser->load($sUserId)) {
3088  return $oWishUser;
3089  }
3090  }
3091  }
3092 
3093  return false;
3094  }
3095 
3101  public function getWidgetLink()
3102  {
3103  return oxRegistry::getConfig()->getWidgetUrl();
3104  }
3105 }