/**
  * Singleton method
  *
  * @return oxSeoEncoderTag
  */
 public static function getInstance()
 {
     // disable caching for test modules
     if (defined('OXID_PHP_UNIT')) {
         self::$_instance = modInstances::getMod(__CLASS__);
     }
     if (!self::$_instance instanceof oxSeoEncoderTag) {
         self::$_instance = oxNew('oxSeoEncoderTag');
         if (defined('OXID_PHP_UNIT')) {
             modInstances::addMod(__CLASS__, self::$_instance);
         }
     }
     if (defined('OXID_PHP_UNIT')) {
         // resetting cache
         self::$_instance->_aSeoCache = array();
     }
     return self::$_instance;
 }
 /**
  * Returns tag url (seo or dynamic depends on shop mode)
  *
  * @param string $sTag tag title
  *
  * @return string
  */
 public function getTagLink($sTag)
 {
     $oSeoEncoderTag = oxSeoEncoderTag::getInstance();
     $iLang = $this->getLanguageId();
     $sUrl = false;
     if (oxUtils::getInstance()->seoIsActive()) {
         $sUrl = $oSeoEncoderTag->getTagUrl($sTag, $iLang);
     }
     return $sUrl ? $sUrl : $this->getConfig()->getShopUrl() . $oSeoEncoderTag->getStdTagUri($sTag) . "&lang=" . $iLang;
 }
Example #3
0
 /**
  * Returns view canonical url
  *
  * @return string
  */
 public function getCanonicalUrl()
 {
     if ($iPage = $this->getActPage()) {
         return $this->_addPageNrParam($this->generatePageNavigationUrl(), $iPage);
     } elseif ($sTag = $this->getTag()) {
         return oxSeoEncoderTag::getInstance()->getTagUrl($sTag);
     }
 }
 /**
  * Returns Bread Crumb - you are here page1/page2/page3...
  *
  * @return array
  */
 public function getBreadCrumb()
 {
     $aPaths = array();
     if ('search' == oxConfig::getParameter('listtype')) {
         $sSearchParam = $this->getSearchParamForHtml();
         $aCatPath = array();
         $aCatPath['title'] = sprintf(oxLang::getInstance()->translateString('searchResult', oxLang::getInstance()->getBaseLanguage(), false), $sSearchParam);
         $aCatPath['link'] = $this->getViewConfig()->getSelfLink() . 'stoken=' . oxSession::getVar('sess_stoken') . "&cl=search&searchparam=" . $sSearchParam;
         $aPaths[] = $aCatPath;
     } elseif ('tag' == oxConfig::getParameter('listtype')) {
         $aCatPath = array();
         $aCatPath['title'] = oxLang::getInstance()->translateString('TAGS', oxLang::getInstance()->getBaseLanguage(), false);
         $aCatPath['link'] = oxSeoEncoder::getInstance()->getStaticUrl($this->getViewConfig()->getSelfLink() . 'cl=tags');
         $aPaths[] = $aCatPath;
         $oStr = getStr();
         $aCatPath['title'] = $oStr->ucfirst(oxConfig::getParameter('searchtag'));
         $aCatPath['link'] = oxSeoEncoderTag::getInstance()->getTagUrl(oxConfig::getParameter('searchtag'));
         $aPaths[] = $aCatPath;
     } elseif ('recommlist' == oxConfig::getParameter('listtype')) {
         $aCatPath = array();
         $aCatPath['title'] = oxLang::getInstance()->translateString('PAGE_RECOMMENDATIONS_PRODUCTS_TITLE', oxLang::getInstance()->getBaseLanguage(), false);
         $aPaths[] = $aCatPath;
     } else {
         $oCatTree = $this->getCatTreePath();
         if ($oCatTree) {
             foreach ($oCatTree as $oCat) {
                 $aCatPath = array();
                 $aCatPath['link'] = $oCat->getLink();
                 $aCatPath['title'] = $oCat->oxcategories__oxtitle->value;
                 $aPaths[] = $aCatPath;
             }
         }
     }
     return $aPaths;
 }
 /**
  * Active tag info object getter. Object properties:
  *  - sTag current tag
  *  - link link leading to tag article list
  *
  * @return oxstdclass
  */
 public function getActTag()
 {
     if ($this->_oActTag === null) {
         $this->_oActTag = new Oxstdclass();
         $this->_oActTag->sTag = $sTag = oxConfig::getParameter("searchtag", 1);
         $oSeoEncoderTag = oxSeoEncoderTag::getInstance();
         $sLink = false;
         if (oxUtils::getInstance()->seoIsActive()) {
             $sLink = $oSeoEncoderTag->getTagUrl($sTag, oxLang::getInstance()->getBaseLanguage());
         }
         $this->_oActTag->link = $sLink ? $sLink : $this->getConfig()->getShopHomeURL() . $oSeoEncoderTag->getStdTagUri($sTag, false);
     }
     return $this->_oActTag;
 }
 /**
  * Sets details locator data for articles that came from tag list.
  *
  * @param oxubase   $oLocatorTarget oxubase object
  * @param oxarticle $oCurrArticle   current article
  *
  * @return null
  */
 protected function _setTagLocatorData($oLocatorTarget, $oCurrArticle)
 {
     if ($oTag = $oLocatorTarget->getActTag()) {
         $myUtils = oxUtils::getInstance();
         // loading data for article navigation
         $oIdList = oxNew('oxarticlelist');
         $oLang = oxLang::getInstance();
         if ($oLocatorTarget->showSorting()) {
             $oLocatorTarget->prepareSortColumns();
             $oIdList->setCustomSorting($oLocatorTarget->getSortingSql('oxtags'));
         }
         $oIdList->getTagArticleIds($oTag->sTag, $oLang->getBaseLanguage());
         //page number
         $iPage = $this->_findActPageNumber($oLocatorTarget->getActPage(), $oIdList, $oCurrArticle);
         // setting product position in list, amount of articles etc
         $oTag->iCntOfProd = $oIdList->count();
         $oTag->iProductPos = $this->_getProductPos($oCurrArticle, $oIdList, $oLocatorTarget);
         if (oxUtils::getInstance()->seoIsActive()) {
             $oTag->toListLink = oxSeoEncoderTag::getInstance()->getTagPageUrl($oTag->sTag, $iPage);
         } else {
             $sPageNr = $this->_getPageNumber($iPage);
             $oTag->toListLink = $this->_makeLink($oTag->link, $sPageNr);
         }
         $sAddSearch = '';
         // setting parameters when seo is Off
         if (!$myUtils->seoIsActive()) {
             $sAddSearch = 'searchtag=' . rawurlencode(oxConfig::getParameter('searchtag', 1));
             $sAddSearch .= '&listtype=tag';
         }
         $oTag->nextProductLink = $this->_oNextProduct ? $this->_makeLink($this->_oNextProduct->getLink(), $sAddSearch) : null;
         $oTag->prevProductLink = $this->_oBackProduct ? $this->_makeLink($this->_oBackProduct->getLink(), $sAddSearch) : null;
         $oStr = getStr();
         $oLocatorTarget->setSearchTitle($oLang->translateString('TAGS') . ' / ' . $oStr->htmlspecialchars($oStr->ucfirst($oTag->sTag)));
         $oLocatorTarget->setActiveCategory($oTag);
     }
 }
 /**
  * Returns SEO uri for passed article and active tag
  *
  * @param oxarticle $oArticle     article object
  * @param int       $iLang        language id
  * @param bool      $blRegenerate if TRUE forces seo url regeneration
  *
  * @return string
  */
 public function getArticleTagUri($oArticle, $iLang, $blRegenerate = false)
 {
     $sSeoUri = null;
     if ($sTag = $this->_getTag($oArticle, $iLang)) {
         $iShopId = $this->getConfig()->getShopId();
         $sStdUrl = $oArticle->getStdTagLink($sTag);
         if ($blRegenerate || !($sSeoUri = $this->_loadFromDb('dynamic', $this->getDynamicObjectId($iShopId, $sStdUrl), $iLang))) {
             // generating new if not found
             if ($sSeoUri = oxSeoEncoderTag::getInstance()->getTagUri($sTag, $iLang, $oArticle->getId())) {
                 $sSeoUri .= $this->_prepareArticleTitle($oArticle);
                 $sSeoUri = $this->_processSeoUrl($sSeoUri, $this->_getStaticObjectId($iShopId, $sStdUrl), $iLang);
                 $sSeoUri = $this->_getDynamicUri($sStdUrl, $sSeoUri, $iLang);
             }
         }
     }
     return $sSeoUri;
 }