Skip to content
Snippets Groups Projects
Commit cb70c441 authored by andi's avatar andi
Browse files

fancy index

darcs-hash:20050115205741-9977f-75c87471f0c801a8b623e2a0af53896331f80975.gz
parent f1b8b946
No related branches found
No related tags found
No related merge requests found
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
images/open.gif 0 → 100644
NaN GiB (NaN%)
View file @ cb70c441
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
...@@ -663,7 +663,7 @@ function html_index($ns){ ...@@ -663,7 +663,7 @@ function html_index($ns){
$data = array(); $data = array();
search($data,$conf['datadir'],'search_index',array('ns' => $ns)); search($data,$conf['datadir'],'search_index',array('ns' => $ns));
print html_buildlist($data,'idx','html_list_index'); print html_buildlist($data,'idx','html_list_index','html_li_index');
} }
/** /**
...@@ -687,17 +687,47 @@ function html_list_index($item){ ...@@ -687,17 +687,47 @@ function html_list_index($item){
return $ret; return $ret;
} }
/**
* 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 * Build an unordered list
* *
* Build an unordered list from the given $data array * Build an unordered list from the given $data array
* Each item in the array has to have a 'level' property * Each item in the array has to have a 'level' property
* the item itself gets printed by the given $func user * the item itself gets printed by the given $func user
* function * function. The second and optional function is used to
* print the <li> tag. Both user function need to accept
* a single item.
* *
* @author Andreas Gohr <andi@splitbrain.org> * @author Andreas Gohr <andi@splitbrain.org>
*/ */
function html_buildlist($data,$class,$func){ function html_buildlist($data,$class,$func,$lifunc='html_li_default'){
$level = 0; $level = 0;
$opens = 0; $opens = 0;
$ret = ''; $ret = '';
...@@ -723,7 +753,7 @@ function html_buildlist($data,$class,$func){ ...@@ -723,7 +753,7 @@ function html_buildlist($data,$class,$func){
$level = $item['level']; $level = $item['level'];
//print item //print item
$ret .= '<li class="level'.$item['level'].'">'; $ret .= $lifunc($item); //user function
$ret .= '<span class="li">'; $ret .= '<span class="li">';
$ret .= $func($item); //user function $ret .= $func($item); //user function
$ret .= '</span>'; $ret .= '</span>';
......
...@@ -79,6 +79,8 @@ function search(&$data,$base,$func,$opts,$dir='',$lvl=1){ ...@@ -79,6 +79,8 @@ function search(&$data,$base,$func,$opts,$dir='',$lvl=1){
function search_index(&$data,$base,$file,$type,$lvl,$opts){ function search_index(&$data,$base,$file,$type,$lvl,$opts){
$return = true; $return = true;
$item = array();
if($type == 'd' && !preg_match('#^'.$file.'(/|$)#','/'.$opts['ns'])){ if($type == 'd' && !preg_match('#^'.$file.'(/|$)#','/'.$opts['ns'])){
//add but don't recurse //add but don't recurse
$return = false; $return = false;
...@@ -95,7 +97,8 @@ function search_index(&$data,$base,$file,$type,$lvl,$opts){ ...@@ -95,7 +97,8 @@ function search_index(&$data,$base,$file,$type,$lvl,$opts){
$data[]=array( 'id' => $id, $data[]=array( 'id' => $id,
'type' => $type, 'type' => $type,
'level' => $lvl ); 'level' => $lvl,
'open' => $return );
return $return; return $return;
} }
......
...@@ -368,6 +368,14 @@ span.li { ...@@ -368,6 +368,14 @@ span.li {
font-weight: normal; font-weight: normal;
} }
li.open {
list-style-image: url(images/open.gif);
}
li.closed {
list-style-image: url(images/closed.gif);
}
.quote { .quote {
border-left: 2px solid #8cacbb; border-left: 2px solid #8cacbb;
padding-left: 3px; padding-left: 3px;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment