xref: /template/wikiweko/conf/boxes.php (revision 4c199a43cab284902d0e4aac3ecac83a10d81dcc)
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 Andreas Haerter <ah@bitkollektiv.org>
13 * @link http://www.dokuwiki.org/template:vector
14 * @link http://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 <http://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("<div class=\"tocheader toctoggle\" id=\"toc__header\">".$lang["toc"]."</div>", //language comes from DokuWiki core
109                                                                 " class=\"toc\"",
110                                                                 " id=\"toc__inside\""),
111                                                           //replace
112                                                           "",
113                                                           //haystack
114                                                           $toc);
115        }
116        unset($toc);
117    }
118
119    //exportbox ("print/export")
120    if (tpl_getConf("vector_exportbox")){
121        //headline
122        $_vector_boxes["p-coll-print_export"]["headline"] = $lang["vector_exportbox"];
123
124        //content
125        if (tpl_getConf("vector_exportbox_default")){
126            //define default, predefined exportbox
127            $_vector_boxes["p-coll-print_export"]["xhtml"] =  "      <ul>\n";
128            //ODT plugin
129            //see <http://www.dokuwiki.org/plugin:odt> for info
130            if (file_exists(DOKU_PLUGIN."odt/syntax.php") &&
131                !plugin_isdisabled("odt")){
132                $_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";
133            }
134            //dw2pdf plugin
135            //see <http://www.dokuwiki.org/plugin:dw2pdf> for info
136            if (file_exists(DOKU_PLUGIN."dw2pdf/action.php") &&
137                !plugin_isdisabled("dw2pdf")){
138                $_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";
139            //html2pdf plugin
140            //see <http://www.dokuwiki.org/plugin:html2pdf> for info
141            } else if (file_exists(DOKU_PLUGIN."html2pdf/action.php") &&
142                       !plugin_isdisabled("html2pdf")){
143                $_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";
144            }
145            $_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"
146                                                              ."      </ul>";
147        }else{
148            //we have to use a custom exportbox
149            if (empty($conf["useacl"]) ||
150                auth_quickaclcheck(cleanID(tpl_getConf("vector_exportbox_location"))) >= AUTH_READ){ //current user got access?
151                //get the rendered content of the defined wiki article to use as
152                //custom exportbox
153                $interim = tpl_include_page(tpl_getConf("vector_exportbox_location"), false);
154                if ($interim === "" ||
155                    $interim === false){
156                    //add creation/edit link if the defined page got no content
157                    $_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>";
158                }else{
159                    //add the rendered page content
160                    $_vector_boxes["p-coll-print_export"]["xhtml"] =  $interim;
161                }
162            }else{
163                //we are not allowed to show the content of the defined wiki
164                //article to use as custom sitenotice.
165                //$_vector_boxes["p-tb"]["xhtml"] = hsc($lang["vector_accessdenied"])." (".tpl_getConf("vector_exportbox_location").")";
166            }
167        }
168    }
169
170    //toolbox
171    if (tpl_getConf("vector_toolbox")){
172        //headline
173        $_vector_boxes["p-tb"]["headline"] = $lang["vector_toolbox"];
174
175        //content
176        if (tpl_getConf("vector_toolbox_default")){
177            //define default, predefined toolbox
178            $_vector_boxes["p-tb"]["xhtml"] = "      <ul>\n";
179            if (actionOK("backlink")){ //check if action is disabled
180                $_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
181            }
182            if (actionOK("recent")){ //check if action is disabled
183                $_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
184            }
185            if (actionOK("media")){ //check if action is disabled
186                if (function_exists("media_managerURL")) {
187                    //use new media manager (available on releases newer than 2011-05-25a "Rincewind" / since 2011-11-10 "Angua" RC1)
188                    $_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
189                } else {
190                    $_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";
191                }
192            }
193            if (actionOK("index")){ //check if action is disabled
194                $_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";
195            }
196            $_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"
197                                               ."        <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"
198                                               ."      </ul>";
199        }else{
200            //we have to use a custom toolbox
201            if (empty($conf["useacl"]) ||
202                auth_quickaclcheck(cleanID(tpl_getConf("vector_toolbox_location"))) >= AUTH_READ){ //current user got access?
203                //get the rendered content of the defined wiki article to use as
204                //custom toolbox
205                $interim = tpl_include_page(tpl_getConf("vector_toolbox_location"), false);
206                if ($interim === "" ||
207                    $interim === false){
208                    //add creation/edit link if the defined page got no content
209                    $_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>";
210                }else{
211                    //add the rendered page content
212                    $_vector_boxes["p-tb"]["xhtml"] =  $interim;
213                }
214            }else{
215                //we are not allowed to show the content of the defined wiki
216                //article to use as custom sitenotice.
217                //$_vector_boxes["p-tb"]["xhtml"] = hsc($lang["vector_accessdenied"])." (".tpl_getConf("vector_toolbox_location").")";
218            }
219        }
220    }
221
222}else{
223
224    //headline
225    $_vector_boxes["p-login"]["headline"] = $lang["btn_login"];
226    $_vector_boxes["p-login"]["xhtml"] =  "      <ul>\n"
227                                         ."        <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
228                                         ."      </ul>";
229
230}
231
232
233/******************************************************************************
234 ********************************  ATTENTION  *********************************
235         DO NOT MODIFY THIS FILE, IT WILL NOT BE PRESERVED ON UPDATES!
236 ******************************************************************************
237  If you want to add some own boxes, have a look at the README of this
238  template and "/user/boxes.php". You have been warned!
239 *****************************************************************************/
240
241