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         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->getArticleLongDesc()->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 canRate()
00452     {
00453         if ( $this->_blCanRate === null ) {
00454 
00455             $this->_blCanRate = false;
00456             $myConfig = $this->getConfig();
00457 
00458             if ( $myConfig->getConfigParam( 'bl_perfLoadReviews' ) &&
00459                  $oUser = $this->getUser() ) {
00460 
00461                 $oRating = oxNew( 'oxrating' );
00462                 $this->_blCanRate = $oRating->allowRating( $oUser->getId(), 'oxarticle', $this->getProduct()->getId() );
00463             }
00464         }
00465         return $this->_blCanRate;
00466     }
00467 
00473     public function canChangeTags()
00474     {
00475         if ( $oUser = $this->getUser() ) {
00476 
00477             return true;
00478         }
00479         return false;
00480     }
00481 
00487     public function saveReview()
00488     {
00489         if ( $this->canAcceptFormData() &&
00490              ( $oUser = $this->getUser() ) && ( $oProduct = $this->getProduct() ) ) {
00491 
00492             $dRating = oxConfig::getParameter( 'artrating' );
00493             if ( $dRating !== null ) {
00494                 $dRating = (int) $dRating;
00495             }
00496 
00497             //save rating
00498             if ( $dRating !== null && $dRating >= 0 && $dRating <= 5 ) {
00499                 $oRating = oxNew( 'oxrating' );
00500                 if ( $oRating->allowRating( $oUser->getId(), 'oxarticle', $oProduct->getId() ) ) {
00501                     $oRating->oxratings__oxuserid   = new oxField( $oUser->getId() );
00502                     $oRating->oxratings__oxtype     = new oxField( 'oxarticle' );
00503                     $oRating->oxratings__oxobjectid = new oxField( $oProduct->getId() );
00504                     $oRating->oxratings__oxrating   = new oxField( $dRating );
00505                     $oRating->save();
00506                     $oProduct->addToRatingAverage( $dRating );
00507                 }
00508             }
00509 
00510             if ( ( $sReviewText = trim( ( string ) oxConfig::getParameter( 'rvw_txt', true ) ) ) ) {
00511                 $oReview = oxNew( 'oxreview' );
00512                 $oReview->oxreviews__oxobjectid = new oxField( $oProduct->getId() );
00513                 $oReview->oxreviews__oxtype     = new oxField( 'oxarticle' );
00514                 $oReview->oxreviews__oxtext     = new oxField( $sReviewText, oxField::T_RAW );
00515                 $oReview->oxreviews__oxlang     = new oxField( oxLang::getInstance()->getBaseLanguage() );
00516                 $oReview->oxreviews__oxuserid   = new oxField( $oUser->getId() );
00517                 $oReview->oxreviews__oxrating   = new oxField( ( $dRating !== null ) ? $dRating : null );
00518                 $oReview->save();
00519             }
00520         }
00521     }
00522 
00528     public function addToRecomm()
00529     {
00530         if (!$this->getViewConfig()->getShowListmania()) {
00531             return;
00532         }
00533 
00534         $sRecommText = trim( ( string ) oxConfig::getParameter( 'recomm_txt' ) );
00535         $sRecommList = oxConfig::getParameter( 'recomm' );
00536         $sArtId      = $this->getProduct()->getId();
00537 
00538         if ( $sArtId ) {
00539             $oRecomm = oxNew( 'oxrecommlist' );
00540             $oRecomm->load( $sRecommList);
00541             $oRecomm->addArticle( $sArtId, $sRecommText );
00542         }
00543     }
00544 
00550     public function addTags()
00551     {
00552         $sTag  = $this->getConfig()->getParameter('newTags', true );
00553         $sHighTag  = $this->getConfig()->getParameter( 'highTags', true );
00554         if ( !$sTag && !$sHighTag) {
00555             return;
00556         }
00557         if ( $sHighTag ) {
00558             $sTag = getStr()->html_entity_decode( $sHighTag );
00559         }
00560 
00561         //can tag only once per product and tags
00562         $aTags = array();
00563         $oProduct = $this->getProduct();
00564         $aTaggedProducts = oxSession::getVar("aTaggedProducts");
00565         if ( $aTaggedProducts ) {
00566             $aTags = $aTaggedProducts[$oProduct->getId()];
00567         }
00568         $blAddedTag = false;
00569         //Checks if user already tagged it
00570         if ( $aTags[$sTag] != 1 ) {
00571             $oProduct->addTag( $sTag );
00572             $aTags[$sTag] = 1;
00573             $aTaggedProducts[$oProduct->getId()] = $aTags;
00574             oxSession::setVar( 'aTaggedProducts', $aTaggedProducts);
00575             $blAddedTag = true;
00576         }
00577         // for ajax call
00578         if ($this->getConfig()->getParameter('blAjax', true )) {
00579             die($blAddedTag);
00580         }
00581     }
00582 
00588     public function editTags()
00589     {
00590         if ( !$this->getUser() ) {
00591             return;
00592         }
00593         $oTagCloud = oxNew("oxTagCloud");
00594         $this->_aTags = $oTagCloud->getTags( $this->getProduct()->getId() );
00595         $this->_blEditTags = true;
00596 
00597         // for ajax call
00598         if ($this->getConfig()->getParameter('blAjax', true )) {
00599             oxUtils::getInstance()->setHeader( "Content-Type: text/html; charset=".oxLang::getInstance()->translateString( 'charset' ) );
00600             $oActView = oxNew( 'oxubase' );
00601             $oSmarty = oxUtilsView::getInstance()->getSmarty();
00602             $oSmarty->assign('oView', $this );
00603             $oSmarty->assign('oViewConf', $this->getViewConfig() );
00604             die($oSmarty->fetch( 'page/details/inc/editTags.tpl', $this->getViewId() ));
00605         }
00606     }
00607 
00613     public function cancelTags()
00614     {
00615         $oTagCloud = oxNew("oxTagCloud");
00616         $this->_aTags = $oTagCloud->getTags( $this->getProduct()->getId() );
00617         $this->_blEditTags = false;
00618 
00619         // for ajax call
00620         if ($this->getConfig()->getParameter('blAjax', true )) {
00621             oxUtils::getInstance()->setHeader( "Content-Type: text/html; charset=".oxLang::getInstance()->translateString( 'charset' ) );
00622             $oActView = oxNew( 'oxubase' );
00623             $oSmarty = oxUtilsView::getInstance()->getSmarty();
00624             $oSmarty->assign('oView', $this );
00625             $oSmarty->assign('oViewConf', $this->getViewConfig() );
00626             die($oSmarty->fetch( 'page/details/inc/tags.tpl', $this->getViewId() ));
00627         }
00628     }
00629 
00635     protected function _getSeoObjectId()
00636     {
00637         if ( $oProduct = $this->getProduct() ) {
00638             return $oProduct->getId();
00639         }
00640     }
00641 
00647     public function getAttributes()
00648     {
00649         if ( $this->_aAttributes === null ) {
00650             // all attributes this article has
00651             $aArtAttributes = $this->getProduct()->getAttributes();
00652 
00653             //making a new array for backward compatibility
00654             $this->_aAttributes = false;
00655 
00656             if ( count( $aArtAttributes ) ) {
00657                 foreach ( $aArtAttributes as $sKey => $oAttribute ) {
00658                     $this->_aAttributes[$sKey] = new stdClass();
00659                     $this->_aAttributes[$sKey]->title = $oAttribute->oxattribute__oxtitle->value;
00660                     $this->_aAttributes[$sKey]->value = $oAttribute->oxattribute__oxvalue->value;
00661                 }
00662             }
00663         }
00664         return $this->_aAttributes;
00665     }
00666 
00667 
00673     public function getEditTags()
00674     {
00675         return $this->_blEditTags;
00676     }
00677 
00683     public function getTags()
00684     {
00685         return $this->_aTags;
00686     }
00687 
00693     public function getTagCloudManager()
00694     {
00695         $oManager = oxNew( "oxTagCloud" );
00696         $oManager->setExtendedMode( true );
00697         $oManager->setProductId( $this->getProduct()->getId() );
00698         return $oManager;
00699     }
00700 
00707     public function isEditableTags()
00708     {
00709         if ( $this->_blCanEditTags === null ) {
00710             $this->_blCanEditTags = false;
00711             if ( $this->getProduct() && $this->getUser()) {
00712                 $this->_blCanEditTags = true;
00713             }
00714         }
00715         return $this->_blCanEditTags;
00716     }
00717 
00723     public function getProduct()
00724     {
00725         $myConfig = $this->getConfig();
00726         $myUtils = oxUtils::getInstance();
00727 
00728         if ( $this->_oProduct === null ) {
00729 
00730             //this option is only for lists and we must reset value
00731             //as blLoadVariants = false affect "ab price" functionality
00732             $myConfig->setConfigParam( 'blLoadVariants', true );
00733 
00734             $sOxid = oxConfig::getParameter( 'anid' );
00735 
00736             // object is not yet loaded
00737             $this->_oProduct = oxNew( 'oxarticle' );
00738             //$this->_oProduct->setSkipAbPrice( true );
00739 
00740             if ( !$this->_oProduct->load( $sOxid ) ) {
00741                 $myUtils->redirect( $myConfig->getShopHomeURL() );
00742                 $myUtils->showMessageAndExit( '' );
00743             }
00744 
00745             $aVariantSelections = $this->_oProduct->getVariantSelections( oxConfig::getParameter( "varselid" ) );
00746             if ($aVariantSelections && $aVariantSelections['oActiveVariant'] && $aVariantSelections['blPerfectFit']) {
00747                 $this->_oProduct = $aVariantSelections['oActiveVariant'];
00748             }
00749         }
00750 
00751         // additional checks
00752         if ( !$this->_blIsInitialized ) {
00753 
00754             $blContinue = true;
00755             if ( !$this->_oProduct->isVisible() ) {
00756                 $blContinue = false;
00757             } elseif ( $this->_oProduct->oxarticles__oxparentid->value ) {
00758                 $oParent = $this->_getParentProduct( $this->_oProduct->oxarticles__oxparentid->value );
00759                 if ( !$oParent || !$oParent->isVisible() ) {
00760                     $blContinue = false;
00761                 }
00762             }
00763 
00764             if ( !$blContinue ) {
00765                 $myUtils->redirect( $myConfig->getShopHomeURL() );
00766                 $myUtils->showMessageAndExit( '' );
00767             }
00768 
00769             $this->_processProduct( $this->_oProduct );
00770             $this->_blIsInitialized = true;
00771         }
00772 
00773         return $this->_oProduct;
00774     }
00775 
00781     public function getLinkType()
00782     {
00783         if ( $this->_iLinkType === null ) {
00784             $sListType = oxConfig::getParameter( 'listtype' );
00785             if ( 'vendor' == $sListType ) {
00786                 $this->_iLinkType = OXARTICLE_LINKTYPE_VENDOR;
00787             } elseif ( 'manufacturer' == $sListType ) {
00788                     $this->_iLinkType = OXARTICLE_LINKTYPE_MANUFACTURER;
00789             } elseif ( 'tag' == $sListType ) {
00790                     $this->_iLinkType = OXARTICLE_LINKTYPE_TAG;
00791             } elseif ( 'recommlist' == $sListType ) {
00792                     $this->_iLinkType = OXARTICLE_LINKTYPE_RECOMM;
00793             } else {
00794                 $this->_iLinkType = OXARTICLE_LINKTYPE_CATEGORY;
00795 
00796                 // price category has own type..
00797                 if ( ( $oCat = $this->getActCategory() ) && $oCat->isPriceCategory() ) {
00798                     $this->_iLinkType = OXARTICLE_LINKTYPE_PRICECATEGORY;
00799                 }
00800             }
00801         }
00802 
00803         return $this->_iLinkType;
00804     }
00805 
00811     public function getVariantList()
00812     {
00813         return $this->loadVariantInformation();
00814     }
00815 
00822     public function getVariantListExceptCurrent()
00823     {
00824         $oList = $this->getVariantList();
00825         if (is_object($oList)) {
00826             $oList = clone $oList;
00827         }
00828 
00829         $sOxid = $this->getProduct()->getId();
00830         if (isset($oList[$sOxid])) {
00831             unset($oList[$sOxid]);
00832         }
00833         return $oList;
00834     }
00835 
00841     public function getCaptcha()
00842     {
00843         if ( $this->_oCaptcha === null ) {
00844             $this->_oCaptcha = oxNew('oxCaptcha');
00845         }
00846         return $this->_oCaptcha;
00847     }
00848 
00854     public function getMediaFiles()
00855     {
00856         if ( $this->_aMediaFiles === null ) {
00857             $aMediaFiles = $this->getProduct()->getMediaUrls();
00858             $this->_aMediaFiles = count($aMediaFiles) ? $aMediaFiles : false;
00859         }
00860         return $this->_aMediaFiles;
00861     }
00862 
00870     public function getLastProducts( $iCnt = 4 )
00871     {
00872         if ( $this->_aLastProducts === null ) {
00873             //last seen products for #768CA
00874             $oProduct = $this->getProduct();
00875             $sArtId = $oProduct->oxarticles__oxparentid->value?$oProduct->oxarticles__oxparentid->value:$oProduct->getId();
00876 
00877             $oHistoryArtList = oxNew( 'oxarticlelist' );
00878             $oHistoryArtList->loadHistoryArticles( $sArtId, $iCnt );
00879             $this->_aLastProducts = $oHistoryArtList;
00880         }
00881         return $this->_aLastProducts;
00882     }
00883 
00889     public function getVendor()
00890     {
00891         if ( $this->_oVendor === null ) {
00892             $this->_oVendor = $this->getProduct()->getVendor( false );
00893         }
00894         return $this->_oVendor;
00895     }
00896 
00902     public function getManufacturer()
00903     {
00904         if ( $this->_oManufacturer === null ) {
00905             $this->_oManufacturer = $this->getProduct()->getManufacturer( false );
00906         }
00907         return $this->_oManufacturer;
00908     }
00909 
00915     public function getCategory()
00916     {
00917         if ( $this->_oCategory === null ) {
00918             $this->_oCategory = $this->getProduct()->getCategory();
00919         }
00920         return $this->_oCategory;
00921     }
00922 
00928     public function drawParentUrl()
00929     {
00930         return $this->getProduct()->isVariant();
00931     }
00932 
00938     public function getParentName()
00939     {
00940         if ( $this->_sParentName === null ) {
00941             $this->_sParentName = false;
00942             if ( ( $oParent = $this->_getParentProduct( $this->getProduct()->oxarticles__oxparentid->value ) ) ) {
00943                 $this->_sParentName = $oParent->oxarticles__oxtitle->value;
00944             }
00945         }
00946         return $this->_sParentName;
00947     }
00948 
00954     public function getParentUrl()
00955     {
00956         if ( $this->_sParentUrl === null ) {
00957             $this->_sParentUrl = false;
00958             if ( ( $oParent = $this->_getParentProduct( $this->getProduct()->oxarticles__oxparentid->value ) ) ) {
00959                 $this->_sParentUrl = $oParent->getLink();
00960             }
00961         }
00962         return $this->_sParentUrl;
00963     }
00964 
00970     public function getPictureGallery()
00971     {
00972         if ( $this->_aPicGallery === null ) {
00973             //get picture gallery
00974             $this->_aPicGallery = $this->getPicturesProduct()->getPictureGallery();
00975         }
00976         return $this->_aPicGallery;
00977     }
00978 
00984     public function getActPictureId()
00985     {
00986         $aPicGallery = $this->getPictureGallery();
00987         return $aPicGallery['ActPicID'];
00988     }
00989 
00995     public function getActPicture()
00996     {
00997         $aPicGallery = $this->getPictureGallery();
00998         return $aPicGallery['ActPic'];
00999     }
01000 
01006     public function morePics()
01007     {
01008         $aPicGallery = $this->getPictureGallery();
01009         return $aPicGallery['MorePics'];
01010     }
01011 
01017     public function getPictures()
01018     {
01019         $aPicGallery = $this->getPictureGallery();
01020         return $aPicGallery['Pics'];
01021     }
01022 
01030     public function getArtPic( $sPicNr )
01031     {
01032         $aPicGallery = $this->getPictureGallery();
01033         return $aPicGallery['Pics'][$sPicNr];
01034     }
01035 
01041     public function getIcons()
01042     {
01043         $aPicGallery = $this->getPictureGallery();
01044         return $aPicGallery['Icons'];
01045     }
01046 
01052     public function showZoomPics()
01053     {
01054         $aPicGallery = $this->getPictureGallery();
01055         return $aPicGallery['ZoomPic'];
01056     }
01057 
01063     public function getZoomPics()
01064     {
01065         $aPicGallery = $this->getPictureGallery();
01066         return $aPicGallery['ZoomPics'];
01067     }
01068 
01074     public function getActZoomPic()
01075     {
01076         return 1;
01077     }
01078 
01084     public function getSelectLists()
01085     {
01086         if ( $this->_aSelectLists === null ) {
01087             $this->_aSelectLists = false;
01088             if ( $this->getConfig()->getConfigParam( 'bl_perfLoadSelectLists' ) ) {
01089                 $this->_aSelectLists = $this->getProduct()->getSelectLists();
01090             }
01091         }
01092         return $this->_aSelectLists;
01093     }
01094 
01100     public function getReviews()
01101     {
01102         if ( $this->_aReviews === null ) {
01103             $this->_aReviews = false;
01104             if ( $this->getConfig()->getConfigParam( 'bl_perfLoadReviews' ) ) {
01105                 $this->_aReviews = $this->getProduct()->getReviews();
01106             }
01107         }
01108         return $this->_aReviews;
01109     }
01110 
01116     public function getCrossSelling()
01117     {
01118         if ( $this->_oCrossSelling === null ) {
01119             $this->_oCrossSelling = false;
01120             if ( $oProduct = $this->getProduct() ) {
01121                 $this->_oCrossSelling = $oProduct->getCrossSelling();
01122             }
01123         }
01124         return $this->_oCrossSelling;
01125     }
01126 
01132     public function getSimilarProducts()
01133     {
01134         if ( $this->_oSimilarProducts === null ) {
01135             $this->_oSimilarProducts = false;
01136             if ( $oProduct = $this->getProduct() ) {
01137                 $this->_oSimilarProducts = $oProduct->getSimilarProducts();
01138             }
01139         }
01140         return $this->_oSimilarProducts;
01141     }
01142 
01148     public function getSimilarRecommLists()
01149     {
01150         if (!$this->getViewConfig()->getShowListmania()) {
01151             return false;
01152         }
01153 
01154         if ( $this->_oRecommList === null ) {
01155             $this->_oRecommList = false;
01156             if ( $oProduct = $this->getProduct() ) {
01157                 $oRecommList = oxNew('oxrecommlist');
01158                 $this->_oRecommList = $oRecommList->getRecommListsByIds( array( $oProduct->getId() ) );
01159             }
01160         }
01161         return $this->_oRecommList;
01162     }
01163 
01169     public function getAccessoires()
01170     {
01171         if ( $this->_oAccessoires === null ) {
01172             $this->_oAccessoires = false;
01173             if ( $oProduct = $this->getProduct() ) {
01174                 $this->_oAccessoires = $oProduct->getAccessoires();
01175             }
01176         }
01177         return $this->_oAccessoires;
01178     }
01179 
01185     public function getAlsoBoughtTheseProducts()
01186     {
01187         if ( $this->_aAlsoBoughtArts === null ) {
01188             $this->_aAlsoBoughtArts = false;
01189             if ( $oProduct = $this->getProduct() ) {
01190                 $this->_aAlsoBoughtArts = $oProduct->getCustomerAlsoBoughtThisProducts();
01191             }
01192         }
01193         return $this->_aAlsoBoughtArts;
01194     }
01195 
01201     public function isPriceAlarm()
01202     {
01203         // #419 disabling pricealarm if article has fixed price
01204         $oProduct = $this->getProduct();
01205         if ( isset( $oProduct->oxarticles__oxblfixedprice->value ) && $oProduct->oxarticles__oxblfixedprice->value ) {
01206             return 0;
01207         }
01208         return 1;
01209     }
01210 
01219     protected function _getSubject( $iLang )
01220     {
01221         return $this->getProduct();
01222     }
01223 
01229     public function getSearchTitle()
01230     {
01231         return $this->_sSearchTitle;
01232     }
01233 
01241     public function setSearchTitle( $sTitle )
01242     {
01243         $this->_sSearchTitle = $sTitle;
01244     }
01245 
01253     public function setCatTreePath( $sActCatPath )
01254     {
01255         $this->_sCatTreePath = $sActCatPath;
01256     }
01257 
01264     public function noIndex()
01265     {
01266         $sListType = oxConfig::getParameter( 'listtype' );
01267         if ( $sListType && ( 'vendor' == $sListType || 'manufacturer' == $sListType ) ) {
01268             return $this->_iViewIndexState = VIEW_INDEXSTATE_NOINDEXFOLLOW;
01269         }
01270         return parent::noIndex();
01271     }
01272 
01278     public function getTitle()
01279     {
01280         if ( $oProduct = $this->getProduct() ) {
01281             return $oProduct->oxarticles__oxtitle->value . ( $oProduct->oxarticles__oxvarselect->value ? ' ' . $oProduct->oxarticles__oxvarselect->value : '' );
01282         }
01283     }
01284 
01285 
01291     public function getTag()
01292     {
01293         return oxConfig::getParameter("searchtag", 1);
01294     }
01295 
01301     public function getCanonicalUrl()
01302     {
01303         if ( ( $oProduct = $this->getProduct() ) ) {
01304             $oUtils = oxUtilsUrl::getInstance();
01305             if ( oxUtils::getInstance()->seoIsActive() ) {
01306                 $sUrl = $oUtils->prepareCanonicalUrl( $oProduct->getBaseSeoLink( $oProduct->getLanguage(), true ) );
01307             } else {
01308                 $sUrl = $oUtils->prepareCanonicalUrl( $oProduct->getBaseStdLink( $oProduct->getLanguage() ) );
01309             }
01310             return $sUrl;
01311         }
01312     }
01313 
01319     public function isMdVariantView()
01320     {
01321         if ( $this->_blMdView === null ) {
01322             $this->_blMdView = false;
01323             if ( $this->getConfig()->getConfigParam( 'blUseMultidimensionVariants' ) ) {
01324                 $iMaxMdDepth = $this->getProduct()->getMdVariants()->getMaxDepth();
01325                 $this->_blMdView = ($iMaxMdDepth > 1);
01326             }
01327         }
01328 
01329         return $this->_blMdView;
01330     }
01331 
01337     public function isPersParam()
01338     {
01339         $oProduct = $this->getProduct();
01340         return $oProduct->oxarticles__oxisconfigurable->value;
01341     }
01342 
01348     public function getTagSeparator()
01349     {
01350         $sSepartor = $this->getConfig()->getConfigParam("sTagSeparator");
01351         return $sSepartor;
01352     }
01353 
01359     public function getRatingValue()
01360     {
01361 
01362         if ( $this->_dRatingValue === null ) {
01363             $this->_dRatingValue = (double) 0;
01364             if ( $this->isReviewActive() && ( $oDetailsProduct = $this->getProduct() ) ) {
01365                 $this->_dRatingValue = round( $oDetailsProduct->getArticleRatingAverage(), 1);
01366             }
01367         }
01368 
01369         return (double) $this->_dRatingValue;
01370     }
01371 
01377     public function isReviewActive()
01378     {
01379         return $this->getConfig()->getConfigParam( 'bl_perfLoadReviews' );
01380     }
01381 
01387     public function getRatingCount()
01388     {
01389         if ( $this->_iRatingCnt === null ) {
01390             $this->_iRatingCnt = false;
01391             if ( $this->isReviewActive() && ( $oDetailsProduct = $this->getProduct() ) ) {
01392                 $this->_iRatingCnt = $oDetailsProduct->oxarticles__oxratingcnt->value;
01393             }
01394         }
01395         return $this->_iRatingCnt;
01396     }
01397 
01403     public function getBreadCrumb()
01404     {
01405         $aPaths = array();
01406 
01407         if ( 'search' == oxConfig::getParameter( 'listtype' ) ) {
01408             $sSearchParam = $this->getSearchParamForHtml();
01409 
01410             $aCatPath = array();
01411             $aCatPath['title'] = sprintf( oxLang::getInstance()->translateString( 'searchResult', oxLang::getInstance()->getBaseLanguage(), false ), $sSearchParam );
01412             $aCatPath['link']  = $this->getViewConfig()->getSelfLink() . 'stoken=' . oxSession::getVar('sess_stoken') . "&amp;cl=search&amp;searchparam=" . $sSearchParam;
01413 
01414             $aPaths[] = $aCatPath;
01415 
01416         } elseif ( 'tag' == oxConfig::getParameter( 'listtype' ) ) {
01417 
01418             $aCatPath = array();
01419 
01420             $aCatPath['title'] = oxLang::getInstance()->translateString( 'TAGS', oxLang::getInstance()->getBaseLanguage(), false );
01421             $aCatPath['link']  = oxSeoEncoder::getInstance()->getStaticUrl( $this->getViewConfig()->getSelfLink() . 'cl=tags' );
01422             $aPaths[] = $aCatPath;
01423 
01424             $oStr = getStr();
01425             $aCatPath['title'] = $oStr->ucfirst(oxConfig::getParameter( 'searchtag' ));
01426             $aCatPath['link']  = oxSeoEncoderTag::getInstance()->getTagUrl( oxConfig::getParameter( 'searchtag' ) );
01427             $aPaths[] = $aCatPath;
01428 
01429         } elseif ( 'recommlist' == oxConfig::getParameter( 'listtype' ) ) {
01430 
01431             $aCatPath = array();
01432             $aCatPath['title'] = oxLang::getInstance()->translateString( 'PAGE_RECOMMENDATIONS_PRODUCTS_TITLE', oxLang::getInstance()->getBaseLanguage(), false );
01433             $aPaths[] = $aCatPath;
01434         } else {
01435 
01436             $oCatTree = $this->getCatTreePath();
01437 
01438             if ( $oCatTree ) {
01439 
01440                 foreach ( $oCatTree as $oCat ) {
01441                     $aCatPath = array();
01442 
01443                     $aCatPath['link'] = $oCat->getLink();
01444                     $aCatPath['title'] = $oCat->oxcategories__oxtitle->value;
01445 
01446                     $aPaths[] = $aCatPath;
01447                 }
01448             }
01449         }
01450 
01451         return $aPaths;
01452     }
01453 
01463     public function addme()
01464     {
01465         $myConfig = $this->getConfig();
01466         $myUtils  = oxUtils::getInstance();
01467 
01468         //control captcha
01469         $sMac     = oxConfig::getParameter( 'c_mac' );
01470         $sMacHash = oxConfig::getParameter( 'c_mach' );
01471         $oCaptcha = $this->getCaptcha();
01472         if ( !$oCaptcha->pass( $sMac, $sMacHash ) ) {
01473             $this->_iPriceAlarmStatus = 2;
01474             return;
01475         }
01476 
01477         $aParams = oxConfig::getParameter( 'pa' );
01478         if ( !isset( $aParams['email'] ) || !$myUtils->isValidEmail( $aParams['email'] ) ) {
01479             $this->_iPriceAlarmStatus = 0;
01480             return;
01481         }
01482         $aParams['aid'] = $this->getProduct()->getId();
01483         $oCur = $myConfig->getActShopCurrencyObject();
01484         // convert currency to default
01485         $dPrice = $myUtils->currency2Float( $aParams['price'] );
01486 
01487         $oAlarm = oxNew( "oxpricealarm" );
01488         $oAlarm->oxpricealarm__oxuserid = new oxField( oxSession::getVar( 'usr' ));
01489         $oAlarm->oxpricealarm__oxemail  = new oxField( $aParams['email']);
01490         $oAlarm->oxpricealarm__oxartid  = new oxField( $aParams['aid']);
01491         $oAlarm->oxpricealarm__oxprice  = new oxField( $myUtils->fRound( $dPrice, $oCur ));
01492         $oAlarm->oxpricealarm__oxshopid = new oxField( $myConfig->getShopId());
01493         $oAlarm->oxpricealarm__oxcurrency = new oxField( $oCur->name);
01494 
01495         $oAlarm->oxpricealarm__oxlang = new oxField(oxLang::getInstance()->getBaseLanguage());
01496 
01497         $oAlarm->save();
01498 
01499         // Send Email
01500         $oEmail = oxNew( 'oxemail' );
01501         $this->_iPriceAlarmStatus = (int) $oEmail->sendPricealarmNotification( $aParams, $oAlarm );
01502     }
01503 
01509     public function getPriceAlarmStatus()
01510     {
01511         return $this->_iPriceAlarmStatus;
01512     }
01513 
01519     public function getBidPrice()
01520     {
01521         if ( $this->_sBidPrice === null ) {
01522             $this->_sBidPrice = false;
01523 
01524             $aParams = oxConfig::getParameter( 'pa' );
01525             $oCur = $this->getConfig()->getActShopCurrencyObject();
01526             $iPrice = oxUtils::getInstance()->currency2Float( $aParams['price'] );
01527             $this->_sBidPrice = oxLang::getInstance()->formatCurrency( $iPrice, $oCur );
01528         }
01529         return $this->_sBidPrice;
01530     }
01531 
01537     public function getVariantSelections()
01538     {
01539         // finding parent
01540         $oProduct = $this->getProduct();
01541         if ( ( $oParent = $this->_getParentProduct( $oProduct->oxarticles__oxparentid->value ) ) ) {
01542             return $oParent->getVariantSelections( oxConfig::getParameter( "varselid" ), $oProduct->getId() );
01543         }
01544 
01545         return $oProduct->getVariantSelections( oxConfig::getParameter( "varselid" ) );
01546     }
01547 
01553     public function getPicturesProduct()
01554     {
01555         $aVariantSelections = $this->getVariantSelections();
01556         if ($aVariantSelections && $aVariantSelections['oActiveVariant'] && !$aVariantSelections['blPerfectFit']) {
01557             return $aVariantSelections['oActiveVariant'];
01558         }
01559         return $this->getProduct();
01560     }
01561 
01562 
01568     public function isMoreTagsVisible()
01569     {
01570         return true;
01571     }
01572 
01578     public function getSearchParamForHtml()
01579     {
01580         if ( $this->_sSearchParamForHtml === null ) {
01581             $this->_sSearchParamForHtml = oxConfig::getParameter( 'searchparam' );
01582         }
01583         return $this->_sSearchParamForHtml;
01584     }
01585 
01586 }