1 <?php
2 
3 /**
4  * Default box configuration of the "monobook" DokuWiki template
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:monobook
14  * @link https://www.dokuwiki.org/devel:configuration
15  */
16 
17 
18 
19 /******************************************************************************
20  ********************************  ATTENTION  *********************************
21          DO NOT MODIFY THIS FILE, IT WILL NOT BE PRESERVED ON UPDATES!
22  ******************************************************************************
23   If you want to add some own boxes, have a look at the README of this
24   template and "/user/boxes.php". You have been warned!
25  *****************************************************************************/
26 
27 
28 //check if we are running within the DokuWiki environment
29 if (!defined("DOKU_INC")){
30     die();
31 }
32 
33 
34 //note: The boxes will be rendered in the order they were defined. Means:
35 //      first box will be rendered first, last box will be rendered at last.
36 
37 
38 //hide boxes for anonymous clients (closed wiki)?
39 if (empty($conf["useacl"]) || //are there any users?
40     $loginname !== "" || //user is logged in?
41     !tpl_getConf("monobook_closedwiki")){
42 
43     //Languages/translations provided by Andreas Gohr's translation plugin,
44     //see <https://www.dokuwiki.org/plugin:translation>. Create plugin object if
45     //needed.
46     if (file_exists(DOKU_PLUGIN."translation/syntax.php") &&
47         !plugin_isdisabled("translation")){
48         $transplugin = &plugin_load("syntax", "translation");
49     } else {
50         $transplugin = false;
51     }
52 
53     //navigation
54     if (tpl_getConf("monobook_navigation")){
55         //headline
56         $_monobook_boxes["p-x-navigation"]["headline"] = $lang["monobook_bar_navigation"];
57 
58         //detect wiki page to load as content
59         if (!empty($transplugin) &&
60             is_object($transplugin) &&
61             tpl_getConf("monobook_navigation_translate")){
62             //translated navigation?
63             $transplugin_langcur = $transplugin->hlp->getLangPart(cleanID(getId())); //current language part
64             $transplugin_langs   = explode(" ", trim($transplugin->getConf("translations"))); //available languages
65             if (empty($transplugin_langs) ||
66                 empty($transplugin_langcur) ||
67                 !is_array($transplugin_langs) ||
68                 !in_array($transplugin_langcur, $transplugin_langs)) {
69                 //current page is no translation or something is wrong, load default navigation
70                 $nav_location = tpl_getConf("monobook_navigation_location");
71             } else {
72                 //load language specific navigation
73                 $nav_location = tpl_getConf("monobook_navigation_location")."_".$transplugin_langcur;
74             }
75         }else{
76             //default navigation, no translation
77             $nav_location = tpl_getConf("monobook_navigation_location");
78         }
79 
80         //content
81         if (empty($conf["useacl"]) ||
82             auth_quickaclcheck(cleanID($nav_location)) >= AUTH_READ){ //current user got access?
83             //get the rendered content of the defined wiki article to use as custom navigation
84             $interim = tpl_include_page($nav_location, false);
85             if ($interim === "" ||
86                 $interim === false){
87                 //creation/edit link if the defined page got no content
88                 $_monobook_boxes["p-x-navigation"]["xhtml"] = "[&#160;".html_wikilink($nav_location, hsc($lang["monobook_fillplaceholder"]." (".$nav_location.")"))."&#160;]<br />";
89             }else{
90                 //the rendered page content
91                 $_monobook_boxes["p-x-navigation"]["xhtml"] = $interim;
92             }
93         }
94         unset($nav_location);
95     }
96 
97     //table of contents (TOC) - show outside the article? (this is a dirty hack but often requested)
98     if (tpl_getConf("monobook_toc_position") === "sidebar"){
99         //check if the current page got a TOC
100         $toc = tpl_toc(true);
101         if (!empty($toc)) {
102             //headline
103             $_monobook_boxes["p-toc"]["headline"] = $lang["toc"]; //language comes from DokuWiki core
104 
105             //content
106             $_monobook_boxes["p-toc"]["xhtml"]    = //get rid of some styles and the embedded headline
107                                                     str_replace(//search
108                                                                 array(//old TOC, until 2012-01-25
109                                                                       "<div class=\"tocheader toctoggle\" id=\"toc__header\">".$lang["toc"]."</div>", //language comes from DokuWiki core
110                                                                       " class=\"toc\"",
111                                                                       " id=\"toc__inside\"",
112                                                                       //new TOC, since 2012-09-10
113                                                                       " id=\"dw__toc\"",
114                                                                       "<h3 class=\"toggle\">".$lang["toc"]."</h3>"), //language comes from DokuWiki core
115                                                                 //replace
116                                                                 "",
117                                                                 //haystack
118                                                                 $toc);
119         }
120         unset($toc);
121     }
122 
123     //search
124     if (tpl_getConf("monobook_search") &&
125         actionOK("search")){ //check if action is disabled
126         //headline
127         $_monobook_boxes["p-search"]["headline"] = $lang["monobook_bar_search"];
128 
129         //content
130         $_monobook_boxes["p-search"]["xhtml"] =  "<form action=\"".wl()."\" accept-charset=\"utf-8\" id=\"dw__search\" name=\"dw__search\">\n"
131                                                 ."  <input type=\"hidden\" name=\"do\" value=\"search\" />\n"
132                                                 ."  <input id=\"qsearch__in\" name=\"id\" type=\"text\" accesskey=\"f\" value=\"\" />\n"
133                                                 ."  <input type=\"button\" class=\"searchButton\" id=\"searchGoButton\" value=\"".hsc($lang["monobook_btn_go"])."\" onclick=\"document.location.href='".DOKU_BASE.DOKU_SCRIPT."?id='+document.getElementById('qsearch__in').value;\" />&#160;\n"
134                                                 ."  <input type=\"submit\" name=\"fulltext\" class=\"searchButton\" value=\"".hsc($lang["monobook_btn_search"])."\" />\n"
135                                                 ."</form>";
136     }
137 
138     //toolbox
139     if (tpl_getConf("monobook_toolbox")){
140         //headline
141         $_monobook_boxes["p-tb"]["headline"] = $lang["monobook_bar_toolbox"];
142 
143         //content
144         if (tpl_getConf("monobook_toolbox_default")){
145             //define default, predefined toolbox
146             $_monobook_boxes["p-tb"]["xhtml"] =  "        <ul>\n";
147             if (actionOK("backlink")){ //check if action is disabled
148                 $_monobook_boxes["p-tb"]["xhtml"] .= "          <li id=\"tb-whatlinkshere\"><a href=\"".wl(cleanID(getId()), array("do" => "backlink"))."\">".hsc($lang["monobook_toolbxdef_whatlinkshere"])."</a></li>\n"; //we might use tpl_actionlink("backlink", "", "", hsc($lang["monobook_toolbxdef_whatlinkshere"]), true), but it would be the only toolbox link where this is possible... therefore I don't use it to be consistent
149             }
150             if (actionOK("recent")){ //check if action is disabled
151                 $_monobook_boxes["p-tb"]["xhtml"] .= "          <li id=\"tb-recent\"><a href=\"".wl("", array("do" => "recent"))."\" rel=\"nofollow\">".hsc($lang["btn_recent"])."</a></li>\n"; //language comes from DokuWiki core
152             }
153             if (actionOK("media")){ //check if action is disabled
154                 if (function_exists("media_managerURL")) {
155                     //use new media manager (available on releases newer than 2011-05-25a "Rincewind" / since 2011-11-10 "Angua" RC1)
156                     $_monobook_boxes["p-tb"]["xhtml"] .= "          <li id=\"tb-upload\"><a href=\"".wl("", array("do" => "media"))."\" rel=\"nofollow\">".hsc($lang["btn_media"])."</a></li>\n"; //language comes from DokuWiki core
157                 }else{
158                     $_monobook_boxes["p-tb"]["xhtml"] .= "          <li id=\"tb-upload\"><a href=\"".DOKU_BASE."lib/exe/mediamanager.php?ns=".getNS(getID())."\" rel=\"nofollow\">".hsc($lang["monobook_toolbxdef_upload"])."</a></li>\n";
159                 }
160             }
161             if (actionOK("index")){ //check if action is disabled
162                 $_monobook_boxes["p-tb"]["xhtml"] .= "          <li id=\"tb-special\"><a href=\"".wl("", array("do" => "index"))."\" rel=\"nofollow\">".hsc($lang["monobook_toolbxdef_siteindex"])."</a></li>\n";
163             }
164             //add link to a printable version? this is not needed in every case (and
165             //therefore configurable) cause the print stylesheets are used automatically
166             //by common browsers if the user wants to print. but often users are
167             //searching for a print version instead of using the browser's printing
168             //preview...
169             if (tpl_getConf("monobook_toolbox_default_print")){
170                 $_monobook_boxes["p-tb"]["xhtml"] .= "          <li id=\"tb-print\"><a href=\"".wl(cleanID(getId()), array("rev" =>(int)$rev, "mddo" => "print"))."\" rel=\"nofollow\">".hsc($lang["monobook_toolbxdef_print"])."</a></li>\n";
171             }
172             $_monobook_boxes["p-tb"]["xhtml"] .= "          <li id=\"tb-permanent\"><a href=\"".wl(cleanID(getId()), array("rev" =>(int)$rev))."\" rel=\"nofollow\">".hsc($lang["monobook_toolboxdef_permanent"])."</a></li>\n"
173                                                 ."          <li id=\"tb-cite\"><a href=\"".wl(cleanID(getId()), array("rev" =>(int)$rev, "mddo" => "cite"))."\" rel=\"nofollow\">".hsc($lang["monobook_toolboxdef_cite"])."</a></li>\n"
174                                                 ."        </ul>";
175         }else{
176             //we have to use a custom toolbox
177             if (empty($conf["useacl"]) ||
178                 auth_quickaclcheck(cleanID(tpl_getConf("monobook_toolbox_location"))) >= AUTH_READ){ //current user got access?
179                 //get the rendered content of the defined wiki article to use as
180                 //custom toolbox
181                 $interim = tpl_include_page(tpl_getConf("monobook_toolbox_location"), false);
182                 if ($interim === "" ||
183                     $interim === false){
184                     //add creation/edit link if the defined page got no content
185                     $_monobook_boxes["p-tb"]["xhtml"] =  "<li>[&#160;".html_wikilink(tpl_getConf("monobook_toolbox_location"), hsc($lang["monobook_fillplaceholder"]." (".tpl_getConf("monobook_toolbox_location").")"), null)."&#160;]<br /></li>";
186                 }else{
187                     //add the rendered page content
188                     $_monobook_boxes["p-tb"]["xhtml"] =  $interim."\n";
189                 }
190             }else{
191                 //we are not allowed to show the content of the defined wiki
192                 //article to use as custom sitenotice.
193                 //$_monobook_boxes["p-tb"]["xhtml"] = hsc($lang["monobook_accessdenied"])." (".tpl_getConf("monobook_toolbox_location").")";
194             }
195         }
196     }
197 
198     //Languages/translations provided by Andreas Gohr's translation plugin,
199     //see <https://www.dokuwiki.org/plugin:translation>
200     if (!empty($transplugin) &&
201         is_object($transplugin)){
202         $_monobook_boxes["p-lang"]["headline"] = $lang["monobook_bar_inotherlanguages"];
203         $_monobook_boxes["p-lang"]["xhtml"]    = $transplugin->_showTranslations();
204     }
205 
206     //QR Code of current page's URL (powered by <http://goqr.me/api/>)
207     if (tpl_getConf("monobook_qrcodebox")){
208         //headline
209         $_monobook_boxes["p-qrcode"]["headline"] = $lang["monobook_qrcodebox"];
210 
211         //content
212         $_monobook_boxes["p-qrcode"]["xhtml"] = "        <span id=\"t-qrcode\">".((cleanID(getID()) === "start") ? "<a href=\"http://".(($conf["lang"] !== "de") ? "goqr.me" : "goqr.me/de")."/\" target=\"_blank\" rel=\"nofollow\">" : "")."<img src=\"".((!empty($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] === "on") ? "https" : "http")."://api.qrserver.com/v1/create-qr-code/?data=".urlencode(wl(cleanID(getId()), false, true, "&"))."&#38;size=130x130&#38;margin=0\" alt=\"".hsc($lang["monobook_qrcodebox_qrcode"])." ".hsc(tpl_pagetitle(null, true))." (".hsc($lang["monobook_qrcodebox_genforcurrentpage"]).")\" title=\"".hsc($lang["monobook_qrcodebox_urlofcurrentpage"])."\" />".((cleanID(getID()) === "start") ? "</a>" : "")."</span>";
213     }
214 
215 }else{
216 
217     //headline
218     $_monobook_boxes["p-login"]["headline"] = $lang["btn_login"];
219     $_monobook_boxes["p-login"]["xhtml"] =  "      <ul>\n"
220                                            ."        <li id=\"t-login\"><a href=\"".wl(cleanID(getId()), array("do" => "login"))."\" rel=\"nofollow\">".hsc($lang["btn_login"])."</a></li>\n" //language comes from DokuWiki core
221                                            ."      </ul>";
222 
223 }
224 
225 
226 /******************************************************************************
227  ********************************  ATTENTION  *********************************
228          DO NOT MODIFY THIS FILE, IT WILL NOT BE PRESERVED ON UPDATES!
229  ******************************************************************************
230   If you want to add some own boxes, have a look at the README of this
231   template and "/user/boxes.php". You have been warned!
232  *****************************************************************************/
233 
234