OXID eShop CE  4.9.7
 All Classes Files Functions Variables Pages
details.php
Go to the documentation of this file.
1 <?php
2 
9 class Details extends oxUBase
10 {
11 
17  protected $_sThisTemplate = 'page/details/details.tpl';
18 
24  protected $_oParentProd = null;
25 
31  protected $_blEditTags = null;
32 
38  protected $_aTags = null;
39 
45  protected $_oCaptcha = null;
46 
52  protected $_sParentName = null;
53 
59  protected $_sParentUrl = null;
60 
66  protected $_aPicGallery = null;
67 
73  protected $_aSelectLists = null;
74 
80  protected $_aReviews = null;
81 
87  protected $_oCrossSelling = null;
88 
94  protected $_oSimilarProducts = null;
95 
101  protected $_oAccessoires = null;
102 
108  protected $_aAlsoBoughtArts = null;
109 
115  protected $_sSearchTitle = null;
116 
123  protected $_blIsInitialized = false;
124 
130  protected $_iLinkType = null;
131 
137  protected $_sBidPrice = null;
138 
144  protected $_iPriceAlarmStatus = null;
145 
151  protected $_sSearchParamForHtml = null;
152 
158  protected $_aSimilarRecommListIds = null;
159 
160 
166  protected $_blShowSorting = true;
167 
175  protected function _getParentProduct($sParentId)
176  {
177  if ($sParentId && $this->_oParentProd === null) {
178  $this->_oParentProd = false;
179  $oProduct = oxNew('oxArticle');
180  if (($oProduct->load($sParentId))) {
181  $this->_processProduct($oProduct);
182  $this->_oParentProd = $oProduct;
183  }
184  }
185 
186  return $this->_oParentProd;
187  }
188 
194  protected function _getAddUrlParams()
195  {
196  if ($this->getListType() == "search") {
197  return $this->getDynUrlParams();
198  }
199  }
200 
209  public function getNavigationParams()
210  {
211  $aParams = parent::getNavigationParams();
212 
213  $aVarSelParams = oxRegistry::getConfig()->getRequestParameter('varselid');
214  $aSelectListParams = oxRegistry::getConfig()->getRequestParameter('sel');
215  if (!$aVarSelParams && !$aSelectListParams) {
216  return $aParams;
217  }
218 
219  if ($aVarSelParams) {
220  foreach ($aVarSelParams as $iKey => $sValue) {
221  $aParams["varselid[$iKey]"] = $sValue;
222  }
223  }
224 
225  if ($aSelectListParams) {
226  foreach ($aSelectListParams as $iKey => $sValue) {
227  $aParams["sel[$iKey]"] = $sValue;
228  }
229  }
230 
231  return $aParams;
232  }
233 
234 
240  protected function _processProduct($oProduct)
241  {
242  $oProduct->setLinkType($this->getLinkType());
243  if ($sAddParams = $this->_getAddUrlParams()) {
244  $oProduct->appendLink($sAddParams);
245  }
246  }
247 
253  public function getViewId()
254  {
255  if (isset($this->_sViewId)) {
256  return $this->_sViewId;
257  }
258 
259  $sViewId = parent::getViewId() . '|' . $this->getConfig()->getRequestParameter('anid') . '|';
260 
261 
262  return $this->_sViewId = $sViewId;
263  }
264 
265 
277  public function render()
278  {
279  $myConfig = $this->getConfig();
280 
281  $oProduct = $this->getProduct();
282 
283  // assign template name
284  if ($oProduct->oxarticles__oxtemplate->value) {
285  $this->_sThisTemplate = $oProduct->oxarticles__oxtemplate->value;
286  }
287 
288  if (($sTplName = oxRegistry::getConfig()->getRequestParameter('tpl'))) {
289  $this->_sThisTemplate = 'custom/' . basename($sTplName);
290  }
291 
292  parent::render();
293 
294  $sPartial = $this->getConfig()->getRequestParameter('renderPartial');
295  $this->addTplParam('renderPartial', $sPartial);
296 
297  switch ($sPartial) {
298  case "productInfo":
299  return 'page/details/ajax/fullproductinfo.tpl';
300  break;
301  case "detailsMain":
302  return 'page/details/ajax/productmain.tpl';
303  break;
304  default:
305  // can not be removed, as it is used for breadcrumb loading
306  $oLocator = oxNew('oxLocator', $this->getListType());
307  $oLocator->setLocatorData($oProduct, $this);
308 
309  if ($myConfig->getConfigParam('bl_rssRecommLists') && $this->getSimilarRecommListIds()) {
310  $oRss = oxNew('oxRssFeed');
311  $sTitle = $oRss->getRecommListsTitle($oProduct);
312  $sUrl = $oRss->getRecommListsUrl($oProduct);
313  $this->addRssFeed($sTitle, $sUrl, 'recommlists');
314  }
315 
316  return $this->_sThisTemplate;
317  }
318  }
319 
331  protected function _prepareMetaDescription($sMeta, $iLength = 200, $blDescTag = false)
332  {
333  if (!$sMeta) {
334  $oProduct = $this->getProduct();
335 
336  if ($this->getConfig()->getConfigParam('bl_perfParseLongDescinSmarty')) {
337  $sMeta = $oProduct->getLongDesc();
338  } else {
339  $sMeta = $oProduct->getLongDescription()->value;
340  }
341  if ($sMeta == '') {
342  $sMeta = $oProduct->oxarticles__oxshortdesc->value;
343  }
344  $sMeta = $oProduct->oxarticles__oxtitle->value . ' - ' . $sMeta;
345  }
346 
347  return parent::_prepareMetaDescription($sMeta, $iLength, $blDescTag);
348  }
349 
360  protected function _prepareMetaKeyword($sKeywords, $blRemoveDuplicatedWords = true)
361  {
362  if (!$sKeywords) {
363  $oProduct = $this->getProduct();
364  $sKeywords = trim($this->getTitle());
365 
366  if ($oCatTree = $this->getCategoryTree()) {
367  foreach ($oCatTree->getPath() as $oCat) {
368  $sKeywords .= ", " . trim($oCat->oxcategories__oxtitle->value);
369  }
370  }
371 
372  //adding search keys info
373  if ($sSearchKeys = trim($oProduct->oxarticles__oxsearchkeys->value)) {
374  $sKeywords .= ", " . $sSearchKeys;
375  }
376 
377  $sKeywords = parent::_prepareMetaKeyword($sKeywords, $blRemoveDuplicatedWords);
378  }
379 
380  return $sKeywords;
381  }
382 
388  public function saveReview()
389  {
390  if (!oxRegistry::getSession()->checkSessionChallenge()) {
391  return;
392  }
393 
394  if ($this->canAcceptFormData() &&
395  ($oUser = $this->getUser()) && ($oProduct = $this->getProduct())
396  ) {
397 
398  $dRating = $this->getConfig()->getRequestParameter('artrating');
399  if ($dRating !== null) {
400  $dRating = (int) $dRating;
401  }
402 
403  //save rating
404  if ($dRating !== null && $dRating >= 1 && $dRating <= 5) {
405  $oRating = oxNew('oxrating');
406  if ($oRating->allowRating($oUser->getId(), 'oxarticle', $oProduct->getId())) {
407  $oRating->oxratings__oxuserid = new oxField($oUser->getId());
408  $oRating->oxratings__oxtype = new oxField('oxarticle');
409  $oRating->oxratings__oxobjectid = new oxField($oProduct->getId());
410  $oRating->oxratings__oxrating = new oxField($dRating);
411  $oRating->save();
412  $oProduct->addToRatingAverage($dRating);
413  }
414  }
415 
416  if (($sReviewText = trim(( string ) $this->getConfig()->getRequestParameter('rvw_txt', true)))) {
417  $oReview = oxNew('oxReview');
418  $oReview->oxreviews__oxobjectid = new oxField($oProduct->getId());
419  $oReview->oxreviews__oxtype = new oxField('oxarticle');
420  $oReview->oxreviews__oxtext = new oxField($sReviewText, oxField::T_RAW);
421  $oReview->oxreviews__oxlang = new oxField(oxRegistry::getLang()->getBaseLanguage());
422  $oReview->oxreviews__oxuserid = new oxField($oUser->getId());
423  $oReview->oxreviews__oxrating = new oxField(($dRating !== null) ? $dRating : 0);
424  $oReview->save();
425  }
426  }
427  }
428 
434  public function addToRecomm()
435  {
436  if (!oxRegistry::getSession()->checkSessionChallenge()) {
437  return;
438  }
439 
440  if (!$this->getViewConfig()->getShowListmania()) {
441  return;
442  }
443 
444  $sRecommText = trim(( string ) $this->getConfig()->getRequestParameter('recomm_txt'));
445  $sRecommList = $this->getConfig()->getRequestParameter('recomm');
446  $sArtId = $this->getProduct()->getId();
447 
448  if ($sArtId) {
449  $oRecomm = oxNew('oxrecommlist');
450  $oRecomm->load($sRecommList);
451  $oRecomm->addArticle($sArtId, $sRecommText);
452  }
453  }
454 
460  public function addTags()
461  {
462  if (!oxRegistry::getSession()->checkSessionChallenge()) {
463  return;
464  }
465 
466  $sTags = $this->getConfig()->getRequestParameter('newTags', true);
467  $sHighTag = $this->getConfig()->getRequestParameter('highTags', true);
468  if (!$sTags && !$sHighTag) {
469  return;
470  }
471  if ($sHighTag) {
472  $sTags = getStr()->html_entity_decode($sHighTag);
473  }
474  $oProduct = $this->getProduct();
475 
476  // set current user added tags for this article for later checking
477  $aTaggedProducts = oxRegistry::getSession()->getVariable("aTaggedProducts");
478  $aAddedTags = $aTaggedProducts ? $aTaggedProducts[$oProduct->getId()] : array();
479 
480  $oArticleTagList = oxNew("oxArticleTagList");
481  $oArticleTagList->load($oProduct->getId());
482  $sSeparator = $oArticleTagList->get()->getSeparator();
483  $aTags = array_unique(explode($sSeparator, $sTags));
484 
485  $aResult = $this->_addTagsToList($oArticleTagList, $aTags, $aAddedTags);
486 
487  if (!empty($aResult['tags'])) {
488  $oArticleTagList->save();
489  foreach ($aResult['tags'] as $sTag) {
490  $aAddedTags[$sTag] = 1;
491  }
492  $aTaggedProducts[$oProduct->getId()] = $aAddedTags;
493  oxRegistry::getSession()->setVariable('aTaggedProducts', $aTaggedProducts);
494  }
495  // for ajax call
496  if ($this->getConfig()->getRequestParameter('blAjax', true)) {
497  oxRegistry::getUtils()->showMessageAndExit(json_encode($aResult));
498  }
499  }
500 
510  protected function _addTagsToList($oArticleTagList, $aTags, $aAddedTags)
511  {
512  $aResult = array('tags' => array(), 'invalid' => array(), 'inlist' => array());
513 
514  foreach ($aTags as $sTag) {
515  $oTag = oxNew("oxtag", $sTag);
516  if ($aAddedTags[$oTag->get()] != 1) {
517  if ($oTag->isValid()) {
518  $oArticleTagList->addTag($oTag);
519  $aResult['tags'][] = $oTag->get();
520  } else {
521  $aResult['invalid'][] = $oTag->get();
522  }
523  } else {
524  $aResult['inlist'][] = $oTag->get();
525  }
526  }
527 
528  return $aResult;
529  }
530 
536  public function editTags()
537  {
538  if (!$this->getUser()) {
539  return;
540  }
541  $oArticleTagList = oxNew("oxArticleTagList");
542  $oArticleTagList->load($this->getProduct()->getId());
543  $oTagSet = $oArticleTagList->get();
544  $this->_aTags = $oTagSet->get();
545  $this->_blEditTags = true;
546 
547  // for ajax call
548  if ($this->getConfig()->getRequestParameter('blAjax', true)) {
549  $sCharset = oxRegistry::getLang()->translateString('charset');
550  oxRegistry::getUtils()->setHeader("Content-Type: text/html; charset=" . $sCharset);
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(
556  $oSmarty->fetch('page/details/inc/editTags.tpl', $this->getViewId())
557  );
558  }
559  }
560 
564  public function cancelTags()
565  {
566  $oArticleTagList = oxNew("oxArticleTagList");
567  $oArticleTagList->load($this->getProduct()->getId());
568  $oTagSet = $oArticleTagList->get();
569  $this->_aTags = $oTagSet->get();
570  $this->_blEditTags = false;
571 
572  // for ajax call
573  if (oxRegistry::getConfig()->getRequestParameter('blAjax', true)) {
574  $sCharset = oxRegistry::getLang()->translateString('charset');
575  oxRegistry::getUtils()->setHeader("Content-Type: text/html; charset=" . $sCharset);
576  $oActView = oxNew('oxubase');
577  $oSmarty = oxRegistry::get("oxUtilsView")->getSmarty();
578  $oSmarty->assign('oView', $this);
579  $oSmarty->assign('oViewConf', $this->getViewConfig());
580  oxRegistry::getUtils()->showMessageAndExit(
581  $oSmarty->fetch('page/details/inc/tags.tpl', $this->getViewId())
582  );
583  }
584  }
585 
591  protected function _getSeoObjectId()
592  {
593  if ($oProduct = $this->getProduct()) {
594  return $oProduct->getId();
595  }
596  }
597 
603  public function getEditTags()
604  {
605  return $this->_blEditTags;
606  }
607 
613  public function getTags()
614  {
615  return $this->_aTags;
616  }
617 
623  public function getProduct()
624  {
625  $oConfig = $this->getConfig();
626  $oUtils = oxRegistry::getUtils();
627 
628  if ($this->_oProduct === null) {
629 
630  //this option is only for lists and we must reset value
631  //as blLoadVariants = false affect "ab price" functionality
632  $oConfig->setConfigParam('blLoadVariants', true);
633 
634  $sOxid = $this->getConfig()->getRequestParameter('anid');
635 
636  // object is not yet loaded
637  $this->_oProduct = oxNew('oxarticle');
638 
639  if (!$this->_oProduct->load($sOxid)) {
640  $oUtils->redirect($oConfig->getShopHomeURL());
641  $oUtils->showMessageAndExit('');
642  }
643 
644  $sVarSelIdParameter = $this->getConfig()->getRequestParameter("varselid");
645  $aVariantSelections = $this->_oProduct->getVariantSelections($sVarSelIdParameter);
646  if ($aVariantSelections && $aVariantSelections['oActiveVariant'] && $aVariantSelections['blPerfectFit']) {
647  $this->_oProduct = $aVariantSelections['oActiveVariant'];
648  }
649  }
650 
651  // additional checks
652  if (!$this->_blIsInitialized) {
654  }
655 
656  return $this->_oProduct;
657  }
658 
662  protected function _additionalChecksForArticle()
663  {
664  $oConfig = $this->getConfig();
665  $oUtils = oxRegistry::getUtils();
666 
667  $blContinue = true;
668  if (!$this->_oProduct->isVisible()) {
669  $blContinue = false;
670  } elseif ($this->_oProduct->oxarticles__oxparentid->value) {
671  $oParent = $this->_getParentProduct($this->_oProduct->oxarticles__oxparentid->value);
672  if (!$oParent || !$oParent->isVisible()) {
673  $blContinue = false;
674  }
675  }
676 
677  if (!$blContinue) {
678  $oUtils->redirect($oConfig->getShopHomeURL());
679  $oUtils->showMessageAndExit('');
680  }
681 
682  $this->_processProduct($this->_oProduct);
683  $this->_blIsInitialized = true;
684  }
685 
691  public function getLinkType()
692  {
693  if ($this->_iLinkType === null) {
694  $sListType = $this->getConfig()->getRequestParameter('listtype');
695  if ('vendor' == $sListType) {
696  $this->_iLinkType = OXARTICLE_LINKTYPE_VENDOR;
697  } elseif ('manufacturer' == $sListType) {
698  $this->_iLinkType = OXARTICLE_LINKTYPE_MANUFACTURER;
699  } elseif ('tag' == $sListType) {
700  $this->_iLinkType = OXARTICLE_LINKTYPE_TAG;
701  } elseif ('recommlist' == $sListType) {
702  $this->_iLinkType = OXARTICLE_LINKTYPE_RECOMM;
703  } else {
704  $this->_iLinkType = OXARTICLE_LINKTYPE_CATEGORY;
705 
706  // price category has own type..
707  if (($oCat = $this->getActiveCategory()) && $oCat->isPriceCategory()) {
708  $this->_iLinkType = OXARTICLE_LINKTYPE_PRICECATEGORY;
709  }
710  }
711  }
712 
713  return $this->_iLinkType;
714  }
715 
721  public function drawParentUrl()
722  {
723  return $this->getProduct()->isVariant();
724  }
725 
733  public function getParentName()
734  {
735  if ($this->_sParentName === null) {
736  $this->_sParentName = false;
737  if (($oParent = $this->_getParentProduct($this->getProduct()->oxarticles__oxparentid->value))) {
738  $this->_sParentName = $oParent->oxarticles__oxtitle->value;
739  }
740  }
741 
742  return $this->_sParentName;
743  }
744 
752  public function getParentUrl()
753  {
754  if ($this->_sParentUrl === null) {
755  $this->_sParentUrl = false;
756  if (($oParent = $this->_getParentProduct($this->getProduct()->oxarticles__oxparentid->value))) {
757  $this->_sParentUrl = $oParent->getLink();
758  }
759  }
760 
761  return $this->_sParentUrl;
762  }
763 
769  public function getPictureGallery()
770  {
771  if ($this->_aPicGallery === null) {
772  //get picture gallery
773  $this->_aPicGallery = $this->getPicturesProduct()->getPictureGallery();
774  }
775 
776  return $this->_aPicGallery;
777  }
778 
784  public function getActPictureId()
785  {
786  $aPicGallery = $this->getPictureGallery();
787 
788  return $aPicGallery['ActPicID'];
789  }
790 
796  public function getActPicture()
797  {
798  $aPicGallery = $this->getPictureGallery();
799 
800  return $aPicGallery['ActPic'];
801  }
802 
808  public function getPictures()
809  {
810  $aPicGallery = $this->getPictureGallery();
811 
812  return $aPicGallery['Pics'];
813  }
814 
822  public function getArtPic($sPicNr)
823  {
824  $aPicGallery = $this->getPictureGallery();
825 
826  return $aPicGallery['Pics'][$sPicNr];
827  }
828 
834  public function getSelectLists()
835  {
836  if ($this->_aSelectLists === null) {
837  $this->_aSelectLists = false;
838  if ($this->getConfig()->getConfigParam('bl_perfLoadSelectLists')) {
839  $this->_aSelectLists = $this->getProduct()->getSelectLists();
840  }
841  }
842 
843  return $this->_aSelectLists;
844  }
845 
851  public function getReviews()
852  {
853  if ($this->_aReviews === null) {
854  $this->_aReviews = false;
855  if ($this->getConfig()->getConfigParam('bl_perfLoadReviews')) {
856  $this->_aReviews = $this->getProduct()->getReviews();
857  }
858  }
859 
860  return $this->_aReviews;
861  }
862 
868  public function getCrossSelling()
869  {
870  if ($this->_oCrossSelling === null) {
871  $this->_oCrossSelling = false;
872  if ($oProduct = $this->getProduct()) {
873  $this->_oCrossSelling = $oProduct->getCrossSelling();
874  }
875  }
876 
877  return $this->_oCrossSelling;
878  }
879 
885  public function getSimilarProducts()
886  {
887  if ($this->_oSimilarProducts === null) {
888  $this->_oSimilarProducts = false;
889  if ($oProduct = $this->getProduct()) {
890  $this->_oSimilarProducts = $oProduct->getSimilarProducts();
891  }
892  }
893 
895  }
896 
902  public function getSimilarRecommListIds()
903  {
904  if ($this->_aSimilarRecommListIds === null) {
905  $this->_aSimilarRecommListIds = false;
906 
907  if ($oProduct = $this->getProduct()) {
908  $this->_aSimilarRecommListIds = array($oProduct->getId());
909  }
910  }
911 
913  }
914 
920  public function getAccessoires()
921  {
922  if ($this->_oAccessoires === null) {
923  $this->_oAccessoires = false;
924  if ($oProduct = $this->getProduct()) {
925  $this->_oAccessoires = $oProduct->getAccessoires();
926  }
927  }
928 
929  return $this->_oAccessoires;
930  }
931 
937  public function getAlsoBoughtTheseProducts()
938  {
939  if ($this->_aAlsoBoughtArts === null) {
940  $this->_aAlsoBoughtArts = false;
941  if ($oProduct = $this->getProduct()) {
942  $this->_aAlsoBoughtArts = $oProduct->getCustomerAlsoBoughtThisProducts();
943  }
944  }
945 
947  }
948 
954  public function isPriceAlarm()
955  {
956  // #419 disabling price alarm if article has fixed price
957  $oProduct = $this->getProduct();
958  if (isset($oProduct->oxarticles__oxblfixedprice->value) && $oProduct->oxarticles__oxblfixedprice->value) {
959  return 0;
960  }
961 
962  return 1;
963  }
964 
973  protected function _getSubject($iLang)
974  {
975  return $this->getProduct();
976  }
977 
983  public function getSearchTitle()
984  {
985  return $this->_sSearchTitle;
986  }
987 
993  public function setSearchTitle($sTitle)
994  {
995  $this->_sSearchTitle = $sTitle;
996  }
997 
1003  public function setCatTreePath($sActCatPath)
1004  {
1005  $this->_sCatTreePath = $sActCatPath;
1006  }
1007 
1014  public function noIndex()
1015  {
1016  $sListType = $this->getConfig()->getRequestParameter('listtype');
1017  if ($sListType && ('vendor' == $sListType || 'manufacturer' == $sListType)) {
1018  return $this->_iViewIndexState = VIEW_INDEXSTATE_NOINDEXFOLLOW;
1019  }
1020 
1021  return parent::noIndex();
1022  }
1023 
1029  public function getTitle()
1030  {
1031  if ($oProduct = $this->getProduct()) {
1032  $sTag = $this->getTag();
1033  $sTitleField = 'oxarticles__oxtitle';
1034  $sVarSelField = 'oxarticles__oxvarselect';
1035 
1036  $sVarSelValue = $oProduct->$sVarSelField->value ? ' ' . $oProduct->$sVarSelField->value : '';
1037  $sTagValue = !empty($sTag) ? ' - ' . $sTag : '';
1038 
1039  return $oProduct->$sTitleField->value . $sVarSelValue . $sTagValue;
1040  }
1041  }
1042 
1048  public function getMetaDescription()
1049  {
1050  $sMeta = parent::getMetaDescription();
1051 
1052  if ($sTag = $this->getTag()) {
1053  $sMeta = $sTag . ' - ' . $sMeta;
1054  }
1055 
1056  return $sMeta;
1057  }
1058 
1064  public function getTag()
1065  {
1066  return oxRegistry::getConfig()->getRequestParameter("searchtag");
1067  }
1068 
1074  public function getCanonicalUrl()
1075  {
1076  if (($oProduct = $this->getProduct())) {
1077  if ($oProduct->oxarticles__oxparentid->value) {
1078  $oProduct = $this->_getParentProduct($oProduct->oxarticles__oxparentid->value);
1079  }
1080 
1081  $oUtils = oxRegistry::get("oxUtilsUrl");
1082  if (oxRegistry::getUtils()->seoIsActive()) {
1083  $sUrl = $oUtils->prepareCanonicalUrl($oProduct->getBaseSeoLink($oProduct->getLanguage(), true));
1084  } else {
1085  $sUrl = $oUtils->prepareCanonicalUrl($oProduct->getBaseStdLink($oProduct->getLanguage()));
1086  }
1087 
1088  return $sUrl;
1089  }
1090  }
1091 
1097  public function getBreadCrumb()
1098  {
1099  if ('search' == $this->getListType()) {
1100  $aPaths = $this->_getSearchBreadCrumb();
1101  } elseif ('tag' == $this->getListType()) {
1102  $aPaths = $this->_getTagBreadCrumb();
1103  } elseif ('recommlist' == $this->getListType()) {
1104  $aPaths = $this->_getRecommendationListBredCrumb();
1105  } elseif ('vendor' == $this->getListType()) {
1106  $aPaths = $this->_getVendorBreadCrumb();
1107  } else {
1108  $aPaths = $this->_getCategoryBreadCrumb();
1109  }
1110 
1111  return $aPaths;
1112  }
1113 
1119  public function getCaptcha()
1120  {
1121  if ($this->_oCaptcha === null) {
1122  $this->_oCaptcha = oxNew('oxCaptcha');
1123  }
1124 
1125  return $this->_oCaptcha;
1126  }
1127 
1137  public function addme()
1138  {
1139  $myConfig = $this->getConfig();
1140  $myUtils = oxRegistry::getUtils();
1141 
1142  //control captcha
1143  $sMac = $this->getConfig()->getRequestParameter('c_mac');
1144  $sMacHash = $this->getConfig()->getRequestParameter('c_mach');
1145  $oCaptcha = $this->getCaptcha();
1146  if (!$oCaptcha->pass($sMac, $sMacHash)) {
1147  $this->_iPriceAlarmStatus = 2;
1148 
1149  return;
1150  }
1151 
1152  $aParams = $this->getConfig()->getRequestParameter('pa');
1153  if (!isset($aParams['email']) || !$myUtils->isValidEmail($aParams['email'])) {
1154  $this->_iPriceAlarmStatus = 0;
1155 
1156  return;
1157  }
1158  $aParams['aid'] = $this->getProduct()->getId();
1159  $oCur = $myConfig->getActShopCurrencyObject();
1160  // convert currency to default
1161  $dPrice = $myUtils->currency2Float($aParams['price']);
1162 
1163  $oAlarm = oxNew("oxPriceAlarm");
1164  $oAlarm->oxpricealarm__oxuserid = new oxField(oxRegistry::getSession()->getVariable('usr'));
1165  $oAlarm->oxpricealarm__oxemail = new oxField($aParams['email']);
1166  $oAlarm->oxpricealarm__oxartid = new oxField($aParams['aid']);
1167  $oAlarm->oxpricealarm__oxprice = new oxField($myUtils->fRound($dPrice, $oCur));
1168  $oAlarm->oxpricealarm__oxshopid = new oxField($myConfig->getShopId());
1169  $oAlarm->oxpricealarm__oxcurrency = new oxField($oCur->name);
1170 
1171  $oAlarm->oxpricealarm__oxlang = new oxField(oxRegistry::getLang()->getBaseLanguage());
1172 
1173  $oAlarm->save();
1174 
1175  // Send Email
1176  $oEmail = oxNew('oxEmail');
1177  $this->_iPriceAlarmStatus = (int) $oEmail->sendPricealarmNotification($aParams, $oAlarm);
1178  }
1179 
1185  public function getPriceAlarmStatus()
1186  {
1188  }
1189 
1195  public function getBidPrice()
1196  {
1197  if ($this->_sBidPrice === null) {
1198  $this->_sBidPrice = false;
1199 
1200  $aParams = $this->getConfig()->getRequestParameter('pa');
1201  $oCur = $this->getConfig()->getActShopCurrencyObject();
1202  $iPrice = oxRegistry::getUtils()->currency2Float($aParams['price']);
1203  $this->_sBidPrice = oxRegistry::getLang()->formatCurrency($iPrice, $oCur);
1204  }
1205 
1206  return $this->_sBidPrice;
1207  }
1208 
1214  public function getVariantSelections()
1215  {
1216  // finding parent
1217  $oProduct = $this->getProduct();
1218  $sVarSelParameter = $this->getConfig()->getRequestParameter("varselid");
1219  $sParentIdField = 'oxarticles__oxparentid';
1220  if (($oParent = $this->_getParentProduct($oProduct->$sParentIdField->value))) {
1221  return $oParent->getVariantSelections($sVarSelParameter, $oProduct->getId());
1222  }
1223 
1224  return $oProduct->getVariantSelections($sVarSelParameter);
1225  }
1226 
1232  public function getPicturesProduct()
1233  {
1234  $aVariantSelections = $this->getVariantSelections();
1235  if ($aVariantSelections && $aVariantSelections['oActiveVariant'] && !$aVariantSelections['blPerfectFit']) {
1236  return $aVariantSelections['oActiveVariant'];
1237  }
1238 
1239  return $this->getProduct();
1240  }
1241 
1247  public function getSearchParamForHtml()
1248  {
1249  if ($this->_sSearchParamForHtml === null) {
1250  $this->_sSearchParamForHtml = $this->getConfig()->getRequestParameter('searchparam');
1251  }
1252 
1254  }
1255 
1261  public function showRdfa()
1262  {
1263  return $this->getConfig()->getConfigParam('blRDFaEmbedding');
1264  }
1265 
1271  public function getRDFaNormalizedRating()
1272  {
1273  $myConfig = $this->getConfig();
1274  $iMin = $myConfig->getConfigParam("iRDFaMinRating");
1275  $iMax = $myConfig->getConfigParam("iRDFaMaxRating");
1276 
1277  $oProduct = $this->getProduct();
1278  $iCount = $oProduct->oxarticles__oxratingcnt->value;
1279  if (isset($iMin) && isset($iMax) && $iMax != '' && $iMin != '' && $iCount > 0) {
1280  $aNormalizedRating = array();
1281  $iValue = ((4 * ($oProduct->oxarticles__oxrating->value - $iMin) / ($iMax - $iMin))) + 1;
1282  $aNormalizedRating["count"] = $iCount;
1283  $aNormalizedRating["value"] = round($iValue, 2);
1284 
1285  return $aNormalizedRating;
1286  }
1287 
1288  return false;
1289  }
1290 
1298  public function getRDFaValidityPeriod($sShopConfVar)
1299  {
1300  if ($sShopConfVar) {
1301  $aValidity = array();
1302  $iDays = $this->getConfig()->getConfigParam($sShopConfVar);
1303  $iFrom = oxRegistry::get("oxUtilsDate")->getTime();
1304 
1305  $iThrough = $iFrom + ($iDays * 24 * 60 * 60);
1306  $aValidity["from"] = date('Y-m-d\TH:i:s', $iFrom) . "Z";
1307  $aValidity["through"] = date('Y-m-d\TH:i:s', $iThrough) . "Z";
1308 
1309  return $aValidity;
1310  }
1311 
1312  return false;
1313  }
1314 
1320  public function getRDFaBusinessFnc()
1321  {
1322  return $this->getConfig()->getConfigParam("sRDFaBusinessFnc");
1323  }
1324 
1330  public function getRDFaCustomers()
1331  {
1332  return $this->getConfig()->getConfigParam("aRDFaCustomers");
1333  }
1334 
1340  public function getRDFaVAT()
1341  {
1342  return $this->getConfig()->getConfigParam("iRDFaVAT");
1343  }
1344 
1350  public function getRDFaGenericCondition()
1351  {
1352  return $this->getConfig()->getConfigParam("iRDFaCondition");
1353  }
1354 
1360  public function getBundleArticle()
1361  {
1362  $oProduct = $this->getProduct();
1363  if ($oProduct && $oProduct->oxarticles__oxbundleid->value) {
1364  $oArticle = oxNew("oxArticle");
1365  $oArticle->load($oProduct->oxarticles__oxbundleid->value);
1366 
1367  return $oArticle;
1368  }
1369 
1370  return false;
1371  }
1372 
1373 
1379  public function getRDFaPaymentMethods()
1380  {
1381  $iPrice = $this->getProduct()->getPrice()->getBruttoPrice();
1382  $oPayments = oxNew("oxPaymentList");
1383  $oPayments->loadRDFaPaymentList($iPrice);
1384 
1385  return $oPayments;
1386  }
1387 
1393  public function getRDFaDeliverySetMethods()
1394  {
1395  $oDelSets = oxNew("oxDeliverySetList");
1396  $oDelSets->loadRDFaDeliverySetList();
1397 
1398  return $oDelSets;
1399  }
1400 
1406  public function getProductsDeliveryList()
1407  {
1408  $oProduct = $this->getProduct();
1409  $oDelList = oxNew("oxDeliveryList");
1410  $oDelList->loadDeliveryListForProduct($oProduct);
1411 
1412  return $oDelList;
1413  }
1414 
1421  {
1422  return $this->getConfig()->getConfigParam("sRDFaDeliveryChargeSpecLoc");
1423  }
1424 
1431  {
1432  return $this->getConfig()->getConfigParam("sRDFaPaymentChargeSpecLoc");
1433  }
1434 
1440  public function getRDFaBusinessEntityLoc()
1441  {
1442  return $this->getConfig()->getConfigParam("sRDFaBusinessEntityLoc");
1443  }
1444 
1450  public function showRDFaProductStock()
1451  {
1452  return $this->getConfig()->getConfigParam("blShowRDFaProductStock");
1453  }
1454 
1460  public function canChangeTags()
1461  {
1462  if ($oUser = $this->getUser()) {
1463 
1464  return true;
1465  }
1466 
1467  return false;
1468  }
1469 
1475  public function getTagCloudManager()
1476  {
1478  $oTagList = oxNew("oxArticleTagList");
1479  //$oTagList->load($this->getProduct()->getId());
1480  $oTagList->setArticleId($this->getProduct()->getId());
1481  $oTagCloud = oxNew("oxTagCloud");
1482  $oTagCloud->setTagList($oTagList);
1483  $oTagCloud->setExtendedMode(true);
1484 
1485  return $oTagCloud;
1486  }
1487 
1493  public function showZoomPics()
1494  {
1495  $aPicGallery = $this->getPictureGallery();
1496 
1497  return $aPicGallery['ZoomPic'];
1498  }
1499 
1505  public function isReviewActive()
1506  {
1507  return $this->getConfig()->getConfigParam('bl_perfLoadReviews');
1508  }
1509 
1515  public function getDefaultSorting()
1516  {
1517  $aSorting = parent::getDefaultSorting();
1518  $oCategory = $this->getActiveCategory();
1519 
1520  if ($this->getListType() != 'search' && $oCategory && $oCategory instanceof oxCategory) {
1521  if ($sSortBy = $oCategory->getDefaultSorting()) {
1522  $sSortDir = ($oCategory->getDefaultSortingMode()) ? "desc" : "asc";
1523  $aSorting = array('sortby' => $sSortBy, 'sortdir' => $sSortDir);
1524  }
1525  }
1526 
1527  return $aSorting;
1528  }
1529 
1535  public function getSortingParameters()
1536  {
1537  $aSorting = $this->getSorting($this->getSortIdent());
1538  if (!is_array($aSorting)) {
1539  return null;
1540  }
1541 
1542  return implode('|', $aSorting);
1543  }
1544 
1550  protected function _getVendorBreadCrumb()
1551  {
1552  $aPaths = array();
1553  $aCatPath = array();
1554 
1555  $oCat = oxNew('oxVendor');
1556  $oCat->load('root');
1557 
1558  $aCatPath['link'] = $oCat->getLink();
1559  $aCatPath['title'] = $oCat->oxvendor__oxtitle->value;
1560  $aPaths[] = $aCatPath;
1561 
1562  $oCat = $this->getActVendor();
1563  if (is_a($oCat, 'oxVendor')) {
1564  $aCatPath['link'] = $oCat->getLink();
1565  $aCatPath['title'] = $oCat->oxvendor__oxtitle->value;
1566  $aPaths[] = $aCatPath;
1567  }
1568 
1569  return $aPaths;
1570  }
1571 
1577  protected function _getRecommendationListBredCrumb()
1578  {
1579  $aPaths = array();
1580  $aCatPath = array();
1581  $iBaseLanguage = oxRegistry::getLang()->getBaseLanguage();
1582  $aCatPath['title'] = oxRegistry::getLang()->translateString('LISTMANIA', $iBaseLanguage, false);
1583  $aPaths[] = $aCatPath;
1584 
1585  return $aPaths;
1586  }
1587 
1593  protected function _getTagBreadCrumb()
1594  {
1595  $aPaths = array();
1596 
1597  $aCatPath = array();
1598 
1599  $iBaseLanguage = oxRegistry::getLang()->getBaseLanguage();
1600  $sSelfLink = $this->getViewConfig()->getSelfLink();
1601 
1602  $aCatPath['title'] = oxRegistry::getLang()->translateString('TAGS', $iBaseLanguage, false);
1603  $aCatPath['link'] = oxRegistry::get("oxSeoEncoder")->getStaticUrl($sSelfLink . 'cl=tags');
1604  $aPaths[] = $aCatPath;
1605 
1606  $sSearchTagParameter = oxRegistry::getConfig()->getRequestParameter('searchtag');
1607  $oStr = getStr();
1608  $aCatPath['title'] = $oStr->ucfirst($sSearchTagParameter);
1609  $aCatPath['link'] = oxRegistry::get("oxSeoEncoderTag")->getTagUrl($sSearchTagParameter);
1610  $aPaths[] = $aCatPath;
1611 
1612  return $aPaths;
1613  }
1614 
1620  protected function _getSearchBreadCrumb()
1621  {
1622  $aPaths = array();
1623  $aCatPath = array();
1624 
1625  $iBaseLanguage = oxRegistry::getLang()->getBaseLanguage();
1626  $sTranslatedString = oxRegistry::getLang()->translateString('SEARCH_RESULT', $iBaseLanguage, false);
1627  $sSelfLink = $this->getViewConfig()->getSelfLink();
1628  $sSessionToken = oxRegistry::getSession()->getVariable('sess_stoken');
1629 
1630  $aCatPath['title'] = sprintf($sTranslatedString, $this->getSearchParamForHtml());
1631  $aCatPath['link'] = $sSelfLink . 'stoken=' . $sSessionToken . "&amp;cl=search&amp;".
1632  "searchparam=" . $this->getSearchParamForHtml();
1633 
1634  $aPaths[] = $aCatPath;
1635 
1636  return $aPaths;
1637  }
1638 
1644  protected function _getCategoryBreadCrumb()
1645  {
1646  $aPaths = array();
1647 
1648  $oCatTree = $this->getCatTreePath();
1649 
1650  if ($oCatTree) {
1651 
1652  foreach ($oCatTree as $oCat) {
1653  $aCatPath = array();
1654 
1655  $aCatPath['link'] = $oCat->getLink();
1656  $aCatPath['title'] = $oCat->oxcategories__oxtitle->value;
1657 
1658  $aPaths[] = $aCatPath;
1659  }
1660 
1661  return $aPaths;
1662  }
1663 
1664  return $aPaths;
1665  }
1666 }