1<?php 2if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); 3 4if ( !defined('DOKU_LF') ) { 5 // Some whitespace to help View > Source 6 define ('DOKU_LF',"\n"); 7} 8 9if ( !defined('DOKU_TAB') ) { 10 // Some whitespace to help View > Source 11 define ('DOKU_TAB',"\t"); 12} 13 14require_once DOKU_INC . 'inc/parser/renderer.php'; 15 16/** 17* @TODO Probably useful for have constant for linefeed formatting 18*/ 19class Doku_Renderer_XHTML extends Doku_Renderer { 20 21 var $doc = ''; 22 23 var $headers = array(); 24 25 var $footnotes = array(); 26 27 var $footnoteIdStack = array(); 28 29 var $acronyms = array(); 30 var $smileys = array(); 31 var $badwords = array(); 32 var $entities = array(); 33 var $interwiki = array(); 34 35 var $lastsec = 0; 36 37 function document_start() { 38 ob_start(); 39 } 40 41 function document_end() { 42 // add button for last section if any 43 if($this->lastsec) $this->__secedit($this->lastsec,''); 44 45 if ( count ($this->footnotes) > 0 ) { 46 echo '<div class="footnotes">'.DOKU_LF; 47 foreach ( $this->footnotes as $footnote ) { 48 echo $footnote; 49 } 50 echo '</div>'.DOKU_LF; 51 } 52 53 $this->doc .= ob_get_contents(); 54 ob_end_clean(); 55 56 } 57 58 function toc_open() { 59 echo '<div class="toc">'.DOKU_LF; 60 echo '<div class="tocheader">Table of Contents <script type="text/javascript">showTocToggle("+","-")</script></div>'.DOKU_LF; 61 echo '<div id="tocinside">'.DOKU_LF; 62 } 63 64 function tocbranch_open($level) { 65 echo '<ul class="toc">'.DOKU_LF; 66 } 67 68 function tocitem_open($level, $empty = FALSE) { 69 if ( !$empty ) { 70 echo '<li class="level'.$level.'">'; 71 } else { 72 echo '<li class="clear">'; 73 } 74 } 75 76 function tocelement($level, $title) { 77 echo '<span class="li"><a href="#'.$this->__headerToLink($title).'" class="toc">'; 78 echo $this->__xmlEntities($title); 79 echo '</a></span>'; 80 } 81 82 function tocitem_close($level) { 83 echo '</li>'.DOKU_LF; 84 } 85 86 function tocbranch_close($level) { 87 echo '</ul>'.DOKU_LF; 88 } 89 90 function toc_close() { 91 echo '</div>'.DOKU_LF.'</div>'.DOKU_LF; 92 } 93 94 function header($text, $level, $pos) { 95 global $conf; 96 //handle section editing 97 if($level <= $conf['maxseclevel']){ 98 // add button for last section if any 99 if($this->lastsec) $this->__secedit($this->lastsec,$pos-1); 100 // remember current position 101 $this->lastsec = $pos; 102 } 103 104 echo DOKU_LF.'<a name="'.$this->__headerToLink($text).'"></a><h'.$level.'>'; 105 echo $this->__xmlEntities($text); 106 echo "</h$level>".DOKU_LF; 107 } 108 109 function section_open($level) { 110 echo "<div class=\"level$level\">".DOKU_LF; 111 } 112 113 function section_close() { 114 echo DOKU_LF.'</div>'.DOKU_LF; 115 } 116 117 function cdata($text) { 118 echo $this->__xmlEntities($text); 119 } 120 121 function p_open() { 122 echo DOKU_LF.'<p>'.DOKU_LF; 123 } 124 125 function p_close() { 126 echo DOKU_LF.'</p>'.DOKU_LF; 127 } 128 129 function linebreak() { 130 echo '<br/>'.DOKU_LF; 131 } 132 133 function hr() { 134 echo '<hr noshade="noshade" size="1" />'.DOKU_LF; 135 } 136 137 function strong_open() { 138 echo '<strong>'; 139 } 140 141 function strong_close() { 142 echo '</strong>'; 143 } 144 145 function emphasis_open() { 146 echo '<em>'; 147 } 148 149 function emphasis_close() { 150 echo '</em>'; 151 } 152 153 function underline_open() { 154 echo '<u>'; 155 } 156 157 function underline_close() { 158 echo '</u>'; 159 } 160 161 function monospace_open() { 162 echo '<code>'; 163 } 164 165 function monospace_close() { 166 echo '</code>'; 167 } 168 169 function subscript_open() { 170 echo '<sub>'; 171 } 172 173 function subscript_close() { 174 echo '</sub>'; 175 } 176 177 function superscript_open() { 178 echo '<sup>'; 179 } 180 181 function superscript_close() { 182 echo '</sup>'; 183 } 184 185 function deleted_open() { 186 echo '<del>'; 187 } 188 189 function deleted_close() { 190 echo '</del>'; 191 } 192 193 function footnote_open() { 194 $id = $this->__newFootnoteId(); 195 echo '<a href="#fn'.$id.'" name="fnt'.$id.'" class="fn_top">'.$id.')</a>'; 196 $this->footnoteIdStack[] = $id; 197 ob_start(); 198 } 199 200 function footnote_close() { 201 $contents = ob_get_contents(); 202 ob_end_clean(); 203 $id = array_pop($this->footnoteIdStack); 204 205 $contents = '<div class="fn"><a href="#fnt'. 206 $id.'" name="fn'.$id.'" class="fn_bot">'. 207 $id.')</a> ' .DOKU_LF .$contents. "\n" . '</div>' . DOKU_LF; 208 $this->footnotes[$id] = $contents; 209 } 210 211 function listu_open() { 212 echo '<ul>'.DOKU_LF; 213 } 214 215 function listu_close() { 216 echo '</ul>'.DOKU_LF; 217 } 218 219 function listo_open() { 220 echo '<ol>'.DOKU_LF; 221 } 222 223 function listo_close() { 224 echo '</ol>'.DOKU_LF; 225 } 226 227 function listitem_open($level) { 228 echo '<li class="level'.$level.'">'; 229 } 230 231 function listitem_close() { 232 echo '</li>'.DOKU_LF; 233 } 234 235 function listcontent_open() { 236 echo '<span class="li">'; 237 } 238 239 function listcontent_close() { 240 echo '</span>'.DOKU_LF; 241 } 242 243 function unformatted($text) { 244 echo $this->__xmlEntities($text); 245 } 246 247 /** 248 */ 249 function php($text) { 250 global $conf; 251 if($conf['phpok']){ 252 eval($text); 253 }else{ 254 $this->file($text); 255 } 256 } 257 258 /** 259 */ 260 function html($text) { 261 global $conf; 262 if($conf['htmlok']){ 263 echo $text; 264 }else{ 265 $this->file($text); 266 } 267 } 268 269 function preformatted($text) { 270 echo '<pre class="code">' . $this->__xmlEntities($text) . '</pre>'. DOKU_LF; 271 } 272 273 function file($text) { 274 echo '<pre class="file">' . $this->__xmlEntities($text). '</pre>'. DOKU_LF; 275 } 276 277 /** 278 * @TODO Shouldn't this output <blockquote?? 279 */ 280 function quote_open() { 281 echo '<div class="quote">'.DOKU_LF; 282 } 283 284 /** 285 * @TODO Shouldn't this output </blockquote>? 286 */ 287 function quote_close() { 288 echo '</div>'.DOKU_LF; 289 } 290 291 /** 292 */ 293 function code($text, $language = NULL) { 294 global $conf; 295 296 if ( is_null($language) ) { 297 $this->preformatted($text); 298 } else { 299 // Handle with Geshi here FIXME: strip first beginning newline 300 require_once(DOKU_INC . 'inc/geshi.php'); 301 $geshi = new GeSHi($text, strtolower($language), DOKU_INC . 'inc/geshi'); 302 $geshi->enable_classes(); 303 $geshi->set_header_type(GESHI_HEADER_PRE); 304 $geshi->set_overall_class('code'); 305 $geshi->set_link_target($conf['target']['extern']); 306 307 $text = $geshi->parse_code(); 308 echo $text; 309 } 310 } 311 312 function acronym($acronym) { 313 314 if ( array_key_exists($acronym, $this->acronyms) ) { 315 316 $title = $this->__xmlEntities($this->acronyms[$acronym]); 317 318 echo '<acronym title="'.$title 319 .'">'.$this->__xmlEntities($acronym).'</acronym>'; 320 321 } else { 322 echo $this->__xmlEntities($acronym); 323 } 324 } 325 326 /** 327 */ 328 function smiley($smiley) { 329 if ( array_key_exists($smiley, $this->smileys) ) { 330 $title = $this->__xmlEntities($this->smileys[$smiley]); 331 echo '<img src="'.DOKU_BASE.'smileys/'.$this->smileys[$smiley]. 332 '" align="middle" alt="'. 333 $this->__xmlEntities($smiley).'" />'; 334 } else { 335 echo $this->__xmlEntities($smiley); 336 } 337 } 338 339 /** 340 * not used 341 function wordblock($word) { 342 if ( array_key_exists($word, $this->badwords) ) { 343 echo '** BLEEP **'; 344 } else { 345 echo $this->__xmlEntities($word); 346 } 347 } 348 */ 349 350 function entity($entity) { 351 if ( array_key_exists($entity, $this->entities) ) { 352 echo $this->entities[$entity]; 353 } else { 354 echo $this->__xmlEntities($entity); 355 } 356 } 357 358 function multiplyentity($x, $y) { 359 echo "$x×$y"; 360 } 361 362 function singlequoteopening() { 363 echo "‘"; 364 } 365 366 function singlequoteclosing() { 367 echo "’"; 368 } 369 370 function doublequoteopening() { 371 echo "“"; 372 } 373 374 function doublequoteclosing() { 375 echo "”"; 376 } 377 378 /** 379 */ 380 function camelcaselink($link) { 381 $this->internallink($link,$link); 382 } 383 384 /** 385 * @TODO Support media 386 * @TODO correct attributes 387 */ 388 function internallink($id, $name = NULL) { 389 global $conf; 390 391 $name = $this->__getLinkTitle($name, $this->__simpleTitle($id), $isImage); 392 resolve_pageid($id,$exists); 393 394 if ( !$isImage ) { 395 if ( $exists ) { 396 $class='wikilink1'; 397 } else { 398 $class='wikilink2'; 399 } 400 } else { 401 $class='media'; 402 } 403 404 //prepare for formating 405 $link['target'] = $conf['target']['wiki']; 406 $link['style'] = ''; 407 $link['pre'] = ''; 408 $link['suf'] = ''; 409 $link['more'] = 'onclick="return svchk()" onkeypress="return svchk()"'; 410 $link['class'] = $class; 411 $link['url'] = wl($id); 412 $link['name'] = $name; 413 $link['title'] = $id; 414 415 //output formatted 416 echo $this->__formatLink($link); 417 } 418 419 420 /** 421 * @TODO Should list assume blacklist check already made? 422 * @TODO External link icon 423 * @TODO correct attributes 424 */ 425 function externallink($link, $title = NULL) { 426 427 echo '<a'; 428 429 $title = $this->__getLinkTitle($title, $link, $isImage); 430 431 if ( !$isImage ) { 432 echo ' class="urlextern"'; 433 } else { 434 echo ' class="media"'; 435 } 436 437 echo ' target="_blank" href="'.$this->__xmlEntities($link).'"'; 438 439 echo ' onclick="return svchk()" onkeypress="return svchk()">'; 440 441 echo $title; 442 443 echo '</a>'; 444 } 445 446 /** 447 * @TODO Remove hard coded link to splitbrain.org on style 448 */ 449 function interwikilink($link, $title = NULL, $wikiName, $wikiUri) { 450 451 // RESOLVE THE URL 452 if ( isset($this->interwiki[$wikiName]) ) { 453 454 $wikiUriEnc = urlencode($wikiUri); 455 456 if ( strstr($this->interwiki[$wikiName],'{URL}' ) !== FALSE ) { 457 458 $url = str_replace('{URL}', $wikiUriEnc, $this->interwiki[$wikiName] ); 459 460 } else if ( strstr($this->interwiki[$wikiName],'{NAME}' ) !== FALSE ) { 461 462 $url = str_replace('{NAME}', $wikiUriEnc, $this->interwiki[$wikiName] ); 463 464 } else { 465 466 $url = $this->interwiki[$wikiName] . urlencode($wikiUri); 467 468 } 469 470 } else { 471 // Default to Google I'm feeling lucky 472 $url = 'http://www.google.com/search?q='.urlencode($wikiUri).'&btnI=lucky'; 473 } 474 475 // BUILD THE LINK 476 echo '<a'; 477 478 $title = $this->__getLinkTitle($title, $wikiUri, $isImage); 479 480 if ( !$isImage ) { 481 echo ' class="interwiki"'; 482 } else { 483 echo ' class="media"'; 484 } 485 486 echo ' href="'.$this->__xmlEntities($url).'"'; 487 488 if ( FALSE !== ( $type = interwikiImgExists($wikiName) ) ) { 489 echo ' style="background: transparent url(http://wiki.splitbrain.org/interwiki/'. 490 $wikiName.'.'.$type.') 0px 1px no-repeat;"'; 491 } 492 493 echo ' onclick="return svchk()" onkeypress="return svchk()">'; 494 495 echo $title; 496 497 echo '</a>'; 498 } 499 500 /** 501 * @TODO Correct the CSS class for files? (not windows) 502 * @TODO Remove hard coded URL to splitbrain.org 503 */ 504 function filelink($link, $title = NULL) { 505 echo '<a'; 506 507 $title = $this->__getLinkTitle($title, $link, $isImage); 508 509 if ( !$isImage ) { 510 echo ' class="windows"'; 511 } else { 512 echo ' class="media"'; 513 } 514 515 echo ' href="'.$this->__xmlEntities($link).'"'; 516 517 echo ' style="background: transparent url(http://wiki.splitbrain.org/images/windows.gif) 0px 1px no-repeat;"'; 518 519 echo ' onclick="return svchk()" onkeypress="return svchk()">'; 520 521 echo $title; 522 523 echo '</a>'; 524 } 525 526 /** 527 * @TODO Remove hard coded URL to splitbrain.org 528 * @TODO Add error message for non-IE users 529 */ 530 function windowssharelink($link, $title = NULL) { 531 echo '<a'; 532 533 $title = $this->__getLinkTitle($title, $link, $isImage); 534 535 if ( !$isImage ) { 536 echo ' class="windows"'; 537 } else { 538 echo ' class="media"'; 539 } 540 541 $link = str_replace('\\','/',$link); 542 $link = 'file:///'.$link; 543 echo ' href="'.$this->__xmlEntities($link).'"'; 544 545 echo ' style="background: transparent url(http://wiki.splitbrain.org/images/windows.gif) 0px 1px no-repeat;"'; 546 547 echo ' onclick="return svchk()" onkeypress="return svchk()">'; 548 549 echo $title; 550 551 echo '</a>'; 552 } 553 554 /** 555 * @TODO Protect email address from harvesters 556 * @TODO Remove hard coded link to splitbrain.org 557 */ 558 function email($address, $title = NULL) { 559 echo '<a'; 560 561 $title = $this->__getLinkTitle($title, $address, $isImage); 562 563 if ( !$isImage ) { 564 echo ' class="mail"'; 565 } else { 566 echo ' class="media"'; 567 } 568 569 echo ' href="mailto:'.$this->__xmlEntities($address).'"'; 570 571 echo ' style="background: transparent url(http://wiki.splitbrain.org/images/mail_icon.gif) 0px 1px no-repeat;"'; 572 573 echo ' onclick="return svchk()" onkeypress="return svchk()">'; 574 575 echo $title; 576 577 echo '</a>'; 578 579 } 580 581 /** 582 * @todo don't add link for flash 583 */ 584 function internalmedia ($src, $title=NULL, $align=NULL, $width=NULL, 585 $height=NULL, $cache=NULL) { 586 587 resolve_mediaid($src, $exists); 588 589 $this->internallink($src, $title = 590 array( 'type' => 'internalmedia', 591 'src' => $src, 592 'title' => $title, 593 'align' => $align, 594 'width' => $width, 595 'height' => $height, 596 'cache' => $cache, 597 'link' => $link )); 598 } 599 600 /** 601 * @todo don't add link for flash 602 */ 603 function externalmedia ($src, $title=NULL, $align=NULL, $width=NULL, 604 $height=NULL, $cache=NULL) { 605 606 $this->externallink($src, $title = 607 array( 'type' => 'externalmedia', 608 'src' => $src, 609 'title' => $title, 610 'align' => $align, 611 'width' => $width, 612 'height' => $height, 613 'cache' => $cache, 614 'link' => $link )); 615 } 616 617 /** 618 * Renders internal and external media 619 * 620 * @author Andreas Gohr <andi@splitbrain.org> 621 * @todo handle center align 622 */ 623 function __media ($src, $title=NULL, $align=NULL, $width=NULL, 624 $height=NULL, $cache=NULL) { 625 626 $ret = ''; 627 628 list($ext,$mime) = mimetype($src); 629 if(substr($mime,0,5) == 'image'){ 630 //add image tag 631 $ret .= '<img class="media" src="'. 632 DOKU_BASE.'fetch.php?media='.urlencode($src). 633 '&w='.$width.'&h='.$height. 634 '&cache='.$cache.'"'; 635 636 if (!is_null($title)) 637 $ret .= ' title="'.$this->__xmlEntities($title).'"'; 638 639 640 if (!is_null($align)) 641 $ret .= ' align="'.$align.'"'; #FIXME use class! 642 643 if ( !is_null($width) ) 644 $ret .= ' width="'.$this->__xmlEntities($width).'"'; 645 646 if ( !is_null($height) ) 647 $ret .= ' height="'.$this->__xmlEntities($height).'"'; 648 649 $ret .= ' />'; 650 651 }elseif($mime == 'application/x-shockwave-flash'){ 652 //FIXME default to a higher flash version? 653 654 $ret .= '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'. 655 ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0"'; 656 if ( !is_null($width) ) $ret .= ' width="'.$this->__xmlEntities($width).'"'; 657 if ( !is_null($height) ) $ret .= ' height="'.$this->__xmlEntities($height).'"'; 658 $ret .= '>'.DOKU_LF; 659 $ret .= '<param name="movie" value="'.DOKU_BASE.'fetch.php?media='.urlencode($src).'" />'.DOKU_LF; 660 $ret .= '<param name="quality" value="high" />'.DOKU_LF; 661 $ret .= '<embed src="'.DOKU_BASE.'fetch.php?media='.urlencode($src).'"'. 662 ' quality="high" bgcolor="#000000"'; 663 if ( !is_null($width) ) $ret .= ' width="'.$this->__xmlEntities($width).'"'; 664 if ( !is_null($height) ) $ret .= ' height="'.$this->__xmlEntities($height).'"'; 665 $ret .= ' type="application/x-shockwave-flash"'. 666 ' pluginspage="http://www.macromedia.com/shockwave/download/index.cgi'. 667 '?P1_Prod_Version=ShockwaveFlash"></embed>'.DOKU_LF; 668 $ret .= '</object>'.DOKU_LF; 669 670 }elseif(!is_null($title)){ 671 // well at least we have a title to display 672 $ret .= $this->__xmlEntities($title); 673 }else{ 674 // just show the source 675 $ret .= $this->__xmlEntities($src); 676 } 677 678 return $ret; 679 } 680 681 // $numrows not yet implemented 682 function table_open($maxcols = NULL, $numrows = NULL){ 683 echo '<table class="inline">'.DOKU_LF; 684 } 685 686 function table_close(){ 687 echo '</table>'.DOKU_LF.'<br />'.DOKU_LF; 688 } 689 690 function tablerow_open(){ 691 echo DOKU_TAB . '<tr>' . DOKU_LF . DOKU_TAB . DOKU_TAB; 692 } 693 694 function tablerow_close(){ 695 echo DOKU_LF . DOKU_TAB . '</tr>' . DOKU_LF; 696 } 697 698 function tableheader_open($colspan = 1, $align = NULL){ 699 echo '<th'; 700 if ( !is_null($align) ) { 701 echo ' class="'.$align.'align"'; 702 } 703 if ( $colspan > 1 ) { 704 echo ' colspan="'.$colspan.'"'; 705 } 706 echo '>'; 707 } 708 709 function tableheader_close(){ 710 echo '</th>'; 711 } 712 713 function tablecell_open($colspan = 1, $align = NULL){ 714 echo '<td'; 715 if ( !is_null($align) ) { 716 echo ' class="'.$align.'align"'; 717 } 718 if ( $colspan > 1 ) { 719 echo ' colspan="'.$colspan.'"'; 720 } 721 echo '>'; 722 } 723 724 function tablecell_close(){ 725 echo '</td>'; 726 } 727 728 //---------------------------------------------------------- 729 // Utils 730 731 /** 732 * Assembles all parts defined by the link formater below 733 * Returns HTML for the link 734 * 735 * @author Andreas Gohr <andi@splitbrain.org> 736 */ 737 function __formatLink($link){ 738 //make sure the url is XHTML compliant (skip mailto) 739 if(substr($link['url'],0,7) != 'mailto:'){ 740 $link['url'] = str_replace('&','&',$link['url']); 741 $link['url'] = str_replace('&amp;','&',$link['url']); 742 } 743 //remove double encodings in titles 744 $link['title'] = str_replace('&amp;','&',$link['title']); 745 746 $ret = ''; 747 $ret .= $link['pre']; 748 $ret .= '<a href="'.$link['url'].'"'; 749 if($link['class']) $ret .= ' class="'.$link['class'].'"'; 750 if($link['target']) $ret .= ' target="'.$link['target'].'"'; 751 if($link['title']) $ret .= ' title="'.$link['title'].'"'; 752 if($link['style']) $ret .= ' style="'.$link['style'].'"'; 753 if($link['more']) $ret .= ' '.$link['more']; 754 $ret .= '>'; 755 $ret .= $link['name']; 756 $ret .= '</a>'; 757 $ret .= $link['suf']; 758 return $ret; 759 } 760 761 /** 762 * Removes any Namespace from the given name but keeps 763 * casing and special chars 764 * 765 * @author Andreas Gohr <andi@splitbrain.org> 766 */ 767 function __simpleTitle($name){ 768 global $conf; 769 if($conf['useslash']){ 770 $nssep = '[:;/]'; 771 }else{ 772 $nssep = '[:;]'; 773 } 774 return preg_replace('!.*'.$nssep.'!','',$name); 775 } 776 777 778 function __newFootnoteId() { 779 static $id = 1; 780 return $id++; 781 } 782 783 function __xmlEntities($string) { 784 return htmlspecialchars($string); 785 } 786 787 /** 788 * @TODO Tuning needed - e.g. utf8 strtolower ? 789 */ 790 function __headerToLink($title) { 791 return preg_replace('/\W/','_',trim($title)); 792 } 793 794 /** 795 * Adds code for section editing button 796 */ 797 function __secedit($f, $t){ 798 print '<!-- SECTION ['.$f.'-'.$t.'] -->'; 799 } 800 801 function __getLinkTitle($title, $default, & $isImage) { 802 $isImage = FALSE; 803 804 if ( is_null($title) ) { 805 return $this->__xmlEntities($default); 806 807 } else if ( is_string($title) ) { 808 809 return $this->__xmlEntities($title); 810 811 } else if ( is_array($title) ) { 812 813 $isImage = TRUE; 814 return $this->__imageTitle($title); 815 816 } 817 } 818 819 /** 820 * @TODO Resolve namespace on internal images 821 */ 822 function __imageTitle($img) { 823 824 //FIXME resolve internal links 825 826 return $this->__media($img['src'], 827 $img['title'], 828 $img['align'], 829 $img['width'], 830 $img['height'], 831 $img['cache']); 832 833/* 834 if ( $img['type'] == 'internalmedia' ) { 835 836 // Resolve here... 837 if ( strpos($img['src'],':') ) { 838 $src = explode(':',$img['src']); 839 $src = $src[1]; 840 } else { 841 $src = $img['src']; 842 } 843 844 $imgStr = '<img class="media" src="http://wiki.splitbrain.org/media/wiki/'.$this->__xmlEntities($src).'"'; 845 846 } else { 847 848 $imgStr = '<img class="media" src="'.$this->__xmlEntities($img['src']).'"'; 849 850 } 851 852 if ( !is_null($img['title']) ) { 853 $imgStr .= ' alt="'.$this->__xmlEntities($img['title']).'"'; 854 } else { 855 $imgStr .= ' alt=""'; 856 } 857 858 if ( !is_null($img['align']) ) { 859 $imgStr .= ' align="'.$img['align'].'"'; 860 } 861 862 if ( !is_null($img['width']) ) { 863 $imgStr .= ' width="'.$this->__xmlEntities($img['width']).'"'; 864 } 865 866 if ( !is_null($img['height']) ) { 867 $imgStr .= ' height="'.$this->__xmlEntities($img['height']).'"'; 868 } 869 870 $imgStr .= '/>'; 871 872 return $imgStr; 873*/ 874 } 875} 876 877/** 878* Test whether there's an image to display with this interwiki link 879*/ 880function interwikiImgExists($name) { 881 882 static $exists = array(); 883 884 if ( array_key_exists($name,$exists) ) { 885 return $exists[$name]; 886 } 887 888 if( @file_exists( DOKU. 'interwiki/'.$name.'.png') ) { 889 $exists[$name] = 'png'; 890 } else if ( @file_exists( DOKU . 'interwiki/'.$name.'.gif') ) { 891 $exists[$name] = 'gif'; 892 } else { 893 $exists[$name] = FALSE; 894 } 895 896 return $exists[$name]; 897} 898 899/** 900 * For determining whether to use CSS class "wikilink1" or "wikilink2" 901 * @todo use configinstead of DOKU_DATA 902 * @deprecated -> resolve_pagename should be used 903 */ 904function wikiPageExists($name) { 905msg("deprecated wikiPageExists called",-1); 906 static $pages = array(); 907 908 if ( array_key_exists($name,$pages) ) { 909 return $pages[$name]; 910 } 911 912 $file = str_replace(':','/',$name).'.txt'; 913 914 if ( @file_exists( DOKU_DATA . $file ) ) { 915 $pages[$name] = TRUE; 916 } else { 917 $pages[$name] = FALSE; 918 } 919 920 return $pages[$name]; 921} 922 923 924//Setup VIM: ex: et ts=4 enc=utf-8 : 925