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 = basename ( $sTplName );
00361         }
00362 
00363         //loading amount price list
00364         $oProduct->loadAmountPriceInfo();
00365 
00366         parent::render();
00367 
00368         $sPartial = oxConfig::getParameter('renderPartial');
00369         $this->addTplParam('sRenderPartial', $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                 // #785A loads and sets locator data
00380                 $oLocator = oxNew( 'oxlocator', $this->getListType() );
00381                 $oLocator->setLocatorData( $oProduct, $this );
00382 
00383                 if ($myConfig->getConfigParam( 'bl_rssRecommLists' ) && $this->getSimilarRecommLists()) {
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             $sMeta = $oProduct->getArticleLongDesc()->value;
00409             $sMeta = str_replace( array( '<br>', '<br />', '<br/>' ), "\n", $sMeta );
00410             $sMeta = $oProduct->oxarticles__oxtitle->value.' - '.$sMeta;
00411             $sMeta = strip_tags( $sMeta );
00412         }
00413         return parent::_prepareMetaDescription( $sMeta, $iLength, $blDescTag );
00414     }
00415 
00426     protected function _prepareMetaKeyword( $sKeywords, $blRemoveDuplicatedWords = true )
00427     {
00428         if ( !$sKeywords ) {
00429             $oProduct = $this->getProduct();
00430             $sKeywords = trim( $this->getTitle() );
00431 
00432             if ( $oCatTree = $this->getCategoryTree() ) {
00433                 foreach ( $oCatTree->getPath() as $oCat ) {
00434                     $sKeywords .= ", " . trim( $oCat->oxcategories__oxtitle->value );
00435                 }
00436             }
00437 
00438             //adding searchkeys info
00439             if ( $sSearchKeys = trim( $oProduct->oxarticles__oxsearchkeys->value ) ) {
00440                 $sKeywords .= ", ". $sSearchKeys;
00441             }
00442 
00443             $sKeywords = parent::_prepareMetaKeyword( $sKeywords, $blRemoveDuplicatedWords );
00444         }
00445 
00446         return $sKeywords;
00447     }
00448 
00454     public function canRate()
00455     {
00456         if ( $this->_blCanRate === null ) {
00457 
00458             $this->_blCanRate = false;
00459             $myConfig = $this->getConfig();
00460 
00461             if ( $myConfig->getConfigParam( 'bl_perfLoadReviews' ) &&
00462                  $oUser = $this->getUser() ) {
00463 
00464                 $oRating = oxNew( 'oxrating' );
00465                 $this->_blCanRate = $oRating->allowRating( $oUser->getId(), 'oxarticle', $this->getProduct()->getId() );
00466             }
00467         }
00468         return $this->_blCanRate;
00469     }
00470 
00476     public function canChangeTags()
00477     {
00478         if ( $oUser = $this->getUser() ) {
00479 
00480             return true;
00481         }
00482         return false;
00483     }
00484 
00490     public function saveReview()
00491     {
00492         if ( $this->canAcceptFormData() &&
00493              ( $oUser = $this->getUser() ) && ( $oProduct = $this->getProduct() ) ) {
00494 
00495             $dRating = oxConfig::getParameter( 'artrating' );
00496             if ( $dRating !== null ) {
00497                 $dRating = (int) $dRating;
00498             }
00499 
00500             //save rating
00501             if ( $dRating !== null && $dRating >= 0 && $dRating <= 5 ) {
00502                 $oRating = oxNew( 'oxrating' );
00503                 if ( $oRating->allowRating( $oUser->getId(), 'oxarticle', $oProduct->getId() ) ) {
00504                     $oRating->oxratings__oxuserid   = new oxField( $oUser->getId() );
00505                     $oRating->oxratings__oxtype     = new oxField( 'oxarticle' );
00506                     $oRating->oxratings__oxobjectid = new oxField( $oProduct->getId() );
00507                     $oRating->oxratings__oxrating   = new oxField( $dRating );
00508                     $oRating->save();
00509                     $oProduct->addToRatingAverage( $dRating );
00510                 }
00511             }
00512 
00513             if ( ( $sReviewText = trim( ( string ) oxConfig::getParameter( 'rvw_txt', true ) ) ) ) {
00514                 $oReview = oxNew( 'oxreview' );
00515                 $oReview->oxreviews__oxobjectid = new oxField( $oProduct->getId() );
00516                 $oReview->oxreviews__oxtype     = new oxField( 'oxarticle' );
00517                 $oReview->oxreviews__oxtext     = new oxField( $sReviewText, oxField::T_RAW );
00518                 $oReview->oxreviews__oxlang     = new oxField( oxLang::getInstance()->getBaseLanguage() );
00519                 $oReview->oxreviews__oxuserid   = new oxField( $oUser->getId() );
00520                 $oReview->oxreviews__oxrating   = new oxField( ( $dRating !== null ) ? $dRating : null );
00521                 $oReview->save();
00522             }
00523         }
00524     }
00525 
00531     public function addToRecomm()
00532     {
00533         if (!$this->getViewConfig()->getShowListmania()) {
00534             return;
00535         }
00536 
00537         $sRecommText = trim( ( string ) oxConfig::getParameter( 'recomm_txt' ) );
00538         $sRecommList = oxConfig::getParameter( 'recomm' );
00539         $sArtId      = $this->getProduct()->getId();
00540 
00541         if ( $sArtId ) {
00542             $oRecomm = oxNew( 'oxrecommlist' );
00543             $oRecomm->load( $sRecommList);
00544             $oRecomm->addArticle( $sArtId, $sRecommText );
00545         }
00546     }
00547 
00553     public function addTags()
00554     {
00555         $sTag  = $this->getConfig()->getParameter('newTags', true );
00556         $sHighTag  = $this->getConfig()->getParameter( 'highTags', true );
00557         if ( !$sTag && !$sHighTag) {
00558             return;
00559         }
00560         if ( $sHighTag ) {
00561             $sTag = getStr()->html_entity_decode( $sHighTag );
00562         }
00563 
00564         //can tag only once per product and tags
00565         $aTags = array();
00566         $oProduct = $this->getProduct();
00567         $aTaggedProducts = oxSession::getVar("aTaggedProducts");
00568         if ( $aTaggedProducts ) {
00569             $aTags = $aTaggedProducts[$oProduct->getId()];
00570         }
00571         $blAddedTag = false;
00572         //Checks if user already tagged it
00573         if ( $aTags[$sTag] != 1 ) {
00574             $oProduct->addTag( $sTag );
00575             $aTags[$sTag] = 1;
00576             $aTaggedProducts[$oProduct->getId()] = $aTags;
00577             oxSession::setVar( 'aTaggedProducts', $aTaggedProducts);
00578             $blAddedTag = true;
00579         }
00580         // for ajax call
00581         if ($this->getConfig()->getParameter('blAjax', true )) {
00582             die($blAddedTag);
00583         }
00584     }
00585 
00591     public function editTags()
00592     {
00593         if ( !$this->getUser() ) {
00594             return;
00595         }
00596         $oTagCloud = oxNew("oxTagCloud");
00597         $this->_aTags = $oTagCloud->getTags( $this->getProduct()->getId() );
00598         $this->_blEditTags = true;
00599 
00600         // for ajax call
00601         if ($this->getConfig()->getParameter('blAjax', true )) {
00602             oxUtils::getInstance()->setHeader( "Content-Type: text/html; charset=".oxLang::getInstance()->translateString( 'charset' ) );
00603             $oActView = oxNew( 'oxubase' );
00604             $oSmarty = oxUtilsView::getInstance()->getSmarty();
00605             $oSmarty->assign('oView', $this );
00606             $oSmarty->assign('oViewConf', $this->getViewConfig() );
00607             die($oSmarty->fetch( 'page/details/inc/editTags.tpl', $this->getViewId() ));
00608         }
00609     }
00610 
00616     public function cancelTags()
00617     {
00618         $oTagCloud = oxNew("oxTagCloud");
00619         $this->_aTags = $oTagCloud->getTags( $this->getProduct()->getId() );
00620         $this->_blEditTags = false;
00621 
00622         // for ajax call
00623         if ($this->getConfig()->getParameter('blAjax', true )) {
00624             oxUtils::getInstance()->setHeader( "Content-Type: text/html; charset=".oxLang::getInstance()->translateString( 'charset' ) );
00625             $oActView = oxNew( 'oxubase' );
00626             $oSmarty = oxUtilsView::getInstance()->getSmarty();
00627             $oSmarty->assign('oView', $this );
00628             $oSmarty->assign('oViewConf', $this->getViewConfig() );
00629             die($oSmarty->fetch( 'page/details/inc/tags.tpl', $this->getViewId() ));
00630         }
00631     }
00632 
00638     protected function _getSeoObjectId()
00639     {
00640         if ( $oProduct = $this->getProduct() ) {
00641             return $oProduct->getId();
00642         }
00643     }
00644 
00650     public function getAttributes()
00651     {
00652         if ( $this->_aAttributes === null ) {
00653             // all attributes this article has
00654             $aArtAttributes = $this->getProduct()->getAttributes();
00655 
00656             //making a new array for backward compatibility
00657             $this->_aAttributes = false;
00658 
00659             if ( count( $aArtAttributes ) ) {
00660                 foreach ( $aArtAttributes as $sKey => $oAttribute ) {
00661                     $this->_aAttributes[$sKey] = new stdClass();
00662                     $this->_aAttributes[$sKey]->title = $oAttribute->oxattribute__oxtitle->value;
00663                     $this->_aAttributes[$sKey]->value = $oAttribute->oxattribute__oxvalue->value;
00664                 }
00665             }
00666         }
00667         return $this->_aAttributes;
00668     }
00669 
00670 
00676     public function getEditTags()
00677     {
00678         return $this->_blEditTags;
00679     }
00680 
00686     public function getTags()
00687     {
00688         return $this->_aTags;
00689     }
00690 
00696     public function getTagCloudManager()
00697     {
00698         $oManager = oxNew( "oxTagCloud" );
00699         $oManager->setExtendedMode( true );
00700         $oManager->setProductId( $this->getProduct()->getId() );
00701         return $oManager;
00702     }
00703 
00710     public function isEditableTags()
00711     {
00712         if ( $this->_blCanEditTags === null ) {
00713             $this->_blCanEditTags = false;
00714             if ( $this->getProduct() && $this->getUser()) {
00715                 $this->_blCanEditTags = true;
00716             }
00717         }
00718         return $this->_blCanEditTags;
00719     }
00720 
00726     public function getProduct()
00727     {
00728         $myConfig = $this->getConfig();
00729         $myUtils = oxUtils::getInstance();
00730 
00731         if ( $this->_oProduct === null ) {
00732 
00733             //this option is only for lists and we must reset value
00734             //as blLoadVariants = false affect "ab price" functionality
00735             $myConfig->setConfigParam( 'blLoadVariants', true );
00736 
00737             $sOxid = oxConfig::getParameter( 'anid' );
00738 
00739             // object is not yet loaded
00740             $this->_oProduct = oxNew( 'oxarticle' );
00741             //$this->_oProduct->setSkipAbPrice( true );
00742 
00743             if ( !$this->_oProduct->load( $sOxid ) ) {
00744                 $myUtils->redirect( $myConfig->getShopHomeURL() );
00745                 $myUtils->showMessageAndExit( '' );
00746             }
00747 
00748             $aVariantSelections = $this->_oProduct->getVariantSelections( oxConfig::getParameter( "varselid" ) );
00749             if ($aVariantSelections && $aVariantSelections['oActiveVariant'] && $aVariantSelections['blPerfectFit']) {
00750                 $this->_oProduct = $aVariantSelections['oActiveVariant'];
00751             }
00752         }
00753 
00754         // additional checks
00755         if ( !$this->_blIsInitialized ) {
00756 
00757             $blContinue = true;
00758             if ( !$this->_oProduct->isVisible() ) {
00759                 $blContinue = false;
00760             } elseif ( $this->_oProduct->oxarticles__oxparentid->value ) {
00761                 $oParent = $this->_getParentProduct( $this->_oProduct->oxarticles__oxparentid->value );
00762                 if ( !$oParent || !$oParent->isVisible() ) {
00763                     $blContinue = false;
00764                 }
00765             }
00766 
00767             if ( !$blContinue ) {
00768                 $myUtils->redirect( $myConfig->getShopHomeURL() );
00769                 $myUtils->showMessageAndExit( '' );
00770             }
00771 
00772             $this->_processProduct( $this->_oProduct );
00773             $this->_blIsInitialized = true;
00774         }
00775 
00776         return $this->_oProduct;
00777     }
00778 
00784     public function getLinkType()
00785     {
00786         if ( $this->_iLinkType === null ) {
00787             $sListType = oxConfig::getParameter( 'listtype' );
00788             if ( 'vendor' == $sListType ) {
00789                 $this->_iLinkType = OXARTICLE_LINKTYPE_VENDOR;
00790             } elseif ( 'manufacturer' == $sListType ) {
00791                     $this->_iLinkType = OXARTICLE_LINKTYPE_MANUFACTURER;
00792             } elseif ( 'tag' == $sListType ) {
00793                     $this->_iLinkType = OXARTICLE_LINKTYPE_TAG;
00794             } elseif ( 'recommlist' == $sListType ) {
00795                     $this->_iLinkType = OXARTICLE_LINKTYPE_RECOMM;
00796             } else {
00797                 $this->_iLinkType = OXARTICLE_LINKTYPE_CATEGORY;
00798 
00799                 // price category has own type..
00800                 if ( ( $oCat = $this->getActCategory() ) && $oCat->isPriceCategory() ) {
00801                     $this->_iLinkType = OXARTICLE_LINKTYPE_PRICECATEGORY;
00802                 }
00803             }
00804         }
00805 
00806         return $this->_iLinkType;
00807     }
00808 
00814     public function getVariantList()
00815     {
00816         return $this->loadVariantInformation();
00817     }
00818 
00825     public function getVariantListExceptCurrent()
00826     {
00827         $oList = $this->getVariantList();
00828         if (is_object($oList)) {
00829             $oList = clone $oList;
00830         }
00831 
00832         $sOxid = $this->getProduct()->getId();
00833         if (isset($oList[$sOxid])) {
00834             unset($oList[$sOxid]);
00835         }
00836         return $oList;
00837     }
00838 
00844     public function getCaptcha()
00845     {
00846         if ( $this->_oCaptcha === null ) {
00847             $this->_oCaptcha = oxNew('oxCaptcha');
00848         }
00849         return $this->_oCaptcha;
00850     }
00851 
00857     public function getMediaFiles()
00858     {
00859         if ( $this->_aMediaFiles === null ) {
00860             $aMediaFiles = $this->getProduct()->getMediaUrls();
00861             $this->_aMediaFiles = count($aMediaFiles) ? $aMediaFiles : false;
00862         }
00863         return $this->_aMediaFiles;
00864     }
00865 
00873     public function getLastProducts( $iCnt = 4 )
00874     {
00875         if ( $this->_aLastProducts === null ) {
00876             //last seen products for #768CA
00877             $oProduct = $this->getProduct();
00878             $sArtId = $oProduct->oxarticles__oxparentid->value?$oProduct->oxarticles__oxparentid->value:$oProduct->getId();
00879 
00880             $oHistoryArtList = oxNew( 'oxarticlelist' );
00881             $oHistoryArtList->loadHistoryArticles( $sArtId, $iCnt );
00882             $this->_aLastProducts = $oHistoryArtList;
00883         }
00884         return $this->_aLastProducts;
00885     }
00886 
00892     public function getVendor()
00893     {
00894         if ( $this->_oVendor === null ) {
00895             $this->_oVendor = $this->getProduct()->getVendor( false );
00896         }
00897         return $this->_oVendor;
00898     }
00899 
00905     public function getManufacturer()
00906     {
00907         if ( $this->_oManufacturer === null ) {
00908             $this->_oManufacturer = $this->getProduct()->getManufacturer( false );
00909         }
00910         return $this->_oManufacturer;
00911     }
00912 
00918     public function getCategory()
00919     {
00920         if ( $this->_oCategory === null ) {
00921             $this->_oCategory = $this->getProduct()->getCategory();
00922         }
00923         return $this->_oCategory;
00924     }
00925 
00931     public function drawParentUrl()
00932     {
00933         return $this->getProduct()->isVariant();
00934     }
00935 
00941     public function getParentName()
00942     {
00943         if ( $this->_sParentName === null ) {
00944             $this->_sParentName = false;
00945             if ( ( $oParent = $this->_getParentProduct( $this->getProduct()->oxarticles__oxparentid->value ) ) ) {
00946                 $this->_sParentName = $oParent->oxarticles__oxtitle->value;
00947             }
00948         }
00949         return $this->_sParentName;
00950     }
00951 
00957     public function getParentUrl()
00958     {
00959         if ( $this->_sParentUrl === null ) {
00960             $this->_sParentUrl = false;
00961             if ( ( $oParent = $this->_getParentProduct( $this->getProduct()->oxarticles__oxparentid->value ) ) ) {
00962                 $this->_sParentUrl = $oParent->getLink();
00963             }
00964         }
00965         return $this->_sParentUrl;
00966     }
00967 
00973     public function getPictureGallery()
00974     {
00975         if ( $this->_aPicGallery === null ) {
00976             //get picture gallery
00977             $this->_aPicGallery = $this->getPicturesProduct()->getPictureGallery();
00978         }
00979         return $this->_aPicGallery;
00980     }
00981 
00987     public function getActPictureId()
00988     {
00989         $aPicGallery = $this->getPictureGallery();
00990         return $aPicGallery['ActPicID'];
00991     }
00992 
00998     public function getActPicture()
00999     {
01000         $aPicGallery = $this->getPictureGallery();
01001         return $aPicGallery['ActPic'];
01002     }
01003 
01009     public function morePics()
01010     {
01011         $aPicGallery = $this->getPictureGallery();
01012         return $aPicGallery['MorePics'];
01013     }
01014 
01020     public function getPictures()
01021     {
01022         $aPicGallery = $this->getPictureGallery();
01023         return $aPicGallery['Pics'];
01024     }
01025 
01033     public function getArtPic( $sPicNr )
01034     {
01035         $aPicGallery = $this->getPictureGallery();
01036         return $aPicGallery['Pics'][$sPicNr];
01037     }
01038 
01044     public function getIcons()
01045     {
01046         $aPicGallery = $this->getPictureGallery();
01047         return $aPicGallery['Icons'];
01048     }
01049 
01055     public function showZoomPics()
01056     {
01057         $aPicGallery = $this->getPictureGallery();
01058         return $aPicGallery['ZoomPic'];
01059     }
01060 
01066     public function getZoomPics()
01067     {
01068         $aPicGallery = $this->getPictureGallery();
01069         return $aPicGallery['ZoomPics'];
01070     }
01071 
01077     public function getActZoomPic()
01078     {
01079         return 1;
01080     }
01081 
01087     public function getSelectLists()
01088     {
01089         if ( $this->_aSelectLists === null ) {
01090             $this->_aSelectLists = false;
01091             if ( $this->getConfig()->getConfigParam( 'bl_perfLoadSelectLists' ) ) {
01092                 $this->_aSelectLists = $this->getProduct()->getSelectLists();
01093             }
01094         }
01095         return $this->_aSelectLists;
01096     }
01097 
01103     public function getReviews()
01104     {
01105         if ( $this->_aReviews === null ) {
01106             $this->_aReviews = false;
01107             if ( $this->getConfig()->getConfigParam( 'bl_perfLoadReviews' ) ) {
01108                 $this->_aReviews = $this->getProduct()->getReviews();
01109             }
01110         }
01111         return $this->_aReviews;
01112     }
01113 
01119     public function getCrossSelling()
01120     {
01121         if ( $this->_oCrossSelling === null ) {
01122             $this->_oCrossSelling = false;
01123             if ( $oProduct = $this->getProduct() ) {
01124                 $this->_oCrossSelling = $oProduct->getCrossSelling();
01125             }
01126         }
01127         return $this->_oCrossSelling;
01128     }
01129 
01135     public function getSimilarProducts()
01136     {
01137         if ( $this->_oSimilarProducts === null ) {
01138             $this->_oSimilarProducts = false;
01139             if ( $oProduct = $this->getProduct() ) {
01140                 $this->_oSimilarProducts = $oProduct->getSimilarProducts();
01141             }
01142         }
01143         return $this->_oSimilarProducts;
01144     }
01145 
01151     public function getSimilarRecommLists()
01152     {
01153         if (!$this->getViewConfig()->getShowListmania()) {
01154             return false;
01155         }
01156 
01157         if ( $this->_oRecommList === null ) {
01158             $this->_oRecommList = false;
01159             if ( $oProduct = $this->getProduct() ) {
01160                 $oRecommList = oxNew('oxrecommlist');
01161                 $this->_oRecommList = $oRecommList->getRecommListsByIds( array( $oProduct->getId() ) );
01162             }
01163         }
01164         return $this->_oRecommList;
01165     }
01166 
01172     public function getAccessoires()
01173     {
01174         if ( $this->_oAccessoires === null ) {
01175             $this->_oAccessoires = false;
01176             if ( $oProduct = $this->getProduct() ) {
01177                 $this->_oAccessoires = $oProduct->getAccessoires();
01178             }
01179         }
01180         return $this->_oAccessoires;
01181     }
01182 
01188     public function getAlsoBoughtTheseProducts()
01189     {
01190         if ( $this->_aAlsoBoughtArts === null ) {
01191             $this->_aAlsoBoughtArts = false;
01192             if ( $oProduct = $this->getProduct() ) {
01193                 $this->_aAlsoBoughtArts = $oProduct->getCustomerAlsoBoughtThisProducts();
01194             }
01195         }
01196         return $this->_aAlsoBoughtArts;
01197     }
01198 
01204     public function isPriceAlarm()
01205     {
01206         // #419 disabling pricealarm if article has fixed price
01207         $oProduct = $this->getProduct();
01208         if ( isset( $oProduct->oxarticles__oxblfixedprice->value ) && $oProduct->oxarticles__oxblfixedprice->value ) {
01209             return 0;
01210         }
01211         return 1;
01212     }
01213 
01222     protected function _getSubject( $iLang )
01223     {
01224         return $this->getProduct();
01225     }
01226 
01232     public function getSearchTitle()
01233     {
01234         return $this->_sSearchTitle;
01235     }
01236 
01244     public function setSearchTitle( $sTitle )
01245     {
01246         $this->_sSearchTitle = $sTitle;
01247     }
01248 
01256     public function setCatTreePath( $sActCatPath )
01257     {
01258         $this->_sCatTreePath = $sActCatPath;
01259     }
01260 
01267     public function noIndex()
01268     {
01269         $sListType = oxConfig::getParameter( 'listtype' );
01270         if ( $sListType && ( 'vendor' == $sListType || 'manufacturer' == $sListType ) ) {
01271             return $this->_iViewIndexState = VIEW_INDEXSTATE_NOINDEXFOLLOW;
01272         }
01273         return parent::noIndex();
01274     }
01275 
01281     public function getTitle()
01282     {
01283         if ( $oProduct = $this->getProduct() ) {
01284             return $oProduct->oxarticles__oxtitle->value . ( $oProduct->oxarticles__oxvarselect->value ? ' ' . $oProduct->oxarticles__oxvarselect->value : '' );
01285         }
01286     }
01287 
01288 
01294     public function getTag()
01295     {
01296         return oxConfig::getParameter("searchtag", 1);
01297     }
01298 
01304     public function getCanonicalUrl()
01305     {
01306         if ( ( $oProduct = $this->getProduct() ) ) {
01307             $oUtils = oxUtilsUrl::getInstance();
01308             if ( oxUtils::getInstance()->seoIsActive() ) {
01309                 $sUrl = $oUtils->prepareCanonicalUrl( $oProduct->getBaseSeoLink( $oProduct->getLanguage(), true ) );
01310             } else {
01311                 $sUrl = $oUtils->prepareCanonicalUrl( $oProduct->getBaseStdLink( $oProduct->getLanguage() ) );
01312             }
01313             return $sUrl;
01314         }
01315     }
01316 
01322     public function isMdVariantView()
01323     {
01324         if ( $this->_blMdView === null ) {
01325             $this->_blMdView = false;
01326             if ( $this->getConfig()->getConfigParam( 'blUseMultidimensionVariants' ) ) {
01327                 $iMaxMdDepth = $this->getProduct()->getMdVariants()->getMaxDepth();
01328                 $this->_blMdView = ($iMaxMdDepth > 1);
01329             }
01330         }
01331 
01332         return $this->_blMdView;
01333     }
01334 
01340     public function isPersParam()
01341     {
01342         $oProduct = $this->getProduct();
01343         return $oProduct->oxarticles__oxisconfigurable->value;
01344     }
01345 
01351     public function getTagSeparator()
01352     {
01353         $sSepartor = $this->getConfig()->getConfigParam("sTagSeparator");
01354         return $sSepartor;
01355     }
01356 
01362     public function getRatingValue()
01363     {
01364 
01365         if ( $this->_dRatingValue === null ) {
01366             $this->_dRatingValue = (double) 0;
01367             if ( $this->isReviewActive() && ( $oDetailsProduct = $this->getProduct() ) ) {
01368                 $this->_dRatingValue = round( $oDetailsProduct->getArticleRatingAverage(), 1);
01369             }
01370         }
01371 
01372         return (double) $this->_dRatingValue;
01373     }
01374 
01380     public function isReviewActive()
01381     {
01382         return $this->getConfig()->getConfigParam( 'bl_perfLoadReviews' );
01383     }
01384 
01390     public function getRatingCount()
01391     {
01392         if ( $this->_iRatingCnt === null ) {
01393             $this->_iRatingCnt = false;
01394             if ( $this->isReviewActive() && ( $oDetailsProduct = $this->getProduct() ) ) {
01395                 $this->_iRatingCnt = $oDetailsProduct->oxarticles__oxratingcnt->value;
01396             }
01397         }
01398         return $this->_iRatingCnt;
01399     }
01400 
01406     public function getBreadCrumb()
01407     {
01408         $aPaths = array();
01409 
01410         if ( 'search' == oxConfig::getParameter( 'listtype' ) ) {
01411 
01412             $aCatPath = array();
01413             $aCatPath['title'] = sprintf(oxLang::getInstance()->translateString( 'searchResult', oxLang::getInstance()->getBaseLanguage(), false ), oxConfig::getParameter( 'searchparam' ));
01414             $sLink = $this->getViewConfig()->getSelfLink() . 'stoken=' . oxSession::getVar('sess_stoken')
01415                    . "&amp;cl=search&amp;searchparam=" . oxConfig::getParameter( 'searchparam' );
01416 
01417             $aCatPath['link']  = $sLink;
01418 
01419             $aPaths[] = $aCatPath;
01420 
01421         } elseif ( 'tag' == oxConfig::getParameter( 'listtype' ) ) {
01422 
01423             $aCatPath = array();
01424 
01425             $aCatPath['title'] = oxLang::getInstance()->translateString( 'TAGS', oxLang::getInstance()->getBaseLanguage(), false );
01426             $aCatPath['link']  = oxSeoEncoder::getInstance()->getStaticUrl( $this->getViewConfig()->getSelfLink() . 'cl=tags' );
01427             $aPaths[] = $aCatPath;
01428 
01429             $oStr = getStr();
01430             $aCatPath['title'] = $oStr->ucfirst(oxConfig::getParameter( 'searchtag' ));
01431             $aCatPath['link']  = oxSeoEncoderTag::getInstance()->getTagUrl( oxConfig::getParameter( 'searchtag' ) );
01432             $aPaths[] = $aCatPath;
01433 
01434         } elseif ( 'recommlist' == oxConfig::getParameter( 'listtype' ) ) {
01435 
01436             $aCatPath = array();
01437             $aCatPath['title'] = oxLang::getInstance()->translateString( 'PAGE_RECOMMENDATIONS_PRODUCTS_TITLE', oxLang::getInstance()->getBaseLanguage(), false );
01438             $aPaths[] = $aCatPath;
01439         } else {
01440 
01441             $oCatTree = $this->getCatTreePath();
01442 
01443             if ( $oCatTree ) {
01444 
01445                 foreach ( $oCatTree as $oCat ) {
01446                     $aCatPath = array();
01447 
01448                     $aCatPath['link'] = $oCat->getLink();
01449                     $aCatPath['title'] = $oCat->oxcategories__oxtitle->value;
01450 
01451                     $aPaths[] = $aCatPath;
01452                 }
01453             }
01454         }
01455 
01456         return $aPaths;
01457     }
01458 
01468     public function addme()
01469     {
01470         $myConfig = $this->getConfig();
01471         $myUtils  = oxUtils::getInstance();
01472 
01473         //control captcha
01474         $sMac     = oxConfig::getParameter( 'c_mac' );
01475         $sMacHash = oxConfig::getParameter( 'c_mach' );
01476         $oCaptcha = $this->getCaptcha();
01477         if ( !$oCaptcha->pass( $sMac, $sMacHash ) ) {
01478             $this->_iPriceAlarmStatus = 2;
01479             return;
01480         }
01481 
01482         $aParams = oxConfig::getParameter( 'pa' );
01483         if ( !isset( $aParams['email'] ) || !$myUtils->isValidEmail( $aParams['email'] ) ) {
01484             $this->_iPriceAlarmStatus = 0;
01485             return;
01486         }
01487         $aParams['aid'] = $this->getProduct()->getId();
01488         $oCur = $myConfig->getActShopCurrencyObject();
01489         // convert currency to default
01490         $dPrice = $myUtils->currency2Float( $aParams['price'] );
01491 
01492         $oAlarm = oxNew( "oxpricealarm" );
01493         $oAlarm->oxpricealarm__oxuserid = new oxField( oxSession::getVar( 'usr' ));
01494         $oAlarm->oxpricealarm__oxemail  = new oxField( $aParams['email']);
01495         $oAlarm->oxpricealarm__oxartid  = new oxField( $aParams['aid']);
01496         $oAlarm->oxpricealarm__oxprice  = new oxField( $myUtils->fRound( $dPrice, $oCur ));
01497         $oAlarm->oxpricealarm__oxshopid = new oxField( $myConfig->getShopId());
01498         $oAlarm->oxpricealarm__oxcurrency = new oxField( $oCur->name);
01499 
01500         $oAlarm->oxpricealarm__oxlang = new oxField(oxLang::getInstance()->getBaseLanguage());
01501 
01502         $oAlarm->save();
01503 
01504         // Send Email
01505         $oEmail = oxNew( 'oxemail' );
01506         $this->_iPriceAlarmStatus = (int) $oEmail->sendPricealarmNotification( $aParams, $oAlarm );
01507     }
01508 
01514     public function getPriceAlarmStatus()
01515     {
01516         return $this->_iPriceAlarmStatus;
01517     }
01518 
01524     public function getBidPrice()
01525     {
01526         if ( $this->_sBidPrice === null ) {
01527             $this->_sBidPrice = false;
01528 
01529             $aParams = oxConfig::getParameter( 'pa' );
01530             $oCur = $this->getConfig()->getActShopCurrencyObject();
01531             $iPrice = oxUtils::getInstance()->currency2Float( $aParams['price'] );
01532             $this->_sBidPrice = oxLang::getInstance()->formatCurrency( $iPrice, $oCur );
01533         }
01534         return $this->_sBidPrice;
01535     }
01536 
01542     public function getVariantSelections()
01543     {
01544         // finding parent
01545         $oProduct = $this->getProduct();
01546         if ( ( $oParent = $this->_getParentProduct( $oProduct->oxarticles__oxparentid->value ) ) ) {
01547             return $oParent->getVariantSelections( oxConfig::getParameter( "varselid" ), $oProduct->getId() );
01548         }
01549 
01550         return $oProduct->getVariantSelections( oxConfig::getParameter( "varselid" ) );
01551     }
01552 
01558     public function getPicturesProduct()
01559     {
01560         $aVariantSelections = $this->getVariantSelections();
01561         if ($aVariantSelections && $aVariantSelections['oActiveVariant'] && !$aVariantSelections['blPerfectFit']) {
01562             return $aVariantSelections['oActiveVariant'];
01563         }
01564         return $this->getProduct();
01565     }
01566 
01567 
01573     public function isMoreTagsVisible()
01574     {
01575         return true;
01576     }
01577 
01583     public function getSearchParamForHtml()
01584     {
01585         if ( $this->_sSearchParamForHtml === null ) {
01586             $this->_sSearchParamForHtml = oxConfig::getParameter( 'searchparam' );
01587         }
01588         return $this->_sSearchParamForHtml;
01589     }
01590 
01591 }