details.php

Go to the documentation of this file.
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 $_blTop5Action = false;
00215 
00220     protected $_sBidPrice = null;
00221 
00226     protected $_iPriceAlarmStatus = null;
00227 
00232     protected $_sSearchParamForHtml = null;
00233 
00241     protected function _getParentProduct( $sParentId )
00242     {
00243         if ( $sParentId && $this->_oParentProd === null ) {
00244             $this->_oParentProd = false;
00245             if ( ( $oParent = oxNewArticle( $sParentId ) ) ) {
00246                 $this->_processProduct( $oParent );
00247                 $this->_oParentProd = $oParent;
00248             }
00249         }
00250         return $this->_oParentProd;
00251     }
00252 
00259     public function loadVariantInformation()
00260     {
00261         if ( $this->_aVariantList === null ) {
00262             $oProduct = $this->getProduct();
00263 
00264             //if we are child and do not have any variants then let's load all parent variants as ours
00265             if ( $oParent = $oProduct->getParentArticle() ) {
00266                 $myConfig = $this->getConfig();
00267 
00268                 $oParent->setNoVariantLoading(false);
00269                 $this->_aVariantList = $oParent->getFullVariants( false );
00270 
00271                 //lets additionally add parent article if it is sellable
00272                 if ( count( $this->_aVariantList ) && $myConfig->getConfigParam( 'blVariantParentBuyable' ) ) {
00273                     //#1104S if parent is buyable load selectlists too
00274                     $oParent->aSelectlist = $oParent->getSelectLists();
00275                     $this->_aVariantList = array_merge( array( $oParent ), $this->_aVariantList->getArray() );
00276                 }
00277             } else {
00278                 //loading full list of variants
00279                 $this->_aVariantList = $oProduct->getFullVariants( false );
00280             }
00281 
00282             // setting link type for variants ..
00283             foreach ( $this->_aVariantList as $oVariant ) {
00284                 $this->_processProduct( $oVariant );
00285             }
00286 
00287         }
00288 
00289         return $this->_aVariantList;
00290     }
00291 
00297     protected function _getAddUrlParams()
00298     {
00299         if ( $this->getListType() == "search" ) {
00300             return $this->getDynUrlParams();
00301         }
00302     }
00303 
00311     protected function _processProduct( $oProduct )
00312     {
00313         $oProduct->setLinkType( $this->getLinkType() );
00314         if ( $sAddParams = $this->_getAddUrlParams() ) {
00315             $oProduct->appendLink( $sAddParams );
00316         }
00317     }
00318 
00324     public function getViewId()
00325     {
00326         if ( isset( $this->_sViewId )) {
00327             return $this->_sViewId;
00328         }
00329 
00330             $sViewId = parent::getViewId().'|'.oxConfig::getParameter( 'anid' ).'|';
00331 
00332 
00333         return $this->_sViewId = $sViewId;
00334     }
00335 
00336 
00348     public function render()
00349     {
00350         $myConfig = $this->getConfig();
00351 
00352         $oProduct = $this->getProduct();
00353 
00354         // assign template name
00355         if ( $oProduct->oxarticles__oxtemplate->value ) {
00356             $this->_sThisTemplate = $oProduct->oxarticles__oxtemplate->value;
00357         }
00358 
00359         if ( ( $sTplName = oxConfig::getParameter( 'tpl' ) ) ) {
00360             $this->_sThisTemplate = 'custom/'.basename ( $sTplName );
00361         }
00362 
00363         parent::render();
00364 
00365         $sPartial = oxConfig::getParameter('renderPartial');
00366         $this->addTplParam('sRenderPartial', $sPartial);
00367 
00368         switch ($sPartial) {
00369             case "productInfo":
00370                 return 'page/details/ajax/fullproductinfo.tpl';
00371                 break;
00372             case "detailsMain":
00373                 return 'page/details/ajax/productmain.tpl';
00374                 break;
00375             default:
00376                 // #785A loads and sets locator data
00377                 $oLocator = oxNew( 'oxlocator', $this->getListType() );
00378                 $oLocator->setLocatorData( $oProduct, $this );
00379 
00380                 if ($myConfig->getConfigParam( 'bl_rssRecommLists' ) && $this->getSimilarRecommLists()) {
00381                     $oRss = oxNew('oxrssfeed');
00382                     $this->addRssFeed($oRss->getRecommListsTitle( $oProduct ), $oRss->getRecommListsUrl( $oProduct ), 'recommlists');
00383                 }
00384 
00385                 return $this->_sThisTemplate;
00386         }
00387     }
00388 
00400     protected function _prepareMetaDescription( $sMeta, $iLength = 200, $blDescTag = false )
00401     {
00402         if ( !$sMeta ) {
00403             $oProduct = $this->getProduct();
00404 
00405             $sMeta = $oProduct->getLongDescription()->value;
00406             $sMeta = str_replace( array( '<br>', '<br />', '<br/>' ), "\n", $sMeta );
00407             $sMeta = $oProduct->oxarticles__oxtitle->value.' - '.$sMeta;
00408             $sMeta = strip_tags( $sMeta );
00409         }
00410         return parent::_prepareMetaDescription( $sMeta, $iLength, $blDescTag );
00411     }
00412 
00423     protected function _prepareMetaKeyword( $sKeywords, $blRemoveDuplicatedWords = true )
00424     {
00425         if ( !$sKeywords ) {
00426             $oProduct = $this->getProduct();
00427             $sKeywords = trim( $this->getTitle() );
00428 
00429             if ( $oCatTree = $this->getCategoryTree() ) {
00430                 foreach ( $oCatTree->getPath() as $oCat ) {
00431                     $sKeywords .= ", " . trim( $oCat->oxcategories__oxtitle->value );
00432                 }
00433             }
00434 
00435             //adding searchkeys info
00436             if ( $sSearchKeys = trim( $oProduct->oxarticles__oxsearchkeys->value ) ) {
00437                 $sKeywords .= ", ". $sSearchKeys;
00438             }
00439 
00440             $sKeywords = parent::_prepareMetaKeyword( $sKeywords, $blRemoveDuplicatedWords );
00441         }
00442 
00443         return $sKeywords;
00444     }
00445 
00451     public function ratingIsActive()
00452     {
00453         $myConfig = $this->getConfig();
00454 
00455         return $myConfig->getConfigParam( 'bl_perfLoadReviews' );
00456     }
00457 
00463     public function canRate()
00464     {
00465         if ( $this->_blCanRate === null ) {
00466 
00467             $this->_blCanRate = false;
00468             $myConfig = $this->getConfig();
00469 
00470             if ( $this->ratingIsActive() && $oUser = $this->getUser() ) {
00471 
00472                 $oRating = oxNew( 'oxrating' );
00473                 $this->_blCanRate = $oRating->allowRating( $oUser->getId(), 'oxarticle', $this->getProduct()->getId() );
00474             }
00475         }
00476 
00477         return $this->_blCanRate;
00478     }
00479 
00485     public function canChangeTags()
00486     {
00487         if ( $oUser = $this->getUser() ) {
00488 
00489             return true;
00490         }
00491         return false;
00492     }
00493 
00499     public function saveReview()
00500     {
00501         if ( $this->canAcceptFormData() &&
00502              ( $oUser = $this->getUser() ) && ( $oProduct = $this->getProduct() ) ) {
00503 
00504             $dRating = oxConfig::getParameter( 'artrating' );
00505             if ( $dRating !== null ) {
00506                 $dRating = (int) $dRating;
00507             }
00508 
00509             //save rating
00510             if ( $dRating !== null && $dRating >= 1 && $dRating <= 5 ) {
00511                 $oRating = oxNew( 'oxrating' );
00512                 if ( $oRating->allowRating( $oUser->getId(), 'oxarticle', $oProduct->getId() ) ) {
00513                     $oRating->oxratings__oxuserid   = new oxField( $oUser->getId() );
00514                     $oRating->oxratings__oxtype     = new oxField( 'oxarticle' );
00515                     $oRating->oxratings__oxobjectid = new oxField( $oProduct->getId() );
00516                     $oRating->oxratings__oxrating   = new oxField( $dRating );
00517                     $oRating->save();
00518                     $oProduct->addToRatingAverage( $dRating );
00519                 }
00520             }
00521 
00522             if ( ( $sReviewText = trim( ( string ) oxConfig::getParameter( 'rvw_txt', true ) ) ) ) {
00523                 $oReview = oxNew( 'oxreview' );
00524                 $oReview->oxreviews__oxobjectid = new oxField( $oProduct->getId() );
00525                 $oReview->oxreviews__oxtype     = new oxField( 'oxarticle' );
00526                 $oReview->oxreviews__oxtext     = new oxField( $sReviewText, oxField::T_RAW );
00527                 $oReview->oxreviews__oxlang     = new oxField( oxLang::getInstance()->getBaseLanguage() );
00528                 $oReview->oxreviews__oxuserid   = new oxField( $oUser->getId() );
00529                 $oReview->oxreviews__oxrating   = new oxField( ( $dRating !== null ) ? $dRating : 0);
00530                 $oReview->save();
00531             }
00532         }
00533     }
00534 
00540     public function addToRecomm()
00541     {
00542         if (!$this->getViewConfig()->getShowListmania()) {
00543             return;
00544         }
00545 
00546         $sRecommText = trim( ( string ) oxConfig::getParameter( 'recomm_txt' ) );
00547         $sRecommList = oxConfig::getParameter( 'recomm' );
00548         $sArtId      = $this->getProduct()->getId();
00549 
00550         if ( $sArtId ) {
00551             $oRecomm = oxNew( 'oxrecommlist' );
00552             $oRecomm->load( $sRecommList);
00553             $oRecomm->addArticle( $sArtId, $sRecommText );
00554         }
00555     }
00556 
00562     public function addTags()
00563     {
00564         $sTag  = $this->getConfig()->getParameter('newTags', true );
00565         $sHighTag  = $this->getConfig()->getParameter( 'highTags', true );
00566         if ( !$sTag && !$sHighTag) {
00567             return;
00568         }
00569         if ( $sHighTag ) {
00570             $sTag = getStr()->html_entity_decode( $sHighTag );
00571         }
00572 
00573         //can tag only once per product and tags
00574         $aTags = array();
00575         $oProduct = $this->getProduct();
00576         $aTaggedProducts = oxSession::getVar("aTaggedProducts");
00577         if ( $aTaggedProducts ) {
00578             $aTags = $aTaggedProducts[$oProduct->getId()];
00579         }
00580         $blAddedTag = false;
00581         //Checks if user already tagged it
00582         if ( $aTags[$sTag] != 1 ) {
00583             $oProduct->addTag( $sTag );
00584             $aTags[$sTag] = 1;
00585             $aTaggedProducts[$oProduct->getId()] = $aTags;
00586             oxSession::setVar( 'aTaggedProducts', $aTaggedProducts);
00587             $blAddedTag = true;
00588         }
00589         // for ajax call
00590         if ($this->getConfig()->getParameter('blAjax', true )) {
00591             oxUtils::getInstance()->showMessageAndExit( $blAddedTag );
00592         }
00593     }
00594 
00600     public function editTags()
00601     {
00602         if ( !$this->getUser() ) {
00603             return;
00604         }
00605         $oTagCloud = oxNew("oxTagCloud");
00606         $this->_aTags = $oTagCloud->getTags( $this->getProduct()->getId() );
00607         $this->_blEditTags = true;
00608 
00609         // for ajax call
00610         if ($this->getConfig()->getParameter('blAjax', true )) {
00611             oxUtils::getInstance()->setHeader( "Content-Type: text/html; charset=".oxLang::getInstance()->translateString( 'charset' ) );
00612             $oActView = oxNew( 'oxubase' );
00613             $oSmarty = oxUtilsView::getInstance()->getSmarty();
00614             $oSmarty->assign('oView', $this );
00615             $oSmarty->assign('oViewConf', $this->getViewConfig() );
00616             oxUtils::getInstance()->showMessageAndExit( $oSmarty->fetch( 'page/details/inc/editTags.tpl', $this->getViewId() ) );
00617         }
00618     }
00619 
00625     public function cancelTags()
00626     {
00627         $oTagCloud = oxNew("oxTagCloud");
00628         $this->_aTags = $oTagCloud->getTags( $this->getProduct()->getId() );
00629         $this->_blEditTags = false;
00630 
00631         // for ajax call
00632         if ($this->getConfig()->getParameter('blAjax', true )) {
00633             oxUtils::getInstance()->setHeader( "Content-Type: text/html; charset=".oxLang::getInstance()->translateString( 'charset' ) );
00634             $oActView = oxNew( 'oxubase' );
00635             $oSmarty = oxUtilsView::getInstance()->getSmarty();
00636             $oSmarty->assign('oView', $this );
00637             $oSmarty->assign('oViewConf', $this->getViewConfig() );
00638             oxUtils::getInstance()->showMessageAndExit( $oSmarty->fetch( 'page/details/inc/tags.tpl', $this->getViewId() ) );
00639         }
00640     }
00641 
00647     protected function _getSeoObjectId()
00648     {
00649         if ( $oProduct = $this->getProduct() ) {
00650             return $oProduct->getId();
00651         }
00652     }
00653 
00659     public function getAttributes()
00660     {
00661         if ( $this->_aAttributes === null ) {
00662             // all attributes this article has
00663             $aArtAttributes = $this->getProduct()->getAttributes();
00664 
00665             //making a new array for backward compatibility
00666             $this->_aAttributes = false;
00667 
00668             if ( count( $aArtAttributes ) ) {
00669                 foreach ( $aArtAttributes as $sKey => $oAttribute ) {
00670                     $this->_aAttributes[$sKey] = new stdClass();
00671                     $this->_aAttributes[$sKey]->title = $oAttribute->oxattribute__oxtitle->value;
00672                     $this->_aAttributes[$sKey]->value = $oAttribute->oxattribute__oxvalue->value;
00673                 }
00674             }
00675         }
00676         return $this->_aAttributes;
00677     }
00678 
00679 
00685     public function getEditTags()
00686     {
00687         return $this->_blEditTags;
00688     }
00689 
00695     public function getTags()
00696     {
00697         return $this->_aTags;
00698     }
00699 
00705     public function getTagCloudManager()
00706     {
00707         $oManager = oxNew( "oxTagCloud" );
00708         $oManager->setExtendedMode( true );
00709         $oManager->setProductId( $this->getProduct()->getId() );
00710         return $oManager;
00711     }
00712 
00719     public function isEditableTags()
00720     {
00721         if ( $this->_blCanEditTags === null ) {
00722             $this->_blCanEditTags = false;
00723             if ( $this->getProduct() && $this->getUser()) {
00724                 $this->_blCanEditTags = true;
00725             }
00726         }
00727         return $this->_blCanEditTags;
00728     }
00729 
00735     public function getProduct()
00736     {
00737         $myConfig = $this->getConfig();
00738         $myUtils = oxUtils::getInstance();
00739 
00740         if ( $this->_oProduct === null ) {
00741 
00742             //this option is only for lists and we must reset value
00743             //as blLoadVariants = false affect "ab price" functionality
00744             $myConfig->setConfigParam( 'blLoadVariants', true );
00745 
00746             $sOxid = oxConfig::getParameter( 'anid' );
00747 
00748             // object is not yet loaded
00749             $this->_oProduct = oxNew( 'oxarticle' );
00750             //$this->_oProduct->setSkipAbPrice( true );
00751 
00752             if ( !$this->_oProduct->load( $sOxid ) ) {
00753                 $myUtils->redirect( $myConfig->getShopHomeURL() );
00754                 $myUtils->showMessageAndExit( '' );
00755             }
00756 
00757             $aVariantSelections = $this->_oProduct->getVariantSelections( oxConfig::getParameter( "varselid" ) );
00758             if ($aVariantSelections && $aVariantSelections['oActiveVariant'] && $aVariantSelections['blPerfectFit']) {
00759                 $this->_oProduct = $aVariantSelections['oActiveVariant'];
00760             }
00761         }
00762 
00763         // additional checks
00764         if ( !$this->_blIsInitialized ) {
00765 
00766             $blContinue = true;
00767             if ( !$this->_oProduct->isVisible() ) {
00768                 $blContinue = false;
00769             } elseif ( $this->_oProduct->oxarticles__oxparentid->value ) {
00770                 $oParent = $this->_getParentProduct( $this->_oProduct->oxarticles__oxparentid->value );
00771                 if ( !$oParent || !$oParent->isVisible() ) {
00772                     $blContinue = false;
00773                 }
00774             }
00775 
00776             if ( !$blContinue ) {
00777                 $myUtils->redirect( $myConfig->getShopHomeURL() );
00778                 $myUtils->showMessageAndExit( '' );
00779             }
00780 
00781             $this->_processProduct( $this->_oProduct );
00782             $this->_blIsInitialized = true;
00783         }
00784 
00785         return $this->_oProduct;
00786     }
00787 
00793     public function getLinkType()
00794     {
00795         if ( $this->_iLinkType === null ) {
00796             $sListType = oxConfig::getParameter( 'listtype' );
00797             if ( 'vendor' == $sListType ) {
00798                 $this->_iLinkType = OXARTICLE_LINKTYPE_VENDOR;
00799             } elseif ( 'manufacturer' == $sListType ) {
00800                     $this->_iLinkType = OXARTICLE_LINKTYPE_MANUFACTURER;
00801             } elseif ( 'tag' == $sListType ) {
00802                     $this->_iLinkType = OXARTICLE_LINKTYPE_TAG;
00803             } elseif ( 'recommlist' == $sListType ) {
00804                     $this->_iLinkType = OXARTICLE_LINKTYPE_RECOMM;
00805             } else {
00806                 $this->_iLinkType = OXARTICLE_LINKTYPE_CATEGORY;
00807 
00808                 // price category has own type..
00809                 if ( ( $oCat = $this->getActCategory() ) && $oCat->isPriceCategory() ) {
00810                     $this->_iLinkType = OXARTICLE_LINKTYPE_PRICECATEGORY;
00811                 }
00812             }
00813         }
00814 
00815         return $this->_iLinkType;
00816     }
00817 
00823     public function getVariantList()
00824     {
00825         return $this->loadVariantInformation();
00826     }
00827 
00834     public function getVariantListExceptCurrent()
00835     {
00836         $oList = $this->getVariantList();
00837         if (is_object($oList)) {
00838             $oList = clone $oList;
00839         }
00840 
00841         $sOxid = $this->getProduct()->getId();
00842         if (isset($oList[$sOxid])) {
00843             unset($oList[$sOxid]);
00844         }
00845         return $oList;
00846     }
00847 
00853     public function getCaptcha()
00854     {
00855         if ( $this->_oCaptcha === null ) {
00856             $this->_oCaptcha = oxNew('oxCaptcha');
00857         }
00858         return $this->_oCaptcha;
00859     }
00860 
00866     public function getMediaFiles()
00867     {
00868         if ( $this->_aMediaFiles === null ) {
00869             $aMediaFiles = $this->getProduct()->getMediaUrls();
00870             $this->_aMediaFiles = count($aMediaFiles) ? $aMediaFiles : false;
00871         }
00872         return $this->_aMediaFiles;
00873     }
00874 
00882     public function getLastProducts( $iCnt = 4 )
00883     {
00884         if ( $this->_aLastProducts === null ) {
00885             //last seen products for #768CA
00886             $oProduct = $this->getProduct();
00887             $sArtId = $oProduct->oxarticles__oxparentid->value?$oProduct->oxarticles__oxparentid->value:$oProduct->getId();
00888 
00889             $oHistoryArtList = oxNew( 'oxarticlelist' );
00890             $oHistoryArtList->loadHistoryArticles( $sArtId, $iCnt );
00891             $this->_aLastProducts = $oHistoryArtList;
00892         }
00893         return $this->_aLastProducts;
00894     }
00895 
00901     public function getVendor()
00902     {
00903         if ( $this->_oVendor === null ) {
00904             $this->_oVendor = $this->getProduct()->getVendor( false );
00905         }
00906         return $this->_oVendor;
00907     }
00908 
00914     public function getManufacturer()
00915     {
00916         if ( $this->_oManufacturer === null ) {
00917             $this->_oManufacturer = $this->getProduct()->getManufacturer( false );
00918         }
00919         return $this->_oManufacturer;
00920     }
00921 
00927     public function getCategory()
00928     {
00929         if ( $this->_oCategory === null ) {
00930             $this->_oCategory = $this->getProduct()->getCategory();
00931         }
00932         return $this->_oCategory;
00933     }
00934 
00940     public function drawParentUrl()
00941     {
00942         return $this->getProduct()->isVariant();
00943     }
00944 
00950     public function getParentName()
00951     {
00952         if ( $this->_sParentName === null ) {
00953             $this->_sParentName = false;
00954             if ( ( $oParent = $this->_getParentProduct( $this->getProduct()->oxarticles__oxparentid->value ) ) ) {
00955                 $this->_sParentName = $oParent->oxarticles__oxtitle->value;
00956             }
00957         }
00958         return $this->_sParentName;
00959     }
00960 
00966     public function getParentUrl()
00967     {
00968         if ( $this->_sParentUrl === null ) {
00969             $this->_sParentUrl = false;
00970             if ( ( $oParent = $this->_getParentProduct( $this->getProduct()->oxarticles__oxparentid->value ) ) ) {
00971                 $this->_sParentUrl = $oParent->getLink();
00972             }
00973         }
00974         return $this->_sParentUrl;
00975     }
00976 
00982     public function getPictureGallery()
00983     {
00984         if ( $this->_aPicGallery === null ) {
00985             //get picture gallery
00986             $this->_aPicGallery = $this->getPicturesProduct()->getPictureGallery();
00987         }
00988         return $this->_aPicGallery;
00989     }
00990 
00996     public function getActPictureId()
00997     {
00998         $aPicGallery = $this->getPictureGallery();
00999         return $aPicGallery['ActPicID'];
01000     }
01001 
01007     public function getActPicture()
01008     {
01009         $aPicGallery = $this->getPictureGallery();
01010         return $aPicGallery['ActPic'];
01011     }
01012 
01018     public function morePics()
01019     {
01020         $aPicGallery = $this->getPictureGallery();
01021         return $aPicGallery['MorePics'];
01022     }
01023 
01029     public function getPictures()
01030     {
01031         $aPicGallery = $this->getPictureGallery();
01032         return $aPicGallery['Pics'];
01033     }
01034 
01042     public function getArtPic( $sPicNr )
01043     {
01044         $aPicGallery = $this->getPictureGallery();
01045         return $aPicGallery['Pics'][$sPicNr];
01046     }
01047 
01053     public function getIcons()
01054     {
01055         $aPicGallery = $this->getPictureGallery();
01056         return $aPicGallery['Icons'];
01057     }
01058 
01064     public function showZoomPics()
01065     {
01066         $aPicGallery = $this->getPictureGallery();
01067         return $aPicGallery['ZoomPic'];
01068     }
01069 
01075     public function getZoomPics()
01076     {
01077         $aPicGallery = $this->getPictureGallery();
01078         return $aPicGallery['ZoomPics'];
01079     }
01080 
01086     public function getActZoomPic()
01087     {
01088         return 1;
01089     }
01090 
01096     public function getSelectLists()
01097     {
01098         if ( $this->_aSelectLists === null ) {
01099             $this->_aSelectLists = false;
01100             if ( $this->getConfig()->getConfigParam( 'bl_perfLoadSelectLists' ) ) {
01101                 $this->_aSelectLists = $this->getProduct()->getSelectLists();
01102             }
01103         }
01104         return $this->_aSelectLists;
01105     }
01106 
01112     public function getReviews()
01113     {
01114         if ( $this->_aReviews === null ) {
01115             $this->_aReviews = false;
01116             if ( $this->getConfig()->getConfigParam( 'bl_perfLoadReviews' ) ) {
01117                 $this->_aReviews = $this->getProduct()->getReviews();
01118             }
01119         }
01120         return $this->_aReviews;
01121     }
01122 
01128     public function getCrossSelling()
01129     {
01130         if ( $this->_oCrossSelling === null ) {
01131             $this->_oCrossSelling = false;
01132             if ( $oProduct = $this->getProduct() ) {
01133                 $this->_oCrossSelling = $oProduct->getCrossSelling();
01134             }
01135         }
01136         return $this->_oCrossSelling;
01137     }
01138 
01144     public function getSimilarProducts()
01145     {
01146         if ( $this->_oSimilarProducts === null ) {
01147             $this->_oSimilarProducts = false;
01148             if ( $oProduct = $this->getProduct() ) {
01149                 $this->_oSimilarProducts = $oProduct->getSimilarProducts();
01150             }
01151         }
01152         return $this->_oSimilarProducts;
01153     }
01154 
01160     public function getSimilarRecommLists()
01161     {
01162         if (!$this->getViewConfig()->getShowListmania()) {
01163             return false;
01164         }
01165 
01166         if ( $this->_oRecommList === null ) {
01167             $this->_oRecommList = false;
01168             if ( $oProduct = $this->getProduct() ) {
01169                 $oRecommList = oxNew('oxrecommlist');
01170                 $this->_oRecommList = $oRecommList->getRecommListsByIds( array( $oProduct->getId() ) );
01171             }
01172         }
01173         return $this->_oRecommList;
01174     }
01175 
01181     public function getAccessoires()
01182     {
01183         if ( $this->_oAccessoires === null ) {
01184             $this->_oAccessoires = false;
01185             if ( $oProduct = $this->getProduct() ) {
01186                 $this->_oAccessoires = $oProduct->getAccessoires();
01187             }
01188         }
01189         return $this->_oAccessoires;
01190     }
01191 
01197     public function getAlsoBoughtTheseProducts()
01198     {
01199         if ( $this->_aAlsoBoughtArts === null ) {
01200             $this->_aAlsoBoughtArts = false;
01201             if ( $oProduct = $this->getProduct() ) {
01202                 $this->_aAlsoBoughtArts = $oProduct->getCustomerAlsoBoughtThisProducts();
01203             }
01204         }
01205         return $this->_aAlsoBoughtArts;
01206     }
01207 
01213     public function isPriceAlarm()
01214     {
01215         // #419 disabling pricealarm if article has fixed price
01216         $oProduct = $this->getProduct();
01217         if ( isset( $oProduct->oxarticles__oxblfixedprice->value ) && $oProduct->oxarticles__oxblfixedprice->value ) {
01218             return 0;
01219         }
01220         return 1;
01221     }
01222 
01231     protected function _getSubject( $iLang )
01232     {
01233         return $this->getProduct();
01234     }
01235 
01241     public function getSearchTitle()
01242     {
01243         return $this->_sSearchTitle;
01244     }
01245 
01253     public function setSearchTitle( $sTitle )
01254     {
01255         $this->_sSearchTitle = $sTitle;
01256     }
01257 
01265     public function setCatTreePath( $sActCatPath )
01266     {
01267         $this->_sCatTreePath = $sActCatPath;
01268     }
01269 
01276     public function noIndex()
01277     {
01278         $sListType = oxConfig::getParameter( 'listtype' );
01279         if ( $sListType && ( 'vendor' == $sListType || 'manufacturer' == $sListType ) ) {
01280             return $this->_iViewIndexState = VIEW_INDEXSTATE_NOINDEXFOLLOW;
01281         }
01282         return parent::noIndex();
01283     }
01284 
01290     public function getTitle()
01291     {
01292         if ( $oProduct = $this->getProduct() ) {
01293             return $oProduct->oxarticles__oxtitle->value . ( $oProduct->oxarticles__oxvarselect->value ? ' ' . $oProduct->oxarticles__oxvarselect->value : '' );
01294         }
01295     }
01296 
01297 
01303     public function getTag()
01304     {
01305         return oxConfig::getParameter("searchtag", 1);
01306     }
01307 
01313     public function getCanonicalUrl()
01314     {
01315         if ( ( $oProduct = $this->getProduct() ) ) {
01316             if ( $oProduct->oxarticles__oxparentid->value ) {
01317                 $oProduct = $this->_getParentProduct( $oProduct->oxarticles__oxparentid->value );
01318             }
01319 
01320             $oUtils = oxUtilsUrl::getInstance();
01321             if ( oxUtils::getInstance()->seoIsActive() ) {
01322                 $sUrl = $oUtils->prepareCanonicalUrl( $oProduct->getBaseSeoLink( $oProduct->getLanguage(), true ) );
01323             } else {
01324                 $sUrl = $oUtils->prepareCanonicalUrl( $oProduct->getBaseStdLink( $oProduct->getLanguage() ) );
01325             }
01326             return $sUrl;
01327         }
01328     }
01329 
01335     public function isMdVariantView()
01336     {
01337         if ( $this->_blMdView === null ) {
01338             $this->_blMdView = false;
01339             if ( $this->getConfig()->getConfigParam( 'blUseMultidimensionVariants' ) ) {
01340                 $iMaxMdDepth = $this->getProduct()->getMdVariants()->getMaxDepth();
01341                 $this->_blMdView = ($iMaxMdDepth > 1);
01342             }
01343         }
01344 
01345         return $this->_blMdView;
01346     }
01347 
01353     public function isPersParam()
01354     {
01355         $oProduct = $this->getProduct();
01356         return $oProduct->oxarticles__oxisconfigurable->value;
01357     }
01358 
01364     public function getTagSeparator()
01365     {
01366         $sSepartor = $this->getConfig()->getConfigParam("sTagSeparator");
01367         return $sSepartor;
01368     }
01369 
01375     public function getRatingValue()
01376     {
01377 
01378         if ( $this->_dRatingValue === null ) {
01379             $this->_dRatingValue = (double) 0;
01380             if ( $this->isReviewActive() && ( $oDetailsProduct = $this->getProduct() ) ) {
01381                 $this->_dRatingValue = round( $oDetailsProduct->getArticleRatingAverage( $this->getConfig()->getConfigParam( 'blShowVariantReviews' ) ), 1);
01382             }
01383         }
01384 
01385         return (double) $this->_dRatingValue;
01386     }
01387 
01393     public function isReviewActive()
01394     {
01395         return $this->getConfig()->getConfigParam( 'bl_perfLoadReviews' );
01396     }
01397 
01403     public function getRatingCount()
01404     {
01405         if ( $this->_iRatingCnt === null ) {
01406             $this->_iRatingCnt = false;
01407             if ( $this->isReviewActive() && ( $oDetailsProduct = $this->getProduct() ) ) {
01408                 $this->_iRatingCnt = $oDetailsProduct->getArticleRatingCount( $this->getConfig()->getConfigParam( 'blShowVariantReviews' ) );
01409             }
01410         }
01411         return $this->_iRatingCnt;
01412     }
01413 
01419     public function getBreadCrumb()
01420     {
01421         $aPaths = array();
01422 
01423         if ( 'search' == oxConfig::getParameter( 'listtype' ) ) {
01424             $sSearchParam = $this->getSearchParamForHtml();
01425 
01426             $aCatPath = array();
01427             $aCatPath['title'] = sprintf( oxLang::getInstance()->translateString( 'searchResult', oxLang::getInstance()->getBaseLanguage(), false ), $sSearchParam );
01428             $aCatPath['link']  = $this->getViewConfig()->getSelfLink() . 'stoken=' . oxSession::getVar('sess_stoken') . "&amp;cl=search&amp;searchparam=" . $sSearchParam;
01429 
01430             $aPaths[] = $aCatPath;
01431 
01432         } elseif ( 'tag' == oxConfig::getParameter( 'listtype' ) ) {
01433 
01434             $aCatPath = array();
01435 
01436             $aCatPath['title'] = oxLang::getInstance()->translateString( 'TAGS', oxLang::getInstance()->getBaseLanguage(), false );
01437             $aCatPath['link']  = oxSeoEncoder::getInstance()->getStaticUrl( $this->getViewConfig()->getSelfLink() . 'cl=tags' );
01438             $aPaths[] = $aCatPath;
01439 
01440             $oStr = getStr();
01441             $aCatPath['title'] = $oStr->ucfirst(oxConfig::getParameter( 'searchtag' ));
01442             $aCatPath['link']  = oxSeoEncoderTag::getInstance()->getTagUrl( oxConfig::getParameter( 'searchtag' ) );
01443             $aPaths[] = $aCatPath;
01444 
01445         } elseif ( 'recommlist' == oxConfig::getParameter( 'listtype' ) ) {
01446 
01447             $aCatPath = array();
01448             $aCatPath['title'] = oxLang::getInstance()->translateString( 'PAGE_RECOMMENDATIONS_PRODUCTS_TITLE', oxLang::getInstance()->getBaseLanguage(), false );
01449             $aPaths[] = $aCatPath;
01450         } else {
01451 
01452             $oCatTree = $this->getCatTreePath();
01453 
01454             if ( $oCatTree ) {
01455 
01456                 foreach ( $oCatTree as $oCat ) {
01457                     $aCatPath = array();
01458 
01459                     $aCatPath['link'] = $oCat->getLink();
01460                     $aCatPath['title'] = $oCat->oxcategories__oxtitle->value;
01461 
01462                     $aPaths[] = $aCatPath;
01463                 }
01464             }
01465         }
01466 
01467         return $aPaths;
01468     }
01469 
01479     public function addme()
01480     {
01481         $myConfig = $this->getConfig();
01482         $myUtils  = oxUtils::getInstance();
01483 
01484         //control captcha
01485         $sMac     = oxConfig::getParameter( 'c_mac' );
01486         $sMacHash = oxConfig::getParameter( 'c_mach' );
01487         $oCaptcha = $this->getCaptcha();
01488         if ( !$oCaptcha->pass( $sMac, $sMacHash ) ) {
01489             $this->_iPriceAlarmStatus = 2;
01490             return;
01491         }
01492 
01493         $aParams = oxConfig::getParameter( 'pa' );
01494         if ( !isset( $aParams['email'] ) || !$myUtils->isValidEmail( $aParams['email'] ) ) {
01495             $this->_iPriceAlarmStatus = 0;
01496             return;
01497         }
01498         $aParams['aid'] = $this->getProduct()->getId();
01499         $oCur = $myConfig->getActShopCurrencyObject();
01500         // convert currency to default
01501         $dPrice = $myUtils->currency2Float( $aParams['price'] );
01502 
01503         $oAlarm = oxNew( "oxpricealarm" );
01504         $oAlarm->oxpricealarm__oxuserid = new oxField( oxSession::getVar( 'usr' ));
01505         $oAlarm->oxpricealarm__oxemail  = new oxField( $aParams['email']);
01506         $oAlarm->oxpricealarm__oxartid  = new oxField( $aParams['aid']);
01507         $oAlarm->oxpricealarm__oxprice  = new oxField( $myUtils->fRound( $dPrice, $oCur ));
01508         $oAlarm->oxpricealarm__oxshopid = new oxField( $myConfig->getShopId());
01509         $oAlarm->oxpricealarm__oxcurrency = new oxField( $oCur->name);
01510 
01511         $oAlarm->oxpricealarm__oxlang = new oxField(oxLang::getInstance()->getBaseLanguage());
01512 
01513         $oAlarm->save();
01514 
01515         // Send Email
01516         $oEmail = oxNew( 'oxemail' );
01517         $this->_iPriceAlarmStatus = (int) $oEmail->sendPricealarmNotification( $aParams, $oAlarm );
01518     }
01519 
01525     public function getPriceAlarmStatus()
01526     {
01527         return $this->_iPriceAlarmStatus;
01528     }
01529 
01535     public function getBidPrice()
01536     {
01537         if ( $this->_sBidPrice === null ) {
01538             $this->_sBidPrice = false;
01539 
01540             $aParams = oxConfig::getParameter( 'pa' );
01541             $oCur = $this->getConfig()->getActShopCurrencyObject();
01542             $iPrice = oxUtils::getInstance()->currency2Float( $aParams['price'] );
01543             $this->_sBidPrice = oxLang::getInstance()->formatCurrency( $iPrice, $oCur );
01544         }
01545         return $this->_sBidPrice;
01546     }
01547 
01553     public function getVariantSelections()
01554     {
01555         // finding parent
01556         $oProduct = $this->getProduct();
01557         if ( ( $oParent = $this->_getParentProduct( $oProduct->oxarticles__oxparentid->value ) ) ) {
01558             return $oParent->getVariantSelections( oxConfig::getParameter( "varselid" ), $oProduct->getId() );
01559         }
01560 
01561         return $oProduct->getVariantSelections( oxConfig::getParameter( "varselid" ) );
01562     }
01563 
01569     public function getPicturesProduct()
01570     {
01571         $aVariantSelections = $this->getVariantSelections();
01572         if ($aVariantSelections && $aVariantSelections['oActiveVariant'] && !$aVariantSelections['blPerfectFit']) {
01573             return $aVariantSelections['oActiveVariant'];
01574         }
01575         return $this->getProduct();
01576     }
01577 
01578 
01584     public function isMoreTagsVisible()
01585     {
01586         return true;
01587     }
01588 
01594     public function getSearchParamForHtml()
01595     {
01596         if ( $this->_sSearchParamForHtml === null ) {
01597             $this->_sSearchParamForHtml = oxConfig::getParameter( 'searchparam' );
01598         }
01599         return $this->_sSearchParamForHtml;
01600     }
01601 
01607     public function showRdfa()
01608     {
01609         return $this->getConfig()->getConfigParam( 'blRDFaEmbedding' );
01610     }
01611 
01617     public function getRDFaNormalizedRating()
01618     {
01619         $myConfig = $this->getConfig();
01620         $iMin = $myConfig->getConfigParam("iRDFaMinRating");
01621         $iMax = $myConfig->getConfigParam("iRDFaMaxRating");
01622 
01623         $oProduct = $this->getProduct();
01624         $iCount = $oProduct->oxarticles__oxratingcnt->value;
01625         if ( isset($iMin) && isset($iMax) && $iMax != '' && $iMin != '' && $iCount > 0 ) {
01626             $aNomalizedRating = array();
01627             $iValue = ((4*($oProduct->oxarticles__oxrating->value - $iMin)/($iMax - $iMin)))+1;
01628             $aNomalizedRating["count"] = $iCount;
01629             $aNomalizedRating["value"] = round($iValue, 2);
01630             return $aNomalizedRating;
01631         }
01632         return false;
01633     }
01634 
01642     public function getRDFaValidityPeriod($sShopConfVar)
01643     {
01644         if ( $sShopConfVar ) {
01645             $aValidity = array();
01646             $iDays = $this->getConfig()->getConfigParam($sShopConfVar);
01647             $iFrom = oxUtilsDate::getInstance()->getTime();
01648 
01649             $iThrough = $iFrom + ($iDays * 24 * 60 * 60);
01650             $aValidity["from"] = date('Y-m-d\TH:i:s', $iFrom)."Z";
01651             $aValidity["through"] = date('Y-m-d\TH:i:s', $iThrough)."Z";
01652 
01653             return $aValidity;
01654         }
01655         return false;
01656     }
01657 
01663     public function getRDFaBusinessFnc()
01664     {
01665         return $this->getConfig()->getConfigParam("sRDFaBusinessFnc");
01666     }
01667 
01673     public function getRDFaCustomers()
01674     {
01675         return $this->getConfig()->getConfigParam("aRDFaCustomers");
01676     }
01677 
01683     public function getRDFaVAT()
01684     {
01685         return $this->getConfig()->getConfigParam("iRDFaVAT");
01686     }
01687 
01693     public function getRDFaGenericCondition()
01694     {
01695         return $this->getConfig()->getConfigParam("iRDFaCondition");
01696     }
01697 
01703     public function getBundleArticle()
01704     {
01705         $oProduct = $this->getProduct();
01706         if ( $oProduct && $oProduct->oxarticles__oxbundleid->value ) {
01707             $oArticle = oxNew("oxarticle");
01708             $oArticle->load($oProduct->oxarticles__oxbundleid->value);
01709             return $oArticle;
01710         }
01711         return false;
01712     }
01713 
01719     public function getRDFaPaymentMethods()
01720     {
01721         $iPrice = $this->getProduct()->getPrice()->getBruttoPrice();
01722         $oPayments = oxNew("oxpaymentlist");
01723         $oPayments->loadRDFaPaymentList($iPrice);
01724         return $oPayments;
01725     }
01726 
01732     public function getRDFaDeliverySetMethods()
01733     {
01734         $oDelSets = oxNew("oxdeliverysetlist");
01735         $oDelSets->loadRDFaDeliverySetList();
01736         return $oDelSets;
01737     }
01738 
01744     public function getProductsDeliveryList()
01745     {
01746         $oProduct = $this->getProduct();
01747         $oDelList = oxNew( "oxDeliveryList" );
01748         $oDelList->loadDeliveryListForProduct( $oProduct );
01749         return $oDelList;
01750     }
01751 
01757     public function getRDFaDeliveryChargeSpecLoc()
01758     {
01759         return $this->getConfig()->getConfigParam("sRDFaDeliveryChargeSpecLoc");
01760     }
01761 
01767     public function getRDFaPaymentChargeSpecLoc()
01768     {
01769         return $this->getConfig()->getConfigParam("sRDFaPaymentChargeSpecLoc");
01770     }
01771 
01777     public function getRDFaBusinessEntityLoc()
01778     {
01779         return $this->getConfig()->getConfigParam("sRDFaBusinessEntityLoc");
01780     }
01781 
01787     public function showRDFaProductStock()
01788     {
01789         return $this->getConfig()->getConfigParam("blShowRDFaProductStock");
01790     }
01791 
01792 }