# Control Panel, Wordlet Update Lists

#use vars qw(%vars_wordlets_this);

my $thisout; my $thatout;

my %vars_wordlets_this = (
	'your_wordlet' => qq!Your Current Wordlet$trademark!,
	'new_wordlet'  => qq!Updated Default Wordlet$trademark!,
	'old_wordlet'  => qq!Old Default Wordlet$trademark!,
);

my (@hiddenws, @hiddenxs);

&FormStart("$vars_config{CGIURL}/cp.cgi", "$Hiddens");

print <<THEEND;
<center><table width="95%"><tr><td>
<font face="Verdana, Arial" size="2" color="black">
Note: The Wordlet$trademark Update utility will always default to
using your existing Wordlet$trademark entry rather than the
Updated Default.  <br />To use the Updated Default entry rather than your own,
you will need to copy the text from the Updated Default text box to your
own.<br />
</font>
</td></tr></table>
THEEND

foreach my $references (@allthewordlets) {
	($changes, $news, $these_wordlets_ref, $whichone, $wordletcode) = @$references;
	my %these_wordlets = %$these_wordlets_ref;

	if (($changes eq '') && ($news eq '')) {
		print "<p>";
		&TBT;
		print <<THEVERYENDOFYOU;
<tr><td colspan="2"><font size="2" face="Verdana, Arial" color="white"><b>
$whichone Wordlet$trademark entries are up to date.
</b></font></td></tr>
THEVERYENDOFYOU
		&TBB;
		print "</p>";

		next;
	}

	if ($changes ne '') {
		my @changelist = @$changes;
		print "<p>";
		&TBT;
		print <<GETTINGTIREDYET;
<tr><td colspan="2" align="center"><font size="2" face="Verdana, Arial" color="white"><b>
Updated $whichone Wordlet$trademark Entries
</b></font></td></tr>
GETTINGTIREDYET

		my ($incount, $outcount) = 0;
		INISH: foreach my $item (sort @changelist) {
			my ($amnew, $amcur, $amold);
			$outcount++;
			my ($starter, $ender, $hiddenthing);
			if ($these_wordlets{$item->{'name'}} eq $item->{'new'}) {
				$starter     = q~<!--~;
				$ender       = q~-->~;
				$hiddenthing = qq~<input type="hidden" name="$wordletcode||$item->{'name'}||action" value="current">~;
				push (@hiddenws, $item->{'name'});
				next INISH;
			}    #endif
			$incount++;

			if ($these_wordlets{$item->{'name'}} ne $item->{'old'}) {
				$these_wordlets{$item->{'name'}} = UBBCGI::escapeHTML($these_wordlets{$item->{'name'}});
				$item->{'old'} = UBBCGI::escapeHTML($item->{'old'});
				print <<WEREALLDEAD;
<tr><td colspan="2"><font size="2" face="Verdana, Arial" color="white"><b>
&nbsp; $item->{"name"}&nbsp; &nbsp; &nbsp;
</b><small>(Changed in <b>$item->{'humanversion'}</b>)
</small></font></td></tr><tr>
<td width="33%" bgcolor="white"><font size="2" face="Verdana, Arial">
$vars_wordlets_this{'your_wordlet'}:
</font></td>
<td width="67%" bgcolor="white"><font size="2" face="Verdana, Arial">
<textarea name="$wordletcode||$item->{'name'}||current_text" cols="55" rows="4" wrap="virtual">$these_wordlets{$item->{'name'}}</textarea>
</font></td></tr>$starter<tr>
<td width="33%" bgcolor="white"><font size="2" face="Verdana, Arial">
$vars_wordlets_this{'old_wordlet'}:
</font></td>
<td width="67%" bgcolor="white"><font size="2" face="Verdana, Arial">
<textarea name="$wordletcode||$item->{'name'}||orig_text" cols="55" rows="4" wrap="virtual">$item->{'old'}</textarea>
</font></td></tr>$ender$starter<tr>
WEREALLDEAD
				$amcur = q(checked="checked");
				$amold = qq(<input type="radio" name="$wordletcode||$item->{'name'}||action" value="old"> Change to OLD Default Wordlet$trademark<br />);
			} else {
				$these_wordlets{$item->{'name'}} = UBBCGI::escapeHTML($these_wordlets{$item->{'name'}});
				$these_wordlets{$item->{'old'}} = UBBCGI::escapeHTML($these_wordlets{$item->{'old'}});

				print <<WEREALLDEAD;
<tr><td colspan="2"><font size="2" face="Verdana, Arial" color="white"><b>
&nbsp; $item->{"name"}&nbsp; &nbsp; &nbsp;
</b><small>(Changed in <b>$item->{'humanversion'}</b>)
</small></font></td></tr><tr>
<td width="33%" bgcolor="white"><font size="2" face="Verdana, Arial">
$vars_wordlets_this{'your_wordlet'}:
<small><br />(Same as the $vars_wordlets_this{'old_wordlet'})
</small></font></td>
<td width="67%" bgcolor="white"><font size="2" face="Verdana, Arial">
<textarea name="$wordletcode||$item->{'name'}||current_text" cols="55" rows="4" wrap="virtual">$these_wordlets{$item->{'name'}}</textarea>
</font></td></tr>$ender$starter<tr>
WEREALLDEAD
				$amnew = q(checked="checked");
			}

			$item->{'new'} = UBBCGI::escapeHTML($item->{'new'});
			print <<WEREALLDEAD;
<td width="33%" bgcolor="white"><font size="2" face="Verdana, Arial">
$vars_wordlets_this{'new_wordlet'}:
</font></td>
<td width="67%" bgcolor="white"><font size="2" face="Verdana, Arial">
<textarea name="$wordletcode||$item->{'name'}||new_text" cols="55" rows="4" wrap="virtual">$item->{'new'}</textarea>
</font></td></tr>$ender$starter<tr>
<td width="33%" bgcolor="white"><font size="2" face="Verdana, Arial">
Action:
</font></td>
<td width="67%" bgcolor="white"><font size="2" face="Verdana, Arial">
<input type="radio" name="$wordletcode||$item->{'name'}||action" value="current" $amcur> Keep Current Wordlet$trademark<br />
<input type="radio" name="$wordletcode||$item->{'name'}||action" value="new" $amnew> Change to Updated Wordlet$trademark<br />
$amold
</font></td>
</tr>$ender
$hiddenthing

WEREALLDEAD
		}    #endforeach
		if ($outcount > $incount) {
			$thisout = $incount;
			my $diff = $outcount - $incount;
			my $more;
			my $thiswlist = join ("</b>, <b>", sort @hiddenws);
			$more = "more" if $incount > 0;
			print <<AIIIEEE;
<tr><td colspan="2" bgcolor="white"><font size="2" face="Verdana, Arial" color="black">
Note: There were $diff $more Wordlet$trademark entries that were marked as changed.  They have
been hidden because you have already made the changes.<br />These entries are: <b>$thiswlist</b>
</font></td></tr>
AIIIEEE
		} else {
			$thisout = $incount;
		}
		&TBB;
		print "</p><p> &nbsp; </p>";
	} else {
		$thisout = 0;
		print "<p>";
		&TBT;
		print <<THEVERYENDOFYOU;
<tr><td colspan="2"><font size="2" face="Verdana, Arial" color="white"><b>
$whichone Wordlet$trademark updates not found - you appear to be up to date
</b></font></td></tr>
THEVERYENDOFYOU
		&TBB;
		print "</p>";
	}


	if ($news ne '') {
		my @newlist = @$news;
		print "<p>";
		&TBT;
		print <<GETTINGTIREDYET;
<tr><td colspan="2" align="center"><font size="2" face="Verdana, Arial" color="white"><b>
New $whichone Wordlet$trademark Entries
</b></font></td></tr>
GETTINGTIREDYET

		my ($outcount2, $incount2);
		OUTISH: foreach my $item (sort @newlist) {
			my ($ihavethis, $amcur, $starter, $ender);
			my $actionthis = qq!<input type="hidden" name="$wordletcode||$item->{'name'}||action" value="new">!;
			$outcount2++;

			if (exists $these_wordlets{$item->{'name'}}) {

				#$ihavethis = q!You already have this Wordlet$trademark.<br>!;
				if ($these_wordlets{$item->{'name'}} ne $item->{'new'}) {
					$these_wordlets{$item->{'name'}} = UBBCGI::escapeHTML($these_wordlets{$item->{'name'}});

					$ihavethis = qq~<b>You seem to have this new Wordlet$trademark already!</b><br /><small>If you wish to change this Wordlet$trademark, edit it in the box below.  The original has been provided for comparison.\n</small>~;
					$ihavethis .= qq%<textarea name="$wordletcode||$item->{'name'}||current_text" cols="55" rows="4" wrap="virtual">$these_wordlets{$item->{'name'}}</textarea>%;
					$actionthis = qq!<input type="hidden" name="$wordletcode||$item->{'name'}||action" value="current">!;
				} else {
					$these_wordlets{$item->{'name'}} = UBBCGI::escapeHTML($these_wordlets{$item->{'name'}});
					$ihavethis .= qq%<textarea name="$wordletcode||$item->{'name'}||current_text" cols="55" rows="4" wrap="virtual">$these_wordlets{$item->{'name'}}</textarea>%;
					$actionthis = qq!<input type="hidden" name="$wordletcode||$item->{'name'}||action" value="current">!;
					$starter    = q~<!-- ~;
					$ender      = q~-->~;
					push (@hiddenxs, $item->{'name'});
					next OUTISH;
				}    #endif
			} else {
				$ihavethis = qq~<b>This is a new Wordlet$trademark - you don't have it yet!</b>
<br /><small>If you wish to change this Wordlet$trademark, edit it in the box below.\n</small>~;
			}
			$incount2++;

			$item->{'new'} = UBBCGI::escapeHTML($item->{'new'});

			print <<ANDTHISISHELL;
<tr><td colspan="2"><font size="2" face="Verdana, Arial" color="white"><b>
&nbsp; $item->{"name"}&nbsp; &nbsp; &nbsp; &nbsp;
</b><small>(Added in <b>$item->{'humanversion'}</b>)
</small></font></td></tr><tr>
<td width="33%" bgcolor="white"><font size="2" face="Verdana, Arial">
$vars_wordlets_this{'your_wordlet'}:
</font></td>
<td width="67%" bgcolor="white"><font size="2" face="Verdana, Arial">
$ihavethis

</font></td></tr>$starter<tr>

<td width="33%" bgcolor="white"><font size="2" face="Verdana, Arial">
$vars_wordlets_this{'new_wordlet'}:
</font></td>
<td width="67%" bgcolor="white"><font size="2" face="Verdana, Arial">
<textarea name="$wordletcode||$item->{'name'}||new_text" cols="55" rows="4" wrap="virtual">$item->{'new'}</textarea>
</font></td></tr>$ender

$actionthis

ANDTHISISHELL
		}    #endforeach

		if ($outcount2 > $incount2) {
			$thatout = $incount2;
			my $diff = $outcount2 - $incount2;
			my $more;
			my $changedones = join ("</b>, <b>", sort @hiddenxs);
			$more = "more" if $incount2 > 0;
			print <<AIIIEEE;
<tr><td colspan="2" bgcolor="white"><font size="2" face="Verdana, Arial" color="black">
Note: There were $diff $more Wordlet$trademark entries that were marked as added.  They have
been hidden because you have already added them.<br />These entries are: <b>$changedones</b>
</font></td></tr>
AIIIEEE
		} else {
			$thatout = $incount2;
		}

		&TBB;
		print "</p>";
	} else {
		$thatout = 0;
		print "<p>";
		&TBT;
		print <<THEVERYENDOFYOU;
<tr><td colspan="2"><font size="2" face="Verdana, Arial" color="white"><b>
$whichone Wordlet$trademark additions not found - you appear to be up to date
</b></font></td></tr>
THEVERYENDOFYOU
		&TBB;
		print "</p>";
	}

	#print "</table>";

}    #endforeach
&Submit("Update Wordlet™ Lists") if(($thisout >= 1) || ($thatout >= 1));
# Nothing below this line should be changed.. and there is no more code!

# This entire program is copyright Infopop Corporation.
# For more info on the Ultimate Bulletin Board and other Infopop
# Products/Services, visit: http://www.infopop.com

# You may not distribute this program in any manner, modified or otherwise.

#You make modifications, but only for your own use and within the confines of the UBB License Agreement.

# DANGER: Do not remove the following line!
1;
