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( false );
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( false );
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->getArray() );
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 if ( !$this->_oProduct->isVisible() ) {
00306 $myUtils->redirect($myConfig->getShopHomeURL());
00307 }
00308
00309
00310 if ( $this->_oProduct->oxarticles__oxtemplate->value ) {
00311 $this->_sThisTemplate = $this->_oProduct->oxarticles__oxtemplate->value;
00312 }
00313
00314 if ( ( $sTplName = oxConfig::getParameter( 'tpl' ) ) ) {
00315 $this->_sThisTemplate = basename ( $sTplName );
00316 }
00317
00318 $this->loadVariantInformation();
00319
00320 if (oxConfig::getParameter( 'listtype' ) == 'vendor') {
00321 $this->_oProduct->setLinkType(1);
00322 }
00323 }
00324
00344 public function render()
00345 {
00346 $myConfig = $this->getConfig();
00347
00348
00349 $this->_oProduct->loadAmountPriceInfo();
00350
00351
00352 $this->_aViewData['product'] = $this->getProduct();
00353
00354 $this->_aViewData["aTags"] = $this->getTags();
00355 $this->_aViewData["blEditTags"] = $this->getEditTags();
00356 startProfile("tagCloud");
00357 $this->_aViewData['tagCloud'] = $this->getTagCloud();
00358 stopProfile("tagCloud");
00359
00360 $this->_aViewData['loginformanchor'] = $this->getLoginFormAnchor();
00361
00362 $this->_aViewData['ispricealarm'] = $this->isPriceAlarm();
00363
00364 $this->_aViewData['customerwho'] = $this->getAlsoBoughtThiesProducts();
00365 $this->_aViewData['accessoirelist'] = $this->getAccessoires();
00366
00367 $this->_aViewData['similarlist'] = $this->getSimilarProducts();
00368 $this->_aViewData['crossselllist'] = $this->getCrossSelling();
00369
00370 $this->_aViewData['variants'] = $this->getVariantList();
00371
00372 $this->_aViewData['reviews'] = $this->getReviews();
00373
00374 $this->_aViewData['selectlist'] = $this->getSelectLists();
00375
00376 $sSource = strtolower($this->_oProduct->oxarticles__oxlongdesc->value);
00377 $sSource = str_replace( array( '<br>', '<br />', '<br/>' ), "\n", $sSource );
00378 $sSource = strip_tags( $sSource );
00379
00380 $this->setMetaDescription( $this->_oProduct->oxarticles__oxtitle->value.' - '.$sSource, 200, true );
00381 if ( strlen( trim( $this->_oProduct->oxarticles__oxsearchkeys->value ) ) > 0 ) {
00382 $sSource = $this->_oProduct->oxarticles__oxsearchkeys->value.' '.$sSource;
00383 }
00384 $this->setMetaKeywords( $sSource );
00385
00386 $this->_aViewData["actpicid"] = $this->getActPictureId();
00387 $this->_aViewData["actpic"] = $this->getActPicture();
00388 $this->_aViewData['blMorePic'] = $this->morePics();
00389 $this->_aViewData['ArtPics'] = $this->getPictures();
00390 $this->_aViewData['ArtIcons'] = $this->getIcons();
00391 $this->_aViewData['blZoomPic'] = $this->showZoomPics();
00392 $this->_aViewData['aZoomPics'] = $this->getZoomPics();
00393 $this->_aViewData['iZoomPic'] = $this->getActZoomPic();
00394
00395 $this->_aViewData['parentname'] = $this->getParentName();
00396 $this->_aViewData['parent_url'] = $this->getParentUrl();
00397 $this->_aViewData['draw_parent_url'] = $this->drawParentUrl();
00398
00399 $this->_aViewData['pgNr'] = $this->getActPage();
00400
00401 parent::render();
00402
00403 $this->_aViewData['allartattr'] = $this->getAttributes();
00404
00405
00406 $this->_aViewData['oCategory'] = $this->getCategory();
00407
00408 $this->_aViewData['oVendor'] = $this->getVendor();
00409
00410 $this->_aViewData['aLastProducts'] = $this->getLastProducts();
00411
00412
00413 $oLocator = oxNew( 'oxlocator', $this->getListType() );
00414 $oLocator->setLocatorData( $this->_oProduct, $this );
00415
00416
00417 $this->_aViewData['aMediaUrls'] = $this->getMediaFiles();
00418
00419 if (in_array('oxrss_recommlists', $myConfig->getConfigParam( 'aRssSelected' )) && $this->getSimilarRecommLists()) {
00420 $oRss = oxNew('oxrssfeed');
00421 $this->addRssFeed($oRss->getRecommListsTitle($this->_oProduct), $oRss->getRecommListsUrl($this->_oProduct), 'recommlists');
00422 }
00423
00424
00425
00426 $this->_aViewData['oCaptcha'] = $this->getCaptcha();
00427 $this->_aViewData['sSearchTitle'] = $this->getSearchTitle();
00428 $this->_aViewData['actCatpath'] = $this->getCatTreePath();
00429
00430 return $this->_sThisTemplate;
00431 }
00432
00438 public function canRate()
00439 {
00440 if ( $this->_blCanRate === null ) {
00441
00442 $this->_blCanRate = false;
00443 $myConfig = $this->getConfig();
00444
00445 if ( $myConfig->getConfigParam( 'bl_perfLoadReviews' ) &&
00446 $oUser = $this->getUser() ) {
00447
00448 $oRating = oxNew( 'oxrating' );
00449 $this->_blCanRate = $oRating->allowRating( $oUser->getId(), 'oxarticle', $this->_oProduct->getId() );
00450 }
00451 }
00452 return $this->_blCanRate;
00453 }
00454
00460 public function saveReview()
00461 {
00462 $sReviewText = trim( ( string ) oxConfig::getParameter( 'rvw_txt' , true ) );
00463 $dRating = oxConfig::getParameter( 'artrating' );
00464 if ($dRating < 0 || $dRating > 5) {
00465 $dRating = null;
00466 }
00467
00468 $sArtId = oxConfig::getParameter( 'anid' );
00469 $sUserId = oxSession::getVar( 'usr' );
00470
00471
00472 if ( $dRating ) {
00473 $oRating = oxNew( 'oxrating' );
00474 $blRate = $oRating->allowRating( $sUserId, 'oxarticle', $this->_oProduct->getId());
00475 if ( $blRate) {
00476 $oRating->oxratings__oxuserid = new oxField($sUserId);
00477 $oRating->oxratings__oxtype = new oxField('oxarticle', oxField::T_RAW);
00478 $oRating->oxratings__oxobjectid = new oxField($sArtId);
00479 $oRating->oxratings__oxrating = new oxField($dRating);
00480 $oRating->save();
00481 $this->_oProduct->addToRatingAverage( $dRating);
00482 } else {
00483 $dRating = null;
00484 }
00485 }
00486
00487 if ( $sReviewText ) {
00488 $oReview = oxNew( 'oxreview' );
00489 $oReview->oxreviews__oxobjectid = new oxField($sArtId);
00490 $oReview->oxreviews__oxtype = new oxField('oxarticle', oxField::T_RAW);
00491 $oReview->oxreviews__oxtext = new oxField($sReviewText, oxField::T_RAW);
00492 $oReview->oxreviews__oxlang = new oxField(oxLang::getInstance()->getBaseLanguage());
00493 $oReview->oxreviews__oxuserid = new oxField($sUserId);
00494 $oReview->oxreviews__oxrating = new oxField(( $dRating) ? $dRating : null);
00495 $oReview->save();
00496 }
00497 }
00498
00504 public function showLogin()
00505 {
00506 $this->_sThisTemplate = 'account_login.tpl';
00507
00508 $sAnchor = oxConfig::getInstance()->getParameter("anchor");
00509 if ($sAnchor)
00510 $this->_sLoginFormAnchor = $sAnchor;
00511 }
00512
00518 public function addToRecomm()
00519 {
00520 $sRecommText = trim( ( string ) oxConfig::getParameter( 'recomm_txt' ) );
00521 $sRecommList = oxConfig::getParameter( 'recomm' );
00522 $sArtId = oxConfig::getParameter( 'anid' );
00523
00524 if ( $sArtId ) {
00525 $oRecomm = oxNew( 'oxrecommlist' );
00526 $oRecomm->load( $sRecommList);
00527 $oRecomm->addArticle( $sArtId, $sRecommText );
00528 }
00529 }
00530
00536 public function addTags()
00537 {
00538 $sTag = $this->getConfig()->getParameter('newTags', 1);
00539 $sTag .= " ".html_entity_decode($this->getConfig()->getParameter('highTags', 1));
00540
00541 $this->_oProduct->addTag($sTag);
00542
00543
00544 $oTagHandler = oxNew('oxTagCloud');
00545 $this->_sTagCloud = $oTagHandler->getTagCloud($this->_oProduct->getId());
00546 }
00547
00548 public function editTags()
00549 {
00550 $oTagCloud = oxNew("oxTagCloud");
00551 $this->_aTags = $oTagCloud->getTags($this->_oProduct->getId());
00552 $this->_blEditTags = true;
00553 }
00554
00560 protected function _getSeoObjectId()
00561 {
00562 if ( isset( $this->_oProduct ) ) {
00563 return $this->_oProduct->getId();
00564 }
00565 }
00566
00572 public function getAttributes()
00573 {
00574 if ( $this->_aAttributes === null ) {
00575
00576 $aArtAttributes = $this->_oProduct->getAttributes();
00577
00578
00579 $this->_aAttributes = array();
00580 if ( count( $aArtAttributes ) ) {
00581 foreach ( $aArtAttributes as $sKey => $oAttribute ) {
00582 $this->_aAttributes[$sKey] = new stdClass();
00583 $this->_aAttributes[$sKey]->title = $oAttribute->oxattribute__oxtitle->value;
00584 $this->_aAttributes[$sKey]->value = $oAttribute->oxattribute__oxvalue->value;
00585 }
00586 }
00587 }
00588
00589 return $this->_aAttributes;
00590 }
00591
00592
00598 public function getEditTags()
00599 {
00600 return $this->_blEditTags;
00601 }
00602
00608 public function getTags()
00609 {
00610 return $this->_aTags;
00611 }
00612
00618 public function getTagCloud()
00619 {
00620 if ( $this->_sTagCloud === null ) {
00621 $this->_sTagCloud = false;
00622 $oTagHandler = oxNew('oxTagCloud');
00623 $this->_sTagCloud = $oTagHandler->getTagCloud($this->getProduct()->getId());
00624 }
00625 return $this->_sTagCloud;
00626 }
00627
00628
00634 public function getLoginFormAnchor()
00635 {
00636 return $this->_sLoginFormAnchor;
00637 }
00638
00644 public function getProduct()
00645 {
00646 return $this->_oProduct;
00647 }
00648
00654 public function getVariantList()
00655 {
00656 return $this->_aVariantList;
00657 }
00658
00664 public function getCaptcha()
00665 {
00666 if ( $this->_oCaptcha === null ) {
00667 $this->_oCaptcha = oxNew('oxCaptcha');
00668 }
00669 return $this->_oCaptcha;
00670 }
00671
00677 public function getMediaFiles()
00678 {
00679 if ( $this->_aMediaFiles === null ) {
00680 $aMediaFiles = $this->getProduct()->getMediaUrls();
00681 $this->_aMediaFiles = count($aMediaFiles) ? $aMediaFiles : false;
00682 }
00683 return $this->_aMediaFiles;
00684 }
00685
00691 public function getLastProducts()
00692 {
00693 if ( $this->_aLastProducts === null ) {
00694
00695 $sArtId = $this->_oProduct->oxarticles__oxparentid->value?$this->_oProduct->oxarticles__oxparentid->value:$this->_oProduct->getId();
00696
00697 $oHistoryArtList = oxNew( 'oxarticlelist' );
00698 $oHistoryArtList->loadHistoryArticles( $sArtId );
00699 $this->_aLastProducts = $oHistoryArtList;
00700 }
00701 return $this->_aLastProducts;
00702 }
00703
00709 public function getVendor()
00710 {
00711 if ( $this->_oVendor === null ) {
00712 $this->_oVendor = false;
00713
00714 if ( $this->getConfig()->getConfigParam( 'bl_perfLoadVendorTree' ) && ( $oVendor = $this->_oProduct->getVendor( false ) ) ) {
00715 $this->_oVendor = $oVendor;
00716 }
00717 }
00718 return $this->_oVendor;
00719 }
00720
00726 public function getCategory()
00727 {
00728 if ( $this->_oCategory === null ) {
00729 $this->_oCategory = false;
00730 $this->_oCategory = $this->_oProduct->getCategory();
00731 }
00732 return $this->_oCategory;
00733 }
00734
00740 public function drawParentUrl()
00741 {
00742 if ( ( $oParent = $this->_getParentProduct( $this->_oProduct->oxarticles__oxparentid->value ) ) ) {
00743 if ( $this->getConfig()->getConfigParam( 'blVariantParentBuyable' ) || count( $this->_aVariantList ) > 0 ) {
00744 return true;
00745 }
00746 }
00747 }
00748
00754 public function getParentName()
00755 {
00756 if ( $this->_sParentName === null ) {
00757 $this->_sParentName = false;
00758 if ( ( $oParent = $this->_getParentProduct( $this->_oProduct->oxarticles__oxparentid->value ) ) ) {
00759 $this->_sParentName = $oParent->oxarticles__oxtitle->value;
00760 }
00761 }
00762 return $this->_sParentName;
00763 }
00764
00770 public function getParentUrl()
00771 {
00772 if ( $this->_sParentUrl === null ) {
00773 $this->_sParentUrl = false;
00774 if ( ( $oParent = $this->_getParentProduct( $this->_oProduct->oxarticles__oxparentid->value ) ) ) {
00775 $this->_sParentUrl = $oParent->oxdetaillink;
00776 }
00777 }
00778 return $this->_sParentUrl;
00779 }
00780
00786 public function getPictureGallery()
00787 {
00788 if ( $this->_aPicGallery === null ) {
00789 $this->_aPicGallery = false;
00790
00791 $this->_aPicGallery = $this->_oProduct->getPictureGallery();
00792 }
00793 return $this->_aPicGallery;
00794 }
00795
00801 public function getActPictureId()
00802 {
00803 $aPicGallery = $this->getPictureGallery();
00804 return $aPicGallery['ActPicID'];
00805 }
00806
00812 public function getActPicture()
00813 {
00814 $aPicGallery = $this->getPictureGallery();
00815 return $aPicGallery['ActPic'];
00816 }
00817
00823 public function morePics()
00824 {
00825 $aPicGallery = $this->getPictureGallery();
00826 return $aPicGallery['MorePics'];
00827 }
00828
00834 public function getPictures()
00835 {
00836 $aPicGallery = $this->getPictureGallery();
00837 return $aPicGallery['Pics'];
00838 }
00839
00847 public function getArtPic( $sPicNr )
00848 {
00849 $aPicGallery = $this->getPictureGallery();
00850 return $aPicGallery['Pics'][$sPicNr];
00851 }
00852
00858 public function getIcons()
00859 {
00860 $aPicGallery = $this->getPictureGallery();
00861 return $aPicGallery['Icons'];
00862 }
00863
00869 public function showZoomPics()
00870 {
00871 $aPicGallery = $this->getPictureGallery();
00872 return $aPicGallery['ZoomPic'];
00873 }
00874
00880 public function getZoomPics()
00881 {
00882 $aPicGallery = $this->getPictureGallery();
00883 return $aPicGallery['ZoomPics'];
00884 }
00885
00891 public function getActZoomPic()
00892 {
00893 return 1;
00894 }
00895
00901 public function getSelectLists()
00902 {
00903 if ( $this->_aSelectLists === null ) {
00904 $this->_aSelectLists = false;
00905 if ( $this->getConfig()->getConfigParam( 'bl_perfLoadSelectLists' ) ) {
00906 $this->_aSelectLists = $this->_oProduct->getSelectLists();
00907 }
00908 }
00909 return $this->_aSelectLists;
00910 }
00911
00917 public function getReviews()
00918 {
00919 if ( $this->_aReviews === null ) {
00920 $this->_aReviews = false;
00921 $myConfig = $this->getConfig();
00922 if ( $myConfig->getConfigParam( 'bl_perfLoadReviews' ) ) {
00923 $this->_aReviews = $this->_oProduct->getReviews();
00924 }
00925 }
00926 return $this->_aReviews;
00927 }
00928
00934 public function getCrossSelling()
00935 {
00936 if ( $this->_oCrossSelling === null ) {
00937 $this->_oCrossSelling = false;
00938 if ( $this->_oProduct ) {
00939 $this->_oCrossSelling = $this->_oProduct->getCrossSelling();
00940 }
00941 }
00942 return $this->_oCrossSelling;
00943 }
00944
00950 public function getSimilarProducts()
00951 {
00952 if ( $this->_oSimilarProducts === null ) {
00953 $this->_oSimilarProducts = false;
00954 if ( $this->_oProduct ) {
00955 $this->_oSimilarProducts = $this->_oProduct->getSimilarProducts();
00956 }
00957 }
00958 return $this->_oSimilarProducts;
00959 }
00960
00966 public function getSimilarRecommLists()
00967 {
00968 if ( $this->_oRecommList === null ) {
00969 $this->_oRecommList = false;
00970 if ( $this->_oProduct ) {
00971 $oRecommList = oxNew('oxrecommlist');
00972 $this->_oRecommList = $oRecommList->getRecommListsByIds( array($this->_oProduct->getId()));
00973 }
00974 }
00975 return $this->_oRecommList;
00976 }
00977
00983 public function getAccessoires()
00984 {
00985 if ( $this->_oAccessoires === null ) {
00986 $this->_oAccessoires = false;
00987 if ( $this->_oProduct ) {
00988 $this->_oAccessoires = $this->_oProduct->getAccessoires();
00989 }
00990 }
00991 return $this->_oAccessoires;
00992 }
00993
00999 public function getAlsoBoughtThiesProducts()
01000 {
01001 if ( $this->_aAlsoBoughtArts === null ) {
01002 $this->_aAlsoBoughtArts = false;
01003 if ( $this->_oProduct ) {
01004 $this->_aAlsoBoughtArts = $this->_oProduct->getCustomerAlsoBoughtThisProducts();
01005 }
01006 }
01007 return $this->_aAlsoBoughtArts;
01008 }
01009
01015 public function isPriceAlarm()
01016 {
01017
01018 if ( isset($this->_oProduct->oxarticles__oxblfixedprice->value) && $this->_oProduct->oxarticles__oxblfixedprice->value) {
01019 return 0;
01020 }
01021 return 1;
01022 }
01023
01030 protected function getSubject()
01031 {
01032 return $this->_oProduct;
01033 }
01034
01040 public function getSearchTitle()
01041 {
01042 return $this->_sSearchTitle;
01043 }
01044
01052 public function setSearchTitle( $sTitle )
01053 {
01054 $this->_sSearchTitle = $sTitle;
01055 }
01056
01064 public function setCatTreePath( $sActCatPath )
01065 {
01066 $this->_sCatTreePath = $sActCatPath;
01067 }
01068
01075 public function noIndex()
01076 {
01077 if (oxConfig::getParameter( 'listtype' ) == 'vendor') {
01078 return $this->_iViewIndexState = 2;
01079 }
01080 return parent::noIndex();
01081 }
01082
01088 public function getTitle()
01089 {
01090 if ( $this->_oProduct ) {
01091 return $this->_oProduct->oxarticles__oxtitle->value . ( $this->_oProduct->oxarticles__oxvarselect->value ? ' ' . $this->_oProduct->oxarticles__oxvarselect->value : '' );
01092 }
01093 }
01094 }