Gets article link

@param int   $iLang   required language [optional]
@param array $aParams additional params to use [optional]

@return string
359344
public function getStdLink($iLang = null, $aParams = [])
    {
        if ($iLang === null) {
            $iLang = (int) $this->getLanguage();
        }

        $iLinkType = $this->getLinkType();
        if (!isset($this->_aStdUrls[$iLang][$iLinkType])) {
            $oArticle = oxNew(\OxidEsales\Eshop\Application\Model\Article::class);
            $oArticle->setId($this->getId());
            $oArticle->setLinkType($iLinkType);
            $this->_aStdUrls[$iLang][$iLinkType] = $oArticle->getStdLink($iLang, $aParams);
        }

        return $this->_aStdUrls[$iLang][$iLinkType];
    }
739193
public function encodeStaticUrls($aStaticUrl, $iShopId, $iLang)
    {
        $db = \OxidEsales\Eshop\Core\DatabaseProvider::getDb();
        $sValues = '';
        $sOldObjectId = null;

        // standard url
        $sStdUrl = $this->_trimUrl(trim($aStaticUrl['oxseo__oxstdurl']));
        $sObjectId = $aStaticUrl['oxseo__oxobjectid'];

        if (!$sObjectId || $sObjectId == '-1') {
            $sObjectId = $this->_getStaticObjectId($iShopId, $sStdUrl);
        } else {
            // marking entry as needs to move to history
            $sOldObjectId = $sObjectId;

            // if std url does not match old
            if ($this->_getStaticObjectId($iShopId, $sStdUrl) != $sObjectId) {
                $sObjectId = $this->_getStaticObjectId($iShopId, $sStdUrl);
            }
        }

        foreach ($aStaticUrl['oxseo__oxseourl'] as $iLang => $sSeoUrl) {
            $iLang = (int) $iLang;

            // generating seo url
            $sSeoUrl = $this->_trimUrl($sSeoUrl);
            if ($sSeoUrl) {
                $sSeoUrl = $this->_processSeoUrl($sSeoUrl, $sObjectId, $iLang);
            }

            if ($sOldObjectId) {
                // Transaction picks master automatically (see ESDEV-3804 and ESDEV-3822).
                $db->startTransaction();
                try {
                    // move changed records to history
                    if (!$db->getOne("select (" . $db->quote($sSeoUrl) . " like oxseourl) & (" . $db->quote($sStdUrl) . " like oxstdurl) from oxseo where oxobjectid = " . $db->quote($sOldObjectId) . " and oxshopid = '{$iShopId}' and oxlang = '{$iLang}' ")) {
                        $this->_copyToHistory($sOldObjectId, $iShopId, $iLang, 'static', $sObjectId);
                    }

                    $db->commitTransaction();
                } catch (Exception $exception) {
                    $db->rollbackTransaction();

                    throw $exception;
                }
            }

            if (!$sSeoUrl || !$sStdUrl) {
                continue;
            }

            $sIdent = $this->_getSeoIdent($sSeoUrl);

            if ($sValues) {
                $sValues .= ', ';
            }

            $sValues .= "( " . $db->quote($sObjectId) . ", " . $db->quote($sIdent) . ", " . $db->quote($iShopId) . ", '{$iLang}', " . $db->quote($sStdUrl) . ", " . $db->quote($sSeoUrl) . ", 'static' )";
        }

        // must delete old before insert/update
        if ($sOldObjectId) {
            $this->executeDatabaseQuery("delete from oxseo where oxobjectid in ( " . $db->quote($sOldObjectId) . ", " . $db->quote($sObjectId) . " )");
        }

        // (re)inserting
        if ($sValues) {
            $sql = "insert into oxseo ( oxobjectid, oxident, oxshopid, oxlang, oxstdurl, oxseourl, oxtype ) values {$sValues} ";
            $this->executeDatabaseQuery($sql);
        }

        return $sObjectId;
    }
676891
public function getBaseStdLink($iLang, $blAddId = true, $blFull = true)
    {
        $sUrl = '';
        if ($blFull) {
            //always returns shop url, not admin
            $sUrl = \OxidEsales\Eshop\Core\Registry::getConfig()->getShopUrl($iLang, false);
        }

        if ($this->oxcontents__oxloadid->value === 'oxcredits') {
            $sUrl .= "index.php?cl=credits";
        } else {
            $sUrl .= "index.php?cl=content";
        }
        $sUrl .= '&amp;oxloadid=' . $this->getLoadId();

        if ($blAddId) {
            $sUrl .= "&amp;oxcid=" . $this->getId();
            // adding parent category if if available
            if ($this->_sParentCatId !== false && $this->oxcontents__oxcatid->value && $this->oxcontents__oxcatid->value != 'oxrootid') {
                if ($this->_sParentCatId === null) {
                    $this->_sParentCatId = false;
                    $oDb = \OxidEsales\Eshop\Core\DatabaseProvider::getDb();
                    $sParentId = $oDb->getOne("select oxparentid from oxcategories where oxid = " . $oDb->quote($this->oxcontents__oxcatid->value));
                    if ($sParentId && 'oxrootid' != $sParentId) {
                        $this->_sParentCatId = $sParentId;
                    }
                }

                if ($this->_sParentCatId) {
                    $sUrl .= "&amp;cnid=" . $this->_sParentCatId;
                }
            }
        }

        //always returns shop url, not admin
        return $sUrl;
    }
510992
public function href(string $controller = null, string $action = null, array $params = null, string $lang = null): string
    {
        return $this->siteHref('', $controller, $action, $params, $lang);
    }
19435
protected function _addPageNrParam($sUrl, $iPage, $iLang = null)
    {
        if (\OxidEsales\Eshop\Core\Registry::getUtils()->seoIsActive() && ($oVendor = $this->getActVendor())) {
            if ($iPage) {
                // only if page number > 0
                $sUrl = $oVendor->getBaseSeoLink($iLang, $iPage);
            }
        } else {
            $sUrl = \OxidEsales\Eshop\Application\Controller\FrontendController::_addPageNrParam($sUrl, $iPage, $iLang);
        }

        return $sUrl;
    }
1058387
public function getBaseStdLink($iLang, $blAddId = true, $blFull = true)
    {
        if (!isset($this->_aBaseStdUrls[$iLang][$iLinkType])) {
            $oArticle = oxNew(\OxidEsales\Eshop\Application\Model\Article::class);
            $oArticle->setId($this->getId());
            $oArticle->setLinkType($iLinkType);
            $this->_aBaseStdUrls[$iLang][$iLinkType] = $oArticle->getBaseStdLink($iLang, $blAddId, $blFull);
        }

        return $this->_aBaseStdUrls[$iLang][$iLinkType];
    }
405492
public function getLink($providerName, $url, array $options = array())
    {
        $this->checkProvider($providerName);

        return  $this->providers[$providerName]['provider']->getLink($url, $options);
    }
787679
public function getArticlesIndexPermalink(array $parameters = [], $absolute = 1)
    {
        return $this->getContainer()->get('router')->generate($this->getArticlesIndexRoute(), $this->getArticlesIndexRouteParameters($parameters), $absolute);
    }
46217
public function getJsLink($lang = null, $callback = false, $onLoadClass = 'onloadCallBack')
    {
        $client_api = static::CLIENT_API;
        $params = [];

        $callback ? $this->setCallBackParams($params, $onLoadClass)  : false;
        $lang ? $params['hl'] = $lang : null;

        return $client_api . '?'. http_build_query($params);
    }
238017
protected static function _getParams($params, $isInternal = true)
    {

        if (!is_array($params)) {
            $params = array($params);
        }

        $result = array();
        foreach ($params as $param) {
            $optional  = $param->isOptional();
            $paramName = (!$optional ? '*' : '') . $param->name;

            $result[$paramName]['name'] = $param->getName();
            if ($optional && !$isInternal) {
                $result[$paramName]['default'] = $param->getDefaultValue();
            }
            if ($param->allowsNull()) {
                $result[$paramName]['null'] = true;
            }
            if ($param->isArray()) {
                $result[$paramName]['array'] = true;
            }
            if ($param->isPassedByReference()) {
                $result[$paramName]['reference'] = true;
            }
        }

        return $result;
    }
222782
protected function _addUrlParameters($sUrl, $aParams)
    {
        $sDelimiter = ((getStr()->strpos($sUrl, '?') !== false)) ? '&' : '?';
        foreach ($aParams as $sName => $sVal) {
            $sUrl = $sUrl . $sDelimiter . $sName . '=' . $sVal;
            $sDelimiter = '&';
        }

        return $sUrl;
    }
1285500
public static function &GetListForShopKeywords($iShopId, $aKeywordList, $iLanguageId = null)
    {
        if (null === $iLanguageId) {
            $iLanguageId = self::getMyLanguageService()->getActiveLanguageId();
        }
        $aKeywordList = TTools::MysqlRealEscapeArray($aKeywordList);
        $query = self::GetDefaultQuery($iLanguageId, "`shop_search_keyword_article`.`shop_id`= '".MySqlLegacySupport::getInstance()->real_escape_string($iShopId)."' AND `shop_search_keyword_article`.`name` IN ('".implode("','", $aKeywordList)."') AND (`shop_search_keyword_article`.`cms_language_id` = '".MySqlLegacySupport::getInstance()->real_escape_string($iLanguageId)."' OR `shop_search_keyword_article`.`cms_language_id` = '') ");

        return TdbShopSearchKeywordArticleList::GetList($query, $iLanguageId);
    }
747916
public function setTplLanguage($iLang = null)
    {
        $this->_iTplLanguageId = isset($iLang) ? (int) $iLang : $this->getBaseLanguage();
        if ($this->isAdmin()) {
            $aLanguages = $this->getAdminTplLanguageArray();
            if (!isset($aLanguages[$this->_iTplLanguageId])) {
                $this->_iTplLanguageId = key($aLanguages);
            }
        }

        \OxidEsales\Eshop\Core\Registry::getSession()->setVariable('tpllanguage', $this->_iTplLanguageId);

        return $this->_iTplLanguageId;
    }
1302456
public function getShareLinkUrl($provider, $url, array $options = array())
    {
        return $this->socialShare->getLink($provider, $url, $options);
    }
752507
public static function get($pUrl, $pParams = array(), $pRelative = true)
    {
        if (strpos($pUrl, '*/') !== false) {
            if (self::$_request === NULL) {
                self::setRequest();
            }

            $pUrl = str_replace('*/*/', self::$_request->getModule() . DS . self::$_request->getView(), $pUrl);
            $pUrl = str_replace('*/', self::$_request->getModule() . DS, $pUrl);
        }

        if (Agl::isModuleLoaded(Agl::AGL_MORE_POOL . '/locale/locale')) {
            return Agl::getSingleton(Agl::AGL_MORE_POOL . '/locale')->getUrl($pUrl, $pParams, $pRelative);
        }

        if (! $pUrl) {
            if ($pRelative) {
                return ROOT;
            }
            return self::getHost(ROOT);
        }

        if (strpos($pUrl, Agl::APP_PUBLIC_DIR) === false) {
            if (is_array($pParams) and ! empty($pParams)) {
                $params = array();
                foreach ($pParams as $key => $value) {
                    $params[] = $key . DS . $value;
                }

                $url = $pUrl . DS . implode(DS, $params) . DS;
            } else if (is_string($pParams) and $pParams) {
                $url = $pUrl . DS . $pParams . DS;
            } else {
                $url = $pUrl . DS;
            }

            if ($pRelative) {
                return ROOT . $url;
            }

            return self::getHost(ROOT . $url);
        }

        if ($pRelative) {
            return ROOT . $pUrl;
        }
        return self::getHost(ROOT . $pUrl);
    }
328995
private function getForeignLink($parentLinkName, $parentLinkParams, $currentEntityDefs)
    {
        if (isset($parentLinkParams['foreign']) && isset($currentEntityDefs['links'][$parentLinkParams['foreign']])) {
            return array(
                'name' => $parentLinkParams['foreign'],
                'params' => $currentEntityDefs['links'][$parentLinkParams['foreign']],
            );
        }

        return false;
    }
375442
protected function _getViewSelect($sTable, $iLang)
    {
        $oMetaData = oxNew(\OxidEsales\Eshop\Core\DbMetaDataHandler::class);
        $aFields = $oMetaData->getSinglelangFields($sTable, $iLang);
        foreach ($aFields as $sCoreField => $sField) {
            if ($sCoreField !== $sField) {
                $aFields[$sCoreField] = $sField . ' AS ' . $sCoreField;
            }
        }

        return implode(',', $aFields);
    }