GeoIP/src/Application/Component/GeoIpComponent.php

88 lignes
3.0 KiB
PHP
Brut Vue normale Historique

2012-02-15 14:15:28 +01:00
<?php
2020-06-10 10:28:16 +02:00
2013-04-22 11:40:11 +02:00
/**
* 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
*
2020-06-10 10:28:16 +02:00
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
* @author D3 Data Development - Daniel Seifert <support@shopmodule.com>
2013-04-22 11:40:11 +02:00
* @link http://www.oxidmodule.com
*/
2015-12-21 14:28:34 +01:00
2020-04-17 09:29:09 +02:00
namespace D3\GeoIp\Application\Component;
use D3\GeoIp\Application\Model\d3geoip;
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;
2020-06-10 10:28:16 +02:00
use OxidEsales\Eshop\Application\Component\CurrencyComponent;
use OxidEsales\Eshop\Application\Controller\FrontendController;
2020-04-17 09:29:09 +02:00
use OxidEsales\Eshop\Core\Controller\BaseController;
use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
use OxidEsales\Eshop\Core\Exception\DatabaseErrorException;
use OxidEsales\Eshop\Core\Exception\StandardException;
use OxidEsales\Eshop\Core\Registry;
2020-04-17 13:53:46 +02:00
class GeoIpComponent extends BaseController
2012-02-15 14:15:28 +01:00
{
2015-12-21 14:28:34 +01:00
/**
* Marking object as component
*
* @var bool
*/
protected $_blIsComponent = true;
2015-06-23 11:29:07 +02:00
private $_sModId = 'd3_geoip';
2013-04-22 11:25:27 +02:00
2020-04-17 09:29:09 +02:00
/**
* @throws DBALException
* @throws DatabaseConnectionException
* @throws DatabaseErrorException
* @throws StandardException
2020-06-10 10:28:16 +02:00
* @throws d3ShopCompatibilityAdapterException
* @throws d3_cfg_mod_exception
2020-04-17 09:29:09 +02:00
*/
2012-02-15 14:15:28 +01:00
public function init()
{
2015-06-23 11:29:07 +02:00
if (d3_cfg_mod::get($this->_sModId)->isActive()) {
if (d3_cfg_mod::get($this->_sModId)->hasDebugMode()) {
2013-04-22 11:40:11 +02:00
/** @var $oGeoIp d3geoip */
2020-04-17 09:29:09 +02:00
$oGeoIp = oxNew(d3geoip::class);
2013-04-22 11:40:11 +02:00
echo $oGeoIp->getIP();
}
2013-04-22 11:25:27 +02:00
2013-04-22 11:40:11 +02:00
/** @var $oLocation d3geoip */
2020-04-17 09:29:09 +02:00
$oLocation = oxNew(d3geoip::class);
2013-04-22 11:40:11 +02:00
$oLocation->setCountryCurrency();
// moved to oxcmp_lang extension because here it's to late
// $oLocation->setCountryLanguage();
if (!isset($oBasket)) {
$oBasket = $this->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())) {
2020-06-10 10:28:16 +02:00
/** @var FrontendController $oActView */
2020-04-17 09:29:09 +02:00
$oActView = Registry::getConfig()->getActiveView();
$aComponents = $oActView->getComponents();
2020-06-10 10:28:16 +02:00
/** @var CurrencyComponent $oCurCmp */
$oCurCmp = $aComponents['oxcmp_cur'];
$oCurCmp->init();
}
// language isn't registered, we don't need an additional check
2015-06-23 11:29:07 +02:00
}
2012-02-15 14:15:28 +01:00
parent::init();
2012-02-15 14:15:28 +01:00
}
}