[selectable index looks]
こんな感じです。
IndexPageにおいて、ページの種類(全ページ|通常ページ|凍結ページ|認証済みページ|非公開ページ)と、表示の形式(リスト|番号付きリスト|ツリー)を変更できるようになります。
resource.txtへの追加
allpage | 全ページ |
normalpage | 通常ページ |
frozenpage | 凍結ページ |
certifiedpage | 認証済みページ |
secretpage | 非公開ページ |
listlooks | リスト |
sequencelooks | 番号付きリスト |
treelooks | ツリー |
@cookie_listに追加
my @cookie_list = ('mypassword','myname','myindexlooks','mycss'); # yakty add [use cookie]
print_indexform()追加
# yakty add [selectable index looks] start sub print_indexform { my ($admin) = @_; $form{myindextarget} = 'all' if(length($form{myindextarget}) == 0); $form{myindexlooks} = 'tree' if(length($form{myindexlooks}) == 0); print <<"EOD"; <form action="$url_cgi" method="get"> <input type="hidden" name="mycmd" value="index" /> <select name="myindextarget"> <option value="all" @{[ $form{myindextarget} eq 'all' ? qq(selected="1") : '' ]}>$resource{allpage}</option> <option value="normal" @{[ $form{myindextarget} eq 'normal' ? qq(selected="1") : '' ]}>$resource{normalpage}</option> <option value="frozen" @{[ $form{myindextarget} eq 'frozen' ? qq(selected="1") : '' ]}>$resource{frozenpage}</option> <option value="certified" @{[ $form{myindextarget} eq 'certified' ? qq(selected="1") : '' ]}>$resource{certifiedpage}</option> @{[$admin ? qq(<option value="secret" @{[ $form{myindextarget} eq 'secret' ? qq(selected="1") : '' ]}>$resource{secretpage}</option>) : '' ]} </select> <select name="myindexlooks"> <option value="list" @{[ $form{myindexlooks} eq 'list' ? qq(selected="1") : '' ]}>$resource{listlooks}</option> <option value="sequence" @{[ $form{myindexlooks} eq 'sequence' ? qq(selected="1") : '' ]}>$resource{sequencelooks}</option> <option value="tree" @{[ $form{myindexlooks} eq 'tree' ? qq(selected="1") : '' ]}>$resource{treelooks}</option> </select> <input type="submit" value="$resource{indexbutton}" /> </form> EOD } # yakty add [selectable index looks] end
do_index()変更
- 2003-07-31 (Thu) 10:27:09 ツリー表示以外でsubjectlineを表示するのを忘れていたので追加
# yakty add [selectable index looks] start sub do_index { &print_header($IndexPage); my $admin = &valid_password($form{mypassword}); # yakty add [secret page] &print_indexform($admin); my $listtag = ($form{myindexlooks} eq 'sequence') ? 'ol' : 'ul'; print qq(<div class="text">); # yakty add [toc & text block] print qq(<$listtag>); my %trees; my $level = 0; my $prev; my @pages = ($sort_case_sense) ? (sort keys(%database)) : sort {lc($a) cmp lc($b)} keys(%database); foreach my $page (@pages){ my @category; next if(not &is_editable($page)); my $frozen = &is_frozen($page); next if(not $admin and $frozen == $frozen_secret); # yakty add [secret page] if($form{myindextarget} ne 'all'){ next if($frozen == 0 and $form{myindextarget} ne 'normal'); next if($frozen == $frozen_frozen and $form{myindextarget} ne 'frozen'); next if($frozen == $frozen_certified and $form{myindextarget} ne 'certified'); next if($frozen == $frozen_secret and $form{myindextarget} ne 'secret'); } if($form{myindexlooks} eq 'tree'){ foreach (split /\//, $page) { my $parent = join '/', @category; $parent = lc($parent) if($sort_case_sense); # 一覧で大文字/小文字を無視 push @category, $_; my $categorytree = join '/', @category; next if($trees{$categorytree}); $trees{$categorytree} = 1; if($prev ne $parent){ print qq(</$listtag>) x ($level - $#category); print qq(<$listtag>) x ($#category - $level); $prev = $parent; $level = $#category; } my $chunk = &armor_name($categorytree); my $link = defined($link_cache{$chunk}) ? $link_cache{$chunk} : &make_link($chunk); #my $link = &make_link(&armor_name($categorytree)); $link =~ s|(<a.*?>)[^<]+/([^<]+)(</a>)|$1$2$3|; if($database{$categorytree}){ my $frozen = &is_frozen($categorytree); if(&is_editable($categorytree)){ if(not $admin and $frozen == $frozen_secret){ print qq(<li>$categorytree</li>\n); } elsif($form{myindextarget} eq 'all' or ($frozen == 0 and $form{myindextarget} eq 'normal') or ($frozen == $frozen_frozen and $form{myindextarget} eq 'frozen') or ($frozen == $frozen_certified and $form{myindextarget} eq 'certified') or ($frozen == $frozen_secret and $form{myindextarget} eq 'secret')){ print qq(<li>$link@{[&escape(&get_subjectline($categorytree))]}</li>\n); } else { print qq(<li>$categorytree</li>\n); } } else { print qq(<li>$categorytree</li>\n); } } else { print qq(<li>$link</li>\n); } } } else { my $chunk = &armor_name($page); my $link = defined($link_cache{$chunk}) ? $link_cache{$chunk} : &make_link($chunk); #my $link = &make_link(&armor_name($page)); print qq(<li>$link@{[&escape(&get_subjectline($page))]}</li>); } } print qq(</$listtag>) x ($level + 1); print qq(</div>); # yakty add [toc & text block] &print_footer($IndexPage); } # yakty add [selectable index looks] end