details.php

Go to the documentation of this file.
00001 <?php
00002 
00009 class Details extends oxUBase
00010 {
00016     protected $_sThisTemplate = 'page/details/details.tpl';
00017 
00023     protected $_oParentProd = null;
00024 
00029     protected $_blEditTags = null;
00030 
00035     protected $_aTags = null;
00036 
00041     protected $_oCaptcha = null;
00042 
00047     protected $_sParentName = null;
00048 
00053     protected $_sParentUrl = null;
00054 
00059     protected $_aPicGallery = null;
00060 
00065     protected $_aSelectLists = null;
00066 
00071     protected $_aReviews = null;
00072 
00077     protected $_oCrossSelling = null;
00078 
00083     protected $_oSimilarProducts = null;
00084 
00089     protected $_oAccessoires = null;
00090 
00095     protected $_aAlsoBoughtArts = null;
00096 
00101     protected $_sSearchTitle = null;
00102 
00108     protected $_blIsInitialized = false;
00109 
00115     protected $_iLinkType = null;
00116 
00121     protected $_sBidPrice = null;
00122 
00127     protected $_iPriceAlarmStatus = null;
00128 
00133     protected $_sSearchParamForHtml = null;
00134 
00140     protected $_aSimilarRecommListIds = null;
00141 
00142 
00147     protected $_blShowSorting = true;
00148 
00156     protected function _getParentProduct( $sParentId )
00157     {
00158         if ( $sParentId && $this->_oParentProd === null ) {
00159             $this->_oParentProd = false;
00160             $oProduct = oxNew( 'oxArticle' );
00161             if ( ( $oProduct->load( $sParentId ) ) ) {
00162                 $this->_processProduct( $oProduct );
00163                 $this->_oParentProd = $oProduct;
00164             }
00165         }
00166         return $this->_oParentProd;
00167     }
00168 
00174     protected function _getAddUrlParams()
00175     {
00176         if ( $this->getListType() == "search" ) {
00177             return $this->getDynUrlParams();
00178         }
00179     }
00180 
00189     public function getNavigationParams()
00190     {
00191         $aParams = parent::getNavigationParams();
00192 
00193         $aVarSelParams = oxRegistry::getConfig()->getRequestParameter( 'varselid' );
00194         $aSelectListParams = oxRegistry::getConfig()->getRequestParameter( 'sel' );
00195         if ( !$aVarSelParams && !$aSelectListParams ) {
00196             return $aParams;
00197         }
00198 
00199         if ( $aVarSelParams ) {
00200             foreach ( $aVarSelParams as $iKey => $sValue ) {
00201                 $aParams["varselid[$iKey]"] = $sValue;
00202             }
00203         }
00204 
00205         if ( $aSelectListParams ) {
00206             foreach ( $aSelectListParams as $iKey => $sValue ) {
00207                 $aParams["sel[$iKey]"] = $sValue;
00208             }
00209         }
00210         return $aParams;
00211     }
00212 
00213 
00221     protected function _processProduct( $oProduct )
00222     {
00223         $oProduct->setLinkType( $this->getLinkType() );
00224         if ( $sAddParams = $this->_getAddUrlParams() ) {
00225             $oProduct->appendLink( $sAddParams );
00226         }
00227     }
00228 
00234     public function getViewId()
00235     {
00236         if ( isset( $this->_sViewId )) {
00237             return $this->_sViewId;
00238         }
00239 
00240             $sViewId = parent::getViewId().'|'.$this->getConfig()->getRequestParameter( 'anid' ).'|';
00241 
00242 
00243         return $this->_sViewId = $sViewId;
00244     }
00245 
00246 
00258     public function render()
00259     {
00260         $myConfig = $this->getConfig();
00261 
00262         $oProduct = $this->getProduct();
00263 
00264         // assign template name
00265         if ( $oProduct->oxarticles__oxtemplate->value ) {
00266             $this->_sThisTemplate = $oProduct->oxarticles__oxtemplate->value;
00267         }
00268 
00269         if ( ( $sTplName = oxConfig::getParameter( 'tpl' ) ) ) {
00270             $this->_sThisTemplate = 'custom/'.basename ( $sTplName );
00271         }
00272 
00273         parent::render();
00274 
00275         $sPartial = $this->getConfig()->getRequestParameter( 'renderPartial' );
00276         $this->addTplParam('renderPartial', $sPartial);
00277 
00278         switch ($sPartial) {
00279             case "productInfo":
00280                 return 'page/details/ajax/fullproductinfo.tpl';
00281                 break;
00282             case "detailsMain":
00283                 return 'page/details/ajax/productmain.tpl';
00284                 break;
00285             default:
00286                 // can not be removed, as it is used for breadcrumb loading
00287                 $oLocator = oxNew( 'oxLocator', $this->getListType() );
00288                 $oLocator->setLocatorData( $oProduct, $this );
00289 
00290                 if ($myConfig->getConfigParam( 'bl_rssRecommLists' ) && $this->getSimilarRecommListIds()) {
00291                     $oRss = oxNew('oxRssFeed');
00292                     $this->addRssFeed($oRss->getRecommListsTitle( $oProduct ), $oRss->getRecommListsUrl( $oProduct ), 'recommlists');
00293                 }
00294 
00295                 return $this->_sThisTemplate;
00296         }
00297     }
00298 
00310     protected function _prepareMetaDescription( $sMeta, $iLength = 200, $blDescTag = false )
00311     {
00312         if ( !$sMeta ) {
00313             $oProduct = $this->getProduct();
00314 
00315             if ( $this->getConfig()->getConfigParam( 'bl_perfParseLongDescinSmarty' ) ) {
00316                 $sMeta = $oProduct->getLongDesc();
00317             } else {
00318                 $sMeta = $oProduct->getLongDescription()->value;
00319             }
00320             if ( $sMeta == '' ) {
00321                 $sMeta = $oProduct->oxarticles__oxshortdesc->value;
00322             }
00323             $sMeta = $oProduct->oxarticles__oxtitle->value.' - '.$sMeta;
00324         }
00325         return parent::_prepareMetaDescription( $sMeta, $iLength, $blDescTag );
00326     }
00327 
00338     protected function _prepareMetaKeyword( $sKeywords, $blRemoveDuplicatedWords = true )
00339     {
00340         if ( !$sKeywords ) {
00341             $oProduct = $this->getProduct();
00342             $sKeywords = trim( $this->getTitle() );
00343 
00344             if ( $oCatTree = $this->getCategoryTree() ) {
00345                 foreach ( $oCatTree->getPath() as $oCat ) {
00346                     $sKeywords .= ", " . trim( $oCat->oxcategories__oxtitle->value );
00347                 }
00348             }
00349 
00350             //adding search keys info
00351             if ( $sSearchKeys = trim( $oProduct->oxarticles__oxsearchkeys->value ) ) {
00352                 $sKeywords .= ", ". $sSearchKeys;
00353             }
00354 
00355             $sKeywords = parent::_prepareMetaKeyword( $sKeywords, $blRemoveDuplicatedWords );
00356         }
00357 
00358         return $sKeywords;
00359     }
00360 
00366     public function saveReview()
00367     {
00368         if ( $this->canAcceptFormData() &&
00369              ( $oUser = $this->getUser() ) && ( $oProduct = $this->getProduct() ) ) {
00370 
00371             $dRating = $this->getConfig()->getRequestParameter( 'artrating' );
00372             if ( $dRating !== null ) {
00373                 $dRating = (int) $dRating;
00374             }
00375 
00376             //save rating
00377             if ( $dRating !== null && $dRating >= 1 && $dRating <= 5 ) {
00378                 $oRating = oxNew( 'oxrating' );
00379                 if ( $oRating->allowRating( $oUser->getId(), 'oxarticle', $oProduct->getId() ) ) {
00380                     $oRating->oxratings__oxuserid   = new oxField( $oUser->getId() );
00381                     $oRating->oxratings__oxtype     = new oxField( 'oxarticle' );
00382                     $oRating->oxratings__oxobjectid = new oxField( $oProduct->getId() );
00383                     $oRating->oxratings__oxrating   = new oxField( $dRating );
00384                     $oRating->save();
00385                     $oProduct->addToRatingAverage( $dRating );
00386                 }
00387             }
00388 
00389             if ( ( $sReviewText = trim( ( string ) $this->getConfig()->getRequestParameter( 'rvw_txt', true ) ) ) ) {
00390                 $oReview = oxNew( 'oxReview' );
00391                 $oReview->oxreviews__oxobjectid = new oxField( $oProduct->getId() );
00392                 $oReview->oxreviews__oxtype     = new oxField( 'oxarticle' );
00393                 $oReview->oxreviews__oxtext     = new oxField( $sReviewText, oxField::T_RAW );
00394                 $oReview->oxreviews__oxlang     = new oxField( oxRegistry::getLang()->getBaseLanguage() );
00395                 $oReview->oxreviews__oxuserid   = new oxField( $oUser->getId() );
00396                 $oReview->oxreviews__oxrating   = new oxField( ( $dRating !== null ) ? $dRating : 0);
00397                 $oReview->save();
00398             }
00399         }
00400     }
00401 
00407     public function addToRecomm()
00408     {
00409         if (!$this->getViewConfig()->getShowListmania()) {
00410             return;
00411         }
00412 
00413         $sRecommText = trim( ( string ) $this->getConfig()->getRequestParameter( 'recomm_txt' ) );
00414         $sRecommList = $this->getConfig()->getRequestParameter( 'recomm' );
00415         $sArtId      = $this->getProduct()->getId();
00416 
00417         if ( $sArtId ) {
00418             $oRecomm = oxNew( 'oxrecommlist' );
00419             $oRecomm->load( $sRecommList);
00420             $oRecomm->addArticle( $sArtId, $sRecommText );
00421         }
00422     }
00423 
00429     public function addTags()
00430     {
00431         $sTags  = $this->getConfig()->getRequestParameter('newTags', true );
00432         $sHighTag  = $this->getConfig()->getRequestParameter( 'highTags', true );
00433         if ( !$sTags && !$sHighTag) {
00434             return;
00435         }
00436         if ( $sHighTag ) {
00437             $sTags = getStr()->html_entity_decode( $sHighTag );
00438         }
00439         $oProduct = $this->getProduct();
00440 
00441         // set current user added tags for this article for later checking
00442         $aTaggedProducts = oxRegistry::getSession()->getVariable("aTaggedProducts");
00443         $aAddedTags = $aTaggedProducts? $aTaggedProducts[$oProduct->getId()] : array();
00444 
00445         $oArticleTagList = oxNew( "oxArticleTagList" );
00446         $oArticleTagList->load( $oProduct->getId() );
00447         $sSeparator = $oArticleTagList->get()->getSeparator();
00448         $aTags = array_unique( explode( $sSeparator, $sTags ) );
00449 
00450         $aResult = $this->_addTagsToList( $oArticleTagList, $aTags, $aAddedTags);
00451 
00452         if ( !empty( $aResult['tags'] ) ) {
00453             $oArticleTagList->save();
00454             foreach ( $aResult['tags'] as $sTag) {
00455                 $aAddedTags[ $sTag ] = 1;
00456             }
00457             $aTaggedProducts[$oProduct->getId()] = $aAddedTags;
00458             oxRegistry::getSession()->setVariable( 'aTaggedProducts', $aTaggedProducts);
00459         }
00460         // for ajax call
00461         if ( $this->getConfig()->getRequestParameter( 'blAjax', true ) ) {
00462             oxRegistry::getUtils()->showMessageAndExit( json_encode( $aResult ) );
00463         }
00464     }
00465 
00475     protected function _addTagsToList( $oArticleTagList, $aTags, $aAddedTags)
00476     {
00477         $aResult = array( 'tags' => array(), 'invalid' => array(), 'inlist' => array() );
00478 
00479         foreach ( $aTags as $sTag ) {
00480             $oTag = oxNew( "oxtag", $sTag );
00481             if ( $aAddedTags[$oTag->get()] != 1 ) {
00482                 if ( $oTag->isValid() ) {
00483                     $oArticleTagList->addTag( $oTag );
00484                     $aResult['tags'][] = $oTag->get();
00485                 } else {
00486                     $aResult['invalid'][] = $oTag->get();
00487                 }
00488             } else {
00489                 $aResult['inlist'][] = $oTag->get();
00490             }
00491         }
00492 
00493         return $aResult;
00494     }
00495 
00501     public function editTags()
00502     {
00503         if ( !$this->getUser() ) {
00504             return;
00505         }
00506         $oArticleTagList = oxNew("oxArticleTagList");
00507         $oArticleTagList->load( $this->getProduct()->getId() );
00508         $oTagSet = $oArticleTagList->get();
00509         $this->_aTags = $oTagSet->get();
00510         $this->_blEditTags = true;
00511 
00512         // for ajax call
00513         if ( $this->getConfig()->getRequestParameter( 'blAjax', true ) ) {
00514             oxRegistry::getUtils()->setHeader( "Content-Type: text/html; charset=".oxRegistry::getLang()->translateString( 'charset' ) );
00515             $oActView = oxNew( 'oxubase' );
00516             $oSmarty = oxRegistry::get("oxUtilsView")->getSmarty();
00517             $oSmarty->assign('oView', $this );
00518             $oSmarty->assign('oViewConf', $this->getViewConfig() );
00519             oxRegistry::getUtils()->showMessageAndExit( $oSmarty->fetch( 'page/details/inc/editTags.tpl', $this->getViewId() ) );
00520         }
00521     }
00522 
00528     public function cancelTags()
00529     {
00530         $oArticleTagList = oxNew("oxArticleTagList");
00531         $oArticleTagList->load( $this->getProduct()->getId() );
00532         $oTagSet = $oArticleTagList->get();
00533         $this->_aTags = $oTagSet->get();
00534         $this->_blEditTags = false;
00535 
00536         // for ajax call
00537         if ( oxConfig::getParameter( 'blAjax', true ) ) {
00538             oxRegistry::getUtils()->setHeader( "Content-Type: text/html; charset=".oxRegistry::getLang()->translateString( 'charset' ) );
00539             $oActView = oxNew( 'oxubase' );
00540             $oSmarty = oxRegistry::get("oxUtilsView")->getSmarty();
00541             $oSmarty->assign('oView', $this );
00542             $oSmarty->assign('oViewConf', $this->getViewConfig() );
00543             oxRegistry::getUtils()->showMessageAndExit( $oSmarty->fetch( 'page/details/inc/tags.tpl', $this->getViewId() ) );
00544         }
00545     }
00546 
00552     protected function _getSeoObjectId()
00553     {
00554         if ( $oProduct = $this->getProduct() ) {
00555             return $oProduct->getId();
00556         }
00557     }
00558 
00564     public function getEditTags()
00565     {
00566         return $this->_blEditTags;
00567     }
00568 
00574     public function getTags()
00575     {
00576         return $this->_aTags;
00577     }
00578 
00584     public function getProduct()
00585     {
00586         $myConfig = $this->getConfig();
00587         $myUtils = oxRegistry::getUtils();
00588 
00589         if ( $this->_oProduct === null ) {
00590 
00591             //this option is only for lists and we must reset value
00592             //as blLoadVariants = false affect "ab price" functionality
00593             $myConfig->setConfigParam( 'blLoadVariants', true );
00594 
00595             $sOxid = $this->getConfig()->getRequestParameter( 'anid' );
00596 
00597             // object is not yet loaded
00598             $this->_oProduct = oxNew( 'oxarticle' );
00599 
00600             if ( !$this->_oProduct->load( $sOxid ) ) {
00601                 $myUtils->redirect( $myConfig->getShopHomeURL() );
00602                 $myUtils->showMessageAndExit( '' );
00603             }
00604 
00605             $aVariantSelections = $this->_oProduct->getVariantSelections( $this->getConfig()->getRequestParameter( "varselid" ) );
00606             if ($aVariantSelections && $aVariantSelections['oActiveVariant'] && $aVariantSelections['blPerfectFit']) {
00607                 $this->_oProduct = $aVariantSelections['oActiveVariant'];
00608             }
00609         }
00610 
00611         // additional checks
00612         if ( !$this->_blIsInitialized ) {
00613 
00614             $blContinue = true;
00615             if ( !$this->_oProduct->isVisible() ) {
00616                 $blContinue = false;
00617             } elseif ( $this->_oProduct->oxarticles__oxparentid->value ) {
00618                 $oParent = $this->_getParentProduct( $this->_oProduct->oxarticles__oxparentid->value );
00619                 if ( !$oParent || !$oParent->isVisible() ) {
00620                     $blContinue = false;
00621                 }
00622             }
00623 
00624             if ( !$blContinue ) {
00625                 $myUtils->redirect( $myConfig->getShopHomeURL() );
00626                 $myUtils->showMessageAndExit( '' );
00627             }
00628 
00629             $this->_processProduct( $this->_oProduct );
00630             $this->_blIsInitialized = true;
00631         }
00632 
00633         return $this->_oProduct;
00634     }
00635 
00641     public function getLinkType()
00642     {
00643         if ( $this->_iLinkType === null ) {
00644             $sListType = $this->getConfig()->getRequestParameter( 'listtype' );
00645             if ( 'vendor' == $sListType ) {
00646                 $this->_iLinkType = OXARTICLE_LINKTYPE_VENDOR;
00647             } elseif ( 'manufacturer' == $sListType ) {
00648                     $this->_iLinkType = OXARTICLE_LINKTYPE_MANUFACTURER;
00649             } elseif ( 'tag' == $sListType ) {
00650                     $this->_iLinkType = OXARTICLE_LINKTYPE_TAG;
00651             } elseif ( 'recommlist' == $sListType ) {
00652                     $this->_iLinkType = OXARTICLE_LINKTYPE_RECOMM;
00653             } else {
00654                 $this->_iLinkType = OXARTICLE_LINKTYPE_CATEGORY;
00655 
00656                 // price category has own type..
00657                 if ( ( $oCat = $this->getActiveCategory() ) && $oCat->isPriceCategory() ) {
00658                     $this->_iLinkType = OXARTICLE_LINKTYPE_PRICECATEGORY;
00659                 }
00660             }
00661         }
00662 
00663         return $this->_iLinkType;
00664     }
00665 
00671     public function drawParentUrl()
00672     {
00673         return $this->getProduct()->isVariant();
00674     }
00675 
00683     public function getParentName()
00684     {
00685         if ( $this->_sParentName === null ) {
00686             $this->_sParentName = false;
00687             if ( ( $oParent = $this->_getParentProduct( $this->getProduct()->oxarticles__oxparentid->value ) ) ) {
00688                 $this->_sParentName = $oParent->oxarticles__oxtitle->value;
00689             }
00690         }
00691         return $this->_sParentName;
00692     }
00693 
00701     public function getParentUrl()
00702     {
00703         if ( $this->_sParentUrl === null ) {
00704             $this->_sParentUrl = false;
00705             if ( ( $oParent = $this->_getParentProduct( $this->getProduct()->oxarticles__oxparentid->value ) ) ) {
00706                 $this->_sParentUrl = $oParent->getLink();
00707             }
00708         }
00709         return $this->_sParentUrl;
00710     }
00711 
00717     public function getPictureGallery()
00718     {
00719         if ( $this->_aPicGallery === null ) {
00720             //get picture gallery
00721             $this->_aPicGallery = $this->getPicturesProduct()->getPictureGallery();
00722         }
00723         return $this->_aPicGallery;
00724     }
00725 
00731     public function getActPictureId()
00732     {
00733         $aPicGallery = $this->getPictureGallery();
00734         return $aPicGallery['ActPicID'];
00735     }
00736 
00742     public function getActPicture()
00743     {
00744         $aPicGallery = $this->getPictureGallery();
00745         return $aPicGallery['ActPic'];
00746     }
00747 
00753     public function getPictures()
00754     {
00755         $aPicGallery = $this->getPictureGallery();
00756         return $aPicGallery['Pics'];
00757     }
00758 
00766     public function getArtPic( $sPicNr )
00767     {
00768         $aPicGallery = $this->getPictureGallery();
00769         return $aPicGallery['Pics'][$sPicNr];
00770     }
00771 
00777     public function getSelectLists()
00778     {
00779         if ( $this->_aSelectLists === null ) {
00780             $this->_aSelectLists = false;
00781             if ( $this->getConfig()->getConfigParam( 'bl_perfLoadSelectLists' ) ) {
00782                 $this->_aSelectLists = $this->getProduct()->getSelectLists();
00783             }
00784         }
00785         return $this->_aSelectLists;
00786     }
00787 
00793     public function getReviews()
00794     {
00795         if ( $this->_aReviews === null ) {
00796             $this->_aReviews = false;
00797             if ( $this->getConfig()->getConfigParam( 'bl_perfLoadReviews' ) ) {
00798                 $this->_aReviews = $this->getProduct()->getReviews();
00799             }
00800         }
00801         return $this->_aReviews;
00802     }
00803 
00809     public function getCrossSelling()
00810     {
00811         if ( $this->_oCrossSelling === null ) {
00812             $this->_oCrossSelling = false;
00813             if ( $oProduct = $this->getProduct() ) {
00814                 $this->_oCrossSelling = $oProduct->getCrossSelling();
00815             }
00816         }
00817         return $this->_oCrossSelling;
00818     }
00819 
00825     public function getSimilarProducts()
00826     {
00827         if ( $this->_oSimilarProducts === null ) {
00828             $this->_oSimilarProducts = false;
00829             if ( $oProduct = $this->getProduct() ) {
00830                 $this->_oSimilarProducts = $oProduct->getSimilarProducts();
00831             }
00832         }
00833         return $this->_oSimilarProducts;
00834     }
00835 
00841     public function getSimilarRecommListIds()
00842     {
00843         if ( $this->_aSimilarRecommListIds === null ) {
00844             $this->_aSimilarRecommListIds = false;
00845 
00846             if ( $oProduct = $this->getProduct() ) {
00847                 $this->_aSimilarRecommListIds = array( $oProduct->getId() );
00848             }
00849         }
00850         return $this->_aSimilarRecommListIds;
00851     }
00852 
00858     public function getAccessoires()
00859     {
00860         if ( $this->_oAccessoires === null ) {
00861             $this->_oAccessoires = false;
00862             if ( $oProduct = $this->getProduct() ) {
00863                 $this->_oAccessoires = $oProduct->getAccessoires();
00864             }
00865         }
00866         return $this->_oAccessoires;
00867     }
00868 
00874     public function getAlsoBoughtTheseProducts()
00875     {
00876         if ( $this->_aAlsoBoughtArts === null ) {
00877             $this->_aAlsoBoughtArts = false;
00878             if ( $oProduct = $this->getProduct() ) {
00879                 $this->_aAlsoBoughtArts = $oProduct->getCustomerAlsoBoughtThisProducts();
00880             }
00881         }
00882         return $this->_aAlsoBoughtArts;
00883     }
00884 
00890     public function isPriceAlarm()
00891     {
00892         // #419 disabling price alarm if article has fixed price
00893         $oProduct = $this->getProduct();
00894         if ( isset( $oProduct->oxarticles__oxblfixedprice->value ) && $oProduct->oxarticles__oxblfixedprice->value ) {
00895             return 0;
00896         }
00897         return 1;
00898     }
00899 
00908     protected function _getSubject( $iLang )
00909     {
00910         return $this->getProduct();
00911     }
00912 
00918     public function getSearchTitle()
00919     {
00920         return $this->_sSearchTitle;
00921     }
00922 
00930     public function setSearchTitle( $sTitle )
00931     {
00932         $this->_sSearchTitle = $sTitle;
00933     }
00934 
00942     public function setCatTreePath( $sActCatPath )
00943     {
00944         $this->_sCatTreePath = $sActCatPath;
00945     }
00946 
00953     public function noIndex()
00954     {
00955         $sListType = $this->getConfig()->getRequestParameter( 'listtype' );
00956         if ( $sListType && ( 'vendor' == $sListType || 'manufacturer' == $sListType ) ) {
00957             return $this->_iViewIndexState = VIEW_INDEXSTATE_NOINDEXFOLLOW;
00958         }
00959         return parent::noIndex();
00960     }
00961 
00967     public function getTitle()
00968     {
00969         if ( $oProduct = $this->getProduct() ) {
00970             $sTag = $this->getTag();
00971             return $oProduct->oxarticles__oxtitle->value . ( $oProduct->oxarticles__oxvarselect->value ? ' ' . $oProduct->oxarticles__oxvarselect->value : '' ) . (!empty($sTag) ? ' - '.$sTag : '');
00972         }
00973     }
00974     
00980     public function getMetaDescription()
00981     {
00982         $sMeta = parent::getMetaDescription();
00983 
00984         if($sTag = $this->getTag()) {
00985             $sMeta = $sTag.' - ' . $sMeta;
00986         }
00987 
00988         return $sMeta;
00989     }
00990 
00996     public function getTag()
00997     {
00998         return oxConfig::getParameter("searchtag");
00999     }
01000 
01006     public function getCanonicalUrl()
01007     {
01008         if ( ( $oProduct = $this->getProduct() ) ) {
01009             if ( $oProduct->oxarticles__oxparentid->value ) {
01010                 $oProduct = $this->_getParentProduct( $oProduct->oxarticles__oxparentid->value );
01011             }
01012 
01013             $oUtils = oxRegistry::get("oxUtilsUrl");
01014             if ( oxRegistry::getUtils()->seoIsActive() ) {
01015                 $sUrl = $oUtils->prepareCanonicalUrl( $oProduct->getBaseSeoLink( $oProduct->getLanguage(), true ) );
01016             } else {
01017                 $sUrl = $oUtils->prepareCanonicalUrl( $oProduct->getBaseStdLink( $oProduct->getLanguage() ) );
01018             }
01019             return $sUrl;
01020         }
01021     }
01022 
01028     public function getBreadCrumb()
01029     {
01030         if ( 'search' == $this->getListType() ) {
01031             $aPaths = $this->_getSearchBreadCrumb();
01032         } elseif ( 'tag' == $this->getListType() ) {
01033             $aPaths = $this->_getTagBreadCrumb();
01034         } elseif ( 'recommlist' == $this->getListType() ) {
01035             $aPaths = $this->_getRecommendationListBredCrumb();
01036         } elseif ( 'vendor' == $this->getListType() ) {
01037             $aPaths = $this->_getVendorBreadCrumb();
01038         } else {
01039             $aPaths = $this->_getCategoryBreadCrumb();
01040         }
01041         return $aPaths;
01042     }
01043 
01049     public function getCaptcha()
01050     {
01051         if ( $this->_oCaptcha === null ) {
01052             $this->_oCaptcha = oxNew('oxCaptcha');
01053         }
01054         return $this->_oCaptcha;
01055     }
01056 
01066     public function addme()
01067     {
01068         $myConfig = $this->getConfig();
01069         $myUtils  = oxRegistry::getUtils();
01070 
01071         //control captcha
01072         $sMac     = $this->getConfig()->getRequestParameter( 'c_mac' );
01073         $sMacHash = $this->getConfig()->getRequestParameter( 'c_mach' );
01074         $oCaptcha = $this->getCaptcha();
01075         if ( !$oCaptcha->pass( $sMac, $sMacHash ) ) {
01076             $this->_iPriceAlarmStatus = 2;
01077             return;
01078         }
01079 
01080         $aParams = $this->getConfig()->getRequestParameter( 'pa' );
01081         if ( !isset( $aParams['email'] ) || !$myUtils->isValidEmail( $aParams['email'] ) ) {
01082             $this->_iPriceAlarmStatus = 0;
01083             return;
01084         }
01085         $aParams['aid'] = $this->getProduct()->getId();
01086         $oCur = $myConfig->getActShopCurrencyObject();
01087         // convert currency to default
01088         $dPrice = $myUtils->currency2Float( $aParams['price'] );
01089 
01090         $oAlarm = oxNew( "oxPriceAlarm" );
01091         $oAlarm->oxpricealarm__oxuserid = new oxField( oxSession::getVar( 'usr' ));
01092         $oAlarm->oxpricealarm__oxemail  = new oxField( $aParams['email']);
01093         $oAlarm->oxpricealarm__oxartid  = new oxField( $aParams['aid']);
01094         $oAlarm->oxpricealarm__oxprice  = new oxField( $myUtils->fRound( $dPrice, $oCur ));
01095         $oAlarm->oxpricealarm__oxshopid = new oxField( $myConfig->getShopId());
01096         $oAlarm->oxpricealarm__oxcurrency = new oxField( $oCur->name);
01097 
01098         $oAlarm->oxpricealarm__oxlang = new oxField(oxRegistry::getLang()->getBaseLanguage());
01099 
01100         $oAlarm->save();
01101 
01102         // Send Email
01103         $oEmail = oxNew( 'oxEmail' );
01104         $this->_iPriceAlarmStatus = (int) $oEmail->sendPricealarmNotification( $aParams, $oAlarm );
01105     }
01106 
01112     public function getPriceAlarmStatus()
01113     {
01114         return $this->_iPriceAlarmStatus;
01115     }
01116 
01122     public function getBidPrice()
01123     {
01124         if ( $this->_sBidPrice === null ) {
01125             $this->_sBidPrice = false;
01126 
01127             $aParams = $this->getConfig()->getRequestParameter( 'pa' );
01128             $oCur = $this->getConfig()->getActShopCurrencyObject();
01129             $iPrice = oxRegistry::getUtils()->currency2Float( $aParams['price'] );
01130             $this->_sBidPrice = oxRegistry::getLang()->formatCurrency( $iPrice, $oCur );
01131         }
01132         return $this->_sBidPrice;
01133     }
01134 
01140     public function getVariantSelections()
01141     {
01142         // finding parent
01143         $oProduct = $this->getProduct();
01144         if ( ( $oParent = $this->_getParentProduct( $oProduct->oxarticles__oxparentid->value ) ) ) {
01145             return $oParent->getVariantSelections( $this->getConfig()->getRequestParameter( "varselid" ), $oProduct->getId() );
01146         }
01147 
01148         return $oProduct->getVariantSelections( $this->getConfig()->getRequestParameter( "varselid" ) );
01149     }
01150 
01156     public function getPicturesProduct()
01157     {
01158         $aVariantSelections = $this->getVariantSelections();
01159         if ($aVariantSelections && $aVariantSelections['oActiveVariant'] && !$aVariantSelections['blPerfectFit']) {
01160             return $aVariantSelections['oActiveVariant'];
01161         }
01162         return $this->getProduct();
01163     }
01164 
01170     public function getSearchParamForHtml()
01171     {
01172         if ( $this->_sSearchParamForHtml === null ) {
01173             $this->_sSearchParamForHtml = $this->getConfig()->getRequestParameter( 'searchparam' );
01174         }
01175         return $this->_sSearchParamForHtml;
01176     }
01177 
01183     public function showRdfa()
01184     {
01185         return $this->getConfig()->getConfigParam( 'blRDFaEmbedding' );
01186     }
01187 
01193     public function getRDFaNormalizedRating()
01194     {
01195         $myConfig = $this->getConfig();
01196         $iMin = $myConfig->getConfigParam("iRDFaMinRating");
01197         $iMax = $myConfig->getConfigParam("iRDFaMaxRating");
01198 
01199         $oProduct = $this->getProduct();
01200         $iCount = $oProduct->oxarticles__oxratingcnt->value;
01201         if ( isset($iMin) && isset($iMax) && $iMax != '' && $iMin != '' && $iCount > 0 ) {
01202             $aNormalizedRating = array();
01203             $iValue = ((4*($oProduct->oxarticles__oxrating->value - $iMin)/($iMax - $iMin)))+1;
01204             $aNormalizedRating["count"] = $iCount;
01205             $aNormalizedRating["value"] = round($iValue, 2);
01206             return $aNormalizedRating;
01207         }
01208         return false;
01209     }
01210 
01218     public function getRDFaValidityPeriod($sShopConfVar)
01219     {
01220         if ( $sShopConfVar ) {
01221             $aValidity = array();
01222             $iDays = $this->getConfig()->getConfigParam($sShopConfVar);
01223             $iFrom = oxRegistry::get("oxUtilsDate")->getTime();
01224 
01225             $iThrough = $iFrom + ($iDays * 24 * 60 * 60);
01226             $aValidity["from"] = date('Y-m-d\TH:i:s', $iFrom)."Z";
01227             $aValidity["through"] = date('Y-m-d\TH:i:s', $iThrough)."Z";
01228 
01229             return $aValidity;
01230         }
01231         return false;
01232     }
01233 
01239     public function getRDFaBusinessFnc()
01240     {
01241         return $this->getConfig()->getConfigParam("sRDFaBusinessFnc");
01242     }
01243 
01249     public function getRDFaCustomers()
01250     {
01251         return $this->getConfig()->getConfigParam("aRDFaCustomers");
01252     }
01253 
01259     public function getRDFaVAT()
01260     {
01261         return $this->getConfig()->getConfigParam("iRDFaVAT");
01262     }
01263 
01269     public function getRDFaGenericCondition()
01270     {
01271         return $this->getConfig()->getConfigParam("iRDFaCondition");
01272     }
01273 
01279     public function getBundleArticle()
01280     {
01281         $oProduct = $this->getProduct();
01282         if ( $oProduct && $oProduct->oxarticles__oxbundleid->value ) {
01283             $oArticle = oxNew("oxArticle");
01284             $oArticle->load($oProduct->oxarticles__oxbundleid->value);
01285             return $oArticle;
01286         }
01287         return false;
01288     }
01289 
01295     public function getRDFaPaymentMethods()
01296     {
01297         $iPrice = $this->getProduct()->getPrice()->getBruttoPrice();
01298         $oPayments = oxNew("oxPaymentList");
01299         $oPayments->loadRDFaPaymentList($iPrice);
01300         return $oPayments;
01301     }
01302 
01308     public function getRDFaDeliverySetMethods()
01309     {
01310         $oDelSets = oxNew("oxDeliverySetList");
01311         $oDelSets->loadRDFaDeliverySetList();
01312         return $oDelSets;
01313     }
01314 
01320     public function getProductsDeliveryList()
01321     {
01322         $oProduct = $this->getProduct();
01323         $oDelList = oxNew( "oxDeliveryList" );
01324         $oDelList->loadDeliveryListForProduct( $oProduct );
01325         return $oDelList;
01326     }
01327 
01333     public function getRDFaDeliveryChargeSpecLoc()
01334     {
01335         return $this->getConfig()->getConfigParam("sRDFaDeliveryChargeSpecLoc");
01336     }
01337 
01343     public function getRDFaPaymentChargeSpecLoc()
01344     {
01345         return $this->getConfig()->getConfigParam("sRDFaPaymentChargeSpecLoc");
01346     }
01347 
01353     public function getRDFaBusinessEntityLoc()
01354     {
01355         return $this->getConfig()->getConfigParam("sRDFaBusinessEntityLoc");
01356     }
01357 
01363     public function showRDFaProductStock()
01364     {
01365         return $this->getConfig()->getConfigParam("blShowRDFaProductStock");
01366     }
01367 
01373     public function canChangeTags()
01374     {
01375         if ( $oUser = $this->getUser() ) {
01376 
01377             return true;
01378         }
01379         return false;
01380     }
01381 
01387     public function getTagCloudManager()
01388     {
01389         $oManager = oxNew( "oxTagCloud" );
01390         $oManager->setExtendedMode( true );
01391         $oManager->setProductId( $this->getProduct()->getId() );
01392         return $oManager;
01393     }
01394 
01400     public function showZoomPics()
01401     {
01402         $aPicGallery = $this->getPictureGallery();
01403         return $aPicGallery['ZoomPic'];
01404     }
01405 
01411     public function isReviewActive()
01412     {
01413         return $this->getConfig()->getConfigParam( 'bl_perfLoadReviews' );
01414     }
01415 
01421     public function getDefaultSorting()
01422     {
01423         $aSorting = parent::getDefaultSorting();
01424         $oCategory = $this->getActiveCategory();
01425 
01426         if ( $this->getListType() != 'search' &&  $oCategory && $oCategory instanceof oxCategory ) {
01427             if ( $sDefaultSorting = $oCategory->getDefaultSorting() ) {
01428                 $sArticleTable = getViewName( 'oxarticles' );
01429                 $sSortBy  = $sArticleTable.'.'.$sDefaultSorting;
01430                 $sSortDir = ( $oCategory->getDefaultSortingMode() ) ? "desc" : "asc";
01431                 $aSorting = array ( 'sortby' => $sSortBy, 'sortdir' => $sSortDir );
01432             }
01433         }
01434 
01435         return $aSorting;
01436     }
01437 
01443     public function getSortingParameters()
01444     {
01445         $aSorting = $this->getSorting( $this->getSortIdent() );
01446         if ( !is_array( $aSorting ) ) {
01447             return null;
01448         }
01449         return implode( '|', $aSorting);
01450     }
01451 
01457     protected function _getVendorBreadCrumb()
01458     {
01459         $aPaths = array();
01460         $aCatPath = array();
01461 
01462         $oCat = oxNew( 'oxVendor' );
01463         $oCat->load( 'root' );
01464 
01465         $aCatPath['link'] = $oCat->getLink();
01466         $aCatPath['title'] = $oCat->oxvendor__oxtitle->value;
01467         $aPaths[] = $aCatPath;
01468 
01469         $oCat = $this->getActVendor();
01470         $aCatPath['link'] = $oCat->getLink();
01471         $aCatPath['title'] = $oCat->oxvendor__oxtitle->value;
01472         $aPaths[] = $aCatPath;
01473 
01474         return $aPaths;
01475     }
01476 
01482     protected function _getRecommendationListBredCrumb()
01483     {
01484         $aPaths = array();
01485         $aCatPath = array();
01486         $aCatPath['title'] = oxRegistry::getLang()->translateString( 'LISTMANIA', oxRegistry::getLang()->getBaseLanguage(), false );
01487         $aPaths[] = $aCatPath;
01488         return $aPaths;
01489     }
01490 
01496     protected function _getTagBreadCrumb()
01497     {
01498         $aPaths = array();
01499 
01500         $aCatPath = array();
01501 
01502         $aCatPath['title'] = oxRegistry::getLang()->translateString( 'TAGS', oxRegistry::getLang()->getBaseLanguage(), false );
01503         $aCatPath['link'] = oxRegistry::get( "oxSeoEncoder" )->getStaticUrl( $this->getViewConfig()->getSelfLink() . 'cl=tags' );
01504         $aPaths[] = $aCatPath;
01505 
01506         $oStr = getStr();
01507         $aCatPath['title'] = $oStr->ucfirst( oxRegistry::getConfig()->getRequestParameter( 'searchtag' ) );
01508         $aCatPath['link'] = oxRegistry::get( "oxSeoEncoderTag" )->getTagUrl( oxRegistry::getConfig()->getRequestParameter( 'searchtag' ) );
01509         $aPaths[] = $aCatPath;
01510         return $aPaths;
01511     }
01512 
01518     protected function _getSearchBreadCrumb()
01519     {
01520         $aPaths = array();
01521         $aCatPath = array();
01522 
01523         $aCatPath['title'] = sprintf( oxRegistry::getLang()->translateString( 'SEARCH_RESULT', oxRegistry::getLang()->getBaseLanguage(), false ), $this->getSearchParamForHtml());
01524         $aCatPath['link'] = $this->getViewConfig()->getSelfLink() . 'stoken=' . oxRegistry::getSession()->getVariable( 'sess_stoken' ) . "&amp;cl=search&amp;searchparam=" . $this->getSearchParamForHtml();
01525 
01526         $aPaths[] = $aCatPath;
01527 
01528         return $aPaths;
01529     }
01530 
01536     protected function _getCategoryBreadCrumb()
01537     {
01538         $aPaths = array();
01539 
01540         $oCatTree = $this->getCatTreePath();
01541 
01542         if ( $oCatTree ) {
01543 
01544             foreach ( $oCatTree as $oCat ) {
01545                 $aCatPath = array();
01546 
01547                 $aCatPath['link'] = $oCat->getLink();
01548                 $aCatPath['title'] = $oCat->oxcategories__oxtitle->value;
01549 
01550                 $aPaths[] = $aCatPath;
01551             }
01552             return $aPaths;
01553         }
01554         return $aPaths;
01555     }
01556 }