/**
  * Singleton method
  *
  * @return oxSeoEncoderRecomm
  */
 public static function getInstance()
 {
     // disable caching for test modules
     if (defined('OXID_PHP_UNIT')) {
         self::$_instance = modInstances::getMod(__CLASS__);
     }
     if (!self::$_instance instanceof oxSeoEncoderRecomm) {
         self::$_instance = oxNew('oxSeoEncoderRecomm');
         if (defined('OXID_PHP_UNIT')) {
             modInstances::addMod(__CLASS__, self::$_instance);
         }
     }
     if (defined('OXID_PHP_UNIT')) {
         // resetting cache
         self::$_instance->_aSeoCache = array();
     }
     return self::$_instance;
 }
Ejemplo n.º 2
0
 /**
  * Returns raw recommlist seo url
  *
  * @param int $iLang language id
  * @param int $iPage page number [optional]
  *
  * @return string
  */
 public function getBaseSeoLink($iLang, $iPage = 0)
 {
     $oEncoder = oxSeoEncoderRecomm::getInstance();
     if (!$iPage) {
         return $oEncoder->getRecommUrl($this, $iLang);
     }
     return $oEncoder->getRecommPageUrl($this, $iPage, $iLang);
 }
Ejemplo n.º 3
0
 /**
  * Sets details locator data for articles that came from recommlist.
  *
  * Template variables:
  * <b>sSearchTitle</b>, <b>searchparamforhtml</b>
  *
  * @param oxubase   $oLocatorTarget oxubase object
  * @param oxarticle $oCurrArticle   current article
  *
  * @return null
  */
 protected function _setRecommlistLocatorData($oLocatorTarget, $oCurrArticle)
 {
     if ($oRecommList = $oLocatorTarget->getActiveRecommList()) {
         // loading data for article navigation
         $oIdList = oxNew('oxarticlelist');
         $oIdList->loadRecommArticleIds($oRecommList->getId(), null);
         //page number
         $iPage = $this->_findActPageNumber($oLocatorTarget->getActPage(), $oIdList, $oCurrArticle);
         $sSearchRecomm = oxConfig::getParameter('searchrecomm', true);
         if ($sSearchRecomm !== null) {
             $sSearchFormRecomm = oxConfig::getParameter('searchrecomm');
             $sSearchLinkRecomm = rawurlencode($sSearchRecomm);
             $sAddSearch = 'searchrecomm=' . $sSearchLinkRecomm;
         }
         // setting product position in list, amount of articles etc
         $oRecommList->iCntOfProd = $oIdList->count();
         $oRecommList->iProductPos = $this->_getProductPos($oCurrArticle, $oIdList, $oLocatorTarget);
         $blSeo = oxUtils::getInstance()->seoIsActive();
         if ($blSeo && $iPage) {
             $oRecommList->toListLink = oxSeoEncoderRecomm::getInstance()->getRecommPageUrl($oRecommList, $iPage);
         } else {
             $oRecommList->toListLink = $this->_makeLink($oRecommList->getLink(), $this->_getPageNumber($iPage));
         }
         $oRecommList->toListLink = $this->_makeLink($oRecommList->toListLink, $sAddSearch);
         $sAdd = '';
         if (!$blSeo) {
             $sAdd = 'recommid=' . $oRecommList->getId() . '&amp;listtype=recommlist' . ($sAddSearch ? '&amp;' : '');
         }
         $sAdd .= $sAddSearch;
         $oRecommList->nextProductLink = $this->_oNextProduct ? $this->_makeLink($this->_oNextProduct->getLink(), $sAdd) : null;
         $oRecommList->prevProductLink = $this->_oBackProduct ? $this->_makeLink($this->_oBackProduct->getLink(), $sAdd) : null;
         $oLang = oxLang::getInstance();
         $sTitle = $oLang->translateString('RECOMMLIST');
         if ($sSearchRecomm !== null) {
             $sTitle .= " / " . $oLang->translateString('RECOMMLIST_SEARCH') . ' "' . $sSearchFormRecomm . '"';
         }
         $oLocatorTarget->setSearchTitle($sTitle);
         $oLocatorTarget->setActiveCategory($oRecommList);
     }
 }
 /**
  * Returns SEO uri for passed article and active tag
  *
  * @param oxarticle $oArticle article object
  * @param int       $iLang    language id
  *
  * @return string
  */
 public function getArticleRecommUri($oArticle, $iLang)
 {
     $sSeoUri = null;
     if ($oRecomm = $this->_getRecomm($oArticle, $iLang)) {
         //load details link from DB
         if (!($sSeoUri = $this->_loadFromDb('oxarticle', $oArticle->getId(), $iLang, null, $oRecomm->getId(), true))) {
             $oArticle = $this->_getProductForLang($oArticle, $iLang);
             // create title part for uri
             $sTitle = $this->_prepareArticleTitle($oArticle);
             // create uri for all categories
             $sSeoUri = oxSeoEncoderRecomm::getInstance()->getRecommUri($oRecomm, $iLang);
             $sSeoUri = $this->_processSeoUrl($sSeoUri . $sTitle, $oArticle->getId(), $iLang);
             $aStdParams = array('recommid' => $oRecomm->getId(), 'listtype' => $this->_getListType());
             $this->_saveToDb('oxarticle', $oArticle->getId(), oxUtilsUrl::getInstance()->appendUrl($oArticle->getBaseStdLink($iLang), $aStdParams), $sSeoUri, $iLang, null, 0, $oRecomm->getId());
         }
     }
     return $sSeoUri;
 }