00001 <?php
00002
00009 class Details extends oxUBase
00010 {
00016 protected $_aVariantList = null;
00017
00023 protected $_sThisTemplate = 'page/details/details.tpl';
00024
00030 protected $_oParentProd = null;
00031
00037 protected $_blCanRate = null;
00038
00043 protected $_blShowSorting = true;
00044
00049 protected $_blEditTags = null;
00050
00055 protected $_blCanEditTags = null;
00056
00061 protected $_aTags = null;
00062
00067 protected $_aUserRecommList = null;
00068
00073 protected $_oCaptcha = null;
00074
00079 protected $_aMediaFiles = null;
00080
00085 protected $_aLastProducts = null;
00086
00091 protected $_oVendor = null;
00092
00097 protected $_oManufacturer = null;
00098
00103 protected $_oCategory = null;
00104
00109 protected $_aAttributes = null;
00110
00115 protected $_sParentName = null;
00116
00121 protected $_sParentUrl = null;
00122
00127 protected $_aPicGallery = null;
00128
00133 protected $_aSelectLists = null;
00134
00139 protected $_aReviews = null;
00140
00145 protected $_oCrossSelling = null;
00146
00151 protected $_oSimilarProducts = null;
00152
00157 protected $_oRecommList = null;
00158
00163 protected $_oAccessoires = null;
00164
00169 protected $_aAlsoBoughtArts = null;
00170
00175 protected $_sSearchTitle = null;
00176
00182 protected $_blIsInitialized = false;
00183
00189 protected $_iLinkType = null;
00190
00196 protected $_blMdView = null;
00197
00202 protected $_dRatingValue = null;
00203
00208 protected $_iRatingCnt = null;
00209
00214 protected $_sBidPrice = null;
00215
00220 protected $_iPriceAlarmStatus = null;
00221
00226 protected $_sSearchParamForHtml = null;
00227
00233 protected $_aSimilarRecommListIds = null;
00234
00235
00243 protected function _getParentProduct( $sParentId )
00244 {
00245 if ( $sParentId && $this->_oParentProd === null ) {
00246 $this->_oParentProd = false;
00247 if ( ( $oParent = oxNewArticle( $sParentId ) ) ) {
00248 $this->_processProduct( $oParent );
00249 $this->_oParentProd = $oParent;
00250 }
00251 }
00252 return $this->_oParentProd;
00253 }
00254
00261 public function loadVariantInformation()
00262 {
00263 if ( $this->_aVariantList === null ) {
00264 $oProduct = $this->getProduct();
00265
00266
00267 if ( $oParent = $oProduct->getParentArticle() ) {
00268 $myConfig = $this->getConfig();
00269
00270 $oParent->setNoVariantLoading(false);
00271 $this->_aVariantList = $oParent->getFullVariants( false );
00272
00273
00274 if ( count( $this->_aVariantList ) && $myConfig->getConfigParam( 'blVariantParentBuyable' ) ) {
00275
00276 $oParent->enablePriceLoad();
00277 $oParent->aSelectlist = $oParent->getSelectLists();
00278 $this->_aVariantList = array_merge( array( $oParent ), $this->_aVariantList->getArray() );
00279 }
00280 } else {
00281
00282 $this->_aVariantList = $oProduct->getFullVariants( false );
00283 }
00284
00285
00286 foreach ( $this->_aVariantList as $oVariant ) {
00287 $this->_processProduct( $oVariant );
00288 }
00289
00290 }
00291
00292 return $this->_aVariantList;
00293 }
00294
00300 protected function _getAddUrlParams()
00301 {
00302 if ( $this->getListType() == "search" ) {
00303 return $this->getDynUrlParams();
00304 }
00305 }
00306
00314 protected function _processProduct( $oProduct )
00315 {
00316 $oProduct->setLinkType( $this->getLinkType() );
00317 if ( $sAddParams = $this->_getAddUrlParams() ) {
00318 $oProduct->appendLink( $sAddParams );
00319 }
00320 }
00321
00327 public function getViewId()
00328 {
00329 if ( isset( $this->_sViewId )) {
00330 return $this->_sViewId;
00331 }
00332
00333 $sViewId = parent::getViewId().'|'.oxConfig::getParameter( 'anid' ).'|';
00334
00335
00336 return $this->_sViewId = $sViewId;
00337 }
00338
00339
00351 public function render()
00352 {
00353 $myConfig = $this->getConfig();
00354
00355 $oProduct = $this->getProduct();
00356
00357
00358 if ( $oProduct->oxarticles__oxtemplate->value ) {
00359 $this->_sThisTemplate = $oProduct->oxarticles__oxtemplate->value;
00360 }
00361
00362 if ( ( $sTplName = oxConfig::getParameter( 'tpl' ) ) ) {
00363 $this->_sThisTemplate = 'custom/'.basename ( $sTplName );
00364 }
00365
00366 parent::render();
00367
00368 $sPartial = oxConfig::getParameter('renderPartial');
00369 $this->addTplParam('renderPartial', $sPartial);
00370
00371 switch ($sPartial) {
00372 case "productInfo":
00373 return 'page/details/ajax/fullproductinfo.tpl';
00374 break;
00375 case "detailsMain":
00376 return 'page/details/ajax/productmain.tpl';
00377 break;
00378 default:
00379
00380 $oLocator = oxNew( 'oxlocator', $this->getListType() );
00381 $oLocator->setLocatorData( $oProduct, $this );
00382
00383 if ($myConfig->getConfigParam( 'bl_rssRecommLists' ) && $this->getSimilarRecommListIds()) {
00384 $oRss = oxNew('oxrssfeed');
00385 $this->addRssFeed($oRss->getRecommListsTitle( $oProduct ), $oRss->getRecommListsUrl( $oProduct ), 'recommlists');
00386 }
00387
00388 return $this->_sThisTemplate;
00389 }
00390 }
00391
00403 protected function _prepareMetaDescription( $sMeta, $iLength = 200, $blDescTag = false )
00404 {
00405 if ( !$sMeta ) {
00406 $oProduct = $this->getProduct();
00407
00408 if ( $this->getConfig()->getConfigParam( 'bl_perfParseLongDescinSmarty' ) ) {
00409 $sMeta = $oProduct->getLongDesc();
00410 } else {
00411 $sMeta = $oProduct->getLongDescription()->value;
00412 }
00413 if ( $sMeta == '' ) {
00414 $sMeta = $oProduct->oxarticles__oxshortdesc->value;
00415 }
00416 $sMeta = $oProduct->oxarticles__oxtitle->value.' - '.$sMeta;
00417 }
00418 return parent::_prepareMetaDescription( $sMeta, $iLength, $blDescTag );
00419 }
00420
00431 protected function _prepareMetaKeyword( $sKeywords, $blRemoveDuplicatedWords = true )
00432 {
00433 if ( !$sKeywords ) {
00434 $oProduct = $this->getProduct();
00435 $sKeywords = trim( $this->getTitle() );
00436
00437 if ( $oCatTree = $this->getCategoryTree() ) {
00438 foreach ( $oCatTree->getPath() as $oCat ) {
00439 $sKeywords .= ", " . trim( $oCat->oxcategories__oxtitle->value );
00440 }
00441 }
00442
00443
00444 if ( $sSearchKeys = trim( $oProduct->oxarticles__oxsearchkeys->value ) ) {
00445 $sKeywords .= ", ". $sSearchKeys;
00446 }
00447
00448 $sKeywords = parent::_prepareMetaKeyword( $sKeywords, $blRemoveDuplicatedWords );
00449 }
00450
00451 return $sKeywords;
00452 }
00453
00459 public function ratingIsActive()
00460 {
00461 return $this->getConfig()->getConfigParam( 'bl_perfLoadReviews' );
00462 }
00463
00469 public function canRate()
00470 {
00471 if ( $this->_blCanRate === null ) {
00472
00473 $this->_blCanRate = false;
00474
00475 if ( $this->ratingIsActive() && $oUser = $this->getUser() ) {
00476
00477 $oRating = oxNew( 'oxrating' );
00478 $this->_blCanRate = $oRating->allowRating( $oUser->getId(), 'oxarticle', $this->getProduct()->getId() );
00479 }
00480 }
00481
00482 return $this->_blCanRate;
00483 }
00484
00490 public function canChangeTags()
00491 {
00492 if ( $oUser = $this->getUser() ) {
00493
00494 return true;
00495 }
00496 return false;
00497 }
00498
00504 public function saveReview()
00505 {
00506 if ( $this->canAcceptFormData() &&
00507 ( $oUser = $this->getUser() ) && ( $oProduct = $this->getProduct() ) ) {
00508
00509 $dRating = oxConfig::getParameter( 'artrating' );
00510 if ( $dRating !== null ) {
00511 $dRating = (int) $dRating;
00512 }
00513
00514
00515 if ( $dRating !== null && $dRating >= 1 && $dRating <= 5 ) {
00516 $oRating = oxNew( 'oxrating' );
00517 if ( $oRating->allowRating( $oUser->getId(), 'oxarticle', $oProduct->getId() ) ) {
00518 $oRating->oxratings__oxuserid = new oxField( $oUser->getId() );
00519 $oRating->oxratings__oxtype = new oxField( 'oxarticle' );
00520 $oRating->oxratings__oxobjectid = new oxField( $oProduct->getId() );
00521 $oRating->oxratings__oxrating = new oxField( $dRating );
00522 $oRating->save();
00523 $oProduct->addToRatingAverage( $dRating );
00524 }
00525 }
00526
00527 if ( ( $sReviewText = trim( ( string ) oxConfig::getParameter( 'rvw_txt', true ) ) ) ) {
00528 $oReview = oxNew( 'oxreview' );
00529 $oReview->oxreviews__oxobjectid = new oxField( $oProduct->getId() );
00530 $oReview->oxreviews__oxtype = new oxField( 'oxarticle' );
00531 $oReview->oxreviews__oxtext = new oxField( $sReviewText, oxField::T_RAW );
00532 $oReview->oxreviews__oxlang = new oxField( oxRegistry::getLang()->getBaseLanguage() );
00533 $oReview->oxreviews__oxuserid = new oxField( $oUser->getId() );
00534 $oReview->oxreviews__oxrating = new oxField( ( $dRating !== null ) ? $dRating : 0);
00535 $oReview->save();
00536 }
00537 }
00538 }
00539
00545 public function addToRecomm()
00546 {
00547 if (!$this->getViewConfig()->getShowListmania()) {
00548 return;
00549 }
00550
00551 $sRecommText = trim( ( string ) oxConfig::getParameter( 'recomm_txt' ) );
00552 $sRecommList = oxConfig::getParameter( 'recomm' );
00553 $sArtId = $this->getProduct()->getId();
00554
00555 if ( $sArtId ) {
00556 $oRecomm = oxNew( 'oxrecommlist' );
00557 $oRecomm->load( $sRecommList);
00558 $oRecomm->addArticle( $sArtId, $sRecommText );
00559 }
00560 }
00561
00567 public function addTags()
00568 {
00569 $sTags = $this->getConfig()->getRequestParameter('newTags', true );
00570 $sHighTag = $this->getConfig()->getRequestParameter( 'highTags', true );
00571 if ( !$sTags && !$sHighTag) {
00572 return;
00573 }
00574 if ( $sHighTag ) {
00575 $sTags = getStr()->html_entity_decode( $sHighTag );
00576 }
00577 $oProduct = $this->getProduct();
00578
00579
00580 $aTaggedProducts = oxRegistry::getSession()->getVariable("aTaggedProducts");
00581 $aAddedTags = $aTaggedProducts? $aTaggedProducts[$oProduct->getId()] : array();
00582
00583 $oArticleTagList = oxNew( "oxarticletaglist" );
00584 $oArticleTagList->load( $oProduct->getId() );
00585 $sSeparator = $oArticleTagList->get()->getSeparator();
00586 $aTags = explode( $sSeparator, $sTags );
00587 $blAddedTag = false;
00588 foreach ( $aTags as $sTag ) {
00589 $oTag = oxNew( "oxtag" );
00590 $oTag->set( $sTag );
00591 if ( $aAddedTags[$oTag->get()] != 1 ) {
00592 $oArticleTagList->addTag( $oTag );
00593 $aAddedTags[$oTag->get()] = 1;
00594 $blAddedTag = true;
00595 }
00596 }
00597 if ( $blAddedTag ) {
00598 $oArticleTagList->save();
00599 $aTaggedProducts[$oProduct->getId()] = $aAddedTags;
00600 oxRegistry::getSession()->setVariable( 'aTaggedProducts', $aTaggedProducts);
00601 }
00602
00603 if ( $this->getConfig()->getRequestParameter( 'blAjax', true ) ) {
00604 oxRegistry::getUtils()->showMessageAndExit( $blAddedTag );
00605 }
00606 }
00607
00613 public function editTags()
00614 {
00615 if ( !$this->getUser() ) {
00616 return;
00617 }
00618 $oArticleTagList = oxNew("oxArticleTagList");
00619 $oArticleTagList->load( $this->getProduct()->getId() );
00620 $oTagSet = $oArticleTagList->get();
00621 $this->_aTags = $oTagSet->get();
00622 $this->_blEditTags = true;
00623
00624
00625 if ( $this->getConfig()->getRequestParameter( 'blAjax', true ) ) {
00626 oxRegistry::getUtils()->setHeader( "Content-Type: text/html; charset=".oxRegistry::getLang()->translateString( 'charset' ) );
00627 $oActView = oxNew( 'oxubase' );
00628 $oSmarty = oxRegistry::get("oxUtilsView")->getSmarty();
00629 $oSmarty->assign('oView', $this );
00630 $oSmarty->assign('oViewConf', $this->getViewConfig() );
00631 oxRegistry::getUtils()->showMessageAndExit( $oSmarty->fetch( 'page/details/inc/editTags.tpl', $this->getViewId() ) );
00632 }
00633 }
00634
00640 public function cancelTags()
00641 {
00642 $oArticleTagList = oxNew("oxArticleTagList");
00643 $oArticleTagList->load( $this->getProduct()->getId() );
00644 $oTagSet = $oArticleTagList->get();
00645 $this->_aTags = $oTagSet->get();
00646 $this->_blEditTags = false;
00647
00648
00649 if ( oxConfig::getParameter( 'blAjax', true ) ) {
00650 oxRegistry::getUtils()->setHeader( "Content-Type: text/html; charset=".oxRegistry::getLang()->translateString( 'charset' ) );
00651 $oActView = oxNew( 'oxubase' );
00652 $oSmarty = oxRegistry::get("oxUtilsView")->getSmarty();
00653 $oSmarty->assign('oView', $this );
00654 $oSmarty->assign('oViewConf', $this->getViewConfig() );
00655 oxRegistry::getUtils()->showMessageAndExit( $oSmarty->fetch( 'page/details/inc/tags.tpl', $this->getViewId() ) );
00656 }
00657 }
00658
00664 protected function _getSeoObjectId()
00665 {
00666 if ( $oProduct = $this->getProduct() ) {
00667 return $oProduct->getId();
00668 }
00669 }
00670
00676 public function getAttributes()
00677 {
00678 if ( $this->_aAttributes === null ) {
00679
00680 $aArtAttributes = $this->getProduct()->getAttributes();
00681
00682
00683 $this->_aAttributes = false;
00684
00685 if ( count( $aArtAttributes ) ) {
00686 foreach ( $aArtAttributes as $sKey => $oAttribute ) {
00687 $this->_aAttributes[$sKey] = new stdClass();
00688 $this->_aAttributes[$sKey]->title = $oAttribute->oxattribute__oxtitle->value;
00689 $this->_aAttributes[$sKey]->value = $oAttribute->oxattribute__oxvalue->value;
00690 }
00691 }
00692 }
00693 return $this->_aAttributes;
00694 }
00695
00696
00702 public function getEditTags()
00703 {
00704 return $this->_blEditTags;
00705 }
00706
00712 public function getTags()
00713 {
00714 return $this->_aTags;
00715 }
00716
00722 public function getTagCloudManager()
00723 {
00724 $oManager = oxNew( "oxTagCloud" );
00725 $oManager->setExtendedMode( true );
00726 $oManager->setProductId( $this->getProduct()->getId() );
00727 return $oManager;
00728 }
00729
00736 public function isEditableTags()
00737 {
00738 if ( $this->_blCanEditTags === null ) {
00739 $this->_blCanEditTags = false;
00740 if ( $this->getProduct() && $this->getUser()) {
00741 $this->_blCanEditTags = true;
00742 }
00743 }
00744 return $this->_blCanEditTags;
00745 }
00746
00752 public function getProduct()
00753 {
00754 $myConfig = $this->getConfig();
00755 $myUtils = oxRegistry::getUtils();
00756
00757 if ( $this->_oProduct === null ) {
00758
00759
00760
00761 $myConfig->setConfigParam( 'blLoadVariants', true );
00762
00763 $sOxid = oxConfig::getParameter( 'anid' );
00764
00765
00766 $this->_oProduct = oxNew( 'oxarticle' );
00767
00768 if ( !$this->_oProduct->load( $sOxid ) ) {
00769 $myUtils->redirect( $myConfig->getShopHomeURL() );
00770 $myUtils->showMessageAndExit( '' );
00771 }
00772
00773 $aVariantSelections = $this->_oProduct->getVariantSelections( oxConfig::getParameter( "varselid" ) );
00774 if ($aVariantSelections && $aVariantSelections['oActiveVariant'] && $aVariantSelections['blPerfectFit']) {
00775 $this->_oProduct = $aVariantSelections['oActiveVariant'];
00776 }
00777 }
00778
00779
00780 if ( !$this->_blIsInitialized ) {
00781
00782 $blContinue = true;
00783 if ( !$this->_oProduct->isVisible() ) {
00784 $blContinue = false;
00785 } elseif ( $this->_oProduct->oxarticles__oxparentid->value ) {
00786 $oParent = $this->_getParentProduct( $this->_oProduct->oxarticles__oxparentid->value );
00787 if ( !$oParent || !$oParent->isVisible() ) {
00788 $blContinue = false;
00789 }
00790 }
00791
00792 if ( !$blContinue ) {
00793 $myUtils->redirect( $myConfig->getShopHomeURL() );
00794 $myUtils->showMessageAndExit( '' );
00795 }
00796
00797 $this->_processProduct( $this->_oProduct );
00798 $this->_blIsInitialized = true;
00799 }
00800
00801 return $this->_oProduct;
00802 }
00803
00809 public function getLinkType()
00810 {
00811 if ( $this->_iLinkType === null ) {
00812 $sListType = oxConfig::getParameter( 'listtype' );
00813 if ( 'vendor' == $sListType ) {
00814 $this->_iLinkType = OXARTICLE_LINKTYPE_VENDOR;
00815 } elseif ( 'manufacturer' == $sListType ) {
00816 $this->_iLinkType = OXARTICLE_LINKTYPE_MANUFACTURER;
00817 } elseif ( 'tag' == $sListType ) {
00818 $this->_iLinkType = OXARTICLE_LINKTYPE_TAG;
00819 } elseif ( 'recommlist' == $sListType ) {
00820 $this->_iLinkType = OXARTICLE_LINKTYPE_RECOMM;
00821 } else {
00822 $this->_iLinkType = OXARTICLE_LINKTYPE_CATEGORY;
00823
00824
00825 if ( ( $oCat = $this->getActiveCategory() ) && $oCat->isPriceCategory() ) {
00826 $this->_iLinkType = OXARTICLE_LINKTYPE_PRICECATEGORY;
00827 }
00828 }
00829 }
00830
00831 return $this->_iLinkType;
00832 }
00833
00839 public function getVariantList()
00840 {
00841 return $this->loadVariantInformation();
00842 }
00843
00850 public function getVariantListExceptCurrent()
00851 {
00852 $oList = $this->getVariantList();
00853 if (is_object($oList)) {
00854 $oList = clone $oList;
00855 }
00856
00857 $sOxid = $this->getProduct()->getId();
00858 if (isset($oList[$sOxid])) {
00859 unset($oList[$sOxid]);
00860 }
00861 return $oList;
00862 }
00863
00869 public function getCaptcha()
00870 {
00871 if ( $this->_oCaptcha === null ) {
00872 $this->_oCaptcha = oxNew('oxCaptcha');
00873 }
00874 return $this->_oCaptcha;
00875 }
00876
00882 public function getMediaFiles()
00883 {
00884 if ( $this->_aMediaFiles === null ) {
00885 $aMediaFiles = $this->getProduct()->getMediaUrls();
00886 $this->_aMediaFiles = count($aMediaFiles) ? $aMediaFiles : false;
00887 }
00888 return $this->_aMediaFiles;
00889 }
00890
00898 public function getLastProducts( $iCnt = 4 )
00899 {
00900 if ( $this->_aLastProducts === null ) {
00901
00902 $oProduct = $this->getProduct();
00903 $sArtId = $oProduct->oxarticles__oxparentid->value?$oProduct->oxarticles__oxparentid->value:$oProduct->getId();
00904
00905 $oHistoryArtList = oxNew( 'oxarticlelist' );
00906 $oHistoryArtList->loadHistoryArticles( $sArtId, $iCnt );
00907 $this->_aLastProducts = $oHistoryArtList;
00908 }
00909 return $this->_aLastProducts;
00910 }
00911
00917 public function getVendor()
00918 {
00919 if ( $this->_oVendor === null ) {
00920 $this->_oVendor = $this->getProduct()->getVendor( false );
00921 }
00922 return $this->_oVendor;
00923 }
00924
00930 public function getManufacturer()
00931 {
00932 if ( $this->_oManufacturer === null ) {
00933 $this->_oManufacturer = $this->getProduct()->getManufacturer( false );
00934 }
00935 return $this->_oManufacturer;
00936 }
00937
00943 public function getCategory()
00944 {
00945 if ( $this->_oCategory === null ) {
00946 $this->_oCategory = $this->getProduct()->getCategory();
00947 }
00948 return $this->_oCategory;
00949 }
00950
00956 public function drawParentUrl()
00957 {
00958 return $this->getProduct()->isVariant();
00959 }
00960
00966 public function getParentName()
00967 {
00968 if ( $this->_sParentName === null ) {
00969 $this->_sParentName = false;
00970 if ( ( $oParent = $this->_getParentProduct( $this->getProduct()->oxarticles__oxparentid->value ) ) ) {
00971 $this->_sParentName = $oParent->oxarticles__oxtitle->value;
00972 }
00973 }
00974 return $this->_sParentName;
00975 }
00976
00982 public function getParentUrl()
00983 {
00984 if ( $this->_sParentUrl === null ) {
00985 $this->_sParentUrl = false;
00986 if ( ( $oParent = $this->_getParentProduct( $this->getProduct()->oxarticles__oxparentid->value ) ) ) {
00987 $this->_sParentUrl = $oParent->getLink();
00988 }
00989 }
00990 return $this->_sParentUrl;
00991 }
00992
00998 public function getPictureGallery()
00999 {
01000 if ( $this->_aPicGallery === null ) {
01001
01002 $this->_aPicGallery = $this->getPicturesProduct()->getPictureGallery();
01003 }
01004 return $this->_aPicGallery;
01005 }
01006
01012 public function getActPictureId()
01013 {
01014 $aPicGallery = $this->getPictureGallery();
01015 return $aPicGallery['ActPicID'];
01016 }
01017
01023 public function getActPicture()
01024 {
01025 $aPicGallery = $this->getPictureGallery();
01026 return $aPicGallery['ActPic'];
01027 }
01028
01034 public function morePics()
01035 {
01036 $aPicGallery = $this->getPictureGallery();
01037 return $aPicGallery['MorePics'];
01038 }
01039
01045 public function getPictures()
01046 {
01047 $aPicGallery = $this->getPictureGallery();
01048 return $aPicGallery['Pics'];
01049 }
01050
01058 public function getArtPic( $sPicNr )
01059 {
01060 $aPicGallery = $this->getPictureGallery();
01061 return $aPicGallery['Pics'][$sPicNr];
01062 }
01063
01069 public function getIcons()
01070 {
01071 $aPicGallery = $this->getPictureGallery();
01072 return $aPicGallery['Icons'];
01073 }
01074
01080 public function showZoomPics()
01081 {
01082 $aPicGallery = $this->getPictureGallery();
01083 return $aPicGallery['ZoomPic'];
01084 }
01085
01091 public function getZoomPics()
01092 {
01093 $aPicGallery = $this->getPictureGallery();
01094 return $aPicGallery['ZoomPics'];
01095 }
01096
01102 public function getActZoomPic()
01103 {
01104 return 1;
01105 }
01106
01112 public function getSelectLists()
01113 {
01114 if ( $this->_aSelectLists === null ) {
01115 $this->_aSelectLists = false;
01116 if ( $this->getConfig()->getConfigParam( 'bl_perfLoadSelectLists' ) ) {
01117 $this->_aSelectLists = $this->getProduct()->getSelectLists();
01118 }
01119 }
01120 return $this->_aSelectLists;
01121 }
01122
01128 public function getReviews()
01129 {
01130 if ( $this->_aReviews === null ) {
01131 $this->_aReviews = false;
01132 if ( $this->getConfig()->getConfigParam( 'bl_perfLoadReviews' ) ) {
01133 $this->_aReviews = $this->getProduct()->getReviews();
01134 }
01135 }
01136 return $this->_aReviews;
01137 }
01138
01144 public function getCrossSelling()
01145 {
01146 if ( $this->_oCrossSelling === null ) {
01147 $this->_oCrossSelling = false;
01148 if ( $oProduct = $this->getProduct() ) {
01149 $this->_oCrossSelling = $oProduct->getCrossSelling();
01150 }
01151 }
01152 return $this->_oCrossSelling;
01153 }
01154
01160 public function getSimilarProducts()
01161 {
01162 if ( $this->_oSimilarProducts === null ) {
01163 $this->_oSimilarProducts = false;
01164 if ( $oProduct = $this->getProduct() ) {
01165 $this->_oSimilarProducts = $oProduct->getSimilarProducts();
01166 }
01167 }
01168 return $this->_oSimilarProducts;
01169 }
01170
01176 public function getSimilarRecommListIds()
01177 {
01178 if ( $this->_aSimilarRecommListIds === null ) {
01179 $this->_aSimilarRecommListIds = false;
01180
01181 if ( $oProduct = $this->getProduct() ) {
01182 $this->_aSimilarRecommListIds = array( $oProduct->getId() );
01183 }
01184 }
01185 return $this->_aSimilarRecommListIds;
01186 }
01187
01193 public function getAccessoires()
01194 {
01195 if ( $this->_oAccessoires === null ) {
01196 $this->_oAccessoires = false;
01197 if ( $oProduct = $this->getProduct() ) {
01198 $this->_oAccessoires = $oProduct->getAccessoires();
01199 }
01200 }
01201 return $this->_oAccessoires;
01202 }
01203
01209 public function getAlsoBoughtTheseProducts()
01210 {
01211 if ( $this->_aAlsoBoughtArts === null ) {
01212 $this->_aAlsoBoughtArts = false;
01213 if ( $oProduct = $this->getProduct() ) {
01214 $this->_aAlsoBoughtArts = $oProduct->getCustomerAlsoBoughtThisProducts();
01215 }
01216 }
01217 return $this->_aAlsoBoughtArts;
01218 }
01219
01225 public function isPriceAlarm()
01226 {
01227
01228 $oProduct = $this->getProduct();
01229 if ( isset( $oProduct->oxarticles__oxblfixedprice->value ) && $oProduct->oxarticles__oxblfixedprice->value ) {
01230 return 0;
01231 }
01232 return 1;
01233 }
01234
01243 protected function _getSubject( $iLang )
01244 {
01245 return $this->getProduct();
01246 }
01247
01253 public function getSearchTitle()
01254 {
01255 return $this->_sSearchTitle;
01256 }
01257
01265 public function setSearchTitle( $sTitle )
01266 {
01267 $this->_sSearchTitle = $sTitle;
01268 }
01269
01277 public function setCatTreePath( $sActCatPath )
01278 {
01279 $this->_sCatTreePath = $sActCatPath;
01280 }
01281
01288 public function noIndex()
01289 {
01290 $sListType = oxConfig::getParameter( 'listtype' );
01291 if ( $sListType && ( 'vendor' == $sListType || 'manufacturer' == $sListType ) ) {
01292 return $this->_iViewIndexState = VIEW_INDEXSTATE_NOINDEXFOLLOW;
01293 }
01294 return parent::noIndex();
01295 }
01296
01302 public function getTitle()
01303 {
01304 if ( $oProduct = $this->getProduct() ) {
01305 return $oProduct->oxarticles__oxtitle->value . ( $oProduct->oxarticles__oxvarselect->value ? ' ' . $oProduct->oxarticles__oxvarselect->value : '' );
01306 }
01307 }
01308
01309
01315 public function getTag()
01316 {
01317 return oxConfig::getParameter("searchtag", 1);
01318 }
01319
01325 public function getCanonicalUrl()
01326 {
01327 if ( ( $oProduct = $this->getProduct() ) ) {
01328 if ( $oProduct->oxarticles__oxparentid->value ) {
01329 $oProduct = $this->_getParentProduct( $oProduct->oxarticles__oxparentid->value );
01330 }
01331
01332 $oUtils = oxRegistry::get("oxUtilsUrl");
01333 if ( oxRegistry::getUtils()->seoIsActive() ) {
01334 $sUrl = $oUtils->prepareCanonicalUrl( $oProduct->getBaseSeoLink( $oProduct->getLanguage(), true ) );
01335 } else {
01336 $sUrl = $oUtils->prepareCanonicalUrl( $oProduct->getBaseStdLink( $oProduct->getLanguage() ) );
01337 }
01338 return $sUrl;
01339 }
01340 }
01341
01347 public function isMdVariantView()
01348 {
01349 if ( $this->_blMdView === null ) {
01350 $this->_blMdView = false;
01351 if ( $this->getConfig()->getConfigParam( 'blUseMultidimensionVariants' ) ) {
01352 $iMaxMdDepth = $this->getProduct()->getMdVariants()->getMaxDepth();
01353 $this->_blMdView = ($iMaxMdDepth > 1);
01354 }
01355 }
01356
01357 return $this->_blMdView;
01358 }
01359
01365 public function isPersParam()
01366 {
01367 $oProduct = $this->getProduct();
01368 return $oProduct->oxarticles__oxisconfigurable->value;
01369 }
01370
01376 public function getTagSeparator()
01377 {
01378 $sSepartor = $this->getConfig()->getConfigParam("sTagSeparator");
01379 return $sSepartor;
01380 }
01381
01387 public function getRatingValue()
01388 {
01389
01390 if ( $this->_dRatingValue === null ) {
01391 $this->_dRatingValue = (double) 0;
01392 if ( $this->isReviewActive() && ( $oDetailsProduct = $this->getProduct() ) ) {
01393 $this->_dRatingValue = round( $oDetailsProduct->getArticleRatingAverage( $this->getConfig()->getConfigParam( 'blShowVariantReviews' ) ), 1);
01394 }
01395 }
01396
01397 return (double) $this->_dRatingValue;
01398 }
01399
01405 public function isReviewActive()
01406 {
01407 return $this->getConfig()->getConfigParam( 'bl_perfLoadReviews' );
01408 }
01409
01415 public function getRatingCount()
01416 {
01417 if ( $this->_iRatingCnt === null ) {
01418 $this->_iRatingCnt = false;
01419 if ( $this->isReviewActive() && ( $oDetailsProduct = $this->getProduct() ) ) {
01420 $this->_iRatingCnt = $oDetailsProduct->getArticleRatingCount( $this->getConfig()->getConfigParam( 'blShowVariantReviews' ) );
01421 }
01422 }
01423 return $this->_iRatingCnt;
01424 }
01425
01431 public function getBreadCrumb()
01432 {
01433 $aPaths = array();
01434
01435 if ( 'search' == oxConfig::getParameter( 'listtype' ) ) {
01436 $sSearchParam = $this->getSearchParamForHtml();
01437
01438 $aCatPath = array();
01439 $aCatPath['title'] = sprintf( oxRegistry::getLang()->translateString( 'searchResult', oxRegistry::getLang()->getBaseLanguage(), false ), $sSearchParam );
01440 $aCatPath['link'] = $this->getViewConfig()->getSelfLink() . 'stoken=' . oxSession::getVar('sess_stoken') . "&cl=search&searchparam=" . $sSearchParam;
01441
01442 $aPaths[] = $aCatPath;
01443
01444 } elseif ( 'tag' == oxConfig::getParameter( 'listtype' ) ) {
01445
01446 $aCatPath = array();
01447
01448 $aCatPath['title'] = oxRegistry::getLang()->translateString( 'TAGS', oxRegistry::getLang()->getBaseLanguage(), false );
01449 $aCatPath['link'] = oxRegistry::get("oxSeoEncoder")->getStaticUrl( $this->getViewConfig()->getSelfLink() . 'cl=tags' );
01450 $aPaths[] = $aCatPath;
01451
01452 $oStr = getStr();
01453 $aCatPath['title'] = $oStr->ucfirst(oxConfig::getParameter( 'searchtag' ));
01454 $aCatPath['link'] = oxRegistry::get("oxSeoEncoderTag")->getTagUrl( oxConfig::getParameter( 'searchtag' ) );
01455 $aPaths[] = $aCatPath;
01456
01457 } elseif ( 'recommlist' == oxConfig::getParameter( 'listtype' ) ) {
01458
01459 $aCatPath = array();
01460 $aCatPath['title'] = oxRegistry::getLang()->translateString( 'PAGE_RECOMMENDATIONS_PRODUCTS_TITLE', oxRegistry::getLang()->getBaseLanguage(), false );
01461 $aPaths[] = $aCatPath;
01462 } else {
01463
01464 $oCatTree = $this->getCatTreePath();
01465
01466 if ( $oCatTree ) {
01467
01468 foreach ( $oCatTree as $oCat ) {
01469 $aCatPath = array();
01470
01471 $aCatPath['link'] = $oCat->getLink();
01472 $aCatPath['title'] = $oCat->oxcategories__oxtitle->value;
01473
01474 $aPaths[] = $aCatPath;
01475 }
01476 }
01477 }
01478
01479 return $aPaths;
01480 }
01481
01491 public function addme()
01492 {
01493 $myConfig = $this->getConfig();
01494 $myUtils = oxRegistry::getUtils();
01495
01496
01497 $sMac = oxConfig::getParameter( 'c_mac' );
01498 $sMacHash = oxConfig::getParameter( 'c_mach' );
01499 $oCaptcha = $this->getCaptcha();
01500 if ( !$oCaptcha->pass( $sMac, $sMacHash ) ) {
01501 $this->_iPriceAlarmStatus = 2;
01502 return;
01503 }
01504
01505 $aParams = oxConfig::getParameter( 'pa' );
01506 if ( !isset( $aParams['email'] ) || !$myUtils->isValidEmail( $aParams['email'] ) ) {
01507 $this->_iPriceAlarmStatus = 0;
01508 return;
01509 }
01510 $aParams['aid'] = $this->getProduct()->getId();
01511 $oCur = $myConfig->getActShopCurrencyObject();
01512
01513 $dPrice = $myUtils->currency2Float( $aParams['price'] );
01514
01515 $oAlarm = oxNew( "oxpricealarm" );
01516 $oAlarm->oxpricealarm__oxuserid = new oxField( oxSession::getVar( 'usr' ));
01517 $oAlarm->oxpricealarm__oxemail = new oxField( $aParams['email']);
01518 $oAlarm->oxpricealarm__oxartid = new oxField( $aParams['aid']);
01519 $oAlarm->oxpricealarm__oxprice = new oxField( $myUtils->fRound( $dPrice, $oCur ));
01520 $oAlarm->oxpricealarm__oxshopid = new oxField( $myConfig->getShopId());
01521 $oAlarm->oxpricealarm__oxcurrency = new oxField( $oCur->name);
01522
01523 $oAlarm->oxpricealarm__oxlang = new oxField(oxRegistry::getLang()->getBaseLanguage());
01524
01525 $oAlarm->save();
01526
01527
01528 $oEmail = oxNew( 'oxemail' );
01529 $this->_iPriceAlarmStatus = (int) $oEmail->sendPricealarmNotification( $aParams, $oAlarm );
01530 }
01531
01537 public function getPriceAlarmStatus()
01538 {
01539 return $this->_iPriceAlarmStatus;
01540 }
01541
01547 public function getBidPrice()
01548 {
01549 if ( $this->_sBidPrice === null ) {
01550 $this->_sBidPrice = false;
01551
01552 $aParams = oxConfig::getParameter( 'pa' );
01553 $oCur = $this->getConfig()->getActShopCurrencyObject();
01554 $iPrice = oxRegistry::getUtils()->currency2Float( $aParams['price'] );
01555 $this->_sBidPrice = oxRegistry::getLang()->formatCurrency( $iPrice, $oCur );
01556 }
01557 return $this->_sBidPrice;
01558 }
01559
01565 public function getVariantSelections()
01566 {
01567
01568 $oProduct = $this->getProduct();
01569 if ( ( $oParent = $this->_getParentProduct( $oProduct->oxarticles__oxparentid->value ) ) ) {
01570 return $oParent->getVariantSelections( oxConfig::getParameter( "varselid" ), $oProduct->getId() );
01571 }
01572
01573 return $oProduct->getVariantSelections( oxConfig::getParameter( "varselid" ) );
01574 }
01575
01581 public function getPicturesProduct()
01582 {
01583 $aVariantSelections = $this->getVariantSelections();
01584 if ($aVariantSelections && $aVariantSelections['oActiveVariant'] && !$aVariantSelections['blPerfectFit']) {
01585 return $aVariantSelections['oActiveVariant'];
01586 }
01587 return $this->getProduct();
01588 }
01589
01595 public function getSearchParamForHtml()
01596 {
01597 if ( $this->_sSearchParamForHtml === null ) {
01598 $this->_sSearchParamForHtml = oxConfig::getParameter( 'searchparam' );
01599 }
01600 return $this->_sSearchParamForHtml;
01601 }
01602
01608 public function showRdfa()
01609 {
01610 return $this->getConfig()->getConfigParam( 'blRDFaEmbedding' );
01611 }
01612
01618 public function getRDFaNormalizedRating()
01619 {
01620 $myConfig = $this->getConfig();
01621 $iMin = $myConfig->getConfigParam("iRDFaMinRating");
01622 $iMax = $myConfig->getConfigParam("iRDFaMaxRating");
01623
01624 $oProduct = $this->getProduct();
01625 $iCount = $oProduct->oxarticles__oxratingcnt->value;
01626 if ( isset($iMin) && isset($iMax) && $iMax != '' && $iMin != '' && $iCount > 0 ) {
01627 $aNomalizedRating = array();
01628 $iValue = ((4*($oProduct->oxarticles__oxrating->value - $iMin)/($iMax - $iMin)))+1;
01629 $aNomalizedRating["count"] = $iCount;
01630 $aNomalizedRating["value"] = round($iValue, 2);
01631 return $aNomalizedRating;
01632 }
01633 return false;
01634 }
01635
01643 public function getRDFaValidityPeriod($sShopConfVar)
01644 {
01645 if ( $sShopConfVar ) {
01646 $aValidity = array();
01647 $iDays = $this->getConfig()->getConfigParam($sShopConfVar);
01648 $iFrom = oxRegistry::get("oxUtilsDate")->getTime();
01649
01650 $iThrough = $iFrom + ($iDays * 24 * 60 * 60);
01651 $aValidity["from"] = date('Y-m-d\TH:i:s', $iFrom)."Z";
01652 $aValidity["through"] = date('Y-m-d\TH:i:s', $iThrough)."Z";
01653
01654 return $aValidity;
01655 }
01656 return false;
01657 }
01658
01664 public function getRDFaBusinessFnc()
01665 {
01666 return $this->getConfig()->getConfigParam("sRDFaBusinessFnc");
01667 }
01668
01674 public function getRDFaCustomers()
01675 {
01676 return $this->getConfig()->getConfigParam("aRDFaCustomers");
01677 }
01678
01684 public function getRDFaVAT()
01685 {
01686 return $this->getConfig()->getConfigParam("iRDFaVAT");
01687 }
01688
01694 public function getRDFaGenericCondition()
01695 {
01696 return $this->getConfig()->getConfigParam("iRDFaCondition");
01697 }
01698
01704 public function getBundleArticle()
01705 {
01706 $oProduct = $this->getProduct();
01707 if ( $oProduct && $oProduct->oxarticles__oxbundleid->value ) {
01708 $oArticle = oxNew("oxarticle");
01709 $oArticle->load($oProduct->oxarticles__oxbundleid->value);
01710 return $oArticle;
01711 }
01712 return false;
01713 }
01714
01720 public function getRDFaPaymentMethods()
01721 {
01722 $iPrice = $this->getProduct()->getPrice()->getBruttoPrice();
01723 $oPayments = oxNew("oxpaymentlist");
01724 $oPayments->loadRDFaPaymentList($iPrice);
01725 return $oPayments;
01726 }
01727
01733 public function getRDFaDeliverySetMethods()
01734 {
01735 $oDelSets = oxNew("oxdeliverysetlist");
01736 $oDelSets->loadRDFaDeliverySetList();
01737 return $oDelSets;
01738 }
01739
01745 public function getProductsDeliveryList()
01746 {
01747 $oProduct = $this->getProduct();
01748 $oDelList = oxNew( "oxDeliveryList" );
01749 $oDelList->loadDeliveryListForProduct( $oProduct );
01750 return $oDelList;
01751 }
01752
01758 public function getRDFaDeliveryChargeSpecLoc()
01759 {
01760 return $this->getConfig()->getConfigParam("sRDFaDeliveryChargeSpecLoc");
01761 }
01762
01768 public function getRDFaPaymentChargeSpecLoc()
01769 {
01770 return $this->getConfig()->getConfigParam("sRDFaPaymentChargeSpecLoc");
01771 }
01772
01778 public function getRDFaBusinessEntityLoc()
01779 {
01780 return $this->getConfig()->getConfigParam("sRDFaBusinessEntityLoc");
01781 }
01782
01788 public function showRDFaProductStock()
01789 {
01790 return $this->getConfig()->getConfigParam("blShowRDFaProductStock");
01791 }
01792
01793 }