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 $_sBidPrice = null;
00215 
00220     protected $_iPriceAlarmStatus = null;
00221 
00226     protected $_sSearchParamForHtml = null;
00227 
00233     protected $_aSimilarRecommListIds = null;
00234 
00235 
00243     protected function _getParentProduct( $sParentId )
00244     {
00245         if ( $sParentId && $this->_oParentProd === null ) {
00246             $this->_oParentProd = false;
00247             $oProduct = oxNew( 'oxArticle' );
00248             if ( ( $oProduct->load( $sParentId ) ) ) {
00249                 $this->_processProduct( $oProduct );
00250                 $this->_oParentProd = $oProduct;
00251             }
00252         }
00253         return $this->_oParentProd;
00254     }
00255 
00262     public function loadVariantInformation()
00263     {
00264         if ( $this->_aVariantList === null ) {
00265             $oProduct = $this->getProduct();
00266 
00267             //if we are child and do not have any variants then let's load all parent variants as ours
00268             if ( $oParent = $oProduct->getParentArticle() ) {
00269                 $myConfig = $this->getConfig();
00270 
00271                 $oParent->setNoVariantLoading(false);
00272                 $this->_aVariantList = $oParent->getFullVariants( false );
00273 
00274                 //lets additionally add parent article if it is sellable
00275                 if ( count( $this->_aVariantList ) && $myConfig->getConfigParam( 'blVariantParentBuyable' ) ) {
00276                     //#1104S if parent is buyable load selectlists too
00277                     $oParent->enablePriceLoad();
00278                     $oParent->aSelectlist = $oParent->getSelectLists();
00279                     $this->_aVariantList = array_merge( array( $oParent ), $this->_aVariantList->getArray() );
00280                 }
00281             } else {
00282                 //loading full list of variants
00283                 $this->_aVariantList = $oProduct->getFullVariants( false );
00284             }
00285 
00286             // setting link type for variants ..
00287             foreach ( $this->_aVariantList as $oVariant ) {
00288                 $this->_processProduct( $oVariant );
00289             }
00290 
00291         }
00292 
00293         return $this->_aVariantList;
00294     }
00295 
00301     protected function _getAddUrlParams()
00302     {
00303         if ( $this->getListType() == "search" ) {
00304             return $this->getDynUrlParams();
00305         }
00306     }
00307 
00315     protected function _processProduct( $oProduct )
00316     {
00317         $oProduct->setLinkType( $this->getLinkType() );
00318         if ( $sAddParams = $this->_getAddUrlParams() ) {
00319             $oProduct->appendLink( $sAddParams );
00320         }
00321     }
00322 
00328     public function getViewId()
00329     {
00330         if ( isset( $this->_sViewId )) {
00331             return $this->_sViewId;
00332         }
00333 
00334             $sViewId = parent::getViewId().'|'.oxConfig::getParameter( 'anid' ).'|';
00335 
00336 
00337         return $this->_sViewId = $sViewId;
00338     }
00339 
00340 
00352     public function render()
00353     {
00354         $myConfig = $this->getConfig();
00355 
00356         $oProduct = $this->getProduct();
00357 
00358         // assign template name
00359         if ( $oProduct->oxarticles__oxtemplate->value ) {
00360             $this->_sThisTemplate = $oProduct->oxarticles__oxtemplate->value;
00361         }
00362 
00363         if ( ( $sTplName = oxConfig::getParameter( 'tpl' ) ) ) {
00364             $this->_sThisTemplate = 'custom/'.basename ( $sTplName );
00365         }
00366 
00367         parent::render();
00368 
00369         $sPartial = oxConfig::getParameter('renderPartial');
00370         $this->addTplParam('renderPartial', $sPartial);
00371 
00372         switch ($sPartial) {
00373             case "productInfo":
00374                 return 'page/details/ajax/fullproductinfo.tpl';
00375                 break;
00376             case "detailsMain":
00377                 return 'page/details/ajax/productmain.tpl';
00378                 break;
00379             default:
00380                 // #785A loads and sets locator data
00381                 $oLocator = oxNew( 'oxlocator', $this->getListType() );
00382                 $oLocator->setLocatorData( $oProduct, $this );
00383 
00384                 if ($myConfig->getConfigParam( 'bl_rssRecommLists' ) && $this->getSimilarRecommListIds()) {
00385                     $oRss = oxNew('oxrssfeed');
00386                     $this->addRssFeed($oRss->getRecommListsTitle( $oProduct ), $oRss->getRecommListsUrl( $oProduct ), 'recommlists');
00387                 }
00388 
00389                 return $this->_sThisTemplate;
00390         }
00391     }
00392 
00404     protected function _prepareMetaDescription( $sMeta, $iLength = 200, $blDescTag = false )
00405     {
00406         if ( !$sMeta ) {
00407             $oProduct = $this->getProduct();
00408 
00409             if ( $this->getConfig()->getConfigParam( 'bl_perfParseLongDescinSmarty' ) ) {
00410                 $sMeta = $oProduct->getLongDesc();
00411             } else {
00412                 $sMeta = $oProduct->getLongDescription()->value;
00413             }
00414             if ( $sMeta == '' ) {
00415                 $sMeta = $oProduct->oxarticles__oxshortdesc->value;
00416             }
00417             $sMeta = $oProduct->oxarticles__oxtitle->value.' - '.$sMeta;
00418         }
00419         return parent::_prepareMetaDescription( $sMeta, $iLength, $blDescTag );
00420     }
00421 
00432     protected function _prepareMetaKeyword( $sKeywords, $blRemoveDuplicatedWords = true )
00433     {
00434         if ( !$sKeywords ) {
00435             $oProduct = $this->getProduct();
00436             $sKeywords = trim( $this->getTitle() );
00437 
00438             if ( $oCatTree = $this->getCategoryTree() ) {
00439                 foreach ( $oCatTree->getPath() as $oCat ) {
00440                     $sKeywords .= ", " . trim( $oCat->oxcategories__oxtitle->value );
00441                 }
00442             }
00443 
00444             //adding search keys info
00445             if ( $sSearchKeys = trim( $oProduct->oxarticles__oxsearchkeys->value ) ) {
00446                 $sKeywords .= ", ". $sSearchKeys;
00447             }
00448 
00449             $sKeywords = parent::_prepareMetaKeyword( $sKeywords, $blRemoveDuplicatedWords );
00450         }
00451 
00452         return $sKeywords;
00453     }
00454 
00460     public function ratingIsActive()
00461     {
00462         return $this->getConfig()->getConfigParam( 'bl_perfLoadReviews' );
00463     }
00464 
00470     public function canRate()
00471     {
00472         if ( $this->_blCanRate === null ) {
00473 
00474             $this->_blCanRate = false;
00475 
00476             if ( $this->ratingIsActive() && $oUser = $this->getUser() ) {
00477 
00478                 $oRating = oxNew( 'oxrating' );
00479                 $this->_blCanRate = $oRating->allowRating( $oUser->getId(), 'oxarticle', $this->getProduct()->getId() );
00480             }
00481         }
00482 
00483         return $this->_blCanRate;
00484     }
00485 
00491     public function canChangeTags()
00492     {
00493         if ( $oUser = $this->getUser() ) {
00494 
00495             return true;
00496         }
00497         return false;
00498     }
00499 
00505     public function saveReview()
00506     {
00507         if ( $this->canAcceptFormData() &&
00508              ( $oUser = $this->getUser() ) && ( $oProduct = $this->getProduct() ) ) {
00509 
00510             $dRating = oxConfig::getParameter( 'artrating' );
00511             if ( $dRating !== null ) {
00512                 $dRating = (int) $dRating;
00513             }
00514 
00515             //save rating
00516             if ( $dRating !== null && $dRating >= 1 && $dRating <= 5 ) {
00517                 $oRating = oxNew( 'oxrating' );
00518                 if ( $oRating->allowRating( $oUser->getId(), 'oxarticle', $oProduct->getId() ) ) {
00519                     $oRating->oxratings__oxuserid   = new oxField( $oUser->getId() );
00520                     $oRating->oxratings__oxtype     = new oxField( 'oxarticle' );
00521                     $oRating->oxratings__oxobjectid = new oxField( $oProduct->getId() );
00522                     $oRating->oxratings__oxrating   = new oxField( $dRating );
00523                     $oRating->save();
00524                     $oProduct->addToRatingAverage( $dRating );
00525                 }
00526             }
00527 
00528             if ( ( $sReviewText = trim( ( string ) oxConfig::getParameter( 'rvw_txt', true ) ) ) ) {
00529                 $oReview = oxNew( 'oxreview' );
00530                 $oReview->oxreviews__oxobjectid = new oxField( $oProduct->getId() );
00531                 $oReview->oxreviews__oxtype     = new oxField( 'oxarticle' );
00532                 $oReview->oxreviews__oxtext     = new oxField( $sReviewText, oxField::T_RAW );
00533                 $oReview->oxreviews__oxlang     = new oxField( oxRegistry::getLang()->getBaseLanguage() );
00534                 $oReview->oxreviews__oxuserid   = new oxField( $oUser->getId() );
00535                 $oReview->oxreviews__oxrating   = new oxField( ( $dRating !== null ) ? $dRating : 0);
00536                 $oReview->save();
00537             }
00538         }
00539     }
00540 
00546     public function addToRecomm()
00547     {
00548         if (!$this->getViewConfig()->getShowListmania()) {
00549             return;
00550         }
00551 
00552         $sRecommText = trim( ( string ) oxConfig::getParameter( 'recomm_txt' ) );
00553         $sRecommList = oxConfig::getParameter( 'recomm' );
00554         $sArtId      = $this->getProduct()->getId();
00555 
00556         if ( $sArtId ) {
00557             $oRecomm = oxNew( 'oxrecommlist' );
00558             $oRecomm->load( $sRecommList);
00559             $oRecomm->addArticle( $sArtId, $sRecommText );
00560         }
00561     }
00562 
00568     public function addTags()
00569     {
00570         $sTags  = $this->getConfig()->getRequestParameter('newTags', true );
00571         $sHighTag  = $this->getConfig()->getRequestParameter( 'highTags', true );
00572         if ( !$sTags && !$sHighTag) {
00573             return;
00574         }
00575         if ( $sHighTag ) {
00576             $sTags = getStr()->html_entity_decode( $sHighTag );
00577         }
00578         $oProduct = $this->getProduct();
00579 
00580         // set current user added tags for this article for later checking
00581         $aTaggedProducts = oxRegistry::getSession()->getVariable("aTaggedProducts");
00582         $aAddedTags = $aTaggedProducts? $aTaggedProducts[$oProduct->getId()] : array();
00583 
00584         $oArticleTagList = oxNew( "oxarticletaglist" );
00585         $oArticleTagList->load( $oProduct->getId() );
00586         $sSeparator = $oArticleTagList->get()->getSeparator();
00587         $aTags = explode( $sSeparator, $sTags );
00588         $blAddedTag = false;
00589         foreach ( $aTags as $sTag ) {
00590             $oTag = oxNew( "oxtag" );
00591             $oTag->set( $sTag );
00592             if ( $aAddedTags[$oTag->get()] != 1 ) {
00593                 $oArticleTagList->addTag( $oTag );
00594                 $aAddedTags[$oTag->get()] = 1;
00595                 $blAddedTag = true;
00596             }
00597         }
00598         if ( $blAddedTag ) {
00599             $oArticleTagList->save();
00600             $aTaggedProducts[$oProduct->getId()] = $aAddedTags;
00601             oxRegistry::getSession()->setVariable( 'aTaggedProducts', $aTaggedProducts);
00602         }
00603         // for ajax call
00604         if ( $this->getConfig()->getRequestParameter( 'blAjax', true ) ) {
00605             oxRegistry::getUtils()->showMessageAndExit( $blAddedTag );
00606         }
00607     }
00608 
00614     public function editTags()
00615     {
00616         if ( !$this->getUser() ) {
00617             return;
00618         }
00619         $oArticleTagList = oxNew("oxArticleTagList");
00620         $oArticleTagList->load( $this->getProduct()->getId() );
00621         $oTagSet = $oArticleTagList->get();
00622         $this->_aTags = $oTagSet->get();
00623         $this->_blEditTags = true;
00624 
00625         // for ajax call
00626         if ( $this->getConfig()->getRequestParameter( 'blAjax', true ) ) {
00627             oxRegistry::getUtils()->setHeader( "Content-Type: text/html; charset=".oxRegistry::getLang()->translateString( 'charset' ) );
00628             $oActView = oxNew( 'oxubase' );
00629             $oSmarty = oxRegistry::get("oxUtilsView")->getSmarty();
00630             $oSmarty->assign('oView', $this );
00631             $oSmarty->assign('oViewConf', $this->getViewConfig() );
00632             oxRegistry::getUtils()->showMessageAndExit( $oSmarty->fetch( 'page/details/inc/editTags.tpl', $this->getViewId() ) );
00633         }
00634     }
00635 
00641     public function cancelTags()
00642     {
00643         $oArticleTagList = oxNew("oxArticleTagList");
00644         $oArticleTagList->load( $this->getProduct()->getId() );
00645         $oTagSet = $oArticleTagList->get();
00646         $this->_aTags = $oTagSet->get();
00647         $this->_blEditTags = false;
00648 
00649         // for ajax call
00650         if ( oxConfig::getParameter( 'blAjax', true ) ) {
00651             oxRegistry::getUtils()->setHeader( "Content-Type: text/html; charset=".oxRegistry::getLang()->translateString( 'charset' ) );
00652             $oActView = oxNew( 'oxubase' );
00653             $oSmarty = oxRegistry::get("oxUtilsView")->getSmarty();
00654             $oSmarty->assign('oView', $this );
00655             $oSmarty->assign('oViewConf', $this->getViewConfig() );
00656             oxRegistry::getUtils()->showMessageAndExit( $oSmarty->fetch( 'page/details/inc/tags.tpl', $this->getViewId() ) );
00657         }
00658     }
00659 
00665     protected function _getSeoObjectId()
00666     {
00667         if ( $oProduct = $this->getProduct() ) {
00668             return $oProduct->getId();
00669         }
00670     }
00671 
00677     public function getAttributes()
00678     {
00679         if ( $this->_aAttributes === null ) {
00680             // all attributes this article has
00681             $aArtAttributes = $this->getProduct()->getAttributes();
00682 
00683             //making a new array for backward compatibility
00684             $this->_aAttributes = false;
00685 
00686             if ( count( $aArtAttributes ) ) {
00687                 foreach ( $aArtAttributes as $sKey => $oAttribute ) {
00688                     $this->_aAttributes[$sKey] = new stdClass();
00689                     $this->_aAttributes[$sKey]->title = $oAttribute->oxattribute__oxtitle->value;
00690                     $this->_aAttributes[$sKey]->value = $oAttribute->oxattribute__oxvalue->value;
00691                 }
00692             }
00693         }
00694         return $this->_aAttributes;
00695     }
00696 
00697 
00703     public function getEditTags()
00704     {
00705         return $this->_blEditTags;
00706     }
00707 
00713     public function getTags()
00714     {
00715         return $this->_aTags;
00716     }
00717 
00723     public function getTagCloudManager()
00724     {
00725         $oManager = oxNew( "oxTagCloud" );
00726         $oManager->setExtendedMode( true );
00727         $oManager->setProductId( $this->getProduct()->getId() );
00728         return $oManager;
00729     }
00730 
00737     public function isEditableTags()
00738     {
00739         if ( $this->_blCanEditTags === null ) {
00740             $this->_blCanEditTags = false;
00741             if ( $this->getProduct() && $this->getUser()) {
00742                 $this->_blCanEditTags = true;
00743             }
00744         }
00745         return $this->_blCanEditTags;
00746     }
00747 
00753     public function getProduct()
00754     {
00755         $myConfig = $this->getConfig();
00756         $myUtils = oxRegistry::getUtils();
00757 
00758         if ( $this->_oProduct === null ) {
00759 
00760             //this option is only for lists and we must reset value
00761             //as blLoadVariants = false affect "ab price" functionality
00762             $myConfig->setConfigParam( 'blLoadVariants', true );
00763 
00764             $sOxid = oxConfig::getParameter( 'anid' );
00765 
00766             // object is not yet loaded
00767             $this->_oProduct = oxNew( 'oxarticle' );
00768 
00769             if ( !$this->_oProduct->load( $sOxid ) ) {
00770                 $myUtils->redirect( $myConfig->getShopHomeURL() );
00771                 $myUtils->showMessageAndExit( '' );
00772             }
00773 
00774             $aVariantSelections = $this->_oProduct->getVariantSelections( oxConfig::getParameter( "varselid" ) );
00775             if ($aVariantSelections && $aVariantSelections['oActiveVariant'] && $aVariantSelections['blPerfectFit']) {
00776                 $this->_oProduct = $aVariantSelections['oActiveVariant'];
00777             }
00778         }
00779 
00780         // additional checks
00781         if ( !$this->_blIsInitialized ) {
00782 
00783             $blContinue = true;
00784             if ( !$this->_oProduct->isVisible() ) {
00785                 $blContinue = false;
00786             } elseif ( $this->_oProduct->oxarticles__oxparentid->value ) {
00787                 $oParent = $this->_getParentProduct( $this->_oProduct->oxarticles__oxparentid->value );
00788                 if ( !$oParent || !$oParent->isVisible() ) {
00789                     $blContinue = false;
00790                 }
00791             }
00792 
00793             if ( !$blContinue ) {
00794                 $myUtils->redirect( $myConfig->getShopHomeURL() );
00795                 $myUtils->showMessageAndExit( '' );
00796             }
00797 
00798             $this->_processProduct( $this->_oProduct );
00799             $this->_blIsInitialized = true;
00800         }
00801 
00802         return $this->_oProduct;
00803     }
00804 
00810     public function getLinkType()
00811     {
00812         if ( $this->_iLinkType === null ) {
00813             $sListType = oxConfig::getParameter( 'listtype' );
00814             if ( 'vendor' == $sListType ) {
00815                 $this->_iLinkType = OXARTICLE_LINKTYPE_VENDOR;
00816             } elseif ( 'manufacturer' == $sListType ) {
00817                     $this->_iLinkType = OXARTICLE_LINKTYPE_MANUFACTURER;
00818             } elseif ( 'tag' == $sListType ) {
00819                     $this->_iLinkType = OXARTICLE_LINKTYPE_TAG;
00820             } elseif ( 'recommlist' == $sListType ) {
00821                     $this->_iLinkType = OXARTICLE_LINKTYPE_RECOMM;
00822             } else {
00823                 $this->_iLinkType = OXARTICLE_LINKTYPE_CATEGORY;
00824 
00825                 // price category has own type..
00826                 if ( ( $oCat = $this->getActiveCategory() ) && $oCat->isPriceCategory() ) {
00827                     $this->_iLinkType = OXARTICLE_LINKTYPE_PRICECATEGORY;
00828                 }
00829             }
00830         }
00831 
00832         return $this->_iLinkType;
00833     }
00834 
00840     public function getVariantList()
00841     {
00842         return $this->loadVariantInformation();
00843     }
00844 
00851     public function getVariantListExceptCurrent()
00852     {
00853         $oList = $this->getVariantList();
00854         if (is_object($oList)) {
00855             $oList = clone $oList;
00856         }
00857 
00858         $sOxid = $this->getProduct()->getId();
00859         if (isset($oList[$sOxid])) {
00860             unset($oList[$sOxid]);
00861         }
00862         return $oList;
00863     }
00864 
00870     public function getCaptcha()
00871     {
00872         if ( $this->_oCaptcha === null ) {
00873             $this->_oCaptcha = oxNew('oxCaptcha');
00874         }
00875         return $this->_oCaptcha;
00876     }
00877 
00883     public function getMediaFiles()
00884     {
00885         if ( $this->_aMediaFiles === null ) {
00886             $aMediaFiles = $this->getProduct()->getMediaUrls();
00887             $this->_aMediaFiles = count($aMediaFiles) ? $aMediaFiles : false;
00888         }
00889         return $this->_aMediaFiles;
00890     }
00891 
00899     public function getLastProducts( $iCnt = 4 )
00900     {
00901         if ( $this->_aLastProducts === null ) {
00902             //last seen products for #768CA
00903             $oProduct = $this->getProduct();
00904             $sArtId = $oProduct->oxarticles__oxparentid->value?$oProduct->oxarticles__oxparentid->value:$oProduct->getId();
00905 
00906             $oHistoryArtList = oxNew( 'oxarticlelist' );
00907             $oHistoryArtList->loadHistoryArticles( $sArtId, $iCnt );
00908             $this->_aLastProducts = $oHistoryArtList;
00909         }
00910         return $this->_aLastProducts;
00911     }
00912 
00918     public function getVendor()
00919     {
00920         if ( $this->_oVendor === null ) {
00921             $this->_oVendor = $this->getProduct()->getVendor( false );
00922         }
00923         return $this->_oVendor;
00924     }
00925 
00931     public function getManufacturer()
00932     {
00933         if ( $this->_oManufacturer === null ) {
00934             $this->_oManufacturer = $this->getProduct()->getManufacturer( false );
00935         }
00936         return $this->_oManufacturer;
00937     }
00938 
00944     public function getCategory()
00945     {
00946         if ( $this->_oCategory === null ) {
00947             $this->_oCategory = $this->getProduct()->getCategory();
00948         }
00949         return $this->_oCategory;
00950     }
00951 
00957     public function drawParentUrl()
00958     {
00959         return $this->getProduct()->isVariant();
00960     }
00961 
00967     public function getParentName()
00968     {
00969         if ( $this->_sParentName === null ) {
00970             $this->_sParentName = false;
00971             if ( ( $oParent = $this->_getParentProduct( $this->getProduct()->oxarticles__oxparentid->value ) ) ) {
00972                 $this->_sParentName = $oParent->oxarticles__oxtitle->value;
00973             }
00974         }
00975         return $this->_sParentName;
00976     }
00977 
00983     public function getParentUrl()
00984     {
00985         if ( $this->_sParentUrl === null ) {
00986             $this->_sParentUrl = false;
00987             if ( ( $oParent = $this->_getParentProduct( $this->getProduct()->oxarticles__oxparentid->value ) ) ) {
00988                 $this->_sParentUrl = $oParent->getLink();
00989             }
00990         }
00991         return $this->_sParentUrl;
00992     }
00993 
00999     public function getPictureGallery()
01000     {
01001         if ( $this->_aPicGallery === null ) {
01002             //get picture gallery
01003             $this->_aPicGallery = $this->getPicturesProduct()->getPictureGallery();
01004         }
01005         return $this->_aPicGallery;
01006     }
01007 
01013     public function getActPictureId()
01014     {
01015         $aPicGallery = $this->getPictureGallery();
01016         return $aPicGallery['ActPicID'];
01017     }
01018 
01024     public function getActPicture()
01025     {
01026         $aPicGallery = $this->getPictureGallery();
01027         return $aPicGallery['ActPic'];
01028     }
01029 
01035     public function morePics()
01036     {
01037         $aPicGallery = $this->getPictureGallery();
01038         return $aPicGallery['MorePics'];
01039     }
01040 
01046     public function getPictures()
01047     {
01048         $aPicGallery = $this->getPictureGallery();
01049         return $aPicGallery['Pics'];
01050     }
01051 
01059     public function getArtPic( $sPicNr )
01060     {
01061         $aPicGallery = $this->getPictureGallery();
01062         return $aPicGallery['Pics'][$sPicNr];
01063     }
01064 
01070     public function getIcons()
01071     {
01072         $aPicGallery = $this->getPictureGallery();
01073         return $aPicGallery['Icons'];
01074     }
01075 
01081     public function showZoomPics()
01082     {
01083         $aPicGallery = $this->getPictureGallery();
01084         return $aPicGallery['ZoomPic'];
01085     }
01086 
01092     public function getZoomPics()
01093     {
01094         $aPicGallery = $this->getPictureGallery();
01095         return $aPicGallery['ZoomPics'];
01096     }
01097 
01103     public function getActZoomPic()
01104     {
01105         return 1;
01106     }
01107 
01113     public function getSelectLists()
01114     {
01115         if ( $this->_aSelectLists === null ) {
01116             $this->_aSelectLists = false;
01117             if ( $this->getConfig()->getConfigParam( 'bl_perfLoadSelectLists' ) ) {
01118                 $this->_aSelectLists = $this->getProduct()->getSelectLists();
01119             }
01120         }
01121         return $this->_aSelectLists;
01122     }
01123 
01129     public function getReviews()
01130     {
01131         if ( $this->_aReviews === null ) {
01132             $this->_aReviews = false;
01133             if ( $this->getConfig()->getConfigParam( 'bl_perfLoadReviews' ) ) {
01134                 $this->_aReviews = $this->getProduct()->getReviews();
01135             }
01136         }
01137         return $this->_aReviews;
01138     }
01139 
01145     public function getCrossSelling()
01146     {
01147         if ( $this->_oCrossSelling === null ) {
01148             $this->_oCrossSelling = false;
01149             if ( $oProduct = $this->getProduct() ) {
01150                 $this->_oCrossSelling = $oProduct->getCrossSelling();
01151             }
01152         }
01153         return $this->_oCrossSelling;
01154     }
01155 
01161     public function getSimilarProducts()
01162     {
01163         if ( $this->_oSimilarProducts === null ) {
01164             $this->_oSimilarProducts = false;
01165             if ( $oProduct = $this->getProduct() ) {
01166                 $this->_oSimilarProducts = $oProduct->getSimilarProducts();
01167             }
01168         }
01169         return $this->_oSimilarProducts;
01170     }
01171 
01177     public function getSimilarRecommListIds()
01178     {
01179         if ( $this->_aSimilarRecommListIds === null ) {
01180             $this->_aSimilarRecommListIds = false;
01181 
01182             if ( $oProduct = $this->getProduct() ) {
01183                 $this->_aSimilarRecommListIds = array( $oProduct->getId() );
01184             }
01185         }
01186         return $this->_aSimilarRecommListIds;
01187     }
01188 
01194     public function getAccessoires()
01195     {
01196         if ( $this->_oAccessoires === null ) {
01197             $this->_oAccessoires = false;
01198             if ( $oProduct = $this->getProduct() ) {
01199                 $this->_oAccessoires = $oProduct->getAccessoires();
01200             }
01201         }
01202         return $this->_oAccessoires;
01203     }
01204 
01210     public function getAlsoBoughtTheseProducts()
01211     {
01212         if ( $this->_aAlsoBoughtArts === null ) {
01213             $this->_aAlsoBoughtArts = false;
01214             if ( $oProduct = $this->getProduct() ) {
01215                 $this->_aAlsoBoughtArts = $oProduct->getCustomerAlsoBoughtThisProducts();
01216             }
01217         }
01218         return $this->_aAlsoBoughtArts;
01219     }
01220 
01226     public function isPriceAlarm()
01227     {
01228         // #419 disabling price alarm if article has fixed price
01229         $oProduct = $this->getProduct();
01230         if ( isset( $oProduct->oxarticles__oxblfixedprice->value ) && $oProduct->oxarticles__oxblfixedprice->value ) {
01231             return 0;
01232         }
01233         return 1;
01234     }
01235 
01244     protected function _getSubject( $iLang )
01245     {
01246         return $this->getProduct();
01247     }
01248 
01254     public function getSearchTitle()
01255     {
01256         return $this->_sSearchTitle;
01257     }
01258 
01266     public function setSearchTitle( $sTitle )
01267     {
01268         $this->_sSearchTitle = $sTitle;
01269     }
01270 
01278     public function setCatTreePath( $sActCatPath )
01279     {
01280         $this->_sCatTreePath = $sActCatPath;
01281     }
01282 
01289     public function noIndex()
01290     {
01291         $sListType = oxConfig::getParameter( 'listtype' );
01292         if ( $sListType && ( 'vendor' == $sListType || 'manufacturer' == $sListType ) ) {
01293             return $this->_iViewIndexState = VIEW_INDEXSTATE_NOINDEXFOLLOW;
01294         }
01295         return parent::noIndex();
01296     }
01297 
01303     public function getTitle()
01304     {
01305         if ( $oProduct = $this->getProduct() ) {
01306             return $oProduct->oxarticles__oxtitle->value . ( $oProduct->oxarticles__oxvarselect->value ? ' ' . $oProduct->oxarticles__oxvarselect->value : '' );
01307         }
01308     }
01309 
01310 
01316     public function getTag()
01317     {
01318         return oxConfig::getParameter("searchtag", 1);
01319     }
01320 
01326     public function getCanonicalUrl()
01327     {
01328         if ( ( $oProduct = $this->getProduct() ) ) {
01329             if ( $oProduct->oxarticles__oxparentid->value ) {
01330                 $oProduct = $this->_getParentProduct( $oProduct->oxarticles__oxparentid->value );
01331             }
01332 
01333             $oUtils = oxRegistry::get("oxUtilsUrl");
01334             if ( oxRegistry::getUtils()->seoIsActive() ) {
01335                 $sUrl = $oUtils->prepareCanonicalUrl( $oProduct->getBaseSeoLink( $oProduct->getLanguage(), true ) );
01336             } else {
01337                 $sUrl = $oUtils->prepareCanonicalUrl( $oProduct->getBaseStdLink( $oProduct->getLanguage() ) );
01338             }
01339             return $sUrl;
01340         }
01341     }
01342 
01348     public function isMdVariantView()
01349     {
01350         if ( $this->_blMdView === null ) {
01351             $this->_blMdView = false;
01352             if ( $this->getConfig()->getConfigParam( 'blUseMultidimensionVariants' ) ) {
01353                 $iMaxMdDepth = $this->getProduct()->getMdVariants()->getMaxDepth();
01354                 $this->_blMdView = ($iMaxMdDepth > 1);
01355             }
01356         }
01357 
01358         return $this->_blMdView;
01359     }
01360 
01366     public function isPersParam()
01367     {
01368         $oProduct = $this->getProduct();
01369         return $oProduct->oxarticles__oxisconfigurable->value;
01370     }
01371 
01377     public function getTagSeparator()
01378     {
01379         $sSepartor = $this->getConfig()->getConfigParam("sTagSeparator");
01380         return $sSepartor;
01381     }
01382 
01388     public function getRatingValue()
01389     {
01390 
01391         if ( $this->_dRatingValue === null ) {
01392             $this->_dRatingValue = (double) 0;
01393             if ( $this->isReviewActive() && ( $oDetailsProduct = $this->getProduct() ) ) {
01394                 $this->_dRatingValue = round( $oDetailsProduct->getArticleRatingAverage( $this->getConfig()->getConfigParam( 'blShowVariantReviews' ) ), 1);
01395             }
01396         }
01397 
01398         return (double) $this->_dRatingValue;
01399     }
01400 
01406     public function isReviewActive()
01407     {
01408         return $this->getConfig()->getConfigParam( 'bl_perfLoadReviews' );
01409     }
01410 
01416     public function getRatingCount()
01417     {
01418         if ( $this->_iRatingCnt === null ) {
01419             $this->_iRatingCnt = false;
01420             if ( $this->isReviewActive() && ( $oDetailsProduct = $this->getProduct() ) ) {
01421                 $this->_iRatingCnt = $oDetailsProduct->getArticleRatingCount( $this->getConfig()->getConfigParam( 'blShowVariantReviews' ) );
01422             }
01423         }
01424         return $this->_iRatingCnt;
01425     }
01426 
01432     public function getBreadCrumb()
01433     {
01434         $aPaths = array();
01435 
01436         if ( 'search' == oxConfig::getParameter( 'listtype' ) ) {
01437             $sSearchParam = $this->getSearchParamForHtml();
01438 
01439             $aCatPath = array();
01440             $aCatPath['title'] = sprintf( oxRegistry::getLang()->translateString( 'searchResult', oxRegistry::getLang()->getBaseLanguage(), false ), $sSearchParam );
01441             $aCatPath['link']  = $this->getViewConfig()->getSelfLink() . 'stoken=' . oxSession::getVar('sess_stoken') . "&amp;cl=search&amp;searchparam=" . $sSearchParam;
01442 
01443             $aPaths[] = $aCatPath;
01444 
01445         } elseif ( 'tag' == oxConfig::getParameter( 'listtype' ) ) {
01446 
01447             $aCatPath = array();
01448 
01449             $aCatPath['title'] = oxRegistry::getLang()->translateString( 'TAGS', oxRegistry::getLang()->getBaseLanguage(), false );
01450             $aCatPath['link']  = oxRegistry::get("oxSeoEncoder")->getStaticUrl( $this->getViewConfig()->getSelfLink() . 'cl=tags' );
01451             $aPaths[] = $aCatPath;
01452 
01453             $oStr = getStr();
01454             $aCatPath['title'] = $oStr->ucfirst(oxConfig::getParameter( 'searchtag' ));
01455             $aCatPath['link']  = oxRegistry::get("oxSeoEncoderTag")->getTagUrl( oxConfig::getParameter( 'searchtag' ) );
01456             $aPaths[] = $aCatPath;
01457 
01458         } elseif ( 'recommlist' == oxConfig::getParameter( 'listtype' ) ) {
01459 
01460             $aCatPath = array();
01461             $aCatPath['title'] = oxRegistry::getLang()->translateString( 'PAGE_RECOMMENDATIONS_PRODUCTS_TITLE', oxRegistry::getLang()->getBaseLanguage(), false );
01462             $aPaths[] = $aCatPath;
01463         } else {
01464 
01465             $oCatTree = $this->getCatTreePath();
01466 
01467             if ( $oCatTree ) {
01468 
01469                 foreach ( $oCatTree as $oCat ) {
01470                     $aCatPath = array();
01471 
01472                     $aCatPath['link'] = $oCat->getLink();
01473                     $aCatPath['title'] = $oCat->oxcategories__oxtitle->value;
01474 
01475                     $aPaths[] = $aCatPath;
01476                 }
01477             }
01478         }
01479 
01480         return $aPaths;
01481     }
01482 
01492     public function addme()
01493     {
01494         $myConfig = $this->getConfig();
01495         $myUtils  = oxRegistry::getUtils();
01496 
01497         //control captcha
01498         $sMac     = oxConfig::getParameter( 'c_mac' );
01499         $sMacHash = oxConfig::getParameter( 'c_mach' );
01500         $oCaptcha = $this->getCaptcha();
01501         if ( !$oCaptcha->pass( $sMac, $sMacHash ) ) {
01502             $this->_iPriceAlarmStatus = 2;
01503             return;
01504         }
01505 
01506         $aParams = oxConfig::getParameter( 'pa' );
01507         if ( !isset( $aParams['email'] ) || !$myUtils->isValidEmail( $aParams['email'] ) ) {
01508             $this->_iPriceAlarmStatus = 0;
01509             return;
01510         }
01511         $aParams['aid'] = $this->getProduct()->getId();
01512         $oCur = $myConfig->getActShopCurrencyObject();
01513         // convert currency to default
01514         $dPrice = $myUtils->currency2Float( $aParams['price'] );
01515 
01516         $oAlarm = oxNew( "oxpricealarm" );
01517         $oAlarm->oxpricealarm__oxuserid = new oxField( oxSession::getVar( 'usr' ));
01518         $oAlarm->oxpricealarm__oxemail  = new oxField( $aParams['email']);
01519         $oAlarm->oxpricealarm__oxartid  = new oxField( $aParams['aid']);
01520         $oAlarm->oxpricealarm__oxprice  = new oxField( $myUtils->fRound( $dPrice, $oCur ));
01521         $oAlarm->oxpricealarm__oxshopid = new oxField( $myConfig->getShopId());
01522         $oAlarm->oxpricealarm__oxcurrency = new oxField( $oCur->name);
01523 
01524         $oAlarm->oxpricealarm__oxlang = new oxField(oxRegistry::getLang()->getBaseLanguage());
01525 
01526         $oAlarm->save();
01527 
01528         // Send Email
01529         $oEmail = oxNew( 'oxemail' );
01530         $this->_iPriceAlarmStatus = (int) $oEmail->sendPricealarmNotification( $aParams, $oAlarm );
01531     }
01532 
01538     public function getPriceAlarmStatus()
01539     {
01540         return $this->_iPriceAlarmStatus;
01541     }
01542 
01548     public function getBidPrice()
01549     {
01550         if ( $this->_sBidPrice === null ) {
01551             $this->_sBidPrice = false;
01552 
01553             $aParams = oxConfig::getParameter( 'pa' );
01554             $oCur = $this->getConfig()->getActShopCurrencyObject();
01555             $iPrice = oxRegistry::getUtils()->currency2Float( $aParams['price'] );
01556             $this->_sBidPrice = oxRegistry::getLang()->formatCurrency( $iPrice, $oCur );
01557         }
01558         return $this->_sBidPrice;
01559     }
01560 
01566     public function getVariantSelections()
01567     {
01568         // finding parent
01569         $oProduct = $this->getProduct();
01570         if ( ( $oParent = $this->_getParentProduct( $oProduct->oxarticles__oxparentid->value ) ) ) {
01571             return $oParent->getVariantSelections( oxConfig::getParameter( "varselid" ), $oProduct->getId() );
01572         }
01573 
01574         return $oProduct->getVariantSelections( oxConfig::getParameter( "varselid" ) );
01575     }
01576 
01582     public function getPicturesProduct()
01583     {
01584         $aVariantSelections = $this->getVariantSelections();
01585         if ($aVariantSelections && $aVariantSelections['oActiveVariant'] && !$aVariantSelections['blPerfectFit']) {
01586             return $aVariantSelections['oActiveVariant'];
01587         }
01588         return $this->getProduct();
01589     }
01590 
01596     public function getSearchParamForHtml()
01597     {
01598         if ( $this->_sSearchParamForHtml === null ) {
01599             $this->_sSearchParamForHtml = oxConfig::getParameter( 'searchparam' );
01600         }
01601         return $this->_sSearchParamForHtml;
01602     }
01603 
01609     public function showRdfa()
01610     {
01611         return $this->getConfig()->getConfigParam( 'blRDFaEmbedding' );
01612     }
01613 
01619     public function getRDFaNormalizedRating()
01620     {
01621         $myConfig = $this->getConfig();
01622         $iMin = $myConfig->getConfigParam("iRDFaMinRating");
01623         $iMax = $myConfig->getConfigParam("iRDFaMaxRating");
01624 
01625         $oProduct = $this->getProduct();
01626         $iCount = $oProduct->oxarticles__oxratingcnt->value;
01627         if ( isset($iMin) && isset($iMax) && $iMax != '' && $iMin != '' && $iCount > 0 ) {
01628             $aNomalizedRating = array();
01629             $iValue = ((4*($oProduct->oxarticles__oxrating->value - $iMin)/($iMax - $iMin)))+1;
01630             $aNomalizedRating["count"] = $iCount;
01631             $aNomalizedRating["value"] = round($iValue, 2);
01632             return $aNomalizedRating;
01633         }
01634         return false;
01635     }
01636 
01644     public function getRDFaValidityPeriod($sShopConfVar)
01645     {
01646         if ( $sShopConfVar ) {
01647             $aValidity = array();
01648             $iDays = $this->getConfig()->getConfigParam($sShopConfVar);
01649             $iFrom = oxRegistry::get("oxUtilsDate")->getTime();
01650 
01651             $iThrough = $iFrom + ($iDays * 24 * 60 * 60);
01652             $aValidity["from"] = date('Y-m-d\TH:i:s', $iFrom)."Z";
01653             $aValidity["through"] = date('Y-m-d\TH:i:s', $iThrough)."Z";
01654 
01655             return $aValidity;
01656         }
01657         return false;
01658     }
01659 
01665     public function getRDFaBusinessFnc()
01666     {
01667         return $this->getConfig()->getConfigParam("sRDFaBusinessFnc");
01668     }
01669 
01675     public function getRDFaCustomers()
01676     {
01677         return $this->getConfig()->getConfigParam("aRDFaCustomers");
01678     }
01679 
01685     public function getRDFaVAT()
01686     {
01687         return $this->getConfig()->getConfigParam("iRDFaVAT");
01688     }
01689 
01695     public function getRDFaGenericCondition()
01696     {
01697         return $this->getConfig()->getConfigParam("iRDFaCondition");
01698     }
01699 
01705     public function getBundleArticle()
01706     {
01707         $oProduct = $this->getProduct();
01708         if ( $oProduct && $oProduct->oxarticles__oxbundleid->value ) {
01709             $oArticle = oxNew("oxarticle");
01710             $oArticle->load($oProduct->oxarticles__oxbundleid->value);
01711             return $oArticle;
01712         }
01713         return false;
01714     }
01715 
01721     public function getRDFaPaymentMethods()
01722     {
01723         $iPrice = $this->getProduct()->getPrice()->getBruttoPrice();
01724         $oPayments = oxNew("oxpaymentlist");
01725         $oPayments->loadRDFaPaymentList($iPrice);
01726         return $oPayments;
01727     }
01728 
01734     public function getRDFaDeliverySetMethods()
01735     {
01736         $oDelSets = oxNew("oxdeliverysetlist");
01737         $oDelSets->loadRDFaDeliverySetList();
01738         return $oDelSets;
01739     }
01740 
01746     public function getProductsDeliveryList()
01747     {
01748         $oProduct = $this->getProduct();
01749         $oDelList = oxNew( "oxDeliveryList" );
01750         $oDelList->loadDeliveryListForProduct( $oProduct );
01751         return $oDelList;
01752     }
01753 
01759     public function getRDFaDeliveryChargeSpecLoc()
01760     {
01761         return $this->getConfig()->getConfigParam("sRDFaDeliveryChargeSpecLoc");
01762     }
01763 
01769     public function getRDFaPaymentChargeSpecLoc()
01770     {
01771         return $this->getConfig()->getConfigParam("sRDFaPaymentChargeSpecLoc");
01772     }
01773 
01779     public function getRDFaBusinessEntityLoc()
01780     {
01781         return $this->getConfig()->getConfigParam("sRDFaBusinessEntityLoc");
01782     }
01783 
01789     public function showRDFaProductStock()
01790     {
01791         return $this->getConfig()->getConfigParam("blShowRDFaProductStock");
01792     }
01793 
01794 }