Compare commits

...

4 Commits

Author SHA1 Message Date
d33699b657 change include 2025-01-14 15:18:37 +01:00
5cccf90508 change vendor 2025-01-14 15:02:08 +01:00
7a79713c61 change path 2025-01-14 14:46:39 +01:00
7b32b264d0 mod for Oxid 7.0 2025-01-14 10:42:36 +01:00
6 changed files with 90 additions and 18 deletions

View File

@ -0,0 +1,11 @@
<?php
declare(strict_types=1);
namespace ProudCommerce\CacheWarmer\Application\Model;
class Constants
{
public const OXID_MODULE_ID = 'psCacheWarmer';
}

View File

@ -14,6 +14,8 @@
namespace ProudCommerce\CacheWarmer\Core;
use OxidEsales\Eshop\Core\Registry;
use OxidEsales\Eshop\Core\ViewConfig;
use ProudCommerce\CacheWarmer\Application\Model\Constants;
/**
* Class CacheWarmer
@ -32,7 +34,7 @@ class CacheWarmer
$this->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 +58,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 +78,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 +88,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 +111,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 +146,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);
}
}

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

@ -25,8 +25,10 @@ $sFileSiteMap = $options['f'] ?? '';
if (!$sFileSiteMap) {
$sFileSitemap = '';
}
require_once dirname(__FILE__) . '/../../../../bootstrap.php';
require_once (__DIR__.'/../../../../source/bootstrap.php');
use OxidEsales\Eshop\Core\Config;
use OxidEsales\Eshop\Core\Registry;
use ProudCommerce\CacheWarmer\Core\CacheWarmer;

View File

@ -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\\": ""
}
}
}

View File

@ -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' => '',