Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
d33699b657 | |||
5cccf90508 | |||
7a79713c61 | |||
7b32b264d0 |
11
Application/Model/Constants.php
Normal file
11
Application/Model/Constants.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace ProudCommerce\CacheWarmer\Application\Model;
|
||||
|
||||
|
||||
class Constants
|
||||
{
|
||||
public const OXID_MODULE_ID = 'psCacheWarmer';
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
@ -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;
|
||||
|
@ -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\\": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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' => '',
|
||||
|
Loading…
x
Reference in New Issue
Block a user