Newer
Older
/**
* HTML output functions
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Andreas Gohr <andi@splitbrain.org>
*/
if(!defined('NL')) define('NL',"\n");
function html_wikilink($id,$name=null,$search=''){
static $xhtml_renderer = null;
if(is_null($xhtml_renderer)){
$xhtml_renderer = p_get_renderer('xhtml');
}
return $xhtml_renderer->internallink($id,$name,$search,true,'navigation');
/**
* Helps building long attribute lists
*
* @deprecated Use buildAttributes instead
* @author Andreas Gohr <andi@splitbrain.org>
*/
function html_attbuild($attributes){
$ret = '';
foreach ( $attributes as $key => $value ) {
$ret .= $key.'="'.formText($value).'" ';
* @author Andreas Gohr <andi@splitbrain.org>
global $lang;
global $conf;
global $ID;
print p_locale_xhtml('login');
print '<div class="centeralign">'.NL;
$form = new Doku_Form(array('id' => 'dw__login'));
$form->startFieldset($lang['btn_login']);
$form->addHidden('id', $ID);
$form->addHidden('do', 'login');
$form->addElement(form_makeTextField('u', ((!$_REQUEST['http_credentials']) ? $_REQUEST['u'] : ''), $lang['user'], 'focus__this', 'block'));
$form->addElement(form_makePasswordField('p', $lang['pass'], '', 'block'));
if($conf['rememberme']) {
$form->addElement(form_makeCheckboxField('r', '1', $lang['remember'], 'remember__me', 'simple'));
}
$form->addElement(form_makeButton('submit', '', $lang['btn_login']));
$form->endFieldset();
$form->addElement('<p>'.$lang['reghere'].': '.tpl_actionlink('register','','','',true).'</p>');
$form->addElement('<p>'.$lang['pwdforget'].': '.tpl_actionlink('resendpwd','','','',true).'</p>');
html_form('login', $form);
* inserts section edit buttons if wanted or removes the markers
function html_secedit($text,$show=true){
$regexp = '#<!-- EDIT(\d+) ([A-Z_]+) (?:"([^"]*)" )?\[(\d+-\d*)\] -->#';
if(!$INFO['writable'] || !$show || $INFO['rev']){
return preg_replace($regexp,'',$text);
}
return preg_replace_callback($regexp,
'html_secedit_button', $text);
* prepares section edit button data for event triggering
* used as a callback in html_secedit
function html_secedit_button($matches){
$data = array('secid' => $matches[1],
'target' => strtolower($matches[2]),
'range' => $matches[count($matches) - 1]);
if (count($matches) === 5) {
$data['name'] = $matches[3];
}
return trigger_event('HTML_SECEDIT_BUTTON', $data,
'html_secedit_get_button');
}
/**
* prints a section editing button
* used as default action form HTML_SECEDIT_BUTTON
*
* @author Adrian Lang <lang@cosmocode.de>
*/
function html_secedit_get_button($data) {
global $ID;
if (!isset($data['name']) || $data['name'] === '') return;
$name = $data['name'];
unset($data['name']);
$secid = $data['secid'];
unset($data['secid']);
return "<div class='secedit editbutton_" . $data['target'] .
html_btn('secedit', $ID, '',
array_merge(array('do' => 'edit',
'rev' => $INFO['lastmod'],
'summary' => '['.$name.'] '), $data),
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function html_topbtn(){
$ret = '';
$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>';
/**
* Displays a button (using its own form)
* If tooltip exists, the access key tooltip is replaced.
Anika Henke
committed
function html_btn($name,$id,$akey,$params,$method='get',$tooltip='',$label=false){
Anika Henke
committed
if (!$label)
$label = $lang['btn_'.$name];
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
$ret = '';
$tip = '';
//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{
$script = DOKU_BASE.DOKU_SCRIPT;
$params['id'] = $id;
}
$ret .= '<form class="button btn_'.$name.'" method="'.$method.'" action="'.$script.'"><div class="no">';
if(is_array($params)){
reset($params);
while (list($key, $val) = each($params)) {
$ret .= '<input type="hidden" name="'.$key.'" ';
$ret .= 'value="'.htmlspecialchars($val).'" />';
}
}
if ($tooltip!='') {
$tip = htmlspecialchars($tooltip);
}else{
$tip = htmlspecialchars($label);
$ret .= '<input type="submit" value="'.hsc($label).'" class="button" ';
if($akey){
$tip .= ' ['.strtoupper($akey).']';
$ret .= 'accesskey="'.$akey.'" ';
}
$ret .= 'title="'.$tip.'" ';
$ret .= '/>';
$ret .= '</div></form>';
return $ret;
/**
* show a wiki page
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
global $ID;
global $REV;
global $HIGH;
global $INFO;
//disable section editing for old revisions or in preview
if($txt || $REV){
$secedit = false;
}else{
$secedit = true;
}
//PreviewHeader
echo '<br id="scroll__here" />';
echo p_locale_xhtml('preview');
echo '<div class="preview">';
$html = html_secedit(p_render('xhtml',p_get_instructions($txt),$info),$secedit);
if($INFO['prependTOC']) $html = tpl_toc(true).$html;
echo $html;
echo '<div class="clearer"></div>';
echo '</div>';
}else{
if ($REV) print p_locale_xhtml('showrev');
$html = p_wiki_xhtml($ID,$REV,true);
$html = html_secedit($html,$secedit);
if($INFO['prependTOC']) $html = tpl_toc(true).$html;
$html = html_hilight($html,$HIGH);
echo $html;
}
/**
* ask the user about how to handle an exisiting draft
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function html_draft(){
global $INFO;
global $ID;
global $lang;
global $conf;
$draft = unserialize(io_readFile($INFO['draft'],false));
$text = cleanText(con($draft['prefix'],$draft['text'],$draft['suffix'],true));
print p_locale_xhtml('draft');
$form = new Doku_Form(array('id' => 'dw__editform'));
$form->addHidden('id', $ID);
$form->addHidden('date', $draft['date']);
$form->addElement(form_makeWikiText($text, array('readonly'=>'readonly')));
$form->addElement(form_makeOpenTag('div', array('id'=>'draft__status')));
$form->addElement($lang['draftdate'].' '. dformat(filemtime($INFO['draft'])));
$form->addElement(form_makeCloseTag('div'));
$form->addElement(form_makeButton('submit', 'recover', $lang['btn_recover'], array('tabindex'=>'1')));
$form->addElement(form_makeButton('submit', 'draftdel', $lang['btn_draftdel'], array('tabindex'=>'2')));
$form->addElement(form_makeButton('submit', 'show', $lang['btn_cancel'], array('tabindex'=>'3')));
html_form('draft', $form);
* @author Harry Fuecks <hfuecks@gmail.com>
function html_hilight($html,$phrases){
$regex = join('|',array_map('ft_snippet_re_preprocess', array_map('preg_quote_cb',$phrases)));
if (!utf8_check($regex)) return $html;
$html = @preg_replace_callback("/((<[^>]*)|$regex)/ui",'html_hilight_callback',$html);
* Callback used by html_hilight()
*
* @author Harry Fuecks <hfuecks@gmail.com>
function html_hilight_callback($m) {
$hlight = unslash($m[0]);
if ( !isset($m[2])) {
$hlight = '<span class="search_hit">'.$hlight.'</span>';
}
return $hlight;
* Run a search and display the result
*
* @author Andreas Gohr <andi@splitbrain.org>
global $conf;
global $QUERY;
global $ID;
global $lang;
$intro = p_locale_xhtml('searchpage');
// allow use of placeholder in search intro
$intro = str_replace(
array('@QUERY@','@SEARCH@'),
array(hsc(rawurlencode($QUERY)),hsc($QUERY)),
$intro);
echo $intro;
flush();
//show progressbar
print '<div class="centeralign" id="dw__loading">'.NL;
print '<script type="text/javascript" charset="utf-8"><!--//--><![CDATA[//><!--'.NL;
print 'showLoadBar();'.NL;
print '//--><!]]></script>'.NL;
print '<br /></div>'.NL;
flush();
//do quick pagesearch
$data = array();
$data = ft_pageLookup($QUERY,true,useHeading('navigation'));
if(count($data)){
print '<div class="search_quickresult">';
print '<h3>'.$lang['quickhits'].':</h3>';
print '<ul class="search_quickhits">';
foreach($data as $id => $title){
if (useHeading('navigation')) {
$name = $title;
$ns = getNS($id);
if($ns){
$name = shorten(noNS($id), ' ('.$ns.')',30);
}else{
$name = $id;
}
}
print html_wikilink(':'.$id,$name);
print '</li> ';
print '</ul> ';
//clear float (see http://www.complexspiral.com/publications/containing-floats/)
flush();
//do fulltext search
$data = ft_pageSearch($QUERY,$regex);
if(count($data)){
$num = 1;
foreach($data as $id => $cnt){
print '<div class="search_result">';
print html_wikilink(':'.$id,useHeading('navigation')?null:$id,$regex);
if($cnt !== 0){
print ': <span class="search_cnt">'.$cnt.' '.$lang['hits'].'</span><br />';
if($num < FT_SNIPPET_NUMBER){ // create snippets for the first number of matches only
print '<div class="search_snippet">'.ft_snippet($id,$regex).'</div>';
}
$num++;
}
print '</div>';
flush();
}
}else{
print '<div class="nothing">'.$lang['nothingfound'].'</div>';
}
//hide progressbar
print '<script type="text/javascript" charset="utf-8"><!--//--><![CDATA[//><!--'.NL;
print 'hideLoadBar("dw__loading");'.NL;
print '//--><!]]></script>'.NL;
flush();
/**
* Display error on locked pages
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
global $ID;
global $conf;
global $lang;
global $INFO;
$locktime = filemtime(wikiLockFN($ID));
$expire = dformat($locktime + $conf['locktime']);
$min = round(($conf['locktime'] - (time() - $locktime) )/60);
print p_locale_xhtml('locked');
print '<ul>';
print '<li><div class="li"><strong>'.$lang['lockedby'].':</strong> '.editorinfo($INFO['locked']).'</div></li>';
print '<li><div class="li"><strong>'.$lang['lockexpire'].':</strong> '.$expire.' ('.$min.' min)</div></li>';
print '</ul>';
/**
* list old revisions
*
* @author Andreas Gohr <andi@splitbrain.org>
global $ID;
global $INFO;
global $conf;
global $lang;
/* we need to get one additionally log entry to be able to
* decide if this is the last page or is there another one.
* see html_recent()
*/
if (!$media_id) $revisions = getRevisions($ID, $first, $conf['recent']+1);
else {
$revisions = getRevisions($media_id, $first, $conf['recent']+1, 8192, true);
$id = $media_id;
}
if(count($revisions)==0 && $first!=0){
$first=0;
if (!$media_id) $revisions = getRevisions($ID, $first, $conf['recent']+1);
else $revisions = getRevisions($media_id, $first, $conf['recent']+1, 8192, true);
$hasNext = false;
if (count($revisions)>$conf['recent']) {
$hasNext = true;
array_pop($revisions); // remove extra log entry
if (!$media_id) $date = dformat($INFO['lastmod']);
else $date = dformat(@filemtime(mediaFN($id)));
if ($media_id) $params['action'] = media_managerURL(array('image' => $media_id), '&');
if (!$media_id) $exists = $INFO['exists'];
else $exists = @file_exists(mediaFN($id));
if($exists && $first==0){
if (!$media_id && isset($INFO['meta']) && isset($INFO['meta']['last_change']) && $INFO['meta']['last_change']['type']===DOKU_CHANGE_TYPE_MINOR_EDIT)
$form->addElement(form_makeOpenTag('li', array('class' => 'minor')));
else
$form->addElement(form_makeOpenTag('li'));
$form->addElement(form_makeOpenTag('div', array('class' => 'li')));
$form->addElement(form_makeTag('input', array(
'type' => 'checkbox',
'name' => 'rev2[]',
'value' => 'current')));
$form->addElement(form_makeOpenTag('span', array('class' => 'date')));
$form->addElement($date);
$form->addElement(form_makeCloseTag('span'));
Anika Henke
committed
$form->addElement('<img src="'.DOKU_BASE.'lib/images/blank.gif" width="15" height="11" alt="" />');
else $href = media_managerURL(array('image' => $id, 'tab_details' => 'view'), '&');
$form->addElement(form_makeOpenTag('a', array(
'class' => 'wikilink1',
if ($media_id) $form->addElement(form_makeOpenTag('div'));
if (!$media_id) {
$form->addElement(form_makeOpenTag('span', array('class' => 'sum')));
$form->addElement(' – ');
$form->addElement(htmlspecialchars($INFO['sum']));
$form->addElement(form_makeCloseTag('span'));
}
$form->addElement(form_makeOpenTag('span', array('class' => 'user')));
if (!$media_id) $editor = $INFO['editor'];
else {
$revinfo = getRevisionInfo($id, @filemtime(fullpath(mediaFN($id))), 1024, true);
if($revinfo['user']){
$editor = $revinfo['user'];
}else{
$editor = $revinfo['ip'];
}
}
$form->addElement((empty($editor))?('('.$lang['external_edit'].')'):editorinfo($editor));
$form->addElement(form_makeCloseTag('span'));
$form->addElement('('.$lang['current'].')');
if ($media_id) $form->addElement(form_makeCloseTag('div'));
$form->addElement(form_makeCloseTag('div'));
$form->addElement(form_makeCloseTag('li'));
$date = dformat($rev);
if (!$media_id) {
$info = getRevisionInfo($id,$rev,true);
$exists = page_exists($id,$rev);
} else {
$info = getRevisionInfo($id,$rev,true,true);
$exists = @file_exists(mediaFN($id,$rev));
}
if ($info['type']===DOKU_CHANGE_TYPE_MINOR_EDIT)
$form->addElement(form_makeOpenTag('li', array('class' => 'minor')));
else
$form->addElement(form_makeOpenTag('li'));
$form->addElement(form_makeOpenTag('div', array('class' => 'li')));
if($exists){
$form->addElement(form_makeTag('input', array(
'type' => 'checkbox',
'name' => 'rev2[]',
'value' => $rev)));
}else{
Anika Henke
committed
$form->addElement('<img src="'.DOKU_BASE.'lib/images/blank.gif" width="15" height="11" alt="" />');
}
$form->addElement(form_makeOpenTag('span', array('class' => 'date')));
$form->addElement($date);
$form->addElement(form_makeCloseTag('span'));
if($exists){
if (!$media_id) $href = wl($id,"rev=$rev,do=diff", false, '&');
else $href = media_managerURL(array('image' => $id, 'rev' => $rev, 'mediado' => 'diff'), '&');
$form->addElement(form_makeOpenTag('a', array('href' => $href, 'class' => 'diff_link')));
$form->addElement(form_makeTag('img', array(
'src' => DOKU_BASE.'lib/images/diff.png',
'width' => 15,
'height' => 11,
'title' => $lang['diff'],
'alt' => $lang['diff'])));
$form->addElement(form_makeCloseTag('a'));
else $href = media_managerURL(array('image' => $id, 'tab_details' => 'view', 'rev' => $rev), '&');
$form->addElement(form_makeOpenTag('a', array('href' => $href, 'class' => 'wikilink1')));
$form->addElement(form_makeCloseTag('a'));
}else{
Anika Henke
committed
$form->addElement('<img src="'.DOKU_BASE.'lib/images/blank.gif" width="15" height="11" alt="" />');
if ($media_id) $form->addElement(form_makeOpenTag('div'));
if ($info['sum']) {
$form->addElement(form_makeOpenTag('span', array('class' => 'sum')));
if (!$media_id) $form->addElement(' – ');
$form->addElement(htmlspecialchars($info['sum']));
$form->addElement(form_makeCloseTag('span'));
}
$form->addElement(form_makeOpenTag('span', array('class' => 'user')));
if($info['user']){
$form->addElement(editorinfo($info['user']));
if(auth_ismanager()){
$form->addElement(' ('.$info['ip'].')');
}
}else{
$form->addElement($info['ip']);
}
$form->addElement(form_makeCloseTag('span'));
if ($media_id) $form->addElement(form_makeCloseTag('div'));
$form->addElement(form_makeCloseTag('div'));
$form->addElement(form_makeCloseTag('li'));
}
$form->addElement(form_makeCloseTag('ul'));
if (!$media_id) {
$form->addElement(form_makeButton('submit', 'diff', $lang['diff2']));
} else {
$form->addHidden('mediado', 'diff');
$form->addElement(form_makeButton('submit', '', $lang['diff2']));
}
html_form('revisions', $form);
print '<div class="pagenav">';
$last = $first + $conf['recent'];
if ($first > 0) {
$first -= $conf['recent'];
if ($first < 0) $first = 0;
print '<div class="pagenav-prev">';
print html_btn('newer',$media_id,"p",media_managerURL(array('first' => $first), '&', false, true));
} else {
print html_btn('newer',$id,"p",array('do' => 'revisions', 'first' => $first));
}
print '</div>';
}
if ($hasNext) {
print '<div class="pagenav-next">';
print html_btn('older',$media_id,"n",media_managerURL(array('first' => $last), '&', false, true));
} else {
print html_btn('older',$id,"n",array('do' => 'revisions', 'first' => $last));
}
/**
* display recent changes
*
* @author Andreas Gohr <andi@splitbrain.org>
* @author Matthias Grimm <matthiasgrimm@users.sourceforge.net>
* @author Kate Arzamastseva <pshns@ukr.net>
function html_recent($first=0, $show_changes='both'){
global $conf;
global $lang;
global $ID;
/* 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.
*/
$flags = 0;
if ($show_changes == 'mediafiles' && $conf['mediarevisions']) {
$flags = RECENTS_MEDIA_CHANGES;
} elseif ($show_changes == 'pages') {
$flags = 0;
} elseif ($conf['mediarevisions']) {
$show_changes = 'both';
$flags = RECENTS_MEDIA_PAGES_MIXED;
}
$recents = getRecents($first,$conf['recent'] + 1,getNS($ID),$flags);
if(count($recents) == 0 && $first != 0){
$first=0;
$recents = getRecents($first,$conf['recent'] + 1,getNS($ID),$flags);
}
$hasNext = false;
if (count($recents)>$conf['recent']) {
$hasNext = true;
array_pop($recents); // remove extra log entry
print p_locale_xhtml('recent');
if (getNS($ID) != '')
print '<div class="level1"><p>' . sprintf($lang['recent_global'], getNS($ID), wl('', 'do=recent')) . '</p></div>';
$form = new Doku_Form(array('id' => 'dw__recent', 'method' => 'GET'));
$form->addHidden('sectok', null);
$form->addHidden('do', 'recent');
$form->addHidden('id', $ID);
if ($conf['mediarevisions']) {
$form->addElement(form_makeListboxField(
'show_changes',
array(
'pages' => $lang['pages_changes'],
'mediafiles' => $lang['media_changes'],
'both' => $lang['both_changes']),
$show_changes,
$lang['changes_type'],
'','',
array('class'=>'quickselect')));
$form->addElement(form_makeButton('submit', 'recent', $lang['btn_apply']));
}
$form->addElement(form_makeOpenTag('ul'));
foreach($recents as $recent){
$date = dformat($recent['date']);
if ($recent['type']===DOKU_CHANGE_TYPE_MINOR_EDIT)
$form->addElement(form_makeOpenTag('li', array('class' => 'minor')));
else
$form->addElement(form_makeOpenTag('li'));
$form->addElement(form_makeOpenTag('div', array('class' => 'li')));
if ($recent['media']) {
$form->addElement(media_printicon($recent['id']));
} else {
$icon = DOKU_BASE.'lib/images/fileicons/file.png';
$form->addElement('<img src="'.$icon.'" alt="'.$filename.'" class="icon" />');
}
$form->addElement(form_makeOpenTag('span', array('class' => 'date')));
$form->addElement($date);
$form->addElement(form_makeCloseTag('span'));
$diff = (count(getRevisions($recent['id'], 0, 1, 8192, true)) && @file_exists(mediaFN($recent['id'])));
if ($diff) {
$href = media_managerURL(array('tab_details' => 'history',
'mediado' => 'diff', 'image' => $recent['id'], 'ns' => getNS($recent['id'])), '&');
}
} else {
$href = wl($recent['id'],"do=diff", false, '&');
}
if ($recent['media'] && !$diff) {
$form->addElement('<img src="'.DOKU_BASE.'lib/images/blank.gif" width="15" height="11" alt="" />');
} else {
$form->addElement(form_makeOpenTag('a', array('class' => 'diff_link', 'href' => $href)));
$form->addElement(form_makeTag('img', array(
'src' => DOKU_BASE.'lib/images/diff.png',
'width' => 15,
'height'=> 11,
'title' => $lang['diff'],
'alt' => $lang['diff']
)));
$form->addElement(form_makeCloseTag('a'));
}
$href = media_managerURL(array('tab_details' => 'history',
'image' => $recent['id'], 'ns' => getNS($recent['id'])), '&');
} else {
$href = wl($recent['id'],"do=revisions",false,'&');
}
$form->addElement(form_makeOpenTag('a', array('class' => 'revisions_link', 'href' => $href)));
$form->addElement(form_makeTag('img', array(
'src' => DOKU_BASE.'lib/images/history.png',
'width' => 12,
'height'=> 14,
'title' => $lang['btn_revs'],
'alt' => $lang['btn_revs']
)));
$form->addElement(form_makeCloseTag('a'));
$href = media_managerURL(array('tab_details' => 'view', 'image' => $recent['id'], 'ns' => getNS($recent['id'])), '&');
$class = (file_exists(mediaFN($recent['id']))) ? 'wikilink1' : $class = 'wikilink2';
$form->addElement(form_makeOpenTag('a', array('class' => $class, 'href' => $href)));
$form->addElement($recent['id']);
$form->addElement(form_makeCloseTag('a'));
} else {
$form->addElement(html_wikilink(':'.$recent['id'],useHeading('navigation')?null:$recent['id']));
}
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
$form->addElement(form_makeOpenTag('span', array('class' => 'sum')));
$form->addElement(' – '.htmlspecialchars($recent['sum']));
$form->addElement(form_makeCloseTag('span'));
$form->addElement(form_makeOpenTag('span', array('class' => 'user')));
if($recent['user']){
$form->addElement(editorinfo($recent['user']));
if(auth_ismanager()){
$form->addElement(' ('.$recent['ip'].')');
}
}else{
$form->addElement($recent['ip']);
}
$form->addElement(form_makeCloseTag('span'));
$form->addElement(form_makeCloseTag('div'));
$form->addElement(form_makeCloseTag('li'));
}
$form->addElement(form_makeCloseTag('ul'));
$form->addElement(form_makeOpenTag('div', array('class' => 'pagenav')));
$last = $first + $conf['recent'];
if ($first > 0) {
$first -= $conf['recent'];
if ($first < 0) $first = 0;
$form->addElement(form_makeOpenTag('div', array('class' => 'pagenav-prev')));
$form->addElement(form_makeTag('input', array(
'type' => 'submit',
'name' => 'first['.$first.']',
'value' => $lang['btn_newer'],
'accesskey' => 'n',
'title' => $lang['btn_newer'].' [N]',
)));
$form->addElement(form_makeCloseTag('div'));
}
if ($hasNext) {
$form->addElement(form_makeOpenTag('div', array('class' => 'pagenav-next')));
$form->addElement(form_makeTag('input', array(
'type' => 'submit',
'name' => 'first['.$last.']',
'value' => $lang['btn_older'],
'accesskey' => 'p',
'title' => $lang['btn_older'].' [P]',
)));
$form->addElement(form_makeCloseTag('div'));
}
$form->addElement(form_makeCloseTag('div'));
/**
* Display page index
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
global $conf;
global $ID;
$dir = $conf['datadir'];
$ns = cleanID($ns);
#fixme use appropriate function
if(empty($ns)){
$ns = dirname(str_replace(':','/',$ID));
if($ns == '.') $ns ='';
}
$ns = utf8_encodeFN(str_replace(':','/',$ns));
echo p_locale_xhtml('index');
echo '<div id="index__tree">';
$data = array();
search($data,$conf['datadir'],'search_index',array('ns' => $ns));
echo html_buildlist($data,'idx','html_list_index','html_li_index');
echo '</div>';
global $ID;
$ret = '';
$base = ':'.$item['id'];
$base = substr($base,strrpos($base,':')+1);
if($item['type']=='d'){
$ret .= '<a href="'.wl($ID,'idx='.rawurlencode($item['id'])).'" class="idx_dir"><strong>';
$ret .= $base;
$ret .= '</strong></a>';
}else{
$ret .= html_wikilink(':'.$item['id']);
}
return $ret;
* This user function is used in html_buildlist 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){
* 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.
* Both user functions can be given as array to point to
* a member of an object.
*
function html_buildlist($data,$class,$func,$lifunc='html_li_default'){
if (count($data) === 0) {
return '';
}
// Trigger building a wrapper ul if the first level is
// 0 (we have a root object) or 1 (just the root content)
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";
}
} elseif ($ret !== '') {
//remember current level
$level = $item['level'];
//print item
$ret .= call_user_func($lifunc,$item);
$ret .= '<div class="li">';
$ret .= call_user_func($func,$item);
$ret .= '</div>';
}
/**
* display backlinks
*
* @author Andreas Gohr <andi@splitbrain.org>
* @author Michael Klier <chi@chimeric.de>
global $ID;
global $conf;
global $lang;
print p_locale_xhtml('backlinks');
$data = ft_backlinks($ID);
if(!empty($data)) {
print '<ul class="idx">';
foreach($data as $blink){
print '<li><div class="li">';
print html_wikilink(':'.$blink,useHeading('navigation')?null:$blink);
print '</div></li>';
}
print '</ul>';
} else {
print '<div class="level1"><p>' . $lang['nothingfound'] . '</p></div>';
}
function html_diff_head($l_rev, $r_rev, $id = null, $media = false) {
global $lang;
if ($id === null) {
global $ID;
$id = $ID;
}
$media_or_wikiFN = $media ? 'mediaFN' : 'wikiFN';
$ml_or_wl = $media ? 'ml' : 'wl';
$l_minor = $r_minor = '';
if(!$l_rev){
$l_head = '—';
}else{
$l_info = getRevisionInfo($id,$l_rev,true, $media);
if($l_info['user']){
$l_user = editorinfo($l_info['user']);