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");
if (!defined('SEC_EDIT_PATTERN')) {
define('SEC_EDIT_PATTERN', '#<!-- EDIT({.*?}) -->#');
* @param string $id id of the target page
* @param string $name the name of the link, i.e. the text that is displayed
* @param string|array $search search string(s) that shall be highlighted in the target page
* @return string the HTML code of the link
function html_wikilink($id,$name=null,$search=''){
/** @var Doku_Renderer_xhtml $xhtml_renderer */
static $xhtml_renderer = null;
if(is_null($xhtml_renderer)){
$xhtml_renderer = p_get_renderer('xhtml');
}
return $xhtml_renderer->internallink($id,$name,$search,true,'navigation');
* @author Andreas Gohr <andi@splitbrain.org>
*
* @param bool $svg Whether to show svg icons in the register and resendpwd links or not
function html_login($svg = false){
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', ((!$INPUT->bool('http_credentials')) ? $INPUT->str('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();
$registerLink = (new \dokuwiki\Menu\Item\Register())->asHtmlLink('', $svg);
$form->addElement('<p>'.$lang['reghere'].': '. $registerLink .'</p>');
$resendPwLink = (new \dokuwiki\Menu\Item\Resendpwd())->asHtmlLink('', $svg);
$form->addElement('<p>'.$lang['pwdforget'].': '. $resendPwLink .'</p>');
html_form('login', $form);
/**
* Denied page content
*
* @return string html
*/
function html_denied() {
print p_locale_xhtml('denied');
if(empty($_SERVER['REMOTE_USER']) && actionOK('login')){
* inserts section edit buttons if wanted or removes the markers
*
* @param string $text
* @param bool $show show section edit buttons?
* @return string
function html_secedit($text,$show=true){
if(!$INFO['writable'] || !$show || $INFO['rev']){
return preg_replace(SEC_EDIT_PATTERN,'',$text);
return preg_replace_callback(SEC_EDIT_PATTERN,
* prepares section edit button data for event triggering
* used as a callback in html_secedit
*
* @param array $matches matches with regexp
* @return string
* @triggers HTML_SECEDIT_BUTTON
function html_secedit_button($matches){
$json = htmlspecialchars_decode($matches[1], ENT_QUOTES);
$data = json_decode($json, true);
$data ['target'] = strtolower($data['target']);
$data ['hid'] = strtolower($data['hid']);
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>
*
* @param array $data name, section id and target
* @return string html
*/
function html_secedit_get_button($data) {
global $ID;
Michael Hamann
committed
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>
*
* @return string html
$ret = '<a class="nolink" href="#dokuwiki__top"><button class="button" onclick="window.scrollTo(0, 0)" title="'.$lang['btn_top'].'">'.$lang['btn_top'].'</button></a>';
/**
* Displays a button (using its own form)
* If tooltip exists, the access key tooltip is replaced.
*
* @param string $name
* @param string $id
* @param string $akey access key
* @param string[] $params key-value pairs added as hidden inputs
* @param string $method
* @param string $tooltip
* @param bool|string $label label text, false: lookup btn_$name in localization
* @param string $svg (optional) svg code, inserted into the button
function html_btn($name, $id, $akey, $params, $method='get', $tooltip='', $label=false, $svg=null){
Anika Henke
committed
if (!$label)
$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{
$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)){
Anika Henke
committed
$ret .= '<button type="submit" ';
if($akey){
$tip .= ' ['.strtoupper($akey).']';
$ret .= 'accesskey="'.$akey.'" ';
}
if ($svg) {
$ret .= '<span>' . hsc($label) . '</span>';
$ret .= inlineSVG($svg);
} else {
$ret .= hsc($label);
}
Anika Henke
committed
$ret .= '</button>';
/**
* show a revision warning
*
* @author Szymon Olewniczak <dokuwiki@imz.re>
*/
function html_showrev() {
print p_locale_xhtml('showrev');
*
* @param null|string $txt wiki text or null for showing $ID
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;
}
Anika Henke
committed
echo '<div class="preview"><div class="pad">';
$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>';
Anika Henke
committed
echo '</div></div>';
$data = array('rev' => &$REV, 'date_at' => &$DATE_AT);
trigger_event('HTML_SHOWREV_OUTPUT', $data, 'html_showrev');
}
$html = p_wiki_xhtml($ID,$REV,true,$DATE_AT);
$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(){
$draft = new \dokuwiki\Draft($ID, $INFO['client']);
$text = $draft->getDraftText();
html_diff($text, false);
$form = new Doku_Form(array('id' => 'dw__editform'));
$form->addHidden('date', $draft->getDraftDate());
$form->addElement(form_makeOpenTag('div', array('id'=>'draft__status')));
$form->addElement($draft->getDraftMessage());
$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>
*
* @param string $html
* @param array|string $phrases
* @return string html
function html_hilight($html,$phrases){
$phrases = (array) $phrases;
$phrases = array_map('preg_quote_cb', $phrases);
$phrases = array_map('ft_snippet_re_preprocess', $phrases);
$phrases = array_filter($phrases);
$regex = join('|',$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>
*
* @param array $m matches
* @return string html
function html_hilight_callback($m) {
$hlight = unslash($m[0]);
if ( !isset($m[2])) {
$hlight = '<span class="search_hit">'.$hlight.'</span>';
}
return $hlight;
/**
* 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>';
/**
* list old revisions
*
* @author Andreas Gohr <andi@splitbrain.org>
*
* @param int $first skip the first n changelog lines
* @param bool|string $media_id id of media, or false for current page
global $ID;
global $INFO;
global $conf;
global $lang;
if ($media_id) {
$id = $media_id;
$changelog = new MediaChangeLog($id);
} else {
$changelog = new PageChangeLog($id);
}
/* we need to get one additional log entry to be able to
* decide if this is the last page or is there another one.
* see html_recent()
*/
$revisions = $changelog->getRevisions($first, $conf['recent']+1);
if(count($revisions)==0 && $first!=0){
$first=0;
$revisions = $changelog->getRevisions($first, $conf['recent']+1);
$hasNext = false;
if (count($revisions)>$conf['recent']) {
$hasNext = true;
array_pop($revisions); // remove extra log entry
$params = array('id' => 'page__revisions', 'class' => 'changes');
if($media_id) {
$params['action'] = media_managerURL(array('image' => $media_id), '&');
}
if(!$media_id) {
$exists = $INFO['exists'];
$display_name = useHeading('navigation') ? hsc(p_get_first_heading($id)) : $id;
if(!$display_name) {
$display_name = $id;
}
} else {
$exists = file_exists(mediaFN($id));
$display_name = $id;
}
if($exists && $first == 0) {
$minor = false;
if($media_id) {
$date = dformat(@filemtime(mediaFN($id)));
$href = media_managerURL(array('image' => $id, 'tab_details' => 'view'), '&');
$changelog->setChunkSize(1024);
$revinfo = $changelog->getRevisionInfo(@filemtime(fullpath(mediaFN($id))));
$summary = $revinfo['sum'];
if($revinfo['user']) {
$editor = $revinfo['user'];
} else {
$editor = $revinfo['ip'];
}
$sizechange = $revinfo['sizechange'];
} else {
$date = dformat($INFO['lastmod']);
if(isset($INFO['meta']) && isset($INFO['meta']['last_change'])) {
if($INFO['meta']['last_change']['type'] === DOKU_CHANGE_TYPE_MINOR_EDIT) {
$minor = true;
}
if(isset($INFO['meta']['last_change']['sizechange'])) {
$sizechange = $INFO['meta']['last_change']['sizechange'];
} else {
$sizechange = null;
}
}
$pagelog = new PageChangeLog($ID);
$latestrev = $pagelog->getRevisions(-1, 1);
$latestrev = array_pop($latestrev);
$href = wl($id,"rev=$latestrev",false,'&');
$summary = $INFO['sum'];
$editor = $INFO['editor'];
}
$form->addElement(form_makeOpenTag('li', array('class' => ($minor ? 'minor' : ''))));
$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="" />');
$form->addElement(form_makeOpenTag('a', array(
'class' => 'wikilink1',
$form->addElement($display_name);
if ($media_id) $form->addElement(form_makeOpenTag('div'));
$form->addElement(form_makeOpenTag('span', array('class' => 'sum')));
if(!$media_id) $form->addElement(' – ');
$form->addElement('<bdi>' . hsc($summary) . '</bdi>');
$form->addElement(form_makeCloseTag('span'));
}
$form->addElement(form_makeOpenTag('span', array('class' => 'user')));
$form->addElement((empty($editor))?('('.$lang['external_edit'].')'):'<bdi>'.editorinfo($editor).'</bdi>');
$form->addElement(form_makeCloseTag('span'));
html_sizechange($sizechange, $form);
if ($media_id) $form->addElement(form_makeCloseTag('div'));
$form->addElement(form_makeCloseTag('div'));
$form->addElement(form_makeCloseTag('li'));
$info = $changelog->getRevisionInfo($rev);
if($media_id) {
$exists = file_exists(mediaFN($id, $rev));
} else {
$exists = page_exists($id, $rev);
$class = '';
if($info['type'] === DOKU_CHANGE_TYPE_MINOR_EDIT) {
$class = 'minor';
}
$form->addElement(form_makeOpenTag('li', array('class' => $class)));
$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(
'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'));
if (!$media_id) {
$href = wl($id,"rev=$rev",false,'&');
} else {
$href = media_managerURL(array('image' => $id, 'tab_details' => 'view', 'rev' => $rev), '&');
}
$form->addElement(form_makeOpenTag('a', array(
'class' => 'wikilink1',
'href' => $href)));
$form->addElement($display_name);
$form->addElement(form_makeCloseTag('a'));
}else{
Anika Henke
committed
$form->addElement('<img src="'.DOKU_BASE.'lib/images/blank.gif" width="15" height="11" alt="" />');
$form->addElement($display_name);
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('<bdi>'.hsc($info['sum']).'</bdi>');
$form->addElement(form_makeCloseTag('span'));
}
$form->addElement(form_makeOpenTag('span', array('class' => 'user')));
if($info['user']){
$form->addElement('<bdi>'.editorinfo($info['user']).'</bdi>');
$form->addElement(' <bdo dir="ltr">('.$info['ip'].')</bdo>');
$form->addElement('<bdo dir="ltr">'.$info['ip'].'</bdo>');
}
$form->addElement(form_makeCloseTag('span'));
html_sizechange($info['sizechange'], $form);
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>
*
* @param int $first
* @param string $show_changes
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.
*/
if($show_changes == 'mediafiles' && $conf['mediarevisions']) {
$flags = RECENTS_MEDIA_CHANGES;
$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 = true;
array_pop($recents); // remove extra log entry
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', 'class' => 'changes'));
$form->addHidden('sectok', null);
$form->addHidden('do', 'recent');
$form->addHidden('id', $ID);
$form->addElement(form_makeListboxField(
'show_changes',
array(
'pages' => $lang['pages_changes'],
'mediafiles' => $lang['media_changes'],
$show_changes,
$lang['changes_type'],
$form->addElement(form_makeButton('submit', 'recent', $lang['btn_apply']));
$class = '';
if($recent['type'] === DOKU_CHANGE_TYPE_MINOR_EDIT) {
$class = 'minor';
}
$form->addElement(form_makeOpenTag('li', array('class' => $class)));
$form->addElement(form_makeOpenTag('div', array('class' => 'li')));
$form->addElement(media_printicon($recent['id']));
} else {
$icon = DOKU_BASE . 'lib/images/fileicons/file.png';
$form->addElement('<img src="' . $icon . '" alt="' . $recent['id'] . '" class="icon" />');
$form->addElement(form_makeOpenTag('span', array('class' => 'date')));
$form->addElement($date);
$form->addElement(form_makeCloseTag('span'));
Michael Hamann
committed
$diff = false;
$href = '';
$changelog = new MediaChangeLog($recent['id']);
$revs = $changelog->getRevisions(0, 1);
$diff = (count($revs) && file_exists(mediaFN($recent['id'])));
'tab_details' => 'history',
'mediado' => 'diff',
'image' => $recent['id'],
'ns' => getNS($recent['id'])
), '&');
if(!empty($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'])), '&');
$form->addElement(form_makeOpenTag('a', array(
'class' => 'revisions_link',
'src' => DOKU_BASE . 'lib/images/history.png',
'width' => 12,
'height' => 14,
'title' => $lang['btn_revs'],
'alt' => $lang['btn_revs']
)));
$href = media_managerURL(array('tab_details' => 'view', 'image' => $recent['id'], 'ns' => getNS($recent['id'])), '&');
$class = file_exists(mediaFN($recent['id'])) ? 'wikilink1' : 'wikilink2';
$form->addElement(form_makeOpenTag('a', array(
'class' => $class,
$form->addElement($recent['id']);
$form->addElement(form_makeCloseTag('a'));
} else {
$form->addElement(html_wikilink(':' . $recent['id'], useHeading('navigation') ? null : $recent['id']));
$form->addElement(form_makeOpenTag('span', array('class' => 'sum')));
$form->addElement(' – ' . hsc($recent['sum']));
$form->addElement(form_makeCloseTag('span'));
$form->addElement(form_makeOpenTag('span', array('class' => 'user')));
if($recent['user']) {
$form->addElement('<bdi>' . editorinfo($recent['user']) . '</bdi>');
if(auth_ismanager()) {
$form->addElement(' <bdo dir="ltr">(' . $recent['ip'] . ')</bdo>');
} else {
$form->addElement('<bdo dir="ltr">' . $recent['ip'] . '</bdo>');
}
$form->addElement(form_makeCloseTag('span'));
html_sizechange($recent['sizechange'], $form);
$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'];
$form->addElement(form_makeOpenTag('div', array('class' => 'pagenav-prev')));
Anika Henke
committed
$form->addElement(form_makeOpenTag('button', array(
'type' => 'submit',
'name' => 'first[' . $first . ']',
'accesskey' => 'n',
'title' => $lang['btn_newer'] . ' [N]',
'class' => 'button show'
Anika Henke
committed
$form->addElement($lang['btn_newer']);
$form->addElement(form_makeCloseTag('button'));
$form->addElement(form_makeCloseTag('div'));
}
$form->addElement(form_makeOpenTag('div', array('class' => 'pagenav-next')));
Anika Henke
committed
$form->addElement(form_makeOpenTag('button', array(
'title' => $lang['btn_older'] . ' [P]',
'class' => 'button show'
)));
Anika Henke
committed
$form->addElement($lang['btn_older']);
$form->addElement(form_makeCloseTag('button'));
$form->addElement(form_makeCloseTag('div'));
}
$form->addElement(form_makeCloseTag('div'));
/**
* Display page index
*
* @author Andreas Gohr <andi@splitbrain.org>
*
* @param string $ns
global $conf;
global $ID;
$ns = cleanID($ns);
if(empty($ns)){
}
$ns = utf8_encodeFN(str_replace(':','/',$ns));
echo p_locale_xhtml('index');
echo '<div id="index__tree" class="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>';
*
* @param array $item
* @return string
global $ID, $conf;
$nofollow = ($ID != $conf['start'] || $conf['sitemap']) ? ' rel="nofollow"' : '';
$ret = '';
$base = ':'.$item['id'];
$base = substr($base,strrpos($base,':')+1);
if($item['type']=='d'){
// FS#2766, no need for search bots to follow namespace links in the index
$ret .= '<a href="'.wl($ID,'idx='.rawurlencode($item['id'])).'" title="' . $item['id'] . '" class="idx_dir"' . $nofollow . '><strong>';
$ret .= $base;
$ret .= '</strong></a>';
}else{
// default is noNSorNS($id), but we want noNS($id) when useheading is off FS#2605
$ret .= html_wikilink(':'.$item['id'], useHeading('navigation') ? null : noNS($item['id']));
* 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>
*
* @param array $item
* @return string html
// scroll to the current item
if($item['id'] == $INFO['id'] && $ACT == 'index') {
$id = ' id="scroll__here"';
return '<li class="level'.$item['level'].$class.'" '.$id.'>';
}elseif($item['open']){
return '<li class="open">';
}else{
return '<li class="closed">';
}
}
/**
* Default List item
*
* @author Andreas Gohr <andi@splitbrain.org>
*
* @param array $item
* @return string html
* 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.
*
* @param array $data array with item arrays
* @param string $class class of ul wrapper
* @param callable $func callback to print an list item
* @param callable $lifunc callback to the opening li tag
* @param bool $forcewrapper Trigger building a wrapper ul if the first level is
Anika Henke
committed
* 0 (we have a root object) or 1 (just the root content)
function html_buildlist($data,$class,$func,$lifunc='html_li_default',$forcewrapper=false){
if (count($data) === 0) {
return '';
}
$firstElement = reset($data);
$start_level = $firstElement['level'];
$ret = '';
$open = 0;
foreach ($data as $item){
if( $item['level'] > $level ){
//open new list
for($i=0; $i<($item['level'] - $level); $i++){