details.php

Go to the documentation of this file.
00001 <?php
00002 
00009 class Details extends oxUBase
00010 {
00011 
00017     protected $_sThisTemplate = 'page/details/details.tpl';
00018 
00024     protected $_oParentProd = null;
00025 
00031     protected $_blEditTags = null;
00032 
00038     protected $_aTags = null;
00039 
00045     protected $_oCaptcha = null;
00046 
00052     protected $_sParentName = null;
00053 
00059     protected $_sParentUrl = null;
00060 
00066     protected $_aPicGallery = null;
00067 
00073     protected $_aSelectLists = null;
00074 
00080     protected $_aReviews = null;
00081 
00087     protected $_oCrossSelling = null;
00088 
00094     protected $_oSimilarProducts = null;
00095 
00101     protected $_oAccessoires = null;
00102 
00108     protected $_aAlsoBoughtArts = null;
00109 
00115     protected $_sSearchTitle = null;
00116 
00123     protected $_blIsInitialized = false;
00124 
00130     protected $_iLinkType = null;
00131 
00137     protected $_sBidPrice = null;
00138 
00144     protected $_iPriceAlarmStatus = null;
00145 
00151     protected $_sSearchParamForHtml = null;
00152 
00158     protected $_aSimilarRecommListIds = null;
00159 
00160 
00166     protected $_blShowSorting = true;
00167 
00175     protected function _getParentProduct($sParentId)
00176     {
00177         if ($sParentId && $this->_oParentProd === null) {
00178             $this->_oParentProd = false;
00179             $oProduct = oxNew('oxArticle');
00180             if (($oProduct->load($sParentId))) {
00181                 $this->_processProduct($oProduct);
00182                 $this->_oParentProd = $oProduct;
00183             }
00184         }
00185 
00186         return $this->_oParentProd;
00187     }
00188 
00194     protected function _getAddUrlParams()
00195     {
00196         if ($this->getListType() == "search") {
00197             return $this->getDynUrlParams();
00198         }
00199     }
00200 
00209     public function getNavigationParams()
00210     {
00211         $aParams = parent::getNavigationParams();
00212 
00213         $aVarSelParams = oxRegistry::getConfig()->getRequestParameter('varselid');
00214         $aSelectListParams = oxRegistry::getConfig()->getRequestParameter('sel');
00215         if (!$aVarSelParams && !$aSelectListParams) {
00216             return $aParams;
00217         }
00218 
00219         if ($aVarSelParams) {
00220             foreach ($aVarSelParams as $iKey => $sValue) {
00221                 $aParams["varselid[$iKey]"] = $sValue;
00222             }
00223         }
00224 
00225         if ($aSelectListParams) {
00226             foreach ($aSelectListParams as $iKey => $sValue) {
00227                 $aParams["sel[$iKey]"] = $sValue;
00228             }
00229         }
00230 
00231         return $aParams;
00232     }
00233 
00234 
00240     protected function _processProduct($oProduct)
00241     {
00242         $oProduct->setLinkType($this->getLinkType());
00243         if ($sAddParams = $this->_getAddUrlParams()) {
00244             $oProduct->appendLink($sAddParams);
00245         }
00246     }
00247 
00253     public function getViewId()
00254     {
00255         if (isset($this->_sViewId)) {
00256             return $this->_sViewId;
00257         }
00258 
00259         $sViewId = parent::getViewId() . '|' . $this->getConfig()->getRequestParameter('anid') . '|';
00260 
00261 
00262         return $this->_sViewId = $sViewId;
00263     }
00264 
00265 
00277     public function render()
00278     {
00279         $myConfig = $this->getConfig();
00280 
00281         $oProduct = $this->getProduct();
00282 
00283         // assign template name
00284         if ($oProduct->oxarticles__oxtemplate->value) {
00285             $this->_sThisTemplate = $oProduct->oxarticles__oxtemplate->value;
00286         }
00287 
00288         if (($sTplName = oxRegistry::getConfig()->getRequestParameter('tpl'))) {
00289             $this->_sThisTemplate = 'custom/' . basename($sTplName);
00290         }
00291 
00292         parent::render();
00293 
00294         $sPartial = $this->getConfig()->getRequestParameter('renderPartial');
00295         $this->addTplParam('renderPartial', $sPartial);
00296 
00297         switch ($sPartial) {
00298             case "productInfo":
00299                 return 'page/details/ajax/fullproductinfo.tpl';
00300                 break;
00301             case "detailsMain":
00302                 return 'page/details/ajax/productmain.tpl';
00303                 break;
00304             default:
00305                 // can not be removed, as it is used for breadcrumb loading
00306                 $oLocator = oxNew('oxLocator', $this->getListType());
00307                 $oLocator->setLocatorData($oProduct, $this);
00308 
00309                 if ($myConfig->getConfigParam('bl_rssRecommLists') && $this->getSimilarRecommListIds()) {
00310                     $oRss = oxNew('oxRssFeed');
00311                     $sTitle = $oRss->getRecommListsTitle($oProduct);
00312                     $sUrl = $oRss->getRecommListsUrl($oProduct);
00313                     $this->addRssFeed($sTitle, $sUrl, 'recommlists');
00314                 }
00315 
00316                 return $this->_sThisTemplate;
00317         }
00318     }
00319 
00331     protected function _prepareMetaDescription($sMeta, $iLength = 200, $blDescTag = false)
00332     {
00333         if (!$sMeta) {
00334             $oProduct = $this->getProduct();
00335 
00336             if ($this->getConfig()->getConfigParam('bl_perfParseLongDescinSmarty')) {
00337                 $sMeta = $oProduct->getLongDesc();
00338             } else {
00339                 $sMeta = $oProduct->getLongDescription()->value;
00340             }
00341             if ($sMeta == '') {
00342                 $sMeta = $oProduct->oxarticles__oxshortdesc->value;
00343             }
00344             $sMeta = $oProduct->oxarticles__oxtitle->value . ' - ' . $sMeta;
00345         }
00346 
00347         return parent::_prepareMetaDescription($sMeta, $iLength, $blDescTag);
00348     }
00349 
00360     protected function _prepareMetaKeyword($sKeywords, $blRemoveDuplicatedWords = true)
00361     {
00362         if (!$sKeywords) {
00363             $oProduct = $this->getProduct();
00364             $sKeywords = trim($this->getTitle());
00365 
00366             if ($oCatTree = $this->getCategoryTree()) {
00367                 foreach ($oCatTree->getPath() as $oCat) {
00368                     $sKeywords .= ", " . trim($oCat->oxcategories__oxtitle->value);
00369                 }
00370             }
00371 
00372             //adding search keys info
00373             if ($sSearchKeys = trim($oProduct->oxarticles__oxsearchkeys->value)) {
00374                 $sKeywords .= ", " . $sSearchKeys;
00375             }
00376 
00377             $sKeywords = parent::_prepareMetaKeyword($sKeywords, $blRemoveDuplicatedWords);
00378         }
00379 
00380         return $sKeywords;
00381     }
00382 
00388     public function saveReview()
00389     {
00390         if (!oxRegistry::getSession()->checkSessionChallenge()) {
00391             return;
00392         }
00393 
00394         if ($this->canAcceptFormData() &&
00395             ($oUser = $this->getUser()) && ($oProduct = $this->getProduct())
00396         ) {
00397 
00398             $dRating = $this->getConfig()->getRequestParameter('artrating');
00399             if ($dRating !== null) {
00400                 $dRating = (int) $dRating;
00401             }
00402 
00403             //save rating
00404             if ($dRating !== null && $dRating >= 1 && $dRating <= 5) {
00405                 $oRating = oxNew('oxrating');
00406                 if ($oRating->allowRating($oUser->getId(), 'oxarticle', $oProduct->getId())) {
00407                     $oRating->oxratings__oxuserid = new oxField($oUser->getId());
00408                     $oRating->oxratings__oxtype = new oxField('oxarticle');
00409                     $oRating->oxratings__oxobjectid = new oxField($oProduct->getId());
00410                     $oRating->oxratings__oxrating = new oxField($dRating);
00411                     $oRating->save();
00412                     $oProduct->addToRatingAverage($dRating);
00413                 }
00414             }
00415 
00416             if (($sReviewText = trim(( string ) $this->getConfig()->getRequestParameter('rvw_txt', true)))) {
00417                 $oReview = oxNew('oxReview');
00418                 $oReview->oxreviews__oxobjectid = new oxField($oProduct->getId());
00419                 $oReview->oxreviews__oxtype = new oxField('oxarticle');
00420                 $oReview->oxreviews__oxtext = new oxField($sReviewText, oxField::T_RAW);
00421                 $oReview->oxreviews__oxlang = new oxField(oxRegistry::getLang()->getBaseLanguage());
00422                 $oReview->oxreviews__oxuserid = new oxField($oUser->getId());
00423                 $oReview->oxreviews__oxrating = new oxField(($dRating !== null) ? $dRating : 0);
00424                 $oReview->save();
00425             }
00426         }
00427     }
00428 
00434     public function addToRecomm()
00435     {
00436         if (!oxRegistry::getSession()->checkSessionChallenge()) {
00437             return;
00438         }
00439 
00440         if (!$this->getViewConfig()->getShowListmania()) {
00441             return;
00442         }
00443 
00444         $sRecommText = trim(( string ) $this->getConfig()->getRequestParameter('recomm_txt'));
00445         $sRecommList = $this->getConfig()->getRequestParameter('recomm');
00446         $sArtId = $this->getProduct()->getId();
00447 
00448         if ($sArtId) {
00449             $oRecomm = oxNew('oxrecommlist');
00450             $oRecomm->load($sRecommList);
00451             $oRecomm->addArticle($sArtId, $sRecommText);
00452         }
00453     }
00454 
00460     public function addTags()
00461     {
00462         if (!oxRegistry::getSession()->checkSessionChallenge()) {
00463             return;
00464         }
00465 
00466         $sTags = $this->getConfig()->getRequestParameter('newTags', true);
00467         $sHighTag = $this->getConfig()->getRequestParameter('highTags', true);
00468         if (!$sTags && !$sHighTag) {
00469             return;
00470         }
00471         if ($sHighTag) {
00472             $sTags = getStr()->html_entity_decode($sHighTag);
00473         }
00474         $oProduct = $this->getProduct();
00475 
00476         // set current user added tags for this article for later checking
00477         $aTaggedProducts = oxRegistry::getSession()->getVariable("aTaggedProducts");
00478         $aAddedTags = $aTaggedProducts ? $aTaggedProducts[$oProduct->getId()] : array();
00479 
00480         $oArticleTagList = oxNew("oxArticleTagList");
00481         $oArticleTagList->load($oProduct->getId());
00482         $sSeparator = $oArticleTagList->get()->getSeparator();
00483         $aTags = array_unique(explode($sSeparator, $sTags));
00484 
00485         $aResult = $this->_addTagsToList($oArticleTagList, $aTags, $aAddedTags);
00486 
00487         if (!empty($aResult['tags'])) {
00488             $oArticleTagList->save();
00489             foreach ($aResult['tags'] as $sTag) {
00490                 $aAddedTags[$sTag] = 1;
00491             }
00492             $aTaggedProducts[$oProduct->getId()] = $aAddedTags;
00493             oxRegistry::getSession()->setVariable('aTaggedProducts', $aTaggedProducts);
00494         }
00495         // for ajax call
00496         if ($this->getConfig()->getRequestParameter('blAjax', true)) {
00497             oxRegistry::getUtils()->showMessageAndExit(json_encode($aResult));
00498         }
00499     }
00500 
00510     protected function _addTagsToList($oArticleTagList, $aTags, $aAddedTags)
00511     {
00512         $aResult = array('tags' => array(), 'invalid' => array(), 'inlist' => array());
00513 
00514         foreach ($aTags as $sTag) {
00515             $oTag = oxNew("oxtag", $sTag);
00516             if ($aAddedTags[$oTag->get()] != 1) {
00517                 if ($oTag->isValid()) {
00518                     $oArticleTagList->addTag($oTag);
00519                     $aResult['tags'][] = $oTag->get();
00520                 } else {
00521                     $aResult['invalid'][] = $oTag->get();
00522                 }
00523             } else {
00524                 $aResult['inlist'][] = $oTag->get();
00525             }
00526         }
00527 
00528         return $aResult;
00529     }
00530 
00536     public function editTags()
00537     {
00538         if (!$this->getUser()) {
00539             return;
00540         }
00541         $oArticleTagList = oxNew("oxArticleTagList");
00542         $oArticleTagList->load($this->getProduct()->getId());
00543         $oTagSet = $oArticleTagList->get();
00544         $this->_aTags = $oTagSet->get();
00545         $this->_blEditTags = true;
00546 
00547         // for ajax call
00548         if ($this->getConfig()->getRequestParameter('blAjax', true)) {
00549             $sCharset = oxRegistry::getLang()->translateString('charset');
00550             oxRegistry::getUtils()->setHeader("Content-Type: text/html; charset=" . $sCharset);
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(
00556                 $oSmarty->fetch('page/details/inc/editTags.tpl', $this->getViewId())
00557             );
00558         }
00559     }
00560 
00564     public function cancelTags()
00565     {
00566         $oArticleTagList = oxNew("oxArticleTagList");
00567         $oArticleTagList->load($this->getProduct()->getId());
00568         $oTagSet = $oArticleTagList->get();
00569         $this->_aTags = $oTagSet->get();
00570         $this->_blEditTags = false;
00571 
00572         // for ajax call
00573         if (oxRegistry::getConfig()->getRequestParameter('blAjax', true)) {
00574             $sCharset = oxRegistry::getLang()->translateString('charset');
00575             oxRegistry::getUtils()->setHeader("Content-Type: text/html; charset=" . $sCharset);
00576             $oActView = oxNew('oxubase');
00577             $oSmarty = oxRegistry::get("oxUtilsView")->getSmarty();
00578             $oSmarty->assign('oView', $this);
00579             $oSmarty->assign('oViewConf', $this->getViewConfig());
00580             oxRegistry::getUtils()->showMessageAndExit(
00581                 $oSmarty->fetch('page/details/inc/tags.tpl', $this->getViewId())
00582             );
00583         }
00584     }
00585 
00591     protected function _getSeoObjectId()
00592     {
00593         if ($oProduct = $this->getProduct()) {
00594             return $oProduct->getId();
00595         }
00596     }
00597 
00603     public function getEditTags()
00604     {
00605         return $this->_blEditTags;
00606     }
00607 
00613     public function getTags()
00614     {
00615         return $this->_aTags;
00616     }
00617 
00623     public function getProduct()
00624     {
00625         $oConfig = $this->getConfig();
00626         $oUtils = oxRegistry::getUtils();
00627 
00628         if ($this->_oProduct === null) {
00629 
00630             //this option is only for lists and we must reset value
00631             //as blLoadVariants = false affect "ab price" functionality
00632             $oConfig->setConfigParam('blLoadVariants', true);
00633 
00634             $sOxid = $this->getConfig()->getRequestParameter('anid');
00635 
00636             // object is not yet loaded
00637             $this->_oProduct = oxNew('oxarticle');
00638 
00639             if (!$this->_oProduct->load($sOxid)) {
00640                 $oUtils->redirect($oConfig->getShopHomeURL());
00641                 $oUtils->showMessageAndExit('');
00642             }
00643 
00644             $sVarSelIdParameter = $this->getConfig()->getRequestParameter("varselid");
00645             $aVariantSelections = $this->_oProduct->getVariantSelections($sVarSelIdParameter);
00646             if ($aVariantSelections && $aVariantSelections['oActiveVariant'] && $aVariantSelections['blPerfectFit']) {
00647                 $this->_oProduct = $aVariantSelections['oActiveVariant'];
00648             }
00649         }
00650 
00651         // additional checks
00652         if (!$this->_blIsInitialized) {
00653             $this->_additionalChecksForArticle();
00654         }
00655 
00656         return $this->_oProduct;
00657     }
00658 
00662     protected function _additionalChecksForArticle()
00663     {
00664         $oConfig = $this->getConfig();
00665         $oUtils = oxRegistry::getUtils();
00666 
00667         $blContinue = true;
00668         if (!$this->_oProduct->isVisible()) {
00669             $blContinue = false;
00670         } elseif ($this->_oProduct->oxarticles__oxparentid->value) {
00671             $oParent = $this->_getParentProduct($this->_oProduct->oxarticles__oxparentid->value);
00672             if (!$oParent || !$oParent->isVisible()) {
00673                 $blContinue = false;
00674             }
00675         }
00676 
00677         if (!$blContinue) {
00678             $oUtils->redirect($oConfig->getShopHomeURL());
00679             $oUtils->showMessageAndExit('');
00680         }
00681 
00682         $this->_processProduct($this->_oProduct);
00683         $this->_blIsInitialized = true;
00684     }
00685 
00691     public function getLinkType()
00692     {
00693         if ($this->_iLinkType === null) {
00694             $sListType = $this->getConfig()->getRequestParameter('listtype');
00695             if ('vendor' == $sListType) {
00696                 $this->_iLinkType = OXARTICLE_LINKTYPE_VENDOR;
00697             } elseif ('manufacturer' == $sListType) {
00698                 $this->_iLinkType = OXARTICLE_LINKTYPE_MANUFACTURER;
00699             } elseif ('tag' == $sListType) {
00700                 $this->_iLinkType = OXARTICLE_LINKTYPE_TAG;
00701             } elseif ('recommlist' == $sListType) {
00702                 $this->_iLinkType = OXARTICLE_LINKTYPE_RECOMM;
00703             } else {
00704                 $this->_iLinkType = OXARTICLE_LINKTYPE_CATEGORY;
00705 
00706                 // price category has own type..
00707                 if (($oCat = $this->getActiveCategory()) && $oCat->isPriceCategory()) {
00708                     $this->_iLinkType = OXARTICLE_LINKTYPE_PRICECATEGORY;
00709                 }
00710             }
00711         }
00712 
00713         return $this->_iLinkType;
00714     }
00715 
00721     public function drawParentUrl()
00722     {
00723         return $this->getProduct()->isVariant();
00724     }
00725 
00733     public function getParentName()
00734     {
00735         if ($this->_sParentName === null) {
00736             $this->_sParentName = false;
00737             if (($oParent = $this->_getParentProduct($this->getProduct()->oxarticles__oxparentid->value))) {
00738                 $this->_sParentName = $oParent->oxarticles__oxtitle->value;
00739             }
00740         }
00741 
00742         return $this->_sParentName;
00743     }
00744 
00752     public function getParentUrl()
00753     {
00754         if ($this->_sParentUrl === null) {
00755             $this->_sParentUrl = false;
00756             if (($oParent = $this->_getParentProduct($this->getProduct()->oxarticles__oxparentid->value))) {
00757                 $this->_sParentUrl = $oParent->getLink();
00758             }
00759         }
00760 
00761         return $this->_sParentUrl;
00762     }
00763 
00769     public function getPictureGallery()
00770     {
00771         if ($this->_aPicGallery === null) {
00772             //get picture gallery
00773             $this->_aPicGallery = $this->getPicturesProduct()->getPictureGallery();
00774         }
00775 
00776         return $this->_aPicGallery;
00777     }
00778 
00784     public function getActPictureId()
00785     {
00786         $aPicGallery = $this->getPictureGallery();
00787 
00788         return $aPicGallery['ActPicID'];
00789     }
00790 
00796     public function getActPicture()
00797     {
00798         $aPicGallery = $this->getPictureGallery();
00799 
00800         return $aPicGallery['ActPic'];
00801     }
00802 
00808     public function getPictures()
00809     {
00810         $aPicGallery = $this->getPictureGallery();
00811 
00812         return $aPicGallery['Pics'];
00813     }
00814 
00822     public function getArtPic($sPicNr)
00823     {
00824         $aPicGallery = $this->getPictureGallery();
00825 
00826         return $aPicGallery['Pics'][$sPicNr];
00827     }
00828 
00834     public function getSelectLists()
00835     {
00836         if ($this->_aSelectLists === null) {
00837             $this->_aSelectLists = false;
00838             if ($this->getConfig()->getConfigParam('bl_perfLoadSelectLists')) {
00839                 $this->_aSelectLists = $this->getProduct()->getSelectLists();
00840             }
00841         }
00842 
00843         return $this->_aSelectLists;
00844     }
00845 
00851     public function getReviews()
00852     {
00853         if ($this->_aReviews === null) {
00854             $this->_aReviews = false;
00855             if ($this->getConfig()->getConfigParam('bl_perfLoadReviews')) {
00856                 $this->_aReviews = $this->getProduct()->getReviews();
00857             }
00858         }
00859 
00860         return $this->_aReviews;
00861     }
00862 
00868     public function getCrossSelling()
00869     {
00870         if ($this->_oCrossSelling === null) {
00871             $this->_oCrossSelling = false;
00872             if ($oProduct = $this->getProduct()) {
00873                 $this->_oCrossSelling = $oProduct->getCrossSelling();
00874             }
00875         }
00876 
00877         return $this->_oCrossSelling;
00878     }
00879 
00885     public function getSimilarProducts()
00886     {
00887         if ($this->_oSimilarProducts === null) {
00888             $this->_oSimilarProducts = false;
00889             if ($oProduct = $this->getProduct()) {
00890                 $this->_oSimilarProducts = $oProduct->getSimilarProducts();
00891             }
00892         }
00893 
00894         return $this->_oSimilarProducts;
00895     }
00896 
00902     public function getSimilarRecommListIds()
00903     {
00904         if ($this->_aSimilarRecommListIds === null) {
00905             $this->_aSimilarRecommListIds = false;
00906 
00907             if ($oProduct = $this->getProduct()) {
00908                 $this->_aSimilarRecommListIds = array($oProduct->getId());
00909             }
00910         }
00911 
00912         return $this->_aSimilarRecommListIds;
00913     }
00914 
00920     public function getAccessoires()
00921     {
00922         if ($this->_oAccessoires === null) {
00923             $this->_oAccessoires = false;
00924             if ($oProduct = $this->getProduct()) {
00925                 $this->_oAccessoires = $oProduct->getAccessoires();
00926             }
00927         }
00928 
00929         return $this->_oAccessoires;
00930     }
00931 
00937     public function getAlsoBoughtTheseProducts()
00938     {
00939         if ($this->_aAlsoBoughtArts === null) {
00940             $this->_aAlsoBoughtArts = false;
00941             if ($oProduct = $this->getProduct()) {
00942                 $this->_aAlsoBoughtArts = $oProduct->getCustomerAlsoBoughtThisProducts();
00943             }
00944         }
00945 
00946         return $this->_aAlsoBoughtArts;
00947     }
00948 
00954     public function isPriceAlarm()
00955     {
00956         // #419 disabling price alarm if article has fixed price
00957         $oProduct = $this->getProduct();
00958         if (isset($oProduct->oxarticles__oxblfixedprice->value) && $oProduct->oxarticles__oxblfixedprice->value) {
00959             return 0;
00960         }
00961 
00962         return 1;
00963     }
00964 
00973     protected function _getSubject($iLang)
00974     {
00975         return $this->getProduct();
00976     }
00977 
00983     public function getSearchTitle()
00984     {
00985         return $this->_sSearchTitle;
00986     }
00987 
00993     public function setSearchTitle($sTitle)
00994     {
00995         $this->_sSearchTitle = $sTitle;
00996     }
00997 
01003     public function setCatTreePath($sActCatPath)
01004     {
01005         $this->_sCatTreePath = $sActCatPath;
01006     }
01007 
01014     public function noIndex()
01015     {
01016         $sListType = $this->getConfig()->getRequestParameter('listtype');
01017         if ($sListType && ('vendor' == $sListType || 'manufacturer' == $sListType)) {
01018             return $this->_iViewIndexState = VIEW_INDEXSTATE_NOINDEXFOLLOW;
01019         }
01020 
01021         return parent::noIndex();
01022     }
01023 
01029     public function getTitle()
01030     {
01031         if ($oProduct = $this->getProduct()) {
01032             $sTag = $this->getTag();
01033             $sTitleField = 'oxarticles__oxtitle';
01034             $sVarSelField = 'oxarticles__oxvarselect';
01035 
01036             $sVarSelValue = $oProduct->$sVarSelField->value ? ' ' . $oProduct->$sVarSelField->value : '';
01037             $sTagValue = !empty($sTag) ? ' - ' . $sTag : '';
01038 
01039             return $oProduct->$sTitleField->value . $sVarSelValue . $sTagValue;
01040         }
01041     }
01042 
01048     public function getMetaDescription()
01049     {
01050         $sMeta = parent::getMetaDescription();
01051 
01052         if ($sTag = $this->getTag()) {
01053             $sMeta = $sTag . ' - ' . $sMeta;
01054         }
01055 
01056         return $sMeta;
01057     }
01058 
01064     public function getTag()
01065     {
01066         return oxRegistry::getConfig()->getRequestParameter("searchtag");
01067     }
01068 
01074     public function getCanonicalUrl()
01075     {
01076         if (($oProduct = $this->getProduct())) {
01077             if ($oProduct->oxarticles__oxparentid->value) {
01078                 $oProduct = $this->_getParentProduct($oProduct->oxarticles__oxparentid->value);
01079             }
01080 
01081             $oUtils = oxRegistry::get("oxUtilsUrl");
01082             if (oxRegistry::getUtils()->seoIsActive()) {
01083                 $sUrl = $oUtils->prepareCanonicalUrl($oProduct->getBaseSeoLink($oProduct->getLanguage(), true));
01084             } else {
01085                 $sUrl = $oUtils->prepareCanonicalUrl($oProduct->getBaseStdLink($oProduct->getLanguage()));
01086             }
01087 
01088             return $sUrl;
01089         }
01090     }
01091 
01097     public function getBreadCrumb()
01098     {
01099         if ('search' == $this->getListType()) {
01100             $aPaths = $this->_getSearchBreadCrumb();
01101         } elseif ('tag' == $this->getListType()) {
01102             $aPaths = $this->_getTagBreadCrumb();
01103         } elseif ('recommlist' == $this->getListType()) {
01104             $aPaths = $this->_getRecommendationListBredCrumb();
01105         } elseif ('vendor' == $this->getListType()) {
01106             $aPaths = $this->_getVendorBreadCrumb();
01107         } else {
01108             $aPaths = $this->_getCategoryBreadCrumb();
01109         }
01110 
01111         return $aPaths;
01112     }
01113 
01119     public function getCaptcha()
01120     {
01121         if ($this->_oCaptcha === null) {
01122             $this->_oCaptcha = oxNew('oxCaptcha');
01123         }
01124 
01125         return $this->_oCaptcha;
01126     }
01127 
01137     public function addme()
01138     {
01139         $myConfig = $this->getConfig();
01140         $myUtils = oxRegistry::getUtils();
01141 
01142         //control captcha
01143         $sMac = $this->getConfig()->getRequestParameter('c_mac');
01144         $sMacHash = $this->getConfig()->getRequestParameter('c_mach');
01145         $oCaptcha = $this->getCaptcha();
01146         if (!$oCaptcha->pass($sMac, $sMacHash)) {
01147             $this->_iPriceAlarmStatus = 2;
01148 
01149             return;
01150         }
01151 
01152         $aParams = $this->getConfig()->getRequestParameter('pa');
01153         if (!isset($aParams['email']) || !$myUtils->isValidEmail($aParams['email'])) {
01154             $this->_iPriceAlarmStatus = 0;
01155 
01156             return;
01157         }
01158         $aParams['aid'] = $this->getProduct()->getId();
01159         $oCur = $myConfig->getActShopCurrencyObject();
01160         // convert currency to default
01161         $dPrice = $myUtils->currency2Float($aParams['price']);
01162 
01163         $oAlarm = oxNew("oxPriceAlarm");
01164         $oAlarm->oxpricealarm__oxuserid = new oxField(oxRegistry::getSession()->getVariable('usr'));
01165         $oAlarm->oxpricealarm__oxemail = new oxField($aParams['email']);
01166         $oAlarm->oxpricealarm__oxartid = new oxField($aParams['aid']);
01167         $oAlarm->oxpricealarm__oxprice = new oxField($myUtils->fRound($dPrice, $oCur));
01168         $oAlarm->oxpricealarm__oxshopid = new oxField($myConfig->getShopId());
01169         $oAlarm->oxpricealarm__oxcurrency = new oxField($oCur->name);
01170 
01171         $oAlarm->oxpricealarm__oxlang = new oxField(oxRegistry::getLang()->getBaseLanguage());
01172 
01173         $oAlarm->save();
01174 
01175         // Send Email
01176         $oEmail = oxNew('oxEmail');
01177         $this->_iPriceAlarmStatus = (int) $oEmail->sendPricealarmNotification($aParams, $oAlarm);
01178     }
01179 
01185     public function getPriceAlarmStatus()
01186     {
01187         return $this->_iPriceAlarmStatus;
01188     }
01189 
01195     public function getBidPrice()
01196     {
01197         if ($this->_sBidPrice === null) {
01198             $this->_sBidPrice = false;
01199 
01200             $aParams = $this->getConfig()->getRequestParameter('pa');
01201             $oCur = $this->getConfig()->getActShopCurrencyObject();
01202             $iPrice = oxRegistry::getUtils()->currency2Float($aParams['price']);
01203             $this->_sBidPrice = oxRegistry::getLang()->formatCurrency($iPrice, $oCur);
01204         }
01205 
01206         return $this->_sBidPrice;
01207     }
01208 
01214     public function getVariantSelections()
01215     {
01216         // finding parent
01217         $oProduct = $this->getProduct();
01218         $sVarSelParameter = $this->getConfig()->getRequestParameter("varselid");
01219         $sParentIdField = 'oxarticles__oxparentid';
01220         if (($oParent = $this->_getParentProduct($oProduct->$sParentIdField->value))) {
01221             return $oParent->getVariantSelections($sVarSelParameter, $oProduct->getId());
01222         }
01223 
01224         return $oProduct->getVariantSelections($sVarSelParameter);
01225     }
01226 
01232     public function getPicturesProduct()
01233     {
01234         $aVariantSelections = $this->getVariantSelections();
01235         if ($aVariantSelections && $aVariantSelections['oActiveVariant'] && !$aVariantSelections['blPerfectFit']) {
01236             return $aVariantSelections['oActiveVariant'];
01237         }
01238 
01239         return $this->getProduct();
01240     }
01241 
01247     public function getSearchParamForHtml()
01248     {
01249         if ($this->_sSearchParamForHtml === null) {
01250             $this->_sSearchParamForHtml = $this->getConfig()->getRequestParameter('searchparam');
01251         }
01252 
01253         return $this->_sSearchParamForHtml;
01254     }
01255 
01261     public function showRdfa()
01262     {
01263         return $this->getConfig()->getConfigParam('blRDFaEmbedding');
01264     }
01265 
01271     public function getRDFaNormalizedRating()
01272     {
01273         $myConfig = $this->getConfig();
01274         $iMin = $myConfig->getConfigParam("iRDFaMinRating");
01275         $iMax = $myConfig->getConfigParam("iRDFaMaxRating");
01276 
01277         $oProduct = $this->getProduct();
01278         $iCount = $oProduct->oxarticles__oxratingcnt->value;
01279         if (isset($iMin) && isset($iMax) && $iMax != '' && $iMin != '' && $iCount > 0) {
01280             $aNormalizedRating = array();
01281             $iValue = ((4 * ($oProduct->oxarticles__oxrating->value - $iMin) / ($iMax - $iMin))) + 1;
01282             $aNormalizedRating["count"] = $iCount;
01283             $aNormalizedRating["value"] = round($iValue, 2);
01284 
01285             return $aNormalizedRating;
01286         }
01287 
01288         return false;
01289     }
01290 
01298     public function getRDFaValidityPeriod($sShopConfVar)
01299     {
01300         if ($sShopConfVar) {
01301             $aValidity = array();
01302             $iDays = $this->getConfig()->getConfigParam($sShopConfVar);
01303             $iFrom = oxRegistry::get("oxUtilsDate")->getTime();
01304 
01305             $iThrough = $iFrom + ($iDays * 24 * 60 * 60);
01306             $aValidity["from"] = date('Y-m-d\TH:i:s', $iFrom) . "Z";
01307             $aValidity["through"] = date('Y-m-d\TH:i:s', $iThrough) . "Z";
01308 
01309             return $aValidity;
01310         }
01311 
01312         return false;
01313     }
01314 
01320     public function getRDFaBusinessFnc()
01321     {
01322         return $this->getConfig()->getConfigParam("sRDFaBusinessFnc");
01323     }
01324 
01330     public function getRDFaCustomers()
01331     {
01332         return $this->getConfig()->getConfigParam("aRDFaCustomers");
01333     }
01334 
01340     public function getRDFaVAT()
01341     {
01342         return $this->getConfig()->getConfigParam("iRDFaVAT");
01343     }
01344 
01350     public function getRDFaGenericCondition()
01351     {
01352         return $this->getConfig()->getConfigParam("iRDFaCondition");
01353     }
01354 
01360     public function getBundleArticle()
01361     {
01362         $oProduct = $this->getProduct();
01363         if ($oProduct && $oProduct->oxarticles__oxbundleid->value) {
01364             $oArticle = oxNew("oxArticle");
01365             $oArticle->load($oProduct->oxarticles__oxbundleid->value);
01366 
01367             return $oArticle;
01368         }
01369 
01370         return false;
01371     }
01372 
01373 
01379     public function getRDFaPaymentMethods()
01380     {
01381         $iPrice = $this->getProduct()->getPrice()->getBruttoPrice();
01382         $oPayments = oxNew("oxPaymentList");
01383         $oPayments->loadRDFaPaymentList($iPrice);
01384 
01385         return $oPayments;
01386     }
01387 
01393     public function getRDFaDeliverySetMethods()
01394     {
01395         $oDelSets = oxNew("oxDeliverySetList");
01396         $oDelSets->loadRDFaDeliverySetList();
01397 
01398         return $oDelSets;
01399     }
01400 
01406     public function getProductsDeliveryList()
01407     {
01408         $oProduct = $this->getProduct();
01409         $oDelList = oxNew("oxDeliveryList");
01410         $oDelList->loadDeliveryListForProduct($oProduct);
01411 
01412         return $oDelList;
01413     }
01414 
01420     public function getRDFaDeliveryChargeSpecLoc()
01421     {
01422         return $this->getConfig()->getConfigParam("sRDFaDeliveryChargeSpecLoc");
01423     }
01424 
01430     public function getRDFaPaymentChargeSpecLoc()
01431     {
01432         return $this->getConfig()->getConfigParam("sRDFaPaymentChargeSpecLoc");
01433     }
01434 
01440     public function getRDFaBusinessEntityLoc()
01441     {
01442         return $this->getConfig()->getConfigParam("sRDFaBusinessEntityLoc");
01443     }
01444 
01450     public function showRDFaProductStock()
01451     {
01452         return $this->getConfig()->getConfigParam("blShowRDFaProductStock");
01453     }
01454 
01460     public function canChangeTags()
01461     {
01462         if ($oUser = $this->getUser()) {
01463 
01464             return true;
01465         }
01466 
01467         return false;
01468     }
01469 
01475     public function getTagCloudManager()
01476     {
01478         $oTagList = oxNew("oxArticleTagList");
01479         //$oTagList->load($this->getProduct()->getId());
01480         $oTagList->setArticleId($this->getProduct()->getId());
01481         $oTagCloud = oxNew("oxTagCloud");
01482         $oTagCloud->setTagList($oTagList);
01483         $oTagCloud->setExtendedMode(true);
01484 
01485         return $oTagCloud;
01486     }
01487 
01493     public function showZoomPics()
01494     {
01495         $aPicGallery = $this->getPictureGallery();
01496 
01497         return $aPicGallery['ZoomPic'];
01498     }
01499 
01505     public function isReviewActive()
01506     {
01507         return $this->getConfig()->getConfigParam('bl_perfLoadReviews');
01508     }
01509 
01515     public function getDefaultSorting()
01516     {
01517         $aSorting = parent::getDefaultSorting();
01518         $oCategory = $this->getActiveCategory();
01519 
01520         if ($this->getListType() != 'search' && $oCategory && $oCategory instanceof oxCategory) {
01521             if ($sSortBy = $oCategory->getDefaultSorting()) {
01522                 $sSortDir = ($oCategory->getDefaultSortingMode()) ? "desc" : "asc";
01523                 $aSorting = array('sortby' => $sSortBy, 'sortdir' => $sSortDir);
01524             }
01525         }
01526 
01527         return $aSorting;
01528     }
01529 
01535     public function getSortingParameters()
01536     {
01537         $aSorting = $this->getSorting($this->getSortIdent());
01538         if (!is_array($aSorting)) {
01539             return null;
01540         }
01541 
01542         return implode('|', $aSorting);
01543     }
01544 
01550     protected function _getVendorBreadCrumb()
01551     {
01552         $aPaths = array();
01553         $aCatPath = array();
01554 
01555         $oCat = oxNew('oxVendor');
01556         $oCat->load('root');
01557 
01558         $aCatPath['link'] = $oCat->getLink();
01559         $aCatPath['title'] = $oCat->oxvendor__oxtitle->value;
01560         $aPaths[] = $aCatPath;
01561 
01562         $oCat = $this->getActVendor();
01563         $aCatPath['link'] = $oCat->getLink();
01564         $aCatPath['title'] = $oCat->oxvendor__oxtitle->value;
01565         $aPaths[] = $aCatPath;
01566 
01567         return $aPaths;
01568     }
01569 
01575     protected function _getRecommendationListBredCrumb()
01576     {
01577         $aPaths = array();
01578         $aCatPath = array();
01579         $iBaseLanguage = oxRegistry::getLang()->getBaseLanguage();
01580         $aCatPath['title'] = oxRegistry::getLang()->translateString('LISTMANIA', $iBaseLanguage, false);
01581         $aPaths[] = $aCatPath;
01582 
01583         return $aPaths;
01584     }
01585 
01591     protected function _getTagBreadCrumb()
01592     {
01593         $aPaths = array();
01594 
01595         $aCatPath = array();
01596 
01597         $iBaseLanguage = oxRegistry::getLang()->getBaseLanguage();
01598         $sSelfLink = $this->getViewConfig()->getSelfLink();
01599 
01600         $aCatPath['title'] = oxRegistry::getLang()->translateString('TAGS', $iBaseLanguage, false);
01601         $aCatPath['link'] = oxRegistry::get("oxSeoEncoder")->getStaticUrl($sSelfLink . 'cl=tags');
01602         $aPaths[] = $aCatPath;
01603 
01604         $sSearchTagParameter = oxRegistry::getConfig()->getRequestParameter('searchtag');
01605         $oStr = getStr();
01606         $aCatPath['title'] = $oStr->ucfirst($sSearchTagParameter);
01607         $aCatPath['link'] = oxRegistry::get("oxSeoEncoderTag")->getTagUrl($sSearchTagParameter);
01608         $aPaths[] = $aCatPath;
01609 
01610         return $aPaths;
01611     }
01612 
01618     protected function _getSearchBreadCrumb()
01619     {
01620         $aPaths = array();
01621         $aCatPath = array();
01622 
01623         $iBaseLanguage = oxRegistry::getLang()->getBaseLanguage();
01624         $sTranslatedString = oxRegistry::getLang()->translateString('SEARCH_RESULT', $iBaseLanguage, false);
01625         $sSelfLink = $this->getViewConfig()->getSelfLink();
01626         $sSessionToken = oxRegistry::getSession()->getVariable('sess_stoken');
01627 
01628         $aCatPath['title'] = sprintf($sTranslatedString, $this->getSearchParamForHtml());
01629         $aCatPath['link'] = $sSelfLink . 'stoken=' . $sSessionToken . "&amp;cl=search&amp;".
01630                             "searchparam=" . $this->getSearchParamForHtml();
01631 
01632         $aPaths[] = $aCatPath;
01633 
01634         return $aPaths;
01635     }
01636 
01642     protected function _getCategoryBreadCrumb()
01643     {
01644         $aPaths = array();
01645 
01646         $oCatTree = $this->getCatTreePath();
01647 
01648         if ($oCatTree) {
01649 
01650             foreach ($oCatTree as $oCat) {
01651                 $aCatPath = array();
01652 
01653                 $aCatPath['link'] = $oCat->getLink();
01654                 $aCatPath['title'] = $oCat->oxcategories__oxtitle->value;
01655 
01656                 $aPaths[] = $aCatPath;
01657             }
01658 
01659             return $aPaths;
01660         }
01661 
01662         return $aPaths;
01663     }
01664 }