/**
  * Returns shopping cart URL
  *
  * @return string
  */
 protected function _getBasketUrl()
 {
     if (is_null($this->_sBasketUrl)) {
         $homeUrl = $this->getConfig()->getShopHomeURL();
         $basketUrl = oxUtilsUrl::getInstance()->processUrl($homeUrl, true, array('cl' => 'basket'));
         if (oxUtils::getInstance()->seoIsActive()) {
             if ($sStaticUrl = oxSeoEncoder::getInstance()->getStaticUrl($basketUrl)) {
                 $basketUrl = $sStaticUrl;
             } else {
                 $basketUrl = oxUtilsUrl::getInstance()->processUrl($basketUrl);
             }
         }
         $this->_sBasketUrl = $basketUrl;
     }
     return $this->_sBasketUrl;
 }
 /**
  * Returns shops home link
  *
  * @return string
  */
 public function getHomeLink()
 {
     if (($sValue = $this->getViewConfigParam('homeLink')) === null) {
         $myConfig = $this->getConfig();
         $myUtils = oxUtils::getInstance();
         $oLang = oxLang::getInstance();
         $iLang = $oLang->getBaseLanguage();
         $sValue = null;
         $blAddStartCl = $myUtils->seoIsActive() && $iLang != $myConfig->getConfigParam('sDefaultLang');
         if ($blAddStartCl) {
             $sValue = oxSeoEncoder::getInstance()->getStaticUrl($this->getSelfLink() . 'cl=start', $iLang);
             $sValue = oxUtilsUrl::getInstance()->appendUrl($sValue, oxUtilsUrl::getInstance()->getBaseAddUrlParams());
             $sValue = getStr()->preg_replace('/(\\?|&(amp;)?)$/', '', $sValue);
         }
         if (!$sValue) {
             $sValue = getStr()->preg_replace('#index.php\\??$#', '', $this->getSelfLink());
         }
         $this->setViewConfigParam('homeLink', $sValue);
     }
     return $sValue;
 }
/**
 * Smarty function
 * -------------------------------------------------------------
 * Purpose: output SEO style url
 * add [{ oxgetseourl ident="..." }] where you want to display content
 * -------------------------------------------------------------
 *
 * @param array  $params  params
 * @param Smarty &$smarty clever simulation of a method
 *
 * @return string
 */
function smarty_function_oxgetseourl($params, &$smarty)
{
    $sOxid = isset($params['oxid']) ? $params['oxid'] : null;
    $sType = isset($params['type']) ? $params['type'] : null;
    $sUrl = $sIdent = isset($params['ident']) ? $params['ident'] : null;
    // requesting specified object SEO url
    if ($sType) {
        $oObject = oxNew($sType);
        // special case for content type object when ident is provided
        if ($sType == 'oxcontent' && $sIdent && $oObject->loadByIdent($sIdent)) {
            $sUrl = $oObject->getLink();
        } elseif ($sOxid) {
            //minimising aricle object loading
            if (strtolower($sType) == "oxarticle") {
                $oObject->disablePriceLoad();
                $oObject->setNoVariantLoading(true);
            }
            if ($oObject->load($sOxid)) {
                $sUrl = $oObject->getLink();
            }
        }
    } elseif ($sUrl && oxUtils::getInstance()->seoIsActive()) {
        // if SEO is on ..
        $oEncoder = oxSeoEncoder::getInstance();
        if ($sStaticUrl = $oEncoder->getStaticUrl($sUrl)) {
            $sUrl = $sStaticUrl;
        } else {
            // in case language parameter is not added to url
            $sUrl = oxUtilsUrl::getInstance()->processUrl($sUrl);
        }
    }
    $sDynParams = isset($params['params']) ? $params['params'] : false;
    if ($sDynParams) {
        include_once $smarty->_get_plugin_filepath('modifier', 'oxaddparams');
        $sUrl = smarty_modifier_oxaddparams($sUrl, $sDynParams);
    }
    return $sUrl;
}
 /**
  * Sets array of words which must be checked before building seo url
  * These words are appended by seo prefix if they are the initial uri segment
  *
  * @param array $aReservedWords reserved words
  *
  * @return null
  */
 public function setReservedWords($aReservedWords)
 {
     self::$_aReservedWords = array_merge(self::$_aReservedWords, $aReservedWords);
 }
 /**
  * Returns Bread Crumb - you are here page1/page2/page3...
  *
  * @return array
  */
 public function getBreadCrumb()
 {
     $aPaths = array();
     $aPath = array();
     $aPath['title'] = oxLang::getInstance()->translateString('PAGE_ACCOUNT_MY_ACCOUNT', oxLang::getInstance()->getBaseLanguage(), false);
     $aPath['link'] = oxSeoEncoder::getInstance()->getStaticUrl($this->getViewConfig()->getSelfLink() . 'cl=account');
     $aPaths[] = $aPath;
     $aPath['title'] = oxLang::getInstance()->translateString('PAGE_ACCOUNT_PASSWORD_PERSONALSETTINGS', oxLang::getInstance()->getBaseLanguage(), false);
     $aPath['link'] = $this->getLink();
     $aPaths[] = $aPath;
     return $aPaths;
 }
 /**
  * Sets selected category as a default
  *
  * @return null
  */
 public function setAsDefault()
 {
     $myConfig = $this->getConfig();
     $sDefCat = oxConfig::getParameter("defcat");
     $soxId = oxConfig::getParameter("oxid");
     $sShopId = $myConfig->getShopId();
     $oDb = oxDb::getDb();
     $sShopCheck = "";
     // #0003650: increment all product references independent to active shop
     $sQ = "update oxobject2category set oxtime = oxtime + 10 where oxobjectid = " . $oDb->quote($soxId);
     oxDb::getInstance()->getDb()->Execute($sQ);
     // set main category for active shop
     $sQ = "update oxobject2category set oxtime = 0 where oxobjectid = " . $oDb->quote($soxId) . " and oxcatnid = " . $oDb->quote($sDefCat) . " {$sShopCheck} ";
     oxDb::getInstance()->getDb()->Execute($sQ);
     // #0003366: invalidate article SEO for all shops
     oxSeoEncoder::getInstance()->markAsExpired($soxId, null, 1, null, "oxtype='oxarticle'");
     $this->resetContentCache();
 }
Пример #7
0
 /**
  * Saves changed shop configuration parameters.
  *
  * @return mixed
  */
 public function save()
 {
     parent::save();
     // saving config params
     $this->saveConfVars();
     $oShop = oxNew('oxshop');
     if ($oShop->loadInLang($this->_iEditLang, $this->getEditObjectId())) {
         //assigning values
         $oShop->setLanguage(0);
         $oShop->assign(oxConfig::getParameter('editval'));
         $oShop->setLanguage($this->_iEditLang);
         $oShop->save();
         oxUtils::getInstance()->rebuildCache();
         // saving static url changes
         if (is_array($aStaticUrl = oxConfig::getParameter('aStaticUrl'))) {
             $this->_sActSeoObject = oxSeoEncoder::getInstance()->encodeStaticUrls($this->_processUrls($aStaticUrl), $oShop->getId(), $this->_iEditLang);
         }
     }
 }
Пример #8
0
 /**
  * Marks seo entires as expired, cleans up tag clouds cache
  *
  * @param string $sShopId Shop id
  *
  * @return null
  */
 public function resetSeoData($sShopId)
 {
     $aTypes = array('oxarticle', 'oxcategory', 'oxvendor', 'oxcontent', 'dynamic', 'oxmanufacturer');
     $oEncoder = oxSeoEncoder::getInstance();
     foreach ($aTypes as $sType) {
         $oEncoder->markAsExpired(null, $sShopId, 1, null, "oxtype = '{$sType}'");
     }
     // resetting tag cache
     $oTagCloud = oxNew('oxtagcloud');
     $oTagCloud->resetTagCache();
 }
Пример #9
0
 public function testOxSeoEncoderEncodeString()
 {
     $sIn = "agentūлитовfür";
     $sOut = "agentūлитовfuer";
     $oSeoEncoder = new oxSeoEncoder();
     $this->assertEquals($sOut, $oSeoEncoder->encodeString($sIn));
 }
Пример #10
0
 /**
  * Returns Bread Crumb - you are here page1/page2/page3...
  *
  * @return array
  */
 public function getBreadCrumb()
 {
     $aPaths = array();
     $aCatPath = array();
     $aCatPath['title'] = oxLang::getInstance()->translateString('TAGS', oxLang::getInstance()->getBaseLanguage(), false);
     $aCatPath['link'] = oxSeoEncoder::getInstance()->getStaticUrl($this->getViewConfig()->getSelfLink() . 'cl=tags');
     $aPaths[] = $aCatPath;
     $aCatPath['title'] = $this->getTitle();
     $aCatPath['link'] = $this->getCanonicalUrl();
     $aPaths[] = $aCatPath;
     return $aPaths;
 }
 /**
  * Returns Bread Crumb - you are here page1/page2/page3...
  *
  * @return array
  */
 public function getBreadCrumb()
 {
     $aPaths = array();
     $aPath = array();
     $aPath['title'] = oxLang::getInstance()->translateString('PAGE_ACCOUNT_MY_ACCOUNT', oxLang::getInstance()->getBaseLanguage(), false);
     $aPath['link'] = oxSeoEncoder::getInstance()->getStaticUrl($this->getViewConfig()->getSelfLink() . "cl=account");
     $aPaths[] = $aPath;
     $aPath['title'] = oxLang::getInstance()->translateString('PAGE_ACCOUNT_NOTICELIST_MYWISHLIST', oxLang::getInstance()->getBaseLanguage(), false);
     $aPath['link'] = $this->getLink();
     $aPaths[] = $aPath;
     return $aPaths;
 }
 /**
  * Returns Bread Crumb - you are here page1/page2/page3...
  *
  * @return array
  */
 public function getBreadCrumb()
 {
     $aPaths = array();
     $aPath = array();
     $oUtils = oxUtilsUrl::getInstance();
     $aPath['title'] = oxLang::getInstance()->translateString('PAGE_ACCOUNT_MY_ACCOUNT', oxLang::getInstance()->getBaseLanguage(), false);
     $aPath['link'] = oxSeoEncoder::getInstance()->getStaticUrl($this->getViewConfig()->getSelfLink() . 'cl=account');
     $aPaths[] = $aPath;
     $aPath['title'] = oxLang::getInstance()->translateString('PAGE_ACCOUNT_NEWSLETTER_SETTINGS', oxLang::getInstance()->getBaseLanguage(), false);
     $aPath['link'] = $oUtils->cleanUrl($this->getLink(), array('fnc'));
     $aPaths[] = $aPath;
     return $aPaths;
 }
Пример #13
0
 /**
  * Update this Object into the database, this function only works on
  * the main table, it will not save any dependend tables, which might
  * be loaded through oxlist (with exception of the active language set
  * table, which will be updated).
  *
  * @throws oxObjectException Throws on failure inserting
  *
  * @return bool
  */
 protected function _update()
 {
     $blRet = parent::_update();
     if ($blRet) {
         //also update multilang table if it is separate
         $aUpdateTables = array();
         if ($this->_blEmployMultilanguage) {
             $sCoreTable = $this->getCoreTableName();
             $sLangTable = getLangTableName($sCoreTable, $this->getLanguage());
             if ($sCoreTable != $sLangTable) {
                 $aUpdateTables[] = $sLangTable;
             }
         } else {
             $aUpdateTables = $this->_getLanguageSetTables();
         }
         foreach ($aUpdateTables as $sLangTable) {
             $sUpdate = "insert into {$sLangTable} set " . $this->_getUpdateFieldsForTable($sLangTable, false) . " on duplicate key update " . $this->_getUpdateFieldsForTable($sLangTable);
             $blRet = (bool) oxDB::getDb()->execute($sUpdate);
         }
     }
     // currently only multilanguage objects are SEO
     // if current object is managed by SEO and SEO is ON
     if ($blRet && $this->_blIsSeoObject && $this->isAdmin()) {
         // marks all object db entries as expired
         oxSeoEncoder::getInstance()->markAsExpired($this->getId(), null, 1, $this->getLanguage());
     }
     return $blRet;
 }
Пример #14
0
 /**
  * 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;
 }
Пример #15
0
 /**
  * get link of current view
  *
  * @param int $iLang requested language
  *
  * @return string
  */
 public function getLink($iLang = null)
 {
     if (!isset($iLang)) {
         $iLang = oxLang::getInstance()->getBaseLanguage();
     }
     $oDisplayObj = null;
     $blTrySeo = false;
     if (oxUtils::getInstance()->seoIsActive()) {
         $blTrySeo = true;
         $oDisplayObj = $this->_getSubject($iLang);
     }
     $iActPageNr = $this->getActPage();
     if ($oDisplayObj) {
         return $this->_addPageNrParam($oDisplayObj->getLink($iLang), $iActPageNr, $iLang);
     }
     $myConfig = $this->getConfig();
     if ($blTrySeo) {
         $oEncoder = oxSeoEncoder::getInstance();
         if ($sSeoUrl = $oEncoder->getStaticUrl($myConfig->getShopHomeURL($iLang) . $this->_getSeoRequestParams(), $iLang)) {
             return $this->_addPageNrParam($sSeoUrl, $iActPageNr, $iLang);
         }
     }
     $sUrl = oxUtilsUrl::getInstance()->processUrl($myConfig->getShopCurrentURL($iLang) . $this->_getRequestParams(), true, null, $iLang);
     // fallback to old non seo url
     return $this->_addPageNrParam($sUrl, $iActPageNr, $iLang);
 }
Пример #16
0
 /**
  * Marks article seo url as expired
  *
  * @param array $aArtIds article id's
  * @param array $aCatIds ids if categories, which must be removed from oxseo
  *
  * @return null
  */
 public function resetArtSeoUrl($aArtIds, $aCatIds = null)
 {
     if (empty($aArtIds)) {
         return;
     }
     if (!is_array($aArtIds)) {
         $aArtIds = array($aArtIds);
     }
     $blCleanCats = false;
     if ($aCatIds) {
         if (!is_array($aCatIds)) {
             $aCatIds = array($aCatIds);
         }
         $sShopId = $this->getConfig()->getShopId();
         $sQ = "delete from oxseo where oxtype='oxarticle' and oxobjectid='%s' and\n                   oxshopid='{$sShopId}' and oxparams in ('" . implode(",", oxDb::getInstance()->quoteArray($aCatIds)) . "')";
         $oDb = oxDb::getDb();
         $blCleanCats = true;
     }
     $sShopId = $this->getConfig()->getShopId();
     foreach ($aArtIds as $sArtId) {
         oxSeoEncoder::getInstance()->markAsExpired($sArtId, $sShopId, 1, null, "oxtype='oxarticle'");
         if ($blCleanCats) {
             $oDb->execute(sprintf($sQ, $sArtId));
         }
     }
 }