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 9 if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../').'/'); 10 require_once(DOKU_CONF.'dokuwiki.php'); 11 12/** 13 * Returns the path to the given template, uses 14 * default one if the custom version doesn't exist. 15 * Also enables gzip compression if configured. 16 * 17 * @author Andreas Gohr <andi@splitbrain.org> 18 */ 19function template($tpl){ 20 global $conf; 21 22 if(@is_readable(DOKU_INC.'lib/tpl/'.$conf['template'].'/'.$tpl)) 23 return DOKU_INC.'lib/tpl/'.$conf['template'].'/'.$tpl; 24 25 return DOKU_INC.'lib/tpl/default/'.$tpl; 26} 27 28/** 29 * Print the content 30 * 31 * This function is used for printing all the usual content 32 * (defined by the global $ACT var) by calling the appropriate 33 * outputfunction(s) from html.php 34 * 35 * Everything that doesn't use the main template file isn't 36 * handled by this function. ACL stuff is not done here either. 37 * 38 * @author Andreas Gohr <andi@splitbrain.org> 39 */ 40function tpl_content() { 41 global $ACT; 42 43 ob_start(); 44 45 trigger_event('TPL_ACT_RENDER',$ACT,tpl_content_core); 46 47 $html_output = ob_get_clean(); 48 49 trigger_event('TPL_CONTENT_DISPLAY',$html_output,ptln); 50} 51 52function tpl_content_core(){ 53 global $ACT; 54 global $TEXT; 55 global $PRE; 56 global $SUF; 57 global $SUM; 58 global $IDX; 59 60 switch($ACT){ 61 case 'show': 62 html_show(); 63 break; 64 case 'preview': 65 html_edit($TEXT); 66 html_show($TEXT); 67 break; 68 case 'recover': 69 html_edit($TEXT); 70 break; 71 case 'edit': 72 html_edit(); 73 break; 74 case 'draft': 75 html_draft(); 76 break; 77 case 'wordblock': 78 html_edit($TEXT,'wordblock'); 79 break; 80 case 'search': 81 html_search(); 82 break; 83 case 'revisions': 84 html_revisions(); 85 break; 86 case 'diff': 87 html_diff(); 88 break; 89 case 'recent': 90 $first = is_numeric($_REQUEST['first']) ? intval($_REQUEST['first']) : 0; 91 html_recent($first); 92 break; 93 case 'index': 94 html_index($IDX); #FIXME can this be pulled from globals? is it sanitized correctly? 95 break; 96 case 'backlink': 97 html_backlinks(); 98 break; 99 case 'conflict': 100 html_conflict(con($PRE,$TEXT,$SUF),$SUM); 101 html_diff(con($PRE,$TEXT,$SUF),false); 102 break; 103 case 'locked': 104 html_locked(); 105 break; 106 case 'login': 107 html_login(); 108 break; 109 case 'register': 110 html_register(); 111 break; 112 case 'resendpwd': 113 html_resendpwd(); 114 break; 115 case 'denied': 116 print p_locale_xhtml('denied'); 117 break; 118 case 'profile' : 119 html_updateprofile(); 120 break; 121 case 'admin': 122 tpl_admin(); 123 break; 124 default: 125 $evt = new Doku_Event('TPL_ACT_UNKNOWN',$ACT); 126 if ($evt->advise_before()) 127 msg("Failed to handle command: ".hsc($ACT),-1); 128 $evt->advise_after(); 129 unset($evt); 130 } 131} 132 133/** 134 * Handle the admin page contents 135 * 136 * @author Andreas Gohr <andi@splitbrain.org> 137 */ 138function tpl_admin(){ 139 140 $plugin = NULL; 141 if ($_REQUEST['page']) { 142 $pluginlist = plugin_list('admin'); 143 144 if (in_array($_REQUEST['page'], $pluginlist)) { 145 146 // attempt to load the plugin 147 $plugin =& plugin_load('admin',$_REQUEST['page']); 148 } 149 } 150 151 if ($plugin !== NULL) 152 $plugin->html(); 153 else 154 html_admin(); 155} 156 157/** 158 * Print the correct HTML meta headers 159 * 160 * This has to go into the head section of your template. 161 * 162 * @param boolean $alt Should feeds and alternative format links be added? 163 * @author Andreas Gohr <andi@splitbrain.org> 164 */ 165function tpl_metaheaders($alt=true){ 166 global $ID; 167 global $INFO; 168 global $ACT; 169 global $lang; 170 global $conf; 171 $it=2; 172 173 // the usual stuff 174 ptln('<meta name="generator" content="DokuWiki '.getVersion().'" />',$it); 175 ptln('<link rel="start" href="'.DOKU_BASE.'" />',$it); 176 ptln('<link rel="contents" href="'.wl($ID,'do=index').'" title="'.$lang['index'].'" />',$it); 177 178 if($alt){ 179 ptln('<link rel="alternate" type="application/rss+xml" title="Recent Changes" href="'.DOKU_BASE.'feed.php" />',$it); 180 ptln('<link rel="alternate" type="application/rss+xml" title="Current Namespace" href="'.DOKU_BASE.'feed.php?mode=list&ns='.$INFO['namespace'].'" />',$it); 181 ptln('<link rel="alternate" type="text/html" title="Plain HTML" href="'.exportlink($ID, 'xhtml').'" />',$it); 182 ptln('<link rel="alternate" type="text/plain" title="Wiki Markup" href="'.exportlink($ID, 'raw').'" />',$it); 183 } 184 185 // setup robot tags apropriate for different modes 186 if( ($ACT=='show' || $ACT=='export_xhtml') && !$REV){ 187 if($INFO['exists']){ 188 ptln('<meta name="date" content="'.date('Y-m-d\TH:i:sO',$INFO['lastmod']).'" />',$it); 189 //delay indexing: 190 if((time() - $INFO['lastmod']) >= $conf['indexdelay']){ 191 ptln('<meta name="robots" content="index,follow" />',$it); 192 }else{ 193 ptln('<meta name="robots" content="noindex,nofollow" />',$it); 194 } 195 }else{ 196 ptln('<meta name="robots" content="noindex,follow" />',$it); 197 } 198 }else{ 199 ptln('<meta name="robots" content="noindex,nofollow" />',$it); 200 } 201 202 // load stylesheets 203 ptln('<link rel="stylesheet" media="screen" type="text/css" href="'.DOKU_BASE.'lib/exe/css.php" />',$it); 204 ptln('<link rel="stylesheet" media="print" type="text/css" href="'.DOKU_BASE.'lib/exe/css.php?print=1" />',$it); 205 206 // load javascript 207 $js_edit = ($ACT=='edit' || $ACT=='preview' || $ACT=='recover') ? 1 : 0; 208 $js_write = ($INFO['writable']) ? 1 : 0; 209 if(defined('DOKU_MEDIAMANAGER')){ 210 $js_edit = 1; 211 $js_write = 0; 212 } 213 if(($js_edit && $js_write) || defined('DOKU_MEDIAMANAGER')){ 214 ptln('<script type="text/javascript" charset="utf-8">',$it); 215 ptln("NS='".$INFO['namespace']."';",$it+2); 216 if($conf['useacl'] && $_SERVER['REMOTE_USER']){ 217 require_once(DOKU_INC.'inc/toolbar.php'); 218 ptln("SIG='".toolbar_signature()."';",$it+2); 219 } 220 ptln('</script>',$it); 221 } 222 ptln('<script type="text/javascript" charset="utf-8" src="'. 223 DOKU_BASE.'lib/exe/js.php?edit='.$js_edit.'&write='.$js_write.'"></script>',$it); 224} 225 226/** 227 * Print a link 228 * 229 * Just builds a link. 230 * 231 * @author Andreas Gohr <andi@splitbrain.org> 232 */ 233function tpl_link($url,$name,$more=''){ 234 print '<a href="'.$url.'" '; 235 if ($more) print ' '.$more; 236 print ">$name</a>"; 237} 238 239/** 240 * Prints a link to a WikiPage 241 * 242 * Wrapper around html_wikilink 243 * 244 * @author Andreas Gohr <andi@splitbrain.org> 245 */ 246function tpl_pagelink($id,$name=NULL){ 247 print html_wikilink($id,$name); 248} 249 250/** 251 * get the parent page 252 * 253 * Tries to find out which page is parent. 254 * returns false if none is available 255 * 256 * @author Andreas Gohr <andi@splitbrain.org> 257 */ 258function tpl_getparent($id){ 259 global $conf; 260 $parent = getNS($id).':'; 261 resolve_pageid('',$parent,$exists); 262 if($parent == $id) return false; 263 return $parent; 264} 265 266/** 267 * Print one of the buttons 268 * 269 * Available Buttons are 270 * 271 * edit - edit/create/show/draft button 272 * history - old revisions 273 * recent - recent changes 274 * login - login/logout button - if ACL enabled 275 * index - The index 276 * admin - admin page - if enough rights 277 * top - a back to top button 278 * back - a back to parent button - if available 279 * backtomedia - returns to the mediafile upload dialog 280 * after references have been displayed 281 * backlink - links to the list of backlinks 282 * 283 * @author Andreas Gohr <andi@splitbrain.org> 284 * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net> 285 */ 286function tpl_button($type){ 287 global $ACT; 288 global $ID; 289 global $NS; 290 global $INFO; 291 global $conf; 292 global $auth; 293 294 switch($type){ 295 case 'edit': 296 print html_editbutton(); 297 break; 298 case 'history': 299 print html_btn('revs',$ID,'o',array('do' => 'revisions')); 300 break; 301 case 'recent': 302 print html_btn('recent','','r',array('do' => 'recent')); 303 break; 304 case 'index': 305 print html_btn('index',$ID,'x',array('do' => 'index')); 306 break; 307 case 'back': 308 if ($parent = tpl_getparent($ID)) { 309 print html_btn('back',$parent,'b',array('do' => 'show')); 310 } 311 break; 312 case 'top': 313 print html_topbtn(); 314 break; 315 case 'login': 316 if($conf['useacl']){ 317 if($_SERVER['REMOTE_USER']){ 318 print html_btn('logout',$ID,'',array('do' => 'logout',)); 319 }else{ 320 print html_btn('login',$ID,'',array('do' => 'login')); 321 } 322 } 323 break; 324 case 'admin': 325 if($INFO['perm'] == AUTH_ADMIN) 326 print html_btn('admin',$ID,'',array('do' => 'admin')); 327 break; 328 case 'backtomedia': 329 print html_backtomedia_button(array('ns' => $NS),'b'); 330 break; 331 case 'subscription': 332 if($conf['useacl'] && $ACT == 'show' && $conf['subscribers'] == 1){ 333 if($_SERVER['REMOTE_USER']){ 334 if($INFO['subscribed']){ 335 print html_btn('unsubscribe',$ID,'',array('do' => 'unsubscribe',)); 336 } else { 337 print html_btn('subscribe',$ID,'',array('do' => 'subscribe',)); 338 } 339 } 340 } 341 break; 342 case 'backlink': 343 print html_btn('backlink',$ID,'',array('do' => 'backlink')); 344 break; 345 case 'profile': 346 if($conf['useacl'] && $_SERVER['REMOTE_USER'] && 347 $auth->canDo('Profile') && ($ACT!='profile')){ 348 print html_btn('profile',$ID,'',array('do' => 'profile')); 349 } 350 break; 351 default: 352 print '[unknown button type]'; 353 } 354} 355 356/** 357 * Like the action buttons but links 358 * 359 * Available links are 360 * 361 * edit - edit/create/show button 362 * history - old revisions 363 * recent - recent changes 364 * login - login/logout button - if ACL enabled 365 * index - The index 366 * admin - admin page - if enough rights 367 * top - a back to top button 368 * back - a back to parent button - if available 369 * backlink - links to the list of backlinks 370 * 371 * @author Andreas Gohr <andi@splitbrain.org> 372 * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net> 373 * @see tpl_button 374 */ 375function tpl_actionlink($type,$pre='',$suf=''){ 376 global $ID; 377 global $INFO; 378 global $REV; 379 global $ACT; 380 global $conf; 381 global $lang; 382 global $auth; 383 384 switch($type){ 385 case 'edit': 386 #most complicated type - we need to decide on current action 387 if($ACT == 'show' || $ACT == 'search'){ 388 if($INFO['writable']){ 389 if($INFO['exists']){ 390 tpl_link(wl($ID,'do=edit&rev='.$REV), 391 $pre.$lang['btn_edit'].$suf, 392 'class="action edit" accesskey="e" rel="nofollow"'); 393 }else{ 394 tpl_link(wl($ID,'do=edit&rev='.$REV), 395 $pre.$lang['btn_create'].$suf, 396 'class="action create" accesskey="e" rel="nofollow"'); 397 } 398 }else{ 399 tpl_link(wl($ID,'do=edit&rev='.$REV), 400 $pre.$lang['btn_source'].$suf, 401 'class="action source" accesskey="v" rel="nofollow"'); 402 } 403 }else{ 404 tpl_link(wl($ID,'do=show'), 405 $pre.$lang['btn_show'].$suf, 406 'class="action show" accesskey="v" rel="nofollow"'); 407 } 408 return true; 409 case 'history': 410 tpl_link(wl($ID,'do=revisions'),$pre.$lang['btn_revs'].$suf,'class="action revisions" accesskey="o"'); 411 return true; 412 case 'recent': 413 tpl_link(wl($ID,'do=recent'),$pre.$lang['btn_recent'].$suf,'class="action recent" accesskey="r"'); 414 return true; 415 case 'index': 416 tpl_link(wl($ID,'do=index'),$pre.$lang['btn_index'].$suf,'class="action index" accesskey="x"'); 417 return true; 418 case 'top': 419 print '<a href="#dokuwiki__top" class="action top" accesskey="x">'.$pre.$lang['btn_top'].$suf.'</a>'; 420 return true; 421 case 'back': 422 if ($ID = tpl_getparent($ID)) { 423 tpl_link(wl($ID,'do=show'),$pre.$lang['btn_back'].$suf,'class="action back" accesskey="b"'); 424 return true; 425 } 426 return false; 427 case 'login': 428 if($conf['useacl']){ 429 if($_SERVER['REMOTE_USER']){ 430 tpl_link(wl($ID,'do=logout'),$pre.$lang['btn_logout'].$suf,'class="action logout"'); 431 }else{ 432 tpl_link(wl($ID,'do=login'),$pre.$lang['btn_login'].$suf,'class="action logout"'); 433 } 434 return true; 435 } 436 return false; 437 case 'admin': 438 if($INFO['perm'] == AUTH_ADMIN){ 439 tpl_link(wl($ID,'do=admin'),$pre.$lang['btn_admin'].$suf,'class="action admin"'); 440 return true; 441 } 442 return false; 443 case 'subscribe': 444 case 'subscription': 445 if($conf['useacl'] && $ACT == 'show' && $conf['subscribers'] == 1){ 446 if($_SERVER['REMOTE_USER']){ 447 if($INFO['subscribed']) { 448 tpl_link(wl($ID,'do=unsubscribe'),$pre.$lang['btn_unsubscribe'].$suf,'class="action unsubscribe"'); 449 } else { 450 tpl_link(wl($ID,'do=subscribe'),$pre.$lang['btn_subscribe'].$suf,'class="action subscribe"'); 451 } 452 return true; 453 } 454 } 455 return false; 456 case 'backlink': 457 tpl_link(wl($ID,'do=backlink'),$pre.$lang['btn_backlink'].$suf, 'class="action backlink"'); 458 return true; 459 case 'profile': 460 if($conf['useacl'] && $_SERVER['REMOTE_USER'] && 461 $auth->canDo('Profile') && ($ACT!='profile')){ 462 tpl_link(wl($ID,'do=profile'),$pre.$lang['btn_profile'].$suf, 'class="action profile"'); 463 return true; 464 } 465 return false; 466 default: 467 print '[unknown link type]'; 468 return true; 469 } 470} 471 472/** 473 * Print the search form 474 * 475 * If the first parameter is given a div with the ID 'qsearch_out' will 476 * be added which instructs the ajax pagequicksearch to kick in and place 477 * its output into this div. The second parameter controls the propritary 478 * attribute autocomplete. If set to false this attribute will be set with an 479 * value of "off" to instruct the browser to disable it's own built in 480 * autocompletion feature (MSIE and Firefox) 481 * 482 * @author Andreas Gohr <andi@splitbrain.org> 483 */ 484function tpl_searchform($ajax=true,$autocomplete=true){ 485 global $lang; 486 global $ACT; 487 488 print '<form action="'.wl().'" accept-charset="utf-8" class="search" id="dw__search"><div class="no">'; 489 print '<input type="hidden" name="do" value="search" />'; 490 print '<input type="text" '; 491 if($ACT == 'search') print 'value="'.htmlspecialchars($_REQUEST['id']).'" '; 492 if(!$autocomplete) print 'autocomplete="off" '; 493 print 'id="qsearch__in" accesskey="f" name="id" class="edit" />'; 494 print '<input type="submit" value="'.$lang['btn_search'].'" class="button" />'; 495 if($ajax) print '<div id="qsearch__out" class="ajax_qsearch JSpopup"></div>'; 496 print '</div></form>'; 497} 498 499/** 500 * Print the breadcrumbs trace 501 * 502 * @author Andreas Gohr <andi@splitbrain.org> 503 */ 504function tpl_breadcrumbs(){ 505 global $lang; 506 global $conf; 507 508 //check if enabled 509 if(!$conf['breadcrumbs']) return; 510 511 $crumbs = breadcrumbs(); //setup crumb trace 512 513 //reverse crumborder in right-to-left mode 514 if($lang['direction'] == 'rtl') $crumbs = array_reverse($crumbs,true); 515 516 //render crumbs, highlight the last one 517 print $lang['breadcrumb'].':'; 518 $last = count($crumbs); 519 $i = 0; 520 foreach ($crumbs as $id => $name){ 521 $i++; 522 print ' <span class="bcsep">»</span> '; 523 if ($i == $last) print '<span class="curid">'; 524 tpl_link(wl($id),$name,'class="breadcrumbs" title="'.$id.'"'); 525 if ($i == $last) print '</span>'; 526 } 527} 528 529/** 530 * Hierarchical breadcrumbs 531 * 532 * This code was suggested as replacement for the usual breadcrumbs. 533 * It only makes sense with a deep site structure. 534 * 535 * @author Andreas Gohr <andi@splitbrain.org> 536 * @author Nigel McNie <oracle.shinoda@gmail.com> 537 * @author Sean Coates <sean@caedmon.net> 538 * @link http://wiki.splitbrain.org/wiki:tipsandtricks:hierarchicalbreadcrumbs 539 * @todo May behave strangely in RTL languages 540 */ 541function tpl_youarehere($sep=' » '){ 542 global $conf; 543 global $ID; 544 global $lang; 545 546 // check if enabled 547 if(!$conf['youarehere']) return; 548 549 $parts = explode(':', $ID); 550 $count = count($parts); 551 552 echo $lang['youarehere'].': '; 553 554 // always print the startpage 555 $title = p_get_first_heading($conf['start']); 556 if(!$title) $title = $conf['start']; 557 tpl_link(wl($conf['start']),$title,'title="'.$conf['start'].'"'); 558 559 // print intermediate namespace links 560 $part = ''; 561 for($i=0; $i<$count - 1; $i++){ 562 $part .= $parts[$i].':'; 563 $page = $part; 564 resolve_pageid('',$page,$exists); 565 if ($page == $conf['start']) continue; // Skip startpage 566 567 // output 568 echo $sep; 569 if($exists){ 570 $title = p_get_first_heading($page); 571 if(!$title) $title = $parts[$i]; 572 tpl_link(wl($page),$title,'title="'.$page.'"'); 573 }else{ 574 tpl_link(wl($page),$parts[$i],'title="'.$page.'" class="wikilink2"'); 575 } 576 } 577 578 // print current page, skipping start page, skipping for namespace index 579 if($page == $part.$parts[$i]) return; 580 $page = $part.$parts[$i]; 581 if($page == $conf['start']) return; 582 echo $sep; 583 if(file_exists(wikiFN($page))){ 584 $title = p_get_first_heading($page); 585 if(!$title) $title = $parts[$i]; 586 tpl_link(wl($page),$title,'title="'.$page.'"'); 587 }else{ 588 tpl_link(wl($page),$parts[$i],'title="'.$page.'" class="wikilink2"'); 589 } 590} 591 592/** 593 * Print info if the user is logged in 594 * and show full name in that case 595 * 596 * Could be enhanced with a profile link in future? 597 * 598 * @author Andreas Gohr <andi@splitbrain.org> 599 */ 600function tpl_userinfo(){ 601 global $lang; 602 global $INFO; 603 if($_SERVER['REMOTE_USER']) 604 print $lang['loggedinas'].': '.$INFO['userinfo']['name']; 605} 606 607/** 608 * Print some info about the current page 609 * 610 * @author Andreas Gohr <andi@splitbrain.org> 611 */ 612function tpl_pageinfo(){ 613 global $conf; 614 global $lang; 615 global $INFO; 616 global $REV; 617 618 // prepare date and path 619 $fn = $INFO['filepath']; 620 if(!$conf['fullpath']){ 621 if($REV){ 622 $fn = str_replace(realpath($conf['olddir']).DIRECTORY_SEPARATOR,'',$fn); 623 }else{ 624 $fn = str_replace(realpath($conf['datadir']).DIRECTORY_SEPARATOR,'',$fn); 625 } 626 } 627 $fn = utf8_decodeFN($fn); 628 $date = date($conf['dformat'],$INFO['lastmod']); 629 630 // print it 631 if($INFO['exists']){ 632 print $fn; 633 print ' · '; 634 print $lang['lastmod']; 635 print ': '; 636 print $date; 637 if($INFO['editor']){ 638 print ' '.$lang['by'].' '; 639 print $INFO['editor']; 640 } 641 if($INFO['locked']){ 642 print ' · '; 643 print $lang['lockedby']; 644 print ': '; 645 print $INFO['locked']; 646 } 647 } 648} 649 650/** 651 * Prints or returns the name of the given page (current one if none given). 652 * 653 * If useheading is enabled this will use the first headline else 654 * the given ID is used. 655 * 656 * @author Andreas Gohr <andi@splitbrain.org> 657 */ 658function tpl_pagetitle($id=null, $ret=false){ 659 global $conf; 660 if(is_null($id)){ 661 global $ID; 662 $id = $ID; 663 } 664 665 $name = $id; 666 if ($conf['useheading']) { 667 $title = p_get_first_heading($id); 668 if ($title) $name = $title; 669 } 670 671 if ($ret) { 672 return hsc($name); 673 } else { 674 print hsc($name); 675 } 676} 677 678/** 679 * Returns the requested EXIF/IPTC tag from the current image 680 * 681 * If $tags is an array all given tags are tried until a 682 * value is found. If no value is found $alt is returned. 683 * 684 * Which texts are known is defined in the functions _exifTagNames 685 * and _iptcTagNames() in inc/jpeg.php (You need to prepend IPTC 686 * to the names of the latter one) 687 * 688 * Only allowed in: detail.php 689 * 690 * @author Andreas Gohr <andi@splitbrain.org> 691 */ 692function tpl_img_getTag($tags,$alt='',$src=null){ 693 // Init Exif Reader 694 global $SRC; 695 696 if(is_null($src)) $src = $SRC; 697 698 static $meta = null; 699 if(is_null($meta)) $meta = new JpegMeta($src); 700 if($meta === false) return $alt; 701 $info = $meta->getField($tags); 702 if($info == false) return $alt; 703 return $info; 704} 705 706/** 707 * Prints the image with a link to the full sized version 708 * 709 * Only allowed in: detail.php 710 */ 711function tpl_img($maxwidth=0,$maxheight=0){ 712 global $IMG; 713 $w = tpl_img_getTag('File.Width'); 714 $h = tpl_img_getTag('File.Height'); 715 716 //resize to given max values 717 $ratio = 1; 718 if($w >= $h){ 719 if($maxwidth && $w >= $maxwidth){ 720 $ratio = $maxwidth/$w; 721 }elseif($maxheight && $h > $maxheight){ 722 $ratio = $maxheight/$h; 723 } 724 }else{ 725 if($maxheight && $h >= $maxheight){ 726 $ratio = $maxheight/$h; 727 }elseif($maxwidth && $w > $maxwidth){ 728 $ratio = $maxwidth/$w; 729 } 730 } 731 if($ratio){ 732 $w = floor($ratio*$w); 733 $h = floor($ratio*$h); 734 } 735 736 //prepare URLs 737 $url=ml($IMG,array('cache'=>$_REQUEST['cache'])); 738 $src=ml($IMG,array('cache'=>$_REQUEST['cache'],'w'=>$w,'h'=>$h)); 739 740 //prepare attributes 741 $alt=tpl_img_getTag('Simple.Title'); 742 $p = array(); 743 if($w) $p['width'] = $w; 744 if($h) $p['height'] = $h; 745 $p['class'] = 'img_detail'; 746 if($alt){ 747 $p['alt'] = $alt; 748 $p['title'] = $alt; 749 }else{ 750 $p['alt'] = ''; 751 } 752 $p = buildAttributes($p); 753 754 print '<a href="'.$url.'">'; 755 print '<img src="'.$src.'" '.$p.'/>'; 756 print '</a>'; 757} 758 759/** 760 * This function inserts a 1x1 pixel gif which in reality 761 * is the inexer function. 762 * 763 * Should be called somewhere at the very end of the main.php 764 * template 765 */ 766function tpl_indexerWebBug(){ 767 global $ID; 768 global $INFO; 769 if(!$INFO['exists']) return; 770 771 if(isHiddenPage($ID)) return; //no need to index hidden pages 772 773 $p = array(); 774 $p['src'] = DOKU_BASE.'lib/exe/indexer.php?id='.rawurlencode($ID). 775 '&'.time(); 776 $p['width'] = 1; 777 $p['height'] = 1; 778 $p['alt'] = ''; 779 $att = buildAttributes($p); 780 print "<img $att />"; 781} 782 783// configuration methods 784/** 785 * tpl_getConf($id) 786 * 787 * use this function to access template configuration variables 788 */ 789function tpl_getConf($id){ 790 global $conf; 791 global $tpl_configloaded; 792 793 $tpl = $conf['template']; 794 795 if (!$tpl_configloaded){ 796 $tconf = tpl_loadConfig(); 797 if ($tconf !== false){ 798 foreach ($tconf as $key => $value){ 799 if (isset($conf['tpl'][$tpl][$key])) continue; 800 $conf['tpl'][$tpl][$key] = $value; 801 } 802 $tpl_configloaded = true; 803 } 804 } 805 806 return $conf['tpl'][$tpl][$id]; 807} 808 809/** 810 * tpl_loadConfig() 811 * reads all template configuration variables 812 * this function is automatically called by tpl_getConf() 813 */ 814function tpl_loadConfig(){ 815 816 $file = DOKU_TPLINC.'/conf/default.php'; 817 $conf = array(); 818 819 if (!@file_exists($file)) return false; 820 821 // load default config file 822 include($file); 823 824 return $conf; 825} 826 827/** 828 * prints the "main content" in the mediamanger popup 829 * 830 * Depending on the user's actions this may be a list of 831 * files in a namespace, the meta editing dialog or 832 * a message of referencing pages 833 * 834 * Only allowed in mediamanager.php 835 * 836 * @author Andreas Gohr <andi@splitbrain.org> 837 */ 838function tpl_mediaContent(){ 839 global $IMG; 840 global $AUTH; 841 global $INUSE; 842 global $NS; 843 global $JUMPTO; 844 845 ptln('<div id="media__content">'); 846 if($_REQUEST['edit']){ 847 media_metaform($IMG,$AUTH); 848 }elseif(is_array($INUSE)){ 849 media_filesinuse($INUSE,$IMG); 850 }else{ 851 media_filelist($NS,$AUTH,$JUMPTO); 852 } 853 ptln('</div>'); 854} 855 856/** 857 * prints the namespace tree in the mediamanger popup 858 * 859 * Only allowed in mediamanager.php 860 * 861 * @author Andreas Gohr <andi@splitbrain.org> 862 */ 863function tpl_mediaTree(){ 864 global $NS; 865 866 ptln('<div id="media__tree">'); 867 media_nstree($NS); 868 ptln('</div>'); 869} 870 871//Setup VIM: ex: et ts=2 enc=utf-8 : 872