diff --git a/Application/Model/Constants.php b/Application/Model/Constants.php new file mode 100644 index 0000000..0a28aa0 --- /dev/null +++ b/Application/Model/Constants.php @@ -0,0 +1,11 @@ +sCliSiteMapFile = trim($sFileSitemap); $aUrls = $this->_getSitemapContent(); - if ((!empty(Registry::getConfig()->getShopConfVar('psCacheWarmerSitemapUrl')) + if ((!empty($this->getModulConfigurationAsString('psCacheWarmerSitemapUrl',Constants::OXID_MODULE_ID)) || !empty($sFileSitemap)) && !empty($aUrls)) { foreach ($aUrls as $sUrl) { @@ -56,8 +60,8 @@ class CacheWarmer curl_setopt($oCurl, CURLOPT_CONNECTTIMEOUT, 25); curl_setopt($oCurl, CURLOPT_HEADER, true); curl_setopt($oCurl, CURLOPT_USERAGENT, 'CacheWarmer'); - $sUsername = Registry::getConfig()->getShopConfVar('psCacheWarmerUser'); - $sPassword = Registry::getConfig()->getShopConfVar('psCacheWarmerPass'); + $sUsername = $this->getModulConfigurationAsString('psCacheWarmerUser',Constants::OXID_MODULE_ID); + $sPassword = $this->getModulConfigurationAsString('psCacheWarmerPass',Constants::OXID_MODULE_ID); curl_setopt($oCurl, CURLOPT_USERPWD, $sUsername . ":" . $sPassword); curl_exec($oCurl); @@ -76,7 +80,7 @@ class CacheWarmer $sMessage = curl_error($oCurl); } else { $sMessage = $sUrl; - if (in_array(trim($httpStatus), Registry::getConfig()->getShopConfVar('psCacheWarmerHttpCodes'))) { + if (in_array(trim($httpStatus), $this->getModulConfigurationAsCollection('psCacheWarmerHttpCodes',Constants::OXID_MODULE_ID))) { $sStatusMsg = 'OK'; } else { $sStatusMsg = 'ERROR'; @@ -86,7 +90,8 @@ class CacheWarmer $aLog = [$sStatusMsg, $httpStatus, $sMessage]; print_r($aLog); - if (!empty($aLog) && ((Registry::getConfig()->getShopConfVar('psCacheWarmerWriteCsvOnlyError') == true && $httpStatus != '200') || Registry::getConfig()->getShopConfVar('psCacheWarmerWriteCsv') == true)) { + if (!empty($aLog) && (($this->getModulConfigurationAsBool('psCacheWarmerWriteCsvOnlyError', Constants::OXID_MODULE_ID) && $httpStatus != '200') + || $this->getModulConfigurationAsBool('psCacheWarmerWriteCsv', Constants::OXID_MODULE_ID))) { $logger = Logging::getLogger('psCacheWarmer', Registry::getConfig()->getLogsDir() . 'pscachewarmer_' . date("dmY_His") . '.log'); $logger->info(implode(' | ', $aLog) . "\r"); } @@ -108,8 +113,8 @@ class CacheWarmer { $sSitemapUrl = $this->_getSitemapUrl($this->sCliSiteMapFile); } - $sUsername = Registry::getConfig()->getShopConfVar('psCacheWarmerUser'); - $sPassword = Registry::getConfig()->getShopConfVar('psCacheWarmerPass'); + $sUsername = $this->getModulConfigurationAsString('psCacheWarmerUser',Constants::OXID_MODULE_ID); + $sPassword = $this->getModulConfigurationAsString('psCacheWarmerPass',Constants::OXID_MODULE_ID); $sSitemapUrl = str_replace("://", "://" . $sUsername . ":" . $sPassword . "@", $sSitemapUrl); $sSitemapXmlData = @file_get_contents($sSitemapUrl); @@ -143,10 +148,70 @@ class CacheWarmer $sSitemapUrl .= $sSitemapFile; } else{ - $sSitemapUrl .= Registry::getConfig()->getShopConfVar('psCacheWarmerSitemapUrl'); + $sSitemapUrl .= $this->getModulConfigurationAsString('psCacheWarmerSitemapUrl',Constants::OXID_MODULE_ID); } return $sSitemapUrl; } + /** + * @param string $sParam + * @param string $sModulId + * @return bool + */ + public function getModulConfigurationExists(string $sParam, string $sModulId) + { + return Registry::get(ViewConfig::class)->d3GetModulConfigurationExists($sParam, $sModulId); + } + + /** + * @param string $sParam + * @param string $sModulId + * @return string + */ + public function getModulConfigurationAsString_(string $sParam, string $sModulId) + { + return Registry::get(ViewConfig::class)->d3GetModulConfigurationAsString($sParam, $sModulId); + } + + /*** + * @param string $sParam + * @param string $sModulId + * @return int + */ + public function getModulConfigurationAsInteger(string $sParam, string $sModulId) + { + return Registry::get(ViewConfig::class)->d3GetModulConfigurationAsInteger($sParam, $sModulId); + } + + /** + * @param string $sParam + * @param string $sModulId + * @return float + */ + public function getModulConfigurationAsFloat(string $sParam, string $sModulId) + { + return Registry::get(ViewConfig::class)->d3GetModulConfigurationAsFloat($sParam, $sModulId); + } + + /** + * @param string $sParam + * @param string $sModulId + * @return bool + */ + public function getModulConfigurationAsBool(string $sParam, string $sModulId) + { + #return $this->d3getModulConfigurationAsBool($sParam, $sModulId); + return Registry::get(ViewConfig::class)->d3GetModulConfigurationAsBool($sParam, $sModulId); + } + + /** + * @param string $sParam + * @param string $sModulId + * @return array + */ + public function getModulConfigurationAsCollection(string $sParam, string $sModulId) + { + return Registry::get(ViewConfig::class)->d3GetModulConfigurationAsCollection($sParam, $sModulId); + } } diff --git a/logo_pc-os.jpg b/assets/logo_pc-os.jpg similarity index 100% rename from logo_pc-os.jpg rename to assets/logo_pc-os.jpg diff --git a/bin/warmup.php b/assets/warmup.php similarity index 96% rename from bin/warmup.php rename to assets/warmup.php index bdfb6e4..b98e256 100644 --- a/bin/warmup.php +++ b/assets/warmup.php @@ -27,6 +27,7 @@ if (!$sFileSiteMap) { } require_once dirname(__FILE__) . '/../../../../bootstrap.php'; +use OxidEsales\Eshop\Core\Config; use OxidEsales\Eshop\Core\Registry; use ProudCommerce\CacheWarmer\Core\CacheWarmer; diff --git a/composer.json b/composer.json index 52e255a..84432da 100644 --- a/composer.json +++ b/composer.json @@ -17,16 +17,12 @@ "email": "support@proudcommerce.com" }, "require": { - "php": ">= 7.0" + "php": ">= 8.0", + "oxid-esales/oxideshop-ce": ">=7.0" }, "autoload": { "psr-4": { - "ProudCommerce\\CacheWarmer\\": "../../../source/modules/pc/cachewarmer" - } - }, - "extra": { - "oxideshop": { - "target-directory": "pc/cachewarmer" + "ProudCommerce\\CacheWarmer\\": "" } } } diff --git a/metadata.php b/metadata.php index e60dff0..c6dfce1 100644 --- a/metadata.php +++ b/metadata.php @@ -14,7 +14,7 @@ /** * Metadata version */ -$sMetadataVersion = '2.0'; +$sMetadataVersion = '2.1'; /** * Module information @@ -27,7 +27,7 @@ $aModule = [ 'en' => 'Automatically calling urls using the xml-sitemap, eg. for cache warmup.', ], 'thumbnail' => 'logo_pc-os.jpg', - 'version' => '3.1.2', + 'version' => '3.2.0', 'author' => 'ProudCommerce', 'url' => 'https://github.com/proudcommerce/psCacheWarmer', 'email' => '',