1<?php 2/** 3 * DokuWiki template functions 4 * 5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 6 * @author Andreas Gohr <andi@splitbrain.org> 7 */ 8 9if(!defined('DOKU_INC')) die('meh.'); 10 11/** 12 * Returns the path to the given template, uses 13 * default one if the custom version doesn't exist. 14 * 15 * @author Andreas Gohr <andi@splitbrain.org> 16 */ 17function template($tpl){ 18 global $conf; 19 20 if(@is_readable(DOKU_INC.'lib/tpl/'.$conf['template'].'/'.$tpl)) 21 return DOKU_INC.'lib/tpl/'.$conf['template'].'/'.$tpl; 22 23 return DOKU_INC.'lib/tpl/default/'.$tpl; 24} 25 26/** 27 * Print the content 28 * 29 * This function is used for printing all the usual content 30 * (defined by the global $ACT var) by calling the appropriate 31 * outputfunction(s) from html.php 32 * 33 * Everything that doesn't use the main template file isn't 34 * handled by this function. ACL stuff is not done here either. 35 * 36 * @author Andreas Gohr <andi@splitbrain.org> 37 */ 38function tpl_content($prependTOC=true) { 39 global $ACT; 40 global $INFO; 41 $INFO['prependTOC'] = $prependTOC; 42 43 ob_start(); 44 trigger_event('TPL_ACT_RENDER',$ACT,'tpl_content_core'); 45 $html_output = ob_get_clean(); 46 trigger_event('TPL_CONTENT_DISPLAY',$html_output,'ptln'); 47 48 return !empty($html_output); 49} 50 51function tpl_content_core(){ 52 global $ACT; 53 global $TEXT; 54 global $PRE; 55 global $SUF; 56 global $SUM; 57 global $IDX; 58 59 switch($ACT){ 60 case 'show': 61 html_show(); 62 break; 63 case 'preview': 64 html_edit($TEXT); 65 html_show($TEXT); 66 break; 67 case 'recover': 68 html_edit($TEXT); 69 break; 70 case 'edit': 71 html_edit(); 72 break; 73 case 'draft': 74 html_draft(); 75 break; 76 case 'wordblock': 77 html_edit($TEXT,'wordblock'); 78 break; 79 case 'search': 80 html_search(); 81 break; 82 case 'revisions': 83 $first = isset($_REQUEST['first']) ? intval($_REQUEST['first']) : 0; 84 html_revisions($first); 85 break; 86 case 'diff': 87 html_diff(); 88 break; 89 case 'recent': 90 if (is_array($_REQUEST['first'])) { 91 $_REQUEST['first'] = array_keys($_REQUEST['first']); 92 $_REQUEST['first'] = $_REQUEST['first'][0]; 93 } 94 $first = is_numeric($_REQUEST['first']) ? intval($_REQUEST['first']) : 0; 95 html_recent($first); 96 break; 97 case 'index': 98 html_index($IDX); #FIXME can this be pulled from globals? is it sanitized correctly? 99 break; 100 case 'backlink': 101 html_backlinks(); 102 break; 103 case 'conflict': 104 html_conflict(con($PRE,$TEXT,$SUF),$SUM); 105 html_diff(con($PRE,$TEXT,$SUF),false); 106 break; 107 case 'locked': 108 html_locked(); 109 html_edit(); 110 break; 111 case 'login': 112 html_login(); 113 break; 114 case 'register': 115 html_register(); 116 break; 117 case 'resendpwd': 118 html_resendpwd(); 119 break; 120 case 'denied': 121 print p_locale_xhtml('denied'); 122 break; 123 case 'profile' : 124 html_updateprofile(); 125 break; 126 case 'admin': 127 tpl_admin(); 128 break; 129 default: 130 $evt = new Doku_Event('TPL_ACT_UNKNOWN',$ACT); 131 if ($evt->advise_before()) 132 msg("Failed to handle command: ".hsc($ACT),-1); 133 $evt->advise_after(); 134 unset($evt); 135 return false; 136 } 137 return true; 138} 139 140/** 141 * Places the TOC where the function is called 142 * 143 * If you use this you most probably want to call tpl_content with 144 * a false argument 145 * 146 * @author Andreas Gohr <andi@splitbrain.org> 147 */ 148function tpl_toc($return=false){ 149 global $TOC; 150 global $ACT; 151 global $ID; 152 global $REV; 153 global $INFO; 154 global $conf; 155 $toc = array(); 156 157 if(is_array($TOC)){ 158 // if a TOC was prepared in global scope, always use it 159 $toc = $TOC; 160 }elseif(($ACT == 'show' || substr($ACT,0,6) == 'export') && !$REV && $INFO['exists']){ 161 // get TOC from metadata, render if neccessary 162 $meta = p_get_metadata($ID, false, true); 163 if(isset($meta['internal']['toc'])){ 164 $tocok = $meta['internal']['toc']; 165 }else{ 166 $tocok = true; 167 } 168 $toc = $meta['description']['tableofcontents']; 169 if(!$tocok || !is_array($toc) || !$conf['tocminheads'] || count($toc) < $conf['tocminheads']){ 170 $toc = array(); 171 } 172 }elseif($ACT == 'admin'){ 173 // try to load admin plugin TOC FIXME: duplicates code from tpl_admin 174 $plugin = null; 175 if (!empty($_REQUEST['page'])) { 176 $pluginlist = plugin_list('admin'); 177 if (in_array($_REQUEST['page'], $pluginlist)) { 178 // attempt to load the plugin 179 $plugin =& plugin_load('admin',$_REQUEST['page']); 180 } 181 } 182 if ( ($plugin !== null) && 183 (!$plugin->forAdminOnly() || $INFO['isadmin']) ){ 184 $toc = $plugin->getTOC(); 185 $TOC = $toc; // avoid later rebuild 186 } 187 } 188 189 trigger_event('TPL_TOC_RENDER', $toc, NULL, false); 190 $html = html_TOC($toc); 191 if($return) return $html; 192 echo $html; 193} 194 195/** 196 * Handle the admin page contents 197 * 198 * @author Andreas Gohr <andi@splitbrain.org> 199 */ 200function tpl_admin(){ 201 global $INFO; 202 global $TOC; 203 204 $plugin = null; 205 if (!empty($_REQUEST['page'])) { 206 $pluginlist = plugin_list('admin'); 207 208 if (in_array($_REQUEST['page'], $pluginlist)) { 209 210 // attempt to load the plugin 211 $plugin =& plugin_load('admin',$_REQUEST['page']); 212 } 213 } 214 215 if ($plugin !== null){ 216 if($plugin->forAdminOnly() && !$INFO['isadmin']){ 217 msg('For admins only',-1); 218 html_admin(); 219 }else{ 220 if(!is_array($TOC)) $TOC = $plugin->getTOC(); //if TOC wasn't requested yet 221 if($INFO['prependTOC']) tpl_toc(); 222 $plugin->html(); 223 } 224 }else{ 225 html_admin(); 226 } 227 return true; 228} 229 230/** 231 * Print the correct HTML meta headers 232 * 233 * This has to go into the head section of your template. 234 * 235 * @triggers TPL_METAHEADER_OUTPUT 236 * @param boolean $alt Should feeds and alternative format links be added? 237 * @author Andreas Gohr <andi@splitbrain.org> 238 */ 239function tpl_metaheaders($alt=true){ 240 global $ID; 241 global $REV; 242 global $INFO; 243 global $JSINFO; 244 global $ACT; 245 global $QUERY; 246 global $lang; 247 global $conf; 248 $it=2; 249 250 // prepare the head array 251 $head = array(); 252 253 254 // the usual stuff 255 $head['meta'][] = array( 'name'=>'generator', 'content'=>'DokuWiki '.getVersion() ); 256 $head['link'][] = array( 'rel'=>'search', 'type'=>'application/opensearchdescription+xml', 257 'href'=>DOKU_BASE.'lib/exe/opensearch.php', 'title'=>$conf['title'] ); 258 $head['link'][] = array( 'rel'=>'start', 'href'=>DOKU_BASE ); 259 if(actionOK('index')){ 260 $head['link'][] = array( 'rel'=>'contents', 'href'=> wl($ID,'do=index',false,'&'), 261 'title'=>$lang['btn_index'] ); 262 } 263 264 if($alt){ 265 $head['link'][] = array( 'rel'=>'alternate', 'type'=>'application/rss+xml', 266 'title'=>'Recent Changes', 'href'=>DOKU_BASE.'feed.php'); 267 $head['link'][] = array( 'rel'=>'alternate', 'type'=>'application/rss+xml', 268 'title'=>'Current Namespace', 269 'href'=>DOKU_BASE.'feed.php?mode=list&ns='.$INFO['namespace']); 270 if(($ACT == 'show' || $ACT == 'search') && $INFO['writable']){ 271 $head['link'][] = array( 'rel'=>'edit', 272 'title'=>$lang['btn_edit'], 273 'href'=> wl($ID,'do=edit',false,'&')); 274 } 275 276 if($ACT == 'search'){ 277 $head['link'][] = array( 'rel'=>'alternate', 'type'=>'application/rss+xml', 278 'title'=>'Search Result', 279 'href'=>DOKU_BASE.'feed.php?mode=search&q='.$QUERY); 280 } 281 282 if(actionOK('export_xhtml')){ 283 $head['link'][] = array( 'rel'=>'alternate', 'type'=>'text/html', 'title'=>'Plain HTML', 284 'href'=>exportlink($ID, 'xhtml', '', false, '&')); 285 } 286 287 if(actionOK('export_raw')){ 288 $head['link'][] = array( 'rel'=>'alternate', 'type'=>'text/plain', 'title'=>'Wiki Markup', 289 'href'=>exportlink($ID, 'raw', '', false, '&')); 290 } 291 } 292 293 // setup robot tags apropriate for different modes 294 if( ($ACT=='show' || $ACT=='export_xhtml') && !$REV){ 295 if($INFO['exists']){ 296 //delay indexing: 297 if((time() - $INFO['lastmod']) >= $conf['indexdelay']){ 298 $head['meta'][] = array( 'name'=>'robots', 'content'=>'index,follow'); 299 }else{ 300 $head['meta'][] = array( 'name'=>'robots', 'content'=>'noindex,nofollow'); 301 } 302 $head['link'][] = array( 'rel'=>'canonical', 'href'=>wl($ID,'',true,'&') ); 303 }else{ 304 $head['meta'][] = array( 'name'=>'robots', 'content'=>'noindex,follow'); 305 } 306 }elseif(defined('DOKU_MEDIADETAIL')){ 307 $head['meta'][] = array( 'name'=>'robots', 'content'=>'index,follow'); 308 }else{ 309 $head['meta'][] = array( 'name'=>'robots', 'content'=>'noindex,nofollow'); 310 } 311 312 // set metadata 313 if($ACT == 'show' || $ACT=='export_xhtml'){ 314 // date of modification 315 if($REV){ 316 $head['meta'][] = array( 'name'=>'date', 'content'=>date('Y-m-d\TH:i:sO',$REV)); 317 }else{ 318 $head['meta'][] = array( 'name'=>'date', 'content'=>date('Y-m-d\TH:i:sO',$INFO['lastmod'])); 319 } 320 321 // keywords (explicit or implicit) 322 if(!empty($INFO['meta']['subject'])){ 323 $head['meta'][] = array( 'name'=>'keywords', 'content'=>join(',',$INFO['meta']['subject'])); 324 }else{ 325 $head['meta'][] = array( 'name'=>'keywords', 'content'=>str_replace(':',',',$ID)); 326 } 327 } 328 329 // load stylesheets 330 $head['link'][] = array('rel'=>'stylesheet', 'media'=>'all', 'type'=>'text/css', 331 'href'=>DOKU_BASE.'lib/exe/css.php?s=all&t='.$conf['template']); 332 $head['link'][] = array('rel'=>'stylesheet', 'media'=>'screen', 'type'=>'text/css', 333 'href'=>DOKU_BASE.'lib/exe/css.php?t='.$conf['template']); 334 $head['link'][] = array('rel'=>'stylesheet', 'media'=>'print', 'type'=>'text/css', 335 'href'=>DOKU_BASE.'lib/exe/css.php?s=print&t='.$conf['template']); 336 337 // make $INFO and other vars available to JavaScripts 338 require_once(DOKU_INC.'inc/JSON.php'); 339 $json = new JSON(); 340 $script = "var NS='".$INFO['namespace']."';"; 341 if($conf['useacl'] && $_SERVER['REMOTE_USER']){ 342 require_once(DOKU_INC.'inc/toolbar.php'); 343 $script .= "var SIG='".toolbar_signature()."';"; 344 } 345 $script .= 'var JSINFO = '.$json->encode($JSINFO).';'; 346 $head['script'][] = array( 'type'=>'text/javascript', 'charset'=>'utf-8', 347 '_data'=> $script); 348 349 // load external javascript 350 $head['script'][] = array( 'type'=>'text/javascript', 'charset'=>'utf-8', '_data'=>'', 351 'src'=>DOKU_BASE.'lib/exe/js.php'); 352 353 354 // trigger event here 355 trigger_event('TPL_METAHEADER_OUTPUT',$head,'_tpl_metaheaders_action',true); 356 return true; 357} 358 359/** 360 * prints the array build by tpl_metaheaders 361 * 362 * $data is an array of different header tags. Each tag can have multiple 363 * instances. Attributes are given as key value pairs. Values will be HTML 364 * encoded automatically so they should be provided as is in the $data array. 365 * 366 * For tags having a body attribute specify the the body data in the special 367 * attribute '_data'. This field will NOT BE ESCAPED automatically. 368 * 369 * @author Andreas Gohr <andi@splitbrain.org> 370 */ 371function _tpl_metaheaders_action($data){ 372 foreach($data as $tag => $inst){ 373 foreach($inst as $attr){ 374 echo '<',$tag,' ',buildAttributes($attr); 375 if(isset($attr['_data']) || $tag == 'script'){ 376 if($tag == 'script' && $attr['_data']) 377 $attr['_data'] = "<!--//--><![CDATA[//><!--\n". 378 $attr['_data']. 379 "\n//--><!]]>"; 380 381 echo '>',$attr['_data'],'</',$tag,'>'; 382 }else{ 383 echo '/>'; 384 } 385 echo "\n"; 386 } 387 } 388} 389 390/** 391 * Print a link 392 * 393 * Just builds a link. 394 * 395 * @author Andreas Gohr <andi@splitbrain.org> 396 */ 397function tpl_link($url,$name,$more='',$return=false){ 398 $out = '<a href="'.$url.'" '; 399 if ($more) $out .= ' '.$more; 400 $out .= ">$name</a>"; 401 if ($return) return $out; 402 print $out; 403 return true; 404} 405 406/** 407 * Prints a link to a WikiPage 408 * 409 * Wrapper around html_wikilink 410 * 411 * @author Andreas Gohr <andi@splitbrain.org> 412 */ 413function tpl_pagelink($id,$name=NULL){ 414 print html_wikilink($id,$name); 415 return true; 416} 417 418/** 419 * get the parent page 420 * 421 * Tries to find out which page is parent. 422 * returns false if none is available 423 * 424 * @author Andreas Gohr <andi@splitbrain.org> 425 */ 426function tpl_getparent($id){ 427 global $conf; 428 $parent = getNS($id).':'; 429 resolve_pageid('',$parent,$exists); 430 if($parent == $id) { 431 $pos = strrpos (getNS($id),':'); 432 $parent = substr($parent,0,$pos).':'; 433 resolve_pageid('',$parent,$exists); 434 if($parent == $id) return false; 435 } 436 return $parent; 437} 438 439/** 440 * Print one of the buttons 441 * 442 * Available Buttons are 443 * 444 * edit - edit/create/show/draft button 445 * history - old revisions 446 * recent - recent changes 447 * login - login/logout button - if ACL enabled 448 * profile - user profile button (if logged in) 449 * index - The index 450 * admin - admin page - if enough rights 451 * top - a back to top button 452 * back - a back to parent button - if available 453 * backlink - links to the list of backlinks 454 * subscription- subscribe/unsubscribe button 455 * 456 * @author Andreas Gohr <andi@splitbrain.org> 457 * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net> 458 */ 459function tpl_button($type,$return=false){ 460 global $ACT; 461 global $ID; 462 global $REV; 463 global $NS; 464 global $INFO; 465 global $conf; 466 global $auth; 467 468 // check disabled actions and fix the badly named ones 469 $ctype = $type; 470 if($type == 'history') $ctype='revisions'; 471 if(!actionOK($ctype)) return false; 472 473 $out = ''; 474 switch($type){ 475 case 'edit': 476 #most complicated type - we need to decide on current action 477 if($ACT == 'show' || $ACT == 'search'){ 478 if($INFO['writable']){ 479 if(!empty($INFO['draft'])){ 480 $out .= html_btn('draft',$ID,'e',array('do' => 'draft'),'post'); 481 }else{ 482 if($INFO['exists']){ 483 $out .= html_btn('edit',$ID,'e',array('do' => 'edit','rev' => $REV),'post'); 484 }else{ 485 $out .= html_btn('create',$ID,'e',array('do' => 'edit','rev' => $REV),'post'); 486 } 487 } 488 }else{ 489 if(!actionOK('source')) return false; //pseudo action 490 $out .= html_btn('source',$ID,'v',array('do' => 'edit','rev' => $REV),'post'); 491 } 492 }else{ 493 $out .= html_btn('show',$ID,'v',array('do' => 'show')); 494 } 495 break; 496 case 'history': 497 if(actionOK('revisions')) 498 $out .= html_btn('revs',$ID,'o',array('do' => 'revisions')); 499 break; 500 case 'recent': 501 if(actionOK('recent')) 502 $out .= html_btn('recent',$ID,'r',array('do' => 'recent')); 503 break; 504 case 'index': 505 if(actionOK('index')) 506 $out .= html_btn('index',$ID,'x',array('do' => 'index')); 507 break; 508 case 'back': 509 if ($parent = tpl_getparent($ID)) { 510 $out .= html_btn('back',$parent,'b',array('do' => 'show')); 511 } 512 break; 513 case 'top': 514 $out .= html_topbtn(); 515 break; 516 case 'login': 517 if($conf['useacl'] && $auth){ 518 if(isset($_SERVER['REMOTE_USER'])){ 519 $out .= html_btn('logout',$ID,'',array('do' => 'logout', 'sectok' => getSecurityToken())); 520 }else{ 521 $out .= html_btn('login',$ID,'',array('do' => 'login', 'sectok' => getSecurityToken())); 522 } 523 } 524 break; 525 case 'admin': 526 if($INFO['ismanager']){ 527 $out .= html_btn('admin',$ID,'',array('do' => 'admin')); 528 } 529 break; 530 case 'revert': 531 if($INFO['ismanager'] && $REV && $INFO['writable'] && actionOK('revert')){ 532 $out .= html_btn('revert',$ID,'',array('do' => 'revert', 'rev' => $REV, 'sectok' => getSecurityToken())); 533 } 534 break; 535 case 'subscribe': 536 case 'subscription': 537 if($conf['useacl'] && $auth && $ACT == 'show' && $conf['subscribers'] == 1){ 538 if($_SERVER['REMOTE_USER']){ 539 if($INFO['subscribed']){ 540 if(actionOK('unsubscribe')) 541 $out .= html_btn('unsubscribe',$ID,'',array('do' => 'unsubscribe',)); 542 } else { 543 if(actionOK('subscribe')) 544 $out .= html_btn('subscribe',$ID,'',array('do' => 'subscribe',)); 545 } 546 } 547 } 548 if($type == 'subscribe') break; 549 // else: fall through for backward compatibility 550 case 'subscribens': 551 if($conf['useacl'] && $auth && $ACT == 'show' && $conf['subscribers'] == 1){ 552 if($_SERVER['REMOTE_USER']){ 553 if($INFO['subscribedns']){ 554 if(actionOK('unsubscribens')) 555 $out .= html_btn('unsubscribens',$ID,'',array('do' => 'unsubscribens',)); 556 } else { 557 if(actionOK('subscribens')) 558 $out .= html_btn('subscribens',$ID,'',array('do' => 'subscribens',)); 559 } 560 } 561 } 562 break; 563 case 'backlink': 564 if(actionOK('backlink')) 565 $out .= html_btn('backlink',$ID,'',array('do' => 'backlink')); 566 break; 567 case 'profile': 568 if($conf['useacl'] && isset($_SERVER['REMOTE_USER']) && $auth && 569 $auth->canDo('Profile') && ($ACT!='profile')){ 570 $out .= html_btn('profile',$ID,'',array('do' => 'profile')); 571 } 572 break; 573 default: 574 $out .= '[unknown button type]'; 575 break; 576 } 577 if ($return) return $out; 578 print $out; 579 return $out ? true : false; 580} 581 582/** 583 * Like the action buttons but links 584 * 585 * Available links are 586 * 587 * edit - edit/create/show link 588 * history - old revisions 589 * recent - recent changes 590 * login - login/logout link - if ACL enabled 591 * profile - user profile link (if logged in) 592 * index - The index 593 * admin - admin page - if enough rights 594 * top - a back to top link 595 * back - a back to parent link - if available 596 * backlink - links to the list of backlinks 597 * subscribe/subscription - subscribe/unsubscribe link 598 * 599 * @author Andreas Gohr <andi@splitbrain.org> 600 * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net> 601 * @see tpl_button 602 */ 603function tpl_actionlink($type,$pre='',$suf='',$inner='',$return=false){ 604 global $ID; 605 global $INFO; 606 global $REV; 607 global $ACT; 608 global $conf; 609 global $lang; 610 global $auth; 611 612 // check disabled actions and fix the badly named ones 613 $ctype = $type; 614 if($type == 'history') $ctype='revisions'; 615 if(!actionOK($ctype)) return false; 616 617 $out = ''; 618 switch($type){ 619 case 'edit': 620 #most complicated type - we need to decide on current action 621 if($ACT == 'show' || $ACT == 'search'){ 622 if($INFO['writable']){ 623 if(!empty($INFO['draft'])) { 624 $out .= tpl_link(wl($ID,'do=draft'), 625 $pre.(($inner)?$inner:$lang['btn_draft']).$suf, 626 'class="action edit" accesskey="e" rel="nofollow"',1); 627 } else { 628 if($INFO['exists']){ 629 $out .= tpl_link(wl($ID,'do=edit&rev='.$REV), 630 $pre.(($inner)?$inner:$lang['btn_edit']).$suf, 631 'class="action edit" accesskey="e" rel="nofollow"',1); 632 }else{ 633 $out .= tpl_link(wl($ID,'do=edit&rev='.$REV), 634 $pre.(($inner)?$inner:$lang['btn_create']).$suf, 635 'class="action create" accesskey="e" rel="nofollow"',1); 636 } 637 } 638 }else{ 639 if(actionOK('source')) //pseudo action 640 $out .= tpl_link(wl($ID,'do=edit&rev='.$REV), 641 $pre.(($inner)?$inner:$lang['btn_source']).$suf, 642 'class="action source" accesskey="v" rel="nofollow"',1); 643 } 644 }else{ 645 $out .= tpl_link(wl($ID,'do=show'), 646 $pre.(($inner)?$inner:$lang['btn_show']).$suf, 647 'class="action show" accesskey="v" rel="nofollow"',1); 648 } 649 break; 650 case 'history': 651 if(actionOK('revisions')) 652 $out .= tpl_link(wl($ID,'do=revisions'), 653 $pre.(($inner)?$inner:$lang['btn_revs']).$suf, 654 'class="action revisions" accesskey="o" rel="nofollow"',1); 655 break; 656 case 'recent': 657 if(actionOK('recent')) 658 $out .= tpl_link(wl($ID,'do=recent'), 659 $pre.(($inner)?$inner:$lang['btn_recent']).$suf, 660 'class="action recent" accesskey="r" rel="nofollow"',1); 661 break; 662 case 'index': 663 if(actionOK('index')) 664 $out .= tpl_link(wl($ID,'do=index'), 665 $pre.(($inner)?$inner:$lang['btn_index']).$suf, 666 'class="action index" accesskey="x" rel="nofollow"',1); 667 break; 668 case 'top': 669 $out .= '<a href="#dokuwiki__top" class="action top" accesskey="x">'. 670 $pre.(($inner)?$inner:$lang['btn_top']).$suf.'</a>'; 671 break; 672 case 'back': 673 if ($parent = tpl_getparent($ID)) { 674 $out .= tpl_link(wl($parent,'do=show'), 675 $pre.(($inner)?$inner:$lang['btn_back']).$suf, 676 'class="action back" accesskey="b" rel="nofollow"',1); 677 } 678 break; 679 case 'login': 680 if($conf['useacl'] && $auth){ 681 if($_SERVER['REMOTE_USER']){ 682 $out .= tpl_link(wl($ID,'do=logout&sectok='.getSecurityToken()), 683 $pre.(($inner)?$inner:$lang['btn_logout']).$suf, 684 'class="action logout" rel="nofollow"',1); 685 }else{ 686 $out .= tpl_link(wl($ID,'do=login&sectok='.getSecurityToken()), 687 $pre.(($inner)?$inner:$lang['btn_login']).$suf, 688 'class="action login" rel="nofollow"',1); 689 } 690 } 691 break; 692 case 'admin': 693 if($INFO['ismanager']){ 694 $out .= tpl_link(wl($ID,'do=admin'), 695 $pre.(($inner)?$inner:$lang['btn_admin']).$suf, 696 'class="action admin" rel="nofollow"',1); 697 } 698 break; 699 case 'revert': 700 if($INFO['ismanager'] && $REV && $INFO['writable'] && actionOK('revert')){ 701 $out .= tpl_link(wl($ID,array('do' => 'revert', 'rev' => $REV, 'sectok' => getSecurityToken())), 702 $pre.(($inner)?$inner:$lang['btn_revert']).$suf, 703 'class="action revert" rel="nofollow"',1); 704 } 705 break; 706 case 'subscribe': 707 case 'subscription': 708 if($conf['useacl'] && $auth && $ACT == 'show' && $conf['subscribers'] == 1){ 709 if($_SERVER['REMOTE_USER']){ 710 if($INFO['subscribed']) { 711 if(actionOK('unsubscribe')) 712 $out .= tpl_link(wl($ID,'do=unsubscribe'), 713 $pre.(($inner)?$inner:$lang['btn_unsubscribe']).$suf, 714 'class="action unsubscribe" rel="nofollow"',1); 715 } else { 716 if(actionOK('subscribe')) 717 $out .= tpl_link(wl($ID,'do=subscribe'), 718 $pre.(($inner)?$inner:$lang['btn_subscribe']).$suf, 719 'class="action subscribe" rel="nofollow"',1); 720 } 721 } 722 } 723 if($type == 'subscribe') break; 724 // else: fall through for backward compatibility 725 case 'subscribens': 726 if($conf['useacl'] && $auth && $ACT == 'show' && $conf['subscribers'] == 1){ 727 if($_SERVER['REMOTE_USER']){ 728 if($INFO['subscribedns']) { 729 if(actionOK('unsubscribens')) 730 $out .= tpl_link(wl($ID,'do=unsubscribens'), 731 $pre.(($inner)?$inner:$lang['btn_unsubscribens']).$suf, 732 'class="action unsubscribens" rel="nofollow"',1); 733 } else { 734 if(actionOK('subscribens')) 735 $out .= tpl_link(wl($ID,'do=subscribens'), 736 $pre.(($inner)?$inner:$lang['btn_subscribens']).$suf, 737 'class="action subscribens" rel="nofollow"',1); 738 } 739 } 740 } 741 break; 742 case 'backlink': 743 if(actionOK('backlink')) 744 $out .= tpl_link(wl($ID,'do=backlink'), 745 $pre.(($inner)?$inner:$lang['btn_backlink']).$suf, 746 'class="action backlink" rel="nofollow"',1); 747 break; 748 case 'profile': 749 if($conf['useacl'] && $auth && $_SERVER['REMOTE_USER'] && 750 $auth->canDo('Profile') && ($ACT!='profile')){ 751 $out .= tpl_link(wl($ID,'do=profile'), 752 $pre.(($inner)?$inner:$lang['btn_profile']).$suf, 753 'class="action profile" rel="nofollow"',1); 754 } 755 break; 756 default: 757 $out .= '[unknown link type]'; 758 break; 759 } 760 if ($return) return $out; 761 print $out; 762 return $out ? true : false; 763} 764 765/** 766 * Wrapper around tpl_button() and tpl_actionlink() 767 * 768 * @author Anika Henke <anika@selfthinker.org> 769 */ 770function tpl_action($type,$link=0,$wrapper=false,$return=false,$pre='',$suf='',$inner='') { 771 $out = ''; 772 if ($link) $out .= tpl_actionlink($type,$pre,$suf,$inner,1); 773 else $out .= tpl_button($type,1); 774 if ($out && $wrapper) $out = "<$wrapper>$out</$wrapper>"; 775 776 if ($return) return $out; 777 print $out; 778 return $out ? true : false; 779} 780 781/** 782 * Print the search form 783 * 784 * If the first parameter is given a div with the ID 'qsearch_out' will 785 * be added which instructs the ajax pagequicksearch to kick in and place 786 * its output into this div. The second parameter controls the propritary 787 * attribute autocomplete. If set to false this attribute will be set with an 788 * value of "off" to instruct the browser to disable it's own built in 789 * autocompletion feature (MSIE and Firefox) 790 * 791 * @author Andreas Gohr <andi@splitbrain.org> 792 */ 793function tpl_searchform($ajax=true,$autocomplete=true){ 794 global $lang; 795 global $ACT; 796 global $QUERY; 797 798 // don't print the search form if search action has been disabled 799 if (!actionOk('search')) return false; 800 801 print '<form action="'.wl().'" accept-charset="utf-8" class="search" id="dw__search"><div class="no">'; 802 print '<input type="hidden" name="do" value="search" />'; 803 print '<input type="text" '; 804 if($ACT == 'search') print 'value="'.htmlspecialchars($QUERY).'" '; 805 if(!$autocomplete) print 'autocomplete="off" '; 806 print 'id="qsearch__in" accesskey="f" name="id" class="edit" title="[F]" />'; 807 print '<input type="submit" value="'.$lang['btn_search'].'" class="button" title="'.$lang['btn_search'].'" />'; 808 if($ajax) print '<div id="qsearch__out" class="ajax_qsearch JSpopup"></div>'; 809 print '</div></form>'; 810 return true; 811} 812 813/** 814 * Print the breadcrumbs trace 815 * 816 * @author Andreas Gohr <andi@splitbrain.org> 817 */ 818function tpl_breadcrumbs($sep='»'){ 819 global $lang; 820 global $conf; 821 822 //check if enabled 823 if(!$conf['breadcrumbs']) return false; 824 825 $crumbs = breadcrumbs(); //setup crumb trace 826 827 //reverse crumborder in right-to-left mode, add RLM character to fix heb/eng display mixups 828 if($lang['direction'] == 'rtl') { 829 $crumbs = array_reverse($crumbs,true); 830 $crumbs_sep = ' ‏<span class="bcsep">'.$sep.'</span>‏ '; 831 } else { 832 $crumbs_sep = ' <span class="bcsep">'.$sep.'</span> '; 833 } 834 835 //render crumbs, highlight the last one 836 print '<span class="bchead">'.$lang['breadcrumb'].':</span>'; 837 $last = count($crumbs); 838 $i = 0; 839 foreach ($crumbs as $id => $name){ 840 $i++; 841 echo $crumbs_sep; 842 if ($i == $last) print '<span class="curid">'; 843 tpl_link(wl($id),hsc($name),'class="breadcrumbs" title="'.$id.'"'); 844 if ($i == $last) print '</span>'; 845 } 846 return true; 847} 848 849/** 850 * Hierarchical breadcrumbs 851 * 852 * This code was suggested as replacement for the usual breadcrumbs. 853 * It only makes sense with a deep site structure. 854 * 855 * @author Andreas Gohr <andi@splitbrain.org> 856 * @author Nigel McNie <oracle.shinoda@gmail.com> 857 * @author Sean Coates <sean@caedmon.net> 858 * @author <fredrik@averpil.com> 859 * @todo May behave strangely in RTL languages 860 */ 861function tpl_youarehere($sep=' » '){ 862 global $conf; 863 global $ID; 864 global $lang; 865 866 // check if enabled 867 if(!$conf['youarehere']) return false; 868 869 $parts = explode(':', $ID); 870 $count = count($parts); 871 872 if($GLOBALS['ACT'] == 'search') 873 { 874 $parts = array($conf['start']); 875 $count = 1; 876 } 877 878 echo '<span class="bchead">'.$lang['youarehere'].': </span>'; 879 880 // always print the startpage 881 $title = useHeading('navigation') ? p_get_first_heading($conf['start']) : $conf['start']; 882 if(!$title) $title = $conf['start']; 883 tpl_link(wl($conf['start']),hsc($title),'title="'.$conf['start'].'"'); 884 885 // print intermediate namespace links 886 $part = ''; 887 for($i=0; $i<$count - 1; $i++){ 888 $part .= $parts[$i].':'; 889 $page = $part; 890 resolve_pageid('',$page,$exists); 891 if ($page == $conf['start']) continue; // Skip startpage 892 893 // output 894 echo $sep; 895 if($exists){ 896 $title = useHeading('navigation') ? p_get_first_heading($page) : $parts[$i]; 897 tpl_link(wl($page),hsc($title),'title="'.$page.'"'); 898 }else{ 899 tpl_link(wl($page),$parts[$i],'title="'.$page.'" class="wikilink2" rel="nofollow"'); 900 } 901 } 902 903 // print current page, skipping start page, skipping for namespace index 904 if(isset($page) && $page==$part.$parts[$i]) return; 905 $page = $part.$parts[$i]; 906 if($page == $conf['start']) return; 907 echo $sep; 908 if(page_exists($page)){ 909 $title = useHeading('navigation') ? p_get_first_heading($page) : $parts[$i]; 910 tpl_link(wl($page),hsc($title),'title="'.$page.'"'); 911 }else{ 912 tpl_link(wl($page),$parts[$i],'title="'.$page.'" class="wikilink2" rel="nofollow"'); 913 } 914 return true; 915} 916 917/** 918 * Print info if the user is logged in 919 * and show full name in that case 920 * 921 * Could be enhanced with a profile link in future? 922 * 923 * @author Andreas Gohr <andi@splitbrain.org> 924 */ 925function tpl_userinfo(){ 926 global $lang; 927 global $INFO; 928 if(isset($_SERVER['REMOTE_USER'])){ 929 print $lang['loggedinas'].': '.$INFO['userinfo']['name'].' ('.$_SERVER['REMOTE_USER'].')'; 930 return true; 931 } 932 return false; 933} 934 935/** 936 * Print some info about the current page 937 * 938 * @author Andreas Gohr <andi@splitbrain.org> 939 */ 940function tpl_pageinfo($ret=false){ 941 global $conf; 942 global $lang; 943 global $INFO; 944 global $ID; 945 946 // return if we are not allowed to view the page 947 if (!auth_quickaclcheck($ID)) { return false; } 948 949 // prepare date and path 950 $fn = $INFO['filepath']; 951 if(!$conf['fullpath']){ 952 if($INFO['rev']){ 953 $fn = str_replace(fullpath($conf['olddir']).'/','',$fn); 954 }else{ 955 $fn = str_replace(fullpath($conf['datadir']).'/','',$fn); 956 } 957 } 958 $fn = utf8_decodeFN($fn); 959 $date = dformat($INFO['lastmod']); 960 961 // print it 962 if($INFO['exists']){ 963 $out = ''; 964 $out .= $fn; 965 $out .= ' · '; 966 $out .= $lang['lastmod']; 967 $out .= ': '; 968 $out .= $date; 969 if($INFO['editor']){ 970 $out .= ' '.$lang['by'].' '; 971 $out .= editorinfo($INFO['editor']); 972 }else{ 973 $out .= ' ('.$lang['external_edit'].')'; 974 } 975 if($INFO['locked']){ 976 $out .= ' · '; 977 $out .= $lang['lockedby']; 978 $out .= ': '; 979 $out .= editorinfo($INFO['locked']); 980 } 981 if($ret){ 982 return $out; 983 }else{ 984 echo $out; 985 return true; 986 } 987 } 988 return false; 989} 990 991/** 992 * Prints or returns the name of the given page (current one if none given). 993 * 994 * If useheading is enabled this will use the first headline else 995 * the given ID is used. 996 * 997 * @author Andreas Gohr <andi@splitbrain.org> 998 */ 999function tpl_pagetitle($id=null, $ret=false){ 1000 global $conf; 1001 if(is_null($id)){ 1002 global $ID; 1003 $id = $ID; 1004 } 1005 1006 $name = $id; 1007 if (useHeading('navigation')) { 1008 $title = p_get_first_heading($id); 1009 if ($title) $name = $title; 1010 } 1011 1012 if ($ret) { 1013 return hsc($name); 1014 } else { 1015 print hsc($name); 1016 return true; 1017 } 1018} 1019 1020/** 1021 * Returns the requested EXIF/IPTC tag from the current image 1022 * 1023 * If $tags is an array all given tags are tried until a 1024 * value is found. If no value is found $alt is returned. 1025 * 1026 * Which texts are known is defined in the functions _exifTagNames 1027 * and _iptcTagNames() in inc/jpeg.php (You need to prepend IPTC 1028 * to the names of the latter one) 1029 * 1030 * Only allowed in: detail.php 1031 * 1032 * @author Andreas Gohr <andi@splitbrain.org> 1033 */ 1034function tpl_img_getTag($tags,$alt='',$src=null){ 1035 // Init Exif Reader 1036 global $SRC; 1037 1038 if(is_null($src)) $src = $SRC; 1039 1040 static $meta = null; 1041 if(is_null($meta)) $meta = new JpegMeta($src); 1042 if($meta === false) return $alt; 1043 $info = $meta->getField($tags); 1044 if($info == false) return $alt; 1045 return $info; 1046} 1047 1048/** 1049 * Prints the image with a link to the full sized version 1050 * 1051 * Only allowed in: detail.php 1052 */ 1053function tpl_img($maxwidth=0,$maxheight=0){ 1054 global $IMG; 1055 $w = tpl_img_getTag('File.Width'); 1056 $h = tpl_img_getTag('File.Height'); 1057 1058 //resize to given max values 1059 $ratio = 1; 1060 if($w >= $h){ 1061 if($maxwidth && $w >= $maxwidth){ 1062 $ratio = $maxwidth/$w; 1063 }elseif($maxheight && $h > $maxheight){ 1064 $ratio = $maxheight/$h; 1065 } 1066 }else{ 1067 if($maxheight && $h >= $maxheight){ 1068 $ratio = $maxheight/$h; 1069 }elseif($maxwidth && $w > $maxwidth){ 1070 $ratio = $maxwidth/$w; 1071 } 1072 } 1073 if($ratio){ 1074 $w = floor($ratio*$w); 1075 $h = floor($ratio*$h); 1076 } 1077 1078 //prepare URLs 1079 $url=ml($IMG,array('cache'=>$_REQUEST['cache'])); 1080 $src=ml($IMG,array('cache'=>$_REQUEST['cache'],'w'=>$w,'h'=>$h)); 1081 1082 //prepare attributes 1083 $alt=tpl_img_getTag('Simple.Title'); 1084 $p = array(); 1085 if($w) $p['width'] = $w; 1086 if($h) $p['height'] = $h; 1087 $p['class'] = 'img_detail'; 1088 if($alt){ 1089 $p['alt'] = $alt; 1090 $p['title'] = $alt; 1091 }else{ 1092 $p['alt'] = ''; 1093 } 1094 $p = buildAttributes($p); 1095 1096 print '<a href="'.$url.'">'; 1097 print '<img src="'.$src.'" '.$p.'/>'; 1098 print '</a>'; 1099 return true; 1100} 1101 1102/** 1103 * This function inserts a 1x1 pixel gif which in reality 1104 * is the indexer function. 1105 * 1106 * Should be called somewhere at the very end of the main.php 1107 * template 1108 */ 1109function tpl_indexerWebBug(){ 1110 global $ID; 1111 global $INFO; 1112 if(!$INFO['exists']) return false; 1113 1114 if(isHiddenPage($ID)) return false; //no need to index hidden pages 1115 1116 $p = array(); 1117 $p['src'] = DOKU_BASE.'lib/exe/indexer.php?id='.rawurlencode($ID). 1118 '&'.time(); 1119 $p['width'] = 1; 1120 $p['height'] = 1; 1121 $p['alt'] = ''; 1122 $att = buildAttributes($p); 1123 print "<img $att />"; 1124 return true; 1125} 1126 1127// configuration methods 1128/** 1129 * tpl_getConf($id) 1130 * 1131 * use this function to access template configuration variables 1132 */ 1133function tpl_getConf($id){ 1134 global $conf; 1135 global $tpl_configloaded; 1136 1137 $tpl = $conf['template']; 1138 1139 if (!$tpl_configloaded){ 1140 $tconf = tpl_loadConfig(); 1141 if ($tconf !== false){ 1142 foreach ($tconf as $key => $value){ 1143 if (isset($conf['tpl'][$tpl][$key])) continue; 1144 $conf['tpl'][$tpl][$key] = $value; 1145 } 1146 $tpl_configloaded = true; 1147 } 1148 } 1149 1150 return $conf['tpl'][$tpl][$id]; 1151} 1152 1153/** 1154 * tpl_loadConfig() 1155 * reads all template configuration variables 1156 * this function is automatically called by tpl_getConf() 1157 */ 1158function tpl_loadConfig(){ 1159 1160 $file = DOKU_TPLINC.'/conf/default.php'; 1161 $conf = array(); 1162 1163 if (!@file_exists($file)) return false; 1164 1165 // load default config file 1166 include($file); 1167 1168 return $conf; 1169} 1170 1171/** 1172 * prints the "main content" in the mediamanger popup 1173 * 1174 * Depending on the user's actions this may be a list of 1175 * files in a namespace, the meta editing dialog or 1176 * a message of referencing pages 1177 * 1178 * Only allowed in mediamanager.php 1179 * 1180 * @triggers MEDIAMANAGER_CONTENT_OUTPUT 1181 * @param bool $fromajax - set true when calling this function via ajax 1182 * @author Andreas Gohr <andi@splitbrain.org> 1183 */ 1184function tpl_mediaContent($fromajax=false){ 1185 global $IMG; 1186 global $AUTH; 1187 global $INUSE; 1188 global $NS; 1189 global $JUMPTO; 1190 1191 if(is_array($_REQUEST['do'])){ 1192 $do = array_shift(array_keys($_REQUEST['do'])); 1193 }else{ 1194 $do = $_REQUEST['do']; 1195 } 1196 if(in_array($do,array('save','cancel'))) $do = ''; 1197 1198 if(!$do){ 1199 if($_REQUEST['edit']){ 1200 $do = 'metaform'; 1201 }elseif(is_array($INUSE)){ 1202 $do = 'filesinuse'; 1203 }else{ 1204 $do = 'filelist'; 1205 } 1206 } 1207 1208 // output the content pane, wrapped in an event. 1209 if(!$fromajax) ptln('<div id="media__content">'); 1210 $data = array( 'do' => $do); 1211 $evt = new Doku_Event('MEDIAMANAGER_CONTENT_OUTPUT', $data); 1212 if ($evt->advise_before()) { 1213 $do = $data['do']; 1214 if($do == 'metaform'){ 1215 media_metaform($IMG,$AUTH); 1216 }elseif($do == 'filesinuse'){ 1217 media_filesinuse($INUSE,$IMG); 1218 }elseif($do == 'filelist'){ 1219 media_filelist($NS,$AUTH,$JUMPTO); 1220 }elseif($do == 'searchlist'){ 1221 media_searchlist($_REQUEST['q'],$NS,$AUTH); 1222 }else{ 1223 msg('Unknown action '.hsc($do),-1); 1224 } 1225 } 1226 $evt->advise_after(); 1227 unset($evt); 1228 if(!$fromajax) ptln('</div>'); 1229 1230} 1231 1232/** 1233 * prints the namespace tree in the mediamanger popup 1234 * 1235 * Only allowed in mediamanager.php 1236 * 1237 * @author Andreas Gohr <andi@splitbrain.org> 1238 */ 1239function tpl_mediaTree(){ 1240 global $NS; 1241 1242 ptln('<div id="media__tree">'); 1243 media_nstree($NS); 1244 ptln('</div>'); 1245} 1246 1247 1248/** 1249 * Print a dropdown menu with all DokuWiki actions 1250 * 1251 * Note: this will not use any pretty URLs 1252 * 1253 * @author Andreas Gohr <andi@splitbrain.org> 1254 */ 1255function tpl_actiondropdown($empty='',$button='>'){ 1256 global $ID; 1257 global $INFO; 1258 global $REV; 1259 global $ACT; 1260 global $conf; 1261 global $lang; 1262 global $auth; 1263 1264 1265 echo '<form method="post" accept-charset="utf-8">'; #FIXME action 1266 echo '<input type="hidden" name="id" value="'.$ID.'" />'; 1267 if($REV) echo '<input type="hidden" name="rev" value="'.$REV.'" />'; 1268 echo '<input type="hidden" name="sectok" value="'.getSecurityToken().'" />'; 1269 1270 echo '<select name="do" id="action__selector" class="edit">'; 1271 echo '<option value="">'.$empty.'</option>'; 1272 1273 echo '<optgroup label=" — ">'; 1274 // 'edit' - most complicated type, we need to decide on current action 1275 if($ACT == 'show' || $ACT == 'search'){ 1276 if($INFO['writable']){ 1277 if(!empty($INFO['draft'])) { 1278 echo '<option value="edit">'.$lang['btn_draft'].'</option>'; 1279 } else { 1280 if($INFO['exists']){ 1281 echo '<option value="edit">'.$lang['btn_edit'].'</option>'; 1282 }else{ 1283 echo '<option value="edit">'.$lang['btn_create'].'</option>'; 1284 } 1285 } 1286 }else if(actionOK('source')) { //pseudo action 1287 echo '<option value="edit">'.$lang['btn_source'].'</option>'; 1288 } 1289 }else{ 1290 echo '<option value="show">'.$lang['btn_show'].'</option>'; 1291 } 1292 1293 echo '<option value="revisions">'.$lang['btn_revs'].'</option>'; 1294 if($INFO['ismanager'] && $REV && $INFO['writable'] && actionOK('revert')){ 1295 echo '<option value="revert">'.$lang['btn_revert'].'</option>'; 1296 } 1297 echo '<option value="backlink">'.$lang['btn_backlink'].'</option>'; 1298 echo '</optgroup>'; 1299 1300 echo '<optgroup label=" — ">'; 1301 echo '<option value="recent">'.$lang['btn_recent'].'</option>'; 1302 echo '<option value="index">'.$lang['btn_index'].'</option>'; 1303 echo '</optgroup>'; 1304 1305 echo '<optgroup label=" — ">'; 1306 if($conf['useacl'] && $auth){ 1307 if($_SERVER['REMOTE_USER']){ 1308 echo '<option value="logout">'.$lang['btn_logout'].'</option>'; 1309 }else{ 1310 echo '<option value="login">'.$lang['btn_login'].'</option>'; 1311 } 1312 } 1313 1314 if($conf['useacl'] && $auth && $_SERVER['REMOTE_USER'] && 1315 $auth->canDo('Profile') && ($ACT!='profile')){ 1316 echo '<option value="profile">'.$lang['btn_profile'].'</option>'; 1317 } 1318 1319 if($conf['useacl'] && $auth && $ACT == 'show' && $conf['subscribers'] == 1){ 1320 if($_SERVER['REMOTE_USER']){ 1321 if($INFO['subscribed']) { 1322 echo '<option value="unsubscribe">'.$lang['btn_unsubscribe'].'</option>'; 1323 } else { 1324 echo '<option value="subscribe">'.$lang['btn_subscribe'].'</option>'; 1325 } 1326 } 1327 } 1328 1329 if($conf['useacl'] && $auth && $ACT == 'show' && $conf['subscribers'] == 1){ 1330 if($_SERVER['REMOTE_USER']){ 1331 if($INFO['subscribedns']) { 1332 echo '<option value="unsubscribens">'.$lang['btn_unsubscribens'].'</option>'; 1333 } else { 1334 echo '<option value="subscribens">'.$lang['btn_subscribens'].'</option>'; 1335 } 1336 } 1337 } 1338 1339 if($INFO['ismanager']){ 1340 echo '<option value="admin">'.$lang['btn_admin'].'</option>'; 1341 } 1342 echo '</optgroup>'; 1343 1344 echo '</select>'; 1345 echo '<input type="submit" value="'.$button.'" id="action__selectorbtn" />'; 1346 echo '</form>'; 1347} 1348 1349/** 1350 * Print a informational line about the used license 1351 * 1352 * @author Andreas Gohr <andi@splitbrain.org> 1353 * @param string $img - print image? (|button|badge) 1354 * @param bool $return - when true don't print, but return HTML 1355 */ 1356function tpl_license($img='badge',$imgonly=false,$return=false){ 1357 global $license; 1358 global $conf; 1359 global $lang; 1360 if(!$conf['license']) return ''; 1361 if(!is_array($license[$conf['license']])) return ''; 1362 $lic = $license[$conf['license']]; 1363 1364 $out = '<div class="license">'; 1365 if($img){ 1366 $src = license_img($img); 1367 if($src){ 1368 $out .= '<a href="'.$lic['url'].'" rel="license"'; 1369 if($conf['target']['external']) $out .= ' target="'.$conf['target']['external'].'"'; 1370 $out .= '><img src="'.DOKU_BASE.$src.'" class="medialeft lic'.$img.'" alt="'.$lic['name'].'" /></a> '; 1371 } 1372 } 1373 if(!$imgonly) { 1374 $out .= $lang['license']; 1375 $out .= '<a href="'.$lic['url'].'" rel="license" class="urlextern"'; 1376 if(isset($conf['target']['external'])) $out .= ' target="'.$conf['target']['external'].'"'; 1377 $out .= '>'.$lic['name'].'</a>'; 1378 } 1379 $out .= '</div>'; 1380 1381 if($return) return $out; 1382 echo $out; 1383} 1384 1385 1386/** 1387 * Includes the rendered XHTML of a given page 1388 * 1389 * This function is useful to populate sidebars or similar features in a 1390 * template 1391 */ 1392function tpl_include_page($pageid,$print=true){ 1393 global $ID; 1394 $oldid = $ID; 1395 $html = p_wiki_xhtml($pageid,'',false); 1396 $ID = $oldid; 1397 1398 if(!$print) return $html; 1399 echo $html; 1400} 1401 1402//Setup VIM: ex: et ts=4 enc=utf-8 : 1403 1404