It seems that the AltCat (MultCat) mod will only build links in multiple categories when BuildAll is used, and not when Staggered is used. Here is the sub, from nph-build.cgi, that I guess is causing this situation... I have put the mod code in red, and bolded the suspected culprit. Any thoughts on a fix?
sub build_stats {
# --------------------------------------------------------
# This routine does a lot of the messy work. It builds globally accessible
# arrays of new_links and cool_links. It finds out how many links are in each
# category, and whether a category contains a new/modified link.
# mult-cat mod > added %unique_categories <
my (@values, $category, $cat, @alt_categories, @categorylist, $depth, $i, $cat, %unique_categories);
my $staggered_mode = shift || undef;
open (DB, "<$db_file_name") or &cgierr("unable to open database: $db_file_name. Reason: $!");
LINE: while (<DB>) {
/^#/ and next LINE; # Skip comment Lines.
/^\s*$/ and next LINE; # Skip blank lines.
chomp;
@values = &split_decode ($_);
$category = $values[$db_category];
# Add the link to the list of links.
push (@{$links{$category}}, @values) if (!$staggered_mode);
$grand_total++;
# Add the link to the alternate categories as well.
if (defined $db_alt) {
@alt_categories = split(/\Q$db_delim\E/, $values[$db_alt]);
foreach (@alt_categories) {
push (@{$links{$_}}, @values);
}
}
# Add the link to the list of featured sites if it is pick.
push (@{$pick_links{$category}}, @values) if ($values[$db_ispick] eq "Yes");
# Add the link to the list of new links if it is new.
push (@{$new_links{$category}}, @values) if ($values[$db_isnew] eq "Yes");
# Add the link to the list of cool links if it is popular.
push (@{$cool_links{$category}}, @values) if ($values[$db_ispop] eq "Yes");
# This adds one to the total of each category above the current category.
# We have to caluclate the affect of the link on each alt category as well as the main.
# mult-cat mod >
%unique_categories = "";
# < mult-cat mod
foreach $cat ($category, @alt_categories) {
# Calculate the stats: the number of links and the newest link.
@categorylist = split (/\//, $cat);
$depth = $#categorylist;
# This adds one to the total of each category above the current category,
# and also marks any above categories new, if this link is new.
for $i (0 .. $depth) {
# mult-cat mod >
if (! defined ($unique_categories{$cat})) {
$unique_categories{$cat} += 1;
$stats{$cat}[0]++;
}
# < mult-cat mod
# $stats{$cat}[0]++;
if ((!$stats{$cat}[1]) || &compare_dates($values[$db_modified], $stats{$cat}[1])) {
$stats{$cat}[1] = $values[$db_modified];
}
pop (@categorylist);
$cat = join("/", @categorylist);
}
}
}
close DB;
# Now we have to sort the links and categories..
if (!$staggered_mode) {
foreach $link ( keys %links ) {
@{$links{$link}} = &build_sorthit (@{$links{$link}});
}
foreach $cat ( keys %subcategories ) {
@{$subcategories{$cat}} = sort @{$subcategories{$cat}};
}
}
$grand_total ||= 0;
}
That last bolded section does something based on building in staggered mode. Whatever it's doing is likely causing the links not to show up under the AltCats. Does anyone understand Perl well enough to see what's happening? Why are those two foreach statements only run under staggered? Actually, I guess they apply only under BuildAll, since that ! means if NOT staggered, correct?
Leonard
aka PerlFlunkie
sub build_stats {
# --------------------------------------------------------
# This routine does a lot of the messy work. It builds globally accessible
# arrays of new_links and cool_links. It finds out how many links are in each
# category, and whether a category contains a new/modified link.
# mult-cat mod > added %unique_categories <
my (@values, $category, $cat, @alt_categories, @categorylist, $depth, $i, $cat, %unique_categories);
my $staggered_mode = shift || undef;
open (DB, "<$db_file_name") or &cgierr("unable to open database: $db_file_name. Reason: $!");
LINE: while (<DB>) {
/^#/ and next LINE; # Skip comment Lines.
/^\s*$/ and next LINE; # Skip blank lines.
chomp;
@values = &split_decode ($_);
$category = $values[$db_category];
# Add the link to the list of links.
push (@{$links{$category}}, @values) if (!$staggered_mode);
$grand_total++;
# Add the link to the alternate categories as well.
if (defined $db_alt) {
@alt_categories = split(/\Q$db_delim\E/, $values[$db_alt]);
foreach (@alt_categories) {
push (@{$links{$_}}, @values);
}
}
# Add the link to the list of featured sites if it is pick.
push (@{$pick_links{$category}}, @values) if ($values[$db_ispick] eq "Yes");
# Add the link to the list of new links if it is new.
push (@{$new_links{$category}}, @values) if ($values[$db_isnew] eq "Yes");
# Add the link to the list of cool links if it is popular.
push (@{$cool_links{$category}}, @values) if ($values[$db_ispop] eq "Yes");
# This adds one to the total of each category above the current category.
# We have to caluclate the affect of the link on each alt category as well as the main.
# mult-cat mod >
%unique_categories = "";
# < mult-cat mod
foreach $cat ($category, @alt_categories) {
# Calculate the stats: the number of links and the newest link.
@categorylist = split (/\//, $cat);
$depth = $#categorylist;
# This adds one to the total of each category above the current category,
# and also marks any above categories new, if this link is new.
for $i (0 .. $depth) {
# mult-cat mod >
if (! defined ($unique_categories{$cat})) {
$unique_categories{$cat} += 1;
$stats{$cat}[0]++;
}
# < mult-cat mod
# $stats{$cat}[0]++;
if ((!$stats{$cat}[1]) || &compare_dates($values[$db_modified], $stats{$cat}[1])) {
$stats{$cat}[1] = $values[$db_modified];
}
pop (@categorylist);
$cat = join("/", @categorylist);
}
}
}
close DB;
# Now we have to sort the links and categories..
if (!$staggered_mode) {
foreach $link ( keys %links ) {
@{$links{$link}} = &build_sorthit (@{$links{$link}});
}
foreach $cat ( keys %subcategories ) {
@{$subcategories{$cat}} = sort @{$subcategories{$cat}};
}
}
$grand_total ||= 0;
}
That last bolded section does something based on building in staggered mode. Whatever it's doing is likely causing the links not to show up under the AltCats. Does anyone understand Perl well enough to see what's happening? Why are those two foreach statements only run under staggered? Actually, I guess they apply only under BuildAll, since that ! means if NOT staggered, correct?
Leonard
aka PerlFlunkie

