-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsuggest.htm
More file actions
188 lines (179 loc) · 6.05 KB
/
suggest.htm
File metadata and controls
188 lines (179 loc) · 6.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
<?xml version="1.0" encoding="UTF-8"?>
<%args>
$lang => ''
$scod => 'XXXX' # for compatibility with python version
$cowc => $scod
$style => ''
$sdesc => '[Suggestion]'
$srat => '[Rationale]'
</%args>
<%perl>
use Apache2::Connection ();
use lib '/var/www/ccow-m';
use Manatee;
use ManateeSQL;
my %config = &Manatee::loadConfig($style);
my $dbh = &ManateeSQL::getDB();
my %var = &Manatee::suggVars($lang,$cowc,$sdesc,$srat,$dbh);
if (length($config{site}) == 0) {
$config{site} = "Manatee";
}
if (length($style)){ $var{style} = "style=$style"; }
$var{ip} = $r->connection->remote_ip;
my @crumbs;
my @subcats;
if ($var{lang}) {
@crumbs = ManateeSQL::glotCrumbs($dbh,$var{cowc},$var{stage},$lang,$var{style});
$var{crumbs} = scalar(@crumbs); # how many crumbs?
$var{crumbdiv} = ($var{crumbs} > 0 and index("xX",substr($var{cowc},0,1)) eq -1) ? 1 : 0;
}
if ($var{showsubs}) {
@subcats = ManateeSQL::glotSubs($dbh,$var{cowc},$var{stage},$lang);
} elsif (!$var{showerr}) {
$var{push} = &ManateeSQL::pushSugg($dbh,$var{ip},$var{cowc},$var{sdesc},$var{srat},$var{lang});
}
if ($var{push} == 1) {
$var{showform} = 0;
$var{showerr} = 1;
$var{error} = "You have (or someone at your IP has) suggested a description for this category recently. Please try again later, or login to your expert account to make and edit suggestions.";
} elsif ($var{push} == 0) {
$var{showform} = 0;
} elsif ($var{push} == -1 or $var{push} > 3) {
$var{showform} = 1;
$var{showerr} = 1;
$var{error} = "An error occurred while trying to execute your query.";
} elsif ($var{push} == 2 and length($var{srat}) < 20) {
my $rl = length($var{srat});
$var{showerr} = 1;
my $it = "just barely ";
if ($rl < 18) {
$it = "a little ";
if ($rl < 15) {
$it = "";
if ($rl < 12) {
$it = "much ";
if ($rl < 9) {
$it = "waaaaay ";
}
}
}
}
$var{error} = "Your rationale is ".$it."too short. Please be more thorough.";
} else {
$var{showform} = 1;
$var{showerr} = 1;
$var{error} = "Please enter a valid suggestion and a thorough reasoning for your suggestion's appropriateness to this category.";
}
$var{suggested} = 0;
my @suggestions;
if ($var{lang}) {
@suggestions = &ManateeSQL::glotSuggs($dbh,$var{cowc},$var{lang});
}
if (@suggestions) {
$var{suggested} = scalar(@suggestions);
}
if ($var{showsubs}) {
$var{suggested} = 0;
}
my $qs = "";
if (length($var{lang})) { $qs = "?lang=".$var{lang}."&cowc=".$cowc; }
if (length($var{style})) { $qs = $qs."&".$var{style}; }
</%perl>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3c.org/1999/xhtml" lang="EN">
<head>
<title><% $config{site} %>: <% $var{title} %></title>
<link rel="stylesheet" type="text/css" href="static/main.css" />
% if(length($config{custom})){
<link rel="stylesheet" type="text/css" href="static/<% $config{custom} %>.css" />
%}
</head>
<body>
% if(length($config{logo})){
<div class="logo"><img src="img/<% $config{logo} %>" alt="<% $config{logodesc} %>" title="<% $config{logodesc} %>" /></div>
% }
% if ($var{crumbs}) {
<ul class="loaf" id="breadtrail">
% foreach my $i (0..$var{crumbs}-1){
<li class="crumb" id="sm0<% $crumbs[$i][0] %>"><a href="<% $crumbs[$i][1] %>"><% $crumbs[$i][2] %></a>
% if ($var{crumbdiv}) {
>
% }
</li>
% }
</ul>
% }
<p class="clearit"> </p>
<& ccowmenu.comp, 'uri'=>$var{uri}, 'query'=>$qs &>
% if ($var{lang}) {
<h1 id="sm11">For subcategory <% substr($var{cowc},$var{stage}-1,1) %>: <% $var{catname} %></h1>
% if (-e "$config{localpath}/$var{catinf}") {
Parent's description: <% $var{parname} %> <& $var{catinf} &>
% } elsif ($var{parname}) {
Parent (<% $var{parname} %>) has no long description.<br />
% } else {
Parent description is not available.
<& cats/dhandler &>
<br />
% }
% if ($var{suggested} != 0) {
Current suggestions for <% $var{cowc} %>:
<table class="suggs"><tr><th>Suggestion</th><th>Rationale</th></tr>
% for (my $i=0; $i < scalar(@suggestions); $i++) { #<lt>
% my @t = $suggestions[$i];
<tr><td><% $t[0]->[0] %></td><td><% $t[0]->[1] %></td></tr>
% }
</table>
<br />
% }
% if ($var{showform}) {
Your suggestion:
<form name="suggest" method="post" action="suggest.htm">
Code: <input type="text" name="cowc" size="4" value="<% $var{cowc} %>" /><br />
Description: <input type="text" name="sdesc" size="75%" value="<% $var{sdesc} %>" /><br />
Rationale: <input type="text" name="srat" size="75%" value="<% $var{srat} %>" /><br />
<input type="hidden" name="lang" value="<% $var{lang} %>" />
<input type="hidden" name="style" value="<% $var{style} %>" />
<input type="submit" value="Send Suggestion" />
</form>
% } elsif ($var{showerr} == 1) {
<br />
% } else {
<p>Your suggestion has been entered for category <% $var{cowc} %>: "<% $var{sdesc} %>" because "<% $var{srat} %>"</p>
% }
% if ($var{showerr}) {
<p class="errtext"><% $var{error} %></p>
% }
% if ($var{showsubs}) {
<p class="clearit"> </p>
% for (my $i=0; $i < scalar(@subcats); $i++) {
<p class="subcat"><a href="?lang=<% $var{lang} %>&cowc=<% $subcats[$i][0] %>
% if (length($var{style})) {
&<% $var{style} %>
% }
"><% $subcats[$i][1] %>: <% $subcats[$i][2] %></a></p>
% }
% }
<p class="clearit"> </p>
% }
% if (length($var{lang}) == 0) {
<h1 id="sm10"><% $var{title} %></h1>
<div class="languages">
<p class="lingua"><a href="?lang=en
% if(length($var{style})){
&<% $var{style} %>
% }
">Language: English</a></p>
<p class="lingua"><a href="?lang=es
% if(length($var{style})){
&<% $var{style} %>
% }
">Idioma: Español</a></p>
</div>
% }
<div class="cc" id="sm11">This suggestion application is released under a <a href="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-Share Alike</a> license.
<p>The contents of the translation and description files are released under a <a href="http://creativecommons.org/licenses/by-nd/3.0/">CC Attribution-No Derivative Works</a> license.</p> (C) copyright 2009-2013 by the Manatee Project Workgroup.</div>
<p class="source" id="sm12">You can obtain the source for this program at https://github.com/over2sd/Manatee/</p>
<& footer.comp &>
</body>
</html>