Newer
Older
/**
* HTML output functions
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Andreas Gohr <andi@splitbrain.org>
*/
if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../').'/');
function html_wikilink($id,$name=NULL,$search=''){
require_once(DOKU_INC.'inc/parser/xhtml.php');
static $xhtml_renderer = NULL;
if(is_null($xhtml_renderer)){
$xhtml_renderer = new Doku_Renderer_xhtml();
return $xhtml_renderer->internallink($id,$name,$search,true);
/**
* Helps building long attribute lists
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function html_attbuild($attributes){
$ret = '';
foreach ( $attributes as $key => $value ) {
$ret .= $key.'="'.formtext($value).'" ';
}
return trim($ret);
}
*/
function html_login(){
global $lang;
global $conf;
global $ID;
<form action="<?php echo script()?>" accept-charset="<?php echo $lang['encoding']?>" method="post">
<legend><?php echo $lang['btn_login']?></legend>
<input type="hidden" name="id" value="<?php echo $ID?>" />
<span><?php echo $lang['user']?></span>
<input type="text" name="u" value="<?php echo formText($_REQUEST['u'])?>" class="edit" />
<input type="password" name="p" class="edit" />
</label><br />
<input type="submit" value="<?php echo $lang['btn_login']?>" class="button" />
<label for="remember" class="simple">
<input type="checkbox" name="r" id="remember" value="1" />
if($conf['openregister']){
print '<p>';
print $lang['reghere'];
print ': <a href="'.wl($ID,'do=register').'" class="wikilink1">'.$lang['register'].'</a>';
print '</p>';
}
chris
committed
if (auth_canDo('modifyUser')) {
print '<p>';
print $lang['pwdforget'];
print ': <a href="'.wl($ID,'do=resendpwd').'" class="wikilink1">'.$lang['resendpwd'].'</a>';
print '</p>';
}
if(@file_exists('includes/login.txt')){
print io_cacheParse('includes/login.txt');
}
}
/**
* shows the edit/source/show button dependent on current mode
*/
function html_editbutton(){
global $ID;
global $REV;
global $ACT;
global $INFO;
if($ACT == 'show' || $ACT == 'search'){
if($INFO['writable']){
if($INFO['exists']){
$r = html_btn('edit',$ID,'e',array('do' => 'edit','rev' => $REV),'post');
}else{
$r = html_btn('create',$ID,'e',array('do' => 'edit','rev' => $REV),'post');
}
}else{
$r = html_btn('source',$ID,'v',array('do' => 'edit','rev' => $REV),'post');
}
}else{
$r = html_btn('show',$ID,'v',array('do' => 'show'));
}
return $r;
}
/**
* prints a section editing button
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function html_secedit_button($section,$p){
global $ID;
global $lang;
$secedit = '';
$secedit .= '<div class="secedit">';
$secedit .= html_btn('secedit',$ID,'',
array('do' => 'edit',
'lines' => "$section"),
'post');
$secedit .= '</div>';
/**
* inserts section edit buttons if wanted or removes the markers
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
if($INFO['writable'] && $show && !$INFO['rev']){
$text = preg_replace('#<!-- SECTION \[(\d+-\d+)\] -->#e',
"html_secedit_button('\\1',true)",
$text);
$text = preg_replace('#<!-- SECTION \[(\d+-)\] -->#e',
"html_secedit_button('\\1',false)",
$text);
}else{
$text = preg_replace('#<!-- SECTION \[(\d*-\d*)\] -->#e','',$text);
}
return $text;
}
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function html_topbtn(){
global $lang;
$ret = '';
$ret = '<a href="#top"><input type="button" class="button" value="'.$lang['btn_top'].'" onclick="window.scrollTo(0, 0)" /></a>';
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
* Just the back to media window button in its own form
*
* @author Matthias Grimm <matthiasgrimm@users.sourceforge.net>
*/
function html_backtomedia_button($params,$akey=''){
global $conf;
global $lang;
$ret = '<form class="button" method="get" action="'.DOKU_BASE.'lib/exe/media.php">';
reset($params);
while (list($key, $val) = each($params)) {
$ret .= '<input type="hidden" name="'.$key.'" ';
$ret .= 'value="'.htmlspecialchars($val).'" />';
}
$ret .= '<input type="submit" value="'.htmlspecialchars($lang['btn_backtomedia']).'" class="button" ';
if($akey){
$ret .= 'title="ALT+'.strtoupper($akey).'" ';
$ret .= 'accesskey="'.$akey.'" ';
}
$ret .= '/>';
$ret .= '</form>';
return $ret;
}
/**
* Displays a button (using its own form)
*/
function html_btn($name,$id,$akey,$params,$method='get'){
global $conf;
global $lang;
$label = $lang['btn_'.$name];
$ret = '';
//filter id (without urlencoding)
$id = idfilter($id,false);
//make nice URLs even for buttons
if($conf['userewrite'] == 2){
$script = DOKU_BASE.DOKU_SCRIPT.'/'.$id;
}elseif($conf['userewrite']){
$script = DOKU_BASE.$id;
}else{
$ret .= '<form class="button" method="'.$method.'" action="'.$script.'">';
reset($params);
while (list($key, $val) = each($params)) {
$ret .= '<input type="hidden" name="'.$key.'" ';
$ret .= 'value="'.htmlspecialchars($val).'" />';
}
$ret .= '<input type="submit" value="'.htmlspecialchars($label).'" class="button" ';
if($akey){
$ret .= 'title="ALT+'.strtoupper($akey).'" ';
$ret .= 'accesskey="'.$akey.'" ';
}
$ret .= '/>';
$ret .= '</form>';
return $ret;
}
/**
* show a wiki page
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
global $ID;
global $REV;
global $HIGH;
//disable section editing for old revisions or in preview
print html_secedit(p_render('xhtml',p_get_instructions($txt),$info),$secedit);
if ($REV) print p_locale_xhtml('showrev');
$html = p_wiki_xhtml($ID,$REV,true);
print html_hilight($html,$HIGH);
}
}
/**
* Highlights searchqueries in HTML code
*/
function html_hilight($html,$query){
$queries = preg_split ("/\s/",$query,-1,PREG_SPLIT_NO_EMPTY);
foreach ($queries as $q){
$q = preg_quote($q,'/');
$html = preg_replace("/((<[^>]*)|$q)/ie", '"\2"=="\1"? unslash("\1"):"<span class=\"search_hit\">".unslash("\1")."</span>"', $html);
* Run a search and display the result
*
* @author Andreas Gohr <andi@splitbrain.org>
require_once(DOKU_INC.'inc/search.php');
global $conf;
global $QUERY;
global $ID;
global $lang;
print '<script language="javascript" type="text/javascript" charset="utf-8">';
print 'showLoadBar();';
print '</script>';
print '<br /></div>';
if(count($data)){
sort($data);
print '<div class="search_quickresult">';
print '<b>'.$lang[quickhits].':</b><br />';
print html_wikilink(':'.$id,$conf['useheading']?NULL:$id);
print '</div> ';
}
//clear float (see http://www.complexspiral.com/publications/containing-floats/)
print '<div class="clearer"> </div>';
print '</div>';
}
flush();
//do fulltext search
$num = 1;
foreach($data as $id => $cnt){
print html_wikilink(':'.$id,$conf['useheading']?NULL:$id,$poswords);
print ': <span class="search_cnt">'.$cnt.' '.$lang['hits'].'</span><br />';
if($num < 15){ // create snippets for the first number of matches only #FIXME add to conf ?
print '<div class="search_snippet">'.ft_snippet($id,$poswords).'</div>';
}
print '<div class="nothing">'.$lang['nothingfound'].'</div>';
print '<script language="javascript" type="text/javascript" charset="utf-8">';
/**
* Display error on locked pages
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
$locktime = filemtime(wikiFN($ID).'.lock');
$expire = @date($conf['dformat'], $locktime + $conf['locktime'] );
$min = round(($conf['locktime'] - (time() - $locktime) )/60);
print '<li><b>'.$lang['lockedby'].':</b> '.$INFO['locked'].'</li>';
print '<li><b>'.$lang['lockexpire'].':</b> '.$expire.' ('.$min.' min)</li>';
print '</ul>';
}
/**
* list old revisions
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function html_revisions(){
global $ID;
global $INFO;
global $conf;
global $lang;
$revisions = getRevisions($ID);
$date = @date($conf['dformat'],$INFO['lastmod']);
print ($INFO['minor']) ? '<li class="minor">' : '<li>';
print ' <img src="'.DOKU_BASE.'lib/images/blank.gif" border="0" width="15" height="11" alt="" /> ';
print '<a class="wikilink1" href="'.wl($ID).'">'.$ID.'</a> ';
print ' <span class="user">';
print $INFO['editor'];
print '</span> ';
print '('.$lang['current'].')';
print '</li>';
}
foreach($revisions as $rev){
$date = date($conf['dformat'],$rev);
print ($info['minor']) ? '<li class="minor">' : '<li>';
print $date;
print ' <a href="'.wl($ID,"rev=$rev,do=diff").'">';
$p = array();
$p['src'] = DOKU_BASE.'lib/images/diff.png';
$p['border'] = 0;
$p['width'] = 15;
$p['height'] = 11;
$p['title'] = $lang['diff'];
$p['alt'] = $lang['diff'];
$att = buildAttributes($p);
print "<img $att />";
print '<a class="wikilink1" href="'.wl($ID,"rev=$rev").'">'.$ID.'</a> ';
print ' <span class="user">';
if($info['user']){
print $info['user'];
}else{
print $info['ip'];
}
print '</span>';
/**
* display recent changes
*
* @author Andreas Gohr <andi@splitbrain.org>
* @author Matthias Grimm <matthiasgrimm@users.sourceforge.net>
/* we need to get one additionally log entry to be able to
* decide if this is the last page or is there another one.
* This is the cheapest solution to get this information.
*/
$recents = getRecents($first,$conf['recent'] + 1,getNS($ID));
if(count($recents) == 0 && $first != 0){
$first=0;
$recents = getRecents(0,$conf['recent'] + 1,getNS($ID));
}
$cnt = count($recents) <= $conf['recent'] ? count($recents) : $conf['recent'];
foreach($recents as $recent){
$date = date($conf['dformat'],$recent['date']);
print ($recent['minor']) ? '<li class="minor">' : '<li>';
print '<a href="'.wl($recent['id'],"do=diff").'">';
$p = array();
$p['src'] = DOKU_BASE.'lib/images/diff.png';
$p['border'] = 0;
$p['width'] = 15;
$p['height'] = 11;
$p['title'] = $lang['diff'];
$p['alt'] = $lang['diff'];
$att = buildAttributes($p);
print "<img $att />";
print '<a href="'.wl($recent['id'],"do=revisions").'">';
$p = array();
$p['src'] = DOKU_BASE.'lib/images/history.png';
$p['border'] = 0;
$p['width'] = 12;
$p['height'] = 14;
$p['title'] = $lang['btn_revs'];
$p['alt'] = $lang['btn_revs'];
$att = buildAttributes($p);
print "<img $att />";
print html_wikilink(':'.$recent['id'],$conf['useheading']?NULL:$recent['id']);
print ' '.htmlspecialchars($recent['sum']);
if($recent['user']){
print $recent['user'];
if ($first > 0) {
$first -= $conf['recent'];
if ($first < 0) $first = 0;
print '<div class="pagenav-prev">';
print html_btn('newer','',"p",array('do' => 'recent', 'first' => $first));
if ($conf['recent'] < count($recents)) {
print html_btn('older','',"n",array('do' => 'recent', 'first' => $last));
/**
* Display page index
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
require_once(DOKU_INC.'inc/search.php');
global $conf;
global $ID;
$dir = $conf['datadir'];
$ns = cleanID($ns);
if(empty($ns)){
$ns = dirname(str_replace(':','/',$ID));
if($ns == '.') $ns ='';
}
$ns = utf8_encodeFN(str_replace(':','/',$ns));
$data = array();
search($data,$conf['datadir'],'search_index',array('ns' => $ns));
*/
function html_list_index($item){
$ret = '';
$base = ':'.$item['id'];
$base = substr($base,strrpos($base,':')+1);
if($item['type']=='d'){
$ret .= '<a href="'.wl($ID,'idx='.$item['id']).'" class="idx_dir">';
$ret .= $base;
$ret .= '</a>';
}else{
$ret .= html_wikilink(':'.$item['id']);
}
return $ret;
}
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
/**
* Index List item
*
* This user function is used in html_build_lidt to build the
* <li> tags for namespaces when displaying the page index
* it gives different classes to opened or closed "folders"
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function html_li_index($item){
if($item['type'] == "f"){
return '<li class="level'.$item['level'].'">';
}elseif($item['open']){
return '<li class="open">';
}else{
return '<li class="closed">';
}
}
/**
* Default List item
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function html_li_default($item){
return '<li class="level'.$item['level'].'">';
}
* Build an unordered list from the given $data array
* Each item in the array has to have a 'level' property
* the item itself gets printed by the given $func user
* function. The second and optional function is used to
* print the <li> tag. Both user function need to accept
* a single item.
function html_buildlist($data,$class,$func,$lifunc='html_li_default'){
$level = 0;
$opens = 0;
$ret = '';
foreach ($data as $item){
if( $item['level'] > $level ){
//open new list
for($i=0; $i<($item['level'] - $level); $i++){
if ($i) $ret .= "<li class=\"clear\">\n";
$ret .= "\n<ul class=\"$class\">\n";
}
}elseif( $item['level'] < $level ){
//close last item
$ret .= "</li>\n";
for ($i=0; $i<($level - $item['level']); $i++){
//close higher lists
$ret .= "</ul>\n</li>\n";
}
}else{
//close last item
$ret .= "</li>\n";
}
//remember current level
$level = $item['level'];
//print item
$ret .= '<span class="li">';
$ret .= $func($item); //user function
$ret .= '</span>';
}
//close remaining items and lists
for ($i=0; $i < $level; $i++){
$ret .= "</li></ul>\n";
}
return $ret;
}
/**
* display backlinks
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
require_once(DOKU_INC.'inc/fulltext.php');
print html_wikilink(':'.$blink,$conf['useheading']?NULL:$blink);
/**
* show diff
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
require_once(DOKU_INC.'inc/DifferenceEngine.php');
global $ID;
global $REV;
global $lang;
global $conf;
if($text){
$df = new Diff(split("\n",htmlspecialchars(rawWiki($ID,''))),
split("\n",htmlspecialchars(cleanText($text))));
$left = '<a class="wikilink1" href="'.wl($ID).'">'.
$ID.' '.date($conf['dformat'],@filemtime(wikiFN($ID))).'</a>'.
$lang['current'];
$right = $lang['yours'];
}else{
if($REV){
$r = $REV;
}else{
//use last revision if none given
$revs = getRevisions($ID);
$r = $revs[0];
}
$df = new Diff(split("\n",htmlspecialchars(rawWiki($ID,$r))),
$left = '<a class="wikilink1" href="'.wl($ID,"rev=$r").'">'.
$ID.' '.date($conf['dformat'],$r).'</a>';
$right = '<a class="wikilink1" href="'.wl($ID).'">'.
$ID.' '.date($conf['dformat'],@filemtime(wikiFN($ID))).'</a> '.
$lang['current'];
}
$tdf = new TableDiffFormatter();
?>
<table class="diff" width="100%">
<tr>
<td colspan="2" width="50%" class="diff-header">
/**
* show warning on conflict detection
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function html_conflict($text,$summary){
global $ID;
global $lang;
<form name="editform" method="post" action="<?php echo script()?>" accept-charset="<?php echo $lang['encoding']?>">
<input type="hidden" name="id" value="<?php echo $ID?>" />
<input type="hidden" name="wikitext" value="<?php echo formText($text)?>" />
<input type="hidden" name="summary" value="<?php echo formText($summary)?>" />
<input class="button" type="submit" name="do" value="<?php echo $lang['btn_save']?>" accesskey="s" title="[ALT+S]" />
<input class="button" type="submit" name="do" value="<?php echo $lang['btn_cancel']?>" />
* Prints the global message array
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function html_msgarea(){
global $MSG;
if(!isset($MSG)) return;
foreach($MSG as $msg){
print '<div class="'.$msg['lvl'].'">';
print $msg['msg'];
print '</div>';
}
}
/**
* Prints the registration form
<form name="register" method="post" action="<?php echo wl($ID)?>" accept-charset="<?php echo $lang['encoding']?>">
<input type="hidden" name="do" value="register" />
<input type="hidden" name="save" value="1" />
<fieldset>
<?php echo $lang['user']?>
<input type="text" name="login" class="edit" size="50" value="<?php echo formText($_POST['login'])?>" />
<?php
if (!$conf['autopasswd']) {
?>
<input type="password" name="pass" class="edit" size="50" />
</label><br />
<input type="password" name="passchk" class="edit" size="50" />
</label><br />
<?php
}
?>
<?php echo $lang['fullname']?>
<input type="text" name="fullname" class="edit" size="50" value="<?php echo formText($_POST['fullname'])?>" />
<?php echo $lang['email']?>
<input type="text" name="email" class="edit" size="50" value="<?php echo formText($_POST['email'])?>" />
<input type="submit" class="button" value="<?php echo $lang['register']?>" />
chris
committed
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
/**
* Print the update profile form
*
* @author Christopher Smith <chris@jalakai.co.uk>
* @author Andreas Gohr <andi@splitbrain.org>
*/
function html_updateprofile(){
global $lang;
global $conf;
global $ID;
global $INFO;
print p_locale_xhtml('updateprofile');
if (empty($_POST['fullname'])) $_POST['fullname'] = $INFO['userinfo']['name'];
if (empty($_POST['email'])) $_POST['email'] = $INFO['userinfo']['mail'];
?>
<div align="center">
<form name="register" method="post" action="<?php echo wl($ID)?>" accept-charset="<?php echo $lang['encoding']?>">
<input type="hidden" name="do" value="profile" />
<input type="hidden" name="save" value="1" />
<fieldset style="width: 80%;">
<legend><?php echo $lang['profile']?></legend>
<label class="block">
<?php echo $lang['user']?>
<input type="text" name="fullname" disabled="disabled" class="edit" size="50" value="<?php echo formText($_SERVER['REMOTE_USER'])?>" />
</label><br />
<label class="block">
<?php echo $lang['fullname']?>
<input type="text" name="fullname" class="edit" size="50" value="<?php echo formText($_POST['fullname'])?>" />
</label><br />
<label class="block">
<?php echo $lang['email']?>
<input type="text" name="email" class="edit" size="50" value="<?php echo formText($_POST['email'])?>" />
</label><br /><br />
<label class="block">
<?php echo $lang['newpass']?>
<input type="password" name="newpass" class="edit" size="50" />
</label><br />
<label class="block">
<?php echo $lang['passchk']?>
<input type="password" name="passchk" class="edit" size="50" />
</label><br />
<?php if ($conf['profileconfirm']) { ?>
<br />
<label class="block">
<?php echo $lang['oldpass']?>
<input type="password" name="oldpass" class="edit" size="50" />
</label><br />
<?php } ?>
<input type="submit" class="button" value="<?php echo $lang['btn_profile']?>" />
<input type="reset" class="button" value="<?php echo $lang['btn_reset']?>" />
</fieldset>
</form>
</div>
<?php
}
* @fixme this is a huge lump of code and should be modularized
*/
function html_edit($text=null,$include='edit'){ //FIXME: include needed?
global $ID;
global $REV;
global $DATE;
global $RANGE;
global $PRE;
global $SUF;
global $INFO;
global $SUM;
global $lang;
global $conf;
//set summary default
if(!$SUM){
if($REV){
$SUM = $lang['restored'];
}elseif(!$INFO['exists']){
$SUM = $lang['created'];
}
}
//no text? Load it!
if(!isset($text)){
$pr = false; //no preview mode
if($INFO['exists']){
if($RANGE){
list($PRE,$text,$SUF) = rawWikiSlices($RANGE,$ID,$REV);
}else{
$text = rawWiki($ID,$REV);
}
//try to load a pagetemplate
$text = pageTemplate($ID);
}
}else{
$pr = true; //preview mode
}
$wr = $INFO['writable'];
if($wr){
if ($REV) print p_locale_xhtml('editrev');
print p_locale_xhtml($include);
$ro='readonly="readonly"';
}
if(!$DATE) $DATE = $INFO['lastmod'];
<form name="editform" method="post" action="<?php echo script()?>" accept-charset="<?php echo $lang['encoding']?>">
<input type="hidden" name="id" value="<?php echo $ID?>" />
<input type="hidden" name="rev" value="<?php echo $REV?>" />
<input type="hidden" name="date" value="<?php echo $DATE?>" />
<input type="hidden" name="prefix" value="<?php echo formText($PRE)?>" />
<input type="hidden" name="suffix" value="<?php echo formText($SUF)?>" />
<div id="toolbar"></div>
<script language="javascript" type="text/javascript" charset="utf-8">
<?php /* sets changed to true when previewed */?>
textChanged = <?php ($pr) ? print 'true' : print 'false' ?>;
<textarea name="wikitext" id="wikitext" <?php echo $ro?> cols="80" rows="10" class="edit" tabindex="1"><?php echo "\n".formText($text)?></textarea>
<input class="button" id="edbtn_save" type="submit" name="do" value="<?php echo $lang['btn_save']?>" accesskey="s" title="[ALT+S]" tabindex="4" />
<input class="button" id="edbtn_preview" type="submit" name="do" value="<?php echo $lang['btn_preview']?>" accesskey="p" title="[ALT+P]" tabindex="5" />
<input class="button" type="submit" name="do" value="<?php echo $lang['btn_cancel']?>" tabindex="5" />
<?php } ?>
<?php if($wr){ ?>
<?php echo $lang['summary']?>:
<input type="text" class="edit" name="summary" id="summary" size="50" value="<?php echo formText($SUM)?>" tabindex="2" />
<div id="sizectl"></div>