diff --git a/SubPageList3.php b/SubPageList3-ASCA.php index b70d050..054af48 100755 --- a/SubPageList3.php +++ b/SubPageList3-ASCA.php @@ -64,6 +64,15 @@ class SubPageList3 { * @var string order type */ private $order = 'asc'; + + /** + * highlight color for subpage tree + * Can be: + * - -1 (bold) + * - any CSS-type string describing a color + * @var string order type + */ + private $highlight_color = -1; /** * column that's used as order method @@ -263,10 +272,20 @@ class SubPageList3 { $this->mode = 'bar'; $this->token = ' ยท '; break; + case 'collapsible': + $this->mode = 'collapsible'; + $this->token = ''; + break; default: $this->error( wfMessage( 'spl3_debug', 'liststyle' )->escaped() ); } } + if ( isset( $options['highlight-color'] ) ) { + $this->highlight_color = $options['highlight-color']; + } + else { + $this->highlight_color = -1; + } if ( isset( $options['parent'] ) ) { if ( intval( $options['parent'] ) == -1 ) { $this->parent = -1; @@ -436,7 +455,7 @@ class SubPageList3 { default: throw new LogicException( "Can not happen" ); } - return ' [[' . $title->getPrefixedText() . '|' . $linktitle . ']]'; + return ' [[' . $title->getPrefixedText() . '|' . $linktitle . ']]'; } /** @@ -463,13 +482,34 @@ class SubPageList3 { } # add descendants $parlv = substr_count( $this->ptitle->getPrefixedText(), '/' ); - foreach ( $titles as $title ) { + + $lv_list = []; + // recording a array to know if each element is the last of the list + foreach ( $titles as $index=>$title ) { + $lv_list[$index] = substr_count( $title, '/' ) - $parlv; + if ( $this->kidsonly != 1 || $lv_list[$index] < 2 ) { + if ( $this->showparent ) { + $lv_list[$index]++; + } + } + + } + + foreach ( $titles as $index=>$title ) { $lv = substr_count( $title, '/' ) - $parlv; + if ( $this->kidsonly != 1 || $lv < 2 ) { if ( $this->showparent ) { $lv++; } + $ss = ""; + + if ($this->mode == 'collapsible' && $index > 0){ + for ($j = 0 ; $j < ($lv_list[$index-1] - $lv_list[$index]) ; $j++) + $ss .= ''; + } + if ( $this->mode == 'bar' ) { if ( $c > 0 ) { $ss .= $this->token; @@ -479,7 +519,34 @@ class SubPageList3 { $ss .= $this->token; } } + $is_elt_final = false; + if ($index == count($titles)-1 || $lv_list[$index] >= $lv_list[$index+1]) + $is_elt_final = true; + if ($this->mode == 'collapsible') { + if ($is_elt_final) + $ss .= '