sub page_btn { my ($i,$pg,$pgmax) = @_;my $I = $i; $pgmax ||= 10; # 表示範囲 my $from = $pg + 1; my $to = $pg + $pgmax > $i ? $i : $pg + $pgmax; my $pg_btn = "$from - $to [ $i件中 ]"; # ページ繰越ボタン作成 if ($pg - $pgmax >= 0 || $pg + $pgmax < $i) { # 引数 my $param = "mode=$in{mode}"; if ($in{word} ne '') { my $word = &url_enc($in{word}); $param .= "&word=$word&cond=$in{cond}&list=$pgmax"; } $param .= "&cat=$in{cat}"; $param .= "&sub=$in{sub}" if ($in{sub} ne ''); # ページボタン $pg_btn .= "   Page: "; my $maxindex = 10; # インデックスの最大数 if ($in{'strt'} > 0) { my $back = $in{strt} - $maxindex; $back = 0 if $back < 0; $pg_btn .= "←前へ  "; } my ($x, $y) = (1, 0); while ($i > 0) { if (($in{strt} - 1)*$pgmax < $_[0] - $i && ($in{strt} + $maxindex)*$pgmax > $_[0] - $i) { if ($pg == $y) { $pg_btn .= qq(| $x ); } else { $pg_btn .= qq(| $x ); } } $x++; $y += $pgmax; $i -= $pgmax; } $pg_btn .= "|"; if ($_[0] > ($in{strt} + $maxindex) * $pgmax) { my $front = $in{strt} + $maxindex; $front = int($_[0] / $pgmax) - $maxindex + 1 if $front > int($_[0] / $pgmax) - $maxindex + 1; $pg_btn .= "  次へ→"; } } return $pg_btn; }