fix small issues

This commit is contained in:
Daniel Seifert 2020-06-10 10:28:16 +02:00
parent 3c82f793e6
commit bb54488989
Signed by: DanielS
GPG Key ID: 8A7C4C6ED1915C6F
13 changed files with 293 additions and 223 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "d3/geoip", "name": "d3/geoip",
"description": "GeoIP preselection for oxid eShop v6", "description": "GeoIP preselection",
"type": "oxideshop-module", "type": "oxideshop-module",
"authors": [ "authors": [
{ {
@ -19,6 +19,7 @@
"eShop", "eShop",
"d3", "d3",
"GeoIp", "GeoIp",
"language",
"country", "country",
"countries", "countries",
"currency", "currency",
@ -36,7 +37,7 @@
}, },
"require": { "require": {
"php": ">=5.6", "php": ">=5.6",
"oxid-esales/oxideshop-ce": "6.0 - 6.3", "oxid-esales/oxideshop-ce": "6.2 - 6.3",
"d3/modcfg": "^5.3.1.0" "d3/modcfg": "^5.3.1.0"
}, },
"autoload": { "autoload": {

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* This Software is the property of Data Development and is protected * This Software is the property of Data Development and is protected
* by copyright law - it is NOT Freeware. * by copyright law - it is NOT Freeware.
@ -9,8 +10,8 @@
* *
* http://www.shopmodule.com * http://www.shopmodule.com
* *
* @copyright © Data Development, Thomas Dartsch * @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
* @author D³ Data Development - Daniel Seifert <ds@shopmodule.com> * @author D3 Data Development - Daniel Seifert <support@shopmodule.com>
* @link http://www.oxidmodule.com * @link http://www.oxidmodule.com
*/ */
@ -21,6 +22,8 @@ use D3\ModCfg\Application\Model\Configuration\d3_cfg_mod;
use D3\ModCfg\Application\Model\Exception\d3_cfg_mod_exception; use D3\ModCfg\Application\Model\Exception\d3_cfg_mod_exception;
use D3\ModCfg\Application\Model\Exception\d3ShopCompatibilityAdapterException; use D3\ModCfg\Application\Model\Exception\d3ShopCompatibilityAdapterException;
use Doctrine\DBAL\DBALException; 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\Controller\BaseController;
use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException; use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
use OxidEsales\Eshop\Core\Exception\DatabaseErrorException; use OxidEsales\Eshop\Core\Exception\DatabaseErrorException;
@ -39,14 +42,12 @@ class GeoIpComponent extends BaseController
private $_sModId = 'd3_geoip'; private $_sModId = 'd3_geoip';
/** /**
* @throws d3ShopCompatibilityAdapterException
* @throws d3_cfg_mod_exception
* @throws DBALException * @throws DBALException
* @throws DatabaseConnectionException * @throws DatabaseConnectionException
* @throws DatabaseErrorException * @throws DatabaseErrorException
* @throws StandardException * @throws StandardException
* @throws ConnectionException * @throws d3ShopCompatibilityAdapterException
* @throws SystemComponentException * @throws d3_cfg_mod_exception
*/ */
public function init() public function init()
{ {
@ -70,11 +71,11 @@ class GeoIpComponent extends BaseController
// call component again, if curr is registered before we changed it // call component again, if curr is registered before we changed it
// reason: own component can added after default components only // reason: own component can added after default components only
if ($oLocation->hasNotSetCurrency($oBasket->getBasketCurrency())) { if ($oLocation->hasNotSetCurrency($oBasket->getBasketCurrency())) {
/** @var oxUBase $oActView */ /** @var FrontendController $oActView */
$oActView = Registry::getConfig()->getActiveView(); $oActView = Registry::getConfig()->getActiveView();
$aComponents = $oActView->getComponents(); $aComponents = $oActView->getComponents();
/** @var oxcmp_cur $oCurCmp */ /** @var CurrencyComponent $oCurCmp */
$oCurCmp = $aComponents['oxcmp_cur']; $oCurCmp = $aComponents['oxcmp_cur'];
$oCurCmp->init(); $oCurCmp->init();
} }

View File

@ -1,9 +1,5 @@
<?php <?php
namespace D3\GeoIp\Application\Controller\Admin;
use D3\ModCfg\Application\Controller\Admin\d3_cfg_mod_;
/** /**
* This Software is the property of Data Development and is protected * This Software is the property of Data Development and is protected
* by copyright law - it is NOT Freeware. * by copyright law - it is NOT Freeware.
@ -15,9 +11,14 @@ use D3\ModCfg\Application\Controller\Admin\d3_cfg_mod_;
* http://www.shopmodule.com * http://www.shopmodule.com
* *
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch) * @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
* @author D3 Data Development - Daniel Seifert <ds@shopmodule.com> * @author D3 Data Development - Daniel Seifert <support@shopmodule.com>
* @link http://www.oxidmodule.com * @link http://www.oxidmodule.com
*/ */
namespace D3\GeoIp\Application\Controller\Admin;
use D3\ModCfg\Application\Controller\Admin\d3_cfg_mod_;
class d3_cfg_geoipset extends d3_cfg_mod_ class d3_cfg_geoipset extends d3_cfg_mod_
{ {
/** /**

View File

@ -1,12 +1,5 @@
<?php <?php
namespace D3\GeoIp\Application\Controller\Admin;
use D3\GeoIp\Application\Model\d3geoip;
use D3\ModCfg\Application\Controller\Admin\d3_cfg_mod_main;
use OxidEsales\Eshop\Application\Model\CountryList;
use OxidEsales\Eshop\Core\Registry;
/** /**
* This Software is the property of Data Development and is protected * This Software is the property of Data Development and is protected
* by copyright law - it is NOT Freeware. * by copyright law - it is NOT Freeware.
@ -18,9 +11,23 @@ use OxidEsales\Eshop\Core\Registry;
* http://www.shopmodule.com * http://www.shopmodule.com
* *
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch) * @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
* @author D3 Data Development - Daniel Seifert <ds@shopmodule.com> * @author D3 Data Development - Daniel Seifert <support@shopmodule.com>
* @link http://www.oxidmodule.com * @link http://www.oxidmodule.com
*/ */
namespace D3\GeoIp\Application\Controller\Admin;
use D3\GeoIp\Application\Model\d3geoip;
use D3\ModCfg\Application\Controller\Admin\d3_cfg_mod_main;
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\Model\CountryList;
use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
use OxidEsales\Eshop\Core\Exception\DatabaseErrorException;
use OxidEsales\Eshop\Core\Exception\StandardException;
use OxidEsales\Eshop\Core\Registry;
class d3_cfg_geoipset_main extends d3_cfg_mod_main class d3_cfg_geoipset_main extends d3_cfg_mod_main
{ {
protected $_sModId = 'd3_geoip'; protected $_sModId = 'd3_geoip';
@ -34,12 +41,12 @@ class d3_cfg_geoipset_main extends d3_cfg_mod_main
/** /**
* @param $sIP * @param $sIP
* @return string * @return string
* @throws \D3\ModCfg\Application\Model\Exception\d3ShopCompatibilityAdapterException * @throws d3ShopCompatibilityAdapterException
* @throws \D3\ModCfg\Application\Model\Exception\d3_cfg_mod_exception * @throws d3_cfg_mod_exception
* @throws \Doctrine\DBAL\DBALException * @throws DBALException
* @throws \OxidEsales\Eshop\Core\Exception\DatabaseConnectionException * @throws DatabaseConnectionException
* @throws \OxidEsales\Eshop\Core\Exception\DatabaseErrorException * @throws DatabaseErrorException
* @throws \OxidEsales\Eshop\Core\Exception\StandardException * @throws StandardException
*/ */
public function getIpCountry($sIP) public function getIpCountry($sIP)
{ {

View File

@ -17,10 +17,15 @@
namespace D3\GeoIp\Application\Controller\Admin; namespace D3\GeoIp\Application\Controller\Admin;
use D3\ModCfg\Application\Model\Configuration\d3_cfg_mod; use D3\ModCfg\Application\Model\Configuration\d3_cfg_mod;
use Doctrine\DBAL\DBALException;
use OxidEsales\Eshop\Application\Controller\Admin\AdminDetailsController; use OxidEsales\Eshop\Application\Controller\Admin\AdminDetailsController;
use OxidEsales\Eshop\Application\Model\Country;
use OxidEsales\Eshop\Application\Model\Shop;
use OxidEsales\Eshop\Application\Model\ShopList;
use OxidEsales\Eshop\Core\DatabaseProvider; use OxidEsales\Eshop\Core\DatabaseProvider;
use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
use OxidEsales\Eshop\Core\Exception\DatabaseErrorException;
use OxidEsales\Eshop\Core\Registry; use OxidEsales\Eshop\Core\Registry;
use OxidEsales\Eshop\Core\Request;
use stdClass; use stdClass;
class d3_country_geoip extends AdminDetailsController class d3_country_geoip extends AdminDetailsController
@ -29,9 +34,9 @@ class d3_country_geoip extends AdminDetailsController
protected $_sDefSortOrder = 'asc'; protected $_sDefSortOrder = 'asc';
protected $_sThisTemplate = 'd3_country_geoip.tpl'; protected $_sThisTemplate = 'd3_country_geoip.tpl';
private $_sModId = 'd3_geoip'; private $_sModId = 'd3_geoip';
/** @var oxcountry */ /** @var Country */
public $oCountry; public $oCountry;
/** @var oxshoplist */ /** @var ShopList */
public $oShopList; public $oShopList;
/** /**
@ -45,9 +50,9 @@ class d3_country_geoip extends AdminDetailsController
$ret = parent::render(); $ret = parent::render();
$soxId = Registry::get(Request::class)->getRequestParameter("oxid"); $soxId = Registry::getRequest()->getRequestEscapedParameter("oxid");
// check if we right now saved a new entry // check if we right now saved a new entry
$sSavedID = Registry::get(Request::class)->getRequestParameter("saved_oxid"); $sSavedID = Registry::getRequest()->getRequestEscapedParameter("saved_oxid");
if (($soxId == "-1" || !isset($soxId)) && isset($sSavedID)) { if (($soxId == "-1" || !isset($soxId)) && isset($sSavedID)) {
$soxId = $sSavedID; $soxId = $sSavedID;
Registry::getSession()->deleteVariable("saved_oxid"); Registry::getSession()->deleteVariable("saved_oxid");
@ -58,8 +63,8 @@ class d3_country_geoip extends AdminDetailsController
if ($soxId != "-1" && isset($soxId)) { if ($soxId != "-1" && isset($soxId)) {
// load object // load object
/** @var $oCountry oxcountry */ /** @var $oCountry Country */
$oCountry = oxNew("oxcountry"); $oCountry = oxNew(Country::class);
$oCountry->loadInLang($this->_iEditLang, $soxId); $oCountry->loadInLang($this->_iEditLang, $soxId);
if ($oCountry->isForeignCountry()) { if ($oCountry->isForeignCountry()) {
@ -93,9 +98,9 @@ class d3_country_geoip extends AdminDetailsController
$this->addTplParam("blForeignCountry", true); $this->addTplParam("blForeignCountry", true);
} }
$this->oShopList = oxNew('oxshoplist'); $this->oShopList = oxNew(ShopList::class);
/** @var $oShop oxshop */ /** @var $oShop Shop */
$oShop = oxNew('oxshop'); $oShop = oxNew(Shop::class);
$sSelect = "SELECT * FROM ".$oShop->getViewName()." WHERE ".$oShop->getSqlActiveSnippet(); $sSelect = "SELECT * FROM ".$oShop->getViewName()." WHERE ".$oShop->getSqlActiveSnippet();
$this->oShopList->selectString($sSelect); $this->oShopList->selectString($sSelect);
$this->getLangList(); $this->getLangList();
@ -106,9 +111,9 @@ class d3_country_geoip extends AdminDetailsController
/** /**
* @param $sIdent * @param $sIdent
* @return mixed * @return mixed
* @throws \Doctrine\DBAL\DBALException * @throws DBALException
* @throws \OxidEsales\Eshop\Core\Exception\DatabaseConnectionException * @throws DatabaseConnectionException
* @throws \OxidEsales\Eshop\Core\Exception\DatabaseErrorException * @throws DatabaseErrorException
*/ */
public function getModCfgValue($sIdent) public function getModCfgValue($sIdent)
{ {
@ -132,11 +137,11 @@ class d3_country_geoip extends AdminDetailsController
return; return;
} }
$soxId = Registry::get(Request::class)->getRequestParameter("oxid"); $soxId = Registry::getRequest()->getRequestEscapedParameter("oxid");
$aParams = Registry::get(Request::class)->getRequestParameter("editval"); $aParams = Registry::getRequest()->getRequestEscapedParameter("editval");
/** @var $oCountry oxcountry */ /** @var $oCountry Country */
$oCountry = oxNew("oxcountry"); $oCountry = oxNew(Country::class);
if ($soxId != "-1") { if ($soxId != "-1") {
$oCountry->loadInLang($this->_iEditLang, $soxId); $oCountry->loadInLang($this->_iEditLang, $soxId);
@ -159,7 +164,7 @@ class d3_country_geoip extends AdminDetailsController
} }
/** /**
* @return oxshoplist * @return ShopList
*/ */
public function getShopList() public function getShopList()
{ {
@ -168,9 +173,9 @@ class d3_country_geoip extends AdminDetailsController
/** /**
* @return array * @return array
* @throws \Doctrine\DBAL\DBALException * @throws DBALException
* @throws \OxidEsales\Eshop\Core\Exception\DatabaseConnectionException * @throws DatabaseConnectionException
* @throws \OxidEsales\Eshop\Core\Exception\DatabaseErrorException * @throws DatabaseErrorException
*/ */
public function getCurList() public function getCurList()
{ {
@ -204,9 +209,11 @@ class d3_country_geoip extends AdminDetailsController
if ($sCurrencies) { if ($sCurrencies) {
foreach (unserialize($sCurrencies) as $sKey => $sValue) { foreach (unserialize($sCurrencies) as $sKey => $sValue) {
$aFields = explode('@', $sValue); $aFields = explode('@', $sValue);
$aCurrencies[$sKey]->id = trim($sKey); $cur = new stdClass();
$aCurrencies[$sKey]->name = trim($aFields[0]); $cur->id = trim($sKey);
$aCurrencies[$sKey]->sign = trim($aFields[4]); $cur->name = trim($aFields[0]);
$cur->sign = trim($aFields[4]);
$aCurrencies[$sKey] = $cur;
} }
} }
@ -216,9 +223,9 @@ class d3_country_geoip extends AdminDetailsController
/** /**
* ToDo: has to be refactored * ToDo: has to be refactored
* @return array * @return array
* @throws \Doctrine\DBAL\DBALException * @throws DBALException
* @throws \OxidEsales\Eshop\Core\Exception\DatabaseConnectionException * @throws DatabaseConnectionException
* @throws \OxidEsales\Eshop\Core\Exception\DatabaseErrorException * @throws DatabaseErrorException
*/ */
public function getLangList() public function getLangList()
{ {

View File

@ -17,12 +17,19 @@
namespace D3\GeoIp\Application\Model; namespace D3\GeoIp\Application\Model;
use D3\ModCfg\Application\Model\Configuration\d3_cfg_mod; use D3\ModCfg\Application\Model\Configuration\d3_cfg_mod;
use D3\ModCfg\Application\Model\d3str;
use D3\ModCfg\Application\Model\Exception\d3_cfg_mod_exception;
use D3\ModCfg\Application\Model\Exception\d3ShopCompatibilityAdapterException;
use D3\ModCfg\Application\Model\Log\d3log; use D3\ModCfg\Application\Model\Log\d3log;
use Doctrine\DBAL\DBALException;
use OxidEsales\Eshop\Application\Model\Country; use OxidEsales\Eshop\Application\Model\Country;
use OxidEsales\Eshop\Core\Config;
use OxidEsales\Eshop\Core\DatabaseProvider; use OxidEsales\Eshop\Core\DatabaseProvider;
use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
use OxidEsales\Eshop\Core\Exception\DatabaseErrorException;
use OxidEsales\Eshop\Core\Exception\StandardException;
use OxidEsales\Eshop\Core\Model\BaseModel; use OxidEsales\Eshop\Core\Model\BaseModel;
use OxidEsales\Eshop\Core\Registry; use OxidEsales\Eshop\Core\Registry;
use OxidEsales\Eshop\Core\Request;
class d3geoip extends BaseModel class d3geoip extends BaseModel
{ {
@ -45,13 +52,13 @@ class d3geoip extends BaseModel
* *
* @param string $sIP optional * @param string $sIP optional
* *
* @return oxcountry * @return Country
* @throws \D3\ModCfg\Application\Model\Exception\d3ShopCompatibilityAdapterException * @throws d3ShopCompatibilityAdapterException
* @throws \D3\ModCfg\Application\Model\Exception\d3_cfg_mod_exception * @throws d3_cfg_mod_exception
* @throws \Doctrine\DBAL\DBALException * @throws DBALException
* @throws \OxidEsales\Eshop\Core\Exception\DatabaseConnectionException * @throws DatabaseConnectionException
* @throws \OxidEsales\Eshop\Core\Exception\DatabaseErrorException * @throws DatabaseErrorException
* @throws \OxidEsales\Eshop\Core\Exception\StandardException * @throws StandardException
*/ */
public function getUserLocationCountryObject($sIP = null) public function getUserLocationCountryObject($sIP = null)
{ {
@ -96,9 +103,9 @@ class d3geoip extends BaseModel
* get IP address from client or set test IP address * get IP address from client or set test IP address
* *
* @return string * @return string
* @throws \Doctrine\DBAL\DBALException * @throws DBALException
* @throws \OxidEsales\Eshop\Core\Exception\DatabaseConnectionException * @throws DatabaseConnectionException
* @throws \OxidEsales\Eshop\Core\Exception\DatabaseErrorException * @throws DatabaseErrorException
*/ */
public function getIP() public function getIP()
{ {
@ -146,7 +153,7 @@ class d3geoip extends BaseModel
* @param int $sIP IP address * @param int $sIP IP address
* *
* @return string * @return string
* @throws \OxidEsales\Eshop\Core\Exception\DatabaseConnectionException * @throws DatabaseConnectionException
*/ */
public function loadByIP($sIP) public function loadByIP($sIP)
{ {
@ -184,7 +191,7 @@ class d3geoip extends BaseModel
* @param string $sISOAlpha * @param string $sISOAlpha
* *
* @return Country * @return Country
* @throws \OxidEsales\Eshop\Core\Exception\DatabaseConnectionException * @throws DatabaseConnectionException
*/ */
public function getCountryObject($sISOAlpha) public function getCountryObject($sISOAlpha)
{ {
@ -206,10 +213,10 @@ class d3geoip extends BaseModel
/** /**
* get Country object for fallback, if set * get Country object for fallback, if set
* *
* @return oxcountry * @return Country
* @throws \Doctrine\DBAL\DBALException * @throws DBALException
* @throws \OxidEsales\Eshop\Core\Exception\DatabaseConnectionException * @throws DatabaseConnectionException
* @throws \OxidEsales\Eshop\Core\Exception\DatabaseErrorException * @throws DatabaseErrorException
*/ */
public function getCountryFallBackObject() public function getCountryFallBackObject()
{ {
@ -220,7 +227,7 @@ class d3geoip extends BaseModel
if ($this->_getModConfig()->getValue('blUseFallback') if ($this->_getModConfig()->getValue('blUseFallback')
&& $this->_getModConfig()->getValue('sFallbackCountryId') && $this->_getModConfig()->getValue('sFallbackCountryId')
) { ) {
$oCountry->Load($this->_getModConfig()->getValue('sFallbackCountryId')); $oCountry->load($this->_getModConfig()->getValue('sFallbackCountryId'));
} }
stopProfile(__METHOD__); stopProfile(__METHOD__);
@ -231,14 +238,12 @@ class d3geoip extends BaseModel
/** /**
* check module active state and set user country specific language * check module active state and set user country specific language
* *
* @throws \D3\ModCfg\Application\Model\Exception\d3ShopCompatibilityAdapterException * @throws DBALException
* @throws \D3\ModCfg\Application\Model\Exception\d3_cfg_mod_exception * @throws DatabaseConnectionException
* @throws \Doctrine\DBAL\DBALException * @throws DatabaseErrorException
* @throws \OxidEsales\Eshop\Core\Exception\DatabaseConnectionException * @throws StandardException
* @throws \OxidEsales\Eshop\Core\Exception\DatabaseErrorException * @throws d3ShopCompatibilityAdapterException
* @throws \OxidEsales\Eshop\Core\Exception\StandardException * @throws d3_cfg_mod_exception
* @throws oxConnectionException
* @throws oxSystemComponentException
*/ */
public function setCountryLanguage() public function setCountryLanguage()
{ {
@ -280,14 +285,12 @@ class d3geoip extends BaseModel
/** /**
* check module active state and set user country specific currency * check module active state and set user country specific currency
* *
* @throws \D3\ModCfg\Application\Model\Exception\d3ShopCompatibilityAdapterException * @throws DBALException
* @throws \D3\ModCfg\Application\Model\Exception\d3_cfg_mod_exception * @throws DatabaseConnectionException
* @throws \Doctrine\DBAL\DBALException * @throws DatabaseErrorException
* @throws \OxidEsales\Eshop\Core\Exception\DatabaseConnectionException * @throws StandardException
* @throws \OxidEsales\Eshop\Core\Exception\DatabaseErrorException * @throws d3ShopCompatibilityAdapterException
* @throws \OxidEsales\Eshop\Core\Exception\StandardException * @throws d3_cfg_mod_exception
* @throws oxConnectionException
* @throws oxSystemComponentException
*/ */
public function setCountryCurrency() public function setCountryCurrency()
{ {
@ -322,14 +325,17 @@ class d3geoip extends BaseModel
stopProfile(__METHOD__); stopProfile(__METHOD__);
} }
/** /**
* @param $oCurr * @param $oCurr
* *
* @return bool * @return bool
* @throws d3_cfg_mod_exception * @throws DBALException
* @throws oxConnectionException * @throws DatabaseConnectionException
* @throws oxSystemComponentException * @throws DatabaseErrorException
*/ * @throws StandardException
* @throws d3ShopCompatibilityAdapterException
* @throws d3_cfg_mod_exception
*/
public function hasNotSetCurrency($oCurr) public function hasNotSetCurrency($oCurr)
{ {
$oCountry = $this->getUserLocationCountryObject(); $oCountry = $this->getUserLocationCountryObject();
@ -345,14 +351,12 @@ class d3geoip extends BaseModel
/** /**
* check module active state and perform switching to user country specific shop (EE only) * check module active state and perform switching to user country specific shop (EE only)
* *
* @throws \D3\ModCfg\Application\Model\Exception\d3ShopCompatibilityAdapterException * @throws DBALException
* @throws \D3\ModCfg\Application\Model\Exception\d3_cfg_mod_exception * @throws DatabaseConnectionException
* @throws \Doctrine\DBAL\DBALException * @throws DatabaseErrorException
* @throws \OxidEsales\Eshop\Core\Exception\DatabaseConnectionException * @throws StandardException
* @throws \OxidEsales\Eshop\Core\Exception\DatabaseErrorException * @throws d3ShopCompatibilityAdapterException
* @throws \OxidEsales\Eshop\Core\Exception\StandardException * @throws d3_cfg_mod_exception
* @throws oxConnectionException
* @throws oxSystemComponentException
*/ */
public function performShopSwitch() public function performShopSwitch()
{ {
@ -365,7 +369,7 @@ class d3geoip extends BaseModel
$oCountry = $this->getUserLocationCountryObject(); $oCountry = $this->getUserLocationCountryObject();
$iNewShop = $oCountry->getFieldData('d3geoipshop'); $iNewShop = $oCountry->getFieldData('d3geoipshop');
if (Registry::get(Request::class)->getRequestParameter('d3redirect') != 1 if (Registry::getRequest()->getRequestEscapedParameter('d3redirect') != 1
&& false == $this->isAdmin() && false == $this->isAdmin()
&& Registry::getUtils()->isSearchEngine() === false && Registry::getUtils()->isSearchEngine() === false
&& $oCountry->getId() && $oCountry->getId()
@ -376,7 +380,7 @@ class d3geoip extends BaseModel
|| strtolower($this->getConfig()->getActiveView()->getClassKey()) == 'mallstart' || strtolower($this->getConfig()->getActiveView()->getClassKey()) == 'mallstart'
) )
) { ) {
$oNewConf = new oxConfig(); $oNewConf = new Config();
$oNewConf->setShopId($iNewShop); $oNewConf->setShopId($iNewShop);
$oNewConf->init(); $oNewConf->init();
@ -392,10 +396,10 @@ class d3geoip extends BaseModel
} }
/** @var $oStr d3str */ /** @var $oStr d3str */
$oStr = Registry::get('d3str'); $oStr = Registry::get(d3str::class);
$aParams = array( $aParams = array(
'd3redirect' => '1', 'd3redirect' => '1',
'fnc' => Registry::get(Request::class)->getRequestParameter('fnc'), 'fnc' => Registry::getRequest()->getRequestEscapedParameter('fnc'),
'shp' => $iNewShop 'shp' => $iNewShop
); );
$sUrl = str_replace( $sUrl = str_replace(
@ -423,14 +427,12 @@ class d3geoip extends BaseModel
/** /**
* check module active state and perform switching to user country specific url * check module active state and perform switching to user country specific url
* *
* @throws \D3\ModCfg\Application\Model\Exception\d3ShopCompatibilityAdapterException * @throws DBALException
* @throws \D3\ModCfg\Application\Model\Exception\d3_cfg_mod_exception * @throws DatabaseConnectionException
* @throws \Doctrine\DBAL\DBALException * @throws DatabaseErrorException
* @throws \OxidEsales\Eshop\Core\Exception\DatabaseConnectionException * @throws StandardException
* @throws \OxidEsales\Eshop\Core\Exception\DatabaseErrorException * @throws d3ShopCompatibilityAdapterException
* @throws \OxidEsales\Eshop\Core\Exception\StandardException * @throws d3_cfg_mod_exception
* @throws oxConnectionException
* @throws oxSystemComponentException
*/ */
public function performURLSwitch() public function performURLSwitch()
{ {
@ -470,9 +472,8 @@ class d3geoip extends BaseModel
/** /**
* get all shop urls * get all shop urls
* *
* @return array * @return array
* @throws oxSystemComponentException */
*/
public function getShopUrls() public function getShopUrls()
{ {
startProfile(__METHOD__); startProfile(__METHOD__);
@ -494,9 +495,9 @@ class d3geoip extends BaseModel
* get modcfg instance * get modcfg instance
* *
* @return d3_cfg_mod * @return d3_cfg_mod
* @throws \Doctrine\DBAL\DBALException * @throws DBALException
* @throws \OxidEsales\Eshop\Core\Exception\DatabaseConnectionException * @throws DatabaseConnectionException
* @throws \OxidEsales\Eshop\Core\Exception\DatabaseErrorException * @throws DatabaseErrorException
*/ */
protected function _getModConfig() protected function _getModConfig()
{ {
@ -507,9 +508,9 @@ class d3geoip extends BaseModel
* get d3log instance * get d3log instance
* *
* @return d3log * @return d3log
* @throws \Doctrine\DBAL\DBALException * @throws DBALException
* @throws \OxidEsales\Eshop\Core\Exception\DatabaseConnectionException * @throws DatabaseConnectionException
* @throws \OxidEsales\Eshop\Core\Exception\DatabaseErrorException * @throws DatabaseErrorException
*/ */
protected function _getLog() protected function _getLog()
{ {

View File

@ -14,8 +14,16 @@
* @link http://www.oxidmodule.com * @link http://www.oxidmodule.com
*/ */
/** */ namespace D3\GeoIp\Modules\Application\Component {
class d3_oxcmp_cur_geoip_parent extends oxcmp_cur {}
/** */ use OxidEsales\Eshop\Application\Component\LanguageComponent;
class d3_oxcmp_lang_geoip_parent extends oxcmp_lang {}
class d3_oxcmp_lang_geoip_parent extends LanguageComponent {}
}
namespace D3\GeoIp\Modules\Core {
use OxidEsales\Eshop\Core\ShopControl;
class d3_oxshopcontrol_geoip_parent extends ShopControl {}
}

View File

@ -1,21 +1,42 @@
<?php <?php
/**
* This Software is the property of Data Development and is protected
* by copyright law - it is NOT Freeware.
*
* Any unauthorized use of this software without a valid license
* is a violation of the license agreement and will be prosecuted by
* civil and criminal law.
*
* http://www.shopmodule.com
*
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
* @author D3 Data Development - Daniel Seifert <ds@shopmodule.com>
* @link http://www.oxidmodule.com
*/
namespace D3\GeoIp\Modules\Application\Component; namespace D3\GeoIp\Modules\Application\Component;
use D3\GeoIp\Application\Model\d3geoip; use D3\GeoIp\Application\Model\d3geoip;
use D3\ModCfg\Application\Model\Configuration\d3_cfg_mod; use D3\ModCfg\Application\Model\Configuration\d3_cfg_mod;
use D3\ModCfg\Application\Model\Exception\d3_cfg_mod_exception;
use D3\ModCfg\Application\Model\Exception\d3ShopCompatibilityAdapterException;
use Doctrine\DBAL\DBALException;
use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
use OxidEsales\Eshop\Core\Exception\DatabaseErrorException;
use OxidEsales\Eshop\Core\Exception\StandardException;
class d3_oxcmp_lang_geoip extends d3_oxcmp_lang_geoip_parent class d3_oxcmp_lang_geoip extends d3_oxcmp_lang_geoip_parent
{ {
private $_sModId = 'd3_geoip'; private $_sModId = 'd3_geoip';
/** /**
* @throws \D3\ModCfg\Application\Model\Exception\d3ShopCompatibilityAdapterException * @throws d3ShopCompatibilityAdapterException
* @throws \D3\ModCfg\Application\Model\Exception\d3_cfg_mod_exception * @throws d3_cfg_mod_exception
* @throws \Doctrine\DBAL\DBALException * @throws DBALException
* @throws \OxidEsales\Eshop\Core\Exception\DatabaseConnectionException * @throws DatabaseConnectionException
* @throws \OxidEsales\Eshop\Core\Exception\DatabaseErrorException * @throws DatabaseErrorException
* @throws \OxidEsales\Eshop\Core\Exception\StandardException * @throws StandardException
*/ */
public function init() public function init()
{ {

View File

@ -16,6 +16,7 @@
namespace D3\GeoIp\Modules\Core; namespace D3\GeoIp\Modules\Core;
use D3\GeoIp\Application\Component\GeoIpComponent;
use OxidEsales\Eshop\Core\Registry; use OxidEsales\Eshop\Core\Registry;
class d3_oxshopcontrol_geoip extends d3_oxshopcontrol_geoip_parent class d3_oxshopcontrol_geoip extends d3_oxshopcontrol_geoip_parent
@ -41,8 +42,7 @@ class d3_oxshopcontrol_geoip extends d3_oxshopcontrol_geoip_parent
startProfile(__METHOD__); startProfile(__METHOD__);
$aUserComponentNames = Registry::getConfig()->getConfigParam('aUserComponentNames'); $aUserComponentNames = Registry::getConfig()->getConfigParam('aUserComponentNames');
$sGeoIpCmpName = 'GeoIpComponent'; $sGeoIpCmpName = GeoIpComponent::class;
$sGeoIpCmpName = \D3\GeoIp\Application\Component\GeoIpComponent::class;
$blDontUseCache = 1; $blDontUseCache = 1;
if (false == is_array($aUserComponentNames)) { if (false == is_array($aUserComponentNames)) {

49
src/Setup/Events.php Normal file
View File

@ -0,0 +1,49 @@
<?php
/**
* This Software is the property of Data Development and is protected
* by copyright law - it is NOT Freeware.
*
* Any unauthorized use of this software without a valid license
* is a violation of the license agreement and will be prosecuted by
* civil and criminal law.
*
* http://www.shopmodule.com
*
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
* @author D3 Data Development - Daniel Seifert <support@shopmodule.com>
* @link http://www.oxidmodule.com
*/
// @codeCoverageIgnoreStart
namespace D3\GeoIp\Setup;
use D3\ModCfg\Application\Model\Exception\d3ShopCompatibilityAdapterException;
use D3\ModCfg\Application\Model\Install\d3install;
use Doctrine\DBAL\DBALException;
use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
use OxidEsales\Eshop\Core\Exception\DatabaseErrorException;
use OxidEsales\Eshop\Core\Exception\StandardException;
use OxidEsales\Eshop\Core\Exception\SystemComponentException;
class Events
{
/**
* @throws d3ShopCompatibilityAdapterException
* @throws DBALException
* @throws DatabaseConnectionException
* @throws DatabaseErrorException
* @throws StandardException
* @throws SystemComponentException
*/
public static function onActivate()
{
d3install::checkUpdateStart();
}
public static function onDeactivate()
{
}
}
// @codeCoverageIgnoreEnd

View File

@ -1,5 +1,5 @@
<?php <?php
/** /**
* This Software is the property of Data Development and is protected * This Software is the property of Data Development and is protected
* by copyright law - it is NOT Freeware. * by copyright law - it is NOT Freeware.
* *
@ -9,8 +9,8 @@
* *
* http://www.shopmodule.com * http://www.shopmodule.com
* *
* @copyright © Data Development, Thomas Dartsch * @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
* @author D³ Data Development - Daniel Seifert <ds@shopmodule.com> * @author D3 Data Development - Daniel Seifert <support@shopmodule.com>
* @link http://www.oxidmodule.com * @link http://www.oxidmodule.com
*/ */
@ -18,30 +18,31 @@ namespace D3\GeoIp\Setup;
use D3\ModCfg\Application\Model\Install\d3install_updatebase; use D3\ModCfg\Application\Model\Install\d3install_updatebase;
use D3\ModCfg\Application\Model\Installwizzard\d3installdbfield; use D3\ModCfg\Application\Model\Installwizzard\d3installdbfield;
use D3\ModCfg\Application\Model\Installwizzard\d3installdbrecord;
use d3\modcfg\Application\Model\d3database;
use D3\ModCfg\Application\Model\Installwizzard\d3installdbtable; use D3\ModCfg\Application\Model\Installwizzard\d3installdbtable;
use Doctrine\DBAL\DBALException;
use OxidEsales\Eshop\Application\Model\Shop; use OxidEsales\Eshop\Application\Model\Shop;
use OxidEsales\Eshop\Core\DatabaseProvider; use OxidEsales\Eshop\Core\DatabaseProvider;
use OxidEsales\Eshop\Core\Exception\ConnectionException;
use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
use OxidEsales\Eshop\Core\Exception\DatabaseErrorException as DatabaseErrorException;
use OxidEsales\Eshop\Core\Registry; use OxidEsales\Eshop\Core\Registry;
use OxidEsales\Facts\Facts;
class d3geoip_update extends d3install_updatebase class d3geoip_update extends d3install_updatebase
{ {
public $sModKey = 'd3_geoip'; public $sModKey = 'd3_geoip';
public $sModName = 'GeoIP'; public $sModName = 'GeoIP';
public $sModVersion = '3.1.0.0'; public $sModVersion = '4.0.0.0';
public $sModRevision = '3100'; public $sModRevision = '4000';
public $sBaseConf = '9qGv2==ZmhGbXhxSWUvZ25tSjFMV3J5aTExOTdhdWg2QkdrdHJBT09CajlXUzRDOGdMZ0YraEp1N0xPc public $sBaseConf = '3Ouv2==YmlyRktwdlovdEFuVDFsa2dPYmV6MGxYKzcrV3p1RVRBN1lIOUh5dnp1T2dCQmd4c0pJeVA1Z
WkyOGhMZDBKMmwyUldaOXVrNDNjOWtMRW9BZEJ3VjY5NWQyMmZ3VG9qdHhRSVF4NXYvUGZqUmpxZm1Td WtrbnlIRC9Tc0Jud2N3VUFNbG1sVU15Yk9ZK2N1VVZWNHdmem9iV1AxeklXY1Bqa3k2UE5MVTN5NmVpR
i9HbkxNZDRxVzNRRlZrRForU0RMSHVNR25hR1ROMkt0ZUM0SXpnKzBYUHJnc0Y1dDJYaDNIMEsrWE9uR m40TVBFQ3h2V3dsQmpXeVBXTTFQcm1VOGhiSFZxL0taUGgveWZXUlgwaVdrb2RyQ1V6Nk1wOXJsajVaM
1FkbmJ4VUlMSGd1UEYxT0pPdGJhazQ4b1l6WDBBRElkM1dTWFM4VFg4S0didCs1aG1lNG9QYTh4YmVZe UVoaHYwdml4N1IxVmp5QmZEUm8xS3VnQWxrTi9UeWtKRERlMjlwY29DTGd3bys3bkU1TXFOM3lXR3FOZ
XhDL3N0aXFncEhHWDJqNFFyQ0VDTFlkWUFVR20zU2RuZ05NUnREZythR2x1Z2VQOTYvbXNHZVVHMW9zN 1FyMkpCaFFBTXova2VkckIvQVlvdzVOeko5YWlpWUxXbHFjWFZKT2N1b0tSN016c3J2WEhqNnNPYTdpT
UUrZ3pOeW9TUmo3MDg4dGx0RkRUK0wzb2k='; k11QjlHNmttejJjYkRxT0lNNWJ3aFRCMmY=';
public $sRequirements = ''; public $sRequirements = '';
public $sBaseValue = ''; public $sBaseValue = '';
public $sMinModCfgVersion = '4.4.1.0'; public $sMinModCfgVersion = '5.3.1.0';
protected $_aUpdateMethods = array( protected $_aUpdateMethods = array(
array('check' => 'checkGeoIpTableExist', array('check' => 'checkGeoIpTableExist',
@ -66,7 +67,7 @@ UUrZ3pOeW9TUmo3MDg4dGx0RkRUK0wzb2k=';
'do' => 'updateModCfgSameRevision'), 'do' => 'updateModCfgSameRevision'),
); );
// Standardwerte für checkMultiLangTables() und fixRegisterMultiLangTables() // default values for checkMultiLangTables() and fixRegisterMultiLangTables()
public $aMultiLangTables = array(); public $aMultiLangTables = array();
public $aFields = array( public $aFields = array(
@ -254,10 +255,12 @@ UUrZ3pOeW9TUmo3MDg4dGx0RkRUK0wzb2k=';
return $blRet; return $blRet;
} }
/** /**
* @return bool * @return bool
* @throws oxSystemComponentException * @throws DBALException
*/ * @throws DatabaseConnectionException
* @throws DatabaseErrorException
*/
public function hasDeleteGeoIpTableFields() public function hasDeleteGeoIpTableFields()
{ {
/** @var d3installdbfield $oInstallDbField */ /** @var d3installdbfield $oInstallDbField */
@ -265,10 +268,12 @@ UUrZ3pOeW9TUmo3MDg4dGx0RkRUK0wzb2k=';
return $oInstallDbField->checkDeleteFields(); return $oInstallDbField->checkDeleteFields();
} }
/** /**
* @return bool * @return bool
* @throws oxSystemComponentException * @throws DBALException
*/ * @throws DatabaseConnectionException
* @throws DatabaseErrorException
*/
public function deleteGeoIpTableFields() public function deleteGeoIpTableFields()
{ {
$blRet = false; $blRet = false;
@ -281,10 +286,11 @@ UUrZ3pOeW9TUmo3MDg4dGx0RkRUK0wzb2k=';
return $blRet; return $blRet;
} }
/** /**
* @return bool true, if table has wrong engine * @return bool true, if table has wrong engine
* @throws oxSystemComponentException * @throws DatabaseConnectionException
*/ * @throws DatabaseErrorException
*/
public function checkGeoIpTableEngine() public function checkGeoIpTableEngine()
{ {
/** @var d3installdbtable $oDbTable */ /** @var d3installdbtable $oDbTable */
@ -300,8 +306,8 @@ UUrZ3pOeW9TUmo3MDg4dGx0RkRUK0wzb2k=';
/** /**
* @return bool * @return bool
* @throws \OxidEsales\Eshop\Core\Exception\DatabaseConnectionException * @throws DatabaseConnectionException
* @throws \OxidEsales\Eshop\Core\Exception\DatabaseErrorException * @throws DatabaseErrorException
*/ */
public function updateGeoIpTableEngine() public function updateGeoIpTableEngine()
{ {
@ -335,14 +341,14 @@ UUrZ3pOeW9TUmo3MDg4dGx0RkRUK0wzb2k=';
/** /**
* @return bool * @return bool
* @throws \Doctrine\DBAL\DBALException * @throws DBALException
* @throws \OxidEsales\Eshop\Core\Exception\DatabaseConnectionException * @throws DatabaseConnectionException
*/ */
public function checkModCfgItemExist() public function checkModCfgItemExist()
{ {
$blRet = false; $blRet = false;
foreach ($this->getShopList() as $oShop) { foreach ($this->getShopList() as $oShop) {
/** @var $oShop oxshop */ /** @var $oShop Shop */
$aWhere = array( $aWhere = array(
'oxmodid' => $this->sModKey, 'oxmodid' => $this->sModKey,
'oxnewrevision' => $this->sModRevision, 'oxnewrevision' => $this->sModRevision,
@ -368,7 +374,7 @@ UUrZ3pOeW9TUmo3MDg4dGx0RkRUK0wzb2k=';
if ($this->checkModCfgItemExist()) { if ($this->checkModCfgItemExist()) {
foreach ($this->getShopList() as $oShop) { foreach ($this->getShopList() as $oShop) {
/** @var $oShop oxshop */ /** @var $oShop Shop */
$aWhere = array( $aWhere = array(
'oxmodid' => $this->sModKey, 'oxmodid' => $this->sModKey,
'oxshopid' => $oShop->getId(), 'oxshopid' => $oShop->getId(),
@ -489,7 +495,7 @@ UUrZ3pOeW9TUmo3MDg4dGx0RkRUK0wzb2k=';
*/ */
public function checkGeoIpFields() public function checkGeoIpFields()
{ {
/** @var $oShop oxshop */ /** @var $oShop Shop */
$oShop = $this->getShopList()->current(); $oShop = $this->getShopList()->current();
$this->aFields['D3GEOIPSHOP']['sDefault'] = $oShop->getId(); $this->aFields['D3GEOIPSHOP']['sDefault'] = $oShop->getId();
@ -502,7 +508,7 @@ UUrZ3pOeW9TUmo3MDg4dGx0RkRUK0wzb2k=';
*/ */
public function fixGeoIpFields() public function fixGeoIpFields()
{ {
/** @var $oShop oxshop */ /** @var $oShop Shop */
$oShop = $this->getShopList()->current(); $oShop = $this->getShopList()->current();
$this->aFields['D3GEOIPSHOP']['sDefault'] = $oShop->getId(); $this->aFields['D3GEOIPSHOP']['sDefault'] = $oShop->getId();
@ -526,9 +532,11 @@ UUrZ3pOeW9TUmo3MDg4dGx0RkRUK0wzb2k=';
} }
/** /**
* @return bool * @return bool
* @throws oxConnectionException * @throws DatabaseConnectionException
*/ * @throws DatabaseErrorException
* @throws ConnectionException
*/
public function checkRegisteredComponent() public function checkRegisteredComponent()
{ {
/** @var $oShop Shop */ /** @var $oShop Shop */
@ -545,16 +553,18 @@ UUrZ3pOeW9TUmo3MDg4dGx0RkRUK0wzb2k=';
return false; return false;
} }
/** /**
* @return bool * @return bool
* @throws oxConnectionException * @throws DBALException
*/ * @throws DatabaseConnectionException
* @throws DatabaseErrorException
*/
public function unregisterComponent() public function unregisterComponent()
{ {
$blRet = true; $blRet = true;
$sVarName = 'aUserComponentNames'; $sVarName = 'aUserComponentNames';
/** @var $oShop oxshop */ /** @var $oShop Shop */
foreach ($this->getShopList() as $oShop) { foreach ($this->getShopList() as $oShop) {
$aUserComponents = $this->_d3GetUserComponentsFromDb($oShop); $aUserComponents = $this->_d3GetUserComponentsFromDb($oShop);
@ -576,8 +586,8 @@ UUrZ3pOeW9TUmo3MDg4dGx0RkRUK0wzb2k=';
* @param Shop $oShop * @param Shop $oShop
* *
* @return array|null * @return array|null
* @throws \OxidEsales\Eshop\Core\Exception\DatabaseConnectionException * @throws DatabaseConnectionException
* @throws \OxidEsales\Eshop\Core\Exception\DatabaseErrorException * @throws DatabaseErrorException
*/ */
protected function _d3GetUserComponentsFromDb(Shop $oShop) protected function _d3GetUserComponentsFromDb(Shop $oShop)
{ {

View File

@ -1,37 +0,0 @@
{
"name": "d3/geoip",
"description": "D3: GeoIp",
"type": "oxideshop-module",
"version": "1.0",
"keywords": [
"oxid",
"modules",
"eShop",
"d3"
],
"authors": [
{
"name": "D3 Data Development (Inh. Thomas Dartsch)",
"email": "info@shopmodule.com",
"homepage": "http://www.d3data.de",
"role": "Owner"
}
],
"support": {
"email": "support@shopmodule.com"
},
"homepage": "https://www.oxidmodule.com/",
"license": [
"proprietary"
],
"extra": {
"source-directory": "/",
"target-directory": "d3/geoip"
},
"require": {},
"autoload": {
"psr-4": {
"D3\\GeoIp\\": "../../../../source/modules/d3/geoip"
}
}
}

View File

@ -31,7 +31,7 @@ $aModule = array(
'en' => '', 'en' => '',
), ),
'thumbnail' => 'picture.png', 'thumbnail' => 'picture.png',
'version' => '3.1.0.0', 'version' => '4.0.0.0',
'author' => 'D&sup3; Data Development (Inh.: Thomas Dartsch)', 'author' => 'D&sup3; Data Development (Inh.: Thomas Dartsch)',
'email' => 'support@shopmodule.com', 'email' => 'support@shopmodule.com',
'url' => 'http://www.oxidmodule.com/', 'url' => 'http://www.oxidmodule.com/',
@ -65,5 +65,6 @@ $aModule = array(
'd3/geoip/IntelliSenseHelper.php', 'd3/geoip/IntelliSenseHelper.php',
'd3/geoip/metadata.php', 'd3/geoip/metadata.php',
'd3/geoip/Application/views/admin/de/d3_geoip_lang.php', 'd3/geoip/Application/views/admin/de/d3_geoip_lang.php',
'd3/geoip/Setup/Events.php'
), ),
); );