1<?php
2
3/**
4 * Main file of the "prsnl10" template for DokuWiki
5 *
6 *
7 * LICENSE: This file is open source software (OSS) and may be copied under
8 *          certain conditions. See COPYING file for details or try to contact
9 *          the author(s) of this file in doubt.
10 *
11 * @license GPLv2 (http://www.gnu.org/licenses/gpl2.html)
12 * @author ARSAVA <dokuwiki@dev.arsava.com>
13 * @link https://www.dokuwiki.org/template:prsnl10
14 * @link https://www.dokuwiki.org/devel:templates
15 * @link https://www.dokuwiki.org/devel:coding_style
16 * @link https://www.dokuwiki.org/devel:environment
17 * @link https://www.dokuwiki.org/devel:action_modes
18 * @link http://blog.andreas-haerter.com/2011/03/16/how-to-create-a-maintainable-dokuwiki-template
19 */
20
21
22//check if we are running within the DokuWiki environment
23if (!defined("DOKU_INC")){
24    die();
25}
26
27
28/**
29 * Stores the name the current client used to login
30 *
31 * @var string
32 * @author ARSAVA <dokuwiki@dev.arsava.com>
33 */
34$loginname = "";
35if (!empty($conf["useacl"])){
36    if (isset($_SERVER["REMOTE_USER"]) && //no empty() but isset(): "0" may be a valid username...
37        $_SERVER["REMOTE_USER"] !== ""){
38        $loginname = $_SERVER["REMOTE_USER"]; //$INFO["client"] would not work here (-> e.g. when
39                                              //current IP differs from the one used to login)
40    }
41}
42
43
44//get needed language array
45include DOKU_TPLINC."lang/en/lang.php";
46//overwrite English language values with available translations
47if (!empty($conf["lang"]) &&
48    $conf["lang"] != "en" &&
49    file_exists(DOKU_TPLINC."/lang/".$conf["lang"]."/lang.php")){
50    //get language file (partially translated language files are no problem
51    //cause non translated stuff is still existing as English array value)
52    include DOKU_TPLINC."/lang/".$conf["lang"]."/lang.php";
53}
54
55
56//detect revision
57$rev = (int)$INFO["rev"]; //$INFO comes from the DokuWiki core
58if ($rev < 1){
59    $rev = (int)$INFO["lastmod"];
60}
61
62?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
63  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
64<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"]); ?>">
65<head>
66<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
67<title><?php tpl_pagetitle(); echo " - ".hsc($conf["title"]); ?></title>
68<!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /><![endif]-->
69<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" />
70<?php
71//show meta-tags
72tpl_metaheaders();
73echo "<meta name=\"viewport\" content=\"width=device-width,initial-scale=1\" />";
74
75//include default or userdefined favicon
76//
77//note: since 2011-04-22 "Rincewind RC1", there is a core function named
78//      "tpl_getFavicon()". But its functionality is not really fitting the
79//      behaviour of this template, therefore I don't use it here exclusively.
80if (file_exists(DOKU_TPLINC."user/favicon.ico")){
81    //user defined - you might find http://tools.dynamicdrive.com/favicon/
82    //useful to generate one
83    echo "\n<link rel=\"shortcut icon\" href=\"".DOKU_TPL."user/favicon.ico\" />\n";
84}elseif (file_exists(DOKU_TPLINC."user/favicon.png")){
85    //note: I do NOT recommend PNG for favicons (cause it is not supported by
86    //all browsers).
87    echo "\n<link rel=\"shortcut icon\" href=\"".DOKU_TPL."user/favicon.png\" />\n";
88}else{
89    //default
90    echo "\n<link rel=\"shortcut icon\" href=\"".(function_exists("tpl_getFavicon") ? tpl_getFavicon() : DOKU_TPL."images/favicon.ico")."\" />\n";
91}
92
93//include default or userdefined Apple Touch Icon (see <http://j.mp/sx3NMT> for
94//details)
95if (file_exists(DOKU_TPLINC."user/apple-touch-icon.png")){
96    echo "<link rel=\"apple-touch-icon\" href=\"".DOKU_TPL."user/apple-touch-icon.png\" />\n";
97}else{
98    //default
99    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";
100}
101
102//load userdefined js?
103if (tpl_getConf("prsnl10_loaduserjs") && file_exists(DOKU_TPLINC."user/user.js")){
104    echo "<script type=\"text/javascript\" charset=\"utf-8\" src=\"".DOKU_TPL."user/user.js\"></script>\n";
105}
106?>
107<!--[if lte IE 8]><link rel="stylesheet" media="all" type="text/css" href="<?php echo DOKU_TPL; ?>css/prsnl10_screen_iehacks.css" /><![endif]-->
108<!--[if lt IE 7]><style type="text/css">img { behavior: url(<?php echo DOKU_TPL; ?>js/iepngfix/iepngfix.htc); }</style><![endif]-->
109</head>
110
111<body>
112<div id="pagewrap"<?php
113    if ($ACT !== "show" && //speed up: check most common action first
114        ($ACT === "admin" ||
115         $ACT === "conflict" ||
116         $ACT === "diff" ||
117         $ACT === "draft" ||
118         $ACT === "edit" ||
119         $ACT === "media" ||
120         $ACT === "preview" ||
121         $ACT === "save")){
122        echo " class=\"admin\"";
123    } ?>>
124
125    <!-- start header -->
126    <div id="tmpl_header">
127        <div id="tmpl_header_left">
128            <?php
129            //include userdefined logo or show text-headline
130            echo "<div id=\"tmpl_header_logo\">\n                <a href=\"".DOKU_BASE."\" name=\"dokuwiki__top\" id=\"dokuwiki__top\" accesskey=\"h\"";
131            if (file_exists(DOKU_TPLINC."user/logo.png")){
132                //user defined PNG
133                echo "><img src=\"".DOKU_TPL."user/logo.png\" id=\"tmpl_header_logo_img\" alt=\"\"/></a>";
134            }elseif (file_exists(DOKU_TPLINC."user/logo.gif")){
135                //user defined GIF
136                echo "><img src=\"".DOKU_TPL."user/logo.gif\" id=\"tmpl_header_logo_img\" alt=\"\"/></a>";
137            }elseif (file_exists(DOKU_TPLINC."user/logo.jpg")){
138                //user defined JPG
139                echo "><img src=\"".DOKU_TPL."user/logo.jpg\" id=\"tmpl_header_logo_img\" alt=\"\"/></a>";
140            }else{
141                //default
142                echo " class=\"tmpl_header_logo_txt\">".hsc($conf["title"])."</a>";
143            }
144            echo "\n            </div>\n";
145            ?>
146        </div>
147
148        <div id="tmpl_header_right">
149            <?php
150            //show header navigation?
151            if (tpl_getConf("prsnl10_headernav")){
152                echo "<div id=\"tmpl_header_nav\">\n                ";
153                //we have to show a custom navigation
154                if (empty($conf["useacl"]) ||
155                    auth_quickaclcheck(cleanID(tpl_getConf("prsnl10_headernav_location")))){ //current user got access?
156                    //get the rendered content of the defined wiki article to use as custom navigation
157                    $interim = tpl_include_page(tpl_getConf("prsnl10_headernav_location"), false);
158                    if ($interim === "" ||
159                        $interim === false){
160                        //show creation/edit link if the defined page got no content
161                        echo "[&#160;";
162                        tpl_pagelink(tpl_getConf("prsnl10_headernav_location"), hsc($lang["prsnl10_fillplaceholder"]." (".tpl_getConf("prsnl10_headernav_location").")"));
163                        echo "&#160;]<br />";
164                    }else{
165                       //show the rendered page content
166                       echo $interim;
167                    }
168                }
169                echo "\n            </div>\n";
170            }
171            ?>
172        </div>
173        <div class="clearer"></div>
174    </div>
175    <!-- end header -->
176
177
178    <!-- start main content area -->
179    <div class="dokuwiki">
180        <?php html_msgarea(); ?>
181
182        <!--[if lt IE 7]>
183        <noscript>Your browser has JavaScript disabled, the page layout will be broken.
184        Please enable it and reload this page or <a href="http://browser-update.org/en/update.html">update
185        your browser</a>.</noscript>
186        <![endif]-->
187
188        <!-- start main content -->
189        <div id="content"<?php echo (($ACT === "media") ? " class=\"mediamanagerfix\"" : ""); ?>>
190            <div class="page">
191            <?php
192            $toc = tpl_toc(true);
193            if ($toc){
194                echo $toc;
195             } ?>
196
197<!-- start rendered page content -->
198<?php
199//send already created content to get a faster page rendering on the client
200tpl_flush();
201//show page content
202tpl_content(false);
203?>
204<!-- end rendered page content -->
205<div class="clearer"></div>
206
207
208            </div>
209        </div>
210        <!-- end main content -->
211        <div class="clearer"></div>
212        <?php
213        //send already created content to get a faster page rendering on the client
214        tpl_flush();
215        ?>
216
217        <div id="tmpl_footer">
218            <div id="tmpl_footer_actlinksleft">
219                <?php
220                echo "[&#160;";
221                tpl_actionlink("top");
222                if (actionOK("index")){ //check if action is disabled
223                    echo "&#160;|&#160;";
224                    tpl_actionlink("index");
225                }
226                echo "&#160;]";
227                ?>
228            </div>
229            <div id="tmpl_footer_actlinksright">
230                <?php
231                if (!empty($loginname) ||
232                    !tpl_getConf("prsnl10_hideadminlinksfromanon")){
233                    echo "[&#160;";
234                    tpl_actionlink("login"); //"login" handles both login/logout
235                    if (!empty($INFO["writable"])){ //$INFO comes from DokuWiki core
236                        echo "&#160;|&#160;";
237                        tpl_actionlink("edit"); //"edit" handles edit/create/show
238                    }
239                    if (!empty($INFO["exists"]) &&
240                        actionOK("revisions")){ //check if action is disabled
241                        echo "&#160;|&#160;";
242                        tpl_actionlink("revisions");
243                    }
244                    if (!empty($loginname) &&
245                        $ACT === "show" &&
246                        actionOK("subscribe")){ //check if action is disabled
247                        echo "&#160;|&#160;";
248                        tpl_actionlink("subscribe");
249                    }
250                    if ((!empty($INFO["writable"]) || //$INFO comes from DokuWiki core
251                         !empty($INFO["isadmin"]) || //purpose of this template are "non-wiki" websites, therefore show this link only to users with write permission and admins
252                         !empty($INFO["ismanager"])) &&
253                        actionOK("media") && //check if action is disabled
254                        function_exists("media_managerURL")) { //new media manager is available on DokuWiki releases newer than 2011-05-25a "Rincewind" / since 2011-11-10 "Angua" RC1
255                        echo "&#160;|&#160;";
256                        tpl_actionlink("media");
257                    }
258                    if (!empty($INFO["isadmin"]) ||  //$INFO comes from DokuWiki core
259                        !empty($INFO["ismanager"])){
260                        echo "&#160;|&#160;";
261                        tpl_actionlink("admin");
262                    }
263                    if (!empty($loginname) &&
264                        actionOK("profile")){ //check if action is disabled
265                        echo "&#160;|&#160;";
266                        tpl_actionlink("profile");
267                    }
268                    echo "&#160;]";
269                }else{
270                    echo "&#160;";
271                }
272                ?>
273            </div>
274            <div class="clearer"></div>
275            <div id="tmpl_footer_metainfo">
276                <!-- Please do NOT remove the following prsnl10 and/or DokuWiki link/notice. Thank you. :-) -->
277                <a href="https://www.dokuwiki.org/template:prsnl10" target="_blank"<?php echo ((cleanID(getID()) === "start") ? "" : " rel=\"nofollow\"") ?>>prsnl10 on DW</a> under the hood
278                <?php
279                if(!empty($INFO["exists"]) &&
280                   tpl_getConf("prsnl10_showpageinfo")) {
281                    echo " &#160;|&#160; ";
282                    tpl_pageinfo();
283                }
284                if (!empty($loginname)){
285                    echo " &#160;|&#160; ";
286                    tpl_userinfo();
287                }
288                //additional footer content?
289                if (tpl_getConf("prsnl10_footer")){
290                    if (empty($conf["useacl"]) ||
291                        auth_quickaclcheck(cleanID(tpl_getConf("prsnl10_footer_location")))){ //current user got access?
292                        //get the rendered content of the defined wiki article to use as custom content
293                        $interim = tpl_include_page(tpl_getConf("prsnl10_footer_location"), false);
294                        if ($interim === "" ||
295                            $interim === false){
296                            //show creation/edit link if the defined page got no content
297                            echo "<p>[&#160;";
298                            tpl_pagelink(tpl_getConf("prsnl10_footer_location"), hsc($lang["prsnl10_fillplaceholder"]." (".tpl_getConf("prsnl10_footer_location").")"));
299                            echo "&#160;]</p>";
300                        }else{
301                            //show the rendered page content
302                            echo $interim;
303                        }
304                    }
305                }
306                ?>
307
308            </div><?php
309            //copyright notice
310            if (tpl_getConf("prsnl10_copyright")){
311                echo "\n            <div id=\"licenseinfo\">\n                ";
312                if (tpl_getConf("prsnl10_copyright_default")){
313                    tpl_license(false);
314                }else{
315                    if (empty($conf["useacl"]) ||
316                        auth_quickaclcheck(cleanID(tpl_getConf("prsnl10_copyright_location")))){ //current user got access?
317                        //get the rendered content of the defined wiki article to use as custom notice
318                        $interim = tpl_include_page(tpl_getConf("prsnl10_copyright_location"), false);
319                        if ($interim === "" ||
320                            $interim === false){
321                            //show creation/edit link if the defined page got no content
322                            echo "[&#160;";
323                            tpl_pagelink(tpl_getConf("prsnl10_copyright_location"), hsc($lang["prsnl10_fillplaceholder"]." (".tpl_getConf("prsnl10_copyright_location").")"));
324                            echo "&#160;]<br />";
325                        }else{
326                            //show the rendered page content
327                            echo $interim;
328                        }
329                    }
330                }
331                echo "\n            </div>";
332            }
333            ?>
334
335        </div>
336    </div>
337    <!-- end main content area -->
338    <div class="clearer"></div>
339    <?php
340    //provide DokuWiki housekeeping, required in all templates
341    tpl_indexerWebBug();
342    //include web analytics software
343    if (file_exists(DOKU_TPLINC."/user/tracker.php")){
344        include DOKU_TPLINC."/user/tracker.php";
345    }
346    ?>
347
348</div>
349</body>
350</html>
351