{'title'}; my $body = \$_[1]->{'body'}; $$body = ''; $$title = ''; # get faqid and redirect to faq.bml if none my $faqid = $GET{'faqid'} + 0; my $faqcat = $GET{'faqcat'}; my $where; my $dbr = LJ::get_db_reader(); # loading single faqid if ($faqid) { $$title = BML::ml('.title_num', { 'num' => $faqid }); $where = "faqid=$faqid"; # loading entire faqcat } elsif ($faqcat) { my $catname = $dbr->selectrow_array("SELECT faqcatname FROM faqcat WHERE faqcat=?", undef, $faqcat); $$title = BML::ml('.title_cat', { 'catname' => LJ::ehtml($catname) }); $where = "faqcat=" . $dbr->quote($faqcat); # no faqid or faqcat specified, redirect } else { return BML::redirect("faq.bml"); } my $remote = LJ::get_remote(); # get language settings my $curlang = BML::get_language(); my $deflang = BML::get_language_default(); my $altlang = $curlang ne $deflang; my $mld; if ($altlang) { my $mll = LJ::Lang::get_lang($curlang); $mld = LJ::Lang::get_dom("faq"); $altlang = 0 unless $mll && $mld; } # query db and get data my $sth = $dbr->prepare("SELECT faqid, question, answer, faqcat, lastmoduserid, ". "DATE_FORMAT(lastmodtime, '%Y-%m-%d'), ". "UNIX_TIMESTAMP(lastmodtime) FROM faq ". "WHERE $where ORDER BY sortorder"); $sth->execute; if ($dbr->err) { $$title = $ML{'Error'}; $$body = "$ML{'error.dberror'} \n"; return; } my $count = 0; my $dbh; my $backfaqcat; while (my ($faqid, $question, $answer, $faqcat, $lastmoduserid, $lastmodtime, $unixmodtime) = $sth->fetchrow_array) { $dbh ||= LJ::get_db_writer(); # log this faq view if ($remote && ! $LJ::DISABLED{faquses}) { $dbh->do("REPLACE INTO faquses (faqid, userid, dateview) ". "VALUES ($faqid, ?, NOW())", undef, $remote->{'userid'}); } BML::note_mod_time($unixmodtime); # it'd be better to load them in a batch, but this works for now: if ($altlang) { $question = LJ::Lang::get_text($curlang, "$faqid.1question", $mld->{'dmid'}); $answer = LJ::Lang::get_text($curlang, "$faqid.2answer", $mld->{'dmid'}); } # escape question and answers my $q = LJ::ehtml($question); $q =~ s/^\s+//; $q =~ s/\s+$//; $q =~ s/\n/
/g; my $a = LJ::ehtml($answer); $a =~ s/^\s+//; $a =~ s/\s+$//; $a =~ s/\n( +)/"\n" . "  "x length($1)/eg; $a =~ s/\n/
/g; $a = LJ::auto_linkify($a); # display output $$body .= "»"; } $$body .= " $q h1?>
$a
"; my $lastmodwho = LJ::get_username($lastmoduserid); if ($lastmodwho) { $$body .= "

$ML{'.lastupdated'}
$lastmodwho, $lastmodtime

"; } if (LJ::check_priv($remote, "faqedit", "*") || LJ::check_priv($remote, "faqedit", $faqcat)) { $$body .= "

$ML{'.edit.faq'}

"; } $count++; $backfaqcat = $faqcat; } # nothing found? unless ($count) { $$title = $ML{'Error'}; $$body .= "

$ML{'.error.nofaq'}

\n"; } $$body .= ""; $$body .= BML::ml('.backfaqcat',{'faqcat'=>$backfaqcat,}) . "
" if $backfaqcat && $faqid; $$body .= "$ML{'.backfaq'}
$ML{'.backsupport'}"; # we're dynamic, set title as crumb title LJ::set_dynamic_crumb($_[1]->{'title'}, 'faq'); return $_[1]->{'body'}; } _code?> <=body title=>{'title'}; _code?> page?> link: htdocs/support/index.bml, htdocs/support/faq.bml _c?>