OXID eShop CE  4.8.12
 All Classes Files Functions Variables Pages
details.php
Go to the documentation of this file.
1 <?php
2 
9 class Details extends oxUBase
10 {
16  protected $_sThisTemplate = 'page/details/details.tpl';
17 
23  protected $_oParentProd = null;
24 
29  protected $_blEditTags = null;
30 
35  protected $_aTags = null;
36 
41  protected $_oCaptcha = null;
42 
47  protected $_sParentName = null;
48 
53  protected $_sParentUrl = null;
54 
59  protected $_aPicGallery = null;
60 
65  protected $_aSelectLists = null;
66 
71  protected $_aReviews = null;
72 
77  protected $_oCrossSelling = null;
78 
83  protected $_oSimilarProducts = null;
84 
89  protected $_oAccessoires = null;
90 
95  protected $_aAlsoBoughtArts = null;
96 
101  protected $_sSearchTitle = null;
102 
108  protected $_blIsInitialized = false;
109 
115  protected $_iLinkType = null;
116 
121  protected $_sBidPrice = null;
122 
127  protected $_iPriceAlarmStatus = null;
128 
133  protected $_sSearchParamForHtml = null;
134 
140  protected $_aSimilarRecommListIds = null;
141 
142 
147  protected $_blShowSorting = true;
148 
156  protected function _getParentProduct( $sParentId )
157  {
158  if ( $sParentId && $this->_oParentProd === null ) {
159  $this->_oParentProd = false;
160  $oProduct = oxNew( 'oxArticle' );
161  if ( ( $oProduct->load( $sParentId ) ) ) {
162  $this->_processProduct( $oProduct );
163  $this->_oParentProd = $oProduct;
164  }
165  }
166  return $this->_oParentProd;
167  }
168 
174  protected function _getAddUrlParams()
175  {
176  if ( $this->getListType() == "search" ) {
177  return $this->getDynUrlParams();
178  }
179  }
180 
189  public function getNavigationParams()
190  {
191  $aParams = parent::getNavigationParams();
192 
193  $aVarSelParams = oxRegistry::getConfig()->getRequestParameter( 'varselid' );
194  $aSelectListParams = oxRegistry::getConfig()->getRequestParameter( 'sel' );
195  if ( !$aVarSelParams && !$aSelectListParams ) {
196  return $aParams;
197  }
198 
199  if ( $aVarSelParams ) {
200  foreach ( $aVarSelParams as $iKey => $sValue ) {
201  $aParams["varselid[$iKey]"] = $sValue;
202  }
203  }
204 
205  if ( $aSelectListParams ) {
206  foreach ( $aSelectListParams as $iKey => $sValue ) {
207  $aParams["sel[$iKey]"] = $sValue;
208  }
209  }
210  return $aParams;
211  }
212 
213 
221  protected function _processProduct( $oProduct )
222  {
223  $oProduct->setLinkType( $this->getLinkType() );
224  if ( $sAddParams = $this->_getAddUrlParams() ) {
225  $oProduct->appendLink( $sAddParams );
226  }
227  }
228 
234  public function getViewId()
235  {
236  if ( isset( $this->_sViewId )) {
237  return $this->_sViewId;
238  }
239 
240  $sViewId = parent::getViewId().'|'.$this->getConfig()->getRequestParameter( 'anid' ).'|';
241 
242 
243  return $this->_sViewId = $sViewId;
244  }
245 
246 
258  public function render()
259  {
260  $myConfig = $this->getConfig();
261 
262  $oProduct = $this->getProduct();
263 
264  // assign template name
265  if ( $oProduct->oxarticles__oxtemplate->value ) {
266  $this->_sThisTemplate = $oProduct->oxarticles__oxtemplate->value;
267  }
268 
269  if ( ( $sTplName = oxConfig::getParameter( 'tpl' ) ) ) {
270  $this->_sThisTemplate = 'custom/'.basename ( $sTplName );
271  }
272 
273  parent::render();
274 
275  $sPartial = $this->getConfig()->getRequestParameter( 'renderPartial' );
276  $this->addTplParam('renderPartial', $sPartial);
277 
278  switch ($sPartial) {
279  case "productInfo":
280  return 'page/details/ajax/fullproductinfo.tpl';
281  break;
282  case "detailsMain":
283  return 'page/details/ajax/productmain.tpl';
284  break;
285  default:
286  // can not be removed, as it is used for breadcrumb loading
287  $oLocator = oxNew( 'oxLocator', $this->getListType() );
288  $oLocator->setLocatorData( $oProduct, $this );
289 
290  if ($myConfig->getConfigParam( 'bl_rssRecommLists' ) && $this->getSimilarRecommListIds()) {
291  $oRss = oxNew('oxRssFeed');
292  $this->addRssFeed($oRss->getRecommListsTitle( $oProduct ), $oRss->getRecommListsUrl( $oProduct ), 'recommlists');
293  }
294 
295  return $this->_sThisTemplate;
296  }
297  }
298 
310  protected function _prepareMetaDescription( $sMeta, $iLength = 200, $blDescTag = false )
311  {
312  if ( !$sMeta ) {
313  $oProduct = $this->getProduct();
314 
315  if ( $this->getConfig()->getConfigParam( 'bl_perfParseLongDescinSmarty' ) ) {
316  $sMeta = $oProduct->getLongDesc();
317  } else {
318  $sMeta = $oProduct->getLongDescription()->value;
319  }
320  if ( $sMeta == '' ) {
321  $sMeta = $oProduct->oxarticles__oxshortdesc->value;
322  }
323  $sMeta = $oProduct->oxarticles__oxtitle->value.' - '.$sMeta;
324  }
325  return parent::_prepareMetaDescription( $sMeta, $iLength, $blDescTag );
326  }
327 
338  protected function _prepareMetaKeyword( $sKeywords, $blRemoveDuplicatedWords = true )
339  {
340  if ( !$sKeywords ) {
341  $oProduct = $this->getProduct();
342  $sKeywords = trim( $this->getTitle() );
343 
344  if ( $oCatTree = $this->getCategoryTree() ) {
345  foreach ( $oCatTree->getPath() as $oCat ) {
346  $sKeywords .= ", " . trim( $oCat->oxcategories__oxtitle->value );
347  }
348  }
349 
350  //adding search keys info
351  if ( $sSearchKeys = trim( $oProduct->oxarticles__oxsearchkeys->value ) ) {
352  $sKeywords .= ", ". $sSearchKeys;
353  }
354 
355  $sKeywords = parent::_prepareMetaKeyword( $sKeywords, $blRemoveDuplicatedWords );
356  }
357 
358  return $sKeywords;
359  }
360 
366  public function saveReview()
367  {
368  if (!oxRegistry::getSession()->checkSessionChallenge()) {
369  return;
370  }
371 
372  if ( $this->canAcceptFormData() &&
373  ( $oUser = $this->getUser() ) && ( $oProduct = $this->getProduct() ) ) {
374 
375  $dRating = $this->getConfig()->getRequestParameter( 'artrating' );
376  if ( $dRating !== null ) {
377  $dRating = (int) $dRating;
378  }
379 
380  //save rating
381  if ( $dRating !== null && $dRating >= 1 && $dRating <= 5 ) {
382  $oRating = oxNew( 'oxrating' );
383  if ( $oRating->allowRating( $oUser->getId(), 'oxarticle', $oProduct->getId() ) ) {
384  $oRating->oxratings__oxuserid = new oxField( $oUser->getId() );
385  $oRating->oxratings__oxtype = new oxField( 'oxarticle' );
386  $oRating->oxratings__oxobjectid = new oxField( $oProduct->getId() );
387  $oRating->oxratings__oxrating = new oxField( $dRating );
388  $oRating->save();
389  $oProduct->addToRatingAverage( $dRating );
390  }
391  }
392 
393  if ( ( $sReviewText = trim( ( string ) $this->getConfig()->getRequestParameter( 'rvw_txt', true ) ) ) ) {
394  $oReview = oxNew( 'oxReview' );
395  $oReview->oxreviews__oxobjectid = new oxField( $oProduct->getId() );
396  $oReview->oxreviews__oxtype = new oxField( 'oxarticle' );
397  $oReview->oxreviews__oxtext = new oxField( $sReviewText, oxField::T_RAW );
398  $oReview->oxreviews__oxlang = new oxField( oxRegistry::getLang()->getBaseLanguage() );
399  $oReview->oxreviews__oxuserid = new oxField( $oUser->getId() );
400  $oReview->oxreviews__oxrating = new oxField( ( $dRating !== null ) ? $dRating : 0);
401  $oReview->save();
402  }
403  }
404  }
405 
411  public function addToRecomm()
412  {
413  if (!oxRegistry::getSession()->checkSessionChallenge()) {
414  return;
415  }
416 
417  if (!$this->getViewConfig()->getShowListmania()) {
418  return;
419  }
420 
421  $sRecommText = trim( ( string ) $this->getConfig()->getRequestParameter( 'recomm_txt' ) );
422  $sRecommList = $this->getConfig()->getRequestParameter( 'recomm' );
423  $sArtId = $this->getProduct()->getId();
424 
425  if ( $sArtId ) {
426  $oRecomm = oxNew( 'oxrecommlist' );
427  $oRecomm->load( $sRecommList);
428  $oRecomm->addArticle( $sArtId, $sRecommText );
429  }
430  }
431 
437  public function addTags()
438  {
439  if (!oxRegistry::getSession()->checkSessionChallenge()) {
440  return;
441  }
442 
443  $sTags = $this->getConfig()->getRequestParameter('newTags', true );
444  $sHighTag = $this->getConfig()->getRequestParameter( 'highTags', true );
445  if ( !$sTags && !$sHighTag) {
446  return;
447  }
448  if ( $sHighTag ) {
449  $sTags = getStr()->html_entity_decode( $sHighTag );
450  }
451  $oProduct = $this->getProduct();
452 
453  // set current user added tags for this article for later checking
454  $aTaggedProducts = oxRegistry::getSession()->getVariable("aTaggedProducts");
455  $aAddedTags = $aTaggedProducts? $aTaggedProducts[$oProduct->getId()] : array();
456 
457  $oArticleTagList = oxNew( "oxArticleTagList" );
458  $oArticleTagList->load( $oProduct->getId() );
459  $sSeparator = $oArticleTagList->get()->getSeparator();
460  $aTags = array_unique( explode( $sSeparator, $sTags ) );
461 
462  $aResult = $this->_addTagsToList( $oArticleTagList, $aTags, $aAddedTags);
463 
464  if ( !empty( $aResult['tags'] ) ) {
465  $oArticleTagList->save();
466  foreach ( $aResult['tags'] as $sTag) {
467  $aAddedTags[ $sTag ] = 1;
468  }
469  $aTaggedProducts[$oProduct->getId()] = $aAddedTags;
470  oxRegistry::getSession()->setVariable( 'aTaggedProducts', $aTaggedProducts);
471  }
472  // for ajax call
473  if ( $this->getConfig()->getRequestParameter( 'blAjax', true ) ) {
474  oxRegistry::getUtils()->showMessageAndExit( json_encode( $aResult ) );
475  }
476  }
477 
487  protected function _addTagsToList( $oArticleTagList, $aTags, $aAddedTags)
488  {
489  $aResult = array( 'tags' => array(), 'invalid' => array(), 'inlist' => array() );
490 
491  foreach ( $aTags as $sTag ) {
492  $oTag = oxNew( "oxtag", $sTag );
493  if ( $aAddedTags[$oTag->get()] != 1 ) {
494  if ( $oTag->isValid() ) {
495  $oArticleTagList->addTag( $oTag );
496  $aResult['tags'][] = $oTag->get();
497  } else {
498  $aResult['invalid'][] = $oTag->get();
499  }
500  } else {
501  $aResult['inlist'][] = $oTag->get();
502  }
503  }
504 
505  return $aResult;
506  }
507 
513  public function editTags()
514  {
515  if ( !$this->getUser() ) {
516  return;
517  }
518  $oArticleTagList = oxNew("oxArticleTagList");
519  $oArticleTagList->load( $this->getProduct()->getId() );
520  $oTagSet = $oArticleTagList->get();
521  $this->_aTags = $oTagSet->get();
522  $this->_blEditTags = true;
523 
524  // for ajax call
525  if ( $this->getConfig()->getRequestParameter( 'blAjax', true ) ) {
526  oxRegistry::getUtils()->setHeader( "Content-Type: text/html; charset=".oxRegistry::getLang()->translateString( 'charset' ) );
527  $oActView = oxNew( 'oxubase' );
528  $oSmarty = oxRegistry::get("oxUtilsView")->getSmarty();
529  $oSmarty->assign('oView', $this );
530  $oSmarty->assign('oViewConf', $this->getViewConfig() );
531  oxRegistry::getUtils()->showMessageAndExit( $oSmarty->fetch( 'page/details/inc/editTags.tpl', $this->getViewId() ) );
532  }
533  }
534 
540  public function cancelTags()
541  {
542  $oArticleTagList = oxNew("oxArticleTagList");
543  $oArticleTagList->load( $this->getProduct()->getId() );
544  $oTagSet = $oArticleTagList->get();
545  $this->_aTags = $oTagSet->get();
546  $this->_blEditTags = false;
547 
548  // for ajax call
549  if ( oxConfig::getParameter( 'blAjax', true ) ) {
550  oxRegistry::getUtils()->setHeader( "Content-Type: text/html; charset=".oxRegistry::getLang()->translateString( 'charset' ) );
551  $oActView = oxNew( 'oxubase' );
552  $oSmarty = oxRegistry::get("oxUtilsView")->getSmarty();
553  $oSmarty->assign('oView', $this );
554  $oSmarty->assign('oViewConf', $this->getViewConfig() );
555  oxRegistry::getUtils()->showMessageAndExit( $oSmarty->fetch( 'page/details/inc/tags.tpl', $this->getViewId() ) );
556  }
557  }
558 
564  protected function _getSeoObjectId()
565  {
566  if ( $oProduct = $this->getProduct() ) {
567  return $oProduct->getId();
568  }
569  }
570 
576  public function getEditTags()
577  {
578  return $this->_blEditTags;
579  }
580 
586  public function getTags()
587  {
588  return $this->_aTags;
589  }
590 
596  public function getProduct()
597  {
598  $myConfig = $this->getConfig();
599  $myUtils = oxRegistry::getUtils();
600 
601  if ( $this->_oProduct === null ) {
602 
603  //this option is only for lists and we must reset value
604  //as blLoadVariants = false affect "ab price" functionality
605  $myConfig->setConfigParam( 'blLoadVariants', true );
606 
607  $sOxid = $this->getConfig()->getRequestParameter( 'anid' );
608 
609  // object is not yet loaded
610  $this->_oProduct = oxNew( 'oxarticle' );
611 
612  if ( !$this->_oProduct->load( $sOxid ) ) {
613  $myUtils->redirect( $myConfig->getShopHomeURL() );
614  $myUtils->showMessageAndExit( '' );
615  }
616 
617  $aVariantSelections = $this->_oProduct->getVariantSelections( $this->getConfig()->getRequestParameter( "varselid" ) );
618  if ($aVariantSelections && $aVariantSelections['oActiveVariant'] && $aVariantSelections['blPerfectFit']) {
619  $this->_oProduct = $aVariantSelections['oActiveVariant'];
620  }
621  }
622 
623  // additional checks
624  if ( !$this->_blIsInitialized ) {
625 
626  $blContinue = true;
627  if ( !$this->_oProduct->isVisible() ) {
628  $blContinue = false;
629  } elseif ( $this->_oProduct->oxarticles__oxparentid->value ) {
630  $oParent = $this->_getParentProduct( $this->_oProduct->oxarticles__oxparentid->value );
631  if ( !$oParent || !$oParent->isVisible() ) {
632  $blContinue = false;
633  }
634  }
635 
636  if ( !$blContinue ) {
637  $myUtils->redirect( $myConfig->getShopHomeURL() );
638  $myUtils->showMessageAndExit( '' );
639  }
640 
641  $this->_processProduct( $this->_oProduct );
642  $this->_blIsInitialized = true;
643  }
644 
645  return $this->_oProduct;
646  }
647 
653  public function getLinkType()
654  {
655  if ( $this->_iLinkType === null ) {
656  $sListType = $this->getConfig()->getRequestParameter( 'listtype' );
657  if ( 'vendor' == $sListType ) {
658  $this->_iLinkType = OXARTICLE_LINKTYPE_VENDOR;
659  } elseif ( 'manufacturer' == $sListType ) {
660  $this->_iLinkType = OXARTICLE_LINKTYPE_MANUFACTURER;
661  } elseif ( 'tag' == $sListType ) {
662  $this->_iLinkType = OXARTICLE_LINKTYPE_TAG;
663  } elseif ( 'recommlist' == $sListType ) {
664  $this->_iLinkType = OXARTICLE_LINKTYPE_RECOMM;
665  } else {
666  $this->_iLinkType = OXARTICLE_LINKTYPE_CATEGORY;
667 
668  // price category has own type..
669  if ( ( $oCat = $this->getActiveCategory() ) && $oCat->isPriceCategory() ) {
670  $this->_iLinkType = OXARTICLE_LINKTYPE_PRICECATEGORY;
671  }
672  }
673  }
674 
675  return $this->_iLinkType;
676  }
677 
683  public function drawParentUrl()
684  {
685  return $this->getProduct()->isVariant();
686  }
687 
695  public function getParentName()
696  {
697  if ( $this->_sParentName === null ) {
698  $this->_sParentName = false;
699  if ( ( $oParent = $this->_getParentProduct( $this->getProduct()->oxarticles__oxparentid->value ) ) ) {
700  $this->_sParentName = $oParent->oxarticles__oxtitle->value;
701  }
702  }
703  return $this->_sParentName;
704  }
705 
713  public function getParentUrl()
714  {
715  if ( $this->_sParentUrl === null ) {
716  $this->_sParentUrl = false;
717  if ( ( $oParent = $this->_getParentProduct( $this->getProduct()->oxarticles__oxparentid->value ) ) ) {
718  $this->_sParentUrl = $oParent->getLink();
719  }
720  }
721  return $this->_sParentUrl;
722  }
723 
729  public function getPictureGallery()
730  {
731  if ( $this->_aPicGallery === null ) {
732  //get picture gallery
733  $this->_aPicGallery = $this->getPicturesProduct()->getPictureGallery();
734  }
735  return $this->_aPicGallery;
736  }
737 
743  public function getActPictureId()
744  {
745  $aPicGallery = $this->getPictureGallery();
746  return $aPicGallery['ActPicID'];
747  }
748 
754  public function getActPicture()
755  {
756  $aPicGallery = $this->getPictureGallery();
757  return $aPicGallery['ActPic'];
758  }
759 
765  public function getPictures()
766  {
767  $aPicGallery = $this->getPictureGallery();
768  return $aPicGallery['Pics'];
769  }
770 
778  public function getArtPic( $sPicNr )
779  {
780  $aPicGallery = $this->getPictureGallery();
781  return $aPicGallery['Pics'][$sPicNr];
782  }
783 
789  public function getSelectLists()
790  {
791  if ( $this->_aSelectLists === null ) {
792  $this->_aSelectLists = false;
793  if ( $this->getConfig()->getConfigParam( 'bl_perfLoadSelectLists' ) ) {
794  $this->_aSelectLists = $this->getProduct()->getSelectLists();
795  }
796  }
797  return $this->_aSelectLists;
798  }
799 
805  public function getReviews()
806  {
807  if ( $this->_aReviews === null ) {
808  $this->_aReviews = false;
809  if ( $this->getConfig()->getConfigParam( 'bl_perfLoadReviews' ) ) {
810  $this->_aReviews = $this->getProduct()->getReviews();
811  }
812  }
813  return $this->_aReviews;
814  }
815 
821  public function getCrossSelling()
822  {
823  if ( $this->_oCrossSelling === null ) {
824  $this->_oCrossSelling = false;
825  if ( $oProduct = $this->getProduct() ) {
826  $this->_oCrossSelling = $oProduct->getCrossSelling();
827  }
828  }
829  return $this->_oCrossSelling;
830  }
831 
837  public function getSimilarProducts()
838  {
839  if ( $this->_oSimilarProducts === null ) {
840  $this->_oSimilarProducts = false;
841  if ( $oProduct = $this->getProduct() ) {
842  $this->_oSimilarProducts = $oProduct->getSimilarProducts();
843  }
844  }
846  }
847 
853  public function getSimilarRecommListIds()
854  {
855  if ( $this->_aSimilarRecommListIds === null ) {
856  $this->_aSimilarRecommListIds = false;
857 
858  if ( $oProduct = $this->getProduct() ) {
859  $this->_aSimilarRecommListIds = array( $oProduct->getId() );
860  }
861  }
863  }
864 
870  public function getAccessoires()
871  {
872  if ( $this->_oAccessoires === null ) {
873  $this->_oAccessoires = false;
874  if ( $oProduct = $this->getProduct() ) {
875  $this->_oAccessoires = $oProduct->getAccessoires();
876  }
877  }
878  return $this->_oAccessoires;
879  }
880 
886  public function getAlsoBoughtTheseProducts()
887  {
888  if ( $this->_aAlsoBoughtArts === null ) {
889  $this->_aAlsoBoughtArts = false;
890  if ( $oProduct = $this->getProduct() ) {
891  $this->_aAlsoBoughtArts = $oProduct->getCustomerAlsoBoughtThisProducts();
892  }
893  }
895  }
896 
902  public function isPriceAlarm()
903  {
904  // #419 disabling price alarm if article has fixed price
905  $oProduct = $this->getProduct();
906  if ( isset( $oProduct->oxarticles__oxblfixedprice->value ) && $oProduct->oxarticles__oxblfixedprice->value ) {
907  return 0;
908  }
909  return 1;
910  }
911 
920  protected function _getSubject( $iLang )
921  {
922  return $this->getProduct();
923  }
924 
930  public function getSearchTitle()
931  {
932  return $this->_sSearchTitle;
933  }
934 
942  public function setSearchTitle( $sTitle )
943  {
944  $this->_sSearchTitle = $sTitle;
945  }
946 
954  public function setCatTreePath( $sActCatPath )
955  {
956  $this->_sCatTreePath = $sActCatPath;
957  }
958 
965  public function noIndex()
966  {
967  $sListType = $this->getConfig()->getRequestParameter( 'listtype' );
968  if ( $sListType && ( 'vendor' == $sListType || 'manufacturer' == $sListType ) ) {
969  return $this->_iViewIndexState = VIEW_INDEXSTATE_NOINDEXFOLLOW;
970  }
971  return parent::noIndex();
972  }
973 
979  public function getTitle()
980  {
981  if ( $oProduct = $this->getProduct() ) {
982  $sTag = $this->getTag();
983  return $oProduct->oxarticles__oxtitle->value . ( $oProduct->oxarticles__oxvarselect->value ? ' ' . $oProduct->oxarticles__oxvarselect->value : '' ) . (!empty($sTag) ? ' - '.$sTag : '');
984  }
985  }
986 
992  public function getMetaDescription()
993  {
994  $sMeta = parent::getMetaDescription();
995 
996  if($sTag = $this->getTag()) {
997  $sMeta = $sTag.' - ' . $sMeta;
998  }
999 
1000  return $sMeta;
1001  }
1002 
1008  public function getTag()
1009  {
1010  return oxConfig::getParameter("searchtag");
1011  }
1012 
1018  public function getCanonicalUrl()
1019  {
1020  if ( ( $oProduct = $this->getProduct() ) ) {
1021  if ( $oProduct->oxarticles__oxparentid->value ) {
1022  $oProduct = $this->_getParentProduct( $oProduct->oxarticles__oxparentid->value );
1023  }
1024 
1025  $oUtils = oxRegistry::get("oxUtilsUrl");
1026  if ( oxRegistry::getUtils()->seoIsActive() ) {
1027  $sUrl = $oUtils->prepareCanonicalUrl( $oProduct->getBaseSeoLink( $oProduct->getLanguage(), true ) );
1028  } else {
1029  $sUrl = $oUtils->prepareCanonicalUrl( $oProduct->getBaseStdLink( $oProduct->getLanguage() ) );
1030  }
1031  return $sUrl;
1032  }
1033  }
1034 
1040  public function getBreadCrumb()
1041  {
1042  if ( 'search' == $this->getListType() ) {
1043  $aPaths = $this->_getSearchBreadCrumb();
1044  } elseif ( 'tag' == $this->getListType() ) {
1045  $aPaths = $this->_getTagBreadCrumb();
1046  } elseif ( 'recommlist' == $this->getListType() ) {
1047  $aPaths = $this->_getRecommendationListBredCrumb();
1048  } elseif ( 'vendor' == $this->getListType() ) {
1049  $aPaths = $this->_getVendorBreadCrumb();
1050  } else {
1051  $aPaths = $this->_getCategoryBreadCrumb();
1052  }
1053  return $aPaths;
1054  }
1055 
1061  public function getCaptcha()
1062  {
1063  if ( $this->_oCaptcha === null ) {
1064  $this->_oCaptcha = oxNew('oxCaptcha');
1065  }
1066  return $this->_oCaptcha;
1067  }
1068 
1078  public function addme()
1079  {
1080  $myConfig = $this->getConfig();
1081  $myUtils = oxRegistry::getUtils();
1082 
1083  //control captcha
1084  $sMac = $this->getConfig()->getRequestParameter( 'c_mac' );
1085  $sMacHash = $this->getConfig()->getRequestParameter( 'c_mach' );
1086  $oCaptcha = $this->getCaptcha();
1087  if ( !$oCaptcha->pass( $sMac, $sMacHash ) ) {
1088  $this->_iPriceAlarmStatus = 2;
1089  return;
1090  }
1091 
1092  $aParams = $this->getConfig()->getRequestParameter( 'pa' );
1093  if ( !isset( $aParams['email'] ) || !$myUtils->isValidEmail( $aParams['email'] ) ) {
1094  $this->_iPriceAlarmStatus = 0;
1095  return;
1096  }
1097  $aParams['aid'] = $this->getProduct()->getId();
1098  $oCur = $myConfig->getActShopCurrencyObject();
1099  // convert currency to default
1100  $dPrice = $myUtils->currency2Float( $aParams['price'] );
1101 
1102  $oAlarm = oxNew( "oxPriceAlarm" );
1103  $oAlarm->oxpricealarm__oxuserid = new oxField( oxSession::getVar( 'usr' ));
1104  $oAlarm->oxpricealarm__oxemail = new oxField( $aParams['email']);
1105  $oAlarm->oxpricealarm__oxartid = new oxField( $aParams['aid']);
1106  $oAlarm->oxpricealarm__oxprice = new oxField( $myUtils->fRound( $dPrice, $oCur ));
1107  $oAlarm->oxpricealarm__oxshopid = new oxField( $myConfig->getShopId());
1108  $oAlarm->oxpricealarm__oxcurrency = new oxField( $oCur->name);
1109 
1110  $oAlarm->oxpricealarm__oxlang = new oxField(oxRegistry::getLang()->getBaseLanguage());
1111 
1112  $oAlarm->save();
1113 
1114  // Send Email
1115  $oEmail = oxNew( 'oxEmail' );
1116  $this->_iPriceAlarmStatus = (int) $oEmail->sendPricealarmNotification( $aParams, $oAlarm );
1117  }
1118 
1124  public function getPriceAlarmStatus()
1125  {
1127  }
1128 
1134  public function getBidPrice()
1135  {
1136  if ( $this->_sBidPrice === null ) {
1137  $this->_sBidPrice = false;
1138 
1139  $aParams = $this->getConfig()->getRequestParameter( 'pa' );
1140  $oCur = $this->getConfig()->getActShopCurrencyObject();
1141  $iPrice = oxRegistry::getUtils()->currency2Float( $aParams['price'] );
1142  $this->_sBidPrice = oxRegistry::getLang()->formatCurrency( $iPrice, $oCur );
1143  }
1144  return $this->_sBidPrice;
1145  }
1146 
1152  public function getVariantSelections()
1153  {
1154  // finding parent
1155  $oProduct = $this->getProduct();
1156  if ( ( $oParent = $this->_getParentProduct( $oProduct->oxarticles__oxparentid->value ) ) ) {
1157  return $oParent->getVariantSelections( $this->getConfig()->getRequestParameter( "varselid" ), $oProduct->getId() );
1158  }
1159 
1160  return $oProduct->getVariantSelections( $this->getConfig()->getRequestParameter( "varselid" ) );
1161  }
1162 
1168  public function getPicturesProduct()
1169  {
1170  $aVariantSelections = $this->getVariantSelections();
1171  if ($aVariantSelections && $aVariantSelections['oActiveVariant'] && !$aVariantSelections['blPerfectFit']) {
1172  return $aVariantSelections['oActiveVariant'];
1173  }
1174  return $this->getProduct();
1175  }
1176 
1182  public function getSearchParamForHtml()
1183  {
1184  if ( $this->_sSearchParamForHtml === null ) {
1185  $this->_sSearchParamForHtml = $this->getConfig()->getRequestParameter( 'searchparam' );
1186  }
1188  }
1189 
1195  public function showRdfa()
1196  {
1197  return $this->getConfig()->getConfigParam( 'blRDFaEmbedding' );
1198  }
1199 
1205  public function getRDFaNormalizedRating()
1206  {
1207  $myConfig = $this->getConfig();
1208  $iMin = $myConfig->getConfigParam("iRDFaMinRating");
1209  $iMax = $myConfig->getConfigParam("iRDFaMaxRating");
1210 
1211  $oProduct = $this->getProduct();
1212  $iCount = $oProduct->oxarticles__oxratingcnt->value;
1213  if ( isset($iMin) && isset($iMax) && $iMax != '' && $iMin != '' && $iCount > 0 ) {
1214  $aNormalizedRating = array();
1215  $iValue = ((4*($oProduct->oxarticles__oxrating->value - $iMin)/($iMax - $iMin)))+1;
1216  $aNormalizedRating["count"] = $iCount;
1217  $aNormalizedRating["value"] = round($iValue, 2);
1218  return $aNormalizedRating;
1219  }
1220  return false;
1221  }
1222 
1230  public function getRDFaValidityPeriod($sShopConfVar)
1231  {
1232  if ( $sShopConfVar ) {
1233  $aValidity = array();
1234  $iDays = $this->getConfig()->getConfigParam($sShopConfVar);
1235  $iFrom = oxRegistry::get("oxUtilsDate")->getTime();
1236 
1237  $iThrough = $iFrom + ($iDays * 24 * 60 * 60);
1238  $aValidity["from"] = date('Y-m-d\TH:i:s', $iFrom)."Z";
1239  $aValidity["through"] = date('Y-m-d\TH:i:s', $iThrough)."Z";
1240 
1241  return $aValidity;
1242  }
1243  return false;
1244  }
1245 
1251  public function getRDFaBusinessFnc()
1252  {
1253  return $this->getConfig()->getConfigParam("sRDFaBusinessFnc");
1254  }
1255 
1261  public function getRDFaCustomers()
1262  {
1263  return $this->getConfig()->getConfigParam("aRDFaCustomers");
1264  }
1265 
1271  public function getRDFaVAT()
1272  {
1273  return $this->getConfig()->getConfigParam("iRDFaVAT");
1274  }
1275 
1281  public function getRDFaGenericCondition()
1282  {
1283  return $this->getConfig()->getConfigParam("iRDFaCondition");
1284  }
1285 
1291  public function getBundleArticle()
1292  {
1293  $oProduct = $this->getProduct();
1294  if ( $oProduct && $oProduct->oxarticles__oxbundleid->value ) {
1295  $oArticle = oxNew("oxArticle");
1296  $oArticle->load($oProduct->oxarticles__oxbundleid->value);
1297  return $oArticle;
1298  }
1299  return false;
1300  }
1301 
1307  public function getRDFaPaymentMethods()
1308  {
1309  $iPrice = $this->getProduct()->getPrice()->getBruttoPrice();
1310  $oPayments = oxNew("oxPaymentList");
1311  $oPayments->loadRDFaPaymentList($iPrice);
1312  return $oPayments;
1313  }
1314 
1320  public function getRDFaDeliverySetMethods()
1321  {
1322  $oDelSets = oxNew("oxDeliverySetList");
1323  $oDelSets->loadRDFaDeliverySetList();
1324  return $oDelSets;
1325  }
1326 
1332  public function getProductsDeliveryList()
1333  {
1334  $oProduct = $this->getProduct();
1335  $oDelList = oxNew( "oxDeliveryList" );
1336  $oDelList->loadDeliveryListForProduct( $oProduct );
1337  return $oDelList;
1338  }
1339 
1346  {
1347  return $this->getConfig()->getConfigParam("sRDFaDeliveryChargeSpecLoc");
1348  }
1349 
1356  {
1357  return $this->getConfig()->getConfigParam("sRDFaPaymentChargeSpecLoc");
1358  }
1359 
1365  public function getRDFaBusinessEntityLoc()
1366  {
1367  return $this->getConfig()->getConfigParam("sRDFaBusinessEntityLoc");
1368  }
1369 
1375  public function showRDFaProductStock()
1376  {
1377  return $this->getConfig()->getConfigParam("blShowRDFaProductStock");
1378  }
1379 
1385  public function canChangeTags()
1386  {
1387  if ( $oUser = $this->getUser() ) {
1388 
1389  return true;
1390  }
1391  return false;
1392  }
1393 
1399  public function getTagCloudManager()
1400  {
1401  $oManager = oxNew( "oxTagCloud" );
1402  $oManager->setExtendedMode( true );
1403  $oManager->setProductId( $this->getProduct()->getId() );
1404  return $oManager;
1405  }
1406 
1412  public function showZoomPics()
1413  {
1414  $aPicGallery = $this->getPictureGallery();
1415  return $aPicGallery['ZoomPic'];
1416  }
1417 
1423  public function isReviewActive()
1424  {
1425  return $this->getConfig()->getConfigParam( 'bl_perfLoadReviews' );
1426  }
1427 
1433  public function getDefaultSorting()
1434  {
1435  $aSorting = parent::getDefaultSorting();
1436  $oCategory = $this->getActiveCategory();
1437 
1438  if ( $this->getListType() != 'search' && $oCategory && $oCategory instanceof oxCategory ) {
1439  if ( $sSortBy = $oCategory->getDefaultSorting() ) {
1440  $sSortDir = ( $oCategory->getDefaultSortingMode() ) ? "desc" : "asc";
1441  $aSorting = array ( 'sortby' => $sSortBy, 'sortdir' => $sSortDir );
1442  }
1443  }
1444 
1445  return $aSorting;
1446  }
1447 
1453  public function getSortingParameters()
1454  {
1455  $aSorting = $this->getSorting( $this->getSortIdent() );
1456  if ( !is_array( $aSorting ) ) {
1457  return null;
1458  }
1459  return implode( '|', $aSorting);
1460  }
1461 
1467  protected function _getVendorBreadCrumb()
1468  {
1469  $aPaths = array();
1470  $aCatPath = array();
1471 
1472  $oCat = oxNew( 'oxVendor' );
1473  $oCat->load( 'root' );
1474 
1475  $aCatPath['link'] = $oCat->getLink();
1476  $aCatPath['title'] = $oCat->oxvendor__oxtitle->value;
1477  $aPaths[] = $aCatPath;
1478 
1479  if (is_a($oCat, 'oxVendor')) {
1480  $aCatPath['link'] = $oCat->getLink();
1481  $aCatPath['title'] = $oCat->oxvendor__oxtitle->value;
1482  $aPaths[] = $aCatPath;
1483  }
1484 
1485  return $aPaths;
1486  }
1487 
1493  protected function _getRecommendationListBredCrumb()
1494  {
1495  $aPaths = array();
1496  $aCatPath = array();
1497  $aCatPath['title'] = oxRegistry::getLang()->translateString( 'LISTMANIA', oxRegistry::getLang()->getBaseLanguage(), false );
1498  $aPaths[] = $aCatPath;
1499  return $aPaths;
1500  }
1501 
1507  protected function _getTagBreadCrumb()
1508  {
1509  $aPaths = array();
1510 
1511  $aCatPath = array();
1512 
1513  $aCatPath['title'] = oxRegistry::getLang()->translateString( 'TAGS', oxRegistry::getLang()->getBaseLanguage(), false );
1514  $aCatPath['link'] = oxRegistry::get( "oxSeoEncoder" )->getStaticUrl( $this->getViewConfig()->getSelfLink() . 'cl=tags' );
1515  $aPaths[] = $aCatPath;
1516 
1517  $oStr = getStr();
1518  $aCatPath['title'] = $oStr->ucfirst( oxRegistry::getConfig()->getRequestParameter( 'searchtag' ) );
1519  $aCatPath['link'] = oxRegistry::get( "oxSeoEncoderTag" )->getTagUrl( oxRegistry::getConfig()->getRequestParameter( 'searchtag' ) );
1520  $aPaths[] = $aCatPath;
1521  return $aPaths;
1522  }
1523 
1529  protected function _getSearchBreadCrumb()
1530  {
1531  $aPaths = array();
1532  $aCatPath = array();
1533 
1534  $aCatPath['title'] = sprintf( oxRegistry::getLang()->translateString( 'SEARCH_RESULT', oxRegistry::getLang()->getBaseLanguage(), false ), $this->getSearchParamForHtml());
1535  $aCatPath['link'] = $this->getViewConfig()->getSelfLink() . 'stoken=' . oxRegistry::getSession()->getVariable( 'sess_stoken' ) . "&amp;cl=search&amp;searchparam=" . $this->getSearchParamForHtml();
1536 
1537  $aPaths[] = $aCatPath;
1538 
1539  return $aPaths;
1540  }
1541 
1547  protected function _getCategoryBreadCrumb()
1548  {
1549  $aPaths = array();
1550 
1551  $oCatTree = $this->getCatTreePath();
1552 
1553  if ( $oCatTree ) {
1554 
1555  foreach ( $oCatTree as $oCat ) {
1556  $aCatPath = array();
1557 
1558  $aCatPath['link'] = $oCat->getLink();
1559  $aCatPath['title'] = $oCat->oxcategories__oxtitle->value;
1560 
1561  $aPaths[] = $aCatPath;
1562  }
1563  return $aPaths;
1564  }
1565  return $aPaths;
1566  }
1567 }