OXID eShop CE  4.8.12
 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 {
23  protected $_blFbWidgetsOn = null;
24 
29  protected $_sRemoveMetaChars = '.\+*?[^]$(){}=!<>|:&';
30 
36  protected $_oaComponents = array();
37 
43  protected $_blIsOrderStep = false;
44 
50  protected $_sListType = null;
51 
57  protected $_aListDisplayTypes = array( 'grid', 'line', 'infogrid' );
58 
64  protected $_sListDisplayType = null;
65 
71  protected $_sCustomListDisplayType = null;
72 
78  protected $_oActCategory = null;
79 
85  protected $_oActManufacturer = null;
86 
92  protected $_oActVendor = null;
93 
98  protected $_oActiveRecommList = null;
99 
105  protected $_oActSearch = null;
106 
111  protected $_blShowSorting = false;
112 
117  protected $_blLoadCurrency = null;
118 
123  protected $_blLoadManufacturerTree = null;
124 
129  protected $_blDontShowEmptyCats = null;
130 
135  protected $_blLoadLanguage = null;
136 
141  protected $_iTopCatNavItmCnt = null;
142 
147  protected $_aRssLinks = null;
148 
153  protected $_sListOrderBy = null;
154 
159  protected $_sListOrderDir = null;
160 
165  protected $_sMetaDescription = null;
166 
171  protected $_sMetaKeywords = null;
172 
178  protected $_sMetaDescriptionIdent = null;
179 
185  protected $_sMetaKeywordsIdent = null;
186 
191  protected $_sAdditionalParams = null;
192 
197  protected $_oActCurrency = null;
198 
203  protected $_blEnabledPrivateSales = null;
204 
211  protected $_blCommonAdded = false;
212 
220 
227  protected $_blForceNoIndex = false;
228 
233  protected $_iCompItemsCnt = null;
234 
240  protected $_sContentId = null;
241 
247  protected $_oContent = null;
248 
254  protected $_sViewResetID = null;
255 
262  protected $_blActiveSorting = null;
263 
268  protected $_aMenueList = null;
269 
275  protected $_aComponentNames = array(
276  'oxcmp_user' => 1, // 0 means dont init if cached
277  'oxcmp_lang' => 0,
278  'oxcmp_cur' => 1,
279  'oxcmp_shop' => 1,
280  'oxcmp_categories' => 0,
281  'oxcmp_utils' => 1,
282  'oxcmp_news' => 0,
283  'oxcmp_basket' => 1
284  );
285 
291  protected $_aUserComponentNames = array();
292 
298  protected $_oProduct = null;
299 
304  protected $_iActPage = null;
305 
310  protected $_aArticleList = null;
311 
316  protected $_oManufacturerTree = null;
317 
322  protected $_oCategoryTree = null;
323 
328  protected $_aTop5ArticleList = null;
329 
334  protected $_aBargainArticleList = null;
335 
340  protected $_blLowOrderPrice = null;
341 
346  protected $_sMinOrderPrice = null;
347 
352  protected $_iNewsRealStatus = null;
353 
359  protected $_aBlockRedirectParams = array( 'fnc', 'stoken', 'force_sid', 'force_admin_sid' );
360 
365  protected $_oRootVendor = null;
366 
371  protected $_sVendorId = null;
372 
377  protected $_aManufacturerlist = null;
378 
383  protected $_oRootManufacturer = null;
384 
389  protected $_sManufacturerId = null;
390 
398  protected $_aSearchCatTree = null;
399 
404  protected $_blNewsSubscribed = null;
405 
410  protected $_oDelAddress = null;
411 
416  protected $_sCatTreePath = null;
417 
422  protected $_aContents = array();
423 
428  protected $_blTop5Action = false;
429 
434  protected $_blBargainAction = false;
435 
441  protected $_aMustFillFields = null;
442 
447  protected $_blShowTagCloud = true;
448 
453  protected $_blRootCatChanged = false;
454 
459  protected $_aInvoiceAddress = null;
460 
465  protected $_aDeliveryAddress = null;
466 
471  protected $_sActiveUsername = null;
472 
478  protected static $_aCollectedComponentNames = null;
479 
486  protected $_blLoadComponents = true;
487 
488 
494  protected $_aSortColumns = null;
495 
501  protected function _getComponentNames()
502  {
503  if ( self::$_aCollectedComponentNames === null ) {
504  self::$_aCollectedComponentNames = array_merge( $this->_aComponentNames, $this->_aUserComponentNames );
505 
506  // #1721: custom component handling. At the moment it is not possible to override this variable in oxubase,
507  // so we added this array to config.inc.php file
508  if ( ( $aUserCmps = $this->getConfig()->getConfigParam( 'aUserComponentNames' ) ) ) {
509  self::$_aCollectedComponentNames = array_merge( self::$_aCollectedComponentNames, $aUserCmps );
510  }
511 
512  if ( oxConfig::getParameter( '_force_no_basket_cmp' ) ) {
513  unset( self::$_aCollectedComponentNames['oxcmp_basket'] );
514  }
515  }
516 
517  // resetting array pointer
518  reset( self::$_aCollectedComponentNames );
520  }
521 
530  protected function _processRequest()
531  {
532  $myUtils = oxRegistry::getUtils();
533 
534  // non admin, request is not empty and was not processed by seo engine
535  if ( !isSearchEngineUrl() && $myUtils->seoIsActive() && ( $sStdUrl = getRequestUrl( '', true ) ) ) {
536 
537  // fetching standard url and looking for it in seo table
538  if ( $this->_canRedirect() && ( $sRedirectUrl = oxRegistry::get("oxSeoEncoder")->fetchSeoUrl( $sStdUrl ) ) ) {
539  $myUtils->redirect( $this->getConfig()->getCurrentShopUrl() . $sRedirectUrl, false );
540  } elseif (VIEW_INDEXSTATE_INDEX == $this->noIndex()) {
541  // forcing to set noindex/follow meta
542  $this->_forceNoIndex();
543 
544  if ( $this->getConfig()->getConfigParam('blSeoLogging') ) {
545  $sShopId = $this->getConfig()->getShopId();
546  $sLangId = oxRegistry::getLang()->getBaseLanguage();
547  $sIdent = md5( strtolower( $sStdUrl ) . $sShopId . $sLangId );
548 
549  // logging "not found" url
550  $oDb = oxDb::getDb();
551  $oDb->execute( "replace oxseologs ( oxstdurl, oxident, oxshopid, oxlang )
552  values ( " . $oDb->quote( $sStdUrl ) . ", '{$sIdent}', '{$sShopId}', '{$sLangId}' ) " );
553  }
554  }
555  }
556  }
557 
564  public function init()
565  {
566  $this->_processRequest();
567 
568  // storing current view
569  $blInit = true;
570 
571 
572  // init all components if there are any
573  if ( $this->_blLoadComponents ) {
574  foreach ( $this->_getComponentNames() as $sComponentName => $blNotCacheable ) {
575  // do not override initiated components
576  if ( !isset( $this->_oaComponents[$sComponentName] ) ) {
577  // component objects MUST be created to support user called functions
578  $oComponent = oxNew( $sComponentName );
579  $oComponent->setParent( $this );
580  $oComponent->setThisAction( $sComponentName );
581  $this->_oaComponents[$sComponentName] = $oComponent;
582  }
583 
584  // do we really need to initiate them ?
585  if ( $blInit ) {
586  $this->_oaComponents[$sComponentName]->init();
587 
588  // executing only is view does not have action method
589  if ( !method_exists( $this, $this->getFncName() ) ) {
590  $this->_oaComponents[$sComponentName]->executeFunction( $this->getFncName() );
591  }
592  }
593  }
594  }
595 
596  parent::init();
597  }
598 
605  public function getViewId()
606  {
607  if ( $this->_sViewId ) {
608  return $this->_sViewId;
609  }
610 
611  $myConfig = $this->getConfig();
612  $iLang = oxRegistry::getLang()->getBaseLanguage();
613  $iCur = (int) $myConfig->getShopCurrency();
614 
615 
616  $this->_sViewId = "ox|$iLang|$iCur";
617 
618  $this->_sViewId .= "|".( (int) $this->_blForceNoIndex ).'|'.((int)$this->isRootCatChanged());
619 
620  // #0004798: SSL should be included in viewId
621  if ($myConfig->isSsl()) {
622  $this->_sViewId .= "|ssl";
623  }
624 
625  // #0002866: external global viewID addition
626  if (function_exists('customGetViewId')) {
627  $oExtViewId = customGetViewId();
628 
629  if ($oExtViewId !== null) {
630  $this->_sViewId .= '|'.md5(serialize($oExtViewId));
631  }
632  }
633  return $this->_sViewId;
634  }
635 
636 
642  public function showSorting()
643  {
644  return $this->_blShowSorting && $this->getConfig()->getConfigParam( 'blShowSorting' );
645  }
646 
654  public function setComponents( $aComponents = null )
655  {
656  $this->_oaComponents = $aComponents;
657  }
658 
664  public function getComponents()
665  {
666  return $this->_oaComponents;
667  }
668 
676  public function getComponent( $sName )
677  {
678  if ( isset( $sName ) && isset( $this->_oaComponents[$sName] ) ) {
679  return $this->_oaComponents[$sName];
680  }
681  }
689  public function setIsOrderStep( $blIsOrderStep = null )
690  {
691  $this->_blIsOrderStep = $blIsOrderStep;
692  }
693 
699  public function getIsOrderStep()
700  {
701  return $this->_blIsOrderStep;
702  }
703 
704 
712  public function setActiveCategory( $oCategory )
713  {
714  $this->_oActCategory = $oCategory;
715  }
716 
722  public function getActiveCategory()
723  {
724  return $this->_oActCategory;
725  }
726 
732  public function getListType()
733  {
734  if ( $this->_sListType == null ) {
735  if ( $sListType = oxConfig::getParameter( 'listtype' ) ) {
736  $this->_sListType = $sListType;
737  } elseif ( $sListType = $this->getConfig()->getGlobalParameter( 'listtype' ) ) {
738  $this->_sListType = $sListType;
739  }
740  }
741  return $this->_sListType;
742  }
743 
749  public function getListDisplayType()
750  {
751  if ( $this->_sListDisplayType == null ) {
752  $this->_sListDisplayType = $this->getCustomListDisplayType();
753 
754  if ( !$this->_sListDisplayType ) {
755  $this->_sListDisplayType = $this->getConfig()->getConfigParam( 'sDefaultListDisplayType' );
756  }
757 
758  $this->_sListDisplayType = in_array( ( string ) $this->_sListDisplayType, $this->_aListDisplayTypes ) ? $this->_sListDisplayType : 'infogrid';
759 
760  // writing to session
761  if ( oxConfig::getParameter( 'ldtype' ) ) {
762  oxSession::setVar( 'ldtype', $this->_sListDisplayType );
763  }
764  }
766  }
767 
773  public function getCustomListDisplayType()
774  {
775  if ( $this->_sCustomListDisplayType == null ) {
776  $this->_sCustomListDisplayType = oxConfig::getParameter( 'ldtype' );
777 
778  if ( !$this->_sCustomListDisplayType ) {
779  $this->_sCustomListDisplayType = oxRegistry::getSession()->getVariable( 'ldtype' );
780  }
781  }
783  }
784 
792  public function setListType( $sType )
793  {
794  $this->_sListType = $sType;
795  $this->getConfig()->setGlobalParameter( 'listtype', $sType );
796  }
797 
803  public function loadCurrency()
804  {
805  if ( $this->_blLoadCurrency == null ) {
806  $this->_blLoadCurrency = false;
807  if ( $blLoadCurrency = $this->getConfig()->getConfigParam( 'bl_perfLoadCurrency' ) ) {
808  $this->_blLoadCurrency = $blLoadCurrency;
809  }
810  }
811  return $this->_blLoadCurrency;
812  }
813 
819  public function dontShowEmptyCategories()
820  {
821  if ( $this->_blDontShowEmptyCats == null ) {
822  $this->_blDontShowEmptyCats = false;
823  if ( $blDontShowEmptyCats = $this->getConfig()->getConfigParam( 'blDontShowEmptyCategories' ) ) {
824  $this->_blDontShowEmptyCats = $blDontShowEmptyCats;
825  }
826  }
828  }
829 
835  public function showCategoryArticlesCount()
836  {
837  return $this->getConfig()->getConfigParam( 'bl_perfShowActionCatArticleCnt' );
838  }
839 
845  public function isLanguageLoaded()
846  {
847  if ( $this->_blLoadLanguage == null ) {
848  $this->_blLoadLanguage = false;
849  if ( $blLoadLanguage = $this->getConfig()->getConfigParam( 'bl_perfLoadLanguages' ) ) {
850  $this->_blLoadLanguage = $blLoadLanguage;
851  }
852  }
853  return $this->_blLoadLanguage;
854  }
855 
861  public function getTopNavigationCatCnt()
862  {
863  if ( $this->_iTopCatNavItmCnt == null ) {
864  $iTopCatNavItmCnt = $this->getConfig()->getConfigParam( 'iTopNaviCatCount' );
865  $this->_iTopCatNavItmCnt = $iTopCatNavItmCnt ? $iTopCatNavItmCnt : 5;
866  }
868  }
869 
879  public function addRssFeed($sTitle, $sUrl, $key = null)
880  {
881  if (!is_array($this->_aRssLinks)) {
882  $this->_aRssLinks = array();
883  }
884 
885  $sUrl = oxRegistry::get("oxUtilsUrl")->prepareUrlForNoSession($sUrl);
886 
887  if ($key === null) {
888  $this->_aRssLinks[] = array('title'=>$sTitle, 'link' => $sUrl);
889  } else {
890  $this->_aRssLinks[$key] = array('title'=>$sTitle, 'link' => $sUrl);
891  }
892  }
893 
899  public function getSortOrderByParameterName()
900  {
901  return 'listorderby';
902  }
903 
909  public function getSortOrderParameterName()
910  {
911  return 'listorder';
912  }
913 
914 
920  public function getSortIdent()
921  {
922  return 'alist';
923  }
924 
930  public function getDefaultSorting()
931  {
932  return null;
933  }
934 
940  public function getUserSelectedSorting()
941  {
942  $aSorting = null;
943  $oStr = getStr();
944  $oConfig = oxRegistry::getConfig();
945  $aSortDirections = array( 'desc', 'asc' );
946  $aSortColumns = $this->getSortColumns();
947 
948  $sSortBy = $oConfig->getParameter( $this->getSortOrderByParameterName() );
949  $sSortDir = $oConfig->getParameter( $this->getSortOrderParameterName() );
950 
951  if ( $sSortBy && oxDb::getInstance()->isValidFieldName( $sSortBy ) && /*in_array( $oStr->strtolower($sSortBy), $aSortColumns ) &&*/
952  $sSortDir && oxRegistry::getUtils()->isValidAlpha( $sSortDir ) && in_array( $oStr->strtolower($sSortDir), $aSortDirections ) ) {
953  $aSorting = array ( 'sortby' => $sSortBy, 'sortdir' => $sSortDir );
954  }
955 
956  return $aSorting;
957  }
958 
959 
967  public function getSavedSorting( $sSortIdent )
968  {
969  $aSorting = oxRegistry::getSession()->getVariable( 'aSorting' );
970  if ( isset( $aSorting[$sSortIdent] ) ) {
971  return $aSorting[$sSortIdent];
972  }
973  }
974 
982  public function setListOrderBy( $sColumn )
983  {
984  $this->_sListOrderBy = $sColumn;
985  }
986 
994  public function setListOrderDirection( $sDirection )
995  {
996  $this->_sListOrderDir = $sDirection;
997  }
998 
999 
1000 
1013  public function prepareSortColumns()
1014  {
1015  $aSortColumns = $this->getConfig()->getConfigParam( 'aSortCols' );
1016  $aSortDir = array( 'desc', 'asc' );
1017  if ( count( $aSortColumns ) > 0 ) {
1018 
1019  $this->_aSortColumns = $aSortColumns;
1020 
1021  $sCnid = oxRegistry::getConfig()->getRequestParameter( 'cnid' );
1022 
1023 
1024  $sSortBy = oxRegistry::getConfig()->getRequestParameter( $this->getSortOrderByParameterName() );
1025  $sSortDir = oxRegistry::getConfig()->getRequestParameter( $this->getSortOrderParameterName() );
1026 
1027  $oStr = getStr();
1028  if ( (!$sSortBy || !in_array( $oStr->strtolower($sSortBy), $aSortColumns) || !in_array( $oStr->strtolower($sSortDir), $aSortDir) ) && $aSorting = $this->getSorting( $sCnid ) ) {
1029  $sSortBy = $aSorting['sortby'];
1030  $sSortDir = $aSorting['sortdir'];
1031  }
1032 
1033  if ( $sSortBy && oxDb::getInstance()->isValidFieldName( $sSortBy ) &&
1034  $sSortDir && oxRegistry::getUtils()->isValidAlpha( $sSortDir ) ) {
1035 
1036  $this->_sListOrderBy = $sSortBy;
1037  $this->_sListOrderDir = $sSortDir;
1038 
1039  // caching sorting config
1040  $this->setItemSorting( $sCnid, $sSortBy, $sSortDir );
1041  }
1042  }
1043  }
1044 
1050  public function getListOrderBy()
1051  {
1052  //if column is with table name split it
1053  $aColumns = explode('.', $this->_sListOrderBy);
1054 
1055  if ( is_array($aColumns) && count($aColumns) > 1 ) {
1056  return $aColumns[1];
1057  }
1058 
1059  return $this->_sListOrderBy;
1060  }
1061 
1067  public function getListOrderDirection()
1068  {
1069  return $this->_sListOrderDir;
1070  }
1071 
1079  public function setMetaDescription ( $sDescription )
1080  {
1081  return $this->_sMetaDescription = $sDescription;
1082  }
1083 
1091  public function setMetaKeywords( $sKeywords )
1092  {
1093  return $this->_sMetaKeywords = $sKeywords;
1094  }
1095 
1103  protected function _getMetaFromSeo( $sDataType )
1104  {
1105  $sOxid = $this->_getSeoObjectId();
1106  $iLang = oxRegistry::getLang()->getBaseLanguage();
1107  $sShop = $this->getConfig()->getShopId();
1108 
1109  if ( $sOxid && oxRegistry::getUtils()->seoIsActive() &&
1110  ( $sKeywords = oxRegistry::get("oxSeoEncoder")->getMetaData( $sOxid, $sDataType, $sShop, $iLang) ) ) {
1111  return $sKeywords;
1112  }
1113  }
1114 
1122  protected function _getMetaFromContent( $sMetaIdent )
1123  {
1124  if ( $sMetaIdent ) {
1125  $oContent = oxNew( 'oxcontent' );
1126  if ( $oContent->loadByIdent( $sMetaIdent ) &&
1127  $oContent->oxcontents__oxactive->value ) {
1128  return getStr()->strip_tags( $oContent->oxcontents__oxcontent->value );
1129  }
1130  }
1131  }
1132 
1138  public function getMetaKeywords()
1139  {
1140  if ( $this->_sMetaKeywords === null ) {
1141  $this->_sMetaKeywords = false;
1142 
1143  // set special meta keywords ?
1144  if ( ( $sKeywords = $this->_getMetaFromSeo( 'oxkeywords' ) ) ) {
1145  $this->_sMetaKeywords = $sKeywords;
1146  } elseif ( ( $sKeywords = $this->_getMetaFromContent( $this->_sMetaKeywordsIdent ) ) ) {
1147  $this->_sMetaKeywords = $this->_prepareMetaKeyword( $sKeywords, false );
1148  } else {
1149  $this->_sMetaKeywords = $this->_prepareMetaKeyword( false, true );
1150  }
1151  }
1152 
1153  return $this->_sMetaKeywords;
1154  }
1155 
1161  public function getMetaDescription()
1162  {
1163  if ( $this->_sMetaDescription === null ) {
1164  $this->_sMetaDescription = false;
1165 
1166  // set special meta description ?
1167  if ( ( $sDescription = $this->_getMetaFromSeo( 'oxdescription' ) ) ) {
1168  $this->_sMetaDescription = $sDescription;
1169  } elseif ( ( $sDescription = $this->_getMetaFromContent( $this->_sMetaDescriptionIdent ) ) ) {
1170  $this->_sMetaDescription = $this->_prepareMetaDescription( $sDescription );
1171  } else {
1172  $this->_sMetaDescription = $this->_prepareMetaDescription( false );
1173  }
1174  }
1175 
1176  return $this->_sMetaDescription;
1177  }
1178 
1184  public function getActCurrency()
1185  {
1186  return $this->_oActCurrency;
1187  }
1188 
1196  public function setActCurrency( $oCur )
1197  {
1198  $this->_oActCurrency = $oCur;
1199  }
1200 
1206  public function getCompareItemCount()
1207  {
1208  if ( $this->_iCompItemsCnt === null ) {
1209  $aItems = oxRegistry::getSession()->getVariable('aFiltcompproducts');
1210  $this->_iCompItemsCnt = is_array($aItems)?count($aItems):0;
1211  }
1212  return $this->_iCompItemsCnt;
1213  }
1214 
1220  protected function _forceNoIndex()
1221  {
1222  $this->_blForceNoIndex = true;
1223  }
1224 
1231  public function noIndex()
1232  {
1233  if ( $this->_blForceNoIndex ) {
1234  $this->_iViewIndexState = VIEW_INDEXSTATE_NOINDEXFOLLOW;
1235  } elseif ( oxConfig::getParameter( 'cur' ) ) {
1236  $this->_iViewIndexState = VIEW_INDEXSTATE_NOINDEXNOFOLLOW;
1237  } else {
1238  switch ( oxConfig::getParameter( 'fnc' ) ) {
1239  case 'tocomparelist':
1240  case 'tobasket':
1241  $this->_iViewIndexState = VIEW_INDEXSTATE_NOINDEXNOFOLLOW;
1242  break;
1243  }
1244  }
1245  return $this->_iViewIndexState;
1246  }
1247 
1255  public function isSortingActive()
1256  {
1257  return $this->_blActiveSorting;
1258  }
1259 
1265  public function getMenueList()
1266  {
1267  return $this->_aMenueList;
1268  }
1269 
1277  public function setMenueList( $aMenue )
1278  {
1279  $this->_aMenueList = $aMenue;
1280  }
1281 
1282 
1288  protected function _setNrOfArtPerPage()
1289  {
1290  $myConfig = $this->getConfig();
1291 
1292  //setting default values to avoid possible errors showing article list
1293  $iNrofCatArticles = $myConfig->getConfigParam( 'iNrofCatArticles' );
1294 
1295  $iNrofCatArticles = ( $iNrofCatArticles ) ? $iNrofCatArticles : 10;
1296 
1297  // checking if all needed data is set
1298  switch ( $this->getListDisplayType() ) {
1299  case 'grid':
1300  $aNrofCatArticles = $myConfig->getConfigParam( 'aNrofCatArticlesInGrid' );
1301  break;
1302  case 'line':
1303  case 'infogrid':
1304  default:
1305  $aNrofCatArticles = $myConfig->getConfigParam( 'aNrofCatArticles' );
1306  }
1307 
1308  if ( !is_array( $aNrofCatArticles ) || !isset( $aNrofCatArticles[0] ) ) {
1309  $aNrofCatArticles = array( $iNrofCatArticles );
1310  $myConfig->setConfigParam( 'aNrofCatArticles', $aNrofCatArticles );
1311  } else {
1312  $iNrofCatArticles = $aNrofCatArticles[0];
1313  }
1314 
1315  $oViewConf = $this->getViewConfig();
1316  //value from user input
1317  if ( ( $iNrofArticles = (int) oxConfig::getParameter( '_artperpage' ) ) ) {
1318  // M45 Possibility to push any "Show articles per page" number parameter
1319  $iNrofCatArticles = ( in_array( $iNrofArticles, $aNrofCatArticles ) ) ? $iNrofArticles : $iNrofCatArticles;
1320  $oViewConf->setViewConfigParam( 'iartPerPage', $iNrofCatArticles );
1321  oxSession::setVar( '_artperpage', $iNrofCatArticles );
1322  } elseif ( ( $iSessArtPerPage = oxRegistry::getSession()->getVariable( '_artperpage' ) )&& is_numeric( $iSessArtPerPage ) ) {
1323  // M45 Possibility to push any "Show articles per page" number parameter
1324  $iNrofCatArticles = ( in_array( $iSessArtPerPage, $aNrofCatArticles ) ) ? $iSessArtPerPage : $iNrofCatArticles;
1325  $oViewConf->setViewConfigParam( 'iartPerPage', $iSessArtPerPage );
1326  $iNrofCatArticles = $iSessArtPerPage;
1327  } else {
1328  $oViewConf->setViewConfigParam( 'iartPerPage', $iNrofCatArticles );
1329  }
1330 
1331  //setting number of articles per page to config value
1332  $myConfig->setConfigParam( 'iNrofCatArticles', $iNrofCatArticles );
1333  }
1334 
1340  protected function _getSeoObjectId()
1341  {
1342  }
1343 
1353  protected function _prepareMetaDescription( $sMeta, $iLength = 1024, $blRemoveDuplicatedWords = false )
1354  {
1355  if ( $sMeta ) {
1356 
1357  $oStr = getStr();
1358  if ( $iLength != -1 ) {
1359  /* *
1360  * performance - we do not need a huge amount of initial text.
1361  * assume that effective text may be double longer than $iLength
1362  * and simple truncate it
1363  */
1364  $iELength = ( $iLength * 2 );
1365  $sMeta = $oStr->substr( $sMeta, 0, $iELength );
1366  }
1367 
1368  // decoding html entities
1369  $sMeta = $oStr->html_entity_decode( $sMeta );
1370  // stripping HTML tags
1371  $sMeta = $oStr->strip_tags( $sMeta );
1372 
1373  // removing some special chars
1374  $sMeta = $oStr->cleanStr( $sMeta );
1375 
1376  // removing duplicate words
1377  if ( $blRemoveDuplicatedWords ) {
1378  $sMeta = $this->_removeDuplicatedWords( $sMeta, $this->getConfig()->getConfigParam( 'aSkipTags' ) );
1379  }
1380 
1381  // some special cases
1382  $sMeta = str_replace( ' ,', ',', $sMeta );
1383  $aPattern = array( "/,[\s\+\-\*]*,/", "/\s+,/" );
1384  $sMeta = $oStr->preg_replace( $aPattern, ',', $sMeta );
1385  $sMeta = oxRegistry::get("oxUtilsString")->minimizeTruncateString( $sMeta, $iLength );
1386  $sMeta = $oStr->htmlspecialchars( $sMeta );
1387 
1388  return trim( $sMeta );
1389  }
1390  }
1391 
1400  protected function _prepareMetaKeyword( $sKeywords, $blRemoveDuplicatedWords = true )
1401  {
1402 
1403  $sString = $this->_prepareMetaDescription( $sKeywords, -1, false );
1404 
1405  if ( $blRemoveDuplicatedWords ) {
1406  $sString = $this->_removeDuplicatedWords( $sString, $this->getConfig()->getConfigParam( 'aSkipTags' ) );
1407  }
1408 
1409  return trim( $sString );
1410  }
1411 
1420  protected function _removeDuplicatedWords( $aInput, $aSkipTags = array() )
1421  {
1422  $oStr = getStr();
1423  if ( is_array( $aInput ) ) {
1424  $aInput = implode( " ", $aInput );
1425  }
1426 
1427  // removing some usually met characters..
1428  $aInput = $oStr->preg_replace( "/[".preg_quote( $this->_sRemoveMetaChars, "/" )."]/", " ", $aInput );
1429 
1430  // splitting by word
1431  $aStrings = $oStr->preg_split( "/[\s,]+/", $aInput );
1432 
1433  if ( $sCount = count( $aSkipTags ) ) {
1434  for ( $iNum = 0; $iNum < $sCount; $iNum++ ) {
1435  $aSkipTags[$iNum] = $oStr->strtolower( $aSkipTags[$iNum] );
1436  }
1437  }
1438  $sCount = count($aStrings);
1439  for ( $iNum = 0; $iNum < $sCount; $iNum++ ) {
1440  $aStrings[$iNum] = $oStr->strtolower( $aStrings[$iNum] );
1441  // removing in admin defined strings
1442  if ( !$aStrings[$iNum] || in_array( $aStrings[$iNum], $aSkipTags ) ) {
1443  unset( $aStrings[$iNum] );
1444  }
1445  }
1446 
1447  // duplicates
1448  return implode( ', ', array_unique( $aStrings ) );
1449  }
1450 
1458  public function getNavigationParams()
1459  {
1460  $aParams['cnid'] = $this->getCategoryId();
1461  $aParams['mnid'] = oxConfig::getParameter( 'mnid' );
1462 
1463  $aParams['listtype'] = $this->getListType();
1464  $aParams['ldtype'] = $this->getCustomListDisplayType();
1465  $aParams['actcontrol'] = $this->getClassName();
1466 
1467  $aParams['recommid'] = oxConfig::getParameter( 'recommid' );
1468 
1469  $aParams['searchrecomm'] = oxConfig::getParameter( 'searchrecomm', true );
1470  $aParams['searchparam'] = oxConfig::getParameter( 'searchparam', true );
1471  $aParams['searchtag'] = oxConfig::getParameter( 'searchtag', true );
1472 
1473  $aParams['searchvendor'] = oxConfig::getParameter( 'searchvendor' );
1474  $aParams['searchcnid'] = oxConfig::getParameter( 'searchcnid' );
1475  $aParams['searchmanufacturer'] = oxConfig::getParameter( 'searchmanufacturer' );
1476 
1477  return $aParams;
1478  }
1479 
1489  public function setItemSorting( $sSortIdent, $sSortBy, $sSortDir = null )
1490  {
1491  $aSorting = oxRegistry::getSession()->getVariable( 'aSorting' );
1492  $aSorting[$sSortIdent]['sortby'] = $sSortBy;
1493  $aSorting[$sSortIdent]['sortdir'] = $sSortDir ? $sSortDir : null;
1494 
1495  oxRegistry::getSession()->setVariable( 'aSorting', $aSorting );
1496  }
1497 
1505  public function getSorting( $sSortIdent )
1506  {
1507  $aSorting = null;
1508 
1509  if ( $aSorting = $this->getUserSelectedSorting() ) {
1510  $this->setItemSorting( $sSortIdent, $aSorting['sortby'], $aSorting['sortdir'] );
1511  } elseif ( !$aSorting = $this->getSavedSorting( $sSortIdent ) ) {
1512  $aSorting = $this->getDefaultSorting();
1513  }
1514 
1515  if ( $aSorting ) {
1516  $this->setListOrderBy( $aSorting['sortby'] );
1517  $this->setListOrderDirection( $aSorting['sortdir'] );
1518  }
1519 
1520  return $aSorting;
1521  }
1522 
1530  public function getSortingSql( $sIdent )
1531  {
1532  $aSorting = $this->getSorting( $sIdent );
1533  if ( is_array( $aSorting ) ) {
1534  return implode( " ", $aSorting );
1535  }
1536  }
1537 
1543  public function getTitleSuffix()
1544  {
1545  return $this->getConfig()->getActiveShop()->oxshops__oxtitlesuffix->value;
1546  }
1547 
1553  public function getTitlePageSuffix()
1554  {
1555  }
1556 
1563  public function getTitlePrefix()
1564  {
1565  return $this->getConfig()->getActiveShop()->oxshops__oxtitleprefix->value;
1566  }
1567 
1568 
1569 
1578  protected function _getSubject( $iLang )
1579  {
1580  return null;
1581  }
1582 
1588  public function getDynUrlParams()
1589  {
1590  $sRet = '';
1591  $sListType = $this->getListType();
1592 
1593  switch ($sListType) {
1594  default:
1595  break;
1596  case 'search':
1597  $sRet .= "&amp;listtype={$sListType}";
1598  if ( $sSearchParamForLink = rawurlencode( oxConfig::getParameter( 'searchparam', true ) ) ) {
1599  $sRet .= "&amp;searchparam={$sSearchParamForLink}";
1600  }
1601 
1602  if ( ( $sVar = oxConfig::getParameter( 'searchcnid', true ) ) ) {
1603  $sRet .= '&amp;searchcnid='.rawurlencode( rawurldecode( $sVar ) );
1604  }
1605  if ( ( $sVar = oxConfig::getParameter( 'searchvendor', true ) ) ) {
1606  $sRet .= '&amp;searchvendor='.rawurlencode( rawurldecode( $sVar ) );
1607  }
1608  if ( ( $sVar = oxConfig::getParameter( 'searchmanufacturer', true ) ) ) {
1609  $sRet .= '&amp;searchmanufacturer='.rawurlencode( rawurldecode( $sVar ) );
1610  }
1611  break;
1612  case 'tag':
1613  $sRet .= "&amp;listtype={$sListType}";
1614  if ( $sParam = rawurlencode( oxConfig::getParameter( 'searchtag', true ) ) ) {
1615  $sRet .= "&amp;searchtag={$sParam}";
1616  }
1617  break;
1618  }
1619 
1620  return $sRet;
1621  }
1622 
1630  public function getLink( $iLang = null )
1631  {
1632  if ( !isset( $iLang ) ) {
1633  $iLang = oxRegistry::getLang()->getBaseLanguage();
1634  }
1635 
1636  $oDisplayObj = null;
1637  $blTrySeo = false;
1638  if ( oxRegistry::getUtils()->seoIsActive() ) {
1639  $blTrySeo = true;
1640  $oDisplayObj = $this->_getSubject( $iLang );
1641  }
1642  $iActPageNr = $this->getActPage();
1643 
1644  if ( $oDisplayObj ) {
1645  return $this->_addPageNrParam( $oDisplayObj->getLink( $iLang ), $iActPageNr, $iLang );
1646  }
1647 
1648  $myConfig = $this->getConfig();
1649 
1650  if ( $blTrySeo ) {
1651  $oEncoder = oxRegistry::get("oxSeoEncoder");
1652  if ( ( $sSeoUrl = $oEncoder->getStaticUrl( $myConfig->getShopHomeURL( $iLang ) . $this->_getSeoRequestParams(), $iLang ) ) ) {
1653  return $this->_addPageNrParam( $sSeoUrl, $iActPageNr, $iLang );
1654  }
1655  }
1656 
1657  $sUrl = oxRegistry::get("oxUtilsUrl")->processUrl( $myConfig->getShopCurrentURL( $iLang ) . $this->_getRequestParams(), true, null, $iLang);
1658 
1659  // fallback to old non seo url
1660  return $this->_addPageNrParam( $sUrl, $iActPageNr, $iLang );
1661  }
1662 
1668  public function getCanonicalUrl()
1669  {
1670  }
1671 
1678  public function getSimilarRecommListIds()
1679  {
1680  return false;
1681  }
1688  public function getSearchParamForHtml()
1689  {
1690  }
1691 
1699  protected function _getRequestParams( $blAddPageNr = true )
1700  {
1701  $sClass = $this->getClassName();
1702  $sFnc = $this->getFncName();
1703 
1704  $aFnc = array( 'tobasket', 'login_noredirect', 'addVoucher', 'moveleft', 'moveright' );
1705  if ( in_array( $sFnc, $aFnc ) ) {
1706  $sFnc = '';
1707  }
1708 
1709  // #680
1710  $sURL = "cl={$sClass}";
1711  if ( $sFnc ) {
1712  $sURL .= "&amp;fnc={$sFnc}";
1713  }
1714  if ( $sVal = oxConfig::getParameter( 'cnid' ) ) {
1715  $sURL .= "&amp;cnid={$sVal}";
1716  }
1717  if ( $sVal = oxConfig::getParameter( 'mnid' ) ) {
1718  $sURL .= "&amp;mnid={$sVal}";
1719  }
1720  if ( $sVal= oxConfig::getParameter( 'anid' ) ) {
1721  $sURL .= "&amp;anid={$sVal}";
1722  }
1723 
1724  if ( $sVal = basename( oxConfig::getParameter( 'page' ) ) ) {
1725  $sURL .= "&amp;page={$sVal}";
1726  }
1727 
1728  if ( $sVal = basename( oxConfig::getParameter( 'tpl' ) ) ) {
1729  $sURL .= "&amp;tpl={$sVal}";
1730  }
1731 
1732  if ( $sVal = oxConfig::getParameter( 'oxloadid' ) ) {
1733  $sURL .= "&amp;oxloadid={$sVal}";
1734  }
1735 
1736  $iPgNr = (int) oxConfig::getParameter( 'pgNr' );
1737  // don't include page number for navigation
1738  // it will be done in oxubase::generatePageNavigation
1739  if ( $blAddPageNr && $iPgNr > 0 ) {
1740  $sURL .= "&amp;pgNr={$iPgNr}";
1741  }
1742 
1743  // #1184M - specialchar search
1744  if ( $sVal = rawurlencode( oxConfig::getParameter( 'searchparam', true ) ) ) {
1745  $sURL .= "&amp;searchparam={$sVal}";
1746  }
1747 
1748  if ( $sVal = oxConfig::getParameter( 'searchcnid' ) ) {
1749  $sURL .= "&amp;searchcnid={$sVal}";
1750  }
1751 
1752  if ( $sVal = oxConfig::getParameter( 'searchvendor' ) ) {
1753  $sURL .= "&amp;searchvendor={$sVal}";
1754  }
1755 
1756  if ( $sVal = oxConfig::getParameter( 'searchmanufacturer' ) ) {
1757  $sURL .= "&amp;searchmanufacturer={$sVal}";
1758  }
1759 
1760  if ( $sVal = oxConfig::getParameter( 'searchrecomm' ) ) {
1761  $sURL .= "&amp;searchrecomm={$sVal}";
1762  }
1763 
1764  if ( $sVal = oxConfig::getParameter( 'searchtag' ) ) {
1765  $sURL .= "&amp;searchtag={$sVal}";
1766  }
1767 
1768  if ( $sVal = oxConfig::getParameter( 'recommid' ) ) {
1769  $sURL .= "&amp;recommid={$sVal}";
1770  }
1771 
1772  return $sURL;
1773  }
1774 
1780  protected function _getSeoRequestParams()
1781  {
1782  $sClass = $this->getClassName();
1783  $sFnc = $this->getFncName();
1784 
1785  // #921 S
1786  $aFnc = array( 'tobasket', 'login_noredirect', 'addVoucher' );
1787  if ( in_array( $sFnc, $aFnc ) ) {
1788  $sFnc = '';
1789  }
1790 
1791  // #680
1792  $sURL = "cl={$sClass}";
1793  if ( $sFnc ) {
1794  $sURL .= "&amp;fnc={$sFnc}";
1795  }
1796  if ( $sVal = basename( oxConfig::getParameter( 'page' ) ) ) {
1797  $sURL .= "&amp;page={$sVal}";
1798  }
1799 
1800  if ( $sVal = basename( oxConfig::getParameter( 'tpl' ) ) ) {
1801  $sURL .= "&amp;tpl={$sVal}";
1802  }
1803 
1804  if ( $sVal = oxConfig::getParameter( 'oxloadid' ) ) {
1805  $sURL .= "&amp;oxloadid={$sVal}";
1806  }
1807 
1808  $iPgNr = (int) oxConfig::getParameter( 'pgNr' );
1809  if ( $iPgNr > 0 ) {
1810  $sURL .= "&amp;pgNr={$iPgNr}";
1811  }
1812 
1813  return $sURL;
1814  }
1815 
1821  public function showSearch()
1822  {
1823  $blShow = true;
1824  if ( $this->getConfig()->getConfigParam( 'blDisableNavBars' ) && $this->getIsOrderStep() ) {
1825  $blShow = false;
1826  }
1827  return (int) $blShow;
1828  }
1829 
1835  public function getRssLinks()
1836  {
1837  return $this->_aRssLinks;
1838  }
1839 
1845  public function getSortColumns()
1846  {
1847  if ( $this->_aSortColumns === null ) {
1848  $this->setSortColumns( $this->getConfig()->getConfigParam( 'aSortCols' ) );
1849  }
1850  return $this->_aSortColumns;
1851  }
1852 
1853 
1861  public function setSortColumns( $aSortColumns )
1862  {
1863  $this->_aSortColumns = $aSortColumns;
1864  }
1865 
1871  public function getEditTags()
1872  {
1873  }
1874 
1880  public function getRecommSearch()
1881  {
1882  }
1883 
1889  public function getPaymentList()
1890  {
1891  }
1892 
1898  public function getActiveRecommList()
1899  {
1900  if ( $this->_oActiveRecommList === null ) {
1901  $this->_oActiveRecommList = false;
1902  if ( $sOxid = oxConfig::getParameter( 'recommid' ) ) {
1903  $this->_oActiveRecommList = oxNew( 'oxrecommlist' );
1904  $this->_oActiveRecommList->load( $sOxid );
1905  }
1906  }
1908  }
1909 
1915  public function getAccessoires()
1916  {
1917  }
1918 
1924  public function getCrossSelling()
1925  {
1926  }
1927 
1933  public function getSimilarProducts()
1934  {
1935  }
1936 
1942  public function getAlsoBoughtTheseProducts()
1943  {
1944  }
1945 
1951  public function getArticleId()
1952  {
1953  }
1954 
1960  public function getTitle()
1961  {
1962  $sTranslationName = 'PAGE_TITLE_'.strtoupper($this->getConfig()->getActiveView()->getClassName());
1963  $sTranslated = oxRegistry::getLang()->translateString( $sTranslationName, oxRegistry::getLang()->getBaseLanguage(), false );
1964  return $sTranslationName == $sTranslated? null : $sTranslated;
1965  }
1966 
1972  public function getActiveLangAbbr()
1973  {
1974  // Performance
1975  if ( !$this->getConfig()->getConfigParam( 'bl_perfLoadLanguages' ) ) {
1976  return;
1977  }
1978 
1979  if ( !isset($this->_sActiveLangAbbr ) ) {
1980  $aLanguages = oxRegistry::getLang()->getLanguageArray();
1981  while ( list( $sKey, $oVal ) = each( $aLanguages ) ) {
1982  if ( $oVal->selected ) {
1983  $this->_sActiveLangAbbr = $oVal->abbr;
1984  break;
1985  }
1986  }
1987  }
1988 
1989  return $this->_sActiveLangAbbr;
1990  }
1991 
1999  public function addGlobalParams( $oShop = null)
2000  {
2001  $oViewConf = parent::addGlobalParams( $oShop );
2002 
2003  $this->_setNrOfArtPerPage();
2004 
2005  return $oViewConf;
2006  }
2007 
2013  public function getAdditionalParams()
2014  {
2015  if ( $this->_sAdditionalParams === null ) {
2016  // #1018A
2017  $this->_sAdditionalParams = parent::getAdditionalParams();
2018  $this->_sAdditionalParams .= 'cl='.$this->getConfig()->getTopActiveView()->getClassName();
2019 
2020  // #1834M - specialchar search
2021  $sSearchParamForLink = rawurlencode( oxConfig::getParameter( 'searchparam', true ) );
2022  if ( isset( $sSearchParamForLink ) ) {
2023  $this->_sAdditionalParams .= "&amp;searchparam={$sSearchParamForLink}";
2024  }
2025  if ( ( $sVar = oxConfig::getParameter( 'searchtag' ) ) ) {
2026  $this->_sAdditionalParams .= '&amp;searchtag='.rawurlencode( rawurldecode( $sVar ) );
2027  }
2028  if ( ( $sVar = oxConfig::getParameter( 'searchcnid' ) ) ) {
2029  $this->_sAdditionalParams .= '&amp;searchcnid='.rawurlencode( rawurldecode( $sVar ) );
2030  }
2031  if ( ( $sVar = oxConfig::getParameter( 'searchvendor' ) ) ) {
2032  $this->_sAdditionalParams .= '&amp;searchvendor='.rawurlencode( rawurldecode( $sVar ) );
2033  }
2034  if ( ( $sVar = oxConfig::getParameter( 'searchmanufacturer' ) ) ) {
2035  $this->_sAdditionalParams .= '&amp;searchmanufacturer='.rawurlencode( rawurldecode( $sVar ) );
2036  }
2037  if ( ( $sVar = oxConfig::getParameter( 'cnid' ) ) ) {
2038  $this->_sAdditionalParams .= '&amp;cnid='.rawurlencode( rawurldecode( $sVar ) );
2039  }
2040  if ( ( $sVar = oxConfig::getParameter( 'mnid' ) ) ) {
2041  $this->_sAdditionalParams .= '&amp;mnid='.rawurlencode( rawurldecode( $sVar ) );
2042  }
2043  }
2044 
2046  }
2047 
2053  public function generatePageNavigationUrl()
2054  {
2055  return $this->getConfig()->getShopHomeURL().$this->_getRequestParams( false );
2056  }
2057 
2067  protected function _addPageNrParam( $sUrl, $iPage, $iLang = null )
2068  {
2069  if ( $iPage ) {
2070  if ( ( strpos( $sUrl, 'pgNr=' ) ) ) {
2071  $sUrl = preg_replace('/pgNr=[0-9]*/', 'pgNr='.$iPage, $sUrl);
2072  } else {
2073  $sUrl .= ( ( strpos( $sUrl, '?' ) === false ) ? '?' : '&amp;' ) . 'pgNr='.$iPage;
2074  }
2075  } else {
2076  $sUrl = preg_replace('/pgNr=[0-9]*/', '', $sUrl);
2077  $sUrl = preg_replace('/\&amp\;\&amp\;/', '&amp;', $sUrl);
2078  $sUrl = preg_replace('/\?\&amp\;/', '?', $sUrl);
2079  $sUrl = preg_replace('/\&amp\;$/', '', $sUrl);
2080  }
2081  return $sUrl;
2082  }
2083 
2089  public function getPageNavigation()
2090  {
2091 
2092  }
2093 
2101  public function getPageNavigationLimitedTop( $iPositionCount = 7 )
2102  {
2103  $this->_oPageNavigation = $this->generatePageNavigation( $iPositionCount );
2104  return $this->_oPageNavigation;
2105  }
2106 
2114  public function getPageNavigationLimitedBottom( $iPositionCount = 11 )
2115  {
2116  $this->_oPageNavigation = $this->generatePageNavigation( $iPositionCount );
2117  return $this->_oPageNavigation;
2118  }
2119 
2120 
2128  public function generatePageNavigation( $iPositionCount = 0 )
2129  {
2130  startProfile('generatePageNavigation');
2131 
2132  $pageNavigation = new stdClass();
2133 
2134  $pageNavigation->NrOfPages = $this->_iCntPages;
2135  $iActPage = $this->getActPage();
2136  $pageNavigation->actPage = $iActPage + 1;
2137  $sUrl = $this->generatePageNavigationUrl();
2138 
2139  if ( $iPositionCount == 0 || ($iPositionCount >= $pageNavigation->NrOfPages) ) {
2140  $iStartNo = 2;
2141  $iFinishNo = $pageNavigation->NrOfPages;
2142  $bStart = false;
2143  $bFinish =false;
2144  } else {
2145  $iTmpVal = $iPositionCount - 3;
2146  $iTmpVal2 = floor( ( $iPositionCount - 4 ) / 2 );
2147 
2148  // actual page is at the start
2149  if ( $pageNavigation->actPage <= $iTmpVal ) {
2150  $iStartNo = 2;
2151  $iFinishNo = $iTmpVal + 1;
2152  $bStart = false;
2153  $bFinish = true;
2154  // actual page is at the end
2155  } elseif ( $pageNavigation->actPage >= $pageNavigation->NrOfPages - $iTmpVal ) {
2156  $iStartNo = $pageNavigation->NrOfPages - $iTmpVal;
2157  $iFinishNo = $pageNavigation->NrOfPages - 1;
2158  $bStart = true;
2159  $bFinish = false;
2160  // actual page is in the midle
2161  } else {
2162  $iStartNo = $pageNavigation->actPage - $iTmpVal2;
2163  $iFinishNo = $pageNavigation->actPage + $iTmpVal2;
2164  $bStart = true;
2165  $bFinish = true;
2166  }
2167  }
2168 
2169  if ( $iActPage > 0) {
2170  $pageNavigation->previousPage = $this->_addPageNrParam( $sUrl, $iActPage - 1 );
2171  }
2172 
2173  if ( $iActPage < $pageNavigation->NrOfPages - 1 ) {
2174  $pageNavigation->nextPage = $this->_addPageNrParam( $sUrl, $iActPage + 1 );
2175  }
2176 
2177  if ( $pageNavigation->NrOfPages > 1 ) {
2178 
2179  for ( $i=1; $i < $pageNavigation->NrOfPages + 1; $i++ ) {
2180 
2181  if ( $i == 1 || $i == $pageNavigation->NrOfPages || ( $i >= $iStartNo && $i <= $iFinishNo ) ) {
2182  $page = new stdClass();
2183  $page->url = $this->_addPageNrParam( $sUrl, $i - 1 );
2184  $page->selected = ( $i == $pageNavigation->actPage ) ? 1 : 0;
2185  $pageNavigation->changePage[$i] = $page;
2186  }
2187  }
2188 
2189  // first/last one
2190  $pageNavigation->firstpage = $this->_addPageNrParam( $sUrl, 0 );
2191  $pageNavigation->lastpage = $this->_addPageNrParam( $sUrl, $pageNavigation->NrOfPages - 1 );
2192  }
2193 
2194  stopProfile('generatePageNavigation');
2195 
2196  return $pageNavigation;
2197  }
2198 
2205  public function render()
2206  {
2207  foreach ( array_keys( $this->_oaComponents ) as $sComponentName ) {
2208  $this->_aViewData[$sComponentName] = $this->_oaComponents[$sComponentName]->render();
2209  }
2210 
2211  parent::render();
2212 
2213  if ( $this->getIsOrderStep() ) {
2214 
2215  // disabling navigation during order ...
2216  if ( $this->getConfig()->getConfigParam( 'blDisableNavBars' ) ) {
2217  $this->_iNewsRealStatus = 1;
2218  $this->setShowNewsletter( 0 );
2219  }
2220  }
2221  return $this->_sThisTemplate;
2222  }
2223 
2229  public function getViewProduct()
2230  {
2231  return $this->getProduct();
2232  }
2233 
2241  public function setViewProduct( $oProduct )
2242  {
2243  $this->_oProduct = $oProduct;
2244  }
2245 
2251  public function getViewProductList()
2252  {
2253  return $this->_aArticleList;
2254  }
2255 
2261  public function getActPage()
2262  {
2263  if ( $this->_iActPage === null ) {
2264  $this->_iActPage = ( int ) oxConfig::getParameter( 'pgNr' );
2265  $this->_iActPage = ( $this->_iActPage < 0 ) ? 0 : $this->_iActPage;
2266  }
2267  return $this->_iActPage;
2268  }
2269 
2277  public function getActTag()
2278  {
2279  if ( $this->_oActTag === null ) {
2280  $this->_oActTag = new stdClass();
2281  $this->_oActTag->sTag = $sTag = oxConfig::getParameter("searchtag", 1);
2282  $oSeoEncoderTag = oxRegistry::get("oxSeoEncoderTag");
2283 
2284  $sLink = false;
2285  if ( oxRegistry::getUtils()->seoIsActive() ) {
2286  $sLink = $oSeoEncoderTag->getTagUrl( $sTag, oxRegistry::getLang()->getBaseLanguage() );
2287  }
2288 
2289  $this->_oActTag->link = $sLink ? $sLink : $this->getConfig()->getShopHomeURL().$oSeoEncoderTag->getStdTagUri( $sTag, false );
2290  }
2291  return $this->_oActTag;
2292  }
2293 
2301  public function getActVendor()
2302  {
2303  // if active vendor is not set yet - trying to load it from request params
2304  // this may be usefull when category component was unable to load active vendor
2305  // and we still need some object to mount navigation info
2306  if ( $this->_oActVendor === null ) {
2307  $this->_oActVendor = false;
2308  $sVendorId = oxConfig::getParameter( 'cnid' );
2309  $sVendorId = $sVendorId ? str_replace( 'v_', '', $sVendorId ) : $sVendorId;
2310  $oVendor = oxNew( 'oxvendor' );
2311  if ( $oVendor->load( $sVendorId ) ) {
2312  $this->_oActVendor = $oVendor;
2313  }
2314  }
2315 
2316  return $this->_oActVendor;
2317  }
2318 
2326  public function getActManufacturer()
2327  {
2328  // if active Manufacturer is not set yet - trying to load it from request params
2329  // this may be usefull when category component was unable to load active Manufacturer
2330  // and we still need some object to mount navigation info
2331  if ( $this->_oActManufacturer === null ) {
2332 
2333  $this->_oActManufacturer = false;
2334  $sManufacturerId = oxConfig::getParameter( 'mnid' );
2335  $oManufacturer = oxNew( 'oxmanufacturer' );
2336  if ( $oManufacturer->load( $sManufacturerId ) ) {
2337  $this->_oActManufacturer = $oManufacturer;
2338  }
2339  }
2340 
2341  return $this->_oActManufacturer;
2342  }
2343 
2351  public function setActVendor( $oVendor )
2352  {
2353  $this->_oActVendor = $oVendor;
2354  }
2355 
2363  public function setActManufacturer( $oManufacturer )
2364  {
2365  $this->_oActManufacturer = $oManufacturer;
2366  }
2367 
2373  public function getActSearch()
2374  {
2375  if ( $this->_oActSearch === null ) {
2376  $this->_oActSearch = new stdClass();
2377  $sUrl = $this->getConfig()->getShopHomeURL();
2378  $this->_oActSearch->link = "{$sUrl}cl=search";
2379  }
2380  return $this->_oActSearch;
2381  }
2382 
2388  public function getCategoryTree()
2389  {
2390  return $this->_oCategoryTree;
2391  }
2392 
2400  public function setCategoryTree( $oCatTree )
2401  {
2402  $this->_oCategoryTree = $oCatTree;
2403  }
2404 
2410  public function getManufacturerTree()
2411  {
2413  }
2414 
2422  public function setManufacturerTree( $oManufacturerTree )
2423  {
2424  $this->_oManufacturerTree = $oManufacturerTree;
2425  }
2426 
2432  public function getAddUrlParams()
2433  {
2434  }
2435 
2444  public function getTop5ArticleList( $iCount = null )
2445  {
2446  if ( $this->_blTop5Action ) {
2447  if ( $this->_aTop5ArticleList === null ) {
2448  $this->_aTop5ArticleList = false;
2449  $myConfig = $this->getConfig();
2450  if ( $myConfig->getConfigParam( 'bl_perfLoadAktion' ) ) {
2451  // top 5 articles
2452  $oArtList = oxNew( 'oxarticlelist' );
2453  $oArtList->loadTop5Articles( $iCount );
2454  if ( $oArtList->count() ) {
2455  $this->_aTop5ArticleList = $oArtList;
2456  }
2457  }
2458  }
2459  }
2460  return $this->_aTop5ArticleList;
2461  }
2462 
2469  public function getBargainArticleList()
2470  {
2471  if ( $this->_blBargainAction ) {
2472  if ( $this->_aBargainArticleList === null ) {
2473  $this->_aBargainArticleList = array();
2474  if ( $this->getConfig()->getConfigParam( 'bl_perfLoadAktion' ) ) {
2475  $oArtList = oxNew( 'oxarticlelist' );
2476  $oArtList->loadActionArticles( 'OXBARGAIN' );
2477  if ( $oArtList->count() ) {
2478  $this->_aBargainArticleList = $oArtList;
2479  }
2480  }
2481  }
2482  }
2484  }
2485 
2494  public function isLowOrderPrice()
2495  {
2496  if ( $this->_blLowOrderPrice === null && ( $oBasket = $this->getSession()->getBasket() ) ) {
2497  $this->_blLowOrderPrice = $oBasket->isBelowMinOrderPrice();
2498  }
2499 
2500  return $this->_blLowOrderPrice;
2501  }
2502 
2510  public function getMinOrderPrice()
2511  {
2512  if ( $this->_sMinOrderPrice === null && $this->isLowOrderPrice() ) {
2513  $dMinOrderPrice = oxPrice::getPriceInActCurrency( $this->getConfig()->getConfigParam( 'iMinOrderPrice' ) );
2514  $this->_sMinOrderPrice = oxRegistry::getLang()->formatCurrency( $dMinOrderPrice );
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 ( oxConfig::getParameter( $sParam ) !== null ) {
2538  return false;
2539  }
2540  }
2541 
2542  return true;
2543  }
2544 
2550  public function getProduct()
2551  {
2552  }
2553 
2559  public function getManufacturerlist()
2560  {
2562  }
2563 
2571  public function setManufacturerlist( $aList )
2572  {
2573  $this->_aManufacturerlist = $aList;
2574  }
2575 
2583  public function setRootVendor( $oVendor )
2584  {
2585  $this->_oRootVendor = $oVendor;
2586  }
2587 
2593  public function getRootVendor()
2594  {
2595  return $this->_oRootVendor;
2596  }
2597 
2605  public function setRootManufacturer( $oManufacturer )
2606  {
2607  $this->_oRootManufacturer = $oManufacturer;
2608  }
2609 
2615  public function getRootManufacturer()
2616  {
2618  }
2619 
2625  public function getVendorId()
2626  {
2627  if ( $this->_sVendorId === null ) {
2628  $this->_sVendorId = false;
2629  if ( ( $oVendor = $this->getActVendor() ) ) {
2630  $this->_sVendorId = $oVendor->getId();
2631  }
2632  }
2633  return $this->_sVendorId;
2634  }
2635 
2641  public function getManufacturerId()
2642  {
2643  if ( $this->_sManufacturerId === null ) {
2644  $this->_sManufacturerId = false;
2645  if ( ( $oManufacturer = $this->getActManufacturer() ) ) {
2646  $this->_sManufacturerId = $oManufacturer->getId();
2647  }
2648  }
2649  return $this->_sManufacturerId;
2650  }
2651 
2659  public function getSearchCatTree()
2660  {
2661  return $this->_aSearchCatTree;
2662  }
2663 
2673  public function setSearchCatTree( $aTree )
2674  {
2675  $this->_aSearchCatTree = $aTree;
2676  }
2677 
2683  public function getCatMoreUrl()
2684  {
2685  return $this->getConfig()->getShopHomeURL().'cnid=oxmore';
2686  }
2687 
2693  public function getCatTreePath()
2694  {
2695  return $this->_sCatTreePath;
2696  }
2697 
2705  public function getContentByIdent( $sIdent )
2706  {
2707  if ( !isset( $this->_aContents[$sIdent] ) ) {
2708  $this->_aContents[$sIdent] = oxNew( 'oxcontent' );
2709  $this->_aContents[$sIdent]->loadByIdent( $sIdent );
2710  }
2711  return $this->_aContents[$sIdent];
2712  }
2713 
2719  public function getContentCategory()
2720  {
2721  return false;
2722  }
2723 
2729  public function getMustFillFields()
2730  {
2731  if ( $this->_aMustFillFields === null ) {
2732  $this->_aMustFillFields = false;
2733 
2734  // passing must-be-filled-fields info
2735  $aMustFillFields = $this->getConfig()->getConfigParam( 'aMustFillFields' );
2736  if ( is_array( $aMustFillFields ) ) {
2737  $this->_aMustFillFields = array_flip( $aMustFillFields );
2738  }
2739  }
2740  return $this->_aMustFillFields;
2741  }
2742 
2750  public function isFieldRequired( $sField )
2751  {
2752  if ( $aMustFillFields = $this->getMustFillFields() ) {
2753  if ( isset( $aMustFillFields[$sField] ) ) {
2754  return true;
2755  }
2756  }
2757 
2758  return false;
2759  }
2760 
2766  public function getFormId()
2767  {
2768  if ( $this->_sFormId === null ) {
2769  $this->_sFormId = oxUtilsObject::getInstance()->generateUId();
2770  oxSession::setVar( 'sessionuformid', $this->_sFormId );
2771  }
2772 
2773  return $this->_sFormId;
2774  }
2775 
2781  public function canAcceptFormData()
2782  {
2783  if ( $this->_blCanAcceptFormData === null ) {
2784  $this->_blCanAcceptFormData = false;
2785 
2786  $sFormId = oxConfig::getParameter( "uformid" );
2787  $sSessionFormId = oxRegistry::getSession()->getVariable( "sessionuformid" );
2788 
2789  // testing if form and session ids matches
2790  if ( $sFormId && $sFormId === $sSessionFormId ) {
2791  $this->_blCanAcceptFormData = true;
2792  }
2793 
2794  // regenerating form data
2795  $this->getFormId();
2796  }
2797  return $this->_blCanAcceptFormData;
2798  }
2799 
2805  public function getPromoFinishedList()
2806  {
2807  if (isset($this->_oPromoFinishedList)) {
2808  return $this->_oPromoFinishedList;
2809  }
2810  $this->_oPromoFinishedList = oxNew( 'oxActionList' );
2811  $this->_oPromoFinishedList->loadFinishedByCount(2);
2812  return $this->_oPromoFinishedList;
2813  }
2814 
2820  public function getPromoCurrentList()
2821  {
2822  if (isset($this->_oPromoCurrentList)) {
2823  return $this->_oPromoCurrentList;
2824  }
2825  $this->_oPromoCurrentList = oxNew( 'oxActionList' );
2826  $this->_oPromoCurrentList->loadCurrent();
2827  return $this->_oPromoCurrentList;
2828  }
2829 
2835  public function getPromoFutureList()
2836  {
2837  if (isset($this->_oPromoFutureList)) {
2838  return $this->_oPromoFutureList;
2839  }
2840  $this->_oPromoFutureList = oxNew( 'oxActionList' );
2841  $this->_oPromoFutureList->loadFutureByCount(2);
2842  return $this->_oPromoFutureList;
2843  }
2844 
2850  public function getShowPromotionList()
2851  {
2852  if (isset($this->_blShowPromotions)) {
2853  return $this->_blShowPromotions;
2854  }
2855  $this->_blShowPromotions = false;
2856  if (oxNew('oxActionList')->areAnyActivePromotions()) {
2857  $this->_blShowPromotions = ( count( $this->getPromoFinishedList() ) + count( $this->getPromoCurrentList() ) + count( $this->getPromoFutureList() ) ) > 0;
2858  }
2859  return $this->_blShowPromotions;
2860  }
2861 
2867  public function isEnabledPrivateSales()
2868  {
2869  if ( $this->_blEnabledPrivateSales === null ) {
2870  $this->_blEnabledPrivateSales = (bool) $this->getConfig()->getConfigParam( 'blPsLoginEnabled' );
2871  if ( $this->_blEnabledPrivateSales && ( $blCanPreview = oxRegistry::getUtils()->canPreview() ) !== null ) {
2872  $this->_blEnabledPrivateSales = !$blCanPreview;
2873  }
2874  }
2876  }
2877 
2883  public function getFieldValidationErrors()
2884  {
2885  return oxRegistry::get("oxInputValidator")->getFieldValidationErrors();
2886  }
2887 
2893  public function getBreadCrumb()
2894  {
2895  return null;
2896  }
2897 
2905  public function setRootCatChanged( $blRootCatChanged )
2906  {
2907  $this->_blRootCatChanged = $blRootCatChanged;
2908  }
2909 
2915  public function isRootCatChanged()
2916  {
2917  return $this->_blRootCatChanged;
2918  }
2919 
2925  public function getInvoiceAddress()
2926  {
2927  if ( $this->_aInvoiceAddress == null ) {
2928  $aAddress = oxConfig::getParameter( 'invadr');
2929  if ( $aAddress ) {
2930  $this->_aInvoiceAddress = $aAddress;
2931  }
2932  }
2933  return $this->_aInvoiceAddress;
2934  }
2935 
2941  public function getDeliveryAddress()
2942  {
2943  if ( $this->_aDeliveryAddress == null ) {
2944  $oConfig = $this->getConfig();
2945  //do not show deladr if address was reloaded
2946  if ( !$oConfig->getRequestParameter( 'reloadaddress' ) ) {
2947  $this->_aDeliveryAddress = $oConfig->getRequestParameter( 'deladr');
2948  }
2949  }
2950  return $this->_aDeliveryAddress;
2951  }
2952 
2960  public function setDeliveryAddress($aDeliveryAddress)
2961  {
2962  $this->_aDeliveryAddress = $aDeliveryAddress;
2963  }
2964 
2972  public function setInvoiceAddress( $aAddress )
2973  {
2974  $this->_aInvoiceAddress = $aAddress;
2975  }
2976 
2982  public function getActiveUsername()
2983  {
2984  if ( $this->_sActiveUsername == null ) {
2985  $this->_sActiveUsername = false;
2986  $sUsername = oxConfig::getParameter( 'lgn_usr' );
2987  if ( $sUsername ) {
2988  $this->_sActiveUsername = $sUsername;
2989  } elseif ( $oUser = $this->getUser() ) {
2990  $this->_sActiveUsername = $oUser->oxuser__oxusername->value;
2991  }
2992  }
2993  return $this->_sActiveUsername;
2994  }
2995 
3001  public function getWishlistUserId()
3002  {
3003  return oxConfig::getParameter( 'wishid' );
3004  }
3005 
3011  public function getSearchCatId()
3012  {
3013  }
3014 
3020  public function getSearchVendor()
3021  {
3022  }
3023 
3029  public function getSearchManufacturer()
3030  {
3031  }
3032 
3038  public function getLastProducts()
3039  {
3040 
3041  }
3042 
3048  public function getNewBasketItemMsgType()
3049  {
3050  return (int) $this->getConfig()->getConfigParam( "iNewBasketItemMessage" );
3051  }
3052 
3060  public function isActive( $sName )
3061  {
3062  return $this->getConfig()->getConfigParam( "bl".$sName."Enabled" );
3063  }
3064 
3070  public function isFbWidgetVisible()
3071  {
3072  if ( $this->_blFbWidgetsOn === null ) {
3073  $oUtils = oxRegistry::get("oxUtilsServer");
3074 
3075  // reading ..
3076  $this->_blFbWidgetsOn = (bool) $oUtils->getOxCookie( "fbwidgetson" );
3077  }
3078  return $this->_blFbWidgetsOn;
3079  }
3080 
3086  public function isEnabledDownloadableFiles()
3087  {
3088  return (bool) $this->getConfig()->getConfigParam( "blEnableDownloads" );
3089  }
3090 
3096  public function showRememberMe()
3097  {
3098  return (bool) $this->getConfig()->getConfigParam('blShowRememberMe');
3099  }
3100 
3107  public function isVatIncluded()
3108  {
3109  $blResult = true;
3110  $oUser = $this->getUser();
3111  $oConfig = $this->getConfig();
3112 
3113  if ( $oConfig->getConfigParam( 'blShowNetPrice' ) || $oConfig->getConfigParam( 'bl_perfCalcVatOnlyForBasketOrder' ) ) {
3114  $blResult = false;
3115  } elseif ( $oUser && $oUser->isPriceViewModeNetto() ) {
3116  $blResult = false;
3117  }
3118 
3119  return $blResult;
3120  }
3121 
3127  public function isPriceCalculated()
3128  {
3129  return (bool) $this->getConfig()->getConfigParam( 'bl_perfLoadPrice' );
3130  }
3131 
3137  public function showTags()
3138  {
3139  return (bool) $this->_blShowTagCloud && $this->getConfig()->getConfigParam( "blShowTags" );
3140  }
3141 
3147  public function getWishlistName()
3148  {
3149  if ( $this->getUser() ) {
3150  $sUserId = oxConfig::getParameter( 'wishid') ? oxConfig::getParameter( 'wishid' ): oxRegistry::getSession()->getVariable( 'wishid');
3151  if ( $sUserId ) {
3152  $oWishUser = oxNew( 'oxuser' );
3153  if ( $oWishUser->load( $sUserId ) ) {
3154  return $oWishUser;
3155  }
3156  }
3157  }
3158  return false;
3159  }
3160 
3166  public function getWidgetLink()
3167  {
3168  return oxRegistry::getConfig()->getWidgetUrl();
3169  }
3170 }