mirror of
https://github.com/processwire/processwire.git
synced 2025-08-14 02:34:24 +02:00
PR #189 – Additional updates to allow use of rock style without an admin.less file, plus add support for a core CSS version to detect when to force recompile of the /site/assets/admin.css file due to Uikit version upgrade or required core LESS/CSS changes.
Co-authored-by: BernhardBaumrock <office@baumrock.com>
This commit is contained in:
@@ -20,7 +20,8 @@
|
|||||||
* @property string $inputSize Size for input/select elements. One of "s" for small, "m" for medium (default), or "l" for large.
|
* @property string $inputSize Size for input/select elements. One of "s" for small, "m" for medium (default), or "l" for large.
|
||||||
* @property bool|int $ukGrid When true, use uk-width classes for Inputfields (rather than CSS percentages).
|
* @property bool|int $ukGrid When true, use uk-width classes for Inputfields (rather than CSS percentages).
|
||||||
* @property int $toggleBehavior (0=Standard, 1=Consistent)
|
* @property int $toggleBehavior (0=Standard, 1=Consistent)
|
||||||
* property string $configPhpHash Hash used internally to detect changes to $config->AdminThemeUikit settings.
|
* @property string $configPhpHash Hash used internally to detect changes to $config->AdminThemeUikit settings.
|
||||||
|
* @property int $cssVersion Current version number of core CSS/LESS files
|
||||||
*
|
*
|
||||||
* @method string getUikitCSS()
|
* @method string getUikitCSS()
|
||||||
*
|
*
|
||||||
@@ -31,7 +32,7 @@ class AdminThemeUikit extends AdminThemeFramework implements Module, Configurabl
|
|||||||
public static function getModuleInfo() {
|
public static function getModuleInfo() {
|
||||||
return array(
|
return array(
|
||||||
'title' => 'Uikit',
|
'title' => 'Uikit',
|
||||||
'version' => 32,
|
'version' => 33,
|
||||||
'summary' => 'Uikit v3 admin theme',
|
'summary' => 'Uikit v3 admin theme',
|
||||||
'autoload' => 'template=admin',
|
'autoload' => 'template=admin',
|
||||||
);
|
);
|
||||||
@@ -51,6 +52,14 @@ class AdminThemeUikit extends AdminThemeFramework implements Module, Configurabl
|
|||||||
*/
|
*/
|
||||||
const upgrade = false;
|
const upgrade = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Required CSS/LESS files version
|
||||||
|
*
|
||||||
|
* Increment on core less file changes that will also require a recompile of /site/assets/admin.css
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
const requireCssVersion = 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default logo image file (relative to this dir)
|
* Default logo image file (relative to this dir)
|
||||||
*
|
*
|
||||||
@@ -93,6 +102,7 @@ class AdminThemeUikit extends AdminThemeFramework implements Module, Configurabl
|
|||||||
$this->set('inputSize', 'm'); // m=medium (default), s=small, l=large
|
$this->set('inputSize', 'm'); // m=medium (default), s=small, l=large
|
||||||
$this->set('ukGrid', false);
|
$this->set('ukGrid', false);
|
||||||
$this->set('configPhpHash', '');
|
$this->set('configPhpHash', '');
|
||||||
|
$this->set('cssVersion', 0);
|
||||||
$this->setClasses(array(
|
$this->setClasses(array(
|
||||||
'input' => 'uk-input',
|
'input' => 'uk-input',
|
||||||
'input-small' => 'uk-input uk-form-small',
|
'input-small' => 'uk-input uk-form-small',
|
||||||
@@ -1092,6 +1102,7 @@ class AdminThemeUikit extends AdminThemeFramework implements Module, Configurabl
|
|||||||
|
|
||||||
$settings = $config->AdminThemeUikit;
|
$settings = $config->AdminThemeUikit;
|
||||||
if(!is_array($settings)) $settings = array();
|
if(!is_array($settings)) $settings = array();
|
||||||
|
$settings['requireCssVersion'] = self::requireCssVersion;
|
||||||
|
|
||||||
if(self::upgrade) {
|
if(self::upgrade) {
|
||||||
$settings['upgrade'] = true;
|
$settings['upgrade'] = true;
|
||||||
|
@@ -15,6 +15,8 @@
|
|||||||
*
|
*
|
||||||
* @property string $configPhpHash Hash used internally to detect changes to $config->AdminThemeUikit settings.
|
* @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').
|
* @property string $configPhpName Name of property in $config that holds custom settings (default='AdminThemeUikit').
|
||||||
|
* @property int $requireCssVersion
|
||||||
|
* @property int $cssVersion
|
||||||
*
|
*
|
||||||
* Settings that may be specified in $config->AdminThemeUikit array:
|
* Settings that may be specified in $config->AdminThemeUikit array:
|
||||||
*
|
*
|
||||||
@@ -30,11 +32,11 @@
|
|||||||
class AdminThemeUikitCss extends WireData {
|
class AdminThemeUikitCss extends WireData {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var AdminTheme
|
* @var AdminTheme|AdminThemeUikit
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
protected $adminTheme;
|
protected $adminTheme;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct
|
* Construct
|
||||||
*
|
*
|
||||||
@@ -68,6 +70,8 @@ class AdminThemeUikitCss extends WireData {
|
|||||||
'configPhpName' => $this->adminTheme->className(),
|
'configPhpName' => $this->adminTheme->className(),
|
||||||
'configPhpHash' => $this->adminTheme->get('configPhpHash'),
|
'configPhpHash' => $this->adminTheme->get('configPhpHash'),
|
||||||
'replacements' => array(),
|
'replacements' => array(),
|
||||||
|
'cssVersion' => (int) $this->adminTheme->get('cssVersion'),
|
||||||
|
'requireCssVersion' => 0,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,12 +105,16 @@ class AdminThemeUikitCss extends WireData {
|
|||||||
if($mtime > $lessTime) $lessTime = $mtime;
|
if($mtime > $lessTime) $lessTime = $mtime;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!count($lessFiles)) return $this->getDefaultCssFile($getPath);
|
if(!count($lessFiles) && ($this->style === '' || $this->style === $this->defaultStyle)) {
|
||||||
|
return $this->getDefaultCssFile($getPath);
|
||||||
|
}
|
||||||
|
|
||||||
$cssFile = $this->customFile($this->customCssFile, 'css');
|
$cssFile = $this->customFile($this->customCssFile, 'css');
|
||||||
if(!$cssFile) return $this->getDefaultCssFile();
|
if(!$cssFile) return $this->getDefaultCssFile($getPath);
|
||||||
|
|
||||||
$cssTime = is_file($cssFile) ? (int) filemtime($cssFile) : 0;
|
$cssTime = is_file($cssFile) ? (int) filemtime($cssFile) : 0;
|
||||||
$recompile = $this->recompile || $lessTime > $cssTime || $this->configPhpSettingsChanged();
|
$recompile = $this->recompile || $lessTime > $cssTime || $this->cssVersion < $this->requireCssVersion;
|
||||||
|
if(!$recompile && $this->configPhpSettingsChanged()) $recompile = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($recompile) try {
|
if($recompile) try {
|
||||||
@@ -117,8 +125,14 @@ class AdminThemeUikitCss extends WireData {
|
|||||||
$less->addFiles($lessFiles);
|
$less->addFiles($lessFiles);
|
||||||
$options = array('replacements' => $this->replacements);
|
$options = array('replacements' => $this->replacements);
|
||||||
if(!$less->saveCss($cssFile, $options)) throw new WireException("Compile error: $cssFile");
|
if(!$less->saveCss($cssFile, $options)) throw new WireException("Compile error: $cssFile");
|
||||||
$this->message(sprintf($this->_('Compiled: %s'), $cssFile), Notice::noGroup);
|
$messages = array(sprintf($this->_('Compiled: %s'), $cssFile));
|
||||||
$cssTime = filemtime($cssFile);
|
$cssTime = filemtime($cssFile);
|
||||||
|
if($this->cssVersion < $this->requireCssVersion) {
|
||||||
|
$messages[] = "(core CSS v$this->cssVersion => v$this->requireCssVersion)";
|
||||||
|
$modules->saveConfig($this->adminTheme, 'cssVersion', $this->requireCssVersion);
|
||||||
|
$this->adminTheme->set('cssVersion', $this->requireCssVersion);
|
||||||
|
}
|
||||||
|
$this->message(implode(' ', $messages), Notice::noGroup);
|
||||||
} catch(\Exception $e) {
|
} catch(\Exception $e) {
|
||||||
$this->error('LESS - ' . $e->getMessage(), Notice::noGroup);
|
$this->error('LESS - ' . $e->getMessage(), Notice::noGroup);
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,7 @@ if(!defined("PROCESSWIRE_INSTALL")) die();
|
|||||||
<!-- FOOTER -->
|
<!-- FOOTER -->
|
||||||
<footer id='pw-footer' class='uk-margin'>
|
<footer id='pw-footer' class='uk-margin'>
|
||||||
<div class='pw-container uk-container uk-container-center'>
|
<div class='pw-container uk-container uk-container-center'>
|
||||||
<p>ProcessWire 3.x © 2020</p>
|
<p>ProcessWire 3.x © 2021</p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
@@ -19,4 +19,4 @@ if(!defined("PROCESSWIRE_INSTALL")) die();
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@@ -23,10 +23,11 @@ interface AdminThemeUikitLessInterface {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $file
|
* @param string $file
|
||||||
|
* @param string $url
|
||||||
* @return self
|
* @return self
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function addFile($file);
|
public function addFile($file, $url = '');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $files
|
* @param array $files
|
||||||
@@ -37,10 +38,11 @@ interface AdminThemeUikitLessInterface {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $file
|
* @param string $file
|
||||||
|
* @param array $options
|
||||||
* @return bool
|
* @return bool
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function saveCss($file);
|
public function saveCss($file, array $options = array());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
|
Reference in New Issue
Block a user