OMatic/appearanceForm.pm untested

filter: Statementstmt 0.0% 0 / 66 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 77 CC 3 SCAR 17.5
CC
3
Cov
0%
main
12.0
BEGIN
2.0
BEGIN
2.0
CRAP 5.8
1 ##############################################################################
2 # The Faq-O-Matic is Copyright 1997 by Jon Howell, all rights reserved. #
3 # #
4 # This program is free software; you can redistribute it and/or #
5 # modify it under the terms of the GNU General Public License #
6 # as published by the Free Software Foundation; either version 2 #
7 # of the License, or (at your option) any later version. #
8 # #
9 # This program is distributed in the hope that it will be useful, #
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
12 # GNU General Public License for more details. #
13 # #
14 # You should have received a copy of the GNU General Public License #
15 # along with this program; if not, write to the Free Software #
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.#
17 # #
18 # Jon Howell can be contacted at: #
19 # 6211 Sudikoff Lab, Dartmouth College #
20 # Hanover, NH 03755-3510 #
21 # jonh@cs.dartmouth.edu #
22 # #
23 # An electronic copy of the GPL is available at: #
24 # http://www.gnu.org/copyleft/gpl.html #
25 # #
26 ##############################################################################
27  
28 use strict;
29  
30 package FAQ::OMatic::appearanceForm;
31  
32 use CGI;
33 use FAQ::OMatic;
34 use FAQ::OMatic::I18N;
35 use FAQ::OMatic::HelpMod;
36  
37 sub main {
38 my $cgi = FAQ::OMatic::dispatch::cgi();
39
40 my $params = FAQ::OMatic::getParams($cgi);
41  
42 my $page = '';
43  
44 $page.=FAQ::OMatic::pageHeader($params, ['help', 'faq']);
45
46 $page.="<h3>".gettext("Appearance Options")."</h3>";
47  
48 # Data structure key:
49 # ['parameterName', # as resolved by $params->{'parameterName'}
50 # ['value-names', ...], # one per table column
51 # ['value', ...], # as will appear in value="" field
52 # 'description'], # text description of parameter
53  
54 my $boxes = [
55 # ['recurse',
56 # ['', gettext("Show"), gettext("Hide")],
57 # ['', '1', ''],
58 # gettext("all categories and answers below current category")],
59 ['editCmds',
60 [gettext("Show"), gettext("Compact"), gettext("Hide")],
61 ['show', 'compact', 'hide'],
62 gettext("expert editing commands")],
63 ['showModerator',
64 ['', gettext("Show"), gettext("Hide")],
65 ['', 'show', 'hide'],
66 gettext("name of moderator who organizes current category")],
67 ['showLastModified',
68 ['', gettext("Show"), gettext("Hide")],
69 ['', 'show', 'hide'],
70 gettext("last modified date")],
71 # showLastModifiedAlways is now obsolete; that default will be handled
72 # in the (new) standard way using OMatic::getParam().
73 # ($FAQ::OMatic::Config::showLastModifiedAlways||0)
74 # ? ['',
75 # ['', '', ''],
76 # ['', '', ''],
77 # '<i>last modified date always shown</i>']
78 # : ['showLastModified',
79 # ['', 'Show', 'Hide'],
80 # ['', '1', ''],
81 # 'last modified date']
82 # ,
83 ['showAttributions',
84 [gettext("Show"), gettext("Default"), gettext("Hide")],
85 ['all', 'default', 'hide'],
86 gettext("attributions")],
87 ['render',
88 ['', gettext("Simple"), gettext("Fancy")],
89 ['', 'simple', 'tables'],
90 'HTML'],
91 ['textCmds',
92 ['', gettext("Show"), gettext("Hide")],
93 ['', 'show', 'hide'],
94 gettext("commands for generating text output")]
95 ];
96  
97 $page.=FAQ::OMatic::makeAref("faq",
98 # kill all params that have a form entry
99 { map {$_->[0] => ''} @{$boxes} },
100 'GET')
101 ."<table>\n";
102 my ($setup, $choice);
103 foreach $setup (@{$boxes}) {
104 $page.="<tr>";
105 foreach $choice (0, 1, 2) {
106 $page.="<td>";
107 if ($setup->[1][$choice]) {
108 $page.="<input type=radio name=\""
109 .$setup->[0]
110 ."\" value=\""
111 .$setup->[2][$choice]
112 ."\"";
113 my $existing = FAQ::OMatic::getParam($params, $setup->[0]);
114 if ($existing eq $setup->[2][$choice]) {
115 $page.=" checked\n";
116 }
117 $page.="> "
118 .$setup->[1][$choice];
119 }
120 $page.="</td>\n";
121 }
122 $page.= "<td>".$setup->[3]."</td>\n";
123 $page.="</tr>";
124 }
125 $page.="<tr><td></td><td></td><td></td><td align=left>"
126 ."<input type=submit name=\"_fromAppearance\" value=\"".gettext("Accept")."\">"
127 ."</td></tr>\n";
128 $page.="</table></form>\n";
129  
130 $page.=FAQ::OMatic::HelpMod::helpFor($params, 'Appearance Options', "\n");
131  
132 $page.= FAQ::OMatic::pageFooter($params, ['help', 'faq']);
133  
134 print $page;
135 }
136  
137 1;