Converted FAQs to use H::T

This commit is contained in:
JT Smith 2002-11-02 18:30:26 +00:00
parent 9406e3684f
commit 6f5ce07396
3 changed files with 113 additions and 107 deletions

View file

@ -34,6 +34,8 @@ save you many hours of grief.
process. Be sure to copy them to a save place before process. Be sure to copy them to a save place before
upgrading. upgrading.
* All FAQ's have been reset to use the default template.
4.6.3 4.6.3
-------------------------------------------------------------------- --------------------------------------------------------------------
* It has been reported that some people had a duplicate key error * It has been reported that some people had a duplicate key error

View file

@ -1028,6 +1028,20 @@ insert into international (internationalId,languageId,namespace,message,lastUpda
insert into international (internationalId,languageId,namespace,message,lastUpdated) values (4,1,'Survey','', 1033944306); insert into international (internationalId,languageId,namespace,message,lastUpdated) values (4,1,'Survey','', 1033944306);
insert into international (internationalId,languageId,namespace,message,lastUpdated) values (2,1,'Survey','Edit Survey', 1033943825); insert into international (internationalId,languageId,namespace,message,lastUpdated) values (2,1,'Survey','Edit Survey', 1033943825);
insert into international (internationalId,languageId,namespace,message,lastUpdated) values (1,1,'Survey','Survey', 1033942924); insert into international (internationalId,languageId,namespace,message,lastUpdated) values (1,1,'Survey','Survey', 1033942924);
delete from international where namespace='FAQ' and internationalId=14;
delete from international where namespace='FAQ' and internationalId=15;
delete from international where namespace='FAQ' and internationalId=16;
alter table FAQ drop column tocOn;
alter table FAQ drop column qaOn;
alter table FAQ drop column topOn;
alter table FAQ add column templateId int not null default 1;
delete from international where namespace='FAQ' and internationalId=1;
insert into international (internationalId,languageId,namespace,message,lastUpdated) values (75,1,'FAQ','Add a question.', 1036260753);
insert into international (internationalId,languageId,namespace,message,lastUpdated) values (74,1,'FAQ','Template', 1036260684);
INSERT INTO template VALUES (1,'Default FAQ','<a name=\"top\"></a>\r\n\r\n<tmpl_if description>\r\n<tmpl_var description><p>\r\n</tmpl_if>\r\n\r\n<tmpl_var addquestion><p>\r\n\r\n<ul>\r\n<tmpl_loop toc_loop>\r\n<li><a href=\"#<tmpl_var questionid>\"><span class=\"faqQuestion\"><tmpl_var question></span></a>\r\n</tmpl_loop>\r\n</ul>\r\n\r\n<tmpl_loop qa_loop>\r\n<tmpl_var controls><a name=\"<tmpl_var questionid>\"><span class=\"faqQuestion\"><tmpl_var question></span></a><br>\r\n<tmpl_var answer>\r\n<p/><a href=\"#top\">[top]</a><p/>\r\n</tmpl_loop>\r\n\r\n','FAQ');
INSERT INTO template VALUES (2,'Q and A','<tmpl_if description>\r\n<tmpl_var description><p>\r\n</tmpl_if>\r\n\r\n<tmpl_var addquestion><p>\r\n\r\n<tmpl_loop qa_loop>\r\n<tmpl_var controls><b>Q: <tmpl_var question></b><br>\r\nA: <tmpl_var answer>\r\n<p/>\r\n</tmpl_loop>\r\n\r\n','FAQ');
INSERT INTO template VALUES (3,'Topics','<tmpl_if description>\r\n<tmpl_var description><p>\r\n</tmpl_if>\r\n\r\n<tmpl_var addquestion><p>\r\n\r\n<tmpl_loop qa_loop>\r\n<tmpl_var controls><h2><tmpl_var question></h2>\r\n<tmpl_var answer>\r\n<p/>\r\n</tmpl_loop>\r\n\r\n','FAQ');

View file

@ -54,112 +54,113 @@ sub purge {
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub set { sub set {
$_[0]->SUPER::set($_[1],[qw(topOn tocOn qaOn)]); $_[0]->SUPER::set($_[1],[qw(templateId)]);
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub www_deleteQuestion { sub www_deleteQuestion {
if (WebGUI::Privilege::canEditPage()) { return WebGUI::Privilege::insufficient() unless (WebGUI::Privilege::canEditPage());
return $_[0]->confirm(WebGUI::International::get(7,$namespace), return $_[0]->confirm(WebGUI::International::get(7,$namespace),
WebGUI::URL::page('func=deleteQuestionConfirm&wid='.$_[0]->get("wobjectId").'&qid='.$session{form}{qid})); WebGUI::URL::page('func=deleteQuestionConfirm&wid='.$_[0]->get("wobjectId").'&qid='.$session{form}{qid}));
} else {
return WebGUI::Privilege::insufficient();
}
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub www_deleteQuestionConfirm { sub www_deleteQuestionConfirm {
my ($output); return WebGUI::Privilege::insufficient() unless (WebGUI::Privilege::canEditPage());
if (WebGUI::Privilege::canEditPage()) { $_[0]->deleteCollateral("FAQ_question","FAQ_questionId",$session{form}{qid});
$_[0]->deleteCollateral("FAQ_question","FAQ_questionId",$session{form}{qid}); $_[0]->reorderCollateral("FAQ_question","FAQ_questionId");
$_[0]->reorderCollateral("FAQ_question","FAQ_questionId"); return "";
return "";
} else {
return WebGUI::Privilege::insufficient();
}
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub www_edit { sub www_edit {
my ($f, $output, $proceed); my ($f, $output, $template);
if (WebGUI::Privilege::canEditPage()) { return WebGUI::Privilege::insufficient() unless (WebGUI::Privilege::canEditPage());
if ($_[0]->get("wobjectId") eq "new") { $template = $_[0]->get("templateId") || 1;
$proceed = 1; $output = helpIcon(1,$namespace);
} $output .= '<h1>'.WebGUI::International::get(8,$namespace).'</h1>';
$output = helpIcon(1,$namespace); $f = WebGUI::HTMLForm->new;
$output .= '<h1>'.WebGUI::International::get(8,$namespace).'</h1>'; $f->template(
$f = WebGUI::HTMLForm->new; -name=>"templateId",
$f->yesNo("tocOn",WebGUI::International::get(11,$namespace),$_[0]->get("tocOn")); -value=>$template,
$f->yesNo("qaOn",WebGUI::International::get(12,$namespace),$_[0]->get("qaOn")); -namespace=>$namespace,
$f->yesNo("topOn",WebGUI::International::get(13,$namespace),$_[0]->get("topOn")); -label=>WebGUI::International::get(74,$namespace),
$f->yesNo("proceed",WebGUI::International::get(1,$namespace),$proceed); -afterEdit=>'func=edit&wid='.$_[0]->get("wobjectId")
$output .= $_[0]->SUPER::www_edit($f->printRowsOnly); );
return $output; if ($_[0]->get("wobjectId") eq "new") {
} else { $f->whatNext(
return WebGUI::Privilege::insufficient(); -options=>{
} addQuestion=>WebGUI::International::get(75,$namespace),
backToPage=>WebGUI::International::get(745)
},
-value=>"addQuestion"
);
}
$output .= $_[0]->SUPER::www_edit($f->printRowsOnly);
return $output;
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub www_editSave { sub www_editSave {
if (WebGUI::Privilege::canEditPage()) { return WebGUI::Privilege::insufficient() unless (WebGUI::Privilege::canEditPage());
$_[0]->SUPER::www_editSave({ $_[0]->SUPER::www_editSave({
tocOn=>$session{form}{tocOn}, templateId=>$session{form}{templateId}
topOn=>$session{form}{topOn}, });
qaOn=>$session{form}{qaOn} if ($session{form}{proceed} eq "addQuestion") {
}); $session{form}{qid} = "new";
if ($session{form}{proceed}) { return $_[0]->www_editQuestion();
$_[0]->www_editQuestion(); }
} else { return "";
return "";
}
} else {
return WebGUI::Privilege::insufficient();
}
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub www_editQuestion { sub www_editQuestion {
my ($output, %question, $f); my ($output, $question, $f);
tie %question, 'Tie::CPHash'; return WebGUI::Privilege::insufficient() unless (WebGUI::Privilege::canEditPage());
if (WebGUI::Privilege::canEditPage()) { $question = $_[0]->getCollateral("FAQ_question","FAQ_questionId",$session{form}{qid});
%question = WebGUI::SQL->quickHash("select * from FAQ_question where FAQ_questionId='$session{form}{qid}'"); $output = helpIcon(2,$namespace);
$output = helpIcon(2,$namespace); $output .= '<h1>'.WebGUI::International::get(10,$namespace).'</h1>';
$output .= '<h1>'.WebGUI::International::get(10,$namespace).'</h1>'; $f = WebGUI::HTMLForm->new;
$f = WebGUI::HTMLForm->new; $f->hidden("wid",$_[0]->get("wobjectId"));
$f->hidden("wid",$_[0]->get("wobjectId")); $f->hidden("qid",$question->{FAQ_questionId});
$session{form}{qid} = "new" if ($session{form}{qid} eq ""); $f->hidden("func","editQuestionSave");
$f->hidden("qid",$session{form}{qid}); $f->textarea(
$f->hidden("func","editQuestionSave"); -name=>"question",
$f->textarea("question",WebGUI::International::get(5,$namespace),$question{question}); -label=>WebGUI::International::get(5,$namespace),
$f->HTMLArea("answer",WebGUI::International::get(6,$namespace),$question{answer}); -value=>$question->{question}
$f->yesNo("proceed",WebGUI::International::get(1,$namespace)); );
$f->submit; $f->HTMLArea(
$output .= $f->print; -name=>"answer",
return $output; -label=>WebGUI::International::get(6,$namespace),
} else { -value=>$question->{answer}
return WebGUI::Privilege::insufficient(); );
if ($question->{FAQ_questionId} eq "new") {
$f->whatNext(
-options=>{
addQuestion=>WebGUI::International::get(75,$namespace),
backToPage=>WebGUI::International::get(745)
},
-value=>"addQuestion"
);
} }
$f->submit;
$output .= $f->print;
return $output; return $output;
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub www_editQuestionSave { sub www_editQuestionSave {
if (WebGUI::Privilege::canEditPage()) { return WebGUI::Privilege::insufficient() unless (WebGUI::Privilege::canEditPage());
$_[0]->setCollateral("FAQ_question", "FAQ_questionId", { $_[0]->setCollateral("FAQ_question", "FAQ_questionId", {
FAQ_questionId => $session{form}{qid}, FAQ_questionId => $session{form}{qid},
question => $session{form}{question}, question => $session{form}{question},
answer => $session{form}{answer} answer => $session{form}{answer}
}); });
if ($session{form}{proceed}) { if ($session{form}{proceed} eq "addQuestion") {
$session{form}{qid} = "new"; $session{form}{qid} = "new";
return $_[0]->www_editQuestion(); return $_[0]->www_editQuestion();
} else { }
return ""; return "";
}
} else {
return WebGUI::Privilege::insufficient();
}
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------
@ -178,48 +179,37 @@ sub www_moveQuestionUp {
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub www_view { sub www_view {
my (%question, $top, $q, $a, $output, $sth, $qNa); my (%question, $output, $controls, $sth, %var, @qa, @toc);
tie %question,'Tie::CPHash'; tie %question,'Tie::CPHash';
$output = $_[0]->displayTitle; $output = $_[0]->displayTitle;
$output .= '<a name="top"></a>';
$output .= $_[0]->description;
$top = WebGUI::International::get(16,$namespace);
$q = WebGUI::International::get(14,$namespace);
$a = WebGUI::International::get(15,$namespace);
if ($session{var}{adminOn}) { if ($session{var}{adminOn}) {
$output .= '<a href="'.WebGUI::URL::page('func=editQuestion&wid='.$_[0]->get("wobjectId")).'">' $var{addquestion} .= '<a href="'.WebGUI::URL::page('func=editQuestion&wid='.$_[0]->get("wobjectId")).'">'
.WebGUI::International::get(9,$namespace).'</a>'; .WebGUI::International::get(9,$namespace).'</a>';
} }
$output .= '<ul>';
$sth = WebGUI::SQL->read("select * from FAQ_question where wobjectId=".$_[0]->get("wobjectId")." order by sequenceNumber"); $sth = WebGUI::SQL->read("select * from FAQ_question where wobjectId=".$_[0]->get("wobjectId")." order by sequenceNumber");
while (%question = $sth->hash) { while (%question = $sth->hash) {
if ($_[0]->get("tocOn")) { push(@toc,{
$output .= '<li><a href="#'.$question{FAQ_questionId}.'"><span class="faqQuestion">'.$question{question}.'</span></a>'; questionId=>$question{FAQ_questionId},
} question=>$question{question}
});
if ($session{var}{adminOn}) { if ($session{var}{adminOn}) {
$qNa .= deleteIcon('func=deleteQuestion&wid='.$_[0]->get("wobjectId").'&qid='.$question{FAQ_questionId}) $controls = deleteIcon('func=deleteQuestion&wid='.$_[0]->get("wobjectId").'&qid='.$question{FAQ_questionId})
.editIcon('func=editQuestion&wid='.$_[0]->get("wobjectId").'&qid='.$question{FAQ_questionId}) .editIcon('func=editQuestion&wid='.$_[0]->get("wobjectId").'&qid='.$question{FAQ_questionId})
.moveUpIcon('func=moveQuestionUp&wid='.$_[0]->get("wobjectId").'&qid='.$question{FAQ_questionId}) .moveUpIcon('func=moveQuestionUp&wid='.$_[0]->get("wobjectId").'&qid='.$question{FAQ_questionId})
.moveDownIcon('func=moveQuestionDown&wid='.$_[0]->get("wobjectId").'&qid='.$question{FAQ_questionId}) .moveDownIcon('func=moveQuestionDown&wid='.$_[0]->get("wobjectId").'&qid='.$question{FAQ_questionId})
.' '; .' ';
} }
$qNa .= '<a name="'.$question{FAQ_questionId}.'"><span class="faqQuestion">'; push(@qa,{
if ($_[0]->get("qaOn")) { questionId=>$question{FAQ_questionId},
$qNa .= $q.': '; answer=>$question{answer},
} question=>$question{question},
$qNa .= $question{question}.'</span></a><br>'; controls=>$controls
if ($_[0]->get("qaOn")) { });
$qNa .= $a.': ';
}
$qNa .= $question{answer};
if ($_[0]->get("topOn")) {
$qNa .= '<p/><a href="#top">'.$top.'</a>';
}
$qNa .= '<p>';
} }
$sth->finish; $sth->finish;
$output .= '</ul>'.$qNa; $var{toc_loop} = \@toc;
return $_[0]->processMacros($output); $var{qa_loop} = \@qa;
return $_[0]->processMacros($output.$_[0]->processTemplate($_[0]->get("templateId"),\%var));
} }