1<?php 2/** 3 * HTML output 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.'); 10if(!defined('NL')) define('NL',"\n"); 11require_once(DOKU_INC.'inc/parserutils.php'); 12require_once(DOKU_INC.'inc/form.php'); 13 14/** 15 * Convenience function to quickly build a wikilink 16 * 17 * @author Andreas Gohr <andi@splitbrain.org> 18 */ 19function html_wikilink($id,$name=NULL,$search=''){ 20 static $xhtml_renderer = NULL; 21 if(is_null($xhtml_renderer)){ 22 require_once(DOKU_INC.'inc/parser/xhtml.php'); 23 $xhtml_renderer = new Doku_Renderer_xhtml(); 24 } 25 26 return $xhtml_renderer->internallink($id,$name,$search,true,'navigation'); 27} 28 29/** 30 * Helps building long attribute lists 31 * 32 * @author Andreas Gohr <andi@splitbrain.org> 33 */ 34function html_attbuild($attributes){ 35 $ret = ''; 36 foreach ( $attributes as $key => $value ) { 37 $ret .= $key.'="'.formtext($value).'" '; 38 } 39 return trim($ret); 40} 41 42/** 43 * The loginform 44 * 45 * @author Andreas Gohr <andi@splitbrain.org> 46 */ 47function html_login(){ 48 global $lang; 49 global $conf; 50 global $ID; 51 global $auth; 52 53 print p_locale_xhtml('login'); 54 print '<div class="centeralign">'.NL; 55 $form = new Doku_Form('dw__login'); 56 $form->startFieldset($lang['btn_login']); 57 $form->addHidden('id', $ID); 58 $form->addHidden('do', 'login'); 59 $form->addElement(form_makeTextField('u', ((!$_REQUEST['http_credentials']) ? $_REQUEST['u'] : ''), $lang['user'], 'focus__this', 'block')); 60 $form->addElement(form_makePasswordField('p', $lang['pass'], '', 'block')); 61 if($conf['rememberme']) { 62 $form->addElement(form_makeCheckboxField('r', '1', $lang['remember'], 'remember__me', 'simple')); 63 } 64 $form->addElement(form_makeButton('submit', '', $lang['btn_login'])); 65 $form->endFieldset(); 66 html_form('login', $form); 67 68 if($auth && $auth->canDo('addUser') && actionOK('register')){ 69 print '<p>'; 70 print $lang['reghere']; 71 print ': <a href="'.wl($ID,'do=register').'" rel="nofollow" class="wikilink1">'.$lang['register'].'</a>'; 72 print '</p>'; 73 } 74 75 if ($auth && $auth->canDo('modPass') && actionOK('resendpwd')) { 76 print '<p>'; 77 print $lang['pwdforget']; 78 print ': <a href="'.wl($ID,'do=resendpwd').'" rel="nofollow" class="wikilink1">'.$lang['btn_resendpwd'].'</a>'; 79 print '</p>'; 80 } 81 print '</div>'.NL; 82} 83 84/** 85 * prints a section editing button 86 * used as a callback in html_secedit 87 * 88 * @author Andreas Gohr <andi@splitbrain.org> 89 */ 90function html_secedit_button($matches){ 91 global $ID; 92 global $INFO; 93 94 $section = $matches[2]; 95 $name = $matches[1]; 96 97 $secedit = ''; 98 $secedit .= '<div class="secedit">'; 99 $secedit .= html_btn('secedit',$ID,'', 100 array('do' => 'edit', 101 'lines' => "$section", 102 'rev' => $INFO['lastmod']), 103 'post', $name); 104 $secedit .= '</div>'; 105 return $secedit; 106} 107 108/** 109 * inserts section edit buttons if wanted or removes the markers 110 * 111 * @author Andreas Gohr <andi@splitbrain.org> 112 */ 113function html_secedit($text,$show=true){ 114 global $INFO; 115 116 if($INFO['writable'] && $show && !$INFO['rev']){ 117 $text = preg_replace_callback('#<!-- SECTION "(.*?)" \[(\d+-\d*)\] -->#', 118 'html_secedit_button', $text); 119 }else{ 120 $text = preg_replace('#<!-- SECTION "(.*?)" \[(\d+-\d*)\] -->#','',$text); 121 } 122 123 return $text; 124} 125 126/** 127 * Just the back to top button (in its own form) 128 * 129 * @author Andreas Gohr <andi@splitbrain.org> 130 */ 131function html_topbtn(){ 132 global $lang; 133 134 $ret = ''; 135 $ret = '<a class="nolink" href="#dokuwiki__top"><input type="button" class="button" value="'.$lang['btn_top'].'" onclick="window.scrollTo(0, 0)" title="'.$lang['btn_top'].'" /></a>'; 136 137 return $ret; 138} 139 140/** 141 * Displays a button (using its own form) 142 * If tooltip exists, the access key tooltip is replaced. 143 * 144 * @author Andreas Gohr <andi@splitbrain.org> 145 */ 146function html_btn($name,$id,$akey,$params,$method='get',$tooltip=''){ 147 global $conf; 148 global $lang; 149 150 $label = $lang['btn_'.$name]; 151 152 $ret = ''; 153 $tip = ''; 154 155 //filter id (without urlencoding) 156 $id = idfilter($id,false); 157 158 //make nice URLs even for buttons 159 if($conf['userewrite'] == 2){ 160 $script = DOKU_BASE.DOKU_SCRIPT.'/'.$id; 161 }elseif($conf['userewrite']){ 162 $script = DOKU_BASE.$id; 163 }else{ 164 $script = DOKU_BASE.DOKU_SCRIPT; 165 $params['id'] = $id; 166 } 167 168 $ret .= '<form class="button btn_'.$name.'" method="'.$method.'" action="'.$script.'"><div class="no">'; 169 170 if(is_array($params)){ 171 reset($params); 172 while (list($key, $val) = each($params)) { 173 $ret .= '<input type="hidden" name="'.$key.'" '; 174 $ret .= 'value="'.htmlspecialchars($val).'" />'; 175 } 176 } 177 178 if ($tooltip!='') { 179 $tip = htmlspecialchars($tooltip); 180 }else{ 181 $tip = htmlspecialchars($label); 182 } 183 184 $ret .= '<input type="submit" value="'.htmlspecialchars($label).'" class="button" '; 185 if($akey){ 186 $tip .= ' ['.strtoupper($akey).']'; 187 $ret .= 'accesskey="'.htmlspecialchars($label).' '.$akey.'" '; 188 } 189 $ret .= 'title="'.$tip.'" '; 190 $ret .= '/>'; 191 $ret .= '</div></form>'; 192 193 return $ret; 194} 195 196/** 197 * show a wiki page 198 * 199 * @author Andreas Gohr <andi@splitbrain.org> 200 */ 201function html_show($txt=''){ 202 global $ID; 203 global $REV; 204 global $HIGH; 205 global $INFO; 206 //disable section editing for old revisions or in preview 207 if($txt || $REV){ 208 $secedit = false; 209 }else{ 210 $secedit = true; 211 } 212 213 if ($txt){ 214 //PreviewHeader 215 echo '<br id="scroll__here" />'; 216 echo p_locale_xhtml('preview'); 217 echo '<div class="preview">'; 218 $html = html_secedit(p_render('xhtml',p_get_instructions($txt),$info),$secedit); 219 if($INFO['prependTOC']) $html = tpl_toc(true).$html; 220 echo $html; 221 echo '<div class="clearer"></div>'; 222 echo '</div>'; 223 224 }else{ 225 if ($REV) print p_locale_xhtml('showrev'); 226 $html = p_wiki_xhtml($ID,$REV,true); 227 $html = html_secedit($html,$secedit); 228 if($INFO['prependTOC']) $html = tpl_toc(true).$html; 229 $html = html_hilight($html,$HIGH); 230 echo $html; 231 } 232} 233 234/** 235 * ask the user about how to handle an exisiting draft 236 * 237 * @author Andreas Gohr <andi@splitbrain.org> 238 */ 239function html_draft(){ 240 global $INFO; 241 global $ID; 242 global $lang; 243 global $conf; 244 $draft = unserialize(io_readFile($INFO['draft'],false)); 245 $text = cleanText(con($draft['prefix'],$draft['text'],$draft['suffix'],true)); 246 247 print p_locale_xhtml('draft'); 248 $form = new Doku_Form('dw__editform'); 249 $form->addHidden('id', $ID); 250 $form->addHidden('date', $draft['date']); 251 $form->addElement(form_makeWikiText($text, array('readonly'=>'readonly'))); 252 $form->addElement(form_makeOpenTag('div', array('id'=>'draft__status'))); 253 $form->addElement($lang['draftdate'].' '. strftime($conf['dformat'],filemtime($INFO['draft']))); 254 $form->addElement(form_makeCloseTag('div')); 255 $form->addElement(form_makeButton('submit', 'recover', $lang['btn_recover'], array('tabindex'=>'1'))); 256 $form->addElement(form_makeButton('submit', 'draftdel', $lang['btn_draftdel'], array('tabindex'=>'2'))); 257 $form->addElement(form_makeButton('submit', 'show', $lang['btn_cancel'], array('tabindex'=>'3'))); 258 html_form('draft', $form); 259} 260 261/** 262 * Highlights searchqueries in HTML code 263 * 264 * @author Andreas Gohr <andi@splitbrain.org> 265 * @author Harry Fuecks <hfuecks@gmail.com> 266 */ 267function html_hilight($html,$phrases){ 268 $regex = join('|',array_map('preg_quote_cb',array_filter((array) $phrases))); 269 270 if ($regex === '') return $html; 271 $html = preg_replace_callback("/((<[^>]*)|$regex)/ui",'html_hilight_callback',$html); 272 return $html; 273} 274 275/** 276 * Callback used by html_hilight() 277 * 278 * @author Harry Fuecks <hfuecks@gmail.com> 279 */ 280function html_hilight_callback($m) { 281 $hlight = unslash($m[0]); 282 if ( !isset($m[2])) { 283 $hlight = '<span class="search_hit">'.$hlight.'</span>'; 284 } 285 return $hlight; 286} 287 288/** 289 * Run a search and display the result 290 * 291 * @author Andreas Gohr <andi@splitbrain.org> 292 */ 293function html_search(){ 294 require_once(DOKU_INC.'inc/search.php'); 295 require_once(DOKU_INC.'inc/fulltext.php'); 296 global $conf; 297 global $QUERY; 298 global $ID; 299 global $lang; 300 301 print p_locale_xhtml('searchpage'); 302 flush(); 303 304 //check if search is restricted to namespace 305 if(preg_match('/([^@]*)@([^@]*)/',$QUERY,$match)) { 306 $id = cleanID($match[1]); 307 if(empty($id)) { 308 print '<div class="nothing">'.$lang['nothingfound'].'</div>'; 309 flush(); 310 return; 311 } 312 } else { 313 $id = cleanID($QUERY); 314 } 315 316 //show progressbar 317 print '<div class="centeralign" id="dw__loading">'.NL; 318 print '<script type="text/javascript" charset="utf-8"><!--//--><![CDATA[//><!--'.NL; 319 print 'showLoadBar();'.NL; 320 print '//--><!]]></script>'.NL; 321 print '<br /></div>'.NL; 322 flush(); 323 324 //do quick pagesearch 325 $data = array(); 326 327 $data = ft_pageLookup($id); 328 if(count($data)){ 329 print '<div class="search_quickresult">'; 330 print '<h3>'.$lang['quickhits'].':</h3>'; 331 print '<ul class="search_quickhits">'; 332 foreach($data as $id){ 333 print '<li> '; 334 $ns = getNS($id); 335 if($ns){ 336 $name = shorten(noNS($id), ' ('.$ns.')',30); 337 }else{ 338 $name = $id; 339 } 340 print html_wikilink(':'.$id,$name); 341 print '</li> '; 342 } 343 print '</ul> '; 344 //clear float (see http://www.complexspiral.com/publications/containing-floats/) 345 print '<div class="clearer"> </div>'; 346 print '</div>'; 347 } 348 flush(); 349 350 //do fulltext search 351 $data = ft_pageSearch($QUERY,$regex); 352 if(count($data)){ 353 $num = 1; 354 foreach($data as $id => $cnt){ 355 print '<div class="search_result">'; 356 print html_wikilink(':'.$id,useHeading('navigation')?NULL:$id,$regex); 357 print ': <span class="search_cnt">'.$cnt.' '.$lang['hits'].'</span><br />'; 358 if($num < 15){ // create snippets for the first number of matches only #FIXME add to conf ? 359 print '<div class="search_snippet">'.ft_snippet($id,$regex).'</div>'; 360 } 361 print '</div>'; 362 flush(); 363 $num++; 364 } 365 }else{ 366 print '<div class="nothing">'.$lang['nothingfound'].'</div>'; 367 } 368 369 //hide progressbar 370 print '<script type="text/javascript" charset="utf-8"><!--//--><![CDATA[//><!--'.NL; 371 print 'hideLoadBar("dw__loading");'.NL; 372 print '//--><!]]></script>'.NL; 373 flush(); 374} 375 376/** 377 * Display error on locked pages 378 * 379 * @author Andreas Gohr <andi@splitbrain.org> 380 */ 381function html_locked(){ 382 global $ID; 383 global $conf; 384 global $lang; 385 global $INFO; 386 387 $locktime = filemtime(wikiLockFN($ID)); 388 $expire = @strftime($conf['dformat'], $locktime + $conf['locktime'] ); 389 $min = round(($conf['locktime'] - (time() - $locktime) )/60); 390 391 print p_locale_xhtml('locked'); 392 print '<ul>'; 393 print '<li><div class="li"><strong>'.$lang['lockedby'].':</strong> '.$INFO['locked'].'</div></li>'; 394 print '<li><div class="li"><strong>'.$lang['lockexpire'].':</strong> '.$expire.' ('.$min.' min)</div></li>'; 395 print '</ul>'; 396} 397 398/** 399 * list old revisions 400 * 401 * @author Andreas Gohr <andi@splitbrain.org> 402 * @author Ben Coburn <btcoburn@silicodon.net> 403 */ 404function html_revisions($first=0){ 405 global $ID; 406 global $INFO; 407 global $conf; 408 global $lang; 409 /* we need to get one additionally log entry to be able to 410 * decide if this is the last page or is there another one. 411 * see html_recent() 412 */ 413 $revisions = getRevisions($ID, $first, $conf['recent']+1); 414 if(count($revisions)==0 && $first!=0){ 415 $first=0; 416 $revisions = getRevisions($ID, $first, $conf['recent']+1);; 417 } 418 $hasNext = false; 419 if (count($revisions)>$conf['recent']) { 420 $hasNext = true; 421 array_pop($revisions); // remove extra log entry 422 } 423 424 $date = @strftime($conf['dformat'],$INFO['lastmod']); 425 426 print p_locale_xhtml('revisions'); 427 428 $form = new Doku_Form('page__revisions', wl($ID)); 429 $form->addElement(form_makeOpenTag('ul')); 430 if($INFO['exists'] && $first==0){ 431 if (isset($INFO['meta']) && isset($INFO['meta']['last_change']) && $INFO['meta']['last_change']['type']===DOKU_CHANGE_TYPE_MINOR_EDIT) 432 $form->addElement(form_makeOpenTag('li', array('class' => 'minor'))); 433 else 434 $form->addElement(form_makeOpenTag('li')); 435 $form->addElement(form_makeOpenTag('div', array('class' => 'li'))); 436 $form->addElement(form_makeTag('input', array( 437 'type' => 'checkbox', 438 'name' => 'rev2[]', 439 'value' => 'current'))); 440 441 $form->addElement(form_makeOpenTag('span', array('class' => 'date'))); 442 $form->addElement($date); 443 $form->addElement(form_makeCloseTag('span')); 444 445 $form->addElement(form_makeTag('img', array( 446 'src' => DOKU_BASE.'lib/images/blank.gif', 447 'width' => '15', 448 'height' => '11', 449 'alt' => ''))); 450 451 $form->addElement(form_makeOpenTag('a', array( 452 'class' => 'wikilink1', 453 'href' => wl($ID)))); 454 $form->addElement($ID); 455 $form->addElement(form_makeCloseTag('a')); 456 457 $form->addElement(form_makeOpenTag('span', array('class' => 'sum'))); 458 $form->addElement(' – '); 459 $form->addElement(htmlspecialchars($INFO['sum'])); 460 $form->addElement(form_makeCloseTag('span')); 461 462 $form->addElement(form_makeOpenTag('span', array('class' => 'user'))); 463 $form->addElement((empty($INFO['editor']))?('('.$lang['external_edit'].')'):editorinfo($INFO['editor'])); 464 $form->addElement(form_makeCloseTag('span')); 465 466 $form->addElement('('.$lang['current'].')'); 467 $form->addElement(form_makeCloseTag('div')); 468 $form->addElement(form_makeCloseTag('li')); 469 } 470 471 foreach($revisions as $rev){ 472 $date = strftime($conf['dformat'],$rev); 473 $info = getRevisionInfo($ID,$rev,true); 474 $exists = page_exists($ID,$rev); 475 476 if ($info['type']===DOKU_CHANGE_TYPE_MINOR_EDIT) 477 $form->addElement(form_makeOpenTag('li', array('class' => 'minor'))); 478 else 479 $form->addElement(form_makeOpenTag('li')); 480 $form->addElement(form_makeOpenTag('div', array('class' => 'li'))); 481 if($exists){ 482 $form->addElement(form_makeTag('input', array( 483 'type' => 'checkbox', 484 'name' => 'rev2[]', 485 'value' => $rev))); 486 }else{ 487 $form->addElement(form_makeTag('img', array( 488 'src' => DOKU_BASE.'lib/images/blank.gif', 489 'width' => 14, 490 'height' => 11, 491 'alt' => ''))); 492 } 493 494 $form->addElement(form_makeOpenTag('span', array('class' => 'date'))); 495 $form->addElement($date); 496 $form->addElement(form_makeCloseTag('span')); 497 498 if($exists){ 499 $form->addElement(form_makeOpenTag('a', array('href' => wl($ID,"rev=$rev,do=diff", false, '&'), 'class' => 'diff_link'))); 500 $form->addElement(form_makeTag('img', array( 501 'src' => DOKU_BASE.'lib/images/diff.png', 502 'width' => 15, 503 'height' => 11, 504 'title' => $lang['diff'], 505 'alt' => $lang['diff']))); 506 $form->addElement(form_makeCloseTag('a')); 507 508 $form->addElement(form_makeOpenTag('a', array('href' => wl($ID,"rev=$rev",false,'&'), 'class' => 'wikilink1'))); 509 $form->addElement($ID); 510 $form->addElement(form_makeCloseTag('a')); 511 }else{ 512 $form->addElement(form_makeTag('img', array( 513 'src' => DOKU_BASE.'lib/images/blank.gif', 514 'width' => '15', 515 'height' => '11', 516 'alt' => ''))); 517 $form->addElement($ID); 518 } 519 520 $form->addElement(form_makeOpenTag('span', array('class' => 'sum'))); 521 $form->addElement(' – '); 522 $form->addElement(htmlspecialchars($info['sum'])); 523 $form->addElement(form_makeCloseTag('span')); 524 525 $form->addElement(form_makeOpenTag('span', array('class' => 'user'))); 526 if($info['user']){ 527 $form->addElement(editorinfo($info['user'])); 528 if(auth_ismanager()){ 529 $form->addElement(' ('.$info['ip'].')'); 530 } 531 }else{ 532 $form->addElement($info['ip']); 533 } 534 $form->addElement(form_makeCloseTag('span')); 535 536 $form->addElement(form_makeCloseTag('div')); 537 $form->addElement(form_makeCloseTag('li')); 538 } 539 $form->addElement(form_makeCloseTag('ul')); 540 $form->addElement(form_makeButton('submit', 'diff', $lang['diff2'])); 541 html_form('revisions', $form); 542 543 print '<div class="pagenav">'; 544 $last = $first + $conf['recent']; 545 if ($first > 0) { 546 $first -= $conf['recent']; 547 if ($first < 0) $first = 0; 548 print '<div class="pagenav-prev">'; 549 print html_btn('newer',$ID,"p",array('do' => 'revisions', 'first' => $first)); 550 print '</div>'; 551 } 552 if ($hasNext) { 553 print '<div class="pagenav-next">'; 554 print html_btn('older',$ID,"n",array('do' => 'revisions', 'first' => $last)); 555 print '</div>'; 556 } 557 print '</div>'; 558 559} 560 561/** 562 * display recent changes 563 * 564 * @author Andreas Gohr <andi@splitbrain.org> 565 * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net> 566 * @author Ben Coburn <btcoburn@silicodon.net> 567 */ 568function html_recent($first=0){ 569 global $conf; 570 global $lang; 571 global $ID; 572 /* we need to get one additionally log entry to be able to 573 * decide if this is the last page or is there another one. 574 * This is the cheapest solution to get this information. 575 */ 576 $recents = getRecents($first,$conf['recent'] + 1,getNS($ID)); 577 if(count($recents) == 0 && $first != 0){ 578 $first=0; 579 $recents = getRecents($first,$conf['recent'] + 1,getNS($ID)); 580 } 581 $hasNext = false; 582 if (count($recents)>$conf['recent']) { 583 $hasNext = true; 584 array_pop($recents); // remove extra log entry 585 } 586 587 print p_locale_xhtml('recent'); 588 589 if (getNS($ID) != '') 590 print '<div class="level1"><p>' . sprintf($lang['recent_global'], getNS($ID), wl('', 'do=recent')) . '</p></div>'; 591 592 $form = new Doku_Form('dw__recent', script(), 'get'); 593 $form->addHidden('sectok', null); 594 $form->addHidden('do', 'recent'); 595 $form->addHidden('id', $ID); 596 $form->addElement(form_makeOpenTag('ul')); 597 598 foreach($recents as $recent){ 599 $date = strftime($conf['dformat'],$recent['date']); 600 if ($recent['type']===DOKU_CHANGE_TYPE_MINOR_EDIT) 601 $form->addElement(form_makeOpenTag('li', array('class' => 'minor'))); 602 else 603 $form->addElement(form_makeOpenTag('li')); 604 605 $form->addElement(form_makeOpenTag('div', array('class' => 'li'))); 606 607 $form->addElement(form_makeOpenTag('span', array('class' => 'date'))); 608 $form->addElement($date); 609 $form->addElement(form_makeCloseTag('span')); 610 611 $form->addElement(form_makeOpenTag('a', array('class' => 'diff_link', 'href' => wl($recent['id'],"do=diff", false, '&')))); 612 $form->addElement(form_makeTag('img', array( 613 'src' => DOKU_BASE.'lib/images/diff.png', 614 'width' => 15, 615 'height'=> 11, 616 'title' => $lang['diff'], 617 'alt' => $lang['diff'] 618 ))); 619 $form->addElement(form_makeCloseTag('a')); 620 621 $form->addElement(form_makeOpenTag('a', array('class' => 'revisions_link', 'href' => wl($recent['id'],"do=revisions",false,'&')))); 622 $form->addElement(form_makeTag('img', array( 623 'src' => DOKU_BASE.'lib/images/history.png', 624 'width' => 12, 625 'height'=> 14, 626 'title' => $lang['btn_revs'], 627 'alt' => $lang['btn_revs'] 628 ))); 629 $form->addElement(form_makeCloseTag('a')); 630 631 $form->addElement(html_wikilink(':'.$recent['id'],useHeading('navigation')?NULL:$recent['id'])); 632 633 $form->addElement(form_makeOpenTag('span', array('class' => 'sum'))); 634 $form->addElement(' – '.htmlspecialchars($recent['sum'])); 635 $form->addElement(form_makeCloseTag('span')); 636 637 $form->addElement(form_makeOpenTag('span', array('class' => 'user'))); 638 if($recent['user']){ 639 $form->addElement(editorinfo($recent['user'])); 640 if(auth_ismanager()){ 641 $form->addElement(' ('.$recent['ip'].')'); 642 } 643 }else{ 644 $form->addElement($recent['ip']); 645 } 646 $form->addElement(form_makeCloseTag('span')); 647 648 $form->addElement(form_makeCloseTag('div')); 649 $form->addElement(form_makeCloseTag('li')); 650 } 651 $form->addElement(form_makeCloseTag('ul')); 652 653 $form->addElement(form_makeOpenTag('div', array('class' => 'pagenav'))); 654 $last = $first + $conf['recent']; 655 if ($first > 0) { 656 $first -= $conf['recent']; 657 if ($first < 0) $first = 0; 658 $form->addElement(form_makeOpenTag('div', array('class' => 'pagenav-prev'))); 659 $form->addElement(form_makeTag('input', array( 660 'type' => 'submit', 661 'name' => 'first['.$first.']', 662 'value' => $lang['btn_newer'], 663 'accesskey' => 'n', 664 'title' => $lang['btn_newer'].' [N]', 665 'class' => 'button' 666 ))); 667 $form->addElement(form_makeCloseTag('div')); 668 } 669 if ($hasNext) { 670 $form->addElement(form_makeOpenTag('div', array('class' => 'pagenav-next'))); 671 $form->addElement(form_makeTag('input', array( 672 'type' => 'submit', 673 'name' => 'first['.$last.']', 674 'value' => $lang['btn_older'], 675 'accesskey' => 'p', 676 'title' => $lang['btn_older'].' [P]', 677 'class' => 'button' 678 ))); 679 $form->addElement(form_makeCloseTag('div')); 680 } 681 $form->addElement(form_makeCloseTag('div')); 682 html_form('recent', $form); 683} 684 685/** 686 * Display page index 687 * 688 * @author Andreas Gohr <andi@splitbrain.org> 689 */ 690function html_index($ns){ 691 require_once(DOKU_INC.'inc/search.php'); 692 global $conf; 693 global $ID; 694 $dir = $conf['datadir']; 695 $ns = cleanID($ns); 696 #fixme use appropriate function 697 if(empty($ns)){ 698 $ns = dirname(str_replace(':','/',$ID)); 699 if($ns == '.') $ns =''; 700 } 701 $ns = utf8_encodeFN(str_replace(':','/',$ns)); 702 703 echo p_locale_xhtml('index'); 704 echo '<div id="index__tree">'; 705 706 $data = array(); 707 search($data,$conf['datadir'],'search_index',array('ns' => $ns)); 708 echo html_buildlist($data,'idx','html_list_index','html_li_index'); 709 710 echo '</div>'; 711} 712 713/** 714 * Index item formatter 715 * 716 * User function for html_buildlist() 717 * 718 * @author Andreas Gohr <andi@splitbrain.org> 719 */ 720function html_list_index($item){ 721 global $ID; 722 $ret = ''; 723 $base = ':'.$item['id']; 724 $base = substr($base,strrpos($base,':')+1); 725 if($item['type']=='d'){ 726 $ret .= '<a href="'.wl($ID,'idx='.rawurlencode($item['id'])).'" class="idx_dir"><strong>'; 727 $ret .= $base; 728 $ret .= '</strong></a>'; 729 }else{ 730 $ret .= html_wikilink(':'.$item['id']); 731 } 732 return $ret; 733} 734 735/** 736 * Index List item 737 * 738 * This user function is used in html_build_lidt to build the 739 * <li> tags for namespaces when displaying the page index 740 * it gives different classes to opened or closed "folders" 741 * 742 * @author Andreas Gohr <andi@splitbrain.org> 743 */ 744function html_li_index($item){ 745 if($item['type'] == "f"){ 746 return '<li class="level'.$item['level'].'">'; 747 }elseif($item['open']){ 748 return '<li class="open">'; 749 }else{ 750 return '<li class="closed">'; 751 } 752} 753 754/** 755 * Default List item 756 * 757 * @author Andreas Gohr <andi@splitbrain.org> 758 */ 759function html_li_default($item){ 760 return '<li class="level'.$item['level'].'">'; 761} 762 763/** 764 * Build an unordered list 765 * 766 * Build an unordered list from the given $data array 767 * Each item in the array has to have a 'level' property 768 * the item itself gets printed by the given $func user 769 * function. The second and optional function is used to 770 * print the <li> tag. Both user function need to accept 771 * a single item. 772 * 773 * Both user functions can be given as array to point to 774 * a member of an object. 775 * 776 * @author Andreas Gohr <andi@splitbrain.org> 777 */ 778function html_buildlist($data,$class,$func,$lifunc='html_li_default'){ 779 $level = 0; 780 $opens = 0; 781 $ret = ''; 782 783 foreach ($data as $item){ 784 785 if( $item['level'] > $level ){ 786 //open new list 787 for($i=0; $i<($item['level'] - $level); $i++){ 788 if ($i) $ret .= "<li class=\"clear\">\n"; 789 $ret .= "\n<ul class=\"$class\">\n"; 790 } 791 }elseif( $item['level'] < $level ){ 792 //close last item 793 $ret .= "</li>\n"; 794 for ($i=0; $i<($level - $item['level']); $i++){ 795 //close higher lists 796 $ret .= "</ul>\n</li>\n"; 797 } 798 }else{ 799 //close last item 800 $ret .= "</li>\n"; 801 } 802 803 //remember current level 804 $level = $item['level']; 805 806 //print item 807 $ret .= call_user_func($lifunc,$item); 808 $ret .= '<div class="li">'; 809 810 $ret .= call_user_func($func,$item); 811 $ret .= '</div>'; 812 } 813 814 //close remaining items and lists 815 for ($i=0; $i < $level; $i++){ 816 $ret .= "</li></ul>\n"; 817 } 818 819 return $ret; 820} 821 822/** 823 * display backlinks 824 * 825 * @author Andreas Gohr <andi@splitbrain.org> 826 * @author Michael Klier <chi@chimeric.de> 827 */ 828function html_backlinks(){ 829 require_once(DOKU_INC.'inc/fulltext.php'); 830 global $ID; 831 global $conf; 832 global $lang; 833 834 print p_locale_xhtml('backlinks'); 835 836 $data = ft_backlinks($ID); 837 838 if(!empty($data)) { 839 print '<ul class="idx">'; 840 foreach($data as $blink){ 841 print '<li><div class="li">'; 842 print html_wikilink(':'.$blink,useHeading('navigation')?NULL:$blink); 843 print '</div></li>'; 844 } 845 print '</ul>'; 846 } else { 847 print '<div class="level1"><p>' . $lang['nothingfound'] . '</p></div>'; 848 } 849} 850 851/** 852 * show diff 853 * 854 * @author Andreas Gohr <andi@splitbrain.org> 855 */ 856function html_diff($text='',$intro=true){ 857 require_once(DOKU_INC.'inc/DifferenceEngine.php'); 858 global $ID; 859 global $REV; 860 global $lang; 861 global $conf; 862 863 // we're trying to be clever here, revisions to compare can be either 864 // given as rev and rev2 parameters, with rev2 being optional. Or in an 865 // array in rev2. 866 $rev1 = $REV; 867 868 if(is_array($_REQUEST['rev2'])){ 869 $rev1 = (int) $_REQUEST['rev2'][0]; 870 $rev2 = (int) $_REQUEST['rev2'][1]; 871 872 if(!$rev1){ 873 $rev1 = $rev2; 874 unset($rev2); 875 } 876 }else{ 877 $rev2 = (int) $_REQUEST['rev2']; 878 } 879 880 if($text){ // compare text to the most current revision 881 $l_rev = ''; 882 $l_text = rawWiki($ID,''); 883 $l_head = '<a class="wikilink1" href="'.wl($ID).'">'. 884 $ID.' '.strftime($conf['dformat'],@filemtime(wikiFN($ID))).'</a> '. 885 $lang['current']; 886 887 $r_rev = ''; 888 $r_text = cleanText($text); 889 $r_head = $lang['yours']; 890 }else{ 891 if($rev1 && $rev2){ // two specific revisions wanted 892 // make sure order is correct (older on the left) 893 if($rev1 < $rev2){ 894 $l_rev = $rev1; 895 $r_rev = $rev2; 896 }else{ 897 $l_rev = $rev2; 898 $r_rev = $rev1; 899 } 900 }elseif($rev1){ // single revision given, compare to current 901 $r_rev = ''; 902 $l_rev = $rev1; 903 }else{ // no revision was given, compare previous to current 904 $r_rev = ''; 905 $revs = getRevisions($ID, 0, 1); 906 $l_rev = $revs[0]; 907 } 908 909 // when both revisions are empty then the page was created just now 910 if(!$l_rev && !$r_rev){ 911 $l_text = ''; 912 }else{ 913 $l_text = rawWiki($ID,$l_rev); 914 } 915 $r_text = rawWiki($ID,$r_rev); 916 917 918 if(!$l_rev){ 919 $l_head = '—'; 920 }else{ 921 $l_head = '<a class="wikilink1" href="'.wl($ID,"rev=$l_rev").'">'. 922 $ID.' '.strftime($conf['dformat'],$l_rev).'</a>'; 923 } 924 925 if($r_rev){ 926 $r_head = '<a class="wikilink1" href="'.wl($ID,"rev=$r_rev").'">'. 927 $ID.' '.strftime($conf['dformat'],$r_rev).'</a>'; 928 }elseif($_rev = @filemtime(wikiFN($ID))){ 929 $r_head = '<a class="wikilink1" href="'.wl($ID).'">'. 930 $ID.' '.strftime($conf['dformat'],$_rev).'</a> '. 931 $lang['current']; 932 }else{ 933 $r_head = '— '.$lang['current']; 934 } 935 } 936 937 $df = new Diff(explode("\n",htmlspecialchars($l_text)), 938 explode("\n",htmlspecialchars($r_text))); 939 940 $tdf = new TableDiffFormatter(); 941 if($intro) print p_locale_xhtml('diff'); 942 ?> 943 <table class="diff"> 944 <tr> 945 <th colspan="2"> 946 <?php echo $l_head?> 947 </th> 948 <th colspan="2"> 949 <?php echo $r_head?> 950 </th> 951 </tr> 952 <?php echo $tdf->format($df)?> 953 </table> 954 <?php 955} 956 957/** 958 * show warning on conflict detection 959 * 960 * @author Andreas Gohr <andi@splitbrain.org> 961 */ 962function html_conflict($text,$summary){ 963 global $ID; 964 global $lang; 965 966 print p_locale_xhtml('conflict'); 967 $form = new Doku_Form('dw__editform'); 968 $form->addHidden('id', $ID); 969 $form->addHidden('wikitext', $text); 970 $form->addHidden('summary', $summary); 971 $form->addElement(form_makeButton('submit', 'save', $lang['btn_save'], array('accesskey'=>'s'))); 972 $form->addElement(form_makeButton('submit', 'cancel', $lang['btn_cancel'])); 973 html_form('conflict', $form); 974 print '<br /><br /><br /><br />'.NL; 975} 976 977/** 978 * Prints the global message array 979 * 980 * @author Andreas Gohr <andi@splitbrain.org> 981 */ 982function html_msgarea(){ 983 global $MSG; 984 985 if(!isset($MSG)) return; 986 987 foreach($MSG as $msg){ 988 print '<div class="'.$msg['lvl'].'">'; 989 print $msg['msg']; 990 print '</div>'; 991 } 992} 993 994/** 995 * Prints the registration form 996 * 997 * @author Andreas Gohr <andi@splitbrain.org> 998 */ 999function html_register(){ 1000 global $lang; 1001 global $conf; 1002 global $ID; 1003 1004 print p_locale_xhtml('register'); 1005 print '<div class="centeralign">'.NL; 1006 $form = new Doku_Form('dw__register', wl($ID)); 1007 $form->startFieldset($lang['register']); 1008 $form->addHidden('do', 'register'); 1009 $form->addHidden('save', '1'); 1010 $form->addElement(form_makeTextField('login', $_POST['login'], $lang['user'], null, 'block', array('size'=>'50'))); 1011 if (!$conf['autopasswd']) { 1012 $form->addElement(form_makePasswordField('pass', $lang['pass'], '', 'block', array('size'=>'50'))); 1013 $form->addElement(form_makePasswordField('passchk', $lang['passchk'], '', 'block', array('size'=>'50'))); 1014 } 1015 $form->addElement(form_makeTextField('fullname', $_POST['fullname'], $lang['fullname'], '', 'block', array('size'=>'50'))); 1016 $form->addElement(form_makeTextField('email', $_POST['email'], $lang['email'], '', 'block', array('size'=>'50'))); 1017 $form->addElement(form_makeButton('submit', '', $lang['register'])); 1018 $form->endFieldset(); 1019 html_form('register', $form); 1020 1021 print '</div>'.NL; 1022} 1023 1024/** 1025 * Print the update profile form 1026 * 1027 * @author Christopher Smith <chris@jalakai.co.uk> 1028 * @author Andreas Gohr <andi@splitbrain.org> 1029 */ 1030function html_updateprofile(){ 1031 global $lang; 1032 global $conf; 1033 global $ID; 1034 global $INFO; 1035 global $auth; 1036 1037 print p_locale_xhtml('updateprofile'); 1038 1039 if (empty($_POST['fullname'])) $_POST['fullname'] = $INFO['userinfo']['name']; 1040 if (empty($_POST['email'])) $_POST['email'] = $INFO['userinfo']['mail']; 1041 print '<div class="centeralign">'.NL; 1042 $form = new Doku_Form('dw__register', wl($ID)); 1043 $form->startFieldset($lang['profile']); 1044 $form->addHidden('do', 'profile'); 1045 $form->addHidden('save', '1'); 1046 $form->addElement(form_makeTextField('fullname', $_SERVER['REMOTE_USER'], $lang['user'], '', 'block', array('size'=>'50', 'disabled'=>'disabled'))); 1047 $attr = array('size'=>'50'); 1048 if (!$auth->canDo('modName')) $attr['disabled'] = 'disabled'; 1049 $form->addElement(form_makeTextField('fullname', $_POST['fullname'], $lang['fullname'], '', 'block', $attr)); 1050 $attr = array('size'=>'50'); 1051 if (!$auth->canDo('modMail')) $attr['disabled'] = 'disabled'; 1052 $form->addElement(form_makeTextField('email', $_POST['email'], $lang['email'], '', 'block', $attr)); 1053 $form->addElement(form_makeTag('br')); 1054 if ($auth->canDo('modPass')) { 1055 $form->addElement(form_makePasswordField('newpass', $lang['newpass'], '', 'block', array('size'=>'50'))); 1056 $form->addElement(form_makePasswordField('passchk', $lang['passchk'], '', 'block', array('size'=>'50'))); 1057 } 1058 if ($conf['profileconfirm']) { 1059 $form->addElement(form_makeTag('br')); 1060 $form->addElement(form_makePasswordField('oldpass', $lang['oldpass'], '', 'block', array('size'=>'50'))); 1061 } 1062 $form->addElement(form_makeButton('submit', '', $lang['btn_save'])); 1063 $form->addElement(form_makeButton('reset', '', $lang['btn_reset'])); 1064 $form->endFieldset(); 1065 html_form('updateprofile', $form); 1066 print '</div>'.NL; 1067} 1068 1069/** 1070 * This displays the edit form (lots of logic included) 1071 * 1072 * @fixme this is a huge lump of code and should be modularized 1073 * @triggers HTML_PAGE_FROMTEMPLATE 1074 * @triggers HTML_EDITFORM_INJECTION 1075 * @author Andreas Gohr <andi@splitbrain.org> 1076 */ 1077function html_edit($text=null,$include='edit'){ //FIXME: include needed? 1078 global $ID; 1079 global $REV; 1080 global $DATE; 1081 global $RANGE; 1082 global $PRE; 1083 global $SUF; 1084 global $INFO; 1085 global $SUM; 1086 global $lang; 1087 global $conf; 1088 global $license; 1089 1090 //set summary default 1091 if(!$SUM){ 1092 if($REV){ 1093 $SUM = $lang['restored']; 1094 }elseif(!$INFO['exists']){ 1095 $SUM = $lang['created']; 1096 } 1097 } 1098 1099 //no text? Load it! 1100 if(!isset($text)){ 1101 $pr = false; //no preview mode 1102 if($INFO['exists']){ 1103 if($RANGE){ 1104 list($PRE,$text,$SUF) = rawWikiSlices($RANGE,$ID,$REV); 1105 }else{ 1106 $text = rawWiki($ID,$REV); 1107 } 1108 $check = md5($text); 1109 $mod = false; 1110 }else{ 1111 //try to load a pagetemplate 1112 $data = array($ID); 1113 $text = trigger_event('HTML_PAGE_FROMTEMPLATE',$data,'pageTemplate',true); 1114 $check = md5(''); 1115 $mod = $text!==''; 1116 } 1117 }else{ 1118 $pr = true; //preview mode 1119 if (isset($_REQUEST['changecheck'])) { 1120 $check = $_REQUEST['changecheck']; 1121 $mod = md5($text)!==$check; 1122 } else { 1123 // Why? Assume default text is unmodified. 1124 $check = md5($text); 1125 $mod = false; 1126 } 1127 } 1128 1129 $wr = $INFO['writable'] && !$INFO['locked']; 1130 if($wr){ 1131 if ($REV) print p_locale_xhtml('editrev'); 1132 print p_locale_xhtml($include); 1133 }else{ 1134 // check pseudo action 'source' 1135 if(!actionOK('source')){ 1136 msg('Command disabled: source',-1); 1137 return; 1138 } 1139 print p_locale_xhtml('read'); 1140 } 1141 if(!$DATE) $DATE = $INFO['lastmod']; 1142 1143 1144?> 1145 <div style="width:99%;"> 1146 1147 <div class="toolbar"> 1148 <div id="draft__status"><?php if(!empty($INFO['draft'])) echo $lang['draftdate'].' '.strftime($conf['dformat']);?></div> 1149 <div id="tool__bar"><?php if($wr){?><a href="<?php echo DOKU_BASE?>lib/exe/mediamanager.php?ns=<?php echo $INFO['namespace']?>" 1150 target="_blank"><?php echo $lang['mediaselect'] ?></a><?php }?></div> 1151 1152 <?php if($wr){?> 1153 <script type="text/javascript" charset="utf-8"><!--//--><![CDATA[//><!-- 1154 <?php /* sets changed to true when previewed */?> 1155 textChanged = <?php ($mod) ? print 'true' : print 'false' ?>; 1156 //--><!]]></script> 1157 <span id="spell__action"></span> 1158 <div id="spell__suggest"></div> 1159 <?php } ?> 1160 </div> 1161 <div id="spell__result"></div> 1162<?php 1163 $form = new Doku_Form('dw__editform'); 1164 $form->addHidden('id', $ID); 1165 $form->addHidden('rev', $REV); 1166 $form->addHidden('date', $DATE); 1167 $form->addHidden('prefix', $PRE); 1168 $form->addHidden('suffix', $SUF); 1169 $form->addHidden('changecheck', $check); 1170 $attr = array('tabindex'=>'1'); 1171 if (!$wr) $attr['readonly'] = 'readonly'; 1172 $form->addElement(form_makeWikiText($text, $attr)); 1173 $form->addElement(form_makeOpenTag('div', array('id'=>'wiki__editbar'))); 1174 $form->addElement(form_makeOpenTag('div', array('id'=>'size__ctl'))); 1175 $form->addElement(form_makeCloseTag('div')); 1176 if ($wr) { 1177 $form->addElement(form_makeOpenTag('div', array('class'=>'editButtons'))); 1178 $form->addElement(form_makeButton('submit', 'save', $lang['btn_save'], array('id'=>'edbtn__save', 'accesskey'=>'s', 'tabindex'=>'4'))); 1179 $form->addElement(form_makeButton('submit', 'preview', $lang['btn_preview'], array('id'=>'edbtn__preview', 'accesskey'=>'p', 'tabindex'=>'5'))); 1180 $form->addElement(form_makeButton('submit', 'draftdel', $lang['btn_cancel'], array('tabindex'=>'6'))); 1181 $form->addElement(form_makeCloseTag('div')); 1182 $form->addElement(form_makeOpenTag('div', array('class'=>'summary'))); 1183 $form->addElement(form_makeTextField('summary', $SUM, $lang['summary'], 'edit__summary', 'nowrap', array('size'=>'50', 'tabindex'=>'2'))); 1184 $elem = html_minoredit(); 1185 if ($elem) $form->addElement($elem); 1186 $form->addElement(form_makeCloseTag('div')); 1187 } 1188 $form->addElement(form_makeCloseTag('div')); 1189 if($conf['license']){ 1190 $form->addElement(form_makeOpenTag('div', array('class'=>'license'))); 1191 $out = $lang['licenseok']; 1192 $out .= '<a href="'.$license[$conf['license']]['url'].'" rel="license" class="urlextern"'; 1193 if($conf['target']['external']) $out .= ' target="'.$conf['target']['external'].'"'; 1194 $out .= '> '.$license[$conf['license']]['name'].'</a>'; 1195 $form->addElement($out); 1196 $form->addElement(form_makeCloseTag('div')); 1197 } 1198 html_form('edit', $form); 1199 print '</div>'.NL; 1200} 1201 1202/** 1203 * Adds a checkbox for minor edits for logged in users 1204 * 1205 * @author Andrea Gohr <andi@splitbrain.org> 1206 */ 1207function html_minoredit(){ 1208 global $conf; 1209 global $lang; 1210 // minor edits are for logged in users only 1211 if(!$conf['useacl'] || !$_SERVER['REMOTE_USER']){ 1212 return false; 1213 } 1214 1215 $p = array(); 1216 $p['tabindex'] = 3; 1217 if(!empty($_REQUEST['minor'])) $p['checked']='checked'; 1218 return form_makeCheckboxField('minor', '1', $lang['minoredit'], 'minoredit', 'nowrap', $p); 1219} 1220 1221/** 1222 * prints some debug info 1223 * 1224 * @author Andreas Gohr <andi@splitbrain.org> 1225 */ 1226function html_debug(){ 1227 global $conf; 1228 global $lang; 1229 global $auth; 1230 global $INFO; 1231 1232 //remove sensitive data 1233 $cnf = $conf; 1234 debug_guard($cnf); 1235 $nfo = $INFO; 1236 debug_guard($nfo); 1237 $ses = $_SESSION; 1238 debug_guard($ses); 1239 1240 print '<html><body>'; 1241 1242 print '<p>When reporting bugs please send all the following '; 1243 print 'output as a mail to andi@splitbrain.org '; 1244 print 'The best way to do this is to save this page in your browser</p>'; 1245 1246 print '<b>$INFO:</b><pre>'; 1247 print_r($nfo); 1248 print '</pre>'; 1249 1250 print '<b>$_SERVER:</b><pre>'; 1251 print_r($_SERVER); 1252 print '</pre>'; 1253 1254 print '<b>$conf:</b><pre>'; 1255 print_r($cnf); 1256 print '</pre>'; 1257 1258 print '<b>DOKU_BASE:</b><pre>'; 1259 print DOKU_BASE; 1260 print '</pre>'; 1261 1262 print '<b>abs DOKU_BASE:</b><pre>'; 1263 print DOKU_URL; 1264 print '</pre>'; 1265 1266 print '<b>rel DOKU_BASE:</b><pre>'; 1267 print dirname($_SERVER['PHP_SELF']).'/'; 1268 print '</pre>'; 1269 1270 print '<b>PHP Version:</b><pre>'; 1271 print phpversion(); 1272 print '</pre>'; 1273 1274 print '<b>locale:</b><pre>'; 1275 print setlocale(LC_ALL,0); 1276 print '</pre>'; 1277 1278 print '<b>encoding:</b><pre>'; 1279 print $lang['encoding']; 1280 print '</pre>'; 1281 1282 if($auth){ 1283 print '<b>Auth backend capabilities:</b><pre>'; 1284 print_r($auth->cando); 1285 print '</pre>'; 1286 } 1287 1288 print '<b>$_SESSION:</b><pre>'; 1289 print_r($ses); 1290 print '</pre>'; 1291 1292 print '<b>Environment:</b><pre>'; 1293 print_r($_ENV); 1294 print '</pre>'; 1295 1296 print '<b>PHP settings:</b><pre>'; 1297 $inis = ini_get_all(); 1298 print_r($inis); 1299 print '</pre>'; 1300 1301 print '</body></html>'; 1302} 1303 1304function html_admin(){ 1305 global $ID; 1306 global $INFO; 1307 global $lang; 1308 global $conf; 1309 1310 print p_locale_xhtml('admin'); 1311 1312 // build menu of admin functions from the plugins that handle them 1313 $pluginlist = plugin_list('admin'); 1314 $menu = array(); 1315 foreach ($pluginlist as $p) { 1316 if($obj =& plugin_load('admin',$p) === NULL) continue; 1317 1318 // check permissions 1319 if($obj->forAdminOnly() && !$INFO['isadmin']) continue; 1320 1321 $menu[] = array('plugin' => $p, 1322 'prompt' => $obj->getMenuText($conf['lang']), 1323 'sort' => $obj->getMenuSort() 1324 ); 1325 } 1326 1327 usort($menu, 'p_sort_modes'); 1328 1329 // output the menu 1330 ptln('<ul>'); 1331 1332 foreach ($menu as $item) { 1333 if (!$item['prompt']) continue; 1334 ptln(' <li><div class="li"><a href="'.wl($ID, 'do=admin&page='.$item['plugin']).'">'.$item['prompt'].'</a></div></li>'); 1335 } 1336 1337 ptln('</ul>'); 1338} 1339 1340/** 1341 * Form to request a new password for an existing account 1342 * 1343 * @author Benoit Chesneau <benoit@bchesneau.info> 1344 */ 1345function html_resendpwd() { 1346 global $lang; 1347 global $conf; 1348 global $ID; 1349 1350 print p_locale_xhtml('resendpwd'); 1351 print '<div class="centeralign">'.NL; 1352 $form = new Doku_Form('dw__resendpwd', wl($ID)); 1353 $form->startFieldset($lang['resendpwd']); 1354 $form->addHidden('do', 'resendpwd'); 1355 $form->addHidden('save', '1'); 1356 $form->addElement(form_makeTag('br')); 1357 $form->addElement(form_makeTextField('login', $_POST['login'], $lang['user'], '', 'block')); 1358 $form->addElement(form_makeTag('br')); 1359 $form->addElement(form_makeTag('br')); 1360 $form->addElement(form_makeButton('submit', '', $lang['btn_resendpwd'])); 1361 $form->endFieldset(); 1362 html_form('resendpwd', $form); 1363 print '</div>'.NL; 1364} 1365 1366/** 1367 * Return the TOC rendered to XHTML 1368 * 1369 * @author Andreas Gohr <andi@splitbrain.org> 1370 */ 1371function html_TOC($toc){ 1372 if(!count($toc)) return ''; 1373 global $lang; 1374 $out = '<!-- TOC START -->'.DOKU_LF; 1375 $out .= '<div class="toc">'.DOKU_LF; 1376 $out .= '<div class="tocheader toctoggle" id="toc__header">'; 1377 $out .= $lang['toc']; 1378 $out .= '</div>'.DOKU_LF; 1379 $out .= '<div id="toc__inside">'.DOKU_LF; 1380 $out .= html_buildlist($toc,'toc','html_list_toc'); 1381 $out .= '</div>'.DOKU_LF.'</div>'.DOKU_LF; 1382 $out .= '<!-- TOC END -->'.DOKU_LF; 1383 return $out; } 1384 1385/** 1386 * Callback for html_buildlist 1387 */ 1388function html_list_toc($item){ 1389 if($item['hid']){ 1390 $link = '#'.$item['hid']; 1391 }else{ 1392 $link = $item['link']; 1393 } 1394 1395 return '<span class="li"><a href="'.$link.'" class="toc">'. 1396 hsc($item['title']).'</a></span>'; 1397} 1398 1399/** 1400 * Helper function to build TOC items 1401 * 1402 * Returns an array ready to be added to a TOC array 1403 * 1404 * @param string $link - where to link (if $hash set to '#' it's a local anchor) 1405 * @param string $text - what to display in the TOC 1406 * @param int $level - nesting level 1407 * @param string $hash - is prepended to the given $link, set blank if you want full links 1408 */ 1409function html_mktocitem($link, $text, $level, $hash='#'){ 1410 global $conf; 1411 return array( 'link' => $hash.$link, 1412 'title' => $text, 1413 'type' => 'ul', 1414 'level' => $level); 1415} 1416 1417/** 1418 * Output a Doku_Form object. 1419 * Triggers an event with the form name: HTML_{$name}FORM_OUTPUT 1420 * 1421 * @author Tom N Harris <tnharris@whoopdedo.org> 1422 */ 1423function html_form($name, &$form) { 1424 // Safety check in case the caller forgets. 1425 $form->endFieldset(); 1426 trigger_event('HTML_'.strtoupper($name).'FORM_OUTPUT', $form, 'html_form_output', false); 1427} 1428 1429/** 1430 * Form print function. 1431 * Just calls printForm() on the data object. 1432 */ 1433function html_form_output($data) { 1434 $data->printForm(); 1435} 1436 1437/** 1438 * Embed a flash object in HTML 1439 * 1440 * This will create the needed HTML to embed a flash movie in a cross browser 1441 * compatble way using valid XHTML 1442 * 1443 * The parameters $params, $flashvars and $atts need to be associative arrays. 1444 * No escaping needs to be done for them. The alternative content *has* to be 1445 * escaped because it is used as is. If no alternative content is given 1446 * $lang['noflash'] is used. 1447 * 1448 * @author Andreas Gohr <andi@splitbrain.org> 1449 * @link http://latrine.dgx.cz/how-to-correctly-insert-a-flash-into-xhtml 1450 * 1451 * @param string $swf - the SWF movie to embed 1452 * @param int $width - width of the flash movie in pixels 1453 * @param int $height - height of the flash movie in pixels 1454 * @param array $params - additional parameters (<param>) 1455 * @param array $flashvars - parameters to be passed in the flashvar parameter 1456 * @param array $atts - additional attributes for the <object> tag 1457 * @param string $alt - alternative content (is NOT automatically escaped!) 1458 * @returns string - the XHTML markup 1459 */ 1460function html_flashobject($swf,$width,$height,$params=null,$flashvars=null,$atts=null,$alt=''){ 1461 global $lang; 1462 1463 $out = ''; 1464 1465 // prepare the object attributes 1466 if(is_null($atts)) $atts = array(); 1467 $atts['width'] = (int) $width; 1468 $atts['height'] = (int) $height; 1469 if(!$atts['width']) $atts['width'] = 425; 1470 if(!$atts['height']) $atts['height'] = 350; 1471 1472 // add object attributes for standard compliant browsers 1473 $std = $atts; 1474 $std['type'] = 'application/x-shockwave-flash'; 1475 $std['data'] = $swf; 1476 1477 // add object attributes for IE 1478 $ie = $atts; 1479 $ie['classid'] = 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'; 1480 1481 // open object (with conditional comments) 1482 $out .= '<!--[if !IE]> -->'.NL; 1483 $out .= '<object '.buildAttributes($std).'>'.NL; 1484 $out .= '<!-- <![endif]-->'.NL; 1485 $out .= '<!--[if IE]>'.NL; 1486 $out .= '<object '.buildAttributes($ie).'>'.NL; 1487 $out .= ' <param name="movie" value="'.hsc($swf).'" />'.NL; 1488 $out .= '<!--><!-- -->'.NL; 1489 1490 // print params 1491 if(is_array($params)) foreach($params as $key => $val){ 1492 $out .= ' <param name="'.hsc($key).'" value="'.hsc($val).'" />'.NL; 1493 } 1494 1495 // add flashvars 1496 if(is_array($flashvars)){ 1497 $out .= ' <param name="FlashVars" value="'.buildURLparams($flashvars).'" />'.NL; 1498 } 1499 1500 // alternative content 1501 if($alt){ 1502 $out .= $alt.NL; 1503 }else{ 1504 $out .= $lang['noflash'].NL; 1505 } 1506 1507 // finish 1508 $out .= '</object>'.NL; 1509 $out .= '<!-- <![endif]-->'.NL; 1510 1511 return $out; 1512} 1513 1514//Setup VIM: ex: et ts=2 enc=utf-8 : 1515