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 (!oxRegistry::getSession()->checkSessionChallenge()) {
00508             return;
00509         }
00510 
00511         if ( $this->canAcceptFormData() &&
00512              ( $oUser = $this->getUser() ) && ( $oProduct = $this->getProduct() ) ) {
00513 
00514             $dRating = oxConfig::getParameter( 'artrating' );
00515             if ( $dRating !== null ) {
00516                 $dRating = (int) $dRating;
00517             }
00518 
00519             //save rating
00520             if ( $dRating !== null && $dRating >= 1 && $dRating <= 5 ) {
00521                 $oRating = oxNew( 'oxrating' );
00522                 if ( $oRating->allowRating( $oUser->getId(), 'oxarticle', $oProduct->getId() ) ) {
00523                     $oRating->oxratings__oxuserid   = new oxField( $oUser->getId() );
00524                     $oRating->oxratings__oxtype     = new oxField( 'oxarticle' );
00525                     $oRating->oxratings__oxobjectid = new oxField( $oProduct->getId() );
00526                     $oRating->oxratings__oxrating   = new oxField( $dRating );
00527                     $oRating->save();
00528                     $oProduct->addToRatingAverage( $dRating );
00529                 }
00530             }
00531 
00532             if ( ( $sReviewText = trim( ( string ) oxConfig::getParameter( 'rvw_txt', true ) ) ) ) {
00533                 $oReview = oxNew( 'oxreview' );
00534                 $oReview->oxreviews__oxobjectid = new oxField( $oProduct->getId() );
00535                 $oReview->oxreviews__oxtype     = new oxField( 'oxarticle' );
00536                 $oReview->oxreviews__oxtext     = new oxField( $sReviewText, oxField::T_RAW );
00537                 $oReview->oxreviews__oxlang     = new oxField( oxRegistry::getLang()->getBaseLanguage() );
00538                 $oReview->oxreviews__oxuserid   = new oxField( $oUser->getId() );
00539                 $oReview->oxreviews__oxrating   = new oxField( ( $dRating !== null ) ? $dRating : 0);
00540                 $oReview->save();
00541             }
00542         }
00543     }
00544 
00550     public function addToRecomm()
00551     {
00552         if (!oxRegistry::getSession()->checkSessionChallenge()) {
00553             return;
00554         }
00555 
00556         if (!$this->getViewConfig()->getShowListmania()) {
00557             return;
00558         }
00559 
00560         $sRecommText = trim( ( string ) oxConfig::getParameter( 'recomm_txt' ) );
00561         $sRecommList = oxConfig::getParameter( 'recomm' );
00562         $sArtId      = $this->getProduct()->getId();
00563 
00564         if ( $sArtId ) {
00565             $oRecomm = oxNew( 'oxrecommlist' );
00566             $oRecomm->load( $sRecommList);
00567             $oRecomm->addArticle( $sArtId, $sRecommText );
00568         }
00569     }
00570 
00576     public function addTags()
00577     {
00578         if (!oxRegistry::getSession()->checkSessionChallenge()) {
00579             return;
00580         }
00581 
00582         $sTags  = $this->getConfig()->getRequestParameter('newTags', true );
00583         $sHighTag  = $this->getConfig()->getRequestParameter( 'highTags', true );
00584         if ( !$sTags && !$sHighTag) {
00585             return;
00586         }
00587         if ( $sHighTag ) {
00588             $sTags = getStr()->html_entity_decode( $sHighTag );
00589         }
00590         $oProduct = $this->getProduct();
00591 
00592         // set current user added tags for this article for later checking
00593         $aTaggedProducts = oxRegistry::getSession()->getVariable("aTaggedProducts");
00594         $aAddedTags = $aTaggedProducts? $aTaggedProducts[$oProduct->getId()] : array();
00595 
00596         $oArticleTagList = oxNew( "oxarticletaglist" );
00597         $oArticleTagList->load( $oProduct->getId() );
00598         $sSeparator = $oArticleTagList->get()->getSeparator();
00599         $aTags = explode( $sSeparator, $sTags );
00600         $blAddedTag = false;
00601         foreach ( $aTags as $sTag ) {
00602             $oTag = oxNew( "oxtag" );
00603             $oTag->set( $sTag );
00604             if ( $aAddedTags[$oTag->get()] != 1 ) {
00605                 $oArticleTagList->addTag( $oTag );
00606                 $aAddedTags[$oTag->get()] = 1;
00607                 $blAddedTag = true;
00608             }
00609         }
00610         if ( $blAddedTag ) {
00611             $oArticleTagList->save();
00612             $aTaggedProducts[$oProduct->getId()] = $aAddedTags;
00613             oxRegistry::getSession()->setVariable( 'aTaggedProducts', $aTaggedProducts);
00614         }
00615         // for ajax call
00616         if ( $this->getConfig()->getRequestParameter( 'blAjax', true ) ) {
00617             oxRegistry::getUtils()->showMessageAndExit( $blAddedTag );
00618         }
00619     }
00620 
00626     public function editTags()
00627     {
00628         if ( !$this->getUser() ) {
00629             return;
00630         }
00631         $oArticleTagList = oxNew("oxArticleTagList");
00632         $oArticleTagList->load( $this->getProduct()->getId() );
00633         $oTagSet = $oArticleTagList->get();
00634         $this->_aTags = $oTagSet->get();
00635         $this->_blEditTags = true;
00636 
00637         // for ajax call
00638         if ( $this->getConfig()->getRequestParameter( 'blAjax', true ) ) {
00639             oxRegistry::getUtils()->setHeader( "Content-Type: text/html; charset=".oxRegistry::getLang()->translateString( 'charset' ) );
00640             $oActView = oxNew( 'oxubase' );
00641             $oSmarty = oxRegistry::get("oxUtilsView")->getSmarty();
00642             $oSmarty->assign('oView', $this );
00643             $oSmarty->assign('oViewConf', $this->getViewConfig() );
00644             oxRegistry::getUtils()->showMessageAndExit( $oSmarty->fetch( 'page/details/inc/editTags.tpl', $this->getViewId() ) );
00645         }
00646     }
00647 
00653     public function cancelTags()
00654     {
00655         $oArticleTagList = oxNew("oxArticleTagList");
00656         $oArticleTagList->load( $this->getProduct()->getId() );
00657         $oTagSet = $oArticleTagList->get();
00658         $this->_aTags = $oTagSet->get();
00659         $this->_blEditTags = false;
00660 
00661         // for ajax call
00662         if ( oxConfig::getParameter( 'blAjax', true ) ) {
00663             oxRegistry::getUtils()->setHeader( "Content-Type: text/html; charset=".oxRegistry::getLang()->translateString( 'charset' ) );
00664             $oActView = oxNew( 'oxubase' );
00665             $oSmarty = oxRegistry::get("oxUtilsView")->getSmarty();
00666             $oSmarty->assign('oView', $this );
00667             $oSmarty->assign('oViewConf', $this->getViewConfig() );
00668             oxRegistry::getUtils()->showMessageAndExit( $oSmarty->fetch( 'page/details/inc/tags.tpl', $this->getViewId() ) );
00669         }
00670     }
00671 
00677     protected function _getSeoObjectId()
00678     {
00679         if ( $oProduct = $this->getProduct() ) {
00680             return $oProduct->getId();
00681         }
00682     }
00683 
00689     public function getAttributes()
00690     {
00691         if ( $this->_aAttributes === null ) {
00692             // all attributes this article has
00693             $aArtAttributes = $this->getProduct()->getAttributes();
00694 
00695             //making a new array for backward compatibility
00696             $this->_aAttributes = false;
00697 
00698             if ( count( $aArtAttributes ) ) {
00699                 foreach ( $aArtAttributes as $sKey => $oAttribute ) {
00700                     $this->_aAttributes[$sKey] = new stdClass();
00701                     $this->_aAttributes[$sKey]->title = $oAttribute->oxattribute__oxtitle->value;
00702                     $this->_aAttributes[$sKey]->value = $oAttribute->oxattribute__oxvalue->value;
00703                 }
00704             }
00705         }
00706         return $this->_aAttributes;
00707     }
00708 
00709 
00715     public function getEditTags()
00716     {
00717         return $this->_blEditTags;
00718     }
00719 
00725     public function getTags()
00726     {
00727         return $this->_aTags;
00728     }
00729 
00735     public function getTagCloudManager()
00736     {
00737         $oManager = oxNew( "oxTagCloud" );
00738         $oManager->setExtendedMode( true );
00739         $oManager->setProductId( $this->getProduct()->getId() );
00740         return $oManager;
00741     }
00742 
00749     public function isEditableTags()
00750     {
00751         if ( $this->_blCanEditTags === null ) {
00752             $this->_blCanEditTags = false;
00753             if ( $this->getProduct() && $this->getUser()) {
00754                 $this->_blCanEditTags = true;
00755             }
00756         }
00757         return $this->_blCanEditTags;
00758     }
00759 
00765     public function getProduct()
00766     {
00767         $myConfig = $this->getConfig();
00768         $myUtils = oxRegistry::getUtils();
00769 
00770         if ( $this->_oProduct === null ) {
00771 
00772             //this option is only for lists and we must reset value
00773             //as blLoadVariants = false affect "ab price" functionality
00774             $myConfig->setConfigParam( 'blLoadVariants', true );
00775 
00776             $sOxid = oxConfig::getParameter( 'anid' );
00777 
00778             // object is not yet loaded
00779             $this->_oProduct = oxNew( 'oxarticle' );
00780 
00781             if ( !$this->_oProduct->load( $sOxid ) ) {
00782                 $myUtils->redirect( $myConfig->getShopHomeURL() );
00783                 $myUtils->showMessageAndExit( '' );
00784             }
00785 
00786             $aVariantSelections = $this->_oProduct->getVariantSelections( oxConfig::getParameter( "varselid" ) );
00787             if ($aVariantSelections && $aVariantSelections['oActiveVariant'] && $aVariantSelections['blPerfectFit']) {
00788                 $this->_oProduct = $aVariantSelections['oActiveVariant'];
00789             }
00790         }
00791 
00792         // additional checks
00793         if ( !$this->_blIsInitialized ) {
00794 
00795             $blContinue = true;
00796             if ( !$this->_oProduct->isVisible() ) {
00797                 $blContinue = false;
00798             } elseif ( $this->_oProduct->oxarticles__oxparentid->value ) {
00799                 $oParent = $this->_getParentProduct( $this->_oProduct->oxarticles__oxparentid->value );
00800                 if ( !$oParent || !$oParent->isVisible() ) {
00801                     $blContinue = false;
00802                 }
00803             }
00804 
00805             if ( !$blContinue ) {
00806                 $myUtils->redirect( $myConfig->getShopHomeURL() );
00807                 $myUtils->showMessageAndExit( '' );
00808             }
00809 
00810             $this->_processProduct( $this->_oProduct );
00811             $this->_blIsInitialized = true;
00812         }
00813 
00814         return $this->_oProduct;
00815     }
00816 
00822     public function getLinkType()
00823     {
00824         if ( $this->_iLinkType === null ) {
00825             $sListType = oxConfig::getParameter( 'listtype' );
00826             if ( 'vendor' == $sListType ) {
00827                 $this->_iLinkType = OXARTICLE_LINKTYPE_VENDOR;
00828             } elseif ( 'manufacturer' == $sListType ) {
00829                     $this->_iLinkType = OXARTICLE_LINKTYPE_MANUFACTURER;
00830             } elseif ( 'tag' == $sListType ) {
00831                     $this->_iLinkType = OXARTICLE_LINKTYPE_TAG;
00832             } elseif ( 'recommlist' == $sListType ) {
00833                     $this->_iLinkType = OXARTICLE_LINKTYPE_RECOMM;
00834             } else {
00835                 $this->_iLinkType = OXARTICLE_LINKTYPE_CATEGORY;
00836 
00837                 // price category has own type..
00838                 if ( ( $oCat = $this->getActiveCategory() ) && $oCat->isPriceCategory() ) {
00839                     $this->_iLinkType = OXARTICLE_LINKTYPE_PRICECATEGORY;
00840                 }
00841             }
00842         }
00843 
00844         return $this->_iLinkType;
00845     }
00846 
00852     public function getVariantList()
00853     {
00854         return $this->loadVariantInformation();
00855     }
00856 
00863     public function getVariantListExceptCurrent()
00864     {
00865         $oList = $this->getVariantList();
00866         if (is_object($oList)) {
00867             $oList = clone $oList;
00868         }
00869 
00870         $sOxid = $this->getProduct()->getId();
00871         if (isset($oList[$sOxid])) {
00872             unset($oList[$sOxid]);
00873         }
00874         return $oList;
00875     }
00876 
00882     public function getCaptcha()
00883     {
00884         if ( $this->_oCaptcha === null ) {
00885             $this->_oCaptcha = oxNew('oxCaptcha');
00886         }
00887         return $this->_oCaptcha;
00888     }
00889 
00895     public function getMediaFiles()
00896     {
00897         if ( $this->_aMediaFiles === null ) {
00898             $aMediaFiles = $this->getProduct()->getMediaUrls();
00899             $this->_aMediaFiles = count($aMediaFiles) ? $aMediaFiles : false;
00900         }
00901         return $this->_aMediaFiles;
00902     }
00903 
00911     public function getLastProducts( $iCnt = 4 )
00912     {
00913         if ( $this->_aLastProducts === null ) {
00914             //last seen products for #768CA
00915             $oProduct = $this->getProduct();
00916             $sArtId = $oProduct->oxarticles__oxparentid->value?$oProduct->oxarticles__oxparentid->value:$oProduct->getId();
00917 
00918             $oHistoryArtList = oxNew( 'oxarticlelist' );
00919             $oHistoryArtList->loadHistoryArticles( $sArtId, $iCnt );
00920             $this->_aLastProducts = $oHistoryArtList;
00921         }
00922         return $this->_aLastProducts;
00923     }
00924 
00930     public function getVendor()
00931     {
00932         if ( $this->_oVendor === null ) {
00933             $this->_oVendor = $this->getProduct()->getVendor( false );
00934         }
00935         return $this->_oVendor;
00936     }
00937 
00943     public function getManufacturer()
00944     {
00945         if ( $this->_oManufacturer === null ) {
00946             $this->_oManufacturer = $this->getProduct()->getManufacturer( false );
00947         }
00948         return $this->_oManufacturer;
00949     }
00950 
00956     public function getCategory()
00957     {
00958         if ( $this->_oCategory === null ) {
00959             $this->_oCategory = $this->getProduct()->getCategory();
00960         }
00961         return $this->_oCategory;
00962     }
00963 
00969     public function drawParentUrl()
00970     {
00971         return $this->getProduct()->isVariant();
00972     }
00973 
00979     public function getParentName()
00980     {
00981         if ( $this->_sParentName === null ) {
00982             $this->_sParentName = false;
00983             if ( ( $oParent = $this->_getParentProduct( $this->getProduct()->oxarticles__oxparentid->value ) ) ) {
00984                 $this->_sParentName = $oParent->oxarticles__oxtitle->value;
00985             }
00986         }
00987         return $this->_sParentName;
00988     }
00989 
00995     public function getParentUrl()
00996     {
00997         if ( $this->_sParentUrl === null ) {
00998             $this->_sParentUrl = false;
00999             if ( ( $oParent = $this->_getParentProduct( $this->getProduct()->oxarticles__oxparentid->value ) ) ) {
01000                 $this->_sParentUrl = $oParent->getLink();
01001             }
01002         }
01003         return $this->_sParentUrl;
01004     }
01005 
01011     public function getPictureGallery()
01012     {
01013         if ( $this->_aPicGallery === null ) {
01014             //get picture gallery
01015             $this->_aPicGallery = $this->getPicturesProduct()->getPictureGallery();
01016         }
01017         return $this->_aPicGallery;
01018     }
01019 
01025     public function getActPictureId()
01026     {
01027         $aPicGallery = $this->getPictureGallery();
01028         return $aPicGallery['ActPicID'];
01029     }
01030 
01036     public function getActPicture()
01037     {
01038         $aPicGallery = $this->getPictureGallery();
01039         return $aPicGallery['ActPic'];
01040     }
01041 
01047     public function morePics()
01048     {
01049         $aPicGallery = $this->getPictureGallery();
01050         return $aPicGallery['MorePics'];
01051     }
01052 
01058     public function getPictures()
01059     {
01060         $aPicGallery = $this->getPictureGallery();
01061         return $aPicGallery['Pics'];
01062     }
01063 
01071     public function getArtPic( $sPicNr )
01072     {
01073         $aPicGallery = $this->getPictureGallery();
01074         return $aPicGallery['Pics'][$sPicNr];
01075     }
01076 
01082     public function getIcons()
01083     {
01084         $aPicGallery = $this->getPictureGallery();
01085         return $aPicGallery['Icons'];
01086     }
01087 
01093     public function showZoomPics()
01094     {
01095         $aPicGallery = $this->getPictureGallery();
01096         return $aPicGallery['ZoomPic'];
01097     }
01098 
01104     public function getZoomPics()
01105     {
01106         $aPicGallery = $this->getPictureGallery();
01107         return $aPicGallery['ZoomPics'];
01108     }
01109 
01115     public function getActZoomPic()
01116     {
01117         return 1;
01118     }
01119 
01125     public function getSelectLists()
01126     {
01127         if ( $this->_aSelectLists === null ) {
01128             $this->_aSelectLists = false;
01129             if ( $this->getConfig()->getConfigParam( 'bl_perfLoadSelectLists' ) ) {
01130                 $this->_aSelectLists = $this->getProduct()->getSelectLists();
01131             }
01132         }
01133         return $this->_aSelectLists;
01134     }
01135 
01141     public function getReviews()
01142     {
01143         if ( $this->_aReviews === null ) {
01144             $this->_aReviews = false;
01145             if ( $this->getConfig()->getConfigParam( 'bl_perfLoadReviews' ) ) {
01146                 $this->_aReviews = $this->getProduct()->getReviews();
01147             }
01148         }
01149         return $this->_aReviews;
01150     }
01151 
01157     public function getCrossSelling()
01158     {
01159         if ( $this->_oCrossSelling === null ) {
01160             $this->_oCrossSelling = false;
01161             if ( $oProduct = $this->getProduct() ) {
01162                 $this->_oCrossSelling = $oProduct->getCrossSelling();
01163             }
01164         }
01165         return $this->_oCrossSelling;
01166     }
01167 
01173     public function getSimilarProducts()
01174     {
01175         if ( $this->_oSimilarProducts === null ) {
01176             $this->_oSimilarProducts = false;
01177             if ( $oProduct = $this->getProduct() ) {
01178                 $this->_oSimilarProducts = $oProduct->getSimilarProducts();
01179             }
01180         }
01181         return $this->_oSimilarProducts;
01182     }
01183 
01189     public function getSimilarRecommListIds()
01190     {
01191         if ( $this->_aSimilarRecommListIds === null ) {
01192             $this->_aSimilarRecommListIds = false;
01193 
01194             if ( $oProduct = $this->getProduct() ) {
01195                 $this->_aSimilarRecommListIds = array( $oProduct->getId() );
01196             }
01197         }
01198         return $this->_aSimilarRecommListIds;
01199     }
01200 
01206     public function getAccessoires()
01207     {
01208         if ( $this->_oAccessoires === null ) {
01209             $this->_oAccessoires = false;
01210             if ( $oProduct = $this->getProduct() ) {
01211                 $this->_oAccessoires = $oProduct->getAccessoires();
01212             }
01213         }
01214         return $this->_oAccessoires;
01215     }
01216 
01222     public function getAlsoBoughtTheseProducts()
01223     {
01224         if ( $this->_aAlsoBoughtArts === null ) {
01225             $this->_aAlsoBoughtArts = false;
01226             if ( $oProduct = $this->getProduct() ) {
01227                 $this->_aAlsoBoughtArts = $oProduct->getCustomerAlsoBoughtThisProducts();
01228             }
01229         }
01230         return $this->_aAlsoBoughtArts;
01231     }
01232 
01238     public function isPriceAlarm()
01239     {
01240         // #419 disabling price alarm if article has fixed price
01241         $oProduct = $this->getProduct();
01242         if ( isset( $oProduct->oxarticles__oxblfixedprice->value ) && $oProduct->oxarticles__oxblfixedprice->value ) {
01243             return 0;
01244         }
01245         return 1;
01246     }
01247 
01256     protected function _getSubject( $iLang )
01257     {
01258         return $this->getProduct();
01259     }
01260 
01266     public function getSearchTitle()
01267     {
01268         return $this->_sSearchTitle;
01269     }
01270 
01278     public function setSearchTitle( $sTitle )
01279     {
01280         $this->_sSearchTitle = $sTitle;
01281     }
01282 
01290     public function setCatTreePath( $sActCatPath )
01291     {
01292         $this->_sCatTreePath = $sActCatPath;
01293     }
01294 
01301     public function noIndex()
01302     {
01303         $sListType = oxConfig::getParameter( 'listtype' );
01304         if ( $sListType && ( 'vendor' == $sListType || 'manufacturer' == $sListType ) ) {
01305             return $this->_iViewIndexState = VIEW_INDEXSTATE_NOINDEXFOLLOW;
01306         }
01307         return parent::noIndex();
01308     }
01309 
01315     public function getTitle()
01316     {
01317         if ( $oProduct = $this->getProduct() ) {
01318             return $oProduct->oxarticles__oxtitle->value . ( $oProduct->oxarticles__oxvarselect->value ? ' ' . $oProduct->oxarticles__oxvarselect->value : '' );
01319         }
01320     }
01321 
01322 
01328     public function getTag()
01329     {
01330         return oxConfig::getParameter("searchtag");
01331     }
01332 
01338     public function getCanonicalUrl()
01339     {
01340         if ( ( $oProduct = $this->getProduct() ) ) {
01341             if ( $oProduct->oxarticles__oxparentid->value ) {
01342                 $oProduct = $this->_getParentProduct( $oProduct->oxarticles__oxparentid->value );
01343             }
01344 
01345             $oUtils = oxRegistry::get("oxUtilsUrl");
01346             if ( oxRegistry::getUtils()->seoIsActive() ) {
01347                 $sUrl = $oUtils->prepareCanonicalUrl( $oProduct->getBaseSeoLink( $oProduct->getLanguage(), true ) );
01348             } else {
01349                 $sUrl = $oUtils->prepareCanonicalUrl( $oProduct->getBaseStdLink( $oProduct->getLanguage() ) );
01350             }
01351             return $sUrl;
01352         }
01353     }
01354 
01360     public function isMdVariantView()
01361     {
01362         if ( $this->_blMdView === null ) {
01363             $this->_blMdView = false;
01364             if ( $this->getConfig()->getConfigParam( 'blUseMultidimensionVariants' ) ) {
01365                 $iMaxMdDepth = $this->getProduct()->getMdVariants()->getMaxDepth();
01366                 $this->_blMdView = ($iMaxMdDepth > 1);
01367             }
01368         }
01369 
01370         return $this->_blMdView;
01371     }
01372 
01378     public function isPersParam()
01379     {
01380         $oProduct = $this->getProduct();
01381         return $oProduct->oxarticles__oxisconfigurable->value;
01382     }
01383 
01389     public function getTagSeparator()
01390     {
01391         $sSepartor = $this->getConfig()->getConfigParam("sTagSeparator");
01392         return $sSepartor;
01393     }
01394 
01400     public function getRatingValue()
01401     {
01402 
01403         if ( $this->_dRatingValue === null ) {
01404             $this->_dRatingValue = (double) 0;
01405             if ( $this->isReviewActive() && ( $oDetailsProduct = $this->getProduct() ) ) {
01406                 $this->_dRatingValue = round( $oDetailsProduct->getArticleRatingAverage( $this->getConfig()->getConfigParam( 'blShowVariantReviews' ) ), 1);
01407             }
01408         }
01409 
01410         return (double) $this->_dRatingValue;
01411     }
01412 
01418     public function isReviewActive()
01419     {
01420         return $this->getConfig()->getConfigParam( 'bl_perfLoadReviews' );
01421     }
01422 
01428     public function getRatingCount()
01429     {
01430         if ( $this->_iRatingCnt === null ) {
01431             $this->_iRatingCnt = false;
01432             if ( $this->isReviewActive() && ( $oDetailsProduct = $this->getProduct() ) ) {
01433                 $this->_iRatingCnt = $oDetailsProduct->getArticleRatingCount( $this->getConfig()->getConfigParam( 'blShowVariantReviews' ) );
01434             }
01435         }
01436         return $this->_iRatingCnt;
01437     }
01438 
01444     public function getBreadCrumb()
01445     {
01446         $aPaths = array();
01447 
01448         if ( 'search' == $this->getListType() ) {
01449 
01450             $sSearchParam = $this->getSearchParamForHtml();
01451 
01452             $aCatPath = array();
01453             $aCatPath['title'] = sprintf( oxRegistry::getLang()->translateString( 'searchResult', oxRegistry::getLang()->getBaseLanguage(), false ), $sSearchParam );
01454             $aCatPath['link']  = $this->getViewConfig()->getSelfLink() . 'stoken=' . oxSession::getVar('sess_stoken') . "&amp;cl=search&amp;searchparam=" . $sSearchParam;
01455 
01456             $aPaths[] = $aCatPath;
01457 
01458         } elseif ( 'tag' == $this->getListType() ) {
01459 
01460             $aCatPath = array();
01461 
01462             $aCatPath['title'] = oxRegistry::getLang()->translateString( 'TAGS', oxRegistry::getLang()->getBaseLanguage(), false );
01463             $aCatPath['link']  = oxRegistry::get("oxSeoEncoder")->getStaticUrl( $this->getViewConfig()->getSelfLink() . 'cl=tags' );
01464             $aPaths[] = $aCatPath;
01465 
01466             $oStr = getStr();
01467             $aCatPath['title'] = $oStr->ucfirst(oxConfig::getParameter( 'searchtag' ));
01468             $aCatPath['link']  = oxRegistry::get("oxSeoEncoderTag")->getTagUrl( oxConfig::getParameter( 'searchtag' ) );
01469             $aPaths[] = $aCatPath;
01470 
01471         } elseif ( 'recommlist' == $this->getListType() ) {
01472 
01473             $aCatPath = array();
01474             $aCatPath['title'] = oxRegistry::getLang()->translateString( 'PAGE_RECOMMENDATIONS_PRODUCTS_TITLE', oxRegistry::getLang()->getBaseLanguage(), false );
01475             $aPaths[] = $aCatPath;
01476 
01477         } elseif ( 'vendor' == $this->getListType() ) {
01478 
01479             $aCatPath = array();
01480 
01481             $oCat = oxNew( 'oxVendor' );
01482             $oCat->load('root');
01483 
01484             $aCatPath['link'] = $oCat->getLink();
01485             $aCatPath['title'] = $oCat->oxvendor__oxtitle->value;
01486             $aPaths[] = $aCatPath;
01487 
01488             $oCat = $this->getActVendor();
01489             $aCatPath['link'] = $oCat->getLink();
01490             $aCatPath['title'] = $oCat->oxvendor__oxtitle->value;
01491             $aPaths[] = $aCatPath;
01492 
01493         } else {
01494 
01495             $oCatTree = $this->getCatTreePath();
01496 
01497             if ( $oCatTree ) {
01498 
01499                 foreach ( $oCatTree as $oCat ) {
01500                     $aCatPath = array();
01501 
01502                     $aCatPath['link'] = $oCat->getLink();
01503                     $aCatPath['title'] = $oCat->oxcategories__oxtitle->value;
01504 
01505                     $aPaths[] = $aCatPath;
01506                 }
01507             }
01508         }
01509 
01510         return $aPaths;
01511     }
01512 
01522     public function addme()
01523     {
01524         $myConfig = $this->getConfig();
01525         $myUtils  = oxRegistry::getUtils();
01526 
01527         //control captcha
01528         $sMac     = oxConfig::getParameter( 'c_mac' );
01529         $sMacHash = oxConfig::getParameter( 'c_mach' );
01530         $oCaptcha = $this->getCaptcha();
01531         if ( !$oCaptcha->pass( $sMac, $sMacHash ) ) {
01532             $this->_iPriceAlarmStatus = 2;
01533             return;
01534         }
01535 
01536         $aParams = oxConfig::getParameter( 'pa' );
01537         if ( !isset( $aParams['email'] ) || !$myUtils->isValidEmail( $aParams['email'] ) ) {
01538             $this->_iPriceAlarmStatus = 0;
01539             return;
01540         }
01541         $aParams['aid'] = $this->getProduct()->getId();
01542         $oCur = $myConfig->getActShopCurrencyObject();
01543         // convert currency to default
01544         $dPrice = $myUtils->currency2Float( $aParams['price'] );
01545 
01546         $oAlarm = oxNew( "oxpricealarm" );
01547         $oAlarm->oxpricealarm__oxuserid = new oxField( oxSession::getVar( 'usr' ));
01548         $oAlarm->oxpricealarm__oxemail  = new oxField( $aParams['email']);
01549         $oAlarm->oxpricealarm__oxartid  = new oxField( $aParams['aid']);
01550         $oAlarm->oxpricealarm__oxprice  = new oxField( $myUtils->fRound( $dPrice, $oCur ));
01551         $oAlarm->oxpricealarm__oxshopid = new oxField( $myConfig->getShopId());
01552         $oAlarm->oxpricealarm__oxcurrency = new oxField( $oCur->name);
01553 
01554         $oAlarm->oxpricealarm__oxlang = new oxField(oxRegistry::getLang()->getBaseLanguage());
01555 
01556         $oAlarm->save();
01557 
01558         // Send Email
01559         $oEmail = oxNew( 'oxemail' );
01560         $this->_iPriceAlarmStatus = (int) $oEmail->sendPricealarmNotification( $aParams, $oAlarm );
01561     }
01562 
01568     public function getPriceAlarmStatus()
01569     {
01570         return $this->_iPriceAlarmStatus;
01571     }
01572 
01578     public function getBidPrice()
01579     {
01580         if ( $this->_sBidPrice === null ) {
01581             $this->_sBidPrice = false;
01582 
01583             $aParams = oxConfig::getParameter( 'pa' );
01584             $oCur = $this->getConfig()->getActShopCurrencyObject();
01585             $iPrice = oxRegistry::getUtils()->currency2Float( $aParams['price'] );
01586             $this->_sBidPrice = oxRegistry::getLang()->formatCurrency( $iPrice, $oCur );
01587         }
01588         return $this->_sBidPrice;
01589     }
01590 
01596     public function getVariantSelections()
01597     {
01598         // finding parent
01599         $oProduct = $this->getProduct();
01600         if ( ( $oParent = $this->_getParentProduct( $oProduct->oxarticles__oxparentid->value ) ) ) {
01601             return $oParent->getVariantSelections( oxConfig::getParameter( "varselid" ), $oProduct->getId() );
01602         }
01603 
01604         return $oProduct->getVariantSelections( oxConfig::getParameter( "varselid" ) );
01605     }
01606 
01612     public function getPicturesProduct()
01613     {
01614         $aVariantSelections = $this->getVariantSelections();
01615         if ($aVariantSelections && $aVariantSelections['oActiveVariant'] && !$aVariantSelections['blPerfectFit']) {
01616             return $aVariantSelections['oActiveVariant'];
01617         }
01618         return $this->getProduct();
01619     }
01620 
01626     public function getSearchParamForHtml()
01627     {
01628         if ( $this->_sSearchParamForHtml === null ) {
01629             $this->_sSearchParamForHtml = oxConfig::getParameter( 'searchparam' );
01630         }
01631         return $this->_sSearchParamForHtml;
01632     }
01633 
01639     public function showRdfa()
01640     {
01641         return $this->getConfig()->getConfigParam( 'blRDFaEmbedding' );
01642     }
01643 
01649     public function getRDFaNormalizedRating()
01650     {
01651         $myConfig = $this->getConfig();
01652         $iMin = $myConfig->getConfigParam("iRDFaMinRating");
01653         $iMax = $myConfig->getConfigParam("iRDFaMaxRating");
01654 
01655         $oProduct = $this->getProduct();
01656         $iCount = $oProduct->oxarticles__oxratingcnt->value;
01657         if ( isset($iMin) && isset($iMax) && $iMax != '' && $iMin != '' && $iCount > 0 ) {
01658             $aNomalizedRating = array();
01659             $iValue = ((4*($oProduct->oxarticles__oxrating->value - $iMin)/($iMax - $iMin)))+1;
01660             $aNomalizedRating["count"] = $iCount;
01661             $aNomalizedRating["value"] = round($iValue, 2);
01662             return $aNomalizedRating;
01663         }
01664         return false;
01665     }
01666 
01674     public function getRDFaValidityPeriod($sShopConfVar)
01675     {
01676         if ( $sShopConfVar ) {
01677             $aValidity = array();
01678             $iDays = $this->getConfig()->getConfigParam($sShopConfVar);
01679             $iFrom = oxRegistry::get("oxUtilsDate")->getTime();
01680 
01681             $iThrough = $iFrom + ($iDays * 24 * 60 * 60);
01682             $aValidity["from"] = date('Y-m-d\TH:i:s', $iFrom)."Z";
01683             $aValidity["through"] = date('Y-m-d\TH:i:s', $iThrough)."Z";
01684 
01685             return $aValidity;
01686         }
01687         return false;
01688     }
01689 
01695     public function getRDFaBusinessFnc()
01696     {
01697         return $this->getConfig()->getConfigParam("sRDFaBusinessFnc");
01698     }
01699 
01705     public function getRDFaCustomers()
01706     {
01707         return $this->getConfig()->getConfigParam("aRDFaCustomers");
01708     }
01709 
01715     public function getRDFaVAT()
01716     {
01717         return $this->getConfig()->getConfigParam("iRDFaVAT");
01718     }
01719 
01725     public function getRDFaGenericCondition()
01726     {
01727         return $this->getConfig()->getConfigParam("iRDFaCondition");
01728     }
01729 
01735     public function getBundleArticle()
01736     {
01737         $oProduct = $this->getProduct();
01738         if ( $oProduct && $oProduct->oxarticles__oxbundleid->value ) {
01739             $oArticle = oxNew("oxarticle");
01740             $oArticle->load($oProduct->oxarticles__oxbundleid->value);
01741             return $oArticle;
01742         }
01743         return false;
01744     }
01745 
01751     public function getRDFaPaymentMethods()
01752     {
01753         $iPrice = $this->getProduct()->getPrice()->getBruttoPrice();
01754         $oPayments = oxNew("oxpaymentlist");
01755         $oPayments->loadRDFaPaymentList($iPrice);
01756         return $oPayments;
01757     }
01758 
01764     public function getRDFaDeliverySetMethods()
01765     {
01766         $oDelSets = oxNew("oxdeliverysetlist");
01767         $oDelSets->loadRDFaDeliverySetList();
01768         return $oDelSets;
01769     }
01770 
01776     public function getProductsDeliveryList()
01777     {
01778         $oProduct = $this->getProduct();
01779         $oDelList = oxNew( "oxDeliveryList" );
01780         $oDelList->loadDeliveryListForProduct( $oProduct );
01781         return $oDelList;
01782     }
01783 
01789     public function getRDFaDeliveryChargeSpecLoc()
01790     {
01791         return $this->getConfig()->getConfigParam("sRDFaDeliveryChargeSpecLoc");
01792     }
01793 
01799     public function getRDFaPaymentChargeSpecLoc()
01800     {
01801         return $this->getConfig()->getConfigParam("sRDFaPaymentChargeSpecLoc");
01802     }
01803 
01809     public function getRDFaBusinessEntityLoc()
01810     {
01811         return $this->getConfig()->getConfigParam("sRDFaBusinessEntityLoc");
01812     }
01813 
01819     public function showRDFaProductStock()
01820     {
01821         return $this->getConfig()->getConfigParam("blShowRDFaProductStock");
01822     }
01823 
01829     public function getDefaultSorting()
01830     {
01831         $aSorting = parent::getDefaultSorting();
01832         $oCategory = $this->getActiveCategory();
01833 
01834         if ( $this->getListType() != 'search' &&  $oCategory && $oCategory instanceof oxCategory ) {
01835             if ( $sDefaultSorting = $oCategory->getDefaultSorting() ) {
01836                 $sArticleTable = getViewName( 'oxarticles' );
01837                 $sSortBy  = $sArticleTable.'.'.$sDefaultSorting;
01838                 $sSortDir = ( $oCategory->getDefaultSortingMode() ) ? "desc" : "asc";
01839                 $aSorting = array ( 'sortby' => $sSortBy, 'sortdir' => $sSortDir );
01840             }
01841         }
01842 
01843         return $aSorting;
01844     }
01845 }