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 
00239     protected $_aSimilarRecommListIds = null;
00240 
00241 
00249     protected function _getParentProduct( $sParentId )
00250     {
00251         if ( $sParentId && $this->_oParentProd === null ) {
00252             $this->_oParentProd = false;
00253             if ( ( $oParent = oxNewArticle( $sParentId ) ) ) {
00254                 $this->_processProduct( $oParent );
00255                 $this->_oParentProd = $oParent;
00256             }
00257         }
00258         return $this->_oParentProd;
00259     }
00260 
00267     public function loadVariantInformation()
00268     {
00269         if ( $this->_aVariantList === null ) {
00270             $oProduct = $this->getProduct();
00271 
00272             //if we are child and do not have any variants then let's load all parent variants as ours
00273             if ( $oParent = $oProduct->getParentArticle() ) {
00274                 $myConfig = $this->getConfig();
00275 
00276                 $oParent->setNoVariantLoading(false);
00277                 $this->_aVariantList = $oParent->getFullVariants( false );
00278 
00279                 //lets additionally add parent article if it is sellable
00280                 if ( count( $this->_aVariantList ) && $myConfig->getConfigParam( 'blVariantParentBuyable' ) ) {
00281                     //#1104S if parent is buyable load selectlists too
00282                     $oParent->enablePriceLoad();
00283                     $oParent->aSelectlist = $oParent->getSelectLists();
00284                     $this->_aVariantList = array_merge( array( $oParent ), $this->_aVariantList->getArray() );
00285                 }
00286             } else {
00287                 //loading full list of variants
00288                 $this->_aVariantList = $oProduct->getFullVariants( false );
00289             }
00290 
00291             // setting link type for variants ..
00292             foreach ( $this->_aVariantList as $oVariant ) {
00293                 $this->_processProduct( $oVariant );
00294             }
00295 
00296         }
00297 
00298         return $this->_aVariantList;
00299     }
00300 
00306     protected function _getAddUrlParams()
00307     {
00308         if ( $this->getListType() == "search" ) {
00309             return $this->getDynUrlParams();
00310         }
00311     }
00312 
00320     protected function _processProduct( $oProduct )
00321     {
00322         $oProduct->setLinkType( $this->getLinkType() );
00323         if ( $sAddParams = $this->_getAddUrlParams() ) {
00324             $oProduct->appendLink( $sAddParams );
00325         }
00326     }
00327 
00333     public function getViewId()
00334     {
00335         if ( isset( $this->_sViewId )) {
00336             return $this->_sViewId;
00337         }
00338 
00339             $sViewId = parent::getViewId().'|'.oxConfig::getParameter( 'anid' ).'|';
00340 
00341 
00342         return $this->_sViewId = $sViewId;
00343     }
00344 
00345 
00357     public function render()
00358     {
00359         $myConfig = $this->getConfig();
00360 
00361         $oProduct = $this->getProduct();
00362 
00363         // assign template name
00364         if ( $oProduct->oxarticles__oxtemplate->value ) {
00365             $this->_sThisTemplate = $oProduct->oxarticles__oxtemplate->value;
00366         }
00367 
00368         if ( ( $sTplName = oxConfig::getParameter( 'tpl' ) ) ) {
00369             $this->_sThisTemplate = 'custom/'.basename ( $sTplName );
00370         }
00371 
00372         parent::render();
00373 
00374         $sPartial = oxConfig::getParameter('renderPartial');
00375         $this->addTplParam('renderPartial', $sPartial);
00376 
00377         switch ($sPartial) {
00378             case "productInfo":
00379                 return 'page/details/ajax/fullproductinfo.tpl';
00380                 break;
00381             case "detailsMain":
00382                 return 'page/details/ajax/productmain.tpl';
00383                 break;
00384             default:
00385                 // #785A loads and sets locator data
00386                 $oLocator = oxNew( 'oxlocator', $this->getListType() );
00387                 $oLocator->setLocatorData( $oProduct, $this );
00388 
00389                 if ($myConfig->getConfigParam( 'bl_rssRecommLists' ) && $this->getSimilarRecommListIds()) {
00390                     $oRss = oxNew('oxrssfeed');
00391                     $this->addRssFeed($oRss->getRecommListsTitle( $oProduct ), $oRss->getRecommListsUrl( $oProduct ), 'recommlists');
00392                 }
00393 
00394                 return $this->_sThisTemplate;
00395         }
00396     }
00397 
00409     protected function _prepareMetaDescription( $sMeta, $iLength = 200, $blDescTag = false )
00410     {
00411         if ( !$sMeta ) {
00412             $oProduct = $this->getProduct();
00413 
00414             if ( $this->getConfig()->getConfigParam( 'bl_perfParseLongDescinSmarty' ) ) {
00415                 $sMeta = $oProduct->getLongDesc();
00416             } else {
00417                 $sMeta = $oProduct->getLongDescription()->value;
00418             }
00419             if ( $sMeta == '' ) {
00420                 $sMeta = $oProduct->oxarticles__oxshortdesc->value;
00421             }
00422             $sMeta = $oProduct->oxarticles__oxtitle->value.' - '.$sMeta;
00423         }
00424         return parent::_prepareMetaDescription( $sMeta, $iLength, $blDescTag );
00425     }
00426 
00437     protected function _prepareMetaKeyword( $sKeywords, $blRemoveDuplicatedWords = true )
00438     {
00439         if ( !$sKeywords ) {
00440             $oProduct = $this->getProduct();
00441             $sKeywords = trim( $this->getTitle() );
00442 
00443             if ( $oCatTree = $this->getCategoryTree() ) {
00444                 foreach ( $oCatTree->getPath() as $oCat ) {
00445                     $sKeywords .= ", " . trim( $oCat->oxcategories__oxtitle->value );
00446                 }
00447             }
00448 
00449             //adding searchkeys info
00450             if ( $sSearchKeys = trim( $oProduct->oxarticles__oxsearchkeys->value ) ) {
00451                 $sKeywords .= ", ". $sSearchKeys;
00452             }
00453 
00454             $sKeywords = parent::_prepareMetaKeyword( $sKeywords, $blRemoveDuplicatedWords );
00455         }
00456 
00457         return $sKeywords;
00458     }
00459 
00465     public function ratingIsActive()
00466     {
00467         return $this->getConfig()->getConfigParam( 'bl_perfLoadReviews' );
00468     }
00469 
00475     public function canRate()
00476     {
00477         if ( $this->_blCanRate === null ) {
00478 
00479             $this->_blCanRate = false;
00480 
00481             if ( $this->ratingIsActive() && $oUser = $this->getUser() ) {
00482 
00483                 $oRating = oxNew( 'oxrating' );
00484                 $this->_blCanRate = $oRating->allowRating( $oUser->getId(), 'oxarticle', $this->getProduct()->getId() );
00485             }
00486         }
00487 
00488         return $this->_blCanRate;
00489     }
00490 
00496     public function canChangeTags()
00497     {
00498         if ( $oUser = $this->getUser() ) {
00499 
00500             return true;
00501         }
00502         return false;
00503     }
00504 
00510     public function saveReview()
00511     {
00512         if ( $this->canAcceptFormData() &&
00513              ( $oUser = $this->getUser() ) && ( $oProduct = $this->getProduct() ) ) {
00514 
00515             $dRating = oxConfig::getParameter( 'artrating' );
00516             if ( $dRating !== null ) {
00517                 $dRating = (int) $dRating;
00518             }
00519 
00520             //save rating
00521             if ( $dRating !== null && $dRating >= 1 && $dRating <= 5 ) {
00522                 $oRating = oxNew( 'oxrating' );
00523                 if ( $oRating->allowRating( $oUser->getId(), 'oxarticle', $oProduct->getId() ) ) {
00524                     $oRating->oxratings__oxuserid   = new oxField( $oUser->getId() );
00525                     $oRating->oxratings__oxtype     = new oxField( 'oxarticle' );
00526                     $oRating->oxratings__oxobjectid = new oxField( $oProduct->getId() );
00527                     $oRating->oxratings__oxrating   = new oxField( $dRating );
00528                     $oRating->save();
00529                     $oProduct->addToRatingAverage( $dRating );
00530                 }
00531             }
00532 
00533             if ( ( $sReviewText = trim( ( string ) oxConfig::getParameter( 'rvw_txt', true ) ) ) ) {
00534                 $oReview = oxNew( 'oxreview' );
00535                 $oReview->oxreviews__oxobjectid = new oxField( $oProduct->getId() );
00536                 $oReview->oxreviews__oxtype     = new oxField( 'oxarticle' );
00537                 $oReview->oxreviews__oxtext     = new oxField( $sReviewText, oxField::T_RAW );
00538                 $oReview->oxreviews__oxlang     = new oxField( oxRegistry::getLang()->getBaseLanguage() );
00539                 $oReview->oxreviews__oxuserid   = new oxField( $oUser->getId() );
00540                 $oReview->oxreviews__oxrating   = new oxField( ( $dRating !== null ) ? $dRating : 0);
00541                 $oReview->save();
00542             }
00543         }
00544     }
00545 
00551     public function addToRecomm()
00552     {
00553         if (!$this->getViewConfig()->getShowListmania()) {
00554             return;
00555         }
00556 
00557         $sRecommText = trim( ( string ) oxConfig::getParameter( 'recomm_txt' ) );
00558         $sRecommList = oxConfig::getParameter( 'recomm' );
00559         $sArtId      = $this->getProduct()->getId();
00560 
00561         if ( $sArtId ) {
00562             $oRecomm = oxNew( 'oxrecommlist' );
00563             $oRecomm->load( $sRecommList);
00564             $oRecomm->addArticle( $sArtId, $sRecommText );
00565         }
00566     }
00567 
00573     public function addTags()
00574     {
00575         $sTags  = $this->getConfig()->getRequestParameter('newTags', true );
00576         $sHighTag  = $this->getConfig()->getRequestParameter( 'highTags', true );
00577         if ( !$sTags && !$sHighTag) {
00578             return;
00579         }
00580         if ( $sHighTag ) {
00581             $sTags = getStr()->html_entity_decode( $sHighTag );
00582         }
00583         $oProduct = $this->getProduct();
00584 
00585         // set current user added tags for this article for later checking
00586         $aTaggedProducts = oxRegistry::getSession()->getVariable("aTaggedProducts");
00587         $aAddedTags = $aTaggedProducts? $aTaggedProducts[$oProduct->getId()] : array();
00588 
00589         $oArticleTagList = oxNew( "oxarticletaglist" );
00590         $oArticleTagList->load( $oProduct->getId() );
00591         $sSeparator = $oArticleTagList->get()->getSeparator();
00592         $aTags = explode( $sSeparator, $sTags );
00593         $blAddedTag = false;
00594         foreach ( $aTags as $sTag ) {
00595             $oTag = oxNew( "oxtag" );
00596             $oTag->set( $sTag );
00597             if ( $aAddedTags[$oTag->get()] != 1 ) {
00598                 $oArticleTagList->addTag( $oTag );
00599                 $aAddedTags[$oTag->get()] = 1;
00600                 $blAddedTag = true;
00601             }
00602         }
00603         if ( $blAddedTag ) {
00604             $oArticleTagList->save();
00605             $aTaggedProducts[$oProduct->getId()] = $aAddedTags;
00606             oxRegistry::getSession()->setVariable( 'aTaggedProducts', $aTaggedProducts);
00607         }
00608         // for ajax call
00609         if ( $this->getConfig()->getRequestParameter( 'blAjax', true ) ) {
00610             oxRegistry::getUtils()->showMessageAndExit( $blAddedTag );
00611         }
00612     }
00613 
00619     public function editTags()
00620     {
00621         if ( !$this->getUser() ) {
00622             return;
00623         }
00624         $oArticleTagList = oxNew("oxArticleTagList");
00625         $oArticleTagList->load( $this->getProduct()->getId() );
00626         $oTagSet = $oArticleTagList->get();
00627         $this->_aTags = $oTagSet->get();
00628         $this->_blEditTags = true;
00629 
00630         // for ajax call
00631         if ( $this->getConfig()->getRequestParameter( 'blAjax', true ) ) {
00632             oxRegistry::getUtils()->setHeader( "Content-Type: text/html; charset=".oxRegistry::getLang()->translateString( 'charset' ) );
00633             $oActView = oxNew( 'oxubase' );
00634             $oSmarty = oxRegistry::get("oxUtilsView")->getSmarty();
00635             $oSmarty->assign('oView', $this );
00636             $oSmarty->assign('oViewConf', $this->getViewConfig() );
00637             oxRegistry::getUtils()->showMessageAndExit( $oSmarty->fetch( 'page/details/inc/editTags.tpl', $this->getViewId() ) );
00638         }
00639     }
00640 
00646     public function cancelTags()
00647     {
00648         $oArticleTagList = oxNew("oxArticleTagList");
00649         $oArticleTagList->load( $this->getProduct()->getId() );
00650         $oTagSet = $oArticleTagList->get();
00651         $this->_aTags = $oTagSet->get();
00652         $this->_blEditTags = false;
00653 
00654         // for ajax call
00655         if ( oxConfig::getParameter( 'blAjax', true ) ) {
00656             oxRegistry::getUtils()->setHeader( "Content-Type: text/html; charset=".oxRegistry::getLang()->translateString( 'charset' ) );
00657             $oActView = oxNew( 'oxubase' );
00658             $oSmarty = oxRegistry::get("oxUtilsView")->getSmarty();
00659             $oSmarty->assign('oView', $this );
00660             $oSmarty->assign('oViewConf', $this->getViewConfig() );
00661             oxRegistry::getUtils()->showMessageAndExit( $oSmarty->fetch( 'page/details/inc/tags.tpl', $this->getViewId() ) );
00662         }
00663     }
00664 
00670     protected function _getSeoObjectId()
00671     {
00672         if ( $oProduct = $this->getProduct() ) {
00673             return $oProduct->getId();
00674         }
00675     }
00676 
00682     public function getAttributes()
00683     {
00684         if ( $this->_aAttributes === null ) {
00685             // all attributes this article has
00686             $aArtAttributes = $this->getProduct()->getAttributes();
00687 
00688             //making a new array for backward compatibility
00689             $this->_aAttributes = false;
00690 
00691             if ( count( $aArtAttributes ) ) {
00692                 foreach ( $aArtAttributes as $sKey => $oAttribute ) {
00693                     $this->_aAttributes[$sKey] = new stdClass();
00694                     $this->_aAttributes[$sKey]->title = $oAttribute->oxattribute__oxtitle->value;
00695                     $this->_aAttributes[$sKey]->value = $oAttribute->oxattribute__oxvalue->value;
00696                 }
00697             }
00698         }
00699         return $this->_aAttributes;
00700     }
00701 
00702 
00708     public function getEditTags()
00709     {
00710         return $this->_blEditTags;
00711     }
00712 
00718     public function getTags()
00719     {
00720         return $this->_aTags;
00721     }
00722 
00728     public function getTagCloudManager()
00729     {
00730         $oManager = oxNew( "oxTagCloud" );
00731         $oManager->setExtendedMode( true );
00732         $oManager->setProductId( $this->getProduct()->getId() );
00733         return $oManager;
00734     }
00735 
00742     public function isEditableTags()
00743     {
00744         if ( $this->_blCanEditTags === null ) {
00745             $this->_blCanEditTags = false;
00746             if ( $this->getProduct() && $this->getUser()) {
00747                 $this->_blCanEditTags = true;
00748             }
00749         }
00750         return $this->_blCanEditTags;
00751     }
00752 
00758     public function getProduct()
00759     {
00760         $myConfig = $this->getConfig();
00761         $myUtils = oxRegistry::getUtils();
00762 
00763         if ( $this->_oProduct === null ) {
00764 
00765             //this option is only for lists and we must reset value
00766             //as blLoadVariants = false affect "ab price" functionality
00767             $myConfig->setConfigParam( 'blLoadVariants', true );
00768 
00769             $sOxid = oxConfig::getParameter( 'anid' );
00770 
00771             // object is not yet loaded
00772             $this->_oProduct = oxNew( 'oxarticle' );
00773 
00774             if ( !$this->_oProduct->load( $sOxid ) ) {
00775                 $myUtils->redirect( $myConfig->getShopHomeURL() );
00776                 $myUtils->showMessageAndExit( '' );
00777             }
00778 
00779             $aVariantSelections = $this->_oProduct->getVariantSelections( oxConfig::getParameter( "varselid" ) );
00780             if ($aVariantSelections && $aVariantSelections['oActiveVariant'] && $aVariantSelections['blPerfectFit']) {
00781                 $this->_oProduct = $aVariantSelections['oActiveVariant'];
00782             }
00783         }
00784 
00785         // additional checks
00786         if ( !$this->_blIsInitialized ) {
00787 
00788             $blContinue = true;
00789             if ( !$this->_oProduct->isVisible() ) {
00790                 $blContinue = false;
00791             } elseif ( $this->_oProduct->oxarticles__oxparentid->value ) {
00792                 $oParent = $this->_getParentProduct( $this->_oProduct->oxarticles__oxparentid->value );
00793                 if ( !$oParent || !$oParent->isVisible() ) {
00794                     $blContinue = false;
00795                 }
00796             }
00797 
00798             if ( !$blContinue ) {
00799                 $myUtils->redirect( $myConfig->getShopHomeURL() );
00800                 $myUtils->showMessageAndExit( '' );
00801             }
00802 
00803             $this->_processProduct( $this->_oProduct );
00804             $this->_blIsInitialized = true;
00805         }
00806 
00807         return $this->_oProduct;
00808     }
00809 
00815     public function getLinkType()
00816     {
00817         if ( $this->_iLinkType === null ) {
00818             $sListType = oxConfig::getParameter( 'listtype' );
00819             if ( 'vendor' == $sListType ) {
00820                 $this->_iLinkType = OXARTICLE_LINKTYPE_VENDOR;
00821             } elseif ( 'manufacturer' == $sListType ) {
00822                     $this->_iLinkType = OXARTICLE_LINKTYPE_MANUFACTURER;
00823             } elseif ( 'tag' == $sListType ) {
00824                     $this->_iLinkType = OXARTICLE_LINKTYPE_TAG;
00825             } elseif ( 'recommlist' == $sListType ) {
00826                     $this->_iLinkType = OXARTICLE_LINKTYPE_RECOMM;
00827             } else {
00828                 $this->_iLinkType = OXARTICLE_LINKTYPE_CATEGORY;
00829 
00830                 // price category has own type..
00831                 if ( ( $oCat = $this->getActCategory() ) && $oCat->isPriceCategory() ) {
00832                     $this->_iLinkType = OXARTICLE_LINKTYPE_PRICECATEGORY;
00833                 }
00834             }
00835         }
00836 
00837         return $this->_iLinkType;
00838     }
00839 
00845     public function getVariantList()
00846     {
00847         return $this->loadVariantInformation();
00848     }
00849 
00856     public function getVariantListExceptCurrent()
00857     {
00858         $oList = $this->getVariantList();
00859         if (is_object($oList)) {
00860             $oList = clone $oList;
00861         }
00862 
00863         $sOxid = $this->getProduct()->getId();
00864         if (isset($oList[$sOxid])) {
00865             unset($oList[$sOxid]);
00866         }
00867         return $oList;
00868     }
00869 
00875     public function getCaptcha()
00876     {
00877         if ( $this->_oCaptcha === null ) {
00878             $this->_oCaptcha = oxNew('oxCaptcha');
00879         }
00880         return $this->_oCaptcha;
00881     }
00882 
00888     public function getMediaFiles()
00889     {
00890         if ( $this->_aMediaFiles === null ) {
00891             $aMediaFiles = $this->getProduct()->getMediaUrls();
00892             $this->_aMediaFiles = count($aMediaFiles) ? $aMediaFiles : false;
00893         }
00894         return $this->_aMediaFiles;
00895     }
00896 
00904     public function getLastProducts( $iCnt = 4 )
00905     {
00906         if ( $this->_aLastProducts === null ) {
00907             //last seen products for #768CA
00908             $oProduct = $this->getProduct();
00909             $sArtId = $oProduct->oxarticles__oxparentid->value?$oProduct->oxarticles__oxparentid->value:$oProduct->getId();
00910 
00911             $oHistoryArtList = oxNew( 'oxarticlelist' );
00912             $oHistoryArtList->loadHistoryArticles( $sArtId, $iCnt );
00913             $this->_aLastProducts = $oHistoryArtList;
00914         }
00915         return $this->_aLastProducts;
00916     }
00917 
00923     public function getVendor()
00924     {
00925         if ( $this->_oVendor === null ) {
00926             $this->_oVendor = $this->getProduct()->getVendor( false );
00927         }
00928         return $this->_oVendor;
00929     }
00930 
00936     public function getManufacturer()
00937     {
00938         if ( $this->_oManufacturer === null ) {
00939             $this->_oManufacturer = $this->getProduct()->getManufacturer( false );
00940         }
00941         return $this->_oManufacturer;
00942     }
00943 
00949     public function getCategory()
00950     {
00951         if ( $this->_oCategory === null ) {
00952             $this->_oCategory = $this->getProduct()->getCategory();
00953         }
00954         return $this->_oCategory;
00955     }
00956 
00962     public function drawParentUrl()
00963     {
00964         return $this->getProduct()->isVariant();
00965     }
00966 
00972     public function getParentName()
00973     {
00974         if ( $this->_sParentName === null ) {
00975             $this->_sParentName = false;
00976             if ( ( $oParent = $this->_getParentProduct( $this->getProduct()->oxarticles__oxparentid->value ) ) ) {
00977                 $this->_sParentName = $oParent->oxarticles__oxtitle->value;
00978             }
00979         }
00980         return $this->_sParentName;
00981     }
00982 
00988     public function getParentUrl()
00989     {
00990         if ( $this->_sParentUrl === null ) {
00991             $this->_sParentUrl = false;
00992             if ( ( $oParent = $this->_getParentProduct( $this->getProduct()->oxarticles__oxparentid->value ) ) ) {
00993                 $this->_sParentUrl = $oParent->getLink();
00994             }
00995         }
00996         return $this->_sParentUrl;
00997     }
00998 
01004     public function getPictureGallery()
01005     {
01006         if ( $this->_aPicGallery === null ) {
01007             //get picture gallery
01008             $this->_aPicGallery = $this->getPicturesProduct()->getPictureGallery();
01009         }
01010         return $this->_aPicGallery;
01011     }
01012 
01018     public function getActPictureId()
01019     {
01020         $aPicGallery = $this->getPictureGallery();
01021         return $aPicGallery['ActPicID'];
01022     }
01023 
01029     public function getActPicture()
01030     {
01031         $aPicGallery = $this->getPictureGallery();
01032         return $aPicGallery['ActPic'];
01033     }
01034 
01040     public function morePics()
01041     {
01042         $aPicGallery = $this->getPictureGallery();
01043         return $aPicGallery['MorePics'];
01044     }
01045 
01051     public function getPictures()
01052     {
01053         $aPicGallery = $this->getPictureGallery();
01054         return $aPicGallery['Pics'];
01055     }
01056 
01064     public function getArtPic( $sPicNr )
01065     {
01066         $aPicGallery = $this->getPictureGallery();
01067         return $aPicGallery['Pics'][$sPicNr];
01068     }
01069 
01075     public function getIcons()
01076     {
01077         $aPicGallery = $this->getPictureGallery();
01078         return $aPicGallery['Icons'];
01079     }
01080 
01086     public function showZoomPics()
01087     {
01088         $aPicGallery = $this->getPictureGallery();
01089         return $aPicGallery['ZoomPic'];
01090     }
01091 
01097     public function getZoomPics()
01098     {
01099         $aPicGallery = $this->getPictureGallery();
01100         return $aPicGallery['ZoomPics'];
01101     }
01102 
01108     public function getActZoomPic()
01109     {
01110         return 1;
01111     }
01112 
01118     public function getSelectLists()
01119     {
01120         if ( $this->_aSelectLists === null ) {
01121             $this->_aSelectLists = false;
01122             if ( $this->getConfig()->getConfigParam( 'bl_perfLoadSelectLists' ) ) {
01123                 $this->_aSelectLists = $this->getProduct()->getSelectLists();
01124             }
01125         }
01126         return $this->_aSelectLists;
01127     }
01128 
01134     public function getReviews()
01135     {
01136         if ( $this->_aReviews === null ) {
01137             $this->_aReviews = false;
01138             if ( $this->getConfig()->getConfigParam( 'bl_perfLoadReviews' ) ) {
01139                 $this->_aReviews = $this->getProduct()->getReviews();
01140             }
01141         }
01142         return $this->_aReviews;
01143     }
01144 
01150     public function getCrossSelling()
01151     {
01152         if ( $this->_oCrossSelling === null ) {
01153             $this->_oCrossSelling = false;
01154             if ( $oProduct = $this->getProduct() ) {
01155                 $this->_oCrossSelling = $oProduct->getCrossSelling();
01156             }
01157         }
01158         return $this->_oCrossSelling;
01159     }
01160 
01166     public function getSimilarProducts()
01167     {
01168         if ( $this->_oSimilarProducts === null ) {
01169             $this->_oSimilarProducts = false;
01170             if ( $oProduct = $this->getProduct() ) {
01171                 $this->_oSimilarProducts = $oProduct->getSimilarProducts();
01172             }
01173         }
01174         return $this->_oSimilarProducts;
01175     }
01176 
01182     public function getSimilarRecommListIds()
01183     {
01184         if ( $this->_aSimilarRecommListIds === null ) {
01185             $this->_aSimilarRecommListIds = false;
01186 
01187             if ( $oProduct = $this->getProduct() ) {
01188                 $this->_aSimilarRecommListIds = array( $oProduct->getId() );
01189             }
01190         }
01191         return $this->_aSimilarRecommListIds;
01192     }
01193 
01199     public function getAccessoires()
01200     {
01201         if ( $this->_oAccessoires === null ) {
01202             $this->_oAccessoires = false;
01203             if ( $oProduct = $this->getProduct() ) {
01204                 $this->_oAccessoires = $oProduct->getAccessoires();
01205             }
01206         }
01207         return $this->_oAccessoires;
01208     }
01209 
01215     public function getAlsoBoughtTheseProducts()
01216     {
01217         if ( $this->_aAlsoBoughtArts === null ) {
01218             $this->_aAlsoBoughtArts = false;
01219             if ( $oProduct = $this->getProduct() ) {
01220                 $this->_aAlsoBoughtArts = $oProduct->getCustomerAlsoBoughtThisProducts();
01221             }
01222         }
01223         return $this->_aAlsoBoughtArts;
01224     }
01225 
01231     public function isPriceAlarm()
01232     {
01233         // #419 disabling pricealarm if article has fixed price
01234         $oProduct = $this->getProduct();
01235         if ( isset( $oProduct->oxarticles__oxblfixedprice->value ) && $oProduct->oxarticles__oxblfixedprice->value ) {
01236             return 0;
01237         }
01238         return 1;
01239     }
01240 
01249     protected function _getSubject( $iLang )
01250     {
01251         return $this->getProduct();
01252     }
01253 
01259     public function getSearchTitle()
01260     {
01261         return $this->_sSearchTitle;
01262     }
01263 
01271     public function setSearchTitle( $sTitle )
01272     {
01273         $this->_sSearchTitle = $sTitle;
01274     }
01275 
01283     public function setCatTreePath( $sActCatPath )
01284     {
01285         $this->_sCatTreePath = $sActCatPath;
01286     }
01287 
01294     public function noIndex()
01295     {
01296         $sListType = oxConfig::getParameter( 'listtype' );
01297         if ( $sListType && ( 'vendor' == $sListType || 'manufacturer' == $sListType ) ) {
01298             return $this->_iViewIndexState = VIEW_INDEXSTATE_NOINDEXFOLLOW;
01299         }
01300         return parent::noIndex();
01301     }
01302 
01308     public function getTitle()
01309     {
01310         if ( $oProduct = $this->getProduct() ) {
01311             return $oProduct->oxarticles__oxtitle->value . ( $oProduct->oxarticles__oxvarselect->value ? ' ' . $oProduct->oxarticles__oxvarselect->value : '' );
01312         }
01313     }
01314 
01315 
01321     public function getTag()
01322     {
01323         return oxConfig::getParameter("searchtag", 1);
01324     }
01325 
01331     public function getCanonicalUrl()
01332     {
01333         if ( ( $oProduct = $this->getProduct() ) ) {
01334             if ( $oProduct->oxarticles__oxparentid->value ) {
01335                 $oProduct = $this->_getParentProduct( $oProduct->oxarticles__oxparentid->value );
01336             }
01337 
01338             $oUtils = oxRegistry::get("oxUtilsUrl");
01339             if ( oxRegistry::getUtils()->seoIsActive() ) {
01340                 $sUrl = $oUtils->prepareCanonicalUrl( $oProduct->getBaseSeoLink( $oProduct->getLanguage(), true ) );
01341             } else {
01342                 $sUrl = $oUtils->prepareCanonicalUrl( $oProduct->getBaseStdLink( $oProduct->getLanguage() ) );
01343             }
01344             return $sUrl;
01345         }
01346     }
01347 
01353     public function isMdVariantView()
01354     {
01355         if ( $this->_blMdView === null ) {
01356             $this->_blMdView = false;
01357             if ( $this->getConfig()->getConfigParam( 'blUseMultidimensionVariants' ) ) {
01358                 $iMaxMdDepth = $this->getProduct()->getMdVariants()->getMaxDepth();
01359                 $this->_blMdView = ($iMaxMdDepth > 1);
01360             }
01361         }
01362 
01363         return $this->_blMdView;
01364     }
01365 
01371     public function isPersParam()
01372     {
01373         $oProduct = $this->getProduct();
01374         return $oProduct->oxarticles__oxisconfigurable->value;
01375     }
01376 
01382     public function getTagSeparator()
01383     {
01384         $sSepartor = $this->getConfig()->getConfigParam("sTagSeparator");
01385         return $sSepartor;
01386     }
01387 
01393     public function getRatingValue()
01394     {
01395 
01396         if ( $this->_dRatingValue === null ) {
01397             $this->_dRatingValue = (double) 0;
01398             if ( $this->isReviewActive() && ( $oDetailsProduct = $this->getProduct() ) ) {
01399                 $this->_dRatingValue = round( $oDetailsProduct->getArticleRatingAverage( $this->getConfig()->getConfigParam( 'blShowVariantReviews' ) ), 1);
01400             }
01401         }
01402 
01403         return (double) $this->_dRatingValue;
01404     }
01405 
01411     public function isReviewActive()
01412     {
01413         return $this->getConfig()->getConfigParam( 'bl_perfLoadReviews' );
01414     }
01415 
01421     public function getRatingCount()
01422     {
01423         if ( $this->_iRatingCnt === null ) {
01424             $this->_iRatingCnt = false;
01425             if ( $this->isReviewActive() && ( $oDetailsProduct = $this->getProduct() ) ) {
01426                 $this->_iRatingCnt = $oDetailsProduct->getArticleRatingCount( $this->getConfig()->getConfigParam( 'blShowVariantReviews' ) );
01427             }
01428         }
01429         return $this->_iRatingCnt;
01430     }
01431 
01437     public function getBreadCrumb()
01438     {
01439         $aPaths = array();
01440 
01441         if ( 'search' == oxConfig::getParameter( 'listtype' ) ) {
01442             $sSearchParam = $this->getSearchParamForHtml();
01443 
01444             $aCatPath = array();
01445             $aCatPath['title'] = sprintf( oxRegistry::getLang()->translateString( 'searchResult', oxRegistry::getLang()->getBaseLanguage(), false ), $sSearchParam );
01446             $aCatPath['link']  = $this->getViewConfig()->getSelfLink() . 'stoken=' . oxSession::getVar('sess_stoken') . "&amp;cl=search&amp;searchparam=" . $sSearchParam;
01447 
01448             $aPaths[] = $aCatPath;
01449 
01450         } elseif ( 'tag' == oxConfig::getParameter( 'listtype' ) ) {
01451 
01452             $aCatPath = array();
01453 
01454             $aCatPath['title'] = oxRegistry::getLang()->translateString( 'TAGS', oxRegistry::getLang()->getBaseLanguage(), false );
01455             $aCatPath['link']  = oxRegistry::get("oxSeoEncoder")->getStaticUrl( $this->getViewConfig()->getSelfLink() . 'cl=tags' );
01456             $aPaths[] = $aCatPath;
01457 
01458             $oStr = getStr();
01459             $aCatPath['title'] = $oStr->ucfirst(oxConfig::getParameter( 'searchtag' ));
01460             $aCatPath['link']  = oxRegistry::get("oxSeoEncoderTag")->getTagUrl( oxConfig::getParameter( 'searchtag' ) );
01461             $aPaths[] = $aCatPath;
01462 
01463         } elseif ( 'recommlist' == oxConfig::getParameter( 'listtype' ) ) {
01464 
01465             $aCatPath = array();
01466             $aCatPath['title'] = oxRegistry::getLang()->translateString( 'PAGE_RECOMMENDATIONS_PRODUCTS_TITLE', oxRegistry::getLang()->getBaseLanguage(), false );
01467             $aPaths[] = $aCatPath;
01468         } else {
01469 
01470             $oCatTree = $this->getCatTreePath();
01471 
01472             if ( $oCatTree ) {
01473 
01474                 foreach ( $oCatTree as $oCat ) {
01475                     $aCatPath = array();
01476 
01477                     $aCatPath['link'] = $oCat->getLink();
01478                     $aCatPath['title'] = $oCat->oxcategories__oxtitle->value;
01479 
01480                     $aPaths[] = $aCatPath;
01481                 }
01482             }
01483         }
01484 
01485         return $aPaths;
01486     }
01487 
01497     public function addme()
01498     {
01499         $myConfig = $this->getConfig();
01500         $myUtils  = oxRegistry::getUtils();
01501 
01502         //control captcha
01503         $sMac     = oxConfig::getParameter( 'c_mac' );
01504         $sMacHash = oxConfig::getParameter( 'c_mach' );
01505         $oCaptcha = $this->getCaptcha();
01506         if ( !$oCaptcha->pass( $sMac, $sMacHash ) ) {
01507             $this->_iPriceAlarmStatus = 2;
01508             return;
01509         }
01510 
01511         $aParams = oxConfig::getParameter( 'pa' );
01512         if ( !isset( $aParams['email'] ) || !$myUtils->isValidEmail( $aParams['email'] ) ) {
01513             $this->_iPriceAlarmStatus = 0;
01514             return;
01515         }
01516         $aParams['aid'] = $this->getProduct()->getId();
01517         $oCur = $myConfig->getActShopCurrencyObject();
01518         // convert currency to default
01519         $dPrice = $myUtils->currency2Float( $aParams['price'] );
01520 
01521         $oAlarm = oxNew( "oxpricealarm" );
01522         $oAlarm->oxpricealarm__oxuserid = new oxField( oxSession::getVar( 'usr' ));
01523         $oAlarm->oxpricealarm__oxemail  = new oxField( $aParams['email']);
01524         $oAlarm->oxpricealarm__oxartid  = new oxField( $aParams['aid']);
01525         $oAlarm->oxpricealarm__oxprice  = new oxField( $myUtils->fRound( $dPrice, $oCur ));
01526         $oAlarm->oxpricealarm__oxshopid = new oxField( $myConfig->getShopId());
01527         $oAlarm->oxpricealarm__oxcurrency = new oxField( $oCur->name);
01528 
01529         $oAlarm->oxpricealarm__oxlang = new oxField(oxRegistry::getLang()->getBaseLanguage());
01530 
01531         $oAlarm->save();
01532 
01533         // Send Email
01534         $oEmail = oxNew( 'oxemail' );
01535         $this->_iPriceAlarmStatus = (int) $oEmail->sendPricealarmNotification( $aParams, $oAlarm );
01536     }
01537 
01543     public function getPriceAlarmStatus()
01544     {
01545         return $this->_iPriceAlarmStatus;
01546     }
01547 
01553     public function getBidPrice()
01554     {
01555         if ( $this->_sBidPrice === null ) {
01556             $this->_sBidPrice = false;
01557 
01558             $aParams = oxConfig::getParameter( 'pa' );
01559             $oCur = $this->getConfig()->getActShopCurrencyObject();
01560             $iPrice = oxRegistry::getUtils()->currency2Float( $aParams['price'] );
01561             $this->_sBidPrice = oxRegistry::getLang()->formatCurrency( $iPrice, $oCur );
01562         }
01563         return $this->_sBidPrice;
01564     }
01565 
01571     public function getVariantSelections()
01572     {
01573         // finding parent
01574         $oProduct = $this->getProduct();
01575         if ( ( $oParent = $this->_getParentProduct( $oProduct->oxarticles__oxparentid->value ) ) ) {
01576             return $oParent->getVariantSelections( oxConfig::getParameter( "varselid" ), $oProduct->getId() );
01577         }
01578 
01579         return $oProduct->getVariantSelections( oxConfig::getParameter( "varselid" ) );
01580     }
01581 
01587     public function getPicturesProduct()
01588     {
01589         $aVariantSelections = $this->getVariantSelections();
01590         if ($aVariantSelections && $aVariantSelections['oActiveVariant'] && !$aVariantSelections['blPerfectFit']) {
01591             return $aVariantSelections['oActiveVariant'];
01592         }
01593         return $this->getProduct();
01594     }
01595 
01601     public function getSearchParamForHtml()
01602     {
01603         if ( $this->_sSearchParamForHtml === null ) {
01604             $this->_sSearchParamForHtml = oxConfig::getParameter( 'searchparam' );
01605         }
01606         return $this->_sSearchParamForHtml;
01607     }
01608 
01614     public function showRdfa()
01615     {
01616         return $this->getConfig()->getConfigParam( 'blRDFaEmbedding' );
01617     }
01618 
01624     public function getRDFaNormalizedRating()
01625     {
01626         $myConfig = $this->getConfig();
01627         $iMin = $myConfig->getConfigParam("iRDFaMinRating");
01628         $iMax = $myConfig->getConfigParam("iRDFaMaxRating");
01629 
01630         $oProduct = $this->getProduct();
01631         $iCount = $oProduct->oxarticles__oxratingcnt->value;
01632         if ( isset($iMin) && isset($iMax) && $iMax != '' && $iMin != '' && $iCount > 0 ) {
01633             $aNomalizedRating = array();
01634             $iValue = ((4*($oProduct->oxarticles__oxrating->value - $iMin)/($iMax - $iMin)))+1;
01635             $aNomalizedRating["count"] = $iCount;
01636             $aNomalizedRating["value"] = round($iValue, 2);
01637             return $aNomalizedRating;
01638         }
01639         return false;
01640     }
01641 
01649     public function getRDFaValidityPeriod($sShopConfVar)
01650     {
01651         if ( $sShopConfVar ) {
01652             $aValidity = array();
01653             $iDays = $this->getConfig()->getConfigParam($sShopConfVar);
01654             $iFrom = oxRegistry::get("oxUtilsDate")->getTime();
01655 
01656             $iThrough = $iFrom + ($iDays * 24 * 60 * 60);
01657             $aValidity["from"] = date('Y-m-d\TH:i:s', $iFrom)."Z";
01658             $aValidity["through"] = date('Y-m-d\TH:i:s', $iThrough)."Z";
01659 
01660             return $aValidity;
01661         }
01662         return false;
01663     }
01664 
01670     public function getRDFaBusinessFnc()
01671     {
01672         return $this->getConfig()->getConfigParam("sRDFaBusinessFnc");
01673     }
01674 
01680     public function getRDFaCustomers()
01681     {
01682         return $this->getConfig()->getConfigParam("aRDFaCustomers");
01683     }
01684 
01690     public function getRDFaVAT()
01691     {
01692         return $this->getConfig()->getConfigParam("iRDFaVAT");
01693     }
01694 
01700     public function getRDFaGenericCondition()
01701     {
01702         return $this->getConfig()->getConfigParam("iRDFaCondition");
01703     }
01704 
01710     public function getBundleArticle()
01711     {
01712         $oProduct = $this->getProduct();
01713         if ( $oProduct && $oProduct->oxarticles__oxbundleid->value ) {
01714             $oArticle = oxNew("oxarticle");
01715             $oArticle->load($oProduct->oxarticles__oxbundleid->value);
01716             return $oArticle;
01717         }
01718         return false;
01719     }
01720 
01726     public function getRDFaPaymentMethods()
01727     {
01728         $iPrice = $this->getProduct()->getPrice()->getBruttoPrice();
01729         $oPayments = oxNew("oxpaymentlist");
01730         $oPayments->loadRDFaPaymentList($iPrice);
01731         return $oPayments;
01732     }
01733 
01739     public function getRDFaDeliverySetMethods()
01740     {
01741         $oDelSets = oxNew("oxdeliverysetlist");
01742         $oDelSets->loadRDFaDeliverySetList();
01743         return $oDelSets;
01744     }
01745 
01751     public function getProductsDeliveryList()
01752     {
01753         $oProduct = $this->getProduct();
01754         $oDelList = oxNew( "oxDeliveryList" );
01755         $oDelList->loadDeliveryListForProduct( $oProduct );
01756         return $oDelList;
01757     }
01758 
01764     public function getRDFaDeliveryChargeSpecLoc()
01765     {
01766         return $this->getConfig()->getConfigParam("sRDFaDeliveryChargeSpecLoc");
01767     }
01768 
01774     public function getRDFaPaymentChargeSpecLoc()
01775     {
01776         return $this->getConfig()->getConfigParam("sRDFaPaymentChargeSpecLoc");
01777     }
01778 
01784     public function getRDFaBusinessEntityLoc()
01785     {
01786         return $this->getConfig()->getConfigParam("sRDFaBusinessEntityLoc");
01787     }
01788 
01794     public function showRDFaProductStock()
01795     {
01796         return $this->getConfig()->getConfigParam("blShowRDFaProductStock");
01797     }
01798 
01799 }