-
Notifications
You must be signed in to change notification settings - Fork 77
/
Copy pathcss.php
183 lines (147 loc) · 5.24 KB
/
css.php
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<?php
/**
* DokuWiki Bootstrap3 Template: CSS Asset Dispatcher
*
* @link http://dokuwiki.org/template:bootstrap3
* @author Giuseppe Di Terlizzi <[email protected]>
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
*/
# NOTE Some Linux distributon change the location of DokuWiki core libraries (DOKU_INC)
#
# Bitnami (Docker) /opt/bitnami/dokuwiki
# LinuxServer.io (Docker) /app/dokuwiki
# Arch Linux /usr/share/webapps/dokuwiki
# Debian/Ubuntu /usr/share/dokuwiki
#
# NOTE If DokuWiki core libraries (DOKU_INC) is in another location you can
# create a PHP file in bootstrap3 root directory called "doku_inc.php" with
# this content:
#
# <?php define('DOKU_INC', '/path/dokuwiki/');
#
# (!) This file will be deleted on every upgrade of template
$doku_inc_dirs = array(
'/opt/bitnami/dokuwiki', # Bitnami (Docker)
'/usr/share/webapps/dokuwiki', # Arch Linux
'/usr/share/dokuwiki', # Debian/Ubuntu
'/app/dokuwiki', # LinuxServer.io (Docker),
realpath(dirname(__FILE__) . '/../../../'), # Default DokuWiki path
);
# Load doku_inc.php file
#
if (file_exists(dirname(__FILE__) . '/doku_inc.php')) {
require_once dirname(__FILE__) . '/doku_inc.php';
}
if (! defined('DOKU_INC')) {
foreach ($doku_inc_dirs as $dir) {
if (! defined('DOKU_INC') && @file_exists("$dir/inc/init.php")) {
define('DOKU_INC', "$dir/");
}
}
}
// we do not use a session or authentication here (better caching)
if (!defined('NOSESSION')) {
define('NOSESSION', true);
}
if (!defined('NL')) {
define('NL', "\n");
}
// we gzip ourself here
if (!defined('DOKU_DISABLE_GZIP_OUTPUT')) {
define('DOKU_DISABLE_GZIP_OUTPUT', 1);
}
function css_error($error)
{
echo "html:before {
content: '$error';
background-color: red;
display: block;
background-color: #fcc;
border-color: #ebb;
color: #000;
padding: 0.5em;
}";
}
// TODO remove this cache-control in future
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header('Content-Type: text/css; charset=utf-8');
if (!file_exists(DOKU_INC)) {
$error = 'Problem with DOKU_INC directory. Please check your DokuWiki installation directory!';
css_error($error);
die;
}
require_once DOKU_INC . 'inc/init.php';
global $INPUT;
global $conf;
global $ID;
$ID = cleanID($INPUT->str('id', null));
$bootstrap_theme = tpl_getConf('bootstrapTheme');
$bootswatch_theme = tpl_getConf('bootswatchTheme');
$custom_theme = tpl_getConf('customTheme');
$theme_by_namespace = tpl_getConf('themeByNamespace');
$tpl_basedir = tpl_basedir();
$tpl_incdir = tpl_incdir();
$themes_filename = DOKU_CONF . 'bootstrap3.themes.conf';
$stylesheets = array();
$bootswatch_themes = array('cerulean', 'cosmo', 'cyborg', 'darkly', 'flatly', 'journal', 'lumen', 'paper', 'readable', 'sandstone', 'simplex', 'solar', 'slate', 'spacelab', 'superhero', 'united', 'yeti');
# Check Theme Switcher
if (tpl_getConf('showThemeSwitcher')) {
if (get_doku_pref('bootswatchTheme', null) !== null && get_doku_pref('bootswatchTheme', null) !== '') {
$bootswatch_theme = get_doku_pref('bootswatchTheme', null);
}
if (!in_array($bootswatch_theme, $bootswatch_themes)) {
$bootswatch_theme = 'default';
}
}
# Check Theme by Namespace
if ($theme_by_namespace && file_exists($themes_filename)) {
$config = confToHash($themes_filename);
krsort($config);
$theme_found = false;
foreach ($config as $page => $theme) {
if (preg_match("/^$page/", "$ID")) {
list($bootstrap_theme, $bootswatch_theme) = explode('/', $theme);
if ($bootstrap_theme && in_array($bootstrap_theme, array('default', 'optional', 'custom'))) {
$theme_found = true;
break;
}
if ($bootstrap_theme == 'bootswatch' && in_array($bootswatch_theme, $bootswatch_themes)) {
$theme_found = true;
break;
}
}
}
}
# Check $ID and unload the template
if ($theme_by_namespace && file_exists($themes_filename) && !$ID) {
$bootstrap_theme = 'none';
}
switch ($bootstrap_theme) {
case 'optional':
$stylesheets[] = 'assets/bootstrap/default/bootstrap.min.css';
$stylesheets[] = 'assets/bootstrap/default/bootstrap-theme.min.css';
break;
case 'custom':
$stylesheets[] = $custom_theme;
break;
case 'bootswatch':
$bootswatch_url = 'assets/bootstrap';
if (file_exists($tpl_incdir . "assets/fonts/$bootswatch_theme.fonts.css")) {
$stylesheets[] = "assets/fonts/$bootswatch_theme.fonts.css";
}
$stylesheets[] = "$bootswatch_url/$bootswatch_theme/bootstrap.min.css";
break;
case 'none':
break;
case 'default':
default:
$stylesheets[] = 'assets/bootstrap/default/bootstrap.min.css';
break;
}
$content = '';
foreach ($stylesheets as $style) {
$content .= "@import url($style);" . NL;
}
print $content;