1ed7b5f09Sandi<?php 215fae107Sandi/** 315fae107Sandi * HTML output functions 415fae107Sandi * 515fae107Sandi * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 615fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 715fae107Sandi */ 815fae107Sandi 9ed7b5f09Sandi if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../').'/'); 10f3f0262cSandi 116bbae538Sandi require_once(DOKU_INC.'inc/parserutils.php'); 126bbae538Sandi 13f3f0262cSandi/** 14f3f0262cSandi * Convenience function to quickly build a wikilink 1515fae107Sandi * 1615fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 17f3f0262cSandi */ 1830f1737dSandifunction html_wikilink($id,$name=NULL,$search=''){ 19723d78dbSandi static $xhtml_renderer = NULL; 20723d78dbSandi if(is_null($xhtml_renderer)){ 21fdf3dcb9SMatthias Urlichs require_once(DOKU_INC.'inc/parser/xhtml.php'); 22723d78dbSandi $xhtml_renderer = new Doku_Renderer_xhtml(); 23f3f0262cSandi } 24f3f0262cSandi 25cffcc403Sandi return $xhtml_renderer->internallink($id,$name,$search,true); 26f3f0262cSandi} 27f3f0262cSandi 28f3f0262cSandi/** 29c19fe9c0Sandi * Helps building long attribute lists 30c19fe9c0Sandi * 31c19fe9c0Sandi * @author Andreas Gohr <andi@splitbrain.org> 32c19fe9c0Sandi */ 33c19fe9c0Sandifunction html_attbuild($attributes){ 34c19fe9c0Sandi $ret = ''; 35c19fe9c0Sandi foreach ( $attributes as $key => $value ) { 36c19fe9c0Sandi $ret .= $key.'="'.formtext($value).'" '; 37c19fe9c0Sandi } 38c19fe9c0Sandi return trim($ret); 39c19fe9c0Sandi} 40c19fe9c0Sandi 41c19fe9c0Sandi/** 42f3f0262cSandi * The loginform 4315fae107Sandi * 4415fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 45f3f0262cSandi */ 46f3f0262cSandifunction html_login(){ 47f3f0262cSandi global $lang; 48f3f0262cSandi global $conf; 49f3f0262cSandi global $ID; 50cd52f92dSchris global $auth; 51f3f0262cSandi 52c112d578Sandi print p_locale_xhtml('login'); 53f3f0262cSandi ?> 5496331712SAnika Henke <div class="centeralign"> 554da078a3Smatthiasgrimm <form action="<?php echo script()?>" accept-charset="<?php echo $lang['encoding']?>" method="post"> 56f3f0262cSandi <fieldset> 574da078a3Smatthiasgrimm <legend><?php echo $lang['btn_login']?></legend> 584da078a3Smatthiasgrimm <input type="hidden" name="id" value="<?php echo $ID?>" /> 59f3f0262cSandi <input type="hidden" name="do" value="login" /> 60b6912aeaSAndreas Gohr <label class="block"> 614da078a3Smatthiasgrimm <span><?php echo $lang['user']?></span> 624da078a3Smatthiasgrimm <input type="text" name="u" value="<?php echo formText($_REQUEST['u'])?>" class="edit" /> 63f3f0262cSandi </label><br /> 64b6912aeaSAndreas Gohr <label class="block"> 654da078a3Smatthiasgrimm <span><?php echo $lang['pass']?></span> 66f3f0262cSandi <input type="password" name="p" class="edit" /> 67f3f0262cSandi </label><br /> 684da078a3Smatthiasgrimm <input type="submit" value="<?php echo $lang['btn_login']?>" class="button" /> 690c1887a0SAndreas Gohr <label for="remember__me" class="simple"> 704d6f545eSAndreas Gohr <input type="checkbox" name="r" id="remember__me" value="1" /> 714da078a3Smatthiasgrimm <span><?php echo $lang['remember']?></span> 72132bdbfeSandi </label> 73f3f0262cSandi </fieldset> 74f3f0262cSandi </form> 754da078a3Smatthiasgrimm <?php 7682fd59b6SAndreas Gohr if($auth->canDo('addUser') && $conf['openregister']){ 77f3f0262cSandi print '<p>'; 78f3f0262cSandi print $lang['reghere']; 79f3f0262cSandi print ': <a href="'.wl($ID,'do=register').'" class="wikilink1">'.$lang['register'].'</a>'; 80f3f0262cSandi print '</p>'; 81f3f0262cSandi } 828b06d178Schris 8382fd59b6SAndreas Gohr if ($auth->canDo('modPass') && $conf['resendpasswd']) { 848b06d178Schris print '<p>'; 858b06d178Schris print $lang['pwdforget']; 86753d5abfSMatthias Grimm print ': <a href="'.wl($ID,'do=resendpwd').'" class="wikilink1">'.$lang['btn_resendpwd'].'</a>'; 878b06d178Schris print '</p>'; 888b06d178Schris } 89f3f0262cSandi ?> 90f3f0262cSandi </div> 914da078a3Smatthiasgrimm <?php 926bbae538Sandi/* 936bbae538Sandi FIXME provide new hook 94f3f0262cSandi if(@file_exists('includes/login.txt')){ 95f3f0262cSandi print io_cacheParse('includes/login.txt'); 96f3f0262cSandi } 976bbae538Sandi*/ 98f3f0262cSandi} 99f3f0262cSandi 100f3f0262cSandi/** 101ee4c4a1bSAndreas Gohr * shows the edit/source/show/draft button dependent on current mode 10215fae107Sandi * 10315fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 104f3f0262cSandi */ 105f3f0262cSandifunction html_editbutton(){ 106f3f0262cSandi global $ID; 107f3f0262cSandi global $REV; 108f3f0262cSandi global $ACT; 109f3f0262cSandi global $INFO; 110f3f0262cSandi 111f3f0262cSandi if($ACT == 'show' || $ACT == 'search'){ 112f3f0262cSandi if($INFO['writable']){ 113ee4c4a1bSAndreas Gohr if($INFO['draft']){ 114ee4c4a1bSAndreas Gohr $r = html_btn('draft',$ID,'e',array('do' => 'draft'),'post'); 115ee4c4a1bSAndreas Gohr }else{ 116f3f0262cSandi if($INFO['exists']){ 117f3f0262cSandi $r = html_btn('edit',$ID,'e',array('do' => 'edit','rev' => $REV),'post'); 118f3f0262cSandi }else{ 119f3f0262cSandi $r = html_btn('create',$ID,'e',array('do' => 'edit','rev' => $REV),'post'); 120f3f0262cSandi } 121ee4c4a1bSAndreas Gohr } 122f3f0262cSandi }else{ 123f3f0262cSandi $r = html_btn('source',$ID,'v',array('do' => 'edit','rev' => $REV),'post'); 124f3f0262cSandi } 125f3f0262cSandi }else{ 126f3f0262cSandi $r = html_btn('show',$ID,'v',array('do' => 'show')); 127f3f0262cSandi } 128f3f0262cSandi return $r; 129f3f0262cSandi} 130f3f0262cSandi 13115fae107Sandi/** 13215fae107Sandi * prints a section editing button 13315fae107Sandi * 13415fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 13515fae107Sandi */ 136f3f0262cSandifunction html_secedit_button($section,$p){ 137f3f0262cSandi global $ID; 138f3f0262cSandi global $lang; 139306b2c85SDenis Simakov global $INFO; 140f3f0262cSandi $secedit = ''; 141506ae684Sandi# if($p) $secedit .= "</p>\n"; 142f3f0262cSandi $secedit .= '<div class="secedit">'; 143f3f0262cSandi $secedit .= html_btn('secedit',$ID,'', 144f3f0262cSandi array('do' => 'edit', 145306b2c85SDenis Simakov 'lines' => "$section", 146306b2c85SDenis Simakov 'rev' => $INFO['lastmod']), 147f3f0262cSandi 'post'); 148f3f0262cSandi $secedit .= '</div>'; 149506ae684Sandi# if($p) $secedit .= "\n<p>"; 150f3f0262cSandi return $secedit; 151f3f0262cSandi} 152f3f0262cSandi 15315fae107Sandi/** 15415fae107Sandi * inserts section edit buttons if wanted or removes the markers 15515fae107Sandi * 15615fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 15715fae107Sandi */ 158f3f0262cSandifunction html_secedit($text,$show=true){ 159f3f0262cSandi global $INFO; 160c112d578Sandi if($INFO['writable'] && $show && !$INFO['rev']){ 161f3f0262cSandi $text = preg_replace('#<!-- SECTION \[(\d+-\d+)\] -->#e', 162f3f0262cSandi "html_secedit_button('\\1',true)", 163f3f0262cSandi $text); 164f3f0262cSandi $text = preg_replace('#<!-- SECTION \[(\d+-)\] -->#e', 165f3f0262cSandi "html_secedit_button('\\1',false)", 166f3f0262cSandi $text); 167f3f0262cSandi }else{ 168f3f0262cSandi $text = preg_replace('#<!-- SECTION \[(\d*-\d*)\] -->#e','',$text); 169f3f0262cSandi } 170f3f0262cSandi return $text; 171f3f0262cSandi} 172f3f0262cSandi 173f3f0262cSandi/** 174d6c9c552Smatthiasgrimm * Just the back to top button (in its own form) 1756b13307fSandi * 1766b13307fSandi * @author Andreas Gohr <andi@splitbrain.org> 1776b13307fSandi */ 1786b13307fSandifunction html_topbtn(){ 1796b13307fSandi global $lang; 1806b13307fSandi 1816b13307fSandi $ret = ''; 1820e99f6d7SBen Coburn $ret = '<a class="nolink" href="#dokuwiki__top"><input type="button" class="button" value="'.$lang['btn_top'].'" onclick="window.scrollTo(0, 0)" /></a>'; 183df7b6005Sandi 1846b13307fSandi return $ret; 1856b13307fSandi} 1866b13307fSandi 1876b13307fSandi/** 188d67ca2c0Smatthiasgrimm * Just the back to media window button in its own form 189d67ca2c0Smatthiasgrimm * 190d67ca2c0Smatthiasgrimm * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net> 191d67ca2c0Smatthiasgrimm */ 192d67ca2c0Smatthiasgrimmfunction html_backtomedia_button($params,$akey=''){ 193d67ca2c0Smatthiasgrimm global $conf; 194d67ca2c0Smatthiasgrimm global $lang; 195d67ca2c0Smatthiasgrimm 1963df72098SAndreas Gohr $ret = '<form class="button" method="get" action="'.DOKU_BASE.'lib/exe/mediamanager.php"><div class="no">'; 197d67ca2c0Smatthiasgrimm 198d67ca2c0Smatthiasgrimm reset($params); 199d67ca2c0Smatthiasgrimm while (list($key, $val) = each($params)) { 200d67ca2c0Smatthiasgrimm $ret .= '<input type="hidden" name="'.$key.'" '; 201d67ca2c0Smatthiasgrimm $ret .= 'value="'.htmlspecialchars($val).'" />'; 202d67ca2c0Smatthiasgrimm } 203d67ca2c0Smatthiasgrimm 204d67ca2c0Smatthiasgrimm $ret .= '<input type="submit" value="'.htmlspecialchars($lang['btn_backtomedia']).'" class="button" '; 205d67ca2c0Smatthiasgrimm if($akey){ 206d67ca2c0Smatthiasgrimm $ret .= 'title="ALT+'.strtoupper($akey).'" '; 207d67ca2c0Smatthiasgrimm $ret .= 'accesskey="'.$akey.'" '; 208d67ca2c0Smatthiasgrimm } 209d67ca2c0Smatthiasgrimm $ret .= '/>'; 2104beabca9SAnika Henke $ret .= '</div></form>'; 211d67ca2c0Smatthiasgrimm 212d67ca2c0Smatthiasgrimm return $ret; 213d67ca2c0Smatthiasgrimm} 214d67ca2c0Smatthiasgrimm 215d67ca2c0Smatthiasgrimm/** 216d67ca2c0Smatthiasgrimm * Displays a button (using its own form) 21715fae107Sandi * 21815fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 219f3f0262cSandi */ 220f3f0262cSandifunction html_btn($name,$id,$akey,$params,$method='get'){ 221f3f0262cSandi global $conf; 222f3f0262cSandi global $lang; 223f3f0262cSandi 224f3f0262cSandi $label = $lang['btn_'.$name]; 225f3f0262cSandi 226f3f0262cSandi $ret = ''; 227f3f0262cSandi 22849c713a3Sandi //filter id (without urlencoding) 22949c713a3Sandi $id = idfilter($id,false); 230f3f0262cSandi 231f3f0262cSandi //make nice URLs even for buttons 2326c7843b5Sandi if($conf['userewrite'] == 2){ 2336c7843b5Sandi $script = DOKU_BASE.DOKU_SCRIPT.'/'.$id; 2346c7843b5Sandi }elseif($conf['userewrite']){ 2356c7843b5Sandi $script = DOKU_BASE.$id; 2366c7843b5Sandi }else{ 2378b00ebcfSandi $script = DOKU_BASE.DOKU_SCRIPT; 238f3f0262cSandi $params['id'] = $id; 239f3f0262cSandi } 240f3f0262cSandi 2414beabca9SAnika Henke $ret .= '<form class="button" method="'.$method.'" action="'.$script.'"><div class="no">'; 242f3f0262cSandi 24306a4bf8fSAndreas Gohr if(is_array($params)){ 244f3f0262cSandi reset($params); 245f3f0262cSandi while (list($key, $val) = each($params)) { 246f3f0262cSandi $ret .= '<input type="hidden" name="'.$key.'" '; 247f3f0262cSandi $ret .= 'value="'.htmlspecialchars($val).'" />'; 248f3f0262cSandi } 24906a4bf8fSAndreas Gohr } 250f3f0262cSandi 251f3f0262cSandi $ret .= '<input type="submit" value="'.htmlspecialchars($label).'" class="button" '; 252f3f0262cSandi if($akey){ 253b1112787SBen Coburn $ret .= 'title="[ALT+'.strtoupper($akey).']" '; 254f3f0262cSandi $ret .= 'accesskey="'.$akey.'" '; 255f3f0262cSandi } 256f3f0262cSandi $ret .= '/>'; 2574beabca9SAnika Henke $ret .= '</div></form>'; 258f3f0262cSandi 259f3f0262cSandi return $ret; 260f3f0262cSandi} 261f3f0262cSandi 262f3f0262cSandi/** 26315fae107Sandi * show a wiki page 26415fae107Sandi * 26515fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 26615fae107Sandi */ 2676bbae538Sandifunction html_show($txt=''){ 268f3f0262cSandi global $ID; 269f3f0262cSandi global $REV; 270f3f0262cSandi global $HIGH; 271f3f0262cSandi //disable section editing for old revisions or in preview 2725400331dSandi if($txt || $REV){ 2736bbae538Sandi $secedit = false; 2746bbae538Sandi }else{ 2756bbae538Sandi $secedit = true; 276f3f0262cSandi } 277f3f0262cSandi 2786bbae538Sandi if ($txt){ 279f3f0262cSandi //PreviewHeader 28050835be7SAndreas Gohr print '<br id="scroll__here" />'; 281c112d578Sandi print p_locale_xhtml('preview'); 282f3f0262cSandi print '<div class="preview">'; 2839dc2c2afSandi print html_secedit(p_render('xhtml',p_get_instructions($txt),$info),$secedit); 28446723c19SAndreas Gohr print '<div class="clearer"></div>'; 285f3f0262cSandi print '</div>'; 2866bbae538Sandi 287f3f0262cSandi }else{ 288c112d578Sandi if ($REV) print p_locale_xhtml('showrev'); 289c112d578Sandi $html = p_wiki_xhtml($ID,$REV,true); 2906bbae538Sandi $html = html_secedit($html,$secedit); 291f3f0262cSandi print html_hilight($html,$HIGH); 292f3f0262cSandi } 293f3f0262cSandi} 294f3f0262cSandi 295f3f0262cSandi/** 296ee4c4a1bSAndreas Gohr * ask the user about how to handle an exisiting draft 297ee4c4a1bSAndreas Gohr * 298ee4c4a1bSAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 299ee4c4a1bSAndreas Gohr */ 300ee4c4a1bSAndreas Gohrfunction html_draft(){ 301ee4c4a1bSAndreas Gohr global $INFO; 302ee4c4a1bSAndreas Gohr global $ID; 303ee4c4a1bSAndreas Gohr global $lang; 304ee4c4a1bSAndreas Gohr global $conf; 305ee4c4a1bSAndreas Gohr $draft = unserialize(io_readFile($INFO['draft'],false)); 306ee4c4a1bSAndreas Gohr $text = cleanText(con($draft['prefix'],$draft['text'],$draft['suffix'],true)); 307ee4c4a1bSAndreas Gohr 308ee4c4a1bSAndreas Gohr echo p_locale_xhtml('draft'); 309ee4c4a1bSAndreas Gohr ?> 310ee4c4a1bSAndreas Gohr <form id="dw__editform" method="post" action="<?php echo script()?>" 311ee4c4a1bSAndreas Gohr accept-charset="<?php echo $lang['encoding']?>"><div class="no"> 312ee4c4a1bSAndreas Gohr <input type="hidden" name="id" value="<?php echo $ID?>" /> 313ee4c4a1bSAndreas Gohr <input type="hidden" name="date" value="<?php echo $draft['date']?>" /></div> 314ee4c4a1bSAndreas Gohr <textarea name="wikitext" id="wiki__text" readonly="readonly" cols="80" rows="10" class="edit"><?php echo "\n".formText($text)?></textarea> 315ee4c4a1bSAndreas Gohr 316ee4c4a1bSAndreas Gohr <div id="draft__status"><?php echo $lang['draftdate'].' '.date($conf['dformat'],filemtime($INFO['draft']))?></div> 317ee4c4a1bSAndreas Gohr 318ee4c4a1bSAndreas Gohr <input class="button" type="submit" name="do" value="<?php echo $lang['btn_recover']?>" tabindex="1" /> 319ee4c4a1bSAndreas Gohr <input class="button" type="submit" name="do" value="<?php echo $lang['btn_draftdel']?>" tabindex="2" /> 320ee4c4a1bSAndreas Gohr <input class="button" type="submit" name="do" value="<?php echo $lang['btn_cancel']?>" tabindex="3" /> 321ee4c4a1bSAndreas Gohr </form> 322ee4c4a1bSAndreas Gohr <?php 323ee4c4a1bSAndreas Gohr} 324ee4c4a1bSAndreas Gohr 325ee4c4a1bSAndreas Gohr/** 326f3f0262cSandi * Highlights searchqueries in HTML code 32715fae107Sandi * 32815fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 3297209be23SAndreas Gohr * @author Harry Fuecks <hfuecks@gmail.com> 330f3f0262cSandi */ 331f3f0262cSandifunction html_hilight($html,$query){ 3327209be23SAndreas Gohr //split at common delimiters 3339d9c165eSAndreas Gohr $queries = preg_split ('/[\s\'"\\\\`()\]\[?:!\.{};,#+*<>\\/]+/',$query,-1,PREG_SPLIT_NO_EMPTY); 334f3f0262cSandi foreach ($queries as $q){ 335f3f0262cSandi $q = preg_quote($q,'/'); 3367209be23SAndreas Gohr $html = preg_replace_callback("/((<[^>]*)|$q)/i",'html_hilight_callback',$html); 337f3f0262cSandi } 338f3f0262cSandi return $html; 339f3f0262cSandi} 340f3f0262cSandi 341f3f0262cSandi/** 3427209be23SAndreas Gohr * Callback used by html_hilight() 3437209be23SAndreas Gohr * 3447209be23SAndreas Gohr * @author Harry Fuecks <hfuecks@gmail.com> 3457209be23SAndreas Gohr */ 3467209be23SAndreas Gohrfunction html_hilight_callback($m) { 3477209be23SAndreas Gohr $hlight = unslash($m[0]); 3487209be23SAndreas Gohr if ( !isset($m[2])) { 3497209be23SAndreas Gohr $hlight = '<span class="search_hit">'.$hlight.'</span>'; 3507209be23SAndreas Gohr } 3517209be23SAndreas Gohr return $hlight; 3527209be23SAndreas Gohr} 3537209be23SAndreas Gohr 3547209be23SAndreas Gohr/** 35515fae107Sandi * Run a search and display the result 35615fae107Sandi * 35715fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 358f3f0262cSandi */ 359f3f0262cSandifunction html_search(){ 360ed7b5f09Sandi require_once(DOKU_INC.'inc/search.php'); 361506fa893SAndreas Gohr require_once(DOKU_INC.'inc/fulltext.php'); 362f3f0262cSandi global $conf; 363f3f0262cSandi global $QUERY; 364f3f0262cSandi global $ID; 365f3f0262cSandi global $lang; 366f3f0262cSandi 367c112d578Sandi print p_locale_xhtml('searchpage'); 368f3f0262cSandi flush(); 369f3f0262cSandi 370d0ab54f6SMichael Klier chi@chimeric.de //check if search is restricted to namespace 371d0ab54f6SMichael Klier chi@chimeric.de if(preg_match('/([^@]*)@([^@]*)/',$QUERY,$match)) { 372d0ab54f6SMichael Klier chi@chimeric.de $id = cleanID($match[1]); 373d0ab54f6SMichael Klier chi@chimeric.de if(empty($id)) { 374d0ab54f6SMichael Klier chi@chimeric.de print '<div class="nothing">'.$lang['nothingfound'].'</div>'; 375d0ab54f6SMichael Klier chi@chimeric.de flush(); 376d0ab54f6SMichael Klier chi@chimeric.de return; 377d0ab54f6SMichael Klier chi@chimeric.de } 378d0ab54f6SMichael Klier chi@chimeric.de } else { 379d0ab54f6SMichael Klier chi@chimeric.de $id = cleanID($QUERY); 380d0ab54f6SMichael Klier chi@chimeric.de } 381d0ab54f6SMichael Klier chi@chimeric.de 3824d9ff3d5Sandi //show progressbar 3839edac8a8SAndreas Gohr print '<div class="centeralign" id="dw__loading">'; 3844d9ff3d5Sandi print '<br /></div>'; 3859edac8a8SAndreas Gohr print '<script type="text/javascript" charset="utf-8">'; 3869edac8a8SAndreas Gohr print 'showLoadBar("dw__loading");'; 3879edac8a8SAndreas Gohr print '</script>'; 3889edac8a8SAndreas Gohr flush(); 3894d9ff3d5Sandi 390f3f0262cSandi //do quick pagesearch 391f3f0262cSandi $data = array(); 392d0ab54f6SMichael Klier chi@chimeric.de 393d0ab54f6SMichael Klier chi@chimeric.de $data = ft_pageLookup($id); 394f3f0262cSandi if(count($data)){ 395f3f0262cSandi sort($data); 396f3f0262cSandi print '<div class="search_quickresult">'; 3974f732f0eSAnika Henke print '<h3>'.$lang[quickhits].':</h3>'; 3984f732f0eSAnika Henke print '<ul class="search_quickhits">'; 399140c93f3SAnika Henke foreach($data as $id){ 4004f732f0eSAnika Henke print '<li> '; 401506fa893SAndreas Gohr print html_wikilink(':'.$id,$conf['useheading']?NULL:$id); 4024f732f0eSAnika Henke print '</li> '; 403f3f0262cSandi } 404140c93f3SAnika Henke print '</ul> '; 405f3f0262cSandi //clear float (see http://www.complexspiral.com/publications/containing-floats/) 406f3f0262cSandi print '<div class="clearer"> </div>'; 407f3f0262cSandi print '</div>'; 408f3f0262cSandi } 409f3f0262cSandi flush(); 410f3f0262cSandi 411f3f0262cSandi //do fulltext search 412506fa893SAndreas Gohr $data = ft_pageSearch($QUERY,$poswords); 413f3f0262cSandi if(count($data)){ 414506fa893SAndreas Gohr $num = 1; 415506fa893SAndreas Gohr foreach($data as $id => $cnt){ 416f3f0262cSandi print '<div class="search_result">'; 417506fa893SAndreas Gohr print html_wikilink(':'.$id,$conf['useheading']?NULL:$id,$poswords); 418506fa893SAndreas Gohr print ': <span class="search_cnt">'.$cnt.' '.$lang['hits'].'</span><br />'; 419506fa893SAndreas Gohr if($num < 15){ // create snippets for the first number of matches only #FIXME add to conf ? 420506fa893SAndreas Gohr print '<div class="search_snippet">'.ft_snippet($id,$poswords).'</div>'; 421506fa893SAndreas Gohr } 422f3f0262cSandi print '</div>'; 423506fa893SAndreas Gohr flush(); 424506fa893SAndreas Gohr $num++; 425f3f0262cSandi } 426f3f0262cSandi }else{ 427820fa24bSandi print '<div class="nothing">'.$lang['nothingfound'].'</div>'; 428f3f0262cSandi } 4294d9ff3d5Sandi 4304d9ff3d5Sandi //hide progressbar 4314beabca9SAnika Henke print '<script type="text/javascript" charset="utf-8">'; 4329edac8a8SAndreas Gohr print 'hideLoadBar("dw__loading");'; 4334d9ff3d5Sandi print '</script>'; 4349edac8a8SAndreas Gohr flush(); 435f3f0262cSandi} 436f3f0262cSandi 43715fae107Sandi/** 43815fae107Sandi * Display error on locked pages 43915fae107Sandi * 44015fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 44115fae107Sandi */ 442ee20e7d1Sandifunction html_locked(){ 443f3f0262cSandi global $ID; 444f3f0262cSandi global $conf; 445f3f0262cSandi global $lang; 44688f522e9Sandi global $INFO; 447f3f0262cSandi 448f3f0262cSandi $locktime = filemtime(wikiFN($ID).'.lock'); 449f3f0262cSandi $expire = @date($conf['dformat'], $locktime + $conf['locktime'] ); 450f3f0262cSandi $min = round(($conf['locktime'] - (time() - $locktime) )/60); 451f3f0262cSandi 452c112d578Sandi print p_locale_xhtml('locked'); 453f3f0262cSandi print '<ul>'; 4540c6b58a8SAndreas Gohr print '<li><div class="li"><strong>'.$lang['lockedby'].':</strong> '.$INFO['locked'].'</li>'; 4550c6b58a8SAndreas Gohr print '<li><div class="li"><strong>'.$lang['lockexpire'].':</strong> '.$expire.' ('.$min.' min)</div></li>'; 456f3f0262cSandi print '</ul>'; 457f3f0262cSandi} 458f3f0262cSandi 45915fae107Sandi/** 46015fae107Sandi * list old revisions 46115fae107Sandi * 46215fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 46315fae107Sandi */ 464f3f0262cSandifunction html_revisions(){ 465f3f0262cSandi global $ID; 466f3f0262cSandi global $INFO; 467f3f0262cSandi global $conf; 468f3f0262cSandi global $lang; 469f3f0262cSandi $revisions = getRevisions($ID); 470f3f0262cSandi $date = @date($conf['dformat'],$INFO['lastmod']); 471f3f0262cSandi 472c112d578Sandi print p_locale_xhtml('revisions'); 473f3f0262cSandi print '<ul>'; 474f3f0262cSandi if($INFO['exists']){ 475b6912aeaSAndreas Gohr print ($INFO['minor']) ? '<li class="minor">' : '<li>'; 4760c6b58a8SAndreas Gohr print '<div class="li">'; 477f9b2fe70Sandi 478f9b2fe70Sandi print $date; 479f9b2fe70Sandi 48002e51121SAnika Henke print ' <img src="'.DOKU_BASE.'lib/images/blank.gif" width="15" height="11" alt="" /> '; 481cffcc403Sandi 482f9b2fe70Sandi print '<a class="wikilink1" href="'.wl($ID).'">'.$ID.'</a> '; 483652610a2Sandi 484652610a2Sandi print $INFO['sum']; 48588f522e9Sandi print ' <span class="user">'; 48688f522e9Sandi print $INFO['editor']; 48788f522e9Sandi print '</span> '; 488652610a2Sandi 489652610a2Sandi print '('.$lang['current'].')'; 4900c6b58a8SAndreas Gohr print '</div>'; 491652610a2Sandi print '</li>'; 492f3f0262cSandi } 493f3f0262cSandi 494f3f0262cSandi foreach($revisions as $rev){ 495f3f0262cSandi $date = date($conf['dformat'],$rev); 496*fb53bfe2SBen Coburn $info = getRevisionInfo($ID,$rev,true); 497652610a2Sandi 498b6912aeaSAndreas Gohr print ($info['minor']) ? '<li class="minor">' : '<li>'; 4990c6b58a8SAndreas Gohr print '<div class="li">'; 500f9b2fe70Sandi print $date; 501f9b2fe70Sandi 502cffcc403Sandi print ' <a href="'.wl($ID,"rev=$rev,do=diff").'">'; 503d94f4568SAndreas Gohr $p = array(); 504d94f4568SAndreas Gohr $p['src'] = DOKU_BASE.'lib/images/diff.png'; 505d94f4568SAndreas Gohr $p['width'] = 15; 506d94f4568SAndreas Gohr $p['height'] = 11; 507d94f4568SAndreas Gohr $p['title'] = $lang['diff']; 508d94f4568SAndreas Gohr $p['alt'] = $lang['diff']; 509d94f4568SAndreas Gohr $att = buildAttributes($p); 510d94f4568SAndreas Gohr print "<img $att />"; 511cffcc403Sandi print '</a> '; 512cffcc403Sandi 513f9b2fe70Sandi print '<a class="wikilink1" href="'.wl($ID,"rev=$rev").'">'.$ID.'</a> '; 514f9b2fe70Sandi 515f243a77fSandi print htmlspecialchars($info['sum']); 51688f522e9Sandi print ' <span class="user">'; 51788f522e9Sandi if($info['user']){ 51888f522e9Sandi print $info['user']; 51988f522e9Sandi }else{ 520652610a2Sandi print $info['ip']; 52188f522e9Sandi } 52288f522e9Sandi print '</span>'; 523652610a2Sandi 5240c6b58a8SAndreas Gohr print '</div>'; 525f3f0262cSandi print '</li>'; 526f3f0262cSandi } 527f3f0262cSandi print '</ul>'; 528f3f0262cSandi} 529f3f0262cSandi 53015fae107Sandi/** 53115fae107Sandi * display recent changes 53215fae107Sandi * 53315fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 5345749f1ceSmatthiasgrimm * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net> 53515fae107Sandi */ 536a39955b0Smatthiasgrimmfunction html_recent($first=0){ 537f3f0262cSandi global $conf; 538cffcc403Sandi global $lang; 539dbb00abcSEsther Brunner global $ID; 5405749f1ceSmatthiasgrimm /* we need to get one additionally log entry to be able to 5415749f1ceSmatthiasgrimm * decide if this is the last page or is there another one. 5425749f1ceSmatthiasgrimm * This is the cheapest solution to get this information. 5435749f1ceSmatthiasgrimm */ 544b6912aeaSAndreas Gohr $recents = getRecents($first,$conf['recent'] + 1,getNS($ID)); 5455749f1ceSmatthiasgrimm if(count($recents) == 0 && $first != 0){ 5465749f1ceSmatthiasgrimm $first=0; 547b6912aeaSAndreas Gohr $recents = getRecents(0,$conf['recent'] + 1,getNS($ID)); 5485749f1ceSmatthiasgrimm } 5495749f1ceSmatthiasgrimm $cnt = count($recents) <= $conf['recent'] ? count($recents) : $conf['recent']; 550f3f0262cSandi 551c112d578Sandi print p_locale_xhtml('recent'); 552f3f0262cSandi print '<ul>'; 553a39955b0Smatthiasgrimm 554d437bcc4SAndreas Gohr foreach($recents as $recent){ 555d437bcc4SAndreas Gohr $date = date($conf['dformat'],$recent['date']); 556b6912aeaSAndreas Gohr print ($recent['minor']) ? '<li class="minor">' : '<li>'; 5570c6b58a8SAndreas Gohr print '<div class="li">'; 558cffcc403Sandi 559f9b2fe70Sandi print $date.' '; 560f9b2fe70Sandi 561d437bcc4SAndreas Gohr print '<a href="'.wl($recent['id'],"do=diff").'">'; 562d94f4568SAndreas Gohr $p = array(); 563d94f4568SAndreas Gohr $p['src'] = DOKU_BASE.'lib/images/diff.png'; 564d94f4568SAndreas Gohr $p['width'] = 15; 565d94f4568SAndreas Gohr $p['height'] = 11; 566d94f4568SAndreas Gohr $p['title'] = $lang['diff']; 567d94f4568SAndreas Gohr $p['alt'] = $lang['diff']; 568d94f4568SAndreas Gohr $att = buildAttributes($p); 569d94f4568SAndreas Gohr print "<img $att />"; 570cffcc403Sandi print '</a> '; 571cffcc403Sandi 572d437bcc4SAndreas Gohr print '<a href="'.wl($recent['id'],"do=revisions").'">'; 573d94f4568SAndreas Gohr $p = array(); 574d94f4568SAndreas Gohr $p['src'] = DOKU_BASE.'lib/images/history.png'; 575d94f4568SAndreas Gohr $p['width'] = 12; 576d94f4568SAndreas Gohr $p['height'] = 14; 577d94f4568SAndreas Gohr $p['title'] = $lang['btn_revs']; 578d94f4568SAndreas Gohr $p['alt'] = $lang['btn_revs']; 579d94f4568SAndreas Gohr $att = buildAttributes($p); 580d94f4568SAndreas Gohr print "<img $att />"; 581cffcc403Sandi print '</a> '; 582cffcc403Sandi 583d437bcc4SAndreas Gohr print html_wikilink(':'.$recent['id'],$conf['useheading']?NULL:$recent['id']); 584d437bcc4SAndreas Gohr print ' '.htmlspecialchars($recent['sum']); 585b6912aeaSAndreas Gohr 58688f522e9Sandi print ' <span class="user">'; 587d437bcc4SAndreas Gohr if($recent['user']){ 588d437bcc4SAndreas Gohr print $recent['user']; 58988f522e9Sandi }else{ 590d437bcc4SAndreas Gohr print $recent['ip']; 59188f522e9Sandi } 59288f522e9Sandi print '</span>'; 593cffcc403Sandi 5940c6b58a8SAndreas Gohr print '</div>'; 595f3f0262cSandi print '</li>'; 596f3f0262cSandi } 597f3f0262cSandi print '</ul>'; 598a39955b0Smatthiasgrimm 599a39955b0Smatthiasgrimm print '<div class="pagenav">'; 6005749f1ceSmatthiasgrimm $last = $first + $conf['recent']; 601a39955b0Smatthiasgrimm if ($first > 0) { 602a39955b0Smatthiasgrimm $first -= $conf['recent']; 603a39955b0Smatthiasgrimm if ($first < 0) $first = 0; 604a39955b0Smatthiasgrimm print '<div class="pagenav-prev">'; 6055749f1ceSmatthiasgrimm print html_btn('newer','',"p",array('do' => 'recent', 'first' => $first)); 606a39955b0Smatthiasgrimm print '</div>'; 607a39955b0Smatthiasgrimm } 6085749f1ceSmatthiasgrimm if ($conf['recent'] < count($recents)) { 609a39955b0Smatthiasgrimm print '<div class="pagenav-next">'; 6105749f1ceSmatthiasgrimm print html_btn('older','',"n",array('do' => 'recent', 'first' => $last)); 611a39955b0Smatthiasgrimm print '</div>'; 612a39955b0Smatthiasgrimm } 613a39955b0Smatthiasgrimm print '</div>'; 614f3f0262cSandi} 615f3f0262cSandi 61615fae107Sandi/** 61715fae107Sandi * Display page index 61815fae107Sandi * 61915fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 62015fae107Sandi */ 621f3f0262cSandifunction html_index($ns){ 622ed7b5f09Sandi require_once(DOKU_INC.'inc/search.php'); 623f3f0262cSandi global $conf; 624f3f0262cSandi global $ID; 625f3f0262cSandi $dir = $conf['datadir']; 626f3f0262cSandi $ns = cleanID($ns); 62730f1737dSandi #fixme use appropriate function 628f3f0262cSandi if(empty($ns)){ 629f3f0262cSandi $ns = dirname(str_replace(':','/',$ID)); 630f3f0262cSandi if($ns == '.') $ns =''; 631f3f0262cSandi } 63288d3a917Sandi $ns = utf8_encodeFN(str_replace(':','/',$ns)); 633f3f0262cSandi 634c112d578Sandi print p_locale_xhtml('index'); 635f3f0262cSandi 636f3f0262cSandi $data = array(); 637f3f0262cSandi search($data,$conf['datadir'],'search_index',array('ns' => $ns)); 638cb70c441Sandi print html_buildlist($data,'idx','html_list_index','html_li_index'); 639f3f0262cSandi} 640f3f0262cSandi 641f3f0262cSandi/** 64215fae107Sandi * Index item formatter 64315fae107Sandi * 644f3f0262cSandi * User function for html_buildlist() 64515fae107Sandi * 64615fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 647f3f0262cSandi */ 648f3f0262cSandifunction html_list_index($item){ 649f3f0262cSandi $ret = ''; 650f3f0262cSandi $base = ':'.$item['id']; 651f3f0262cSandi $base = substr($base,strrpos($base,':')+1); 652f3f0262cSandi if($item['type']=='d'){ 653f3f0262cSandi $ret .= '<a href="'.wl($ID,'idx='.$item['id']).'" class="idx_dir">'; 654f3f0262cSandi $ret .= $base; 655f3f0262cSandi $ret .= '</a>'; 656f3f0262cSandi }else{ 657f3f0262cSandi $ret .= html_wikilink(':'.$item['id']); 658f3f0262cSandi } 659f3f0262cSandi return $ret; 660f3f0262cSandi} 661f3f0262cSandi 662f3f0262cSandi/** 663cb70c441Sandi * Index List item 664cb70c441Sandi * 665cb70c441Sandi * This user function is used in html_build_lidt to build the 666cb70c441Sandi * <li> tags for namespaces when displaying the page index 667cb70c441Sandi * it gives different classes to opened or closed "folders" 668cb70c441Sandi * 669cb70c441Sandi * @author Andreas Gohr <andi@splitbrain.org> 670cb70c441Sandi */ 671cb70c441Sandifunction html_li_index($item){ 672cb70c441Sandi if($item['type'] == "f"){ 673cb70c441Sandi return '<li class="level'.$item['level'].'">'; 674cb70c441Sandi }elseif($item['open']){ 675cb70c441Sandi return '<li class="open">'; 676cb70c441Sandi }else{ 677cb70c441Sandi return '<li class="closed">'; 678cb70c441Sandi } 679cb70c441Sandi} 680cb70c441Sandi 681cb70c441Sandi/** 682cb70c441Sandi * Default List item 683cb70c441Sandi * 684cb70c441Sandi * @author Andreas Gohr <andi@splitbrain.org> 685cb70c441Sandi */ 686cb70c441Sandifunction html_li_default($item){ 687cb70c441Sandi return '<li class="level'.$item['level'].'">'; 688cb70c441Sandi} 689cb70c441Sandi 690cb70c441Sandi/** 69115fae107Sandi * Build an unordered list 69215fae107Sandi * 693f3f0262cSandi * Build an unordered list from the given $data array 694f3f0262cSandi * Each item in the array has to have a 'level' property 695f3f0262cSandi * the item itself gets printed by the given $func user 696cb70c441Sandi * function. The second and optional function is used to 697cb70c441Sandi * print the <li> tag. Both user function need to accept 698cb70c441Sandi * a single item. 69915fae107Sandi * 700c5a8fd96SAndreas Gohr * Both user functions can be given as array to point to 701c5a8fd96SAndreas Gohr * a member of an object. 702c5a8fd96SAndreas Gohr * 70315fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 704f3f0262cSandi */ 705cb70c441Sandifunction html_buildlist($data,$class,$func,$lifunc='html_li_default'){ 706f3f0262cSandi $level = 0; 707f3f0262cSandi $opens = 0; 708f3f0262cSandi $ret = ''; 709f3f0262cSandi 710f3f0262cSandi foreach ($data as $item){ 711f3f0262cSandi 712f3f0262cSandi if( $item['level'] > $level ){ 713f3f0262cSandi //open new list 714df52d0feSandi for($i=0; $i<($item['level'] - $level); $i++){ 715df52d0feSandi if ($i) $ret .= "<li class=\"clear\">\n"; 716f3f0262cSandi $ret .= "\n<ul class=\"$class\">\n"; 717df52d0feSandi } 718f3f0262cSandi }elseif( $item['level'] < $level ){ 719f3f0262cSandi //close last item 720f3f0262cSandi $ret .= "</li>\n"; 721f3f0262cSandi for ($i=0; $i<($level - $item['level']); $i++){ 722f3f0262cSandi //close higher lists 723f3f0262cSandi $ret .= "</ul>\n</li>\n"; 724f3f0262cSandi } 725f3f0262cSandi }else{ 726f3f0262cSandi //close last item 727f3f0262cSandi $ret .= "</li>\n"; 728f3f0262cSandi } 729f3f0262cSandi 730f3f0262cSandi //remember current level 731f3f0262cSandi $level = $item['level']; 732f3f0262cSandi 733f3f0262cSandi //print item 734c5a8fd96SAndreas Gohr if(is_array($lifunc)){ 735c5a8fd96SAndreas Gohr $ret .= $lifunc[0]->$lifunc[1]($item); //user object method 736c5a8fd96SAndreas Gohr }else{ 737cb70c441Sandi $ret .= $lifunc($item); //user function 738c5a8fd96SAndreas Gohr } 7390c6b58a8SAndreas Gohr $ret .= '<div class="li">'; 740c5a8fd96SAndreas Gohr if(is_array($func)){ 741c5a8fd96SAndreas Gohr $ret .= $func[0]->$func[1]($item); //user object method 742c5a8fd96SAndreas Gohr }else{ 743f3f0262cSandi $ret .= $func($item); //user function 744c5a8fd96SAndreas Gohr } 7450c6b58a8SAndreas Gohr $ret .= '</div>'; 746f3f0262cSandi } 747f3f0262cSandi 748f3f0262cSandi //close remaining items and lists 749f3f0262cSandi for ($i=0; $i < $level; $i++){ 750f3f0262cSandi $ret .= "</li></ul>\n"; 751f3f0262cSandi } 752f3f0262cSandi 753f3f0262cSandi return $ret; 754f3f0262cSandi} 755f3f0262cSandi 75615fae107Sandi/** 75715fae107Sandi * display backlinks 75815fae107Sandi * 75915fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 76015fae107Sandi */ 761f3f0262cSandifunction html_backlinks(){ 76254f4c056SAndreas Gohr require_once(DOKU_INC.'inc/fulltext.php'); 763f3f0262cSandi global $ID; 764f3f0262cSandi global $conf; 765f3f0262cSandi 766c112d578Sandi print p_locale_xhtml('backlinks'); 767f3f0262cSandi 76854f4c056SAndreas Gohr $data = ft_backlinks($ID); 769f3f0262cSandi 770f3f0262cSandi print '<ul class="idx">'; 77154f4c056SAndreas Gohr foreach($data as $blink){ 7720c6b58a8SAndreas Gohr print '<li><div class="li">'; 77354f4c056SAndreas Gohr print html_wikilink(':'.$blink,$conf['useheading']?NULL:$blink); 7740c6b58a8SAndreas Gohr print '</div></li>'; 775f3f0262cSandi } 776f3f0262cSandi print '</ul>'; 777f3f0262cSandi} 778f3f0262cSandi 77915fae107Sandi/** 78015fae107Sandi * show diff 78115fae107Sandi * 78215fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 78315fae107Sandi */ 784f3f0262cSandifunction html_diff($text='',$intro=true){ 785ed7b5f09Sandi require_once(DOKU_INC.'inc/DifferenceEngine.php'); 786f3f0262cSandi global $ID; 787f3f0262cSandi global $REV; 788f3f0262cSandi global $lang; 789f3f0262cSandi global $conf; 790f3f0262cSandi if($text){ 791f3f0262cSandi $df = new Diff(split("\n",htmlspecialchars(rawWiki($ID,''))), 792f3f0262cSandi split("\n",htmlspecialchars(cleanText($text)))); 793f3f0262cSandi $left = '<a class="wikilink1" href="'.wl($ID).'">'. 794f3f0262cSandi $ID.' '.date($conf['dformat'],@filemtime(wikiFN($ID))).'</a>'. 795f3f0262cSandi $lang['current']; 796f3f0262cSandi $right = $lang['yours']; 797f3f0262cSandi }else{ 7984d58bd99Sandi if($REV){ 7994d58bd99Sandi $r = $REV; 8004d58bd99Sandi }else{ 8014d58bd99Sandi //use last revision if none given 8024d58bd99Sandi $revs = getRevisions($ID); 8034d58bd99Sandi $r = $revs[0]; 8044d58bd99Sandi } 8054d58bd99Sandi 8064d58bd99Sandi $df = new Diff(split("\n",htmlspecialchars(rawWiki($ID,$r))), 807f3f0262cSandi split("\n",htmlspecialchars(rawWiki($ID,'')))); 8084d58bd99Sandi $left = '<a class="wikilink1" href="'.wl($ID,"rev=$r").'">'. 8094d58bd99Sandi $ID.' '.date($conf['dformat'],$r).'</a>'; 810f3f0262cSandi $right = '<a class="wikilink1" href="'.wl($ID).'">'. 811f3f0262cSandi $ID.' '.date($conf['dformat'],@filemtime(wikiFN($ID))).'</a> '. 812f3f0262cSandi $lang['current']; 813f3f0262cSandi } 814f3f0262cSandi $tdf = new TableDiffFormatter(); 815c112d578Sandi if($intro) print p_locale_xhtml('diff'); 816f3f0262cSandi ?> 817daf4ca4eSAnika Henke <table class="diff"> 818f3f0262cSandi <tr> 819daf4ca4eSAnika Henke <th colspan="2"> 8204da078a3Smatthiasgrimm <?php echo $left?> 821daf4ca4eSAnika Henke </th> 822daf4ca4eSAnika Henke <th colspan="2"> 8234da078a3Smatthiasgrimm <?php echo $right?> 824daf4ca4eSAnika Henke </th> 825f3f0262cSandi </tr> 8264da078a3Smatthiasgrimm <?php echo $tdf->format($df)?> 827f3f0262cSandi </table> 8284da078a3Smatthiasgrimm <?php 829f3f0262cSandi} 830f3f0262cSandi 83115fae107Sandi/** 83215fae107Sandi * show warning on conflict detection 83315fae107Sandi * 83415fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 83515fae107Sandi */ 836f3f0262cSandifunction html_conflict($text,$summary){ 837f3f0262cSandi global $ID; 838f3f0262cSandi global $lang; 839f3f0262cSandi 840c112d578Sandi print p_locale_xhtml('conflict'); 841f3f0262cSandi ?> 8421dd0c202SAnika Henke <form id="dw__editform" method="post" action="<?php echo script()?>" accept-charset="<?php echo $lang['encoding']?>"> 84396331712SAnika Henke <div class="centeralign"> 8444da078a3Smatthiasgrimm <input type="hidden" name="id" value="<?php echo $ID?>" /> 8454da078a3Smatthiasgrimm <input type="hidden" name="wikitext" value="<?php echo formText($text)?>" /> 8464da078a3Smatthiasgrimm <input type="hidden" name="summary" value="<?php echo formText($summary)?>" /> 847f3f0262cSandi 8484da078a3Smatthiasgrimm <input class="button" type="submit" name="do" value="<?php echo $lang['btn_save']?>" accesskey="s" title="[ALT+S]" /> 8494da078a3Smatthiasgrimm <input class="button" type="submit" name="do" value="<?php echo $lang['btn_cancel']?>" /> 850f3f0262cSandi </div> 851f3f0262cSandi </form> 852f3f0262cSandi <br /><br /><br /><br /> 8534da078a3Smatthiasgrimm <?php 854f3f0262cSandi} 855f3f0262cSandi 856f3f0262cSandi/** 85715fae107Sandi * Prints the global message array 85815fae107Sandi * 85915fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 860f3f0262cSandi */ 861f3f0262cSandifunction html_msgarea(){ 862f3f0262cSandi global $MSG; 863f3f0262cSandi 864f3f0262cSandi if(!isset($MSG)) return; 865f3f0262cSandi 866f3f0262cSandi foreach($MSG as $msg){ 867f3f0262cSandi print '<div class="'.$msg['lvl'].'">'; 868f3f0262cSandi print $msg['msg']; 869f3f0262cSandi print '</div>'; 870f3f0262cSandi } 871f3f0262cSandi} 872f3f0262cSandi 873f3f0262cSandi/** 874f3f0262cSandi * Prints the registration form 87515fae107Sandi * 87615fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 877f3f0262cSandi */ 878f3f0262cSandifunction html_register(){ 879f3f0262cSandi global $lang; 880cab2716aSmatthias.grimm global $conf; 881f3f0262cSandi global $ID; 882f3f0262cSandi 883c112d578Sandi print p_locale_xhtml('register'); 884f3f0262cSandi?> 88596331712SAnika Henke <div class="centeralign"> 8861dd0c202SAnika Henke <form id="dw__register" method="post" action="<?php echo wl($ID)?>" accept-charset="<?php echo $lang['encoding']?>"> 88796331712SAnika Henke <fieldset> 888f3f0262cSandi <input type="hidden" name="do" value="register" /> 889f3f0262cSandi <input type="hidden" name="save" value="1" /> 89096331712SAnika Henke 8914da078a3Smatthiasgrimm <legend><?php echo $lang['register']?></legend> 892b6912aeaSAndreas Gohr <label class="block"> 8934da078a3Smatthiasgrimm <?php echo $lang['user']?> 8944da078a3Smatthiasgrimm <input type="text" name="login" class="edit" size="50" value="<?php echo formText($_POST['login'])?>" /> 895f3f0262cSandi </label><br /> 896cab2716aSmatthias.grimm 897cab2716aSmatthias.grimm <?php 898cab2716aSmatthias.grimm if (!$conf['autopasswd']) { 899cab2716aSmatthias.grimm ?> 900b6912aeaSAndreas Gohr <label class="block"> 9014da078a3Smatthiasgrimm <?php echo $lang['pass']?> 902cab2716aSmatthias.grimm <input type="password" name="pass" class="edit" size="50" /> 903cab2716aSmatthias.grimm </label><br /> 904b6912aeaSAndreas Gohr <label class="block"> 9054da078a3Smatthiasgrimm <?php echo $lang['passchk']?> 906cab2716aSmatthias.grimm <input type="password" name="passchk" class="edit" size="50" /> 907cab2716aSmatthias.grimm </label><br /> 908cab2716aSmatthias.grimm <?php 909cab2716aSmatthias.grimm } 910cab2716aSmatthias.grimm ?> 911cab2716aSmatthias.grimm 912b6912aeaSAndreas Gohr <label class="block"> 9134da078a3Smatthiasgrimm <?php echo $lang['fullname']?> 9144da078a3Smatthiasgrimm <input type="text" name="fullname" class="edit" size="50" value="<?php echo formText($_POST['fullname'])?>" /> 915f3f0262cSandi </label><br /> 916b6912aeaSAndreas Gohr <label class="block"> 9174da078a3Smatthiasgrimm <?php echo $lang['email']?> 9184da078a3Smatthiasgrimm <input type="text" name="email" class="edit" size="50" value="<?php echo formText($_POST['email'])?>" /> 919f3f0262cSandi </label><br /> 9204da078a3Smatthiasgrimm <input type="submit" class="button" value="<?php echo $lang['register']?>" /> 921f3f0262cSandi </fieldset> 922f3f0262cSandi </form> 923f3f0262cSandi </div> 9244da078a3Smatthiasgrimm<?php 925f3f0262cSandi} 926f3f0262cSandi 927f3f0262cSandi/** 9288b06d178Schris * Print the update profile form 9298b06d178Schris * 9308b06d178Schris * @author Christopher Smith <chris@jalakai.co.uk> 9318b06d178Schris * @author Andreas Gohr <andi@splitbrain.org> 9328b06d178Schris */ 9338b06d178Schrisfunction html_updateprofile(){ 9348b06d178Schris global $lang; 9358b06d178Schris global $conf; 9368b06d178Schris global $ID; 9378b06d178Schris global $INFO; 93882fd59b6SAndreas Gohr global $auth; 9398b06d178Schris 9408b06d178Schris print p_locale_xhtml('updateprofile'); 9418b06d178Schris 9428b06d178Schris if (empty($_POST['fullname'])) $_POST['fullname'] = $INFO['userinfo']['name']; 9438b06d178Schris if (empty($_POST['email'])) $_POST['email'] = $INFO['userinfo']['mail']; 9448b06d178Schris?> 94596331712SAnika Henke <div class="centeralign"> 9461dd0c202SAnika Henke <form id="dw__register" method="post" action="<?php echo wl($ID)?>" accept-charset="<?php echo $lang['encoding']?>"> 94796331712SAnika Henke <fieldset style="width: 80%;"> 9488b06d178Schris <input type="hidden" name="do" value="profile" /> 9498b06d178Schris <input type="hidden" name="save" value="1" /> 95096331712SAnika Henke 9518b06d178Schris <legend><?php echo $lang['profile']?></legend> 9528b06d178Schris <label class="block"> 9538b06d178Schris <?php echo $lang['user']?> 9548b06d178Schris <input type="text" name="fullname" disabled="disabled" class="edit" size="50" value="<?php echo formText($_SERVER['REMOTE_USER'])?>" /> 9558b06d178Schris </label><br /> 9568b06d178Schris <label class="block"> 9578b06d178Schris <?php echo $lang['fullname']?> 95882fd59b6SAndreas Gohr <input type="text" name="fullname" <?php if(!$auth->canDo('modName')) echo 'disabled="disabled"'?> class="edit" size="50" value="<?php echo formText($_POST['fullname'])?>" /> 9598b06d178Schris </label><br /> 9608b06d178Schris <label class="block"> 9618b06d178Schris <?php echo $lang['email']?> 96282fd59b6SAndreas Gohr <input type="text" name="email" <?php if(!$auth->canDo('modName')) echo 'disabled="disabled"'?> class="edit" size="50" value="<?php echo formText($_POST['email'])?>" /> 9638b06d178Schris </label><br /><br /> 96482fd59b6SAndreas Gohr 96582fd59b6SAndreas Gohr <?php if($auth->canDo('modPass')) { ?> 9668b06d178Schris <label class="block"> 9678b06d178Schris <?php echo $lang['newpass']?> 9688b06d178Schris <input type="password" name="newpass" class="edit" size="50" /> 9698b06d178Schris </label><br /> 9708b06d178Schris <label class="block"> 9718b06d178Schris <?php echo $lang['passchk']?> 9728b06d178Schris <input type="password" name="passchk" class="edit" size="50" /> 9738b06d178Schris </label><br /> 97482fd59b6SAndreas Gohr <?php } ?> 9758b06d178Schris 9768b06d178Schris <?php if ($conf['profileconfirm']) { ?> 9778b06d178Schris <br /> 9788b06d178Schris <label class="block"> 9798b06d178Schris <?php echo $lang['oldpass']?> 9808b06d178Schris <input type="password" name="oldpass" class="edit" size="50" /> 9818b06d178Schris </label><br /> 9828b06d178Schris <?php } ?> 9838b06d178Schris 9844cb79657SMatthias Grimm <input type="submit" class="button" value="<?php echo $lang['btn_save']?>" /> 9858b06d178Schris <input type="reset" class="button" value="<?php echo $lang['btn_reset']?>" /> 9868b06d178Schris </fieldset> 9878b06d178Schris </form> 9888b06d178Schris </div> 9898b06d178Schris<?php 9908b06d178Schris} 9918b06d178Schris 9928b06d178Schris/** 993f3f0262cSandi * This displays the edit form (lots of logic included) 99415fae107Sandi * 9957146cee2SAndreas Gohr * @fixme this is a huge lump of code and should be modularized 99615fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 997f3f0262cSandi */ 998f3f0262cSandifunction html_edit($text=null,$include='edit'){ //FIXME: include needed? 999f3f0262cSandi global $ID; 1000f3f0262cSandi global $REV; 1001f3f0262cSandi global $DATE; 1002f3f0262cSandi global $RANGE; 1003f3f0262cSandi global $PRE; 1004f3f0262cSandi global $SUF; 1005f3f0262cSandi global $INFO; 1006f3f0262cSandi global $SUM; 1007f3f0262cSandi global $lang; 1008f3f0262cSandi global $conf; 1009f3f0262cSandi 1010f3f0262cSandi //set summary default 1011f3f0262cSandi if(!$SUM){ 1012f3f0262cSandi if($REV){ 1013f3f0262cSandi $SUM = $lang['restored']; 1014f3f0262cSandi }elseif(!$INFO['exists']){ 1015f3f0262cSandi $SUM = $lang['created']; 1016f3f0262cSandi } 1017f3f0262cSandi } 1018f3f0262cSandi 1019f3f0262cSandi //no text? Load it! 1020f3f0262cSandi if(!isset($text)){ 1021f3f0262cSandi $pr = false; //no preview mode 10227146cee2SAndreas Gohr if($INFO['exists']){ 1023f3f0262cSandi if($RANGE){ 1024f3f0262cSandi list($PRE,$text,$SUF) = rawWikiSlices($RANGE,$ID,$REV); 1025f3f0262cSandi }else{ 1026f3f0262cSandi $text = rawWiki($ID,$REV); 1027f3f0262cSandi } 1028f3f0262cSandi }else{ 10297146cee2SAndreas Gohr //try to load a pagetemplate 10307146cee2SAndreas Gohr $text = pageTemplate($ID); 10317146cee2SAndreas Gohr } 10327146cee2SAndreas Gohr }else{ 1033f3f0262cSandi $pr = true; //preview mode 1034f3f0262cSandi } 1035f3f0262cSandi 1036f3f0262cSandi $wr = $INFO['writable']; 1037f3f0262cSandi if($wr){ 1038c112d578Sandi if ($REV) print p_locale_xhtml('editrev'); 1039c112d578Sandi print p_locale_xhtml($include); 1040f3f0262cSandi }else{ 1041c112d578Sandi print p_locale_xhtml('read'); 1042f3f0262cSandi $ro='readonly="readonly"'; 1043f3f0262cSandi } 1044f3f0262cSandi if(!$DATE) $DATE = $INFO['lastmod']; 1045dc57ef04Sandi 1046dc57ef04Sandi 1047f3f0262cSandi?> 104863afe2a6SAnika Henke <div style="width:99%;"> 104942c7abd6SAndreas Gohr 105063afe2a6SAnika Henke <div class="toolbar"> 1051ee4c4a1bSAndreas Gohr <div id="draft__status"><?php if($INFO['draft']) echo $lang['draftdate'].' '.date($conf['dformat']);?></div> 1052ee379fa4SAndreas Gohr <div id="tool__bar"><a href="<?php echo DOKU_BASE?>lib/exe/mediamanager.php?ns=<?php echo $INFO['namespace']?>" 105372f0e11fSAndreas Gohr target="_blank"><?php echo $lang['mediaselect'] ?></a></div> 105420d062caSAndreas Gohr 10554da078a3Smatthiasgrimm <?php if($wr){?> 10564beabca9SAnika Henke <script type="text/javascript" charset="utf-8"> 10574da078a3Smatthiasgrimm <?php /* sets changed to true when previewed */?> 10584da078a3Smatthiasgrimm textChanged = <?php ($pr) ? print 'true' : print 'false' ?>; 1059f3f0262cSandi </script> 106024a33b42SAndreas Gohr <span id="spell__action"></span> 106124a33b42SAndreas Gohr <div id="spell__suggest"></div> 1062ee4c4a1bSAndreas Gohr <?php } ?> 106363afe2a6SAnika Henke </div> 106424a33b42SAndreas Gohr <div id="spell__result"></div> 106563afe2a6SAnika Henke 106642c7abd6SAndreas Gohr 106742c7abd6SAndreas Gohr <form id="dw__editform" method="post" action="<?php echo script()?>" accept-charset="<?php echo $lang['encoding']?>"><div class="no"> 106842c7abd6SAndreas Gohr <input type="hidden" name="id" value="<?php echo $ID?>" /> 106942c7abd6SAndreas Gohr <input type="hidden" name="rev" value="<?php echo $REV?>" /> 107042c7abd6SAndreas Gohr <input type="hidden" name="date" value="<?php echo $DATE?>" /> 107142c7abd6SAndreas Gohr <input type="hidden" name="prefix" value="<?php echo formText($PRE)?>" /> 107242c7abd6SAndreas Gohr <input type="hidden" name="suffix" value="<?php echo formText($SUF)?>" /> 107342c7abd6SAndreas Gohr </div> 107442c7abd6SAndreas Gohr 107524a33b42SAndreas Gohr <textarea name="wikitext" id="wiki__text" <?php echo $ro?> cols="80" rows="10" class="edit" tabindex="1"><?php echo "\n".formText($text)?></textarea> 107663afe2a6SAnika Henke 107724a33b42SAndreas Gohr <div id="wiki__editbar"> 107824a33b42SAndreas Gohr <div id="size__ctl"></div> 10794da078a3Smatthiasgrimm <?php if($wr){?> 1080fa24fadbSAnika Henke <div class="editButtons"> 108124a33b42SAndreas Gohr <input class="button" id="edbtn__save" type="submit" name="do" value="<?php echo $lang['btn_save']?>" accesskey="s" title="[ALT+S]" tabindex="4" /> 108224a33b42SAndreas Gohr <input class="button" id="edbtn__preview" type="submit" name="do" value="<?php echo $lang['btn_preview']?>" accesskey="p" title="[ALT+P]" tabindex="5" /> 108342c7abd6SAndreas Gohr <input class="button" type="submit" name="do[draftdel]" value="<?php echo $lang['btn_cancel']?>" tabindex="6" /> 1084fa24fadbSAnika Henke </div> 10854da078a3Smatthiasgrimm <?php } ?> 10864da078a3Smatthiasgrimm <?php if($wr){ ?> 1087fa24fadbSAnika Henke <div class="summary"> 108824a33b42SAndreas Gohr <label for="edit__summary" class="nowrap"><?php echo $lang['summary']?>:</label> 108924a33b42SAndreas Gohr <input type="text" class="edit" name="summary" id="edit__summary" size="50" value="<?php echo formText($SUM)?>" tabindex="2" /> 1090b6912aeaSAndreas Gohr <?php html_minoredit()?> 1091fa24fadbSAnika Henke </div> 10924da078a3Smatthiasgrimm <?php }?> 109363afe2a6SAnika Henke </div> 109442c7abd6SAndreas Gohr </form> 109563afe2a6SAnika Henke </div> 10964da078a3Smatthiasgrimm<?php 1097f3f0262cSandi} 1098f3f0262cSandi 1099f3f0262cSandi/** 1100b6912aeaSAndreas Gohr * Adds a checkbox for minor edits for logged in users 1101b6912aeaSAndreas Gohr * 1102b6912aeaSAndreas Gohr * @author Andrea Gohr <andi@splitbrain.org> 1103b6912aeaSAndreas Gohr */ 1104b6912aeaSAndreas Gohrfunction html_minoredit(){ 1105b6912aeaSAndreas Gohr global $conf; 1106b6912aeaSAndreas Gohr global $lang; 1107b6912aeaSAndreas Gohr // minor edits are for logged in users only 1108b6912aeaSAndreas Gohr if(!$conf['useacl'] || !$_SERVER['REMOTE_USER']){ 1109b6912aeaSAndreas Gohr return; 1110b6912aeaSAndreas Gohr } 1111b6912aeaSAndreas Gohr 1112b6912aeaSAndreas Gohr $p = array(); 1113b6912aeaSAndreas Gohr $p['name'] = 'minor'; 1114b6912aeaSAndreas Gohr $p['type'] = 'checkbox'; 1115b6912aeaSAndreas Gohr $p['id'] = 'minoredit'; 1116b6912aeaSAndreas Gohr $p['tabindex'] = 3; 1117b6912aeaSAndreas Gohr $p['value'] = '1'; 1118b6912aeaSAndreas Gohr if($_REQUEST['minor']) $p['checked']='checked'; 1119b6912aeaSAndreas Gohr $att = buildAttributes($p); 1120b6912aeaSAndreas Gohr 1121fa24fadbSAnika Henke print '<span class="nowrap">'; 1122b6912aeaSAndreas Gohr print "<input $att />"; 1123b6912aeaSAndreas Gohr print '<label for="minoredit">'; 1124b6912aeaSAndreas Gohr print $lang['minoredit']; 1125b6912aeaSAndreas Gohr print '</label>'; 1126fa24fadbSAnika Henke print '</span>'; 1127b6912aeaSAndreas Gohr} 1128b6912aeaSAndreas Gohr 1129b6912aeaSAndreas Gohr/** 1130f3f0262cSandi * prints some debug info 113115fae107Sandi * 113215fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 1133f3f0262cSandi */ 1134f3f0262cSandifunction html_debug(){ 1135f3f0262cSandi global $conf; 1136d16a4edaSandi global $lang; 11375298a619SAndreas Gohr global $auth; 113828fb55ffSandi //remove sensitive data 113928fb55ffSandi $cnf = $conf; 114028fb55ffSandi $cnf['auth']='***'; 114128fb55ffSandi $cnf['notify']='***'; 11423dc3a5f1Sandi $cnf['ftp']='***'; 1143f3f0262cSandi 1144f3f0262cSandi print '<html><body>'; 1145f3f0262cSandi 1146f3f0262cSandi print '<p>When reporting bugs please send all the following '; 1147f3f0262cSandi print 'output as a mail to andi@splitbrain.org '; 1148f3f0262cSandi print 'The best way to do this is to save this page in your browser</p>'; 1149f3f0262cSandi 1150f3f0262cSandi print '<b>$_SERVER:</b><pre>'; 1151f3f0262cSandi print_r($_SERVER); 1152f3f0262cSandi print '</pre>'; 1153f3f0262cSandi 1154f3f0262cSandi print '<b>$conf:</b><pre>'; 115528fb55ffSandi print_r($cnf); 1156f3f0262cSandi print '</pre>'; 1157f3f0262cSandi 1158ed7b5f09Sandi print '<b>DOKU_BASE:</b><pre>'; 1159ed7b5f09Sandi print DOKU_BASE; 1160f3f0262cSandi print '</pre>'; 1161f3f0262cSandi 1162ed7b5f09Sandi print '<b>abs DOKU_BASE:</b><pre>'; 1163ed7b5f09Sandi print DOKU_URL; 1164ed7b5f09Sandi print '</pre>'; 1165ed7b5f09Sandi 1166ed7b5f09Sandi print '<b>rel DOKU_BASE:</b><pre>'; 1167f3f0262cSandi print dirname($_SERVER['PHP_SELF']).'/'; 1168f3f0262cSandi print '</pre>'; 1169f3f0262cSandi 1170f3f0262cSandi print '<b>PHP Version:</b><pre>'; 1171f3f0262cSandi print phpversion(); 1172f3f0262cSandi print '</pre>'; 1173f3f0262cSandi 1174f3f0262cSandi print '<b>locale:</b><pre>'; 1175f3f0262cSandi print setlocale(LC_ALL,0); 1176f3f0262cSandi print '</pre>'; 1177f3f0262cSandi 1178d16a4edaSandi print '<b>encoding:</b><pre>'; 1179d16a4edaSandi print $lang['encoding']; 1180d16a4edaSandi print '</pre>'; 1181d16a4edaSandi 11825298a619SAndreas Gohr if($auth){ 11835298a619SAndreas Gohr print '<b>Auth backend capabilities:</b><pre>'; 11845298a619SAndreas Gohr print_r($auth->cando); 11855298a619SAndreas Gohr print '</pre>'; 11865298a619SAndreas Gohr } 11875298a619SAndreas Gohr 11883aa54d7cSAndreas Gohr print '<b>$_SESSION:</b><pre>'; 11893aa54d7cSAndreas Gohr print_r($_SESSION); 11903aa54d7cSAndreas Gohr print '</pre>'; 11913aa54d7cSAndreas Gohr 1192f3f0262cSandi print '<b>Environment:</b><pre>'; 1193f3f0262cSandi print_r($_ENV); 1194f3f0262cSandi print '</pre>'; 1195f3f0262cSandi 1196f3f0262cSandi print '<b>PHP settings:</b><pre>'; 1197f3f0262cSandi $inis = ini_get_all(); 1198f3f0262cSandi print_r($inis); 1199f3f0262cSandi print '</pre>'; 1200f3f0262cSandi 1201f3f0262cSandi print '</body></html>'; 1202f3f0262cSandi} 1203f3f0262cSandi 1204c19fe9c0Sandifunction html_admin(){ 1205c19fe9c0Sandi global $ID; 1206c19fe9c0Sandi global $lang; 1207ca3a6df1SMatthias Grimm global $conf; 1208c19fe9c0Sandi 1209c112d578Sandi print p_locale_xhtml('admin'); 1210c19fe9c0Sandi 121111e2ce22Schris // build menu of admin functions from the plugins that handle them 121211e2ce22Schris $pluginlist = plugin_list('admin'); 121311e2ce22Schris $menu = array(); 121411e2ce22Schris foreach ($pluginlist as $p) { 121511e2ce22Schris if($obj =& plugin_load('admin',$p) === NULL) continue; 121611e2ce22Schris $menu[] = array('plugin' => $p, 121711e2ce22Schris 'prompt' => $obj->getMenuText($conf['lang']), 121811e2ce22Schris 'sort' => $obj->getMenuSort() 121911e2ce22Schris ); 122011e2ce22Schris } 122111e2ce22Schris 122211e2ce22Schris usort($menu, p_sort_modes); 122311e2ce22Schris 122411e2ce22Schris // output the menu 122511e2ce22Schris ptln('<ul>'); 122611e2ce22Schris 122711e2ce22Schris foreach ($menu as $item) { 122811e2ce22Schris if (!$item['prompt']) continue; 12290c6b58a8SAndreas Gohr ptln(' <li><div class="li"><a href="'.wl($ID, 'do=admin&page='.$item['plugin']).'">'.$item['prompt'].'</a></div></li>'); 123011e2ce22Schris } 123111e2ce22Schris 123211e2ce22Schris // add in non-plugin functions 123311e2ce22Schris if (!$conf['openregister']){ 12340c6b58a8SAndreas Gohr ptln('<li><div class="li"><a href="'.wl($ID,'do=register').'">'.$lang['admin_register'].'</a></div></li>'); 123511e2ce22Schris } 123611e2ce22Schris 123711e2ce22Schris ptln('</ul>'); 1238ca3a6df1SMatthias Grimm} 1239c19fe9c0Sandi 12408b06d178Schris/** 12418b06d178Schris * Form to request a new password for an existing account 12428b06d178Schris * 12438b06d178Schris * @author Benoit Chesneau <benoit@bchesneau.info> 124411e2ce22Schris */ 12458b06d178Schrisfunction html_resendpwd() { 12468b06d178Schris global $lang; 12478b06d178Schris global $conf; 12488b06d178Schris global $ID; 1249c19fe9c0Sandi 12508b06d178Schris print p_locale_xhtml('resendpwd'); 12518b06d178Schris?> 125296331712SAnika Henke <div class="centeralign"> 12531dd0c202SAnika Henke <form id="dw__resendpwd" action="<?php echo wl($ID)?>" accept-charset="<?php echo $lang['encoding']?>" method="post"> 12548b06d178Schris <fieldset> 12558b06d178Schris <br /> 1256753d5abfSMatthias Grimm <legend><?php echo $lang['resendpwd']?></legend> 12578b06d178Schris <input type="hidden" name="do" value="resendpwd" /> 12588b06d178Schris <input type="hidden" name="save" value="1" /> 12598b06d178Schris <label class="block"> 12608b06d178Schris <span><?php echo $lang['user']?></span> 12618b06d178Schris <input type="text" name="login" value="<?php echo formText($_POST['login'])?>" class="edit" /><br /><br /> 12628b06d178Schris </label><br /> 12638b06d178Schris <input type="submit" value="<?php echo $lang['btn_resendpwd']?>" class="button" /> 12648b06d178Schris </fieldset> 12658b06d178Schris </form> 12668b06d178Schris </div> 12678b06d178Schris<?php 12688b06d178Schris} 1269340756e4Sandi 1270340756e4Sandi//Setup VIM: ex: et ts=2 enc=utf-8 : 1271