mark: A photo of Mark kneeling on top of the Taal Volcano in the Philippines. It was a long hike. (Default)
Mark Smith ([staff profile] mark) wrote in [site community profile] changelog2009-03-06 04:49 am

[dw-free] FAQ variables not expanded consistently in FAQ titles (questions)

[commit: http://hg.dwscoalition.org/dw-free/rev/172d7378a441]

http://bugs.dwscoalition.org/show_bug.cgi?id=115

More FAQ cleanup.

Patch by [personal profile] pauamma.

Files modified:
  • htdocs/admin/faq/index.bml
--------------------------------------------------------------------------------
diff -r 57d6e3b5d5c0 -r 172d7378a441 htdocs/admin/faq/index.bml
--- a/htdocs/admin/faq/index.bml	Thu Mar 05 06:41:58 2009 +0000
+++ b/htdocs/admin/faq/index.bml	Fri Mar 06 04:49:02 2009 +0000
@@ -5,59 +5,51 @@ body<=
 body<=
 
 <?_code
+{
+    my $dbh = LJ::get_db_writer();
 
- my $dbh = LJ::get_db_writer();
+    my $remote = LJ::get_remote();
+    my %ac_add;
+    my %ac_edit;
+    LJ::remote_has_priv( $remote, "faqadd", \%ac_add );
+    LJ::remote_has_priv( $remote, "faqedit", \%ac_edit );
 
- my $remote = LJ::get_remote();
- my %ac_add;
- my %ac_edit;
- LJ::remote_has_priv($remote, "faqadd", \%ac_add);
- LJ::remote_has_priv($remote, "faqedit", \%ac_edit);
+    my $ret = "";
+    $ret .= "<a href='faqedit.bml'>[Add to FAQ]</a>\n"
+        if %ac_add;
 
- $ret = "";
- if (%ac_add)
- {
-     $ret .= "<A HREF=\"faqedit.bml\">[Add to FAQ]</A>\n";
- }
+    my %faqcat;
+    my %faqq;
+    $sth = $dbh->prepare( "SELECT faqcat, faqcatname, catorder FROM faqcat" );
+    $sth->execute;
+    $faqcat{ $_->{ faqcat } } = $_
+        while $_ = $sth->fetchrow_hashref;
 
- my %faqcat;
- my %faqq;
- $sth = $dbh->prepare("SELECT faqcat, faqcatname, catorder FROM faqcat");
- $sth->execute;
- while ($_ = $sth->fetchrow_hashref)
- {
-     $faqcat{$_->{'faqcat'}} = $_;
- }
- 
- $sth = $dbh->prepare("SELECT faqid, question, sortorder, faqcat, lastmodtime FROM faq");
- $sth->execute;
- while ($_ = $sth->fetchrow_hashref)
- {
-     $faqq{$_->{'faqcat'}}->{$_->{'faqid'}} = $_;
- }
+    $sth = $dbh->prepare( "SELECT faqid, question, sortorder, faqcat, lastmodtime FROM faq" );
+    $sth->execute;
+    $faqq{ $_->{ faqcat } }->{ $_->{ faqid } } = $_
+        while $_ = $sth->fetchrow_hashref;
 
- foreach my $faqcat (sort { $faqcat{$a}->{'catorder'} <=> $faqcat{$b}->{'catorder'} } keys %faqcat)
- {
-     $ret .= "<H2><A HREF=\"readcat.bml?faqcat=$faqcat\">" . LJ::ehtml($faqcat{$faqcat}->{'faqcatname'}) . "</A></H2>\n";
-     $ret .= "<UL>\n";
-     foreach my $faqid (sort { $faqq{$faqcat}->{$a}->{'sortorder'} <=> $faqq{$faqcat}->{$b}->{'sortorder'} } keys %{$faqq{$faqcat}})
-     {
-         my $fe = $faqq{$faqcat}->{$faqid};
-         next unless ($fe->{'question'});
-         my $q = LJ::ehtml($fe->{'question'});
-         $q =~ s/^\s+//; $q =~ s/\s+$//;
-         $q =~ s/\n/<BR>/g;
-         $ret .= "<LI>";
-         if ($ac_edit{'*'} || $ac_edit{$faqcat}) {
-             $ret .= "<A HREF=\"faqedit.bml?id=$faqid\">[edit]</A> ($fe->{'sortorder'}) ";
-         }
-         $ret .= "<B>{$faqid}</B> $q\n";
-     }
-     $ret .= "</UL>\n";
- }
+    foreach my $faqcat ( sort { $faqcat{ $a }->{ catorder } <=> $faqcat{ $b }->{ catorder } } keys %faqcat ) {
+        $ret .= "<h2><a href='readcat.bml?faqcat=$faqcat'>"
+            . LJ::ehtml( $faqcat{ $faqcat }->{ faqcatname } ) . "</a></h2>\n";
+        $ret .= "<ul>\n";
+        foreach my $faqid ( sort { $faqq{ $faqcat}->{ $a }->{ sortorder } <=> $faqq{ $faqcat }->{ $b }->{ sortorder } } keys %{ $faqq{ $faqcat } } ) {
+            my $fe = $faqq{ $faqcat }->{ $faqid };
+            next unless $fe->{ question };
+            my $q = LJ::ehtml( $fe->{ question } );
+            $q =~ s/^\s+//; $q =~ s/\s+$//;
+            $q =~ s|\n|<br />|g;
+            $ret .= "<li>";
+            $ret .= "<a href='faqedit.bml?id=$faqid'>[edit]</a> ($fe->{'sortorder'}) "
+                if $ac_edit{ '*' } || $ac_edit{ $faqcat };
+            $ret .= "<b>{$faqid}</b> $q</li>\n";
+        }
+        $ret .= "</ul>\n";
+    }
 
- return $ret;
-
+    return $ret;
+}
 _code?>
 
 <=body
--------------------------------------------------------------------------------