diff --git a/src/Application/Component/GeoIpComponent.php b/src/Application/Component/GeoIpComponent.php index ca3f2d3..1360227 100644 --- a/src/Application/Component/GeoIpComponent.php +++ b/src/Application/Component/GeoIpComponent.php @@ -23,7 +23,6 @@ use D3\ModCfg\Application\Model\Exception\d3_cfg_mod_exception; use D3\ModCfg\Application\Model\Exception\d3ShopCompatibilityAdapterException; use Doctrine\DBAL\DBALException; use OxidEsales\Eshop\Application\Component\CurrencyComponent; -use OxidEsales\Eshop\Application\Controller\FrontendController; use OxidEsales\Eshop\Core\Controller\BaseController; use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException; use OxidEsales\Eshop\Core\Exception\DatabaseErrorException; @@ -61,17 +60,16 @@ class GeoIpComponent extends BaseController /** @var $oLocation d3geoip */ $oLocation = oxNew(d3geoip::class); $oLocation->setCountryCurrency(); - // moved to oxcmp_lang extension because here it's to late + // moved to oxcmp_lang extension because here it's too late // $oLocation->setCountryLanguage(); if (!isset($oBasket)) { - $oBasket = $this->getSession()->getBasket(); + $oBasket = Registry::getSession()->getBasket(); } // call component again, if curr is registered before we changed it // reason: own component can added after default components only if ($oLocation->hasNotSetCurrency($oBasket->getBasketCurrency())) { - /** @var FrontendController $oActView */ $oActView = Registry::getConfig()->getActiveView(); $aComponents = $oActView->getComponents(); diff --git a/src/Application/Controller/Admin/d3_country_geoip.php b/src/Application/Controller/Admin/d3_country_geoip.php index 47f750f..35be49a 100644 --- a/src/Application/Controller/Admin/d3_country_geoip.php +++ b/src/Application/Controller/Admin/d3_country_geoip.php @@ -41,6 +41,9 @@ class d3_country_geoip extends AdminDetailsController /** * @return string + * @throws DBALException + * @throws DatabaseConnectionException + * @throws DatabaseErrorException */ public function render() { @@ -245,7 +248,7 @@ class d3_country_geoip extends AdminDetailsController if (is_array($aConfLanguages)) { $i = 0; reset($aConfLanguages); - while ((list($key, $val) = each($aConfLanguages))) { + foreach ($aConfLanguages as $key => $val) { if (is_array($aLangParams)) { //skipping non active languages if (false == $aLangParams[$key]['active']) { diff --git a/src/Application/Model/d3geoip.php b/src/Application/Model/d3geoip.php index a53ad9f..465c179 100644 --- a/src/Application/Model/d3geoip.php +++ b/src/Application/Model/d3geoip.php @@ -53,7 +53,7 @@ class d3geoip extends BaseModel /** * get oxcountry object by given IP address (optional) * - * @param string $sIP optional + * @param string|null $sIP optional * * @return Country * @throws d3ShopCompatibilityAdapterException @@ -63,7 +63,7 @@ class d3geoip extends BaseModel * @throws DatabaseErrorException * @throws StandardException */ - public function getUserLocationCountryObject($sIP = null) + public function getUserLocationCountryObject(string $sIP = null) { if (!$this->oCountry) { startProfile(__METHOD__); @@ -123,25 +123,15 @@ class d3geoip extends BaseModel ) { $sIP = $this->_getModConfig()->getValue('sTestCountryIp'); } else { - if(isset($_SERVER['HTTP_CF_CONNECTING_IP'])) { - $sIP = $_SERVER['HTTP_CF_CONNECTING_IP']; - } else if (isset($_SERVER['HTTP_X_REAL_IP'])) { - $sIP = $_SERVER['HTTP_X_REAL_IP']; - } else if (isset($_SERVER['HTTP_CLIENT_IP'])) { - $sIP = $_SERVER['HTTP_CLIENT_IP']; - } else if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { - $sIP = $_SERVER['HTTP_X_FORWARDED_FOR']; - } else if(isset($_SERVER['HTTP_X_FORWARDED'])) { - $sIP = $_SERVER['HTTP_X_FORWARDED']; - } else if(isset($_SERVER['HTTP_FORWARDED_FOR'])) { - $sIP = $_SERVER['HTTP_FORWARDED_FOR']; - } else if(isset($_SERVER['HTTP_FORWARDED'])) { - $sIP = $_SERVER['HTTP_FORWARDED']; - } else if(isset($_SERVER['REMOTE_ADDR'])) { - $sIP = $_SERVER['REMOTE_ADDR']; - } else { - $sIP = 'UNKNOWN'; - } + $sIP = $_SERVER['HTTP_CF_CONNECTING_IP'] + ?? $_SERVER['HTTP_X_REAL_IP'] + ?? $_SERVER['HTTP_CLIENT_IP'] + ?? $_SERVER['HTTP_X_FORWARDED_FOR'] + ?? $_SERVER['HTTP_X_FORWARDED'] + ?? $_SERVER['HTTP_FORWARDED_FOR'] + ?? $_SERVER['HTTP_FORWARDED'] + ?? $_SERVER['REMOTE_ADDR'] + ?? 'UNKNOWN'; } $sIP = str_replace(' ', '', $sIP); @@ -153,12 +143,12 @@ class d3geoip extends BaseModel /** * get ISO alpha 2 ID by IP address * - * @param int $sIP IP address + * @param string $sIP IP address * * @return string * @throws DatabaseConnectionException */ - public function loadByIP($sIP) + public function loadByIP(string $sIP) { startProfile(__METHOD__); @@ -196,7 +186,7 @@ class d3geoip extends BaseModel * @return Country * @throws DatabaseConnectionException */ - public function getCountryObject($sISOAlpha) + public function getCountryObject(string $sISOAlpha) { startProfile(__METHOD__); @@ -376,18 +366,18 @@ class d3geoip extends BaseModel && false == $this->isAdmin() && Registry::getUtils()->isSearchEngine() === false && $oCountry->getId() - && $this->getConfig()->isMall() + && Registry::getConfig()->isMall() && $iNewShop > -1 && ( - $iNewShop != $this->getConfig()->getShopId() - || strtolower($this->getConfig()->getActiveView()->getClassKey()) == 'mallstart' + $iNewShop != Registry::getConfig()->getShopId() + || strtolower(Registry::getConfig()->getActiveView()->getClassKey()) == 'mallstart' ) ) { $oNewConf = new Config(); $oNewConf->setShopId($iNewShop); $oNewConf->init(); - $this->getConfig()->onShopChange(); + Registry::getConfig()->onShopChange(); if (!Registry::getSession()->getVariable('d3isSetLang') && $this->_getModConfig()->getValue('blChangeLang') @@ -502,7 +492,7 @@ class d3geoip extends BaseModel $aShopUrls = array(); foreach ($oShoplist->arrayKeys() as $sId) { - $aShopUrls[$sId] = $this->getConfig()->getShopConfVar('sMallShopURL', $sId); + $aShopUrls[$sId] = Registry::getConfig()->getShopConfVar('sMallShopURL', $sId); } stopProfile(__METHOD__); diff --git a/src/Application/views/admin/de/d3_geoip_lang.php b/src/Application/views/admin/de/d3_geoip_lang.php index b78999e..4a09e26 100644 --- a/src/Application/views/admin/de/d3_geoip_lang.php +++ b/src/Application/views/admin/de/d3_geoip_lang.php @@ -68,7 +68,7 @@ $aLang = [ 'D3_GEOIP_UPDATE_ITEMINSTALL' => 'Die umfangreiche IP-Liste kann leider nicht über die '. 'automatische Installation eingebunden werden. Bitte installieren Sie diese manuell. '.PHP_EOL.PHP_EOL. - 'Laden Sie bitte die aktuellen CSV-Daten des Anbieters Maxmind. In "setup+doku/importCSVtoMySQL" des Modulpaketes finden Sie weitere Informationen und die erforderlichen Datenbank-Befehle, um die nötigen Daten zu generieren.'.PHP_EOL.PHP_EOL. - 'Alternativ finden Sie die erforderlichen Daten im Installationspaket des Moduls unter "setup+doku/geoip-data_*". '.PHP_EOL.PHP_EOL. + 'Laden Sie bitte die aktuellen CSV-Daten des Anbieters Maxmind. In "docs/importCSVtoMySQL" des Modulpaketes finden Sie weitere Informationen und die erforderlichen Datenbank-Befehle, um die nötigen Daten zu generieren.'.PHP_EOL.PHP_EOL. + 'Alternativ finden Sie die erforderlichen Daten im Installationspaket des Moduls unter "docs/geoip-data_*". '.PHP_EOL.PHP_EOL. 'Führen Sie die SQL-Datei(en) bitte in Ihrer Datenbank aus.', ]; diff --git a/src/Application/views/admin/tpl/d3_cfg_geoipset_main.tpl b/src/Application/views/admin/tpl/d3_cfg_geoipset_main.tpl index 530068d..d76b67a 100644 --- a/src/Application/views/admin/tpl/d3_cfg_geoipset_main.tpl +++ b/src/Application/views/admin/tpl/d3_cfg_geoipset_main.tpl @@ -30,7 +30,7 @@ function EditThis( sID) function _groupExp(el) { var _cur = el.parentNode; - if (_cur.className == "exp") _cur.className = ""; + if (_cur.className === "exp") _cur.className = ""; else _cur.className = "exp"; } @@ -47,7 +47,7 @@ function showFormatSettings(sElemId, visible, blUseOldElem) sOldSettingElem = sElemId; } - if (visible == true) { + if (visible === true) { document.getElementById(sElemId).style.display = 'block'; } else { document.getElementById(sElemId).style.display = 'none'; @@ -57,7 +57,7 @@ function showFormatSettings(sElemId, visible, blUseOldElem) --> -