1<?php
2
3/**
4 * Default box configuration of the "vector" 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:vector
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
29if (!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)?
39if (empty($conf["useacl"]) || //are there any users?
40    $loginname !== "" || //user is logged in?
41    !tpl_getConf("vector_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("vector_navigation")){
55        //headline
56        $_vector_boxes["p-navigation"]["headline"] = $lang["vector_navigation"];
57
58        //detect wiki page to load as content
59        if (!empty($transplugin) &&
60            is_object($transplugin) &&
61            tpl_getConf("vector_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("vector_navigation_location");
71            } else {
72                //load language specific navigation
73                $nav_location = tpl_getConf("vector_navigation_location")."_".$transplugin_langcur;
74            }
75        }else{
76            //default navigation, no translation
77            $nav_location = tpl_getConf("vector_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                $_vector_boxes["p-navigation"]["xhtml"] = "[&#160;".html_wikilink($nav_location, hsc($lang["vector_fillplaceholder"]." (".$nav_location.")"))."&#160;]<br />";
89            }else{
90                //the rendered page content
91                $_vector_boxes["p-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("vector_toc_position") === "sidebar"){
99        //check if the current page got a TOC
100        $toc = tpl_toc(true);
101        if (!empty($toc)) {
102            //headline
103            $_vector_boxes["p-toc"]["headline"] = $lang["toc"]; //language comes from DokuWiki core
104
105            //content
106            $_vector_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    //exportbox ("print/export")
124    if (tpl_getConf("vector_exportbox")){
125        //headline
126        $_vector_boxes["p-coll-print_export"]["headline"] = $lang["vector_exportbox"];
127
128        //content
129        if (tpl_getConf("vector_exportbox_default")){
130            //define default, predefined exportbox
131            $_vector_boxes["p-coll-print_export"]["xhtml"] =  "      <ul>\n";
132            //ODT plugin
133            //see <https://www.dokuwiki.org/plugin:odt> for info
134            if (file_exists(DOKU_PLUGIN."odt/syntax.php") &&
135                !plugin_isdisabled("odt")){
136                $_vector_boxes["p-coll-print_export"]["xhtml"]  .= "        <li id=\"coll-download-as-odt\"><a href=\"".wl(cleanID(getId()), array("do" => "export_odt"))."\" rel=\"nofollow\">".hsc($lang["vector_exportbxdef_downloadodt"])."</a></li>\n";
137            }
138            //dw2pdf plugin
139            //see <https://www.dokuwiki.org/plugin:dw2pdf> for info
140            if (file_exists(DOKU_PLUGIN."dw2pdf/action.php") &&
141                !plugin_isdisabled("dw2pdf")){
142                $_vector_boxes["p-coll-print_export"]["xhtml"]  .= "        <li id=\"coll-download-as-rl\"><a href=\"".wl(cleanID(getId()), array("do" => "export_pdf"))."\" rel=\"nofollow\">".hsc($lang["vector_exportbxdef_downloadpdf"])."</a></li>\n";
143            //html2pdf plugin
144            //see <https://www.dokuwiki.org/plugin:html2pdf> for info
145            } else if (file_exists(DOKU_PLUGIN."html2pdf/action.php") &&
146                       !plugin_isdisabled("html2pdf")){
147                $_vector_boxes["p-coll-print_export"]["xhtml"]  .= "        <li id=\"coll-download-as-rl\"><a href=\"".wl(cleanID(getId()), array("do" => "export_pdf"))."\" rel=\"nofollow\">".hsc($lang["vector_exportbxdef_downloadpdf"])."</a></li>\n";
148            }
149            $_vector_boxes["p-coll-print_export"]["xhtml"] .=  "        <li id=\"t-print\"><a href=\"".wl(cleanID(getId()), array("rev" =>(int)$rev, "vecdo" => "print"))."\" rel=\"nofollow\">".hsc($lang["vector_exportbxdef_print"])."</a></li>\n"
150                                                              ."      </ul>";
151        }else{
152            //we have to use a custom exportbox
153            if (empty($conf["useacl"]) ||
154                auth_quickaclcheck(cleanID(tpl_getConf("vector_exportbox_location"))) >= AUTH_READ){ //current user got access?
155                //get the rendered content of the defined wiki article to use as
156                //custom exportbox
157                $interim = tpl_include_page(tpl_getConf("vector_exportbox_location"), false);
158                if ($interim === "" ||
159                    $interim === false){
160                    //add creation/edit link if the defined page got no content
161                    $_vector_boxes["p-coll-print_export"]["xhtml"] =  "<li>[&#160;".html_wikilink(tpl_getConf("vector_exportbox_location"), hsc($lang["vector_fillplaceholder"]." (".tpl_getConf("vector_exportbox_location").")"), null)."&#160;]<br /></li>";
162                }else{
163                    //add the rendered page content
164                    $_vector_boxes["p-coll-print_export"]["xhtml"] =  $interim;
165                }
166            }else{
167                //we are not allowed to show the content of the defined wiki
168                //article to use as custom sitenotice.
169                //$_vector_boxes["p-tb"]["xhtml"] = hsc($lang["vector_accessdenied"])." (".tpl_getConf("vector_exportbox_location").")";
170            }
171        }
172    }
173
174    //toolbox
175    if (tpl_getConf("vector_toolbox")){
176        //headline
177        $_vector_boxes["p-tb"]["headline"] = $lang["vector_toolbox"];
178
179        //content
180        if (tpl_getConf("vector_toolbox_default")){
181            //define default, predefined toolbox
182            $_vector_boxes["p-tb"]["xhtml"] = "      <ul>\n";
183            if (actionOK("backlink")){ //check if action is disabled
184                $_vector_boxes["p-tb"]["xhtml"] .= "        <li id=\"t-whatlinkshere\"><a href=\"".wl(cleanID(getId()), array("do" => "backlink"))."\">".hsc($lang["vector_toolbxdef_whatlinkshere"])."</a></li>\n"; //we might use tpl_actionlink("backlink", "", "", hsc($lang["vector_toolbxdef_whatlinkshere"]), true), but it would be the only toolbox link where this is possible... therefore I don't use it to be consistent
185            }
186            if (actionOK("recent")){ //check if action is disabled
187                $_vector_boxes["p-tb"]["xhtml"] .= "        <li id=\"t-recentchanges\"><a href=\"".wl("", array("do" => "recent"))."\" rel=\"nofollow\">".hsc($lang["btn_recent"])."</a></li>\n"; //language comes from DokuWiki core
188            }
189            if (actionOK("media")){ //check if action is disabled
190                if (function_exists("media_managerURL")) {
191                    //use new media manager (available on releases newer than 2011-05-25a "Rincewind" / since 2011-11-10 "Angua" RC1)
192                    $_vector_boxes["p-tb"]["xhtml"] .= "        <li id=\"t-upload\"><a href=\"".wl("", array("do" => "media"))."\" rel=\"nofollow\">".hsc($lang["btn_media"])."</a></li>\n"; //language comes from DokuWiki core
193                } else {
194                    $_vector_boxes["p-tb"]["xhtml"] .= "        <li id=\"t-upload\"><a href=\"".DOKU_BASE."lib/exe/mediamanager.php?ns=".getNS(getID())."\" rel=\"nofollow\">".hsc($lang["vector_toolbxdef_upload"])."</a></li>\n";
195                }
196            }
197            if (actionOK("index")){ //check if action is disabled
198                $_vector_boxes["p-tb"]["xhtml"] .= "        <li id=\"t-special\"><a href=\"".wl("", array("do" => "index"))."\" rel=\"nofollow\">".hsc($lang["vector_toolbxdef_siteindex"])."</a></li>\n";
199            }
200            $_vector_boxes["p-tb"]["xhtml"] .=  "        <li id=\"t-permanent\"><a href=\"".wl(cleanID(getId()), array("rev" =>(int)$rev))."\" rel=\"nofollow\">".hsc($lang["vector_toolboxdef_permanent"])."</a></li>\n"
201                                               ."        <li id=\"t-cite\"><a href=\"".wl(cleanID(getId()), array("rev" =>(int)$rev, "vecdo" => "cite"))."\" rel=\"nofollow\">".hsc($lang["vector_toolboxdef_cite"])."</a></li>\n"
202                                               ."      </ul>";
203        }else{
204            //we have to use a custom toolbox
205            if (empty($conf["useacl"]) ||
206                auth_quickaclcheck(cleanID(tpl_getConf("vector_toolbox_location"))) >= AUTH_READ){ //current user got access?
207                //get the rendered content of the defined wiki article to use as
208                //custom toolbox
209                $interim = tpl_include_page(tpl_getConf("vector_toolbox_location"), false);
210                if ($interim === "" ||
211                    $interim === false){
212                    //add creation/edit link if the defined page got no content
213                    $_vector_boxes["p-tb"]["xhtml"] =  "<li>[&#160;".html_wikilink(tpl_getConf("vector_toolbox_location"), hsc($lang["vector_fillplaceholder"]." (".tpl_getConf("vector_toolbox_location").")"), null)."&#160;]<br /></li>";
214                }else{
215                    //add the rendered page content
216                    $_vector_boxes["p-tb"]["xhtml"] =  $interim;
217                }
218            }else{
219                //we are not allowed to show the content of the defined wiki
220                //article to use as custom sitenotice.
221                //$_vector_boxes["p-tb"]["xhtml"] = hsc($lang["vector_accessdenied"])." (".tpl_getConf("vector_toolbox_location").")";
222            }
223        }
224    }
225
226    //QR Code of current page's URL (powered by <http://goqr.me/api/>)
227    if (tpl_getConf("vector_qrcodebox")){
228        //headline
229        $_vector_boxes["p-qrcode"]["headline"] = $lang["vector_qrcodebox"];
230
231        //content
232        $_vector_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&#38;bgcolor=f3f3f3\" alt=\"".hsc($lang["vector_qrcodebox_qrcode"])." ".hsc(tpl_pagetitle(null, true))." (".hsc($lang["vector_qrcodebox_genforcurrentpage"]).")\" title=\"".hsc($lang["vector_qrcodebox_urlofcurrentpage"])."\" />".((cleanID(getID()) === "start") ? "</a>" : "")."</span>";
233    }
234
235}else{
236
237    //headline
238    $_vector_boxes["p-login"]["headline"] = $lang["btn_login"];
239    $_vector_boxes["p-login"]["xhtml"] =  "      <ul>\n"
240                                         ."        <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
241                                         ."      </ul>";
242
243}
244
245
246//Languages/translations provided by Andreas Gohr's translation plugin,
247//see <https://www.dokuwiki.org/plugin:translation>
248if (!empty($transplugin) &&
249    is_object($transplugin)){
250    $_vector_boxes["p-lang"]["headline"] = $lang["vector_translations"];
251    $_vector_boxes["p-lang"]["xhtml"]    = $transplugin->_showTranslations();
252}
253
254
255
256/******************************************************************************
257 ********************************  ATTENTION  *********************************
258         DO NOT MODIFY THIS FILE, IT WILL NOT BE PRESERVED ON UPDATES!
259 ******************************************************************************
260  If you want to add some own boxes, have a look at the README of this
261  template and "/user/boxes.php". You have been warned!
262 *****************************************************************************/
263
264