1<?php
2
3  function tpl_ID($text=null) {
4    global $conf;
5    global $ID;
6    if ($text==null) $text=$ID;
7    if ($conf['useslash'])
8        return str_replace(":","/",$text);
9    else
10        return $text;
11  }
12
13  function tpl_bs_actionlink($type, $pre = '', $suf = '', $class='', $inner = '', $return = false) {
14       global $lang;
15       $data = tpl_get_action($type);
16       if($data === false) {
17           return false;
18       } elseif(!is_array($data)) {
19           $out = sprintf($data, 'link');
20       } else {
21           /**
22            * @var string $accesskey
23            * @var string $id
24            * @var string $method
25            * @var bool   $nofollow
26            * @var array  $params
27            * @var string $replacement
28            */
29           extract($data);
30           if(strpos($id, '#') === 0) {
31               $linktarget = $id;
32           } else {
33               $linktarget = wl($id, $params);
34           }
35           $caption = $lang['btn_'.$type];
36           if(strpos($caption, '%s')){
37               $caption = sprintf($caption, $replacement);
38           }
39           $akey    = $addTitle = '';
40           if($accesskey) {
41               $akey     = 'accesskey="'.$accesskey.'" ';
42               $addTitle = ' ['.strtoupper($accesskey).']';
43           }
44           $rel = $nofollow ? 'rel="nofollow" ' : '';
45           $out = tpl_link(
46               $linktarget, $pre.(($inner) ? $inner : $caption).$suf,
47               'class="btn action '.$type.' '.$class.'" '.
48                   $akey.$rel.
49                   'title="'.hsc($caption).$addTitle.'"', 1
50           );
51           $out='<a href="'.$linktarget.'" ';
52           $out.='class="action '.$type.' '.$class.'" '.
53                   $akey.$rel.
54                   'title="'.hsc($caption).$addTitle.'"';
55           $out.='>';
56           if ($pre) $out.='<span class="glyphicon glyphicon-'.$pre.'"></span>&nbsp;';
57           $out.=(($inner) ? $inner : "&nbsp;".$caption);
58           $out.='</a>';
59           if ($suf) $out='<'.$suf.'>'.$out.'</'.$suf.'>';
60
61       }
62       if($return) return $out;
63       echo $out;
64       return true;
65   }
66
67  function tpl_button_a($type, $pre = '', $suf = '', $class='', $inner = '', $return = false) {
68       global $lang;
69       $data = tpl_get_action($type);
70       if($data === false) {
71           return false;
72       } elseif(!is_array($data)) {
73           $out = sprintf($data, 'link');
74       } else {
75           /**
76            * @var string $accesskey
77            * @var string $id
78            * @var string $method
79            * @var bool   $nofollow
80            * @var array  $params
81            * @var string $replacement
82            */
83           extract($data);
84           if(strpos($id, '#') === 0) {
85               $linktarget = $id;
86           } else {
87               $linktarget = wl($id, $params);
88           }
89           $caption = $lang['btn_'.$type];
90           if(strpos($caption, '%s')){
91               $caption = sprintf($caption, $replacement);
92           }
93           $akey    = $addTitle = '';
94           if($accesskey) {
95               $akey     = 'accesskey="'.$accesskey.'" ';
96               $addTitle = ' ['.strtoupper($accesskey).']';
97           }
98           $rel = $nofollow ? 'rel="nofollow" ' : '';
99           $out = tpl_link(
100               $linktarget, $pre.(($inner) ? $inner : $caption).$suf,
101               'class="btn action '.$type.' '.$class.'" '.
102                   $akey.$rel.
103                   'title="'.hsc($caption).$addTitle.'"', 1
104           );
105
106           $out='<a href="'.$linktarget.'" ';
107           $out.='class="action_'.$type.' '.$class.'" '.
108                   $akey.$rel.
109                   'title="'.hsc($caption).$addTitle.'"';
110           $out.='>';
111         //  if ($pre) $out.='<span class="glyphicon glyphicon-'.$pre.'"></span>&nbsp;';
112           if ($pre) $out.='<div><i class="fa fa-'.$pre.'"></i></div>';
113        //   $out.=(($inner) ? $inner : "&nbsp;".$caption);
114           $out.='<div>'.(($inner) ? $inner : $caption).'</div>';
115           $out.='</a>';
116         //  if ($suf) $out='<'.$suf.'>'.$out.'</'.$suf.'>';
117
118       }
119       if($return) return $out;
120       echo $out;
121       return true;
122   }
123
124  function ds_html_msgarea(){  /* ½ºÆ®·¦¿ë msg */
125	global $MSG, $MSG_shown;
126     /** @var array $MSG */
127     // store if the global $MSG has already been shown and thus HTML output has been started
128     $MSG_shown = true;
129
130     if(!isset($MSG)) return;
131
132     $shown = array();
133     foreach($MSG as $msg){
134         $hash = md5($msg['msg']);
135         if(isset($shown[$hash])) continue; // skip double messages
136         if(info_msg_allowed($msg)){
137             print '<div class="alert-'.$msg['lvl'].' alert alert-dismissible" role="alert">';
138			 print '<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>';
139             print $msg['msg'];
140             print '</div>';
141         }
142         $shown[$hash] = 1;
143     }
144
145     unset($GLOBALS['MSG']);
146 }
147
148
149
150   function tpl_bs_breadcrumbs($tag='li') {
151       global $lang;
152       global $conf;
153
154     //check if enabled
155     if(!$conf['breadcrumbs']) return false;
156
157     $crumbs = breadcrumbs(); //setup crumb trace
158
159     $last = count($crumbs);
160
161     if ($last==1) return false;
162     $i    = 0;
163     print '<ol class="breadcrumb text-capitalize hidden-xs">';
164     print '<li><i class="fa fa-book" aria-hidden="true"></i></li>';
165     foreach($crumbs as $id => $name) {
166         $i++;
167         print '<'.$tag.'>';
168         tpl_link(wl($id), hsc($name), '  title="'.$id.'"');
169         print '</'.$tag.'>';
170       }
171     print '</ol>';
172     return true;
173 }
174
175 /*
176    from twitter bootstrap template
177  * @author Anika Henke <anika@selfthinker.org>
178 */
179
180
181
182function _tpl_toc_to_twitter_bootstrap_event_hander_dump_level($data, $header='', $firstlevel=false)
183{
184    global $lang;
185
186    if (count($data) == 0)
187    {
188        return '';
189    }
190
191    $ret = '';
192    $ret .= '<li class="divider"></li>';
193   // $ret .= '<ul class="nav list-group">';
194    if ($header != '') {
195        $ret .= '<li class="dropdown-header">'.$header.'</li>';
196    }
197  //  $ret .= '<li class="divider"></li>';
198
199  //  $first = true;
200   // $li_inner = ' class ="active"';
201
202    //Only supports top level links for now.
203    foreach($data as $heading)
204    {
205        $ret .= '<li' . $li_inner . '><a href="#' . $heading['hid'] . '">'. $chevronHTML . $heading['title'] . '</a></li>';
206
207        $li_inner = '';
208    }
209
210    //$ret .= '<li class="divider"></li>';
211   // $ret .= '</ul>';
212
213    return $ret;
214}
215
216function _tpl_toc_to_twitter_bootstrap_event_hander(&$event, $param)
217{
218    global $conf;
219    global $lang;
220    //This is tied to the specific format of the DokuWiki TOC.
221    echo _tpl_toc_to_twitter_bootstrap_event_hander_dump_level($event->data,$lang['toc'], true);
222}
223
224function _tpl_toc_to_twitter_bootstrap()
225{
226    //Force generation of TOC, request that the TOC is returned as HTML, but then ignore the returned string. The hook will instead dump out the TOC.
227    global $EVENT_HANDLER;
228    $EVENT_HANDLER->register_hook('TPL_TOC_RENDER', 'AFTER', NULL, '_tpl_toc_to_twitter_bootstrap_event_hander');
229    tpl_toc(true);
230}
231
232function tpl_logo ($return = false) {
233    global $INFO;
234    global $conf;
235
236            $logoSize = array();
237            $logo = tpl_getMediaFile(array(':'.$INFO['namespace'].':logo.jpg',':'.$INFO['namespace'].':logo.png',':¿À´Ã:'.date("n¿ù_jÀÏ").'.png',':logo.png',':wiki:logo.png', 'images/logo.png'), false, $logoSize);
238			$out='<div><img class="logo" src="'.$logo.'" alt="" ></div>';
239          //  $out=tpl_link(wl('..:'),$out,'',1);
240            $out=tpl_link(wl($INFO['namespace'].':'.$conf['start'],'',true),$out,'',1);
241            if($return) return $out;
242            echo $out;
243            return true;
244}
245function tpl_background ($return = false) {
246    global $INFO;
247    $bg=tpl_getConf('bg_ns');
248    $logoSize = array();
249    $img = tpl_getMediaFile(array(':'.$INFO['namespace'].':'.$bg,':'.$bg, 'images/bg.png'), false);
250	$out=$img;
251    if($return) return $out;
252    echo $out;
253    return true;
254}
255
256function tpl_title ($return=false) {
257    global $INFO;
258    global $conf;
259    //strip_tags($conf['title'])
260    $out='<div class="text-center" >'.tpl_link(  wl($INFO['namespace'].':'.$conf['start']),p_get_first_heading(':'.$INFO['namespace'].':'.$conf['start']),'accesskey="h" title="[H]"',1).'</div>';
261    if($return) return $out;
262    echo $out;
263    return true;
264}
265
266  function tpl_apple_touch_icon() {
267
268     $return = '';
269
270     $look = array(':apple-touch-icon.svg', ':wiki:apple-touch-icon.png', ':apple-touch-icon.png', 'images/apple-touch-icon.png');
271     $return .= tpl_getMediaFile($look);
272
273     return $return;
274 }
275
276  function tpl_pagesize($ID) {
277    $page = wikiFN($ID);
278    if(file_exists($page))
279          return  filesize_h(filesize($page));
280   }
281?>