/**
 * Smarty function
 * -------------------------------------------------------------
 * Purpose: add additional parameters to SEO url
 * add |oxaddparams:"...." to link
 * -------------------------------------------------------------
 *
 * @param string $sUrl       Url
 * @param string $sDynParams Dynamic URL parameters
 *
 * @return string
 */
function smarty_modifier_oxaddparams($sUrl, $sDynParams)
{
    $oStr = getStr();
    // removing empty parameters
    $sDynParams = $sDynParams ? $oStr->preg_replace(array('/^\\?/', '/^\\&(amp;)?$/'), '', $sDynParams) : false;
    if ($sDynParams) {
        $sUrl .= (strpos($sUrl, '?') !== false ? "&" : "?") . $sDynParams;
    }
    return oxUtilsUrl::getInstance()->processSeoUrl($sUrl);
}
 /**
  * Sets up navigation for current view
  *
  * @param string $sNode None name
  *
  * @return null
  */
 protected function _setupNavigation($sNode)
 {
     $myAdminNavig = $this->getNavigation();
     $sNode = oxConfig::getParameter("menu");
     // active tab
     $iActTab = oxConfig::getParameter('actedit');
     $iActTab = $iActTab ? $iActTab : $this->_iDefEdit;
     $sActTab = $iActTab ? "&actedit={$iActTab}" : '';
     // list url
     $this->_aViewData['listurl'] = $myAdminNavig->getListUrl($sNode) . $sActTab;
     // edit url
     $sEditUrl = $myAdminNavig->getEditUrl($sNode, $iActTab) . $sActTab;
     if (!getStr()->preg_match("/^http(s)?:\\/\\//", $sEditUrl)) {
         //internal link, adding path
         $sEditUrl = oxUtilsUrl::getInstance()->appendParamSeparator($this->getViewConfig()->getViewConfigParam('selflink')) . $sEditUrl;
     }
     $this->_aViewData['editurl'] = $sEditUrl;
     // tabs
     $this->_aViewData['editnavi'] = $myAdminNavig->getTabs($sNode, $iActTab);
     // active tab
     $this->_aViewData['actlocation'] = $myAdminNavig->getActiveTab($sNode, $iActTab);
     // default tab
     $this->_aViewData['default_edit'] = $myAdminNavig->getActiveTab($sNode, $this->_iDefEdit);
     // passign active tab number
     $this->_aViewData['actedit'] = $iActTab;
     // buttons
     $this->_aViewData['bottom_buttons'] = $myAdminNavig->getBtn($sNode);
 }
 /**
  * Returns export file download url
  *
  * @return string
  */
 public function getDownloadUrl()
 {
     $myConfig = $this->getConfig();
     // override cause of admin dir
     $sUrl = $myConfig->getConfigParam('sShopURL') . $myConfig->getConfigParam('sAdminDir');
     if ($myConfig->getConfigParam('sAdminSSLURL')) {
         $sUrl = $myConfig->getConfigParam('sAdminSSLURL');
     }
     $sUrl = oxUtilsUrl::getInstance()->processUrl($sUrl . '/index.php');
     return $sUrl . '&cl=' . $this->sClassDo . '&fnc=download';
 }
 /**
  * Returns new seo url including the model no.
  *
  *
  * @param oxArticle  $oArticle  article object
  * @param oxCategory $oCategory category object
  * @param int        $iLang     language to generate uri for
  *
  * @return string
  */
 protected function _createArticleCategoryUri($oArticle, $oCategory, $iLang)
 {
     startProfile(__FUNCTION__);
     $oArticle = $this->_getProductForLang($oArticle, $iLang);
     // create title part for uri
     $sTitle = $this->_prepareArticleTitle($oArticle);
     $sTitle = str_replace($this->_getUrlExtension(), " " . $oArticle->oxarticles__oxartnum->value, $sTitle) . "." . $this->_getUrlExtension();
     // writing category path
     $sSeoUri = $this->_processSeoUrl($sTitle, $oArticle->getId(), $iLang);
     $sCatId = $oCategory->getId();
     $this->_saveToDb('oxarticle', $oArticle->getId(), oxUtilsUrl::getInstance()->appendUrl($oArticle->getBaseStdLink($iLang), array('cnid' => $sCatId)), $sSeoUri, $iLang, null, 0, $sCatId);
     stopProfile(__FUNCTION__);
     return $sSeoUri;
 }
 /**
  * resturns a single instance of this class
  *
  * @return oxUtilsUrl
  */
 public static function getInstance()
 {
     // disable caching for test modules
     if (defined('OXID_PHP_UNIT')) {
         self::$_instance = modInstances::getMod(__CLASS__);
     }
     if (!self::$_instance instanceof oxUtilsUrl) {
         self::$_instance = oxNew('oxUtilsUrl');
         if (defined('OXID_PHP_UNIT')) {
             modInstances::addMod(__CLASS__, self::$_instance);
         }
     }
     return self::$_instance;
 }
 /**
  * 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;
}
 /**
  * Returns assigned banner link. If no link is defined and article is
  * assigned to banner, article link will be returned.
  *
  * @return string
  */
 public function getBannerLink()
 {
     if (isset($this->oxactions__oxlink) && $this->oxactions__oxlink->value) {
         return oxUtilsUrl::getInstance()->processUrl($this->oxactions__oxlink->value);
     } else {
         // if article is assinged to banner, getting article link
         if ($oArticle = $this->getBannerArticle()) {
             return $oArticle->getLink();
         }
     }
 }
 /**
  * Returns standard (dynamic) object URL
  *
  * @param int   $iLang   language id [optional]
  * @param array $aParams additional params to use [optional]
  *
  * @return string
  */
 public function getStdLink($iLang = null, $aParams = array())
 {
     if ($iLang === null) {
         $iLang = oxLang::getInstance()->getBaseLanguage();
     }
     return oxUtilsUrl::getInstance()->processUrl($this->getBaseStdLink($iLang), true, $aParams, $iLang);
 }
 /**
  * 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);
 }
Beispiel #12
0
 /**
  * Returns view canonical url
  *
  * @return string
  */
 public function getCanonicalUrl()
 {
     if (oxUtils::getInstance()->seoIsActive() && ($oViewConf = $this->getViewConfig())) {
         return oxUtilsUrl::getInstance()->prepareCanonicalUrl($oViewConf->getHomeLink());
     }
 }
 /**
  * For some user actions (like writing guestbook entry or product
  * review) user must be logged in. So e.g. in product details page
  * there is a link leading to current view. Link contains parameter
  * "sourcecl", which tells where to redirect after successfull login.
  * If this parameter is defined and oxcmp_user::getLoginStatus() ==
  * USER_LOGIN_SUCCESS (means user has just logged in) then user is
  * redirected back to source view.
  *
  * @return null
  */
 public function redirectAfterLogin()
 {
     // in case source class is provided - redirecting back to it with all default parameters
     if (($sSource = oxConfig::getParameter("sourcecl")) && $this->_oaComponents['oxcmp_user']->getLoginStatus() === USER_LOGIN_SUCCESS) {
         $sRedirectUrl = $this->getConfig()->getShopUrl() . 'index.php?cl=' . rawurlencode($sSource);
         // building redirect link
         foreach ($this->getNavigationParams() as $sName => $sValue) {
             if ($sValue && $sName != "sourcecl") {
                 $sRedirectUrl .= '&' . rawurlencode($sName) . "=" . rawurlencode($sValue);
             }
         }
         return oxUtils::getInstance()->redirect(oxUtilsUrl::getInstance()->processUrl($sRedirectUrl), true, 302);
     }
 }
 /**
  * Returns standard URL to product
  *
  * @param int   $iLang   required language. optional
  * @param array $aParams additional params to use [optional]
  *
  * @return string
  */
 public function getStdLink($iLang = null, $aParams = array())
 {
     if ($iLang === null) {
         $iLang = $this->getLanguage();
     }
     if (!isset($this->_aStdUrls[$iLang])) {
         $this->_aStdUrls[$iLang] = $this->getBaseStdLink($iLang);
     }
     return oxUtilsUrl::getInstance()->processUrl($this->_aStdUrls[$iLang], true, $aParams, $iLang);
 }
 /**
  * Returns view canonical url
  *
  * @return string
  */
 public function getCanonicalUrl()
 {
     if ($oProduct = $this->getProduct()) {
         if ($oProduct->oxarticles__oxparentid->value) {
             $oProduct = $this->_getParentProduct($oProduct->oxarticles__oxparentid->value);
         }
         $oUtils = oxUtilsUrl::getInstance();
         if (oxUtils::getInstance()->seoIsActive()) {
             $sUrl = $oUtils->prepareCanonicalUrl($oProduct->getBaseSeoLink($oProduct->getLanguage(), true));
         } else {
             $sUrl = $oUtils->prepareCanonicalUrl($oProduct->getBaseStdLink($oProduct->getLanguage()));
         }
         return $sUrl;
     }
 }
 /**
  * Assigns general product parameters to oxbasketitem object :
  *  - sProduct    - oxarticle object ID;
  *  - title       - products title;
  *  - icon        - icon name;
  *  - link        - details URL's;
  *  - sShopId     - current shop ID;
  *  - sNativeShopId  - article shop ID;
  *  - _sDimageDirNoSsl - NON SSL mode image path;
  *  - _sDimageDirSsl   - SSL mode image path;
  *
  * @param string $sProductId product id
  *
  * @throws oxNoArticleException exception
  *
  * @return null
  */
 protected function _setArticle($sProductId)
 {
     $oConfig = $this->getConfig();
     $oArticle = $this->getArticle(true, $sProductId);
     // product ID
     $this->_sProductId = $sProductId;
     $this->_sTitle = null;
     $this->_sVarSelect = null;
     $this->getTitle();
     // icon and details URL's
     $this->_sIcon = $oArticle->oxarticles__oxicon->value;
     $this->_sIconUrl = $oArticle->getIconUrl();
     $this->_blSsl = $oConfig->isSsl();
     // removing force_sid from the link (incase it'll change)
     $this->_sLink = oxUtilsUrl::getInstance()->cleanUrl($oArticle->getLink(), array('force_sid'));
     // shop Ids
     $this->_sShopId = $oConfig->getShopId();
     $this->_sNativeShopId = $oArticle->oxarticles__oxshopid->value;
     // SSL/NON SSL image paths
     $this->_sDimageDirNoSsl = $oArticle->nossl_dimagedir;
     $this->_sDimageDirSsl = $oArticle->ssl_dimagedir;
 }
Beispiel #17
0
 /**
  * Returns view canonical url
  *
  * @return string
  */
 public function getCanonicalUrl()
 {
     if ($oCategory = $this->getActiveCategory()) {
         $oUtils = oxUtilsUrl::getInstance();
         if (oxUtils::getInstance()->seoIsActive()) {
             $sUrl = $oUtils->prepareCanonicalUrl($oCategory->getBaseSeoLink($oCategory->getLanguage(), $this->getActPage()));
         } else {
             $sUrl = $oUtils->prepareCanonicalUrl($oCategory->getBaseStdLink($oCategory->getLanguage(), $this->getActPage()));
         }
         return $sUrl;
     }
 }
 /**
  * Returns SEO url with shop's path + additional params ( oxseoencoder:: _getAddParams)
  *
  * @param string $sSeoUrl seo URL
  * @param int    $iLang   active language
  * @param bool   $blSsl   forces to build ssl url
  *
  * @return string
  */
 protected function _getFullUrl($sSeoUrl, $iLang = null, $blSsl = false)
 {
     if ($sSeoUrl) {
         $sFullUrl = ($blSsl ? $this->getConfig()->getSslShopUrl($iLang) : $this->getConfig()->getShopUrl($iLang, false)) . $sSeoUrl;
         return oxUtilsUrl::getInstance()->processSeoUrl($sFullUrl);
     }
     return false;
 }
 /**
  * Sets mailer additional settings and sends "InviteMail" mail to user.
  * Returns true on success.
  *
  * @param object $oParams Mailing parameters object
  *
  * @return bool
  */
 public function sendInviteMail($oParams)
 {
     $myConfig = $this->getConfig();
     //sets language of shop
     $iCurrLang = $myConfig->getActiveShop()->getLanguage();
     // shop info
     $oShop = $this->_getShop($iCurrLang);
     // mailer stuff
     $this->setFrom($oParams->send_email, $oParams->send_name);
     $this->setSMTP();
     // create messages
     $oSmarty = oxUtilsView::getInstance()->getSmarty();
     $this->setUser($oParams);
     $sHomeUrl = $this->getViewConfig()->getHomeLink();
     //setting recommended user id
     if ($myConfig->getActiveView()->isActive('Invitations') && ($oActiveUser = $oShop->getUser())) {
         $sHomeUrl = oxUtilsUrl::getInstance()->appendParamSeparator($sHomeUrl);
         $sHomeUrl .= "su=" . $oActiveUser->getId();
     }
     if (is_array($oParams->rec_email) && count($oParams->rec_email) > 0) {
         foreach ($oParams->rec_email as $sEmail) {
             if (!empty($sEmail)) {
                 $sRegisterUrl = oxUtilsUrl::getInstance()->appendParamSeparator($sHomeUrl);
                 //setting recipient user email
                 $sRegisterUrl .= "re=" . md5($sEmail);
                 $this->setViewData("sHomeUrl", $sRegisterUrl);
                 // Process view data array through oxoutput processor
                 $this->_processViewArray();
                 $this->setBody($oSmarty->fetch($this->_sInviteTemplate));
                 $this->setAltBody($oSmarty->fetch($this->_sInviteTemplatePlain));
                 $this->setSubject($oParams->send_subject);
                 $this->setRecipient($sEmail);
                 $this->setReplyTo($oParams->send_email, $oParams->send_name);
                 $this->send();
                 $this->clearAllRecipients();
             }
         }
         return true;
     }
     return false;
 }
 /**
  * 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;
 }
 /**
  * Returns standard URL to category
  *
  * @param int   $iLang   language
  * @param array $aParams additional params to use [optional]
  *
  * @return string
  */
 public function getStdLink($iLang = null, $aParams = array())
 {
     if (isset($this->oxcategories__oxextlink) && $this->oxcategories__oxextlink->value) {
         return oxUtilsUrl::getInstance()->processUrl($this->oxcategories__oxextlink->value, false);
     }
     if ($iLang === null) {
         $iLang = $this->getLanguage();
     }
     if (!isset($this->_aStdUrls[$iLang])) {
         $this->_aStdUrls[$iLang] = $this->getBaseStdLink($iLang);
     }
     return oxUtilsUrl::getInstance()->processUrl($this->_aStdUrls[$iLang], true, $aParams, $iLang);
 }
 /**
  * Admin url getter
  *
  * @return string
  */
 protected function _getAdminUrl()
 {
     $myConfig = $this->getConfig();
     if ($sAdminSslUrl = $myConfig->getConfigParam('sAdminSSLURL')) {
         $sURL = trim($sAdminSslUrl, '/');
     } else {
         $sURL = trim($myConfig->getConfigParam('sShopURL'), '/') . '/admin';
     }
     return oxUtilsUrl::getInstance()->processUrl("{$sURL}/index.php", false);
 }
 /**
  * Sets some global parameters to Smarty engine (such as self link, etc.), returns
  * modified shop object.
  *
  * @param object $oShop Object to modify some parameters
  *
  * @return object
  */
 public function addGlobalParams($oShop = null)
 {
     $mySession = $this->getSession();
     $myConfig = $this->getConfig();
     $oLang = oxLang::getInstance();
     $oShop = parent::addGlobalParams($oShop);
     // override cause of admin dir
     $sURL = $myConfig->getConfigParam('sShopURL') . $myConfig->getConfigParam('sAdminDir') . "/";
     if ($myConfig->getConfigParam('sAdminSSLURL')) {
         $sURL = $myConfig->getConfigParam('sAdminSSLURL');
     }
     $oViewConf = $this->getViewConfig();
     $oViewConf->setViewConfigParam('selflink', oxUtilsUrl::getInstance()->processUrl($sURL . 'index.php?editlanguage=' . $this->_iEditLang, false));
     $oViewConf->setViewConfigParam('ajaxlink', str_replace('&', '&', oxUtilsUrl::getInstance()->processUrl($sURL . 'oxajax.php?editlanguage=' . $this->_iEditLang, false)));
     $oViewConf->setViewConfigParam('sServiceUrl', $this->getServiceUrl());
     $oViewConf->setViewConfigParam('blLoadDynContents', $myConfig->getConfigParam('blLoadDynContents'));
     $oViewConf->setViewConfigParam('sShopCountry', $myConfig->getConfigParam('sShopCountry'));
     // set langugae in admin
     $iDynInterfaceLanguage = $myConfig->getConfigParam('iDynInterfaceLanguage');
     //$this->_aViewData['adminlang'] = isset( $iDynInterfaceLanguage )?$iDynInterfaceLanguage:$myConfig->getConfigParam( 'iAdminLanguage' );
     $this->_aViewData['adminlang'] = isset($iDynInterfaceLanguage) ? $iDynInterfaceLanguage : $oLang->getTplLanguage();
     $this->_aViewData['charset'] = $this->getCharSet();
     //setting active currency object
     $this->_aViewData["oActCur"] = $myConfig->getActShopCurrencyObject();
     return $oShop;
 }
 /**
  * Returns shop SSL URL with index.php and sid.
  *
  * @return string
  */
 public function getShopSecureHomeUrl()
 {
     return oxUtilsUrl::getInstance()->processUrl($this->getSslShopUrl() . 'index.php', false);
 }
Beispiel #25
0
 /**
  * Returns the OXID URL utilities object.
  *
  * @return oxUtilsUrl
  */
 public function getUtilsUrl()
 {
     return oxUtilsUrl::getInstance();
 }
 /**
  * Executes parent::render(), passes currency object to template
  * engine and returns currencies array.
  *
  * Template variables:
  * <b>currency</b>
  *
  * @return array
  */
 public function render()
 {
     parent::render();
     $oParentView = $this->getParent();
     $oParentView->setActCurrency($this->_oActCur);
     $oUrlUtils = oxUtilsUrl::getInstance();
     $sUrl = $oUrlUtils->cleanUrl($this->getParent()->getLink(), array("cur"));
     if ($this->getConfig()->getConfigParam('bl_perfLoadCurrency')) {
         reset($this->aCurrencies);
         while (list(, $oItem) = each($this->aCurrencies)) {
             $oItem->link = $oUrlUtils->processUrl($sUrl, true, array("cur" => $oItem->id));
         }
     }
     return $this->aCurrencies;
 }
 /**
  * Template variable getter. Returns additional params for url
  *
  * @return string
  */
 public function getAdditionalParams()
 {
     return oxUtilsUrl::getInstance()->processUrl('', false);
 }
 /**
  * Get redirect URL or inline iFrame code
  *
  * @param  bool $inline
  * @return bool
  * @throws Exception|oxException
  */
 public function getRedirectUrl($inline = false)
 {
     // TODO: implement currency check
     // Is current currency supported?
     // if (!$this->canUseForCurrency()) {
     //     return false;
     // }
     // Create Rakuten Checkout Insert Cart XML request
     $xml = new SimpleXMLElement("<?xml version='1.0' encoding='UTF-8' ?><tradoria_insert_cart />");
     $merchantAuth = $xml->addChild('merchant_authentication');
     // TODO: investigate why shop is saved as "-1":
     $merchantAuth->addChild('project_id', $this->getConfig()->getShopConfVar('sRakutenProjectId', -1));
     $merchantAuth->addChild('api_key', $this->getConfig()->getShopConfVar('sRakutenApiKey', -1));
     $sLanguageCode = oxLang::getInstance()->getLanguageAbbr();
     if ($sLanguageCode) {
         $sLanguageCode = strtoupper($sLanguageCode);
     }
     if ($sLanguageCode != 'DE') {
         $sLanguageCode = 'DE';
         // TODO: check supported languages based on supported languages list
     }
     $sCurrency = $this->getSession()->getBasket()->_oCurrency->name;
     if ($sCurrency != 'EUR') {
         die('Unsupported currency');
         // TODO: improve currency check!
     }
     $xml->addChild('language', $sLanguageCode);
     $xml->addChild('currency', $sCurrency);
     $merchantCart = $xml->addChild('merchant_carts')->addChild('merchant_cart');
     $sSessionName = $this->getSession()->getName();
     $sSessionId = $this->getSession()->getId();
     $merchantCart->addChild('custom_1', $sSessionName);
     $merchantCart->addChild('custom_2', $sSessionId);
     $merchantCart->addChild('custom_3');
     $merchantCart->addChild('custom_4');
     $merchantCartItems = $merchantCart->addChild('items');
     $items = $this->getSession()->getBasket()->_aBasketContents;
     /** @var $item oxBasketItem */
     foreach ($items as $item) {
         $merchantCartItemsItem = $merchantCartItems->addChild('item');
         $merchantCartItemsItemName = $merchantCartItemsItem->addChild('name');
         $this->_addCDATA($merchantCartItemsItemName, $item->getTitle());
         $merchantCartItemsItem->addChild('sku', $this->_escapeStr($item->getArticle()->oxarticles__oxartnum->value));
         $merchantCartItemsItem->addChild('external_product_id');
         $merchantCartItemsItem->addChild('qty', $item->getAmount());
         // positive integers
         $merchantCartItemsItem->addChild('unit_price', $item->getUnitPrice()->getBruttoPrice());
         $merchantCartItemsItem->addChild('tax_class', $this->getRakutenTaxClass($item->getPrice()->getVat()));
         $merchantCartItemsItem->addChild('image_url', $this->_escapeStr($item->getIconUrl()));
         $merchantCartItemsItem->addChild('product_url', $this->_escapeStr($item->getLink()));
         $options = $item->getVarSelect();
         if (!empty($options)) {
             $custom = $options;
             $comment = $options;
         } else {
             $custom = '';
             $comment = '';
         }
         $merchantCartItemsItemComment = $merchantCartItemsItem->addChild('comment');
         $this->_addCDATA($merchantCartItemsItemComment, $comment);
         $merchantCartItemsItemCustom = $merchantCartItemsItem->addChild('custom');
         $this->_addCDATA($merchantCartItemsItemCustom, $custom);
     }
     $merchantCartShippingRates = $merchantCart->addChild('shipping_rates');
     $shippingRates = $this->_strGetCSV($this->getConfig()->getShopConfVar('sRakutenShippingRates', -1));
     foreach ($shippingRates as $shippingRate) {
         if (isset($shippingRate[0]) && isset($shippingRate[1]) && is_numeric($shippingRate[1])) {
             // TODO: check if buyer country is supported
             $merchantCartShippingRate = $merchantCartShippingRates->addChild('shipping_rate');
             $merchantCartShippingRate->addChild('country', (string) $shippingRate[0]);
             $merchantCartShippingRate->addChild('price', (double) $shippingRate[1]);
             if (isset($shippingRate[2]) && (int) $shippingRate[2] > 0) {
                 $merchantCartShippingRate->addChild('delivery_date', date('Y-m-d', strtotime('+' . (int) $shippingRate[2] . ' days')));
             }
         }
     }
     $billingAddressRestrictions = $xml->addChild('billing_address_restrictions');
     // restrict invoice address to require private / commercial and by country
     $billingAddressRestrictions->addChild('customer_type')->addAttribute('allow', $this->getConfig()->getShopConfVar('iRakutenBillingAddr', -1));
     // 1=all 2=business 3=private
     $aCountries = array();
     /** @var $oCountryList oxCountryList */
     $oCountryList = oxNew('oxcountrylist');
     $oCountryList->loadActiveCountries();
     /** @var $oCountry oxCountry */
     foreach ($oCountryList as $sCountryId => $oCountry) {
         $oCountry->load($sCountryId);
         $aCountries[] = $oCountry->oxcountry__oxisoalpha2->value;
     }
     if (!empty($aCountries)) {
         $billingAddressRestrictions->addChild('countries')->addAttribute('allow', implode(',', $aCountries));
     }
     $baseUrl = $this->getConfig()->getSslShopUrl();
     // Force SID for ROPE URL to load shopping cart data and flush it when order is saved
     $ropeUrl = $baseUrl . oxUtilsUrl::getInstance()->processUrl('index.php', true, array('cl' => 'rakuten', 'fnc' => 'rope'));
     // No forced SID for PIPE URL to avoid session switches after opening Rakuten Checkout iFrame
     $pipeUrl = oxUtilsUrl::getInstance()->processUrl($baseUrl . 'index.php', true, array('cl' => 'rakuten', 'fnc' => 'pipe'));
     $xml->addChild('callback_url', $ropeUrl);
     $xml->addChild('pipe_url', $pipeUrl);
     $request = $xml->asXML();
     $response = $this->sendRequest($request);
     if (!$response) {
         return false;
     }
     try {
         $response = new SimpleXMLElement($response);
         if ($response->success != 'true') {
             throw new oxException((string) $response->message, (int) $response->code);
         } else {
             $redirectUrl = $response->redirect_url;
             $inlineCode = $response->inline_code;
         }
     } catch (oxException $e) {
         oxUtilsView::getInstance()->addErrorToDisplay(sprintf('Error #%s: %s', $e->getCode(), $e->getMessage()));
         return false;
     } catch (Exception $e) {
         oxUtilsView::getInstance()->addErrorToDisplay('Unable to redirect to Rakuten Checkout.');
         return false;
     }
     if ($inline) {
         return $inlineCode;
     } else {
         return $redirectUrl;
     }
 }
 /**
  * Returns manufacturer seo uri for current article
  *
  * @param oxarticle $oArticle     article object
  * @param int       $iLang        language id
  * @param bool      $blRegenerate if TRUE forces seo url regeneration
  *
  * @return string
  */
 public function getArticleManufacturerUri($oArticle, $iLang, $blRegenerate = false)
 {
     $sSeoUri = null;
     startProfile(__FUNCTION__);
     if ($oManufacturer = $this->_getManufacturer($oArticle, $iLang)) {
         //load details link from DB
         if ($blRegenerate || !($sSeoUri = $this->_loadFromDb('oxarticle', $oArticle->getId(), $iLang, null, $oManufacturer->getId(), true))) {
             $oArticle = $this->_getProductForLang($oArticle, $iLang);
             // create title part for uri
             $sTitle = $this->_prepareArticleTitle($oArticle);
             // create uri for all categories
             $sSeoUri = oxSeoEncoderManufacturer::getInstance()->getManufacturerUri($oManufacturer, $iLang);
             $sSeoUri = $this->_processSeoUrl($sSeoUri . $sTitle, $oArticle->getId(), $iLang);
             $aStdParams = array('mnid' => $oManufacturer->getId(), 'listtype' => $this->_getListType());
             $this->_saveToDb('oxarticle', $oArticle->getId(), oxUtilsUrl::getInstance()->appendUrl($oArticle->getBaseStdLink($iLang), $aStdParams), $sSeoUri, $iLang, null, 0, $oManufacturer->getId());
         }
         stopProfile(__FUNCTION__);
     }
     return $sSeoUri;
 }