00001 <?php
00002
00010 class Details extends oxUBase
00011 {
00017 protected $_aVariantList = array();
00018
00024 protected $_sThisTemplate = 'details.tpl';
00025
00031 protected $_oParent = null;
00032
00038 protected $_blCanRate = null;
00039
00044 protected $_blShowSorting = true;
00045
00050 protected $_blEditTags = null;
00051
00056 protected $_aTags = null;
00057
00062 protected $_sTagCloud = null;
00063
00068 protected $_aUserRecommList = null;
00069
00074 protected $_sLoginFormAnchor = null;
00075
00080 protected $_oCaptcha = null;
00081
00086 protected $_aMediaFiles = null;
00087
00092 protected $_aLastProducts = null;
00093
00098 protected $_oVendor = null;
00099
00104 protected $_oCategory = null;
00105
00110 protected $_aAttributes = null;
00111
00116 protected $_sParentName = null;
00117
00122 protected $_sParentUrl = null;
00123
00128 protected $_aPicGallery = null;
00129
00134 protected $_aSelectLists = null;
00135
00140 protected $_aReviews = null;
00141
00146 protected $_oCrossSelling = null;
00147
00152 protected $_oSimilarProducts = null;
00153
00158 protected $_oRecommList = null;
00159
00164 protected $_oAccessoires = null;
00165
00170 protected $_aAlsoBoughtArts = null;
00171
00176 protected $_sSearchTitle = null;
00177
00185 protected function _getParentProduct( $sParentId )
00186 {
00187 if ( $sParentId && $this->_oParent === null ) {
00188 if ( ( $oParent = oxNewArticle( $sParentId ) ) ) {
00189 $this->_oParent = $oParent;
00190 } else {
00191 $this->_oParent = false;
00192 }
00193 }
00194 return $this->_oParent;
00195 }
00196
00203 public function loadVariantInformation()
00204 {
00205
00206 $this->_aVariantList = $this->_oProduct->getVariants();
00207
00208
00209 if ( ( $oParent = $this->_getParentProduct( $this->_oProduct->oxarticles__oxparentid->value ) ) && count( $this->_aVariantList ) == 0 ) {
00210 $myConfig = $this->getConfig();
00211
00212 $this->_aVariantList = $oParent->getVariants();
00213
00214
00215 if ( $oParent->blNotBuyableParent ) {
00216 $oParent->blNotBuyable = true;
00217 }
00218
00219
00220 if ( $myConfig->getConfigParam( 'blVariantParentBuyable' ) ) {
00221
00222 $oParent->aSelectlist = $oParent->getSelectLists();
00223 $this->_aVariantList = array_merge( array( $oParent ), $this->_aVariantList );
00224 }
00225
00226
00227 if ( isset( $this->_aVariantList[$this->_oProduct->getId()] ) ) {
00228 unset( $this->_aVariantList[$this->_oProduct->getId()] );
00229 }
00230 }
00231
00232 }
00233
00239 public function getViewId()
00240 {
00241 if ( isset( $this->_sViewId )) {
00242 return $this->_sViewId;
00243 }
00244
00245 $_sViewId = parent::getViewId().'|'.oxConfig::getParameter( 'anid' ).'|'.count( $this->_aVariantList ).'|';
00246
00247
00248 return $this->_sViewId = $_sViewId;
00249 }
00250
00256 public function getViewResetId()
00257 {
00258 $sId = parent::GetViewResetID();
00259 $sId .= '|anid='.$this->_oProduct->getId();
00260 if ( $this->_oProduct->oxarticles__oxparentid->value ) {
00261 $sId .= '|anid='.$this->_oProduct->oxarticles__oxparentid->value;
00262 }
00263
00264 return $sId;
00265 }
00266
00273 public function init()
00274 {
00275 parent::init();
00276
00277 $myConfig = $this->getConfig();
00278 $myUtils = oxUtils::getInstance();
00279
00280
00281
00282 $myConfig->setConfigParam( 'blLoadVariants', true );
00283
00284 $sOxid = oxConfig::getParameter( 'anid' );
00285
00286
00287 if ( !$this->_oProduct || ($this->_oProduct && $this->_oProduct->getId() == $sOxid ) ) {
00288 $this->_oProduct = oxNew( 'oxarticle' );
00289
00290
00291
00292
00293
00294
00295
00296
00297 $this->_oProduct->setSkipAbPrice( true);
00298
00299 if ( !$this->_oProduct->load( $sOxid ) ) {
00300 $myUtils->redirect( $myConfig->getShopHomeURL() );
00301 }
00302
00303 }
00304
00305
00306
00307 if ( $this->_oProduct->oxarticles__oxtemplate->value ) {
00308 $this->_sThisTemplate = $this->_oProduct->oxarticles__oxtemplate->value;
00309 }
00310
00311 if ( ( $sTplName = oxConfig::getParameter( 'tpl' ) ) ) {
00312 $this->_sThisTemplate = basename ( $sTplName );
00313 }
00314
00315 $this->loadVariantInformation();
00316
00317 if (oxConfig::getParameter( 'listtype' ) == 'vendor') {
00318 $this->_oProduct->setLinkType(1);
00319 }
00320 }
00321
00341 public function render()
00342 {
00343 $myConfig = $this->getConfig();
00344
00345
00346 $this->_oProduct->loadAmountPriceInfo();
00347
00348
00349 $this->_aViewData['product'] = $this->getProduct();
00350
00351 $this->_aViewData["aTags"] = $this->getTags();
00352 $this->_aViewData["blEditTags"] = $this->getEditTags();
00353 startProfile("tagCloud");
00354 $this->_aViewData['tagCloud'] = $this->getTagCloud();
00355 stopProfile("tagCloud");
00356
00357 $this->_aViewData['loginformanchor'] = $this->getLoginFormAnchor();
00358
00359 $this->_aViewData['ispricealarm'] = $this->isPriceAlarm();
00360
00361 $this->_aViewData['customerwho'] = $this->getAlsoBoughtThiesProducts();
00362 $this->_aViewData['accessoirelist'] = $this->getAccessoires();
00363
00364 $this->_aViewData['similarlist'] = $this->getSimilarProducts();
00365 $this->_aViewData['crossselllist'] = $this->getCrossSelling();
00366
00367 $this->_aViewData['variants'] = $this->getVariantList();
00368
00369 $this->_aViewData['reviews'] = $this->getReviews();
00370
00371 $this->_aViewData['selectlist'] = $this->getSelectLists();
00372
00373 $sSource = strtolower($this->_oProduct->oxarticles__oxlongdesc->value);
00374 $sSource = str_replace( array( '<br>', '<br />', '<br/>' ), "\n", $sSource );
00375 $sSource = strip_tags( $sSource );
00376
00377 $this->setMetaDescription( $this->_oProduct->oxarticles__oxtitle->value.' - '.$sSource, 200, true );
00378 if ( strlen( trim( $this->_oProduct->oxarticles__oxsearchkeys->value ) ) > 0 ) {
00379 $sSource = $this->_oProduct->oxarticles__oxsearchkeys->value.' '.$sSource;
00380 }
00381 $this->setMetaKeywords( $sSource );
00382
00383 $this->_aViewData["actpicid"] = $this->getActPictureId();
00384 $this->_aViewData["actpic"] = $this->getActPicture();
00385 $this->_aViewData['blMorePic'] = $this->morePics();
00386 $this->_aViewData['ArtPics'] = $this->getPictures();
00387 $this->_aViewData['ArtIcons'] = $this->getIcons();
00388 $this->_aViewData['blZoomPic'] = $this->showZoomPics();
00389 $this->_aViewData['aZoomPics'] = $this->getZoomPics();
00390 $this->_aViewData['iZoomPic'] = $this->getActZoomPic();
00391
00392 $this->_aViewData['parentname'] = $this->getParentName();
00393 $this->_aViewData['parent_url'] = $this->getParentUrl();
00394 $this->_aViewData['draw_parent_url'] = $this->drawParentUrl();
00395
00396 $this->_aViewData['pgNr'] = $this->getActPage();
00397
00398 parent::render();
00399
00400 $this->_aViewData['allartattr'] = $this->getAttributes();
00401
00402
00403 $this->_aViewData['oCategory'] = $this->getCategory();
00404
00405 $this->_aViewData['oVendor'] = $this->getVendor();
00406
00407 $this->_aViewData['aLastProducts'] = $this->getLastProducts();
00408
00409
00410 $oLocator = oxNew( 'oxlocator', $this->getListType() );
00411 $oLocator->setLocatorData( $this->_oProduct, $this );
00412
00413
00414 $this->_aViewData['aMediaUrls'] = $this->getMediaFiles();
00415
00416 if (in_array('oxrss_recommlists', $myConfig->getConfigParam( 'aRssSelected' )) && $this->getSimilarRecommLists()) {
00417 $oRss = oxNew('oxrssfeed');
00418 $this->addRssFeed($oRss->getRecommListsTitle($this->_oProduct), $oRss->getRecommListsUrl($this->_oProduct), 'recommlists');
00419 }
00420
00421
00422
00423 $this->_aViewData['oCaptcha'] = $this->getCaptcha();
00424 $this->_aViewData['sSearchTitle'] = $this->getSearchTitle();
00425 $this->_aViewData['actCatpath'] = $this->getCatTreePath();
00426
00427 return $this->_sThisTemplate;
00428 }
00429
00435 public function canRate()
00436 {
00437 if ( $this->_blCanRate === null ) {
00438
00439 $this->_blCanRate = false;
00440 $myConfig = $this->getConfig();
00441
00442 if ( $myConfig->getConfigParam( 'bl_perfLoadReviews' ) &&
00443 $oUser = $this->getUser() ) {
00444
00445 $oRating = oxNew( 'oxrating' );
00446 $this->_blCanRate = $oRating->allowRating( $oUser->getId(), 'oxarticle', $this->_oProduct->getId() );
00447 }
00448 }
00449 return $this->_blCanRate;
00450 }
00451
00457 public function saveReview()
00458 {
00459 $sReviewText = trim( ( string ) oxConfig::getParameter( 'rvw_txt' , true ) );
00460 $dRating = oxConfig::getParameter( 'artrating' );
00461 if ($dRating < 0 || $dRating > 5) {
00462 $dRating = null;
00463 }
00464
00465 $sArtId = oxConfig::getParameter( 'anid' );
00466 $sUserId = oxSession::getVar( 'usr' );
00467
00468
00469 if ( $dRating ) {
00470 $oRating = oxNew( 'oxrating' );
00471 $blRate = $oRating->allowRating( $sUserId, 'oxarticle', $this->_oProduct->getId());
00472 if ( $blRate) {
00473 $oRating->oxratings__oxuserid = new oxField($sUserId);
00474 $oRating->oxratings__oxtype = new oxField('oxarticle', oxField::T_RAW);
00475 $oRating->oxratings__oxobjectid = new oxField($sArtId);
00476 $oRating->oxratings__oxrating = new oxField($dRating);
00477 $oRating->save();
00478 $this->_oProduct->addToRatingAverage( $dRating);
00479 } else {
00480 $dRating = null;
00481 }
00482 }
00483
00484 if ( $sReviewText ) {
00485 $oReview = oxNew( 'oxreview' );
00486 $oReview->oxreviews__oxobjectid = new oxField($sArtId);
00487 $oReview->oxreviews__oxtype = new oxField('oxarticle', oxField::T_RAW);
00488 $oReview->oxreviews__oxtext = new oxField($sReviewText, oxField::T_RAW);
00489 $oReview->oxreviews__oxlang = new oxField(oxLang::getInstance()->getBaseLanguage());
00490 $oReview->oxreviews__oxuserid = new oxField($sUserId);
00491 $oReview->oxreviews__oxrating = new oxField(( $dRating) ? $dRating : null);
00492 $oReview->save();
00493 }
00494 }
00495
00501 public function showLogin()
00502 {
00503 $this->_sThisTemplate = 'account_login.tpl';
00504
00505 $sAnchor = oxConfig::getInstance()->getParameter("anchor");
00506 if ($sAnchor)
00507 $this->_sLoginFormAnchor = $sAnchor;
00508 }
00509
00515 public function addToRecomm()
00516 {
00517 $sRecommText = trim( ( string ) oxConfig::getParameter( 'recomm_txt' ) );
00518 $sRecommList = oxConfig::getParameter( 'recomm' );
00519 $sArtId = oxConfig::getParameter( 'anid' );
00520
00521 if ( $sArtId ) {
00522 $oRecomm = oxNew( 'oxrecommlist' );
00523 $oRecomm->load( $sRecommList);
00524 $oRecomm->addArticle( $sArtId, $sRecommText );
00525 }
00526 }
00527
00533 public function addTags()
00534 {
00535 $sTag = $this->getConfig()->getParameter('newTags', 1);
00536 $sTag .= " ".html_entity_decode($this->getConfig()->getParameter('highTags', 1));
00537
00538 $this->_oProduct->addTag($sTag);
00539
00540
00541 $oTagHandler = oxNew('oxTagCloud');
00542 $this->_sTagCloud = $oTagHandler->getTagCloud($this->_oProduct->getId());
00543 }
00544
00545 public function editTags()
00546 {
00547 $oTagCloud = oxNew("oxTagCloud");
00548 $this->_aTags = $oTagCloud->getTags($this->_oProduct->getId());
00549 $this->_blEditTags = true;
00550 }
00551
00557 protected function _getSeoObjectId()
00558 {
00559 if ( isset( $this->_oProduct ) ) {
00560 return $this->_oProduct->getId();
00561 }
00562 }
00563
00569 public function getAttributes()
00570 {
00571 if ( $this->_aAttributes === null ) {
00572
00573 $aArtAttributes = $this->_oProduct->getAttributes();
00574
00575
00576 $this->_aAttributes = array();
00577 if ( count( $aArtAttributes ) ) {
00578 foreach ( $aArtAttributes as $sKey => $oAttribute ) {
00579 $this->_aAttributes[$sKey] = new stdClass();
00580 $this->_aAttributes[$sKey]->title = $oAttribute->oxattribute__oxtitle->value;
00581 $this->_aAttributes[$sKey]->value = $oAttribute->oxattribute__oxvalue->value;
00582 }
00583 }
00584 }
00585
00586 return $this->_aAttributes;
00587 }
00588
00589
00595 public function getEditTags()
00596 {
00597 return $this->_blEditTags;
00598 }
00599
00605 public function getTags()
00606 {
00607 return $this->_aTags;
00608 }
00609
00615 public function getTagCloud()
00616 {
00617 if ( $this->_sTagCloud === null ) {
00618 $this->_sTagCloud = false;
00619 $oTagHandler = oxNew('oxTagCloud');
00620 $this->_sTagCloud = $oTagHandler->getTagCloud($this->getProduct()->getId());
00621 }
00622 return $this->_sTagCloud;
00623 }
00624
00625
00631 public function getLoginFormAnchor()
00632 {
00633 return $this->_sLoginFormAnchor;
00634 }
00635
00641 public function getProduct()
00642 {
00643 return $this->_oProduct;
00644 }
00645
00651 public function getVariantList()
00652 {
00653 return $this->_aVariantList;
00654 }
00655
00661 public function getCaptcha()
00662 {
00663 if ( $this->_oCaptcha === null ) {
00664 $this->_oCaptcha = oxNew('oxCaptcha');
00665 }
00666 return $this->_oCaptcha;
00667 }
00668
00674 public function getMediaFiles()
00675 {
00676 if ( $this->_aMediaFiles === null ) {
00677 $aMediaFiles = $this->getProduct()->getMediaUrls();
00678 $this->_aMediaFiles = count($aMediaFiles) ? $aMediaFiles : false;
00679 }
00680 return $this->_aMediaFiles;
00681 }
00682
00688 public function getLastProducts()
00689 {
00690 if ( $this->_aLastProducts === null ) {
00691
00692 $sArtId = $this->_oProduct->oxarticles__oxparentid->value?$this->_oProduct->oxarticles__oxparentid->value:$this->_oProduct->getId();
00693
00694 $oHistoryArtList = oxNew( 'oxarticlelist' );
00695 $oHistoryArtList->loadHistoryArticles( $sArtId );
00696 $this->_aLastProducts = $oHistoryArtList;
00697 }
00698 return $this->_aLastProducts;
00699 }
00700
00706 public function getVendor()
00707 {
00708 if ( $this->_oVendor === null ) {
00709 $this->_oVendor = false;
00710
00711 if ( $this->getConfig()->getConfigParam( 'bl_perfLoadVendorTree' ) && ( $oVendor = $this->_oProduct->getVendor( false ) ) ) {
00712 $this->_oVendor = $oVendor;
00713 }
00714 }
00715 return $this->_oVendor;
00716 }
00717
00723 public function getCategory()
00724 {
00725 if ( $this->_oCategory === null ) {
00726 $this->_oCategory = false;
00727 $this->_oCategory = $this->_oProduct->getCategory();
00728 }
00729 return $this->_oCategory;
00730 }
00731
00737 public function drawParentUrl()
00738 {
00739 if ( ( $oParent = $this->_getParentProduct( $this->_oProduct->oxarticles__oxparentid->value ) ) ) {
00740 if ( $this->getConfig()->getConfigParam( 'blVariantParentBuyable' ) || count( $this->_aVariantList ) > 0 ) {
00741 return true;
00742 }
00743 }
00744 }
00745
00751 public function getParentName()
00752 {
00753 if ( $this->_sParentName === null ) {
00754 $this->_sParentName = false;
00755 if ( ( $oParent = $this->_getParentProduct( $this->_oProduct->oxarticles__oxparentid->value ) ) ) {
00756 $this->_sParentName = $oParent->oxarticles__oxtitle->value;
00757 }
00758 }
00759 return $this->_sParentName;
00760 }
00761
00767 public function getParentUrl()
00768 {
00769 if ( $this->_sParentUrl === null ) {
00770 $this->_sParentUrl = false;
00771 if ( ( $oParent = $this->_getParentProduct( $this->_oProduct->oxarticles__oxparentid->value ) ) ) {
00772 $this->_sParentUrl = $oParent->oxdetaillink;
00773 }
00774 }
00775 return $this->_sParentUrl;
00776 }
00777
00783 public function getPictureGallery()
00784 {
00785 if ( $this->_aPicGallery === null ) {
00786 $this->_aPicGallery = false;
00787
00788 $this->_aPicGallery = $this->_oProduct->getPictureGallery();
00789 }
00790 return $this->_aPicGallery;
00791 }
00792
00798 public function getActPictureId()
00799 {
00800 $aPicGallery = $this->getPictureGallery();
00801 return $aPicGallery['ActPicID'];
00802 }
00803
00809 public function getActPicture()
00810 {
00811 $aPicGallery = $this->getPictureGallery();
00812 return $aPicGallery['ActPic'];
00813 }
00814
00820 public function morePics()
00821 {
00822 $aPicGallery = $this->getPictureGallery();
00823 return $aPicGallery['MorePics'];
00824 }
00825
00831 public function getPictures()
00832 {
00833 $aPicGallery = $this->getPictureGallery();
00834 return $aPicGallery['Pics'];
00835 }
00836
00844 public function getArtPic( $sPicNr )
00845 {
00846 $aPicGallery = $this->getPictureGallery();
00847 return $aPicGallery['Pics'][$sPicNr];
00848 }
00849
00855 public function getIcons()
00856 {
00857 $aPicGallery = $this->getPictureGallery();
00858 return $aPicGallery['Icons'];
00859 }
00860
00866 public function showZoomPics()
00867 {
00868 $aPicGallery = $this->getPictureGallery();
00869 return $aPicGallery['ZoomPic'];
00870 }
00871
00877 public function getZoomPics()
00878 {
00879 $aPicGallery = $this->getPictureGallery();
00880 return $aPicGallery['ZoomPics'];
00881 }
00882
00888 public function getActZoomPic()
00889 {
00890 return 1;
00891 }
00892
00898 public function getSelectLists()
00899 {
00900 if ( $this->_aSelectLists === null ) {
00901 $this->_aSelectLists = false;
00902 if ( $this->getConfig()->getConfigParam( 'bl_perfLoadSelectLists' ) ) {
00903 $this->_aSelectLists = $this->_oProduct->getSelectLists();
00904 }
00905 }
00906 return $this->_aSelectLists;
00907 }
00908
00914 public function getReviews()
00915 {
00916 if ( $this->_aReviews === null ) {
00917 $this->_aReviews = false;
00918 $myConfig = $this->getConfig();
00919 if ( $myConfig->getConfigParam( 'bl_perfLoadReviews' ) ) {
00920 $this->_aReviews = $this->_oProduct->getReviews();
00921 }
00922 }
00923 return $this->_aReviews;
00924 }
00925
00931 public function getCrossSelling()
00932 {
00933 if ( $this->_oCrossSelling === null ) {
00934 $this->_oCrossSelling = false;
00935 if ( $this->_oProduct ) {
00936 $this->_oCrossSelling = $this->_oProduct->getCrossSelling();
00937 }
00938 }
00939 return $this->_oCrossSelling;
00940 }
00941
00947 public function getSimilarProducts()
00948 {
00949 if ( $this->_oSimilarProducts === null ) {
00950 $this->_oSimilarProducts = false;
00951 if ( $this->_oProduct ) {
00952 $this->_oSimilarProducts = $this->_oProduct->getSimilarProducts();
00953 }
00954 }
00955 return $this->_oSimilarProducts;
00956 }
00957
00963 public function getSimilarRecommLists()
00964 {
00965 if ( $this->_oRecommList === null ) {
00966 $this->_oRecommList = false;
00967 if ( $this->_oProduct ) {
00968 $oRecommList = oxNew('oxrecommlist');
00969 $this->_oRecommList = $oRecommList->getRecommListsByIds( array($this->_oProduct->getId()));
00970 }
00971 }
00972 return $this->_oRecommList;
00973 }
00974
00980 public function getAccessoires()
00981 {
00982 if ( $this->_oAccessoires === null ) {
00983 $this->_oAccessoires = false;
00984 if ( $this->_oProduct ) {
00985 $this->_oAccessoires = $this->_oProduct->getAccessoires();
00986 }
00987 }
00988 return $this->_oAccessoires;
00989 }
00990
00996 public function getAlsoBoughtThiesProducts()
00997 {
00998 if ( $this->_aAlsoBoughtArts === null ) {
00999 $this->_aAlsoBoughtArts = false;
01000 if ( $this->_oProduct ) {
01001 $this->_aAlsoBoughtArts = $this->_oProduct->getCustomerAlsoBoughtThisProducts();
01002 }
01003 }
01004 return $this->_aAlsoBoughtArts;
01005 }
01006
01012 public function isPriceAlarm()
01013 {
01014
01015 if ( isset($this->_oProduct->oxarticles__oxblfixedprice->value) && $this->_oProduct->oxarticles__oxblfixedprice->value) {
01016 return 0;
01017 }
01018 return 1;
01019 }
01020
01027 protected function getSubject()
01028 {
01029 return $this->_oProduct;
01030 }
01031
01037 public function getSearchTitle()
01038 {
01039 return $this->_sSearchTitle;
01040 }
01041
01049 public function setSearchTitle( $sTitle )
01050 {
01051 $this->_sSearchTitle = $sTitle;
01052 }
01053
01061 public function setCatTreePath( $sActCatPath )
01062 {
01063 $this->_sCatTreePath = $sActCatPath;
01064 }
01065
01072 public function noIndex()
01073 {
01074 if (oxConfig::getParameter( 'listtype' ) == 'vendor') {
01075 return $this->_iViewIndexState = 2;
01076 }
01077 return parent::noIndex();
01078 }
01079
01085 public function getTitle()
01086 {
01087 if ( $this->_oProduct ) {
01088 return $this->_oProduct->oxarticles__oxtitle->value . ( $this->_oProduct->oxarticles__oxvarselect->value ? ' ' . $this->_oProduct->oxarticles__oxvarselect->value : '' );
01089 }
01090 }
01091 }