-
Notifications
You must be signed in to change notification settings - Fork 0
/
theme.php
257 lines (191 loc) · 5.94 KB
/
theme.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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
<?php
if(!defined('e107_INIT'))
{
exit();
}
class theme implements e_theme_render
{
public function init()
{
e107::lan('theme');
e107::meta('viewport', 'width=device-width, initial-scale=1.0'); // added to <head>
e107::link('rel="preload" href="{THEME}fonts/myfont.woff2?v=2.2.0" as="font" type="font/woff2" crossorigin'); // added to <head>
//e107::meta('apple-mobile-web-app-capable','yes');
$bootswatch = e107::pref('theme', 'bootswatch', false);
if($bootswatch) {
e107::css('url', 'https://bootswatch.com/4/' . $bootswatch . '/bootstrap.min.css');
e107::css('url', 'https://bootswatch.com/4/' . $bootswatch . '/bootstrap.min.css');
}
$inlinecss = e107::pref('theme', 'inlinecss', false);
if($inlinecss)
{
e107::css("inline", $inlinecss);
}
$inlinejs = e107::pref('theme', 'inlinejs');
if($inlinejs)
{
e107::js("footer-inline", $inlinejs);
}
e107::js("theme", 'custom.js', 'jquery');
$login_iframe = e107::pref('theme', 'login_iframe', false);
//XXX FIXME - e_IFRAME cannot be redefined.
if (THEME_LAYOUT == "singlelogin" && $login_iframe)
{
define('e_IFRAME', '0');
}
if (THEME_LAYOUT == "singlesignup" && $login_iframe)
{
define('e_IFRAME', '0');
}
}
/**
* @param string $text
* @return string without p tags added always with bbcodes
* note: this solves W3C validation issue and CSS style problems
* use this carefully, mainly for custom menus, let decision on theme developers
*/
function remove_ptags($text = '') // FIXME this is a bug in e107 if this is required.
{
$text = str_replace(array("<!-- bbcode-html-start --><p>", "</p><!-- bbcode-html-end -->"), "", $text);
return $text;
}
public function tablestyle($caption, $text, $mode='', $options = array())
{
$style = varset($options['setStyle'], 'default');
//this should be displayed only in e_debug mode
echo "\n<!-- tablestyle initial: style=" . $style . " mode=" . $mode . " UniqueId=" . varset($options['uniqueId']) . " -->\n\n";
if($mode == 'wmessage' OR $mode == 'wm')
{
$style = 'wmessage';
}
if($style === 'listgroup' && empty($options['list']))
{
$style = 'cardmenu';
}
if($style === 'cardmenu' && !empty($options['list']))
{
$style = 'listgroup';
}
// in iframe SETSTYLE is ignored
if($mode === 'login_page' )
{
$style = 'singlelogin';
}
if($mode === 'fpw' )
{
$style = 'singlelogin';
}
if($mode === 'coppa' )
{
$style = 'singlelogin';
}
if($mode === 'signup' )
{
$style = 'singlelogin';
}
/* Changing card look via prefs */
if(!e107::pref('theme', 'cardmenu_look') && $style == 'cardmenu')
{
$style = 'menu';
}
echo "\n<!-- tablestyle: style=" . $style . " mode=" . $mode . " UniqueId=" . varset($options['uniqueId']) . " -->\n\n";
echo "\n<!-- \n";
echo json_encode($options, JSON_PRETTY_PRINT);
echo "\n-->\n\n";
switch($style)
{
/* case 'home':
echo $caption;
echo $text;
break;
case 'menu':
echo $caption;
echo $text;
break;
case 'full':
echo $caption;
echo $text;
break;
*/
case 'wmessage':
echo '<div class="jumbotron"><div class="container text-center">';
if(!empty($caption))
{
echo '<h1 class="display-4">'.$caption.'</h1>';
}
echo '<p class="lead">'.$this->remove_ptags($text).'</p>';
echo '</div></div>';
break;
case 'bare':
echo $this->remove_ptags($text);
break;
case 'nocaption':
case 'main':
echo $text;;
break;
case 'menu':
echo '<div class=" mb-4">';
if(!empty($caption))
{
echo '<h5 >' . $caption . '</h5>';
}
echo $text;
echo '</div>';
break;
case 'cardmenu':
echo '<div class="card mb-4">';
if(!empty($caption))
{
echo '<h5 class="card-header">' . $caption . '</h5>';
}
echo '<div class="card-body">';
echo $text;
echo '</div>
</div>';
break;
case 'listgroup':
echo '<div class="card mb-4">';
if(!empty($caption))
{
echo '<h5 class="card-header">' . $caption . '</h5>';
}
echo $text;
if(!empty($options['footer'])) // XXX @see news-months menu.
{
echo '<div class="card-footer">
'.$options['footer'].'
</div>';
}
echo '</div>';
break;
case 'singlelogin': {
echo '<div class="container justify-content-center text-center my-5" id="fpw-page">
<div class="row align-items-center">';
echo '<div class="card card-signin col-md-6 offset-md-3 " id="login-template"><div class="card-body">';
if(!empty($caption))
{
echo '<h5 class="card-title text-center">' . $caption . '</h5>';
}
echo $text;
if(!empty($options['footer'])) // XXX @see news-months menu.
{
echo '<div class="card-footer">
'.$options['footer'].'
</div>';
}
echo '</div></div>';
echo '</div></div>';
break;
}
default:
// default style
// only if this always work, play with different styles
if(!empty($caption))
{
echo '<div class="my-4">' . $caption . '</div>';
}
echo $text;
return;
}
}
}