X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=NDWeb%2FPages%2FForum.pm;h=5951be73071350adc42d03afdbcf4a4726330bc2;hb=f091970c5fb3cb60583c1d00aaef3b00191feacb;hp=ac28bb023394e28ad7828cfc6a33e73d70e67d64;hpb=a074bd17f5e8ba341a22bbfca1da7093b8351774;p=ndwebbie.git diff --git a/NDWeb/Pages/Forum.pm b/NDWeb/Pages/Forum.pm index ac28bb0..5951be7 100644 --- a/NDWeb/Pages/Forum.pm +++ b/NDWeb/Pages/Forum.pm @@ -32,7 +32,10 @@ $NDWeb::Page::PAGES{forum} = __PACKAGE__; sub parse { my $self = shift; if ($self->{URI} =~ m{^/.*/allUnread}){ - param('allUnread',1); + $self->{allUnread} = 1; + }elsif ($self->{URI} =~ m{^/.*/search(?:/(.*))?}){ + bless $self, 'NDWeb::Pages::Forum::Search'; + $self->{PAGE} = 'forum/search'; } } @@ -155,7 +158,7 @@ sub render_body { ,undef,$thread->{fcid}) or $ND::ERROR .= p($DBH->errstr); $BODY->param(Category => $category); - }elsif(defined param('allUnread')){ #List threads in this board + }elsif(defined $self->{allUnread}){ #List threads in this board $BODY->param(AllUnread => 1); $BODY->param(Id => $board->{id}); my ($time) = $DBH->selectrow_array('SELECT now()::timestamp',undef); @@ -168,16 +171,13 @@ sub render_body { while (my $board = $boards->fetchrow_hashref){ next if $board->{id} < 0; $threads->execute($board->{id},$ND::UID,1) or $ND::ERROR .= p($DBH->errstr); - my $i = 0; my @threads; while (my $thread = $threads->fetchrow_hashref){ - $i++; - $thread->{Odd} = $i % 2; push @threads,$thread; } $board->{Threads} = \@threads; delete $board->{post}; - push @boards,$board if $i > 0; + push @boards,$board if $threads->rows > 0; } $category->{Boards} = \@boards; delete $category->{id}; @@ -196,11 +196,8 @@ sub render_body { my ($time) = $DBH->selectrow_array('SELECT now()::timestamp',undef); $BODY->param(Date => $time); $threads->execute($board->{id},$ND::UID,0) or $ND::ERROR .= p($DBH->errstr); - my $i = 0; my @threads; while (my $thread = $threads->fetchrow_hashref){ - $i++; - $thread->{Odd} = $i % 2; push @threads,$thread; } $BODY->param(Threads => \@threads); @@ -226,8 +223,6 @@ sub render_body { my ($category) = $DBH->selectrow_array(q{SELECT category FROM forum_categories WHERE fcid = $1} ,undef,$board->{fcid}) or $ND::ERROR .= p($DBH->errstr); $BODY->param(Category => $category); - - }elsif($self->{URI} =~ m{^/.*/search/(.*)}){ #List threads in this board }else{ #List boards $BODY->param(Overview => 1); $categories->execute or $ND::ERROR .= p($DBH->errstr); @@ -241,15 +236,12 @@ sub render_body { while (my $category = $categories->fetchrow_hashref){ $boards->execute($category->{id},$ND::UID) or $ND::ERROR .= p($DBH->errstr); my @boards; - my $i = 0; while (my $board = $boards->fetchrow_hashref){ - $i++; - $board->{Odd} = $i % 2; push @boards,$board; } $category->{Boards} = \@boards; delete $category->{id}; - push @categories,$category if $i > 0; + push @categories,$category if $boards->rows > 0; } $BODY->param(Categories => \@categories);