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");
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' == $this->getListType() ) {
01437 
01438             $sSearchParam = $this->getSearchParamForHtml();
01439 
01440             $aCatPath = array();
01441             $aCatPath['title'] = sprintf( oxRegistry::getLang()->translateString( 'searchResult', oxRegistry::getLang()->getBaseLanguage(), false ), $sSearchParam );
01442             $aCatPath['link']  = $this->getViewConfig()->getSelfLink() . 'stoken=' . oxSession::getVar('sess_stoken') . "&amp;cl=search&amp;searchparam=" . $sSearchParam;
01443 
01444             $aPaths[] = $aCatPath;
01445 
01446         } elseif ( 'tag' == $this->getListType() ) {
01447 
01448             $aCatPath = array();
01449 
01450             $aCatPath['title'] = oxRegistry::getLang()->translateString( 'TAGS', oxRegistry::getLang()->getBaseLanguage(), false );
01451             $aCatPath['link']  = oxRegistry::get("oxSeoEncoder")->getStaticUrl( $this->getViewConfig()->getSelfLink() . 'cl=tags' );
01452             $aPaths[] = $aCatPath;
01453 
01454             $oStr = getStr();
01455             $aCatPath['title'] = $oStr->ucfirst(oxConfig::getParameter( 'searchtag' ));
01456             $aCatPath['link']  = oxRegistry::get("oxSeoEncoderTag")->getTagUrl( oxConfig::getParameter( 'searchtag' ) );
01457             $aPaths[] = $aCatPath;
01458 
01459         } elseif ( 'recommlist' == $this->getListType() ) {
01460 
01461             $aCatPath = array();
01462             $aCatPath['title'] = oxRegistry::getLang()->translateString( 'PAGE_RECOMMENDATIONS_PRODUCTS_TITLE', oxRegistry::getLang()->getBaseLanguage(), false );
01463             $aPaths[] = $aCatPath;
01464 
01465         } elseif ( 'vendor' == $this->getListType() ) {
01466 
01467             $aCatPath = array();
01468 
01469             $oCat = oxNew( 'oxVendor' );
01470             $oCat->load('root');
01471 
01472             $aCatPath['link'] = $oCat->getLink();
01473             $aCatPath['title'] = $oCat->oxvendor__oxtitle->value;
01474             $aPaths[] = $aCatPath;
01475 
01476             $oCat = $this->getActVendor();
01477             $aCatPath['link'] = $oCat->getLink();
01478             $aCatPath['title'] = $oCat->oxvendor__oxtitle->value;
01479             $aPaths[] = $aCatPath;
01480 
01481         } else {
01482 
01483             $oCatTree = $this->getCatTreePath();
01484 
01485             if ( $oCatTree ) {
01486 
01487                 foreach ( $oCatTree as $oCat ) {
01488                     $aCatPath = array();
01489 
01490                     $aCatPath['link'] = $oCat->getLink();
01491                     $aCatPath['title'] = $oCat->oxcategories__oxtitle->value;
01492 
01493                     $aPaths[] = $aCatPath;
01494                 }
01495             }
01496         }
01497 
01498         return $aPaths;
01499     }
01500 
01510     public function addme()
01511     {
01512         $myConfig = $this->getConfig();
01513         $myUtils  = oxRegistry::getUtils();
01514 
01515         //control captcha
01516         $sMac     = oxConfig::getParameter( 'c_mac' );
01517         $sMacHash = oxConfig::getParameter( 'c_mach' );
01518         $oCaptcha = $this->getCaptcha();
01519         if ( !$oCaptcha->pass( $sMac, $sMacHash ) ) {
01520             $this->_iPriceAlarmStatus = 2;
01521             return;
01522         }
01523 
01524         $aParams = oxConfig::getParameter( 'pa' );
01525         if ( !isset( $aParams['email'] ) || !$myUtils->isValidEmail( $aParams['email'] ) ) {
01526             $this->_iPriceAlarmStatus = 0;
01527             return;
01528         }
01529         $aParams['aid'] = $this->getProduct()->getId();
01530         $oCur = $myConfig->getActShopCurrencyObject();
01531         // convert currency to default
01532         $dPrice = $myUtils->currency2Float( $aParams['price'] );
01533 
01534         $oAlarm = oxNew( "oxpricealarm" );
01535         $oAlarm->oxpricealarm__oxuserid = new oxField( oxSession::getVar( 'usr' ));
01536         $oAlarm->oxpricealarm__oxemail  = new oxField( $aParams['email']);
01537         $oAlarm->oxpricealarm__oxartid  = new oxField( $aParams['aid']);
01538         $oAlarm->oxpricealarm__oxprice  = new oxField( $myUtils->fRound( $dPrice, $oCur ));
01539         $oAlarm->oxpricealarm__oxshopid = new oxField( $myConfig->getShopId());
01540         $oAlarm->oxpricealarm__oxcurrency = new oxField( $oCur->name);
01541 
01542         $oAlarm->oxpricealarm__oxlang = new oxField(oxRegistry::getLang()->getBaseLanguage());
01543 
01544         $oAlarm->save();
01545 
01546         // Send Email
01547         $oEmail = oxNew( 'oxemail' );
01548         $this->_iPriceAlarmStatus = (int) $oEmail->sendPricealarmNotification( $aParams, $oAlarm );
01549     }
01550 
01556     public function getPriceAlarmStatus()
01557     {
01558         return $this->_iPriceAlarmStatus;
01559     }
01560 
01566     public function getBidPrice()
01567     {
01568         if ( $this->_sBidPrice === null ) {
01569             $this->_sBidPrice = false;
01570 
01571             $aParams = oxConfig::getParameter( 'pa' );
01572             $oCur = $this->getConfig()->getActShopCurrencyObject();
01573             $iPrice = oxRegistry::getUtils()->currency2Float( $aParams['price'] );
01574             $this->_sBidPrice = oxRegistry::getLang()->formatCurrency( $iPrice, $oCur );
01575         }
01576         return $this->_sBidPrice;
01577     }
01578 
01584     public function getVariantSelections()
01585     {
01586         // finding parent
01587         $oProduct = $this->getProduct();
01588         if ( ( $oParent = $this->_getParentProduct( $oProduct->oxarticles__oxparentid->value ) ) ) {
01589             return $oParent->getVariantSelections( oxConfig::getParameter( "varselid" ), $oProduct->getId() );
01590         }
01591 
01592         return $oProduct->getVariantSelections( oxConfig::getParameter( "varselid" ) );
01593     }
01594 
01600     public function getPicturesProduct()
01601     {
01602         $aVariantSelections = $this->getVariantSelections();
01603         if ($aVariantSelections && $aVariantSelections['oActiveVariant'] && !$aVariantSelections['blPerfectFit']) {
01604             return $aVariantSelections['oActiveVariant'];
01605         }
01606         return $this->getProduct();
01607     }
01608 
01614     public function getSearchParamForHtml()
01615     {
01616         if ( $this->_sSearchParamForHtml === null ) {
01617             $this->_sSearchParamForHtml = oxConfig::getParameter( 'searchparam' );
01618         }
01619         return $this->_sSearchParamForHtml;
01620     }
01621 
01627     public function showRdfa()
01628     {
01629         return $this->getConfig()->getConfigParam( 'blRDFaEmbedding' );
01630     }
01631 
01637     public function getRDFaNormalizedRating()
01638     {
01639         $myConfig = $this->getConfig();
01640         $iMin = $myConfig->getConfigParam("iRDFaMinRating");
01641         $iMax = $myConfig->getConfigParam("iRDFaMaxRating");
01642 
01643         $oProduct = $this->getProduct();
01644         $iCount = $oProduct->oxarticles__oxratingcnt->value;
01645         if ( isset($iMin) && isset($iMax) && $iMax != '' && $iMin != '' && $iCount > 0 ) {
01646             $aNomalizedRating = array();
01647             $iValue = ((4*($oProduct->oxarticles__oxrating->value - $iMin)/($iMax - $iMin)))+1;
01648             $aNomalizedRating["count"] = $iCount;
01649             $aNomalizedRating["value"] = round($iValue, 2);
01650             return $aNomalizedRating;
01651         }
01652         return false;
01653     }
01654 
01662     public function getRDFaValidityPeriod($sShopConfVar)
01663     {
01664         if ( $sShopConfVar ) {
01665             $aValidity = array();
01666             $iDays = $this->getConfig()->getConfigParam($sShopConfVar);
01667             $iFrom = oxRegistry::get("oxUtilsDate")->getTime();
01668 
01669             $iThrough = $iFrom + ($iDays * 24 * 60 * 60);
01670             $aValidity["from"] = date('Y-m-d\TH:i:s', $iFrom)."Z";
01671             $aValidity["through"] = date('Y-m-d\TH:i:s', $iThrough)."Z";
01672 
01673             return $aValidity;
01674         }
01675         return false;
01676     }
01677 
01683     public function getRDFaBusinessFnc()
01684     {
01685         return $this->getConfig()->getConfigParam("sRDFaBusinessFnc");
01686     }
01687 
01693     public function getRDFaCustomers()
01694     {
01695         return $this->getConfig()->getConfigParam("aRDFaCustomers");
01696     }
01697 
01703     public function getRDFaVAT()
01704     {
01705         return $this->getConfig()->getConfigParam("iRDFaVAT");
01706     }
01707 
01713     public function getRDFaGenericCondition()
01714     {
01715         return $this->getConfig()->getConfigParam("iRDFaCondition");
01716     }
01717 
01723     public function getBundleArticle()
01724     {
01725         $oProduct = $this->getProduct();
01726         if ( $oProduct && $oProduct->oxarticles__oxbundleid->value ) {
01727             $oArticle = oxNew("oxarticle");
01728             $oArticle->load($oProduct->oxarticles__oxbundleid->value);
01729             return $oArticle;
01730         }
01731         return false;
01732     }
01733 
01739     public function getRDFaPaymentMethods()
01740     {
01741         $iPrice = $this->getProduct()->getPrice()->getBruttoPrice();
01742         $oPayments = oxNew("oxpaymentlist");
01743         $oPayments->loadRDFaPaymentList($iPrice);
01744         return $oPayments;
01745     }
01746 
01752     public function getRDFaDeliverySetMethods()
01753     {
01754         $oDelSets = oxNew("oxdeliverysetlist");
01755         $oDelSets->loadRDFaDeliverySetList();
01756         return $oDelSets;
01757     }
01758 
01764     public function getProductsDeliveryList()
01765     {
01766         $oProduct = $this->getProduct();
01767         $oDelList = oxNew( "oxDeliveryList" );
01768         $oDelList->loadDeliveryListForProduct( $oProduct );
01769         return $oDelList;
01770     }
01771 
01777     public function getRDFaDeliveryChargeSpecLoc()
01778     {
01779         return $this->getConfig()->getConfigParam("sRDFaDeliveryChargeSpecLoc");
01780     }
01781 
01787     public function getRDFaPaymentChargeSpecLoc()
01788     {
01789         return $this->getConfig()->getConfigParam("sRDFaPaymentChargeSpecLoc");
01790     }
01791 
01797     public function getRDFaBusinessEntityLoc()
01798     {
01799         return $this->getConfig()->getConfigParam("sRDFaBusinessEntityLoc");
01800     }
01801 
01807     public function showRDFaProductStock()
01808     {
01809         return $this->getConfig()->getConfigParam("blShowRDFaProductStock");
01810     }
01811 
01817     public function getDefaultSorting()
01818     {
01819         $aSorting = parent::getDefaultSorting();
01820         $oCategory = $this->getActiveCategory();
01821 
01822         if ( $this->getListType() != 'search' &&  $oCategory && $oCategory instanceof oxCategory ) {
01823             if ( $sDefaultSorting = $oCategory->getDefaultSorting() ) {
01824                 $sArticleTable = getViewName( 'oxarticles' );
01825                 $sSortBy  = $sArticleTable.'.'.$sDefaultSorting;
01826                 $sSortDir = ( $oCategory->getDefaultSortingMode() ) ? "desc" : "asc";
01827                 $aSorting = array ( 'sortby' => $sSortBy, 'sortdir' => $sSortDir );
01828             }
01829         }
01830 
01831         return $aSorting;
01832     }
01833 }