Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 143 lines (127 sloc) 4.127 kB
f4d2720 @selfthinker initial commit
authored
1 <?php
23bca4f @selfthinker finished design, improved template functions
authored
2 /**
3 * Template Functions
4 *
5 * This file provides template specific custom functions that are
6 * not provided by the DokuWiki core.
a21fd4b @selfthinker made favicon.ico more flexible (use from data/media only if it exists…
authored
7 * It is common practice to start each function with an underscore
8 * to make sure it won't interfere with future core functions.
23bca4f @selfthinker finished design, improved template functions
authored
9 */
f4d2720 @selfthinker initial commit
authored
10
11 // must be run from within DokuWiki
12 if (!defined('DOKU_INC')) die();
5b4c3e6 @selfthinker added user page link
authored
13
f4d2720 @selfthinker initial commit
authored
14 /**
15 * Create link/button to discussion page and back
23bca4f @selfthinker finished design, improved template functions
authored
16 *
17 * @author Anika Henke <anika@selfthinker.org>
f4d2720 @selfthinker initial commit
authored
18 */
5da0b4f @selfthinker fix wrong order of _tpl_action() items, return instead of echo (fixes…
authored
19 function _tpl_discussion($discussionPage, $title, $backTitle, $link=0, $wrapper=0, $return=0) {
f4d2720 @selfthinker initial commit
authored
20 global $ID;
5da0b4f @selfthinker fix wrong order of _tpl_action() items, return instead of echo (fixes…
authored
21 $output = '';
23bca4f @selfthinker finished design, improved template functions
authored
22
8dc924f @selfthinker use new core functionalities where possible and deprecated old fallbacks
authored
23 $discussPage = str_replace('@ID@', $ID, $discussionPage);
24 $discussPageRaw = str_replace('@ID@', '', $discussionPage);
25 $isDiscussPage = strpos($ID, $discussPageRaw) !== false;
5afd56e @selfthinker fixed link back from discussion page if coming from root page
authored
26 $backID = ':'.str_replace($discussPageRaw, '', $ID);
23bca4f @selfthinker finished design, improved template functions
authored
27
5da0b4f @selfthinker fix wrong order of _tpl_action() items, return instead of echo (fixes…
authored
28 if ($wrapper) $output .= "<$wrapper>";
23bca4f @selfthinker finished design, improved template functions
authored
29
afe47fa @selfthinker made template functions more flexible
authored
30 if ($isDiscussPage) {
5da0b4f @selfthinker fix wrong order of _tpl_action() items, return instead of echo (fixes…
authored
31 if ($link) {
32 ob_start();
8dc924f @selfthinker use new core functionalities where possible and deprecated old fallbacks
authored
33 tpl_pagelink($backID, $backTitle);
5da0b4f @selfthinker fix wrong order of _tpl_action() items, return instead of echo (fixes…
authored
34 $output .= ob_get_contents();
35 ob_end_clean();
36 } else {
37 $output .= html_btn('back2article', $backID, '', array(), 'get', 0, $backTitle);
38 }
f4d2720 @selfthinker initial commit
authored
39 } else {
5da0b4f @selfthinker fix wrong order of _tpl_action() items, return instead of echo (fixes…
authored
40 if ($link) {
41 ob_start();
8dc924f @selfthinker use new core functionalities where possible and deprecated old fallbacks
authored
42 tpl_pagelink($discussPage, $title);
5da0b4f @selfthinker fix wrong order of _tpl_action() items, return instead of echo (fixes…
authored
43 $output .= ob_get_contents();
44 ob_end_clean();
45 } else {
46 $output .= html_btn('discussion', $discussPage, '', array(), 'get', 0, $title);
47 }
f4d2720 @selfthinker initial commit
authored
48 }
23bca4f @selfthinker finished design, improved template functions
authored
49
5da0b4f @selfthinker fix wrong order of _tpl_action() items, return instead of echo (fixes…
authored
50 if ($wrapper) $output .= "</$wrapper>";
51 if ($return) return $output;
52 echo $output;
f4d2720 @selfthinker initial commit
authored
53 }
5b4c3e6 @selfthinker added user page link
authored
54
55 /**
56 * Create link/button to user page
23bca4f @selfthinker finished design, improved template functions
authored
57 *
58 * @author Anika Henke <anika@selfthinker.org>
5b4c3e6 @selfthinker added user page link
authored
59 */
5da0b4f @selfthinker fix wrong order of _tpl_action() items, return instead of echo (fixes…
authored
60 function _tpl_userpage($userPage, $title, $link=0, $wrapper=0, $return=0) {
7ce7c37 @selfthinker prevent php errors for potentially uninitialised var
authored
61 if (empty($_SERVER['REMOTE_USER'])) return;
23bca4f @selfthinker finished design, improved template functions
authored
62
5b4c3e6 @selfthinker added user page link
authored
63 global $conf;
5da0b4f @selfthinker fix wrong order of _tpl_action() items, return instead of echo (fixes…
authored
64 $output = '';
8dc924f @selfthinker use new core functionalities where possible and deprecated old fallbacks
authored
65 $userPage = str_replace('@USER@', $_SERVER['REMOTE_USER'], $userPage);
23bca4f @selfthinker finished design, improved template functions
authored
66
5da0b4f @selfthinker fix wrong order of _tpl_action() items, return instead of echo (fixes…
authored
67 if ($wrapper) $output .= "<$wrapper>";
23bca4f @selfthinker finished design, improved template functions
authored
68
5da0b4f @selfthinker fix wrong order of _tpl_action() items, return instead of echo (fixes…
authored
69 if ($link) {
70 ob_start();
8dc924f @selfthinker use new core functionalities where possible and deprecated old fallbacks
authored
71 tpl_pagelink($userPage, $title);
5da0b4f @selfthinker fix wrong order of _tpl_action() items, return instead of echo (fixes…
authored
72 $output .= ob_get_contents();
73 ob_end_clean();
74 } else {
75 $output .= html_btn('userpage', $userPage, '', array(), 'get', 0, $title);
76 }
23bca4f @selfthinker finished design, improved template functions
authored
77
5da0b4f @selfthinker fix wrong order of _tpl_action() items, return instead of echo (fixes…
authored
78 if ($wrapper) $output .= "</$wrapper>";
79 if ($return) return $output;
80 echo $output;
5b4c3e6 @selfthinker added user page link
authored
81 }
a21fd4b @selfthinker made favicon.ico more flexible (use from data/media only if it exists…
authored
82
83 /**
afe47fa @selfthinker made template functions more flexible
authored
84 * Wrapper around custom template actions
85 *
86 * @author Anika Henke <anika@selfthinker.org>
87 */
5da0b4f @selfthinker fix wrong order of _tpl_action() items, return instead of echo (fixes…
authored
88 function _tpl_action($type, $link=0, $wrapper=0, $return=0) {
afe47fa @selfthinker made template functions more flexible
authored
89 switch ($type) {
90 case 'discussion':
91 if (tpl_getConf('discussionPage')) {
5da0b4f @selfthinker fix wrong order of _tpl_action() items, return instead of echo (fixes…
authored
92 $output = _tpl_discussion(tpl_getConf('discussionPage'), tpl_getLang('discussion'), tpl_getLang('back_to_article'), $link, $wrapper, 1);
93 if ($return) return $output;
94 echo $output;
afe47fa @selfthinker made template functions more flexible
authored
95 }
96 break;
97 case 'userpage':
98 if (tpl_getConf('userPage')) {
5da0b4f @selfthinker fix wrong order of _tpl_action() items, return instead of echo (fixes…
authored
99 $output = _tpl_userpage(tpl_getConf('userPage'), tpl_getLang('userpage'), $link, $wrapper, 1);
100 if ($return) return $output;
101 echo $output;
afe47fa @selfthinker made template functions more flexible
authored
102 }
103 break;
0cac8eb @selfthinker removed fallback for tpl_sidebar() and updated other old fallback fun…
authored
104 }
105 }
e54aa15 @selfthinker added tpl_classes() function to keep latest stable working
authored
106
107 /**
5c7e8b9 @selfthinker use core tpl_toolsevent (if available)
authored
108 * copied to core (available since Detritus)
4dd812d @selfthinker added event to all tools menues
authored
109 */
5c7e8b9 @selfthinker use core tpl_toolsevent (if available)
authored
110 if (!function_exists('tpl_toolsevent')) {
111 function tpl_toolsevent($toolsname, $items, $view='main') {
112 $data = array(
113 'view' => $view,
114 'items' => $items
115 );
4dd812d @selfthinker added event to all tools menues
authored
116
5c7e8b9 @selfthinker use core tpl_toolsevent (if available)
authored
117 $hook = 'TEMPLATE_'.strtoupper($toolsname).'_DISPLAY';
118 $evt = new Doku_Event($hook, $data);
119 if($evt->advise_before()){
120 foreach($evt->data['items'] as $k => $html) echo $html;
121 }
122 $evt->advise_after();
4dd812d @selfthinker added event to all tools menues
authored
123 }
124 }
125
126 /**
dc6a97d @selfthinker version 2013-11-18
authored
127 * copied from core (available since Binky)
e54aa15 @selfthinker added tpl_classes() function to keep latest stable working
authored
128 */
129 if (!function_exists('tpl_classes')) {
130 function tpl_classes() {
131 global $ACT, $conf, $ID, $INFO;
132 $classes = array(
133 'dokuwiki',
134 'mode_'.$ACT,
135 'tpl_'.$conf['template'],
7ce7c37 @selfthinker prevent php errors for potentially uninitialised var
authored
136 !empty($_SERVER['REMOTE_USER']) ? 'loggedIn' : '',
e54aa15 @selfthinker added tpl_classes() function to keep latest stable working
authored
137 $INFO['exists'] ? '' : 'notFound',
138 ($ID == $conf['start']) ? 'home' : '',
139 );
140 return join(' ', $classes);
141 }
142 }
Something went wrong with that request. Please try again.