forked from arsava/dokuwiki-template-prsnl10
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.php
350 lines (323 loc) · 14.9 KB
/
main.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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
<?php
/**
* Main file of the "prsnl10" template for DokuWiki
*
*
* LICENSE: This file is open source software (OSS) and may be copied under
* certain conditions. See COPYING file for details or try to contact
* the author(s) of this file in doubt.
*
* @license GPLv2 (http://www.gnu.org/licenses/gpl2.html)
* @author ARSAVA <[email protected]>
* @link https://www.dokuwiki.org/template:prsnl10
* @link https://www.dokuwiki.org/devel:templates
* @link https://www.dokuwiki.org/devel:coding_style
* @link https://www.dokuwiki.org/devel:environment
* @link https://www.dokuwiki.org/devel:action_modes
* @link http://blog.andreas-haerter.com/2011/03/16/how-to-create-a-maintainable-dokuwiki-template
*/
//check if we are running within the DokuWiki environment
if (!defined("DOKU_INC")){
die();
}
/**
* Stores the name the current client used to login
*
* @var string
* @author ARSAVA <[email protected]>
*/
$loginname = "";
if (!empty($conf["useacl"])){
if (isset($_SERVER["REMOTE_USER"]) && //no empty() but isset(): "0" may be a valid username...
$_SERVER["REMOTE_USER"] !== ""){
$loginname = $_SERVER["REMOTE_USER"]; //$INFO["client"] would not work here (-> e.g. when
//current IP differs from the one used to login)
}
}
//get needed language array
include DOKU_TPLINC."lang/en/lang.php";
//overwrite English language values with available translations
if (!empty($conf["lang"]) &&
$conf["lang"] != "en" &&
file_exists(DOKU_TPLINC."/lang/".$conf["lang"]."/lang.php")){
//get language file (partially translated language files are no problem
//cause non translated stuff is still existing as English array value)
include DOKU_TPLINC."/lang/".$conf["lang"]."/lang.php";
}
//detect revision
$rev = (int)$INFO["rev"]; //$INFO comes from the DokuWiki core
if ($rev < 1){
$rev = (int)$INFO["lastmod"];
}
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo hsc($conf["lang"]); ?>" lang="<?php echo hsc($conf["lang"]); ?>" dir="<?php echo hsc($lang["direction"]); ?>">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php tpl_pagetitle(); echo " - ".hsc($conf["title"]); ?></title>
<!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /><![endif]-->
<link rel="stylesheet" media="all" type="text/css" href="<?php echo ((!empty($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] === "on") ? "https" : "http"); ?>://fonts.googleapis.com/css?family=Droid+Sans" />
<?php
//show meta-tags
tpl_metaheaders();
echo "<meta name=\"viewport\" content=\"width=device-width,initial-scale=1\" />";
//include default or userdefined favicon
//
//note: since 2011-04-22 "Rincewind RC1", there is a core function named
// "tpl_getFavicon()". But its functionality is not really fitting the
// behaviour of this template, therefore I don't use it here exclusively.
if (file_exists(DOKU_TPLINC."user/favicon.ico")){
//user defined - you might find http://tools.dynamicdrive.com/favicon/
//useful to generate one
echo "\n<link rel=\"shortcut icon\" href=\"".DOKU_TPL."user/favicon.ico\" />\n";
}elseif (file_exists(DOKU_TPLINC."user/favicon.png")){
//note: I do NOT recommend PNG for favicons (cause it is not supported by
//all browsers).
echo "\n<link rel=\"shortcut icon\" href=\"".DOKU_TPL."user/favicon.png\" />\n";
}else{
//default
echo "\n<link rel=\"shortcut icon\" href=\"".(function_exists("tpl_getFavicon") ? tpl_getFavicon() : DOKU_TPL."images/favicon.ico")."\" />\n";
}
//include default or userdefined Apple Touch Icon (see <http://j.mp/sx3NMT> for
//details)
if (file_exists(DOKU_TPLINC."user/apple-touch-icon.png")){
echo "<link rel=\"apple-touch-icon\" href=\"".DOKU_TPL."user/apple-touch-icon.png\" />\n";
}else{
//default
echo "<link rel=\"apple-touch-icon\" href=\"".(function_exists("tpl_getFavicon") ? tpl_getFavicon(false, "apple-touch-icon.png") : DOKU_TPL."images/apple-touch-icon.png")."\" />\n";
}
//load userdefined js?
if (tpl_getConf("prsnl10_loaduserjs") && file_exists(DOKU_TPLINC."user/user.js")){
echo "<script type=\"text/javascript\" charset=\"utf-8\" src=\"".DOKU_TPL."user/user.js\"></script>\n";
}
?>
<!--[if lte IE 8]><link rel="stylesheet" media="all" type="text/css" href="<?php echo DOKU_TPL; ?>css/prsnl10_screen_iehacks.css" /><![endif]-->
<!--[if lt IE 7]><style type="text/css">img { behavior: url(<?php echo DOKU_TPL; ?>js/iepngfix/iepngfix.htc); }</style><![endif]-->
</head>
<body>
<div id="pagewrap"<?php
if ($ACT !== "show" && //speed up: check most common action first
($ACT === "admin" ||
$ACT === "conflict" ||
$ACT === "diff" ||
$ACT === "draft" ||
$ACT === "edit" ||
$ACT === "media" ||
$ACT === "preview" ||
$ACT === "save")){
echo " class=\"admin\"";
} ?>>
<!-- start header -->
<div id="tmpl_header">
<div id="tmpl_header_left">
<?php
//include userdefined logo or show text-headline
echo "<div id=\"tmpl_header_logo\">\n <a href=\"".DOKU_BASE."\" name=\"dokuwiki__top\" id=\"dokuwiki__top\" accesskey=\"h\"";
if (file_exists(DOKU_TPLINC."user/logo.png")){
//user defined PNG
echo "><img src=\"".DOKU_TPL."user/logo.png\" id=\"tmpl_header_logo_img\" alt=\"\"/></a>";
}elseif (file_exists(DOKU_TPLINC."user/logo.gif")){
//user defined GIF
echo "><img src=\"".DOKU_TPL."user/logo.gif\" id=\"tmpl_header_logo_img\" alt=\"\"/></a>";
}elseif (file_exists(DOKU_TPLINC."user/logo.jpg")){
//user defined JPG
echo "><img src=\"".DOKU_TPL."user/logo.jpg\" id=\"tmpl_header_logo_img\" alt=\"\"/></a>";
}else{
//default
echo " class=\"tmpl_header_logo_txt\">".hsc($conf["title"])."</a>";
}
echo "\n </div>\n";
?>
</div>
<div id="tmpl_header_right">
<?php
//show header navigation?
if (tpl_getConf("prsnl10_headernav")){
echo "<div id=\"tmpl_header_nav\">\n ";
//we have to show a custom navigation
if (empty($conf["useacl"]) ||
auth_quickaclcheck(cleanID(tpl_getConf("prsnl10_headernav_location")))){ //current user got access?
//get the rendered content of the defined wiki article to use as custom navigation
$interim = tpl_include_page(tpl_getConf("prsnl10_headernav_location"), false);
if ($interim === "" ||
$interim === false){
//show creation/edit link if the defined page got no content
echo "[ ";
tpl_pagelink(tpl_getConf("prsnl10_headernav_location"), hsc($lang["prsnl10_fillplaceholder"]." (".tpl_getConf("prsnl10_headernav_location").")"));
echo " ]<br />";
}else{
//show the rendered page content
echo $interim;
}
}
echo "\n </div>\n";
}
?>
</div>
<div class="clearer"></div>
</div>
<!-- end header -->
<!-- start main content area -->
<div class="dokuwiki">
<?php html_msgarea(); ?>
<!--[if lt IE 7]>
<noscript>Your browser has JavaScript disabled, the page layout will be broken.
Please enable it and reload this page or <a href="http://browser-update.org/en/update.html">update
your browser</a>.</noscript>
<![endif]-->
<!-- start main content -->
<div id="content"<?php echo (($ACT === "media") ? " class=\"mediamanagerfix\"" : ""); ?>>
<div class="page">
<?php
$toc = tpl_toc(true);
if ($toc){
echo $toc;
} ?>
<!-- start rendered page content -->
<?php
//send already created content to get a faster page rendering on the client
tpl_flush();
//show page content
tpl_content(false);
?>
<!-- end rendered page content -->
<div class="clearer"></div>
</div>
</div>
<!-- end main content -->
<div class="clearer"></div>
<?php
//send already created content to get a faster page rendering on the client
tpl_flush();
?>
<div id="tmpl_footer">
<div id="tmpl_footer_actlinksleft">
<?php
echo "[ ";
tpl_actionlink("top");
if (actionOK("index")){ //check if action is disabled
echo " | ";
tpl_actionlink("index");
}
echo " ]";
?>
</div>
<div id="tmpl_footer_actlinksright">
<?php
if (!empty($loginname) ||
!tpl_getConf("prsnl10_hideadminlinksfromanon")){
echo "[ ";
tpl_actionlink("login"); //"login" handles both login/logout
if (!empty($INFO["writable"])){ //$INFO comes from DokuWiki core
echo " | ";
tpl_actionlink("edit"); //"edit" handles edit/create/show
}
if (!empty($INFO["exists"]) &&
actionOK("revisions")){ //check if action is disabled
echo " | ";
tpl_actionlink("revisions");
}
if (!empty($loginname) &&
$ACT === "show" &&
actionOK("subscribe")){ //check if action is disabled
echo " | ";
tpl_actionlink("subscribe");
}
if ((!empty($INFO["writable"]) || //$INFO comes from DokuWiki core
!empty($INFO["isadmin"]) || //purpose of this template are "non-wiki" websites, therefore show this link only to users with write permission and admins
!empty($INFO["ismanager"])) &&
actionOK("media") && //check if action is disabled
function_exists("media_managerURL")) { //new media manager is available on DokuWiki releases newer than 2011-05-25a "Rincewind" / since 2011-11-10 "Angua" RC1
echo " | ";
tpl_actionlink("media");
}
if (!empty($INFO["isadmin"]) || //$INFO comes from DokuWiki core
!empty($INFO["ismanager"])){
echo " | ";
tpl_actionlink("admin");
}
if (!empty($loginname) &&
actionOK("profile")){ //check if action is disabled
echo " | ";
tpl_actionlink("profile");
}
echo " ]";
}else{
echo " ";
}
?>
</div>
<div class="clearer"></div>
<div id="tmpl_footer_metainfo">
<!-- Please do NOT remove the following prsnl10 and/or DokuWiki link/notice. Thank you. :-) -->
<a href="https://www.dokuwiki.org/template:prsnl10" target="_blank"<?php echo ((cleanID(getID()) === "start") ? "" : " rel=\"nofollow\"") ?>>prsnl10 on DW</a> under the hood
<?php
if(!empty($INFO["exists"]) &&
tpl_getConf("prsnl10_showpageinfo")) {
echo "  |  ";
tpl_pageinfo();
}
if (!empty($loginname)){
echo "  |  ";
tpl_userinfo();
}
//additional footer content?
if (tpl_getConf("prsnl10_footer")){
if (empty($conf["useacl"]) ||
auth_quickaclcheck(cleanID(tpl_getConf("prsnl10_footer_location")))){ //current user got access?
//get the rendered content of the defined wiki article to use as custom content
$interim = tpl_include_page(tpl_getConf("prsnl10_footer_location"), false);
if ($interim === "" ||
$interim === false){
//show creation/edit link if the defined page got no content
echo "<p>[ ";
tpl_pagelink(tpl_getConf("prsnl10_footer_location"), hsc($lang["prsnl10_fillplaceholder"]." (".tpl_getConf("prsnl10_footer_location").")"));
echo " ]</p>";
}else{
//show the rendered page content
echo $interim;
}
}
}
?>
</div><?php
//copyright notice
if (tpl_getConf("prsnl10_copyright")){
echo "\n <div id=\"licenseinfo\">\n ";
if (tpl_getConf("prsnl10_copyright_default")){
tpl_license(false);
}else{
if (empty($conf["useacl"]) ||
auth_quickaclcheck(cleanID(tpl_getConf("prsnl10_copyright_location")))){ //current user got access?
//get the rendered content of the defined wiki article to use as custom notice
$interim = tpl_include_page(tpl_getConf("prsnl10_copyright_location"), false);
if ($interim === "" ||
$interim === false){
//show creation/edit link if the defined page got no content
echo "[ ";
tpl_pagelink(tpl_getConf("prsnl10_copyright_location"), hsc($lang["prsnl10_fillplaceholder"]." (".tpl_getConf("prsnl10_copyright_location").")"));
echo " ]<br />";
}else{
//show the rendered page content
echo $interim;
}
}
}
echo "\n </div>";
}
?>
</div>
</div>
<!-- end main content area -->
<div class="clearer"></div>
<?php
//provide DokuWiki housekeeping, required in all templates
tpl_indexerWebBug();
//include web analytics software
if (file_exists(DOKU_TPLINC."/user/tracker.php")){
include DOKU_TPLINC."/user/tracker.php";
}
?>
</div>
</body>
</html>