mirror of
https://github.com/processwire/processwire.git
synced 2025-08-16 11:44:42 +02:00
PR #189 - Additional updates for CSS image file references that don't survive compilation
This commit is contained in:
@@ -1092,7 +1092,19 @@ class AdminThemeUikit extends AdminThemeFramework implements Module, Configurabl
|
||||
|
||||
$settings = $config->AdminThemeUikit;
|
||||
if(!is_array($settings)) $settings = array();
|
||||
if(self::upgrade) $settings['upgrade'] = true;
|
||||
|
||||
if(self::upgrade) {
|
||||
$settings['upgrade'] = true;
|
||||
$settings['replacements'] = array('../pw/images/' => 'images/');
|
||||
} else {
|
||||
if(empty($settings['customCssFile'])) $settings['customCssFile'] = '/site/assets/admin.css';
|
||||
$path = 'wire/modules/AdminTheme/AdminThemeUikit/uikit-pw/images/';
|
||||
$back = str_repeat('../', substr_count(trim($settings['customCssFile'], '/'), '/'));
|
||||
$settings['replacements'] = array(
|
||||
'url(../pw/images/' => "url($back$path",
|
||||
'url("../pw/images/' => "url(\"$back$path"
|
||||
);
|
||||
}
|
||||
|
||||
$css = new AdminThemeUikitCss($this, $settings);
|
||||
|
||||
|
@@ -11,6 +11,7 @@
|
||||
* @property string $defaultStyle Default style (default='reno')
|
||||
* @property string $defaultCssFile Core CSS file to create when upgrading (relative to module root)
|
||||
* @property string $styleDir Directory where base .less files are located (relative to module root)
|
||||
* @property array $replacements Array of [find=>replace] for compiled CSS file.
|
||||
*
|
||||
* @property string $configPhpHash Hash used internally to detect changes to $config->AdminThemeUikit settings.
|
||||
* @property string $configPhpName Name of property in $config that holds custom settings (default='AdminThemeUikit').
|
||||
@@ -66,6 +67,7 @@ class AdminThemeUikitCss extends WireData {
|
||||
'customCssFile' => '/site/assets/admin.css',
|
||||
'configPhpName' => $this->adminTheme->className(),
|
||||
'configPhpHash' => $this->adminTheme->get('configPhpHash'),
|
||||
'replacements' => array(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -104,7 +106,7 @@ class AdminThemeUikitCss extends WireData {
|
||||
$cssFile = $this->customFile($this->customCssFile, 'css');
|
||||
if(!$cssFile) return $this->getDefaultCssFile();
|
||||
$cssTime = is_file($cssFile) ? (int) filemtime($cssFile) : 0;
|
||||
$recompile = $lessTime > $cssTime || $this->configPhpSettingsChanged();
|
||||
$recompile = $this->recompile || $lessTime > $cssTime || $this->configPhpSettingsChanged();
|
||||
}
|
||||
|
||||
if($recompile) try {
|
||||
@@ -113,7 +115,7 @@ class AdminThemeUikitCss extends WireData {
|
||||
$less->setOption('compress', $this->compress);
|
||||
$less->addFile($this->getAdminLessFile());
|
||||
$less->addFiles($lessFiles);
|
||||
$options = array('replacements' => array('../pw/images/' => 'images/'));
|
||||
$options = array('replacements' => $this->replacements);
|
||||
if(!$less->saveCss($cssFile, $options)) throw new WireException("Compile error: $cssFile");
|
||||
$this->message(sprintf($this->_('Compiled: %s'), $cssFile), Notice::noGroup);
|
||||
$cssTime = filemtime($cssFile);
|
||||
|
Reference in New Issue
Block a user