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 (!oxRegistry::getSession()->checkSessionChallenge()) {
00369             return;
00370         }
00371 
00372         if ( $this->canAcceptFormData() &&
00373              ( $oUser = $this->getUser() ) && ( $oProduct = $this->getProduct() ) ) {
00374 
00375             $dRating = $this->getConfig()->getRequestParameter( 'artrating' );
00376             if ( $dRating !== null ) {
00377                 $dRating = (int) $dRating;
00378             }
00379 
00380             //save rating
00381             if ( $dRating !== null && $dRating >= 1 && $dRating <= 5 ) {
00382                 $oRating = oxNew( 'oxrating' );
00383                 if ( $oRating->allowRating( $oUser->getId(), 'oxarticle', $oProduct->getId() ) ) {
00384                     $oRating->oxratings__oxuserid   = new oxField( $oUser->getId() );
00385                     $oRating->oxratings__oxtype     = new oxField( 'oxarticle' );
00386                     $oRating->oxratings__oxobjectid = new oxField( $oProduct->getId() );
00387                     $oRating->oxratings__oxrating   = new oxField( $dRating );
00388                     $oRating->save();
00389                     $oProduct->addToRatingAverage( $dRating );
00390                 }
00391             }
00392 
00393             if ( ( $sReviewText = trim( ( string ) $this->getConfig()->getRequestParameter( 'rvw_txt', true ) ) ) ) {
00394                 $oReview = oxNew( 'oxReview' );
00395                 $oReview->oxreviews__oxobjectid = new oxField( $oProduct->getId() );
00396                 $oReview->oxreviews__oxtype     = new oxField( 'oxarticle' );
00397                 $oReview->oxreviews__oxtext     = new oxField( $sReviewText, oxField::T_RAW );
00398                 $oReview->oxreviews__oxlang     = new oxField( oxRegistry::getLang()->getBaseLanguage() );
00399                 $oReview->oxreviews__oxuserid   = new oxField( $oUser->getId() );
00400                 $oReview->oxreviews__oxrating   = new oxField( ( $dRating !== null ) ? $dRating : 0);
00401                 $oReview->save();
00402             }
00403         }
00404     }
00405 
00411     public function addToRecomm()
00412     {
00413         if (!oxRegistry::getSession()->checkSessionChallenge()) {
00414             return;
00415         }
00416 
00417         if (!$this->getViewConfig()->getShowListmania()) {
00418             return;
00419         }
00420 
00421         $sRecommText = trim( ( string ) $this->getConfig()->getRequestParameter( 'recomm_txt' ) );
00422         $sRecommList = $this->getConfig()->getRequestParameter( 'recomm' );
00423         $sArtId      = $this->getProduct()->getId();
00424 
00425         if ( $sArtId ) {
00426             $oRecomm = oxNew( 'oxrecommlist' );
00427             $oRecomm->load( $sRecommList);
00428             $oRecomm->addArticle( $sArtId, $sRecommText );
00429         }
00430     }
00431 
00437     public function addTags()
00438     {
00439         if (!oxRegistry::getSession()->checkSessionChallenge()) {
00440             return;
00441         }
00442 
00443         $sTags  = $this->getConfig()->getRequestParameter('newTags', true );
00444         $sHighTag  = $this->getConfig()->getRequestParameter( 'highTags', true );
00445         if ( !$sTags && !$sHighTag) {
00446             return;
00447         }
00448         if ( $sHighTag ) {
00449             $sTags = getStr()->html_entity_decode( $sHighTag );
00450         }
00451         $oProduct = $this->getProduct();
00452 
00453         // set current user added tags for this article for later checking
00454         $aTaggedProducts = oxRegistry::getSession()->getVariable("aTaggedProducts");
00455         $aAddedTags = $aTaggedProducts? $aTaggedProducts[$oProduct->getId()] : array();
00456 
00457         $oArticleTagList = oxNew( "oxArticleTagList" );
00458         $oArticleTagList->load( $oProduct->getId() );
00459         $sSeparator = $oArticleTagList->get()->getSeparator();
00460         $aTags = array_unique( explode( $sSeparator, $sTags ) );
00461 
00462         $aResult = $this->_addTagsToList( $oArticleTagList, $aTags, $aAddedTags);
00463 
00464         if ( !empty( $aResult['tags'] ) ) {
00465             $oArticleTagList->save();
00466             foreach ( $aResult['tags'] as $sTag) {
00467                 $aAddedTags[ $sTag ] = 1;
00468             }
00469             $aTaggedProducts[$oProduct->getId()] = $aAddedTags;
00470             oxRegistry::getSession()->setVariable( 'aTaggedProducts', $aTaggedProducts);
00471         }
00472         // for ajax call
00473         if ( $this->getConfig()->getRequestParameter( 'blAjax', true ) ) {
00474             oxRegistry::getUtils()->showMessageAndExit( json_encode( $aResult ) );
00475         }
00476     }
00477 
00487     protected function _addTagsToList( $oArticleTagList, $aTags, $aAddedTags)
00488     {
00489         $aResult = array( 'tags' => array(), 'invalid' => array(), 'inlist' => array() );
00490 
00491         foreach ( $aTags as $sTag ) {
00492             $oTag = oxNew( "oxtag", $sTag );
00493             if ( $aAddedTags[$oTag->get()] != 1 ) {
00494                 if ( $oTag->isValid() ) {
00495                     $oArticleTagList->addTag( $oTag );
00496                     $aResult['tags'][] = $oTag->get();
00497                 } else {
00498                     $aResult['invalid'][] = $oTag->get();
00499                 }
00500             } else {
00501                 $aResult['inlist'][] = $oTag->get();
00502             }
00503         }
00504 
00505         return $aResult;
00506     }
00507 
00513     public function editTags()
00514     {
00515         if ( !$this->getUser() ) {
00516             return;
00517         }
00518         $oArticleTagList = oxNew("oxArticleTagList");
00519         $oArticleTagList->load( $this->getProduct()->getId() );
00520         $oTagSet = $oArticleTagList->get();
00521         $this->_aTags = $oTagSet->get();
00522         $this->_blEditTags = true;
00523 
00524         // for ajax call
00525         if ( $this->getConfig()->getRequestParameter( 'blAjax', true ) ) {
00526             oxRegistry::getUtils()->setHeader( "Content-Type: text/html; charset=".oxRegistry::getLang()->translateString( 'charset' ) );
00527             $oActView = oxNew( 'oxubase' );
00528             $oSmarty = oxRegistry::get("oxUtilsView")->getSmarty();
00529             $oSmarty->assign('oView', $this );
00530             $oSmarty->assign('oViewConf', $this->getViewConfig() );
00531             oxRegistry::getUtils()->showMessageAndExit( $oSmarty->fetch( 'page/details/inc/editTags.tpl', $this->getViewId() ) );
00532         }
00533     }
00534 
00540     public function cancelTags()
00541     {
00542         $oArticleTagList = oxNew("oxArticleTagList");
00543         $oArticleTagList->load( $this->getProduct()->getId() );
00544         $oTagSet = $oArticleTagList->get();
00545         $this->_aTags = $oTagSet->get();
00546         $this->_blEditTags = false;
00547 
00548         // for ajax call
00549         if ( oxConfig::getParameter( 'blAjax', true ) ) {
00550             oxRegistry::getUtils()->setHeader( "Content-Type: text/html; charset=".oxRegistry::getLang()->translateString( 'charset' ) );
00551             $oActView = oxNew( 'oxubase' );
00552             $oSmarty = oxRegistry::get("oxUtilsView")->getSmarty();
00553             $oSmarty->assign('oView', $this );
00554             $oSmarty->assign('oViewConf', $this->getViewConfig() );
00555             oxRegistry::getUtils()->showMessageAndExit( $oSmarty->fetch( 'page/details/inc/tags.tpl', $this->getViewId() ) );
00556         }
00557     }
00558 
00564     protected function _getSeoObjectId()
00565     {
00566         if ( $oProduct = $this->getProduct() ) {
00567             return $oProduct->getId();
00568         }
00569     }
00570 
00576     public function getEditTags()
00577     {
00578         return $this->_blEditTags;
00579     }
00580 
00586     public function getTags()
00587     {
00588         return $this->_aTags;
00589     }
00590 
00596     public function getProduct()
00597     {
00598         $myConfig = $this->getConfig();
00599         $myUtils = oxRegistry::getUtils();
00600 
00601         if ( $this->_oProduct === null ) {
00602 
00603             //this option is only for lists and we must reset value
00604             //as blLoadVariants = false affect "ab price" functionality
00605             $myConfig->setConfigParam( 'blLoadVariants', true );
00606 
00607             $sOxid = $this->getConfig()->getRequestParameter( 'anid' );
00608 
00609             // object is not yet loaded
00610             $this->_oProduct = oxNew( 'oxarticle' );
00611 
00612             if ( !$this->_oProduct->load( $sOxid ) ) {
00613                 $myUtils->redirect( $myConfig->getShopHomeURL() );
00614                 $myUtils->showMessageAndExit( '' );
00615             }
00616 
00617             $aVariantSelections = $this->_oProduct->getVariantSelections( $this->getConfig()->getRequestParameter( "varselid" ) );
00618             if ($aVariantSelections && $aVariantSelections['oActiveVariant'] && $aVariantSelections['blPerfectFit']) {
00619                 $this->_oProduct = $aVariantSelections['oActiveVariant'];
00620             }
00621         }
00622 
00623         // additional checks
00624         if ( !$this->_blIsInitialized ) {
00625 
00626             $blContinue = true;
00627             if ( !$this->_oProduct->isVisible() ) {
00628                 $blContinue = false;
00629             } elseif ( $this->_oProduct->oxarticles__oxparentid->value ) {
00630                 $oParent = $this->_getParentProduct( $this->_oProduct->oxarticles__oxparentid->value );
00631                 if ( !$oParent || !$oParent->isVisible() ) {
00632                     $blContinue = false;
00633                 }
00634             }
00635 
00636             if ( !$blContinue ) {
00637                 $myUtils->redirect( $myConfig->getShopHomeURL() );
00638                 $myUtils->showMessageAndExit( '' );
00639             }
00640 
00641             $this->_processProduct( $this->_oProduct );
00642             $this->_blIsInitialized = true;
00643         }
00644 
00645         return $this->_oProduct;
00646     }
00647 
00653     public function getLinkType()
00654     {
00655         if ( $this->_iLinkType === null ) {
00656             $sListType = $this->getConfig()->getRequestParameter( 'listtype' );
00657             if ( 'vendor' == $sListType ) {
00658                 $this->_iLinkType = OXARTICLE_LINKTYPE_VENDOR;
00659             } elseif ( 'manufacturer' == $sListType ) {
00660                     $this->_iLinkType = OXARTICLE_LINKTYPE_MANUFACTURER;
00661             } elseif ( 'tag' == $sListType ) {
00662                     $this->_iLinkType = OXARTICLE_LINKTYPE_TAG;
00663             } elseif ( 'recommlist' == $sListType ) {
00664                     $this->_iLinkType = OXARTICLE_LINKTYPE_RECOMM;
00665             } else {
00666                 $this->_iLinkType = OXARTICLE_LINKTYPE_CATEGORY;
00667 
00668                 // price category has own type..
00669                 if ( ( $oCat = $this->getActiveCategory() ) && $oCat->isPriceCategory() ) {
00670                     $this->_iLinkType = OXARTICLE_LINKTYPE_PRICECATEGORY;
00671                 }
00672             }
00673         }
00674 
00675         return $this->_iLinkType;
00676     }
00677 
00683     public function drawParentUrl()
00684     {
00685         return $this->getProduct()->isVariant();
00686     }
00687 
00695     public function getParentName()
00696     {
00697         if ( $this->_sParentName === null ) {
00698             $this->_sParentName = false;
00699             if ( ( $oParent = $this->_getParentProduct( $this->getProduct()->oxarticles__oxparentid->value ) ) ) {
00700                 $this->_sParentName = $oParent->oxarticles__oxtitle->value;
00701             }
00702         }
00703         return $this->_sParentName;
00704     }
00705 
00713     public function getParentUrl()
00714     {
00715         if ( $this->_sParentUrl === null ) {
00716             $this->_sParentUrl = false;
00717             if ( ( $oParent = $this->_getParentProduct( $this->getProduct()->oxarticles__oxparentid->value ) ) ) {
00718                 $this->_sParentUrl = $oParent->getLink();
00719             }
00720         }
00721         return $this->_sParentUrl;
00722     }
00723 
00729     public function getPictureGallery()
00730     {
00731         if ( $this->_aPicGallery === null ) {
00732             //get picture gallery
00733             $this->_aPicGallery = $this->getPicturesProduct()->getPictureGallery();
00734         }
00735         return $this->_aPicGallery;
00736     }
00737 
00743     public function getActPictureId()
00744     {
00745         $aPicGallery = $this->getPictureGallery();
00746         return $aPicGallery['ActPicID'];
00747     }
00748 
00754     public function getActPicture()
00755     {
00756         $aPicGallery = $this->getPictureGallery();
00757         return $aPicGallery['ActPic'];
00758     }
00759 
00765     public function getPictures()
00766     {
00767         $aPicGallery = $this->getPictureGallery();
00768         return $aPicGallery['Pics'];
00769     }
00770 
00778     public function getArtPic( $sPicNr )
00779     {
00780         $aPicGallery = $this->getPictureGallery();
00781         return $aPicGallery['Pics'][$sPicNr];
00782     }
00783 
00789     public function getSelectLists()
00790     {
00791         if ( $this->_aSelectLists === null ) {
00792             $this->_aSelectLists = false;
00793             if ( $this->getConfig()->getConfigParam( 'bl_perfLoadSelectLists' ) ) {
00794                 $this->_aSelectLists = $this->getProduct()->getSelectLists();
00795             }
00796         }
00797         return $this->_aSelectLists;
00798     }
00799 
00805     public function getReviews()
00806     {
00807         if ( $this->_aReviews === null ) {
00808             $this->_aReviews = false;
00809             if ( $this->getConfig()->getConfigParam( 'bl_perfLoadReviews' ) ) {
00810                 $this->_aReviews = $this->getProduct()->getReviews();
00811             }
00812         }
00813         return $this->_aReviews;
00814     }
00815 
00821     public function getCrossSelling()
00822     {
00823         if ( $this->_oCrossSelling === null ) {
00824             $this->_oCrossSelling = false;
00825             if ( $oProduct = $this->getProduct() ) {
00826                 $this->_oCrossSelling = $oProduct->getCrossSelling();
00827             }
00828         }
00829         return $this->_oCrossSelling;
00830     }
00831 
00837     public function getSimilarProducts()
00838     {
00839         if ( $this->_oSimilarProducts === null ) {
00840             $this->_oSimilarProducts = false;
00841             if ( $oProduct = $this->getProduct() ) {
00842                 $this->_oSimilarProducts = $oProduct->getSimilarProducts();
00843             }
00844         }
00845         return $this->_oSimilarProducts;
00846     }
00847 
00853     public function getSimilarRecommListIds()
00854     {
00855         if ( $this->_aSimilarRecommListIds === null ) {
00856             $this->_aSimilarRecommListIds = false;
00857 
00858             if ( $oProduct = $this->getProduct() ) {
00859                 $this->_aSimilarRecommListIds = array( $oProduct->getId() );
00860             }
00861         }
00862         return $this->_aSimilarRecommListIds;
00863     }
00864 
00870     public function getAccessoires()
00871     {
00872         if ( $this->_oAccessoires === null ) {
00873             $this->_oAccessoires = false;
00874             if ( $oProduct = $this->getProduct() ) {
00875                 $this->_oAccessoires = $oProduct->getAccessoires();
00876             }
00877         }
00878         return $this->_oAccessoires;
00879     }
00880 
00886     public function getAlsoBoughtTheseProducts()
00887     {
00888         if ( $this->_aAlsoBoughtArts === null ) {
00889             $this->_aAlsoBoughtArts = false;
00890             if ( $oProduct = $this->getProduct() ) {
00891                 $this->_aAlsoBoughtArts = $oProduct->getCustomerAlsoBoughtThisProducts();
00892             }
00893         }
00894         return $this->_aAlsoBoughtArts;
00895     }
00896 
00902     public function isPriceAlarm()
00903     {
00904         // #419 disabling price alarm if article has fixed price
00905         $oProduct = $this->getProduct();
00906         if ( isset( $oProduct->oxarticles__oxblfixedprice->value ) && $oProduct->oxarticles__oxblfixedprice->value ) {
00907             return 0;
00908         }
00909         return 1;
00910     }
00911 
00920     protected function _getSubject( $iLang )
00921     {
00922         return $this->getProduct();
00923     }
00924 
00930     public function getSearchTitle()
00931     {
00932         return $this->_sSearchTitle;
00933     }
00934 
00942     public function setSearchTitle( $sTitle )
00943     {
00944         $this->_sSearchTitle = $sTitle;
00945     }
00946 
00954     public function setCatTreePath( $sActCatPath )
00955     {
00956         $this->_sCatTreePath = $sActCatPath;
00957     }
00958 
00965     public function noIndex()
00966     {
00967         $sListType = $this->getConfig()->getRequestParameter( 'listtype' );
00968         if ( $sListType && ( 'vendor' == $sListType || 'manufacturer' == $sListType ) ) {
00969             return $this->_iViewIndexState = VIEW_INDEXSTATE_NOINDEXFOLLOW;
00970         }
00971         return parent::noIndex();
00972     }
00973 
00979     public function getTitle()
00980     {
00981         if ( $oProduct = $this->getProduct() ) {
00982             $sTag = $this->getTag();
00983             return $oProduct->oxarticles__oxtitle->value . ( $oProduct->oxarticles__oxvarselect->value ? ' ' . $oProduct->oxarticles__oxvarselect->value : '' ) . (!empty($sTag) ? ' - '.$sTag : '');
00984         }
00985     }
00986     
00992     public function getMetaDescription()
00993     {
00994         $sMeta = parent::getMetaDescription();
00995 
00996         if($sTag = $this->getTag()) {
00997             $sMeta = $sTag.' - ' . $sMeta;
00998         }
00999 
01000         return $sMeta;
01001     }
01002 
01008     public function getTag()
01009     {
01010         return oxConfig::getParameter("searchtag");
01011     }
01012 
01018     public function getCanonicalUrl()
01019     {
01020         if ( ( $oProduct = $this->getProduct() ) ) {
01021             if ( $oProduct->oxarticles__oxparentid->value ) {
01022                 $oProduct = $this->_getParentProduct( $oProduct->oxarticles__oxparentid->value );
01023             }
01024 
01025             $oUtils = oxRegistry::get("oxUtilsUrl");
01026             if ( oxRegistry::getUtils()->seoIsActive() ) {
01027                 $sUrl = $oUtils->prepareCanonicalUrl( $oProduct->getBaseSeoLink( $oProduct->getLanguage(), true ) );
01028             } else {
01029                 $sUrl = $oUtils->prepareCanonicalUrl( $oProduct->getBaseStdLink( $oProduct->getLanguage() ) );
01030             }
01031             return $sUrl;
01032         }
01033     }
01034 
01040     public function getBreadCrumb()
01041     {
01042         if ( 'search' == $this->getListType() ) {
01043             $aPaths = $this->_getSearchBreadCrumb();
01044         } elseif ( 'tag' == $this->getListType() ) {
01045             $aPaths = $this->_getTagBreadCrumb();
01046         } elseif ( 'recommlist' == $this->getListType() ) {
01047             $aPaths = $this->_getRecommendationListBredCrumb();
01048         } elseif ( 'vendor' == $this->getListType() ) {
01049             $aPaths = $this->_getVendorBreadCrumb();
01050         } else {
01051             $aPaths = $this->_getCategoryBreadCrumb();
01052         }
01053         return $aPaths;
01054     }
01055 
01061     public function getCaptcha()
01062     {
01063         if ( $this->_oCaptcha === null ) {
01064             $this->_oCaptcha = oxNew('oxCaptcha');
01065         }
01066         return $this->_oCaptcha;
01067     }
01068 
01078     public function addme()
01079     {
01080         $myConfig = $this->getConfig();
01081         $myUtils  = oxRegistry::getUtils();
01082 
01083         //control captcha
01084         $sMac     = $this->getConfig()->getRequestParameter( 'c_mac' );
01085         $sMacHash = $this->getConfig()->getRequestParameter( 'c_mach' );
01086         $oCaptcha = $this->getCaptcha();
01087         if ( !$oCaptcha->pass( $sMac, $sMacHash ) ) {
01088             $this->_iPriceAlarmStatus = 2;
01089             return;
01090         }
01091 
01092         $aParams = $this->getConfig()->getRequestParameter( 'pa' );
01093         if ( !isset( $aParams['email'] ) || !$myUtils->isValidEmail( $aParams['email'] ) ) {
01094             $this->_iPriceAlarmStatus = 0;
01095             return;
01096         }
01097         $aParams['aid'] = $this->getProduct()->getId();
01098         $oCur = $myConfig->getActShopCurrencyObject();
01099         // convert currency to default
01100         $dPrice = $myUtils->currency2Float( $aParams['price'] );
01101 
01102         $oAlarm = oxNew( "oxPriceAlarm" );
01103         $oAlarm->oxpricealarm__oxuserid = new oxField( oxSession::getVar( 'usr' ));
01104         $oAlarm->oxpricealarm__oxemail  = new oxField( $aParams['email']);
01105         $oAlarm->oxpricealarm__oxartid  = new oxField( $aParams['aid']);
01106         $oAlarm->oxpricealarm__oxprice  = new oxField( $myUtils->fRound( $dPrice, $oCur ));
01107         $oAlarm->oxpricealarm__oxshopid = new oxField( $myConfig->getShopId());
01108         $oAlarm->oxpricealarm__oxcurrency = new oxField( $oCur->name);
01109 
01110         $oAlarm->oxpricealarm__oxlang = new oxField(oxRegistry::getLang()->getBaseLanguage());
01111 
01112         $oAlarm->save();
01113 
01114         // Send Email
01115         $oEmail = oxNew( 'oxEmail' );
01116         $this->_iPriceAlarmStatus = (int) $oEmail->sendPricealarmNotification( $aParams, $oAlarm );
01117     }
01118 
01124     public function getPriceAlarmStatus()
01125     {
01126         return $this->_iPriceAlarmStatus;
01127     }
01128 
01134     public function getBidPrice()
01135     {
01136         if ( $this->_sBidPrice === null ) {
01137             $this->_sBidPrice = false;
01138 
01139             $aParams = $this->getConfig()->getRequestParameter( 'pa' );
01140             $oCur = $this->getConfig()->getActShopCurrencyObject();
01141             $iPrice = oxRegistry::getUtils()->currency2Float( $aParams['price'] );
01142             $this->_sBidPrice = oxRegistry::getLang()->formatCurrency( $iPrice, $oCur );
01143         }
01144         return $this->_sBidPrice;
01145     }
01146 
01152     public function getVariantSelections()
01153     {
01154         // finding parent
01155         $oProduct = $this->getProduct();
01156         if ( ( $oParent = $this->_getParentProduct( $oProduct->oxarticles__oxparentid->value ) ) ) {
01157             return $oParent->getVariantSelections( $this->getConfig()->getRequestParameter( "varselid" ), $oProduct->getId() );
01158         }
01159 
01160         return $oProduct->getVariantSelections( $this->getConfig()->getRequestParameter( "varselid" ) );
01161     }
01162 
01168     public function getPicturesProduct()
01169     {
01170         $aVariantSelections = $this->getVariantSelections();
01171         if ($aVariantSelections && $aVariantSelections['oActiveVariant'] && !$aVariantSelections['blPerfectFit']) {
01172             return $aVariantSelections['oActiveVariant'];
01173         }
01174         return $this->getProduct();
01175     }
01176 
01182     public function getSearchParamForHtml()
01183     {
01184         if ( $this->_sSearchParamForHtml === null ) {
01185             $this->_sSearchParamForHtml = $this->getConfig()->getRequestParameter( 'searchparam' );
01186         }
01187         return $this->_sSearchParamForHtml;
01188     }
01189 
01195     public function showRdfa()
01196     {
01197         return $this->getConfig()->getConfigParam( 'blRDFaEmbedding' );
01198     }
01199 
01205     public function getRDFaNormalizedRating()
01206     {
01207         $myConfig = $this->getConfig();
01208         $iMin = $myConfig->getConfigParam("iRDFaMinRating");
01209         $iMax = $myConfig->getConfigParam("iRDFaMaxRating");
01210 
01211         $oProduct = $this->getProduct();
01212         $iCount = $oProduct->oxarticles__oxratingcnt->value;
01213         if ( isset($iMin) && isset($iMax) && $iMax != '' && $iMin != '' && $iCount > 0 ) {
01214             $aNormalizedRating = array();
01215             $iValue = ((4*($oProduct->oxarticles__oxrating->value - $iMin)/($iMax - $iMin)))+1;
01216             $aNormalizedRating["count"] = $iCount;
01217             $aNormalizedRating["value"] = round($iValue, 2);
01218             return $aNormalizedRating;
01219         }
01220         return false;
01221     }
01222 
01230     public function getRDFaValidityPeriod($sShopConfVar)
01231     {
01232         if ( $sShopConfVar ) {
01233             $aValidity = array();
01234             $iDays = $this->getConfig()->getConfigParam($sShopConfVar);
01235             $iFrom = oxRegistry::get("oxUtilsDate")->getTime();
01236 
01237             $iThrough = $iFrom + ($iDays * 24 * 60 * 60);
01238             $aValidity["from"] = date('Y-m-d\TH:i:s', $iFrom)."Z";
01239             $aValidity["through"] = date('Y-m-d\TH:i:s', $iThrough)."Z";
01240 
01241             return $aValidity;
01242         }
01243         return false;
01244     }
01245 
01251     public function getRDFaBusinessFnc()
01252     {
01253         return $this->getConfig()->getConfigParam("sRDFaBusinessFnc");
01254     }
01255 
01261     public function getRDFaCustomers()
01262     {
01263         return $this->getConfig()->getConfigParam("aRDFaCustomers");
01264     }
01265 
01271     public function getRDFaVAT()
01272     {
01273         return $this->getConfig()->getConfigParam("iRDFaVAT");
01274     }
01275 
01281     public function getRDFaGenericCondition()
01282     {
01283         return $this->getConfig()->getConfigParam("iRDFaCondition");
01284     }
01285 
01291     public function getBundleArticle()
01292     {
01293         $oProduct = $this->getProduct();
01294         if ( $oProduct && $oProduct->oxarticles__oxbundleid->value ) {
01295             $oArticle = oxNew("oxArticle");
01296             $oArticle->load($oProduct->oxarticles__oxbundleid->value);
01297             return $oArticle;
01298         }
01299         return false;
01300     }
01301 
01307     public function getRDFaPaymentMethods()
01308     {
01309         $iPrice = $this->getProduct()->getPrice()->getBruttoPrice();
01310         $oPayments = oxNew("oxPaymentList");
01311         $oPayments->loadRDFaPaymentList($iPrice);
01312         return $oPayments;
01313     }
01314 
01320     public function getRDFaDeliverySetMethods()
01321     {
01322         $oDelSets = oxNew("oxDeliverySetList");
01323         $oDelSets->loadRDFaDeliverySetList();
01324         return $oDelSets;
01325     }
01326 
01332     public function getProductsDeliveryList()
01333     {
01334         $oProduct = $this->getProduct();
01335         $oDelList = oxNew( "oxDeliveryList" );
01336         $oDelList->loadDeliveryListForProduct( $oProduct );
01337         return $oDelList;
01338     }
01339 
01345     public function getRDFaDeliveryChargeSpecLoc()
01346     {
01347         return $this->getConfig()->getConfigParam("sRDFaDeliveryChargeSpecLoc");
01348     }
01349 
01355     public function getRDFaPaymentChargeSpecLoc()
01356     {
01357         return $this->getConfig()->getConfigParam("sRDFaPaymentChargeSpecLoc");
01358     }
01359 
01365     public function getRDFaBusinessEntityLoc()
01366     {
01367         return $this->getConfig()->getConfigParam("sRDFaBusinessEntityLoc");
01368     }
01369 
01375     public function showRDFaProductStock()
01376     {
01377         return $this->getConfig()->getConfigParam("blShowRDFaProductStock");
01378     }
01379 
01385     public function canChangeTags()
01386     {
01387         if ( $oUser = $this->getUser() ) {
01388 
01389             return true;
01390         }
01391         return false;
01392     }
01393 
01399     public function getTagCloudManager()
01400     {
01401         $oManager = oxNew( "oxTagCloud" );
01402         $oManager->setExtendedMode( true );
01403         $oManager->setProductId( $this->getProduct()->getId() );
01404         return $oManager;
01405     }
01406 
01412     public function showZoomPics()
01413     {
01414         $aPicGallery = $this->getPictureGallery();
01415         return $aPicGallery['ZoomPic'];
01416     }
01417 
01423     public function isReviewActive()
01424     {
01425         return $this->getConfig()->getConfigParam( 'bl_perfLoadReviews' );
01426     }
01427 
01433     public function getDefaultSorting()
01434     {
01435         $aSorting = parent::getDefaultSorting();
01436         $oCategory = $this->getActiveCategory();
01437 
01438         if ( $this->getListType() != 'search' &&  $oCategory && $oCategory instanceof oxCategory ) {
01439             if ( $sSortBy = $oCategory->getDefaultSorting() ) {
01440                 $sSortDir = ( $oCategory->getDefaultSortingMode() ) ? "desc" : "asc";
01441                 $aSorting = array ( 'sortby' => $sSortBy, 'sortdir' => $sSortDir );
01442             }
01443         }
01444 
01445         return $aSorting;
01446     }
01447 
01453     public function getSortingParameters()
01454     {
01455         $aSorting = $this->getSorting( $this->getSortIdent() );
01456         if ( !is_array( $aSorting ) ) {
01457             return null;
01458         }
01459         return implode( '|', $aSorting);
01460     }
01461 
01467     protected function _getVendorBreadCrumb()
01468     {
01469         $aPaths = array();
01470         $aCatPath = array();
01471 
01472         $oCat = oxNew( 'oxVendor' );
01473         $oCat->load( 'root' );
01474 
01475         $aCatPath['link'] = $oCat->getLink();
01476         $aCatPath['title'] = $oCat->oxvendor__oxtitle->value;
01477         $aPaths[] = $aCatPath;
01478 
01479         $oCat = $this->getActVendor();
01480         $aCatPath['link'] = $oCat->getLink();
01481         $aCatPath['title'] = $oCat->oxvendor__oxtitle->value;
01482         $aPaths[] = $aCatPath;
01483 
01484         return $aPaths;
01485     }
01486 
01492     protected function _getRecommendationListBredCrumb()
01493     {
01494         $aPaths = array();
01495         $aCatPath = array();
01496         $aCatPath['title'] = oxRegistry::getLang()->translateString( 'LISTMANIA', oxRegistry::getLang()->getBaseLanguage(), false );
01497         $aPaths[] = $aCatPath;
01498         return $aPaths;
01499     }
01500 
01506     protected function _getTagBreadCrumb()
01507     {
01508         $aPaths = array();
01509 
01510         $aCatPath = array();
01511 
01512         $aCatPath['title'] = oxRegistry::getLang()->translateString( 'TAGS', oxRegistry::getLang()->getBaseLanguage(), false );
01513         $aCatPath['link'] = oxRegistry::get( "oxSeoEncoder" )->getStaticUrl( $this->getViewConfig()->getSelfLink() . 'cl=tags' );
01514         $aPaths[] = $aCatPath;
01515 
01516         $oStr = getStr();
01517         $aCatPath['title'] = $oStr->ucfirst( oxRegistry::getConfig()->getRequestParameter( 'searchtag' ) );
01518         $aCatPath['link'] = oxRegistry::get( "oxSeoEncoderTag" )->getTagUrl( oxRegistry::getConfig()->getRequestParameter( 'searchtag' ) );
01519         $aPaths[] = $aCatPath;
01520         return $aPaths;
01521     }
01522 
01528     protected function _getSearchBreadCrumb()
01529     {
01530         $aPaths = array();
01531         $aCatPath = array();
01532 
01533         $aCatPath['title'] = sprintf( oxRegistry::getLang()->translateString( 'SEARCH_RESULT', oxRegistry::getLang()->getBaseLanguage(), false ), $this->getSearchParamForHtml());
01534         $aCatPath['link'] = $this->getViewConfig()->getSelfLink() . 'stoken=' . oxRegistry::getSession()->getVariable( 'sess_stoken' ) . "&amp;cl=search&amp;searchparam=" . $this->getSearchParamForHtml();
01535 
01536         $aPaths[] = $aCatPath;
01537 
01538         return $aPaths;
01539     }
01540 
01546     protected function _getCategoryBreadCrumb()
01547     {
01548         $aPaths = array();
01549 
01550         $oCatTree = $this->getCatTreePath();
01551 
01552         if ( $oCatTree ) {
01553 
01554             foreach ( $oCatTree as $oCat ) {
01555                 $aCatPath = array();
01556 
01557                 $aCatPath['link'] = $oCat->getLink();
01558                 $aCatPath['title'] = $oCat->oxcategories__oxtitle->value;
01559 
01560                 $aPaths[] = $aCatPath;
01561             }
01562             return $aPaths;
01563         }
01564         return $aPaths;
01565     }
01566 }