-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAdminThemeTweaker.module
81 lines (62 loc) · 2.82 KB
/
AdminThemeTweaker.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php namespace ProcessWire;
/**
* Admin Theme Tweaker
* @author Chris Bennett
* ProcessWire 3.x
* Copyright (C) 2011 by Ryan Cramer
* Licensed under GNU/GPL v2, see LICENSE.TXT
* http://www.processwire.com
* http://www.ryancramer.com
*/
class AdminThemeTweaker extends WireData implements Module {
public static function getModuleInfo() {
return array(
'title' => 'AdminThemeTweaker',
'summary' => 'Easily tweak default Uikit Theme',
'version' => '1.0.6',
'author' => 'bene - Chris Bennett',
'autoload' => 'template=admin',
'icon' => 'wrench',
'requires' => 'ProcessWire>=3.0.16, AdminThemeUikit',
);
}
public function init() {
$this->config->styles->add( $this->config->urls->siteModules.'AdminThemeTweaker/AdminThemeTweaker.css' );
}
public function ready() {
$cssPath = $this->config->paths->siteModules.'AdminThemeTweaker/AdminThemeTweaker.css';
$moduleName = $this->input->name;
if( $moduleName == 'AdminThemeTweaker') { // Load module specific hooks, styles, scripts
if ($this->showThemeTweaker) {
function minifyCSS($css) {
return str_replace('; ',';',str_replace(' }','}',
str_replace('{ ','{',str_replace(array("\r\n","\r","\n","\t",' ',' ',' '),"",
preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!','',$css)))));
}
$this->config->scripts->add($this->config->urls->siteModules.'AdminThemeTweaker/AdminThemeTweaker.js');
include( 'Engine/CSSvariables.php' );
$cssOutput = $cssVariables;
$cssOutput .= $conditionalVariables;
$cssOutput .= '}'; //closes :root
$cssOutput .= file_get_contents ( $this->config->paths->siteModules.'AdminThemeTweaker/Engine/AdminThemeTweakerFramework.css' );
$cssOutput .= file_get_contents ( $this->config->paths->siteModules.'AdminThemeTweaker/Engine/AdminThemeTweakerStyleTree.css' );
if( $this->toggleCheckbox ) {
$cssOutput .= file_get_contents ( $this->config->paths->siteModules.'AdminThemeTweaker/Engine/AdminThemeTweakerToggleCheckbox.css' );
}
if( !$this->show_shadows ) {
$cssOutput .= '#pw-content-body * {box-shadow: none!important;}';
}
if( $this->styleScrollbar ) {
$cssOutput .= file_get_contents ( $this->config->paths->siteModules.'AdminThemeTweaker/Engine/AdminThemeTweakerStyleScrollbar.css' );
}
$cssOutput .= $svgIncVariables;
file_put_contents ( $cssPath, minifyCSS($cssOutput) );
}
}
if ($this->showThemeTweaker) {
$this->config->styles->add( $this->config->urls->siteModules . 'AdminThemeTweaker/AdminThemeTweaker.css?v='.filemtime($cssPath) );
} else {
$this->config->styles->remove( $this->config->urls->siteModules . 'AdminThemeTweaker/AdminThemeTweaker.css' );
}
}
}