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