OXID eShop CE  4.10.1
 All Classes Namespaces 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 
27  protected $_blFbWidgetsOn = null;
28 
34  protected $_sRemoveMetaChars = '.\+*?[^]$(){}=!<>|:&';
35 
41  protected $_oaComponents = array();
42 
48  protected $_blIsOrderStep = false;
49 
55  protected $_sListType = null;
56 
62  protected $_aListDisplayTypes = array('grid', 'line', 'infogrid');
63 
69  protected $_sListDisplayType = null;
70 
76  protected $_sCustomListDisplayType = null;
77 
83  protected $_oActCategory = null;
84 
90  protected $_oActManufacturer = null;
91 
97  protected $_oActVendor = null;
98 
106  protected $_oActiveRecommList = null;
107 
113  protected $_oActSearch = null;
114 
120  protected $_blShowSorting = false;
121 
127  protected $_blLoadCurrency = null;
128 
134  protected $_blLoadManufacturerTree = null;
135 
141  protected $_blDontShowEmptyCats = null;
142 
148  protected $_blLoadLanguage = null;
149 
155  protected $_iTopCatNavItmCnt = null;
156 
162  protected $_aRssLinks = null;
163 
169  protected $_sListOrderBy = null;
170 
176  protected $_sListOrderDir = null;
177 
183  protected $_sMetaDescription = null;
184 
190  protected $_sMetaKeywords = null;
191 
197  protected $_sMetaDescriptionIdent = null;
198 
204  protected $_sMetaKeywordsIdent = null;
205 
211  protected $_sAdditionalParams = null;
212 
218  protected $_oActCurrency = null;
219 
225  protected $_blEnabledPrivateSales = null;
226 
234  protected $_blCommonAdded = false;
235 
243 
250  protected $_blForceNoIndex = false;
251 
257  protected $_iCompItemsCnt = null;
258 
264  protected $_sContentId = null;
265 
271  protected $_oContent = null;
272 
278  protected $_sViewResetID = null;
279 
285  protected $_aMenueList = null;
286 
293  protected $_aComponentNames = array(
294  'oxcmp_user' => 1, // 0 means dont init if cached
295  'oxcmp_lang' => 0,
296  'oxcmp_cur' => 1,
297  'oxcmp_shop' => 1,
298  'oxcmp_categories' => 0,
299  'oxcmp_utils' => 1,
300  // @deprecated since v.5.3.0 (2016-06-17); The Admin Menu: Customer Info -> News feature will be moved to a module in v6.0.0
301  'oxcmp_news' => 0,
302  // END deprecated
303  'oxcmp_basket' => 1
304  );
305 
312  protected $_aUserComponentNames = array();
313 
319  protected $_oProduct = null;
320 
326  protected $_iActPage = null;
327 
333  protected $_aArticleList = null;
334 
340  protected $_oManufacturerTree = null;
341 
347  protected $_oCategoryTree = null;
348 
354  protected $_aTop5ArticleList = null;
355 
361  protected $_aBargainArticleList = null;
362 
368  protected $_blLowOrderPrice = null;
369 
375  protected $_sMinOrderPrice = null;
376 
382  protected $_iNewsRealStatus = null;
383 
389  protected $_aBlockRedirectParams = array('fnc', 'stoken', 'force_sid', 'force_admin_sid');
390 
396  protected $_oRootVendor = null;
397 
403  protected $_sVendorId = null;
404 
410  protected $_aManufacturerlist = null;
411 
417  protected $_oRootManufacturer = null;
418 
424  protected $_sManufacturerId = null;
425 
431  protected $_blNewsSubscribed = null;
432 
438  protected $_oDelAddress = null;
439 
445  protected $_sCatTreePath = null;
446 
452  protected $_aContents = array();
453 
459  protected $_blTop5Action = false;
460 
466  protected $_blBargainAction = false;
467 
473  protected $_aMustFillFields = null;
474 
482  protected $_blShowTagCloud = true;
483 
489  protected $_blRootCatChanged = false;
490 
496  protected $_aInvoiceAddress = null;
497 
503  protected $_aDeliveryAddress = null;
504 
510  protected $_sActiveUsername = null;
511 
518  protected static $_aCollectedComponentNames = null;
519 
526  protected $_blLoadComponents = true;
527 
528 
534  protected $_aSortColumns = null;
535 
541  protected function _getComponentNames()
542  {
543  if (self::$_aCollectedComponentNames === null) {
544  self::$_aCollectedComponentNames = array_merge($this->_aComponentNames, $this->_aUserComponentNames);
545 
546  // #1721: custom component handling. At the moment it is not possible to override this variable in oxubase,
547  // so we added this array to config.inc.php file
548  if (($aUserCmps = $this->getConfig()->getConfigParam('aUserComponentNames'))) {
549  self::$_aCollectedComponentNames = array_merge(self::$_aCollectedComponentNames, $aUserCmps);
550  }
551 
552  if (oxRegistry::getConfig()->getRequestParameter('_force_no_basket_cmp')) {
553  unset(self::$_aCollectedComponentNames['oxcmp_basket']);
554  }
555  }
556 
557  // resetting array pointer
558  reset(self::$_aCollectedComponentNames);
559 
561  }
562 
569  protected function _processRequest()
570  {
571  $myUtils = oxRegistry::getUtils();
572 
573  // non admin, request is not empty and was not processed by seo engine
574  if (!isSearchEngineUrl() && $myUtils->seoIsActive() && ($sStdUrl = getRequestUrl('', true))) {
575 
576  // fetching standard url and looking for it in seo table
577  if ($this->_canRedirect() && ($sRedirectUrl = oxRegistry::get("oxSeoEncoder")->fetchSeoUrl($sStdUrl))) {
578  $myUtils->redirect($this->getConfig()->getCurrentShopUrl() . $sRedirectUrl, false);
579  } elseif (VIEW_INDEXSTATE_INDEX == $this->noIndex()) {
580  // forcing to set no index/follow meta
581  $this->_forceNoIndex();
582 
583  if ($this->getConfig()->getConfigParam('blSeoLogging')) {
584  $sShopId = $this->getConfig()->getShopId();
585  $sLangId = oxRegistry::getLang()->getBaseLanguage();
586  $sIdent = md5(strtolower($sStdUrl) . $sShopId . $sLangId);
587 
588  // logging "not found" url
589  $oDb = oxDb::getDb();
590  $oDb->execute(
591  "replace oxseologs ( oxstdurl, oxident, oxshopid, oxlang )
592  values ( " . $oDb->quote($sStdUrl) . ", '{$sIdent}', '{$sShopId}', '{$sLangId}' ) "
593  );
594  }
595  }
596  }
597  }
598 
603  public function init()
604  {
605  $this->_processRequest();
606 
607  // storing current view
608  $blInit = true;
609 
610 
611  // init all components if there are any
612  if ($this->_blLoadComponents) {
613  foreach ($this->_getComponentNames() as $sComponentName => $blNotCacheable) {
614  // do not override initiated components
615  if (!isset($this->_oaComponents[$sComponentName])) {
616  // component objects MUST be created to support user called functions
617  $oComponent = oxNew($sComponentName);
618  $oComponent->setParent($this);
619  $oComponent->setThisAction($sComponentName);
620  $this->_oaComponents[$sComponentName] = $oComponent;
621  }
622 
623  // do we really need to initiate them ?
624  if ($blInit) {
625  $this->_oaComponents[$sComponentName]->init();
626 
627  // executing only is view does not have action method
628  if (!method_exists($this, $this->getFncName())) {
629  $this->_oaComponents[$sComponentName]->executeFunction($this->getFncName());
630  }
631  }
632  }
633  }
634 
635  parent::init();
636  }
637 
644  public function getViewId()
645  {
646  if ($this->_sViewId) {
647  return $this->_sViewId;
648  }
649 
650  $oConfig = $this->getConfig();
651  $iLang = oxRegistry::getLang()->getBaseLanguage();
652  $iCur = (int) $oConfig->getShopCurrency();
653 
654 
655  $this->_sViewId = "ox|$iLang|$iCur";
656 
657  $this->_sViewId .= "|" . ((int) $this->_blForceNoIndex) . '|' . ((int) $this->isRootCatChanged());
658 
659  // #0004798: SSL should be included in viewId
660  if ($oConfig->isSsl()) {
661  $this->_sViewId .= "|ssl";
662  }
663 
664  // #0002866: external global viewID addition
665  if (function_exists('customGetViewId')) {
666  $oExtViewId = customGetViewId();
667 
668  if ($oExtViewId !== null) {
669  $this->_sViewId .= '|' . md5(serialize($oExtViewId));
670  }
671  }
672 
673  return $this->_sViewId;
674  }
675 
676 
682  public function showSorting()
683  {
684  return $this->_blShowSorting && $this->getConfig()->getConfigParam('blShowSorting');
685  }
686 
692  public function setComponents($aComponents = null)
693  {
694  $this->_oaComponents = $aComponents;
695  }
696 
702  public function getComponents()
703  {
704  return $this->_oaComponents;
705  }
706 
714  public function getComponent($sName)
715  {
716  if (isset($sName) && isset($this->_oaComponents[$sName])) {
717  return $this->_oaComponents[$sName];
718  }
719  }
720 
726  public function setIsOrderStep($blIsOrderStep = null)
727  {
728  $this->_blIsOrderStep = $blIsOrderStep;
729  }
730 
736  public function getIsOrderStep()
737  {
738  return $this->_blIsOrderStep;
739  }
740 
741 
747  public function setActiveCategory($oCategory)
748  {
749  $this->_oActCategory = $oCategory;
750  }
751 
757  public function getActiveCategory()
758  {
759  return $this->_oActCategory;
760  }
761 
767  public function getListType()
768  {
769  if ($this->_sListType == null) {
770  if ($sListType = $this->getConfig()->getRequestParameter('listtype')) {
771  $this->_sListType = $sListType;
772  } elseif ($sListType = $this->getConfig()->getGlobalParameter('listtype')) {
773  $this->_sListType = $sListType;
774  }
775  }
776 
777  return $this->_sListType;
778  }
779 
785  public function getListDisplayType()
786  {
787  if ($this->_sListDisplayType == null) {
788  $this->_sListDisplayType = $this->getCustomListDisplayType();
789 
790  if (!$this->_sListDisplayType) {
791  $this->_sListDisplayType = $this->getConfig()->getConfigParam('sDefaultListDisplayType');
792  }
793 
794  $this->_sListDisplayType = in_array(( string ) $this->_sListDisplayType, $this->_aListDisplayTypes) ?
795  $this->_sListDisplayType : 'infogrid';
796 
797  // writing to session
798  if ($this->getConfig()->getRequestParameter('ldtype')) {
799  oxRegistry::getSession()->setVariable('ldtype', $this->_sListDisplayType);
800  }
801  }
802 
804  }
805 
811  public function getCustomListDisplayType()
812  {
813  if ($this->_sCustomListDisplayType == null) {
814  $this->_sCustomListDisplayType = $this->getConfig()->getRequestParameter('ldtype');
815 
816  if (!$this->_sCustomListDisplayType) {
817  $this->_sCustomListDisplayType = oxRegistry::getSession()->getVariable('ldtype');
818  }
819  }
820 
822  }
823 
829  public function setListType($sType)
830  {
831  $this->_sListType = $sType;
832  $this->getConfig()->setGlobalParameter('listtype', $sType);
833  }
834 
840  public function loadCurrency()
841  {
842  if ($this->_blLoadCurrency == null) {
843  $this->_blLoadCurrency = false;
844  if ($blLoadCurrency = $this->getConfig()->getConfigParam('bl_perfLoadCurrency')) {
845  $this->_blLoadCurrency = $blLoadCurrency;
846  }
847  }
848 
849  return $this->_blLoadCurrency;
850  }
851 
857  public function dontShowEmptyCategories()
858  {
859  if ($this->_blDontShowEmptyCats == null) {
860  $this->_blDontShowEmptyCats = false;
861  if ($blDontShowEmptyCats = $this->getConfig()->getConfigParam('blDontShowEmptyCategories')) {
862  $this->_blDontShowEmptyCats = $blDontShowEmptyCats;
863  }
864  }
865 
867  }
868 
874  public function showCategoryArticlesCount()
875  {
876  return $this->getConfig()->getConfigParam('bl_perfShowActionCatArticleCnt');
877  }
878 
884  public function isLanguageLoaded()
885  {
886  if ($this->_blLoadLanguage == null) {
887  $this->_blLoadLanguage = false;
888  if ($blLoadLanguage = $this->getConfig()->getConfigParam('bl_perfLoadLanguages')) {
889  $this->_blLoadLanguage = $blLoadLanguage;
890  }
891  }
892 
893  return $this->_blLoadLanguage;
894  }
895 
901  public function getTopNavigationCatCnt()
902  {
903  if ($this->_iTopCatNavItmCnt == null) {
904  $iTopCatNavItmCnt = $this->getConfig()->getConfigParam('iTopNaviCatCount');
905  $this->_iTopCatNavItmCnt = $iTopCatNavItmCnt ? $iTopCatNavItmCnt : 5;
906  }
907 
909  }
910 
918  public function addRssFeed($sTitle, $sUrl, $key = null)
919  {
920  if (!is_array($this->_aRssLinks)) {
921  $this->_aRssLinks = array();
922  }
923 
924  $sUrl = oxRegistry::get("oxUtilsUrl")->prepareUrlForNoSession($sUrl);
925 
926  if ($key === null) {
927  $this->_aRssLinks[] = array('title' => $sTitle, 'link' => $sUrl);
928  } else {
929  $this->_aRssLinks[$key] = array('title' => $sTitle, 'link' => $sUrl);
930  }
931  }
932 
938  public function getSortOrderByParameterName()
939  {
940  return 'listorderby';
941  }
942 
948  public function getSortOrderParameterName()
949  {
950  return 'listorder';
951  }
952 
953 
959  public function getSortIdent()
960  {
961  return 'alist';
962  }
963 
969  public function getDefaultSorting()
970  {
971  return null;
972  }
973 
979  public function getUserSelectedSorting()
980  {
981  $aSorting = null;
982  $oStr = getStr();
983  $oConfig = oxRegistry::getConfig();
984  $aSortDirections = array('desc', 'asc');
985 
986  $sSortBy = $oConfig->getRequestParameter($this->getSortOrderByParameterName());
987  $sSortDir = $oConfig->getRequestParameter($this->getSortOrderParameterName());
988 
989  if ($sSortBy && oxDb::getInstance()->isValidFieldName($sSortBy) && $sSortDir
990  && oxRegistry::getUtils()->isValidAlpha($sSortDir)
991  && in_array($oStr->strtolower($sSortDir), $aSortDirections)
992  && in_array($sSortBy, oxNew('oxArticle')->getFieldNames())
993  ) {
994  $aSorting = array('sortby' => $sSortBy, 'sortdir' => $sSortDir);
995  }
996 
997  return $aSorting;
998  }
999 
1000 
1008  public function getSavedSorting($sSortIdent)
1009  {
1010  $aSorting = oxRegistry::getSession()->getVariable('aSorting');
1011  if (isset($aSorting[$sSortIdent])) {
1012  return $aSorting[$sSortIdent];
1013  }
1014  }
1015 
1021  public function setListOrderBy($sColumn)
1022  {
1023  $this->_sListOrderBy = $sColumn;
1024  }
1025 
1031  public function setListOrderDirection($sDirection)
1032  {
1033  $this->_sListOrderDir = $sDirection;
1034  }
1035 
1041  public function getListOrderBy()
1042  {
1043  //if column is with table name split it
1044  $aColumns = explode('.', $this->_sListOrderBy);
1045 
1046  if (is_array($aColumns) && count($aColumns) > 1) {
1047  return $aColumns[1];
1048  }
1049 
1050  return $this->_sListOrderBy;
1051  }
1052 
1058  public function getListOrderDirection()
1059  {
1060  return $this->_sListOrderDir;
1061  }
1062 
1070  public function setMetaDescription($sDescription)
1071  {
1072  return $this->_sMetaDescription = $sDescription;
1073  }
1074 
1082  public function setMetaKeywords($sKeywords)
1083  {
1084  return $this->_sMetaKeywords = $sKeywords;
1085  }
1086 
1094  protected function _getMetaFromSeo($sDataType)
1095  {
1096  $sOxId = $this->_getSeoObjectId();
1097  $iLang = oxRegistry::getLang()->getBaseLanguage();
1098  $sShop = $this->getConfig()->getShopId();
1099 
1100  if ($sOxId && oxRegistry::getUtils()->seoIsActive() &&
1101  ($sKeywords = oxRegistry::get("oxSeoEncoder")->getMetaData($sOxId, $sDataType, $sShop, $iLang))
1102  ) {
1103  return $sKeywords;
1104  }
1105  }
1106 
1114  protected function _getMetaFromContent($sMetaIdent)
1115  {
1116  if ($sMetaIdent) {
1117  $oContent = oxNew('oxContent');
1118  if ($oContent->loadByIdent($sMetaIdent) &&
1119  $oContent->oxcontents__oxactive->value
1120  ) {
1121  return getStr()->strip_tags($oContent->oxcontents__oxcontent->value);
1122  }
1123  }
1124  }
1125 
1131  public function getMetaKeywords()
1132  {
1133  if ($this->_sMetaKeywords === null) {
1134  $this->_sMetaKeywords = false;
1135 
1136  // set special meta keywords ?
1137  if (($sKeywords = $this->_getMetaFromSeo('oxkeywords'))) {
1138  $this->_sMetaKeywords = $sKeywords;
1139  } elseif (($sKeywords = $this->_getMetaFromContent($this->_sMetaKeywordsIdent))) {
1140  $this->_sMetaKeywords = $this->_prepareMetaKeyword($sKeywords, false);
1141  } else {
1142  $this->_sMetaKeywords = $this->_prepareMetaKeyword(false, true);
1143  }
1144  }
1145 
1146  return $this->_sMetaKeywords;
1147  }
1148 
1154  public function getMetaDescription()
1155  {
1156  if ($this->_sMetaDescription === null) {
1157  $this->_sMetaDescription = false;
1158 
1159  // set special meta description ?
1160  if (($sDescription = $this->_getMetaFromSeo('oxdescription'))) {
1161  $this->_sMetaDescription = $sDescription;
1162  } elseif (($sDescription = $this->_getMetaFromContent($this->_sMetaDescriptionIdent))) {
1163  $this->_sMetaDescription = $this->_prepareMetaDescription($sDescription);
1164  } else {
1165  $this->_sMetaDescription = $this->_prepareMetaDescription(false);
1166  }
1167  }
1168 
1169  return $this->_sMetaDescription;
1170  }
1171 
1177  public function getActCurrency()
1178  {
1179  return $this->_oActCurrency;
1180  }
1181 
1187  public function setActCurrency($oCur)
1188  {
1189  $this->_oActCurrency = $oCur;
1190  }
1191 
1197  public function getCompareItemCount()
1198  {
1199  if ($this->_iCompItemsCnt === null) {
1200  $aItems = oxRegistry::getSession()->getVariable('aFiltcompproducts');
1201  $this->_iCompItemsCnt = is_array($aItems) ? count($aItems) : 0;
1202  }
1203 
1204  return $this->_iCompItemsCnt;
1205  }
1206 
1210  protected function _forceNoIndex()
1211  {
1212  $this->_blForceNoIndex = true;
1213  }
1214 
1221  public function noIndex()
1222  {
1223  if ($this->_blForceNoIndex) {
1224  $this->_iViewIndexState = VIEW_INDEXSTATE_NOINDEXFOLLOW;
1225  } elseif ($this->getConfig()->getRequestParameter('cur')) {
1226  $this->_iViewIndexState = VIEW_INDEXSTATE_NOINDEXNOFOLLOW;
1227  } else {
1228  switch ($this->getConfig()->getRequestParameter('fnc')) {
1229  case 'tocomparelist':
1230  case 'tobasket':
1231  $this->_iViewIndexState = VIEW_INDEXSTATE_NOINDEXNOFOLLOW;
1232  break;
1233  }
1234  }
1235 
1236  return $this->_iViewIndexState;
1237  }
1238 
1244  public function getMenueList()
1245  {
1246  return $this->_aMenueList;
1247  }
1248 
1254  public function setMenueList($aMenu)
1255  {
1256  $this->_aMenueList = $aMenu;
1257  }
1258 
1262  protected function _setNrOfArtPerPage()
1263  {
1264  $myConfig = $this->getConfig();
1265 
1266  //setting default values to avoid possible errors showing article list
1267  $iNrofCatArticles = $myConfig->getConfigParam('iNrofCatArticles');
1268 
1269  $iNrofCatArticles = ($iNrofCatArticles) ? $iNrofCatArticles : 10;
1270 
1271  // checking if all needed data is set
1272  switch ($this->getListDisplayType()) {
1273  case 'grid':
1274  $aNrofCatArticles = $myConfig->getConfigParam('aNrofCatArticlesInGrid');
1275  break;
1276  case 'line':
1277  case 'infogrid':
1278  default:
1279  $aNrofCatArticles = $myConfig->getConfigParam('aNrofCatArticles');
1280  }
1281 
1282  if (!is_array($aNrofCatArticles) || !isset($aNrofCatArticles[0])) {
1283  $aNrofCatArticles = array($iNrofCatArticles);
1284  $myConfig->setConfigParam('aNrofCatArticles', $aNrofCatArticles);
1285  } else {
1286  $iNrofCatArticles = $aNrofCatArticles[0];
1287  }
1288 
1289  $oViewConf = $this->getViewConfig();
1290  //value from user input
1291  $oSession = oxRegistry::getSession();
1292  if (($iNrofArticles = (int) oxRegistry::getConfig()->getRequestParameter('_artperpage'))) {
1293  // M45 Possibility to push any "Show articles per page" number parameter
1294  $iNrofCatArticles = (in_array($iNrofArticles, $aNrofCatArticles)) ? $iNrofArticles : $iNrofCatArticles;
1295  $oViewConf->setViewConfigParam('iartPerPage', $iNrofCatArticles);
1296  $oSession->setVariable('_artperpage', $iNrofCatArticles);
1297  } elseif (($iSessArtPerPage = $oSession->getVariable('_artperpage')) && is_numeric($iSessArtPerPage)) {
1298  // M45 Possibility to push any "Show articles per page" number parameter
1299  $iNrofCatArticles = (in_array($iSessArtPerPage, $aNrofCatArticles)) ? $iSessArtPerPage : $iNrofCatArticles;
1300  $oViewConf->setViewConfigParam('iartPerPage', $iSessArtPerPage);
1301  $iNrofCatArticles = $iSessArtPerPage;
1302  } else {
1303  $oViewConf->setViewConfigParam('iartPerPage', $iNrofCatArticles);
1304  }
1305 
1306  //setting number of articles per page to config value
1307  $myConfig->setConfigParam('iNrofCatArticles', $iNrofCatArticles);
1308  }
1309 
1313  protected function _getSeoObjectId()
1314  {
1315  }
1316 
1326  protected function _prepareMetaDescription($sMeta, $iLength = 1024, $blRemoveDuplicatedWords = false)
1327  {
1328  if ($sMeta) {
1329 
1330  $oStr = getStr();
1331  if ($iLength != -1) {
1332  /* *
1333  * performance - we do not need a huge amount of initial text.
1334  * assume that effective text may be double longer than $iLength
1335  * and simple truncate it
1336  */
1337  $iELength = ($iLength * 2);
1338  $sMeta = $oStr->substr($sMeta, 0, $iELength);
1339  }
1340 
1341  // decoding html entities
1342  $sMeta = $oStr->html_entity_decode($sMeta);
1343  // stripping HTML tags
1344  $sMeta = $oStr->strip_tags($sMeta);
1345 
1346  // removing some special chars
1347  $sMeta = $oStr->cleanStr($sMeta);
1348 
1349  // removing duplicate words
1350  if ($blRemoveDuplicatedWords) {
1351  $sMeta = $this->_removeDuplicatedWords($sMeta, $this->getConfig()->getConfigParam('aSkipTags'));
1352  }
1353 
1354  // some special cases
1355  $sMeta = str_replace(' ,', ',', $sMeta);
1356  $aPattern = array("/,[\s\+\-\*]*,/", "/\s+,/");
1357  $sMeta = $oStr->preg_replace($aPattern, ',', $sMeta);
1358  $sMeta = oxRegistry::get("oxUtilsString")->minimizeTruncateString($sMeta, $iLength);
1359  $sMeta = $oStr->htmlspecialchars($sMeta);
1360 
1361  return trim($sMeta);
1362  }
1363  }
1364 
1373  protected function _prepareMetaKeyword($sKeywords, $blRemoveDuplicatedWords = true)
1374  {
1375 
1376  $sString = $this->_prepareMetaDescription($sKeywords, -1, false);
1377 
1378  if ($blRemoveDuplicatedWords) {
1379  $sString = $this->_removeDuplicatedWords($sString, $this->getConfig()->getConfigParam('aSkipTags'));
1380  }
1381 
1382  return trim($sString);
1383  }
1384 
1393  protected function _removeDuplicatedWords($aInput, $aSkipTags = array())
1394  {
1395  $oStr = getStr();
1396  if (is_array($aInput)) {
1397  $aInput = implode(" ", $aInput);
1398  }
1399 
1400  // removing some usually met characters..
1401  $aInput = $oStr->preg_replace("/[" . preg_quote($this->_sRemoveMetaChars, "/") . "]/", " ", $aInput);
1402 
1403  // splitting by word
1404  $aStrings = $oStr->preg_split("/[\s,]+/", $aInput);
1405 
1406  if ($sCount = count($aSkipTags)) {
1407  for ($iNum = 0; $iNum < $sCount; $iNum++) {
1408  $aSkipTags[$iNum] = $oStr->strtolower($aSkipTags[$iNum]);
1409  }
1410  }
1411  $sCount = count($aStrings);
1412  for ($iNum = 0; $iNum < $sCount; $iNum++) {
1413  $aStrings[$iNum] = $oStr->strtolower($aStrings[$iNum]);
1414  // removing in admin defined strings
1415  if (!$aStrings[$iNum] || in_array($aStrings[$iNum], $aSkipTags)) {
1416  unset($aStrings[$iNum]);
1417  }
1418  }
1419 
1420  // duplicates
1421  return implode(', ', array_unique($aStrings));
1422  }
1423 
1431  public function getNavigationParams()
1432  {
1433  $oConfig = $this->getConfig();
1434  $aParams['cnid'] = $this->getCategoryId();
1435  $aParams['mnid'] = $oConfig->getRequestParameter('mnid');
1436 
1437  $aParams['listtype'] = $this->getListType();
1438  $aParams['ldtype'] = $this->getCustomListDisplayType();
1439  $aParams['actcontrol'] = $this->getClassName();
1440 
1441  // @deprecated since v5.3 (2016-06-17); Listmania will be moved to an own module.
1442  $aParams['recommid'] = $oConfig->getRequestParameter('recommid');
1443 
1444  $aParams['searchrecomm'] = $oConfig->getRequestParameter('searchrecomm', true);
1445  // END deprecated
1446  $aParams['searchparam'] = $oConfig->getRequestParameter('searchparam', true);
1447  // @deprecated v5.3 (2016-05-04); Tags will be moved to own module.
1448  $aParams['searchtag'] = $oConfig->getRequestParameter('searchtag', true);
1449  // END deprecated
1450 
1451  $aParams['searchvendor'] = $oConfig->getRequestParameter('searchvendor');
1452  $aParams['searchcnid'] = $oConfig->getRequestParameter('searchcnid');
1453  $aParams['searchmanufacturer'] = $oConfig->getRequestParameter('searchmanufacturer');
1454 
1455  return $aParams;
1456  }
1457 
1465  public function setItemSorting($sSortIdent, $sSortBy, $sSortDir = null)
1466  {
1467  $aSorting = oxRegistry::getSession()->getVariable('aSorting');
1468  $aSorting[$sSortIdent]['sortby'] = $sSortBy;
1469  $aSorting[$sSortIdent]['sortdir'] = $sSortDir ? $sSortDir : null;
1470 
1471  oxRegistry::getSession()->setVariable('aSorting', $aSorting);
1472  }
1473 
1481  public function getSorting($sSortIdent)
1482  {
1483  $aSorting = null;
1484 
1485  if ($aSorting = $this->getUserSelectedSorting()) {
1486  $this->setItemSorting($sSortIdent, $aSorting['sortby'], $aSorting['sortdir']);
1487  } elseif (!$aSorting = $this->getSavedSorting($sSortIdent)) {
1488  $aSorting = $this->getDefaultSorting();
1489  }
1490 
1491  if ($aSorting) {
1492  $this->setListOrderBy($aSorting['sortby']);
1493  $this->setListOrderDirection($aSorting['sortdir']);
1494  }
1495 
1496  return $aSorting;
1497  }
1498 
1506  public function getSortingSql($sIdent)
1507  {
1508  $aSorting = $this->getSorting($sIdent);
1509  if (is_array($aSorting)) {
1510  return implode(" ", $aSorting);
1511  }
1512  }
1513 
1519  public function getTitleSuffix()
1520  {
1521  return $this->getConfig()->getActiveShop()->oxshops__oxtitlesuffix->value;
1522  }
1523 
1527  public function getTitlePageSuffix()
1528  {
1529  }
1530 
1536  public function getTitlePrefix()
1537  {
1538  return $this->getConfig()->getActiveShop()->oxshops__oxtitleprefix->value;
1539  }
1540 
1541 
1547  public function getPageTitle()
1548  {
1549  $sTitle = '';
1550 
1551  $aTitleParts = array();
1552  $aTitleParts[] = $this->getTitlePrefix();
1553  $aTitleParts[] = $this->getTitle();
1554  $aTitleParts[] = $this->getTitleSuffix();
1555  $aTitleParts[] = $this->getTitlePageSuffix();
1556 
1557  $aTitleParts = array_filter($aTitleParts);
1558 
1559  if (count($aTitleParts)) {
1560  $sTitle = implode(' | ', $aTitleParts);
1561  }
1562 
1563 
1564  return $sTitle;
1565  }
1566 
1567 
1576  protected function _getSubject($iLang)
1577  {
1578  return null;
1579  }
1580 
1586  public function getDynUrlParams()
1587  {
1588  $sRet = '';
1589  $sListType = $this->getListType();
1590  $oConfig = $this->getConfig();
1591 
1592  switch ($sListType) {
1593  default:
1594  break;
1595  case 'search':
1596  $sRet .= "&amp;listtype={$sListType}";
1597  if ($sSearchParamForLink = rawurlencode($oConfig->getRequestParameter('searchparam', true))) {
1598  $sRet .= "&amp;searchparam={$sSearchParamForLink}";
1599  }
1600 
1601  if (($sVar = $oConfig->getRequestParameter('searchcnid', true))) {
1602  $sRet .= '&amp;searchcnid=' . rawurlencode(rawurldecode($sVar));
1603  }
1604  if (($sVar = $oConfig->getRequestParameter('searchvendor', true))) {
1605  $sRet .= '&amp;searchvendor=' . rawurlencode(rawurldecode($sVar));
1606  }
1607  if (($sVar = $oConfig->getRequestParameter('searchmanufacturer', true))) {
1608  $sRet .= '&amp;searchmanufacturer=' . rawurlencode(rawurldecode($sVar));
1609  }
1610  break;
1611  // @deprecated v5.3 (2016-05-04); Tags will be moved to own module.
1612  case 'tag':
1613  $sRet .= "&amp;listtype={$sListType}";
1614  if ($sParam = rawurlencode($oConfig->getRequestParameter('searchtag', true))) {
1615  $sRet .= "&amp;searchtag={$sParam}";
1616  }
1617  break;
1618  // END deprecated
1619  }
1620 
1621  return $sRet;
1622  }
1623 
1631  public function getBaseLink($iLang = null)
1632  {
1633  if (!isset($iLang)) {
1634  $iLang = oxRegistry::getLang()->getBaseLanguage();
1635  }
1636 
1637  $oConfig = $this->getConfig();
1638 
1639  if (oxRegistry::getUtils()->seoIsActive()) {
1640  if ($oDisplayObj = $this->_getSubject($iLang)) {
1641  $sUrl = $oDisplayObj->getLink($iLang);
1642  } else {
1643  $oEncoder = oxRegistry::get("oxSeoEncoder");
1644  $sConstructedUrl = $oConfig->getShopHomeURL($iLang) . $this->_getSeoRequestParams();
1645  $sUrl = $oEncoder->getStaticUrl($sConstructedUrl, $iLang);
1646  }
1647  }
1648 
1649  if (!$sUrl) {
1650  $sConstructedUrl = $oConfig->getShopCurrentURL($iLang) . $this->_getRequestParams();
1651  $sUrl = oxRegistry::get("oxUtilsUrl")->processUrl($sConstructedUrl, true, null, $iLang);
1652  }
1653 
1654  return $sUrl;
1655  }
1656 
1657 
1665  public function getLink($iLang = null)
1666  {
1667  return $this->_addPageNrParam($this->getBaseLink($iLang), $this->getActPage(), $iLang);
1668  }
1669 
1673  public function getCanonicalUrl()
1674  {
1675  }
1676 
1685  public function getSimilarRecommListIds()
1686  {
1687  return false;
1688  }
1689 
1694  public function getSearchParamForHtml()
1695  {
1696  }
1697 
1705  protected function _getRequestParams($blAddPageNr = true)
1706  {
1707  $sClass = $this->getClassName();
1708  $sFnc = $this->getFncName();
1709 
1710  $aFnc = array('tobasket', 'login_noredirect', 'addVoucher', 'moveleft', 'moveright');
1711  if (in_array($sFnc, $aFnc)) {
1712  $sFnc = '';
1713  }
1714 
1715  // #680
1716  $sURL = "cl={$sClass}";
1717  if ($sFnc) {
1718  $sURL .= "&amp;fnc={$sFnc}";
1719  }
1720  if ($sVal = oxRegistry::getConfig()->getRequestParameter('cnid')) {
1721  $sURL .= "&amp;cnid={$sVal}";
1722  }
1723  if ($sVal = oxRegistry::getConfig()->getRequestParameter('mnid')) {
1724  $sURL .= "&amp;mnid={$sVal}";
1725  }
1726  if ($sVal = oxRegistry::getConfig()->getRequestParameter('anid')) {
1727  $sURL .= "&amp;anid={$sVal}";
1728  }
1729 
1730  if ($sVal = basename(oxRegistry::getConfig()->getRequestParameter('page'))) {
1731  $sURL .= "&amp;page={$sVal}";
1732  }
1733 
1734  if ($sVal = basename(oxRegistry::getConfig()->getRequestParameter('tpl'))) {
1735  $sURL .= "&amp;tpl={$sVal}";
1736  }
1737 
1738  if ($sVal = oxRegistry::getConfig()->getRequestParameter('oxloadid')) {
1739  $sURL .= "&amp;oxloadid={$sVal}";
1740  }
1741 
1742  $iPgNr = (int) oxRegistry::getConfig()->getRequestParameter('pgNr');
1743  // don't include page number for navigation
1744  // it will be done in oxubase::generatePageNavigation
1745  if ($blAddPageNr && $iPgNr > 0) {
1746  $sURL .= "&amp;pgNr={$iPgNr}";
1747  }
1748 
1749  // #1184M - specialchar search
1750  if ($sVal = rawurlencode(oxRegistry::getConfig()->getRequestParameter('searchparam', true))) {
1751  $sURL .= "&amp;searchparam={$sVal}";
1752  }
1753 
1754  if ($sVal = oxRegistry::getConfig()->getRequestParameter('searchcnid')) {
1755  $sURL .= "&amp;searchcnid={$sVal}";
1756  }
1757 
1758  if ($sVal = oxRegistry::getConfig()->getRequestParameter('searchvendor')) {
1759  $sURL .= "&amp;searchvendor={$sVal}";
1760  }
1761 
1762  if ($sVal = oxRegistry::getConfig()->getRequestParameter('searchmanufacturer')) {
1763  $sURL .= "&amp;searchmanufacturer={$sVal}";
1764  }
1765 
1766  if ($sVal = oxRegistry::getConfig()->getRequestParameter('searchrecomm')) {
1767  $sURL .= "&amp;searchrecomm={$sVal}";
1768  }
1769 
1770  // @deprecated v5.3 (2016-05-04); Tags will be moved to own module.
1771  if ($sVal = oxRegistry::getConfig()->getRequestParameter('searchtag')) {
1772  $sURL .= "&amp;searchtag={$sVal}";
1773  }
1774  // END deprecated
1775 
1776  // @deprecated since v5.3 (2016-06-17); Listmania will be moved to an own module.
1777  if ($sVal = oxRegistry::getConfig()->getRequestParameter('recommid')) {
1778  $sURL .= "&amp;recommid={$sVal}";
1779  }
1780  // END deprecated
1781 
1782  return $sURL;
1783  }
1784 
1790  protected function _getSeoRequestParams()
1791  {
1792  $sClass = $this->getClassName();
1793  $sFnc = $this->getFncName();
1794 
1795  // #921 S
1796  $aFnc = array('tobasket', 'login_noredirect', 'addVoucher');
1797  if (in_array($sFnc, $aFnc)) {
1798  $sFnc = '';
1799  }
1800 
1801  // #680
1802  $sURL = "cl={$sClass}";
1803  if ($sFnc) {
1804  $sURL .= "&amp;fnc={$sFnc}";
1805  }
1806  if ($sVal = basename(oxRegistry::getConfig()->getRequestParameter('page'))) {
1807  $sURL .= "&amp;page={$sVal}";
1808  }
1809 
1810  if ($sVal = basename(oxRegistry::getConfig()->getRequestParameter('tpl'))) {
1811  $sURL .= "&amp;tpl={$sVal}";
1812  }
1813 
1814  if ($sVal = oxRegistry::getConfig()->getRequestParameter('oxloadid')) {
1815  $sURL .= "&amp;oxloadid={$sVal}";
1816  }
1817 
1818  $iPgNr = (int) oxRegistry::getConfig()->getRequestParameter('pgNr');
1819  if ($iPgNr > 0) {
1820  $sURL .= "&amp;pgNr={$iPgNr}";
1821  }
1822 
1823  return $sURL;
1824  }
1825 
1831  public function showSearch()
1832  {
1833  $blShow = true;
1834  if ($this->getConfig()->getConfigParam('blDisableNavBars') && $this->getIsOrderStep()) {
1835  $blShow = false;
1836  }
1837 
1838  return (int) $blShow;
1839  }
1840 
1846  public function getRssLinks()
1847  {
1848  return $this->_aRssLinks;
1849  }
1850 
1856  public function getSortColumns()
1857  {
1858  if ($this->_aSortColumns === null) {
1859  $this->setSortColumns($this->getConfig()->getConfigParam('aSortCols'));
1860  }
1861 
1862  return $this->_aSortColumns;
1863  }
1864 
1865 
1871  public function setSortColumns($aSortColumns)
1872  {
1873  $this->_aSortColumns = $aSortColumns;
1874  }
1875 
1881  public function getEditTags()
1882  {
1883  }
1884 
1890  public function getRecommSearch()
1891  {
1892  }
1893 
1897  public function getPaymentList()
1898  {
1899  }
1900 
1908  public function getActiveRecommList()
1909  {
1910  if ($this->_oActiveRecommList === null) {
1911  $this->_oActiveRecommList = false;
1912  if ($sOxId = $this->getConfig()->getRequestParameter('recommid')) {
1913  $this->_oActiveRecommList = oxNew('oxrecommlist');
1914  $this->_oActiveRecommList->load($sOxId);
1915  }
1916  }
1917 
1919  }
1920 
1924  public function getAccessoires()
1925  {
1926  }
1927 
1931  public function getCrossSelling()
1932  {
1933  }
1934 
1938  public function getSimilarProducts()
1939  {
1940  }
1941 
1945  public function getAlsoBoughtTheseProducts()
1946  {
1947  }
1948 
1952  public function getArticleId()
1953  {
1954  }
1955 
1961  public function getTitle()
1962  {
1963  $oLang = oxRegistry::getLang();
1964  $sTranslationName = 'PAGE_TITLE_' . strtoupper($this->getConfig()->getActiveView()->getClassName());
1965  $sTranslated = $oLang->translateString($sTranslationName, oxRegistry::getLang()->getBaseLanguage(), false);
1966 
1967  return $sTranslationName == $sTranslated ? null : $sTranslated;
1968  }
1969 
1976  public function getActiveLangAbbr()
1977  {
1978  if (!isset($this->_sActiveLangAbbr)) {
1979  $languageService = oxRegistry::getLang();
1980  if ($this->getConfig()->getConfigParam('bl_perfLoadLanguages')) {
1981  $languages = $languageService->getLanguageArray();
1982  while (list($key, $language) = each($languages)) {
1983  if ($language->selected) {
1984  $this->_sActiveLangAbbr = $language->abbr;
1985  break;
1986  }
1987  }
1988  } else {
1989  // Performance
1990  // use oxid shop internal languageAbbr, this might be correct in the most cases but not guaranteed to be that
1991  // configured in the admin backend for that language
1992  $this->_sActiveLangAbbr = $languageService->getLanguageAbbr();
1993  }
1994  }
1995 
1996  return $this->_sActiveLangAbbr;
1997  }
1998 
2006  public function addGlobalParams($oShop = null)
2007  {
2008  $oViewConf = parent::addGlobalParams($oShop);
2009 
2010  $this->_setNrOfArtPerPage();
2011 
2012  return $oViewConf;
2013  }
2014 
2020  public function getAdditionalParams()
2021  {
2022  if ($this->_sAdditionalParams === null) {
2023  // #1018A
2024  $this->_sAdditionalParams = parent::getAdditionalParams();
2025  $this->_sAdditionalParams .= 'cl=' . $this->getConfig()->getTopActiveView()->getClassName();
2026 
2027  // #1834M - specialchar search
2028  $sSearchParamForLink = rawurlencode(oxRegistry::getConfig()->getRequestParameter('searchparam', true));
2029  if (isset($sSearchParamForLink)) {
2030  $this->_sAdditionalParams .= "&amp;searchparam={$sSearchParamForLink}";
2031  }
2032  // @deprecated v5.3 (2016-05-04); Tags will be moved to own module.
2033  if (($sVar = oxRegistry::getConfig()->getRequestParameter('searchtag'))) {
2034  $this->_sAdditionalParams .= '&amp;searchtag=' . rawurlencode(rawurldecode($sVar));
2035  }
2036  // END deprecated
2037  if (($sVar = oxRegistry::getConfig()->getRequestParameter('searchcnid'))) {
2038  $this->_sAdditionalParams .= '&amp;searchcnid=' . rawurlencode(rawurldecode($sVar));
2039  }
2040  if (($sVar = oxRegistry::getConfig()->getRequestParameter('searchvendor'))) {
2041  $this->_sAdditionalParams .= '&amp;searchvendor=' . rawurlencode(rawurldecode($sVar));
2042  }
2043  if (($sVar = oxRegistry::getConfig()->getRequestParameter('searchmanufacturer'))) {
2044  $this->_sAdditionalParams .= '&amp;searchmanufacturer=' . rawurlencode(rawurldecode($sVar));
2045  }
2046  if (($sVar = oxRegistry::getConfig()->getRequestParameter('cnid'))) {
2047  $this->_sAdditionalParams .= '&amp;cnid=' . rawurlencode(rawurldecode($sVar));
2048  }
2049  if (($sVar = oxRegistry::getConfig()->getRequestParameter('mnid'))) {
2050  $this->_sAdditionalParams .= '&amp;mnid=' . rawurlencode(rawurldecode($sVar));
2051  }
2052  }
2053 
2055  }
2056 
2062  public function generatePageNavigationUrl()
2063  {
2064  return $this->getConfig()->getShopHomeURL() . $this->_getRequestParams(false);
2065  }
2066 
2076  protected function _addPageNrParam($sUrl, $iPage, $iLang = null)
2077  {
2078  if ($iPage) {
2079  if ((strpos($sUrl, 'pgNr='))) {
2080  $sUrl = preg_replace('/pgNr=[0-9]*/', 'pgNr=' . $iPage, $sUrl);
2081  } else {
2082  $sUrl .= ((strpos($sUrl, '?') === false) ? '?' : '&amp;') . 'pgNr=' . $iPage;
2083  }
2084  } else {
2085  $sUrl = preg_replace('/pgNr=[0-9]*/', '', $sUrl);
2086  $sUrl = preg_replace('/\&amp\;\&amp\;/', '&amp;', $sUrl);
2087  $sUrl = preg_replace('/\?\&amp\;/', '?', $sUrl);
2088  $sUrl = preg_replace('/\&amp\;$/', '', $sUrl);
2089  }
2090 
2091  return $sUrl;
2092  }
2093 
2097  public function getPageNavigation()
2098  {
2099 
2100  }
2101 
2109  public function getPageNavigationLimitedTop($iPositionCount = 7)
2110  {
2111  $this->_oPageNavigation = $this->generatePageNavigation($iPositionCount);
2112 
2113  return $this->_oPageNavigation;
2114  }
2115 
2123  public function getPageNavigationLimitedBottom($iPositionCount = 11)
2124  {
2125  $this->_oPageNavigation = $this->generatePageNavigation($iPositionCount);
2126 
2127  return $this->_oPageNavigation;
2128  }
2129 
2130 
2138  public function generatePageNavigation($iPositionCount = 0)
2139  {
2140  startProfile('generatePageNavigation');
2141 
2142  $pageNavigation = new stdClass();
2143 
2144  $pageNavigation->NrOfPages = $this->_iCntPages;
2145  $iActPage = $this->getActPage();
2146  $pageNavigation->actPage = $iActPage + 1;
2147  $sUrl = $this->generatePageNavigationUrl();
2148 
2149  if ($iPositionCount == 0 || ($iPositionCount >= $pageNavigation->NrOfPages)) {
2150  $iStartNo = 2;
2151  $iFinishNo = $pageNavigation->NrOfPages;
2152  } else {
2153  $iTmpVal = $iPositionCount - 3;
2154  $iTmpVal2 = floor(($iPositionCount - 4) / 2);
2155 
2156  // actual page is at the start
2157  if ($pageNavigation->actPage <= $iTmpVal) {
2158  $iStartNo = 2;
2159  $iFinishNo = $iTmpVal + 1;
2160  // actual page is at the end
2161  } elseif ($pageNavigation->actPage >= $pageNavigation->NrOfPages - $iTmpVal + 1) {
2162  $iStartNo = $pageNavigation->NrOfPages - $iTmpVal;
2163  $iFinishNo = $pageNavigation->NrOfPages - 1;
2164  // actual page is in the middle
2165  } else {
2166  $iStartNo = $pageNavigation->actPage - $iTmpVal2;
2167  $iFinishNo = $pageNavigation->actPage + $iTmpVal2;
2168  }
2169  }
2170 
2171  if ($iActPage > 0) {
2172  $pageNavigation->previousPage = $this->_addPageNrParam($sUrl, $iActPage - 1);
2173  }
2174 
2175  if ($iActPage < $pageNavigation->NrOfPages - 1) {
2176  $pageNavigation->nextPage = $this->_addPageNrParam($sUrl, $iActPage + 1);
2177  }
2178 
2179  if ($pageNavigation->NrOfPages > 1) {
2180 
2181  for ($i = 1; $i < $pageNavigation->NrOfPages + 1; $i++) {
2182 
2183  if ($i == 1 || $i == $pageNavigation->NrOfPages || ($i >= $iStartNo && $i <= $iFinishNo)) {
2184  $page = new stdClass();
2185  $page->url = $this->_addPageNrParam($sUrl, $i - 1);
2186  $page->selected = ($i == $pageNavigation->actPage) ? 1 : 0;
2187  $pageNavigation->changePage[$i] = $page;
2188  }
2189  }
2190 
2191  // first/last one
2192  $pageNavigation->firstpage = $this->_addPageNrParam($sUrl, 0);
2193  $pageNavigation->lastpage = $this->_addPageNrParam($sUrl, $pageNavigation->NrOfPages - 1);
2194  }
2195 
2196  stopProfile('generatePageNavigation');
2197 
2198  return $pageNavigation;
2199  }
2200 
2207  public function render()
2208  {
2209  foreach (array_keys($this->_oaComponents) as $sComponentName) {
2210  $this->_aViewData[$sComponentName] = $this->_oaComponents[$sComponentName]->render();
2211  }
2212 
2213  parent::render();
2214 
2215  if ($this->getIsOrderStep()) {
2216 
2217  // disabling navigation during order ...
2218  if ($this->getConfig()->getConfigParam('blDisableNavBars')) {
2219  $this->_iNewsRealStatus = 1;
2220  $this->setShowNewsletter(0);
2221  }
2222  }
2223 
2224  return $this->_sThisTemplate;
2225  }
2226 
2232  public function getViewProduct()
2233  {
2234  return $this->getProduct();
2235  }
2236 
2242  public function setViewProduct($oProduct)
2243  {
2244  $this->_oProduct = $oProduct;
2245  }
2246 
2252  public function getViewProductList()
2253  {
2254  return $this->_aArticleList;
2255  }
2256 
2262  public function getActPage()
2263  {
2264  if ($this->_iActPage === null) {
2265  $this->_iActPage = ( int ) $this->getConfig()->getRequestParameter('pgNr');
2266  $this->_iActPage = ($this->_iActPage < 0) ? 0 : $this->_iActPage;
2267  }
2268 
2269  return $this->_iActPage;
2270  }
2271 
2281  public function getActTag()
2282  {
2283  if ($this->_oActTag === null) {
2284  $this->_oActTag = new stdClass();
2285  $this->_oActTag->sTag = $sTag = $this->getConfig()->getRequestParameter("searchtag", 1);
2286  $oSeoEncoderTag = oxRegistry::get("oxSeoEncoderTag");
2287 
2288  $sLink = false;
2289  if (oxRegistry::getUtils()->seoIsActive()) {
2290  $sLink = $oSeoEncoderTag->getTagUrl($sTag, oxRegistry::getLang()->getBaseLanguage());
2291  }
2292 
2293  $sConstructedUrl = $this->getConfig()->getShopHomeURL() . $oSeoEncoderTag->getStdTagUri($sTag, false);
2294  $this->_oActTag->link = $sLink ? $sLink : $sConstructedUrl;
2295  }
2296 
2297  return $this->_oActTag;
2298  }
2299 
2307  public function getActVendor()
2308  {
2309  // if active vendor is not set yet - trying to load it from request params
2310  // this may be useful when category component was unable to load active vendor
2311  // and we still need some object to mount navigation info
2312  if ($this->_oActVendor === null) {
2313  $this->_oActVendor = false;
2314  $sVendorId = $this->getConfig()->getRequestParameter('cnid');
2315  $sVendorId = $sVendorId ? str_replace('v_', '', $sVendorId) : $sVendorId;
2316  $oVendor = oxNew('oxVendor');
2317  if ($oVendor->load($sVendorId)) {
2318  $this->_oActVendor = $oVendor;
2319  }
2320  }
2321 
2322  return $this->_oActVendor;
2323  }
2324 
2332  public function getActManufacturer()
2333  {
2334  // if active Manufacturer is not set yet - trying to load it from request params
2335  // this may be useful when category component was unable to load active Manufacturer
2336  // and we still need some object to mount navigation info
2337  if ($this->_oActManufacturer === null) {
2338 
2339  $this->_oActManufacturer = false;
2340  $sManufacturerId = $this->getConfig()->getRequestParameter('mnid');
2341  $oManufacturer = oxNew('oxManufacturer');
2342  if ($oManufacturer->load($sManufacturerId)) {
2343  $this->_oActManufacturer = $oManufacturer;
2344  }
2345  }
2346 
2347  return $this->_oActManufacturer;
2348  }
2349 
2355  public function setActVendor($oVendor)
2356  {
2357  $this->_oActVendor = $oVendor;
2358  }
2359 
2365  public function setActManufacturer($oManufacturer)
2366  {
2367  $this->_oActManufacturer = $oManufacturer;
2368  }
2369 
2375  public function getActSearch()
2376  {
2377  if ($this->_oActSearch === null) {
2378  $this->_oActSearch = new stdClass();
2379  $sUrl = $this->getConfig()->getShopHomeURL();
2380  $this->_oActSearch->link = "{$sUrl}cl=search";
2381  }
2382 
2383  return $this->_oActSearch;
2384  }
2385 
2391  public function getCategoryTree()
2392  {
2393  return $this->_oCategoryTree;
2394  }
2395 
2401  public function setCategoryTree($oCatTree)
2402  {
2403  $this->_oCategoryTree = $oCatTree;
2404  }
2405 
2411  public function getManufacturerTree()
2412  {
2414  }
2415 
2421  public function setManufacturerTree($oManufacturerTree)
2422  {
2423  $this->_oManufacturerTree = $oManufacturerTree;
2424  }
2425 
2429  public function getAddUrlParams()
2430  {
2431  }
2432 
2441  public function getTop5ArticleList($iCount = null)
2442  {
2443  if ($this->_blTop5Action) {
2444  if ($this->_aTop5ArticleList === null) {
2445  $this->_aTop5ArticleList = false;
2446  $myConfig = $this->getConfig();
2447  if ($myConfig->getConfigParam('bl_perfLoadAktion')) {
2448  // top 5 articles
2449  $oArtList = oxNew('oxArticleList');
2450  $oArtList->loadTop5Articles($iCount);
2451  if ($oArtList->count()) {
2452  $this->_aTop5ArticleList = $oArtList;
2453  }
2454  }
2455  }
2456  }
2457 
2458  return $this->_aTop5ArticleList;
2459  }
2460 
2467  public function getBargainArticleList()
2468  {
2469  if ($this->_blBargainAction) {
2470  if ($this->_aBargainArticleList === null) {
2471  $this->_aBargainArticleList = array();
2472  if ($this->getConfig()->getConfigParam('bl_perfLoadAktion')) {
2473  $oArtList = oxNew('oxArticleList');
2474  $oArtList->loadActionArticles('OXBARGAIN');
2475  if ($oArtList->count()) {
2476  $this->_aBargainArticleList = $oArtList;
2477  }
2478  }
2479  }
2480  }
2481 
2483  }
2484 
2493  public function isLowOrderPrice()
2494  {
2495  if ($this->_blLowOrderPrice === null && ($oBasket = $this->getSession()->getBasket())) {
2496  $this->_blLowOrderPrice = $oBasket->isBelowMinOrderPrice();
2497  }
2498 
2499  return $this->_blLowOrderPrice;
2500  }
2501 
2509  public function getMinOrderPrice()
2510  {
2511  if ($this->_sMinOrderPrice === null && $this->isLowOrderPrice()) {
2512  $dMinOrderPrice = oxPrice::getPriceInActCurrency($this->getConfig()->getConfigParam('iMinOrderPrice'));
2513  $this->_sMinOrderPrice = oxRegistry::getLang()->formatCurrency($dMinOrderPrice);
2514  }
2515 
2516  return $this->_sMinOrderPrice;
2517  }
2518 
2524  public function getNewsRealStatus()
2525  {
2526  return $this->_iNewsRealStatus;
2527  }
2528 
2534  protected function _canRedirect()
2535  {
2536  foreach ($this->_aBlockRedirectParams as $sParam) {
2537  if ($this->getConfig()->getRequestParameter($sParam) !== null) {
2538  return false;
2539  }
2540  }
2541 
2542  return true;
2543  }
2544 
2548  public function getProduct()
2549  {
2550  }
2551 
2557  public function getManufacturerlist()
2558  {
2560  }
2561 
2567  public function setManufacturerlist($aList)
2568  {
2569  $this->_aManufacturerlist = $aList;
2570  }
2571 
2577  public function setRootVendor($oVendor)
2578  {
2579  $this->_oRootVendor = $oVendor;
2580  }
2581 
2587  public function getRootVendor()
2588  {
2589  return $this->_oRootVendor;
2590  }
2591 
2597  public function setRootManufacturer($oManufacturer)
2598  {
2599  $this->_oRootManufacturer = $oManufacturer;
2600  }
2601 
2607  public function getRootManufacturer()
2608  {
2610  }
2611 
2617  public function getVendorId()
2618  {
2619  if ($this->_sVendorId === null) {
2620  $this->_sVendorId = false;
2621  if (($oVendor = $this->getActVendor())) {
2622  $this->_sVendorId = $oVendor->getId();
2623  }
2624  }
2625 
2626  return $this->_sVendorId;
2627  }
2628 
2634  public function getManufacturerId()
2635  {
2636  if ($this->_sManufacturerId === null) {
2637  $this->_sManufacturerId = false;
2638  if (($oManufacturer = $this->getActManufacturer())) {
2639  $this->_sManufacturerId = $oManufacturer->getId();
2640  }
2641  }
2642 
2643  return $this->_sManufacturerId;
2644  }
2645 
2651  public function getCatMoreUrl()
2652  {
2653  return $this->getConfig()->getShopHomeURL() . 'cnid=oxmore';
2654  }
2655 
2661  public function getCatTreePath()
2662  {
2663  return $this->_sCatTreePath;
2664  }
2665 
2673  public function getContentByIdent($sIdent)
2674  {
2675  if (!isset($this->_aContents[$sIdent])) {
2676  $this->_aContents[$sIdent] = oxNew('oxContent');
2677  $this->_aContents[$sIdent]->loadByIdent($sIdent);
2678  }
2679 
2680  return $this->_aContents[$sIdent];
2681  }
2682 
2688  public function getContentCategory()
2689  {
2690  return false;
2691  }
2692 
2698  public function getMustFillFields()
2699  {
2700  if ($this->_aMustFillFields === null) {
2701  $this->_aMustFillFields = false;
2702 
2703  // passing must-be-filled-fields info
2704  $aMustFillFields = $this->getConfig()->getConfigParam('aMustFillFields');
2705  if (is_array($aMustFillFields)) {
2706  $this->_aMustFillFields = array_flip($aMustFillFields);
2707  }
2708  }
2709 
2710  return $this->_aMustFillFields;
2711  }
2712 
2720  public function isFieldRequired($sField)
2721  {
2722  if ($aMustFillFields = $this->getMustFillFields()) {
2723  if (isset($aMustFillFields[$sField])) {
2724  return true;
2725  }
2726  }
2727 
2728  return false;
2729  }
2730 
2736  public function getFormId()
2737  {
2738  if ($this->_sFormId === null) {
2739  $this->_sFormId = oxUtilsObject::getInstance()->generateUId();
2740  oxRegistry::getSession()->setVariable('sessionuformid', $this->_sFormId);
2741  }
2742 
2743  return $this->_sFormId;
2744  }
2745 
2751  public function canAcceptFormData()
2752  {
2753  if ($this->_blCanAcceptFormData === null) {
2754  $this->_blCanAcceptFormData = false;
2755 
2756  $sFormId = $this->getConfig()->getRequestParameter("uformid");
2757  $sSessionFormId = oxRegistry::getSession()->getVariable("sessionuformid");
2758 
2759  // testing if form and session ids matches
2760  if ($sFormId && $sFormId === $sSessionFormId) {
2761  $this->_blCanAcceptFormData = true;
2762  }
2763 
2764  // regenerating form data
2765  $this->getFormId();
2766  }
2767 
2768  return $this->_blCanAcceptFormData;
2769  }
2770 
2776  public function getPromoFinishedList()
2777  {
2778  if (isset($this->_oPromoFinishedList)) {
2779  return $this->_oPromoFinishedList;
2780  }
2781  $this->_oPromoFinishedList = oxNew('oxActionList');
2782  $this->_oPromoFinishedList->loadFinishedByCount(2);
2783 
2784  return $this->_oPromoFinishedList;
2785  }
2786 
2792  public function getPromoCurrentList()
2793  {
2794  if (isset($this->_oPromoCurrentList)) {
2795  return $this->_oPromoCurrentList;
2796  }
2797  $this->_oPromoCurrentList = oxNew('oxActionList');
2798  $this->_oPromoCurrentList->loadCurrent();
2799 
2800  return $this->_oPromoCurrentList;
2801  }
2802 
2808  public function getPromoFutureList()
2809  {
2810  if (isset($this->_oPromoFutureList)) {
2811  return $this->_oPromoFutureList;
2812  }
2813  $this->_oPromoFutureList = oxNew('oxActionList');
2814  $this->_oPromoFutureList->loadFutureByCount(2);
2815 
2816  return $this->_oPromoFutureList;
2817  }
2818 
2824  public function getShowPromotionList()
2825  {
2826  if (isset($this->_blShowPromotions)) {
2827  return $this->_blShowPromotions;
2828  }
2829  $this->_blShowPromotions = false;
2830  if (oxNew('oxActionList')->areAnyActivePromotions()) {
2831  $this->_blShowPromotions = (count($this->getPromoFinishedList()) + count($this->getPromoCurrentList()) +
2832  count($this->getPromoFutureList())) > 0;
2833  }
2834 
2835  return $this->_blShowPromotions;
2836  }
2837 
2843  public function isEnabledPrivateSales()
2844  {
2845  if ($this->_blEnabledPrivateSales === null) {
2846  $this->_blEnabledPrivateSales = (bool) $this->getConfig()->getConfigParam('blPsLoginEnabled');
2847  if ($this->_blEnabledPrivateSales && ($blCanPreview = oxRegistry::getUtils()->canPreview()) !== null) {
2848  $this->_blEnabledPrivateSales = !$blCanPreview;
2849  }
2850  }
2851 
2853  }
2854 
2860  public function getFieldValidationErrors()
2861  {
2862  return oxRegistry::get("oxInputValidator")->getFieldValidationErrors();
2863  }
2864 
2870  public function getBreadCrumb()
2871  {
2872  return null;
2873  }
2874 
2880  public function setRootCatChanged($blRootCatChanged)
2881  {
2882  $this->_blRootCatChanged = $blRootCatChanged;
2883  }
2884 
2890  public function isRootCatChanged()
2891  {
2892  return $this->_blRootCatChanged;
2893  }
2894 
2900  public function getInvoiceAddress()
2901  {
2902  if ($this->_aInvoiceAddress == null) {
2903  $aAddress = $this->getConfig()->getRequestParameter('invadr');
2904  if ($aAddress) {
2905  $this->_aInvoiceAddress = $aAddress;
2906  }
2907  }
2908 
2909  return $this->_aInvoiceAddress;
2910  }
2911 
2917  public function getDeliveryAddress()
2918  {
2919  if ($this->_aDeliveryAddress == null) {
2920  $oConfig = $this->getConfig();
2921  //do not show deladr if address was reloaded
2922  if (!$oConfig->getRequestParameter('reloadaddress')) {
2923  $this->_aDeliveryAddress = $oConfig->getRequestParameter('deladr');
2924  }
2925  }
2926 
2927  return $this->_aDeliveryAddress;
2928  }
2929 
2935  public function setDeliveryAddress($aDeliveryAddress)
2936  {
2937  $this->_aDeliveryAddress = $aDeliveryAddress;
2938  }
2939 
2945  public function setInvoiceAddress($aAddress)
2946  {
2947  $this->_aInvoiceAddress = $aAddress;
2948  }
2949 
2955  public function getActiveUsername()
2956  {
2957  if ($this->_sActiveUsername == null) {
2958  $this->_sActiveUsername = false;
2959  $sUsername = $this->getConfig()->getRequestParameter('lgn_usr');
2960  if ($sUsername) {
2961  $this->_sActiveUsername = $sUsername;
2962  } elseif ($oUser = $this->getUser()) {
2963  $this->_sActiveUsername = $oUser->oxuser__oxusername->value;
2964  }
2965  }
2966 
2967  return $this->_sActiveUsername;
2968  }
2969 
2975  public function getWishlistUserId()
2976  {
2977  return $this->getConfig()->getRequestParameter('wishid');
2978  }
2979 
2983  public function getSearchCatId()
2984  {
2985  }
2986 
2990  public function getSearchVendor()
2991  {
2992  }
2993 
2997  public function getSearchManufacturer()
2998  {
2999  }
3000 
3004  public function getLastProducts()
3005  {
3006 
3007  }
3008 
3014  public function getNewBasketItemMsgType()
3015  {
3016  return (int) $this->getConfig()->getConfigParam("iNewBasketItemMessage");
3017  }
3018 
3026  public function isActive($sName)
3027  {
3028  return $this->getConfig()->getConfigParam("bl" . $sName . "Enabled");
3029  }
3030 
3038  public function isFbWidgetVisible()
3039  {
3040  if ($this->_blFbWidgetsOn === null) {
3041  $oUtils = oxRegistry::get("oxUtilsServer");
3042 
3043  // reading ..
3044  $this->_blFbWidgetsOn = (bool) $oUtils->getOxCookie("fbwidgetson");
3045  }
3046 
3047  return $this->_blFbWidgetsOn;
3048  }
3049 
3055  public function isEnabledDownloadableFiles()
3056  {
3057  return (bool) $this->getConfig()->getConfigParam("blEnableDownloads");
3058  }
3059 
3065  public function showRememberMe()
3066  {
3067  return (bool) $this->getConfig()->getConfigParam('blShowRememberMe');
3068  }
3069 
3076  public function isVatIncluded()
3077  {
3078  $blResult = true;
3079  $oUser = $this->getUser();
3080  $oConfig = $this->getConfig();
3081 
3082  $blShowNetPriceParameter = $oConfig->getConfigParam('blShowNetPrice');
3083  $blPerfCalcVatOnlyForBasketOrderParameter = $oConfig->getConfigParam('bl_perfCalcVatOnlyForBasketOrder');
3084  if ($blShowNetPriceParameter || $blPerfCalcVatOnlyForBasketOrderParameter) {
3085  $blResult = false;
3086  } elseif ($oUser && $oUser->isPriceViewModeNetto()) {
3087  $blResult = false;
3088  }
3089 
3090  return $blResult;
3091  }
3092 
3098  public function isPriceCalculated()
3099  {
3100  return (bool) $this->getConfig()->getConfigParam('bl_perfLoadPrice');
3101  }
3102 
3110  public function showTags()
3111  {
3112  return (bool) $this->_blShowTagCloud && $this->getConfig()->getConfigParam("blShowTags");
3113  }
3114 
3120  public function getWishlistName()
3121  {
3122  if ($this->getUser()) {
3123  $sWishId = $this->getConfig()->getRequestParameter('wishid');
3124  $sUserId = ($sWishId) ? $sWishId : oxRegistry::getSession()->getVariable('wishid');
3125  if ($sUserId) {
3126  $oWishUser = oxNew('oxUser');
3127  if ($oWishUser->load($sUserId)) {
3128  return $oWishUser;
3129  }
3130  }
3131  }
3132 
3133  return false;
3134  }
3135 
3141  public function getWidgetLink()
3142  {
3143  return oxRegistry::getConfig()->getWidgetUrl();
3144  }
3145 }