391 lines
14 KiB
Perl
Executable File
391 lines
14 KiB
Perl
Executable File
#!/usr/sbin/perl
|
|
|
|
#**************************************************************************
|
|
#* *
|
|
#* Copyright (c) 1996 Silicon Graphics, Inc. *
|
|
#* All Rights Reserved *
|
|
#* *
|
|
#* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF SGI *
|
|
#* *
|
|
#* The copyright notice above does not evidence any actual of intended *
|
|
#* publication of such source code, and is an unpublished work by Silicon *
|
|
#* Graphics, Inc. This material contains CONFIDENTIAL INFORMATION that is *
|
|
#* the property of Silicon Graphics, Inc. Any use, duplication or *
|
|
#* disclosure not specifically authorized by Silicon Graphics is strictly *
|
|
#* prohibited. *
|
|
#* *
|
|
#* RESTRICTED RIGHTS LEGEND: *
|
|
#* *
|
|
#* Use, duplication or disclosure by the Government is subject to *
|
|
#* restrictions as set forth in subdivision (c)(1)(ii) of the Rights in *
|
|
#* Technical Data and Computer Software clause at DFARS 52.227-7013, *
|
|
#* and/or in similar or successor clauses in the FAR, DOD or NASA FAR *
|
|
#* Supplement. Unpublished - rights reserved under the Copyright Laws of *
|
|
#* the United States. Contractor is SILICON GRAPHICS, INC., 2011 N. *
|
|
#* Shoreline Blvd., Mountain View, CA 94039-7311 *
|
|
#**************************************************************************
|
|
|
|
# DEMO_search.pl
|
|
#
|
|
# Routines to run the demo search functionality
|
|
|
|
1; # Return true
|
|
|
|
sub Generate_Search_Page {
|
|
if ($in{$CGI_SEARCH_NAME_SWITCH}) {
|
|
&Print_Name_Search_Results;
|
|
} elsif ($in{$CGI_SEARCH_ADV_SWITCH}) {
|
|
&Print_Adv_Search_Results;
|
|
} else {
|
|
&Print_Search_Form_Page;
|
|
}
|
|
}
|
|
|
|
sub Print_Name_Search_Results {
|
|
local(@match_demos, $match_demos_string);
|
|
@match_demos = &Find_Demos_By_Title($in{$CGI_SEARCH_NAME_SWITCH});
|
|
$match_demos_string = join( "$HTTP_DEMOS_DELIM", @match_demos);
|
|
&Print_Search_Form_Results_Head($match_demos_string);
|
|
&Print_Search_Name_Top;
|
|
&Print_Search_Form_Results_Mid;
|
|
&Print_Search_Form_Bottom;
|
|
}
|
|
|
|
sub Print_Adv_Search_Results {
|
|
local(@match_demos, $match_demos_string);
|
|
@match_demos = &Find_Demos_By_Category;
|
|
$match_demos_string = join( "$HTTP_DEMOS_DELIM", @match_demos);
|
|
&Print_Search_Form_Results_Head($match_demos_string);
|
|
&Print_Search_Category_Top;
|
|
&Print_Search_Form_Results_Mid;
|
|
&Print_Search_Form_Bottom;
|
|
}
|
|
|
|
|
|
sub Compute_Array_Intersect {
|
|
local(%MARK, @result);
|
|
grep($MARK{$_}++, @compute_first);
|
|
@result = grep($MARK{$_}, @compute_second);
|
|
return(@result);
|
|
}
|
|
|
|
sub Compute_Array_Addition {
|
|
local($i, @compute_first_clean);
|
|
foreach $i (0..$#compute_first) {
|
|
push(@compute_first_clean, $compute_first[$i]) if (!grep(/^$compute_first[$i]$/, @compute_second));
|
|
}
|
|
@result = (@compute_first_clean, @compute_second);
|
|
return(@result);
|
|
}
|
|
|
|
sub Find_Category_Matches {
|
|
local($category_table_file, @categories_q, $cat_q, @demos_in_category, @matches_category, $first_time);
|
|
$category_table_file = shift @_;
|
|
@categories_q = @_;
|
|
&Source_Table("$category_table_file", @categories_q);
|
|
$first_time = 1;
|
|
for $cat_q (@categories_q) {
|
|
@demos_in_category = split(/$TABLE_SECOND_DELIM/, $demos_under{$cat_q});
|
|
if ($first_time) {
|
|
@matches_category = @demos_in_category;
|
|
$first_time = 0;
|
|
} else {
|
|
@compute_second = @matches_category;
|
|
@compute_first = @demos_in_category;
|
|
@matches_category = &Compute_Array_Intersect if ("$logic{'WITHIN'}" eq "AND");
|
|
@matches_category = &Compute_Array_Addition if ("$logic{'WITHIN'}" eq "OR");
|
|
}
|
|
}
|
|
return(@matches_category);
|
|
}
|
|
|
|
sub Assign_Input_Values {
|
|
@markets_q = split(/\n/, $in{'MARKETS'});
|
|
@hardware_q = split(/\n/, $in{'HARDWARE'});
|
|
@features_q = split(/\n/, $in{'FEATURES'});
|
|
@logic_temp = split(/$SEARCH_DELIM/, $in{$CGI_SEARCH_ADV_SWITCH});
|
|
$logic{'BETWEEN'} = shift @logic_temp;
|
|
$logic{'WITHIN'} = shift @logic_temp;
|
|
}
|
|
|
|
sub Find_Demos_By_Category {
|
|
&Assign_Input_Values;
|
|
# Find matches within each category
|
|
@matches_markets = &Find_Category_Matches("$FILE_TABLE_MARKETS", @markets_q) if @markets_q;
|
|
@matches_hardware = &Find_Category_Matches("$FILE_TABLE_HARDWARE", @hardware_q) if @hardware_q;
|
|
@matches_features = &Find_Category_Matches("$FILE_TABLE_FEATURES", @features_q) if @features_q;
|
|
# Count categories -- Oh but for a structured type
|
|
$num_categories = 0;
|
|
++$num_categories if @markets_q;
|
|
++$num_categories if @hardware_q;
|
|
++$num_categories if @features_q;
|
|
if ($num_categories == 0) {
|
|
@final_matches = @null;
|
|
} elsif ($num_categories == 1) {
|
|
@final_matches = @matches_markets if @markets_q;
|
|
@final_matches = @matches_hardware if @hardware_q;
|
|
@final_matches = @matches_features if @features_q;
|
|
} elsif ($num_categories == 2) {
|
|
if ((@markets_q) && (@hardware_q)) {
|
|
@compute_first = @matches_markets;
|
|
@compute_second = @matches_hardware;
|
|
@final_matches = &Compute_Array_Intersect if ("$logic{'BETWEEN'}" eq "AND");
|
|
@final_matches = &Compute_Array_Addition if ("$logic{'BETWEEN'}" eq "OR");
|
|
} elsif ((@markets_q) && (@features_q)) {
|
|
@compute_first = @matches_markets;
|
|
@compute_second = @matches_features;
|
|
@final_matches = &Compute_Array_Intersect if ("$logic{'BETWEEN'}" eq "AND");
|
|
@final_matches = &Compute_Array_Addition if ("$logic{'BETWEEN'}" eq "OR");
|
|
} elsif ((@hardware_q) && (@features_q)) {
|
|
@compute_first = @matches_hardware;
|
|
@compute_second = @matches_features;
|
|
@final_matches = &Compute_Array_Intersect if ("$logic{'BETWEEN'}" eq "AND");
|
|
@final_matches = &Compute_Array_Addition if ("$logic{'BETWEEN'}" eq "OR");
|
|
}
|
|
} elsif ($num_categories == 3) {
|
|
if ("$logic{'BETWEEN'}" eq "OR") {
|
|
@compute_first = @matches_hardware;
|
|
@compute_second = @matches_features;
|
|
@mid_result = &Compute_Array_Addition;
|
|
@compute_first = @mid_result;
|
|
@compute_second = @matches_markets;
|
|
@final_matches = &Compute_Array_Addition;
|
|
} else {
|
|
@compute_first = @matches_hardware;
|
|
@compute_second = @matches_features;
|
|
@mid_result = &Compute_Array_Intersect;
|
|
@compute_first = @mid_result;
|
|
@compute_second = @matches_markets;
|
|
@final_matches = &Compute_Array_Intersect;
|
|
}
|
|
}
|
|
grep( (s/$TREES_DELIM/$HTTP_TREES_DELIM/g), @final_matches);
|
|
grep( (s/\s/$HTTP_GET_DELIM/g), @final_matches);
|
|
return(&alpha(@final_matches));
|
|
}
|
|
|
|
sub Print_Search_Form_Results_Head {
|
|
&Print_HTTP_Header("BLANK", "$HTTP_YES_SCRIPT");
|
|
print "<script>\n";
|
|
print "//\n";
|
|
print "function UpdateSide() {\n";
|
|
print "top.frames[\"$FRAME_SIDE\"].location = \"$WWW_SCRIPT?$CGI_SWITCH=$FRAME_SIDE&";
|
|
print "$CGI_SUB_SWITCH=$CGI_SEARCH_RESULT_FLAG&$CGI_DEMO_LIST_SWITCH=$_[0]\"\n";
|
|
print "}\n";
|
|
print "//\n";
|
|
print "</script>\n";
|
|
print "<body OnLoad=\"UpdateSide()\" bgcolor=white>\n";
|
|
print "<table width=100%>\n";
|
|
print "<tr><td align=right><img src=\"$IMGSRC_HEADER_SEARCH\"></td></tr></table>\n";
|
|
print "<center>\n";
|
|
print "<font color=red size=+3>Search Results</font>\n";
|
|
print "</center>\n";
|
|
print "<p>\n";
|
|
|
|
}
|
|
|
|
sub Print_Search_Name_Top {
|
|
print "<center>\n";
|
|
print "<p>\n";
|
|
print "<b>TITLE: <font color=blue>$in{$CGI_SEARCH_NAME_SWITCH}</font></b>\n";
|
|
print "<p>\n";
|
|
print "</center>\n";
|
|
}
|
|
|
|
sub Print_Search_Category_Top {
|
|
print "<center>\n";
|
|
print "<table width=90%>\n";
|
|
print "<tr>\n";
|
|
print "<td>\n";
|
|
print "<dl><dt><b>Searched for demos that</b>\n";
|
|
# if market is selected then print that info
|
|
if ( $#markets_q != -1 ) {
|
|
print "<dd>were in the\n";
|
|
for (@markets_q) {
|
|
print "<font color=blue>\U$_\E</font>\n";
|
|
print "<font color=red>$logic{'WITHIN'}</font>\n" if ($_ ne $markets_q[$#markets_q]);
|
|
}
|
|
print "<b>Industry</b>";
|
|
# If features or hardware are selected then print AND/OR
|
|
if ( ($#features_q != -1) || ($#hardware_q != -1) ) {
|
|
print ",<br>\n";
|
|
print "<dd><font size=+1 color=red><i>$logic{'BETWEEN'}</i></font>\n";
|
|
}
|
|
else { print "<br>\n"; }
|
|
}
|
|
# if last category was empty indent
|
|
else { print "<dd>"; }
|
|
|
|
# if feature is selected then print that info
|
|
if ( $#features_q != -1 ) {
|
|
print "had\n";
|
|
for (@features_q) {
|
|
print "<font color=blue>\U$_\E</font>\n";
|
|
print "<font color=red>$logic{'WITHIN'}</font>\n" if ($_ ne $features_q[$#features_q]);
|
|
}
|
|
print "<b>Features</b>";
|
|
# If hardware are selected then print AND/OR
|
|
if ( $#hardware_q != -1 ) {
|
|
print ",<br>\n";
|
|
print "<dd><font size=+1 color=red><i>$logic{'BETWEEN'}</i></font>\n";
|
|
}
|
|
else { print "<br>\n"; }
|
|
}
|
|
|
|
# if hardware is selected then print that info
|
|
if ( $#hardware_q != -1 ) {
|
|
if ( ($#markets_q == -1) && ($#features_q == -1) ) { print "<dd>"; } # if last category was empty indent
|
|
print "uses\n";
|
|
for (@hardware_q) {
|
|
print "<font color=blue>\U$_\E</font>\n";
|
|
print "<font color=red>$logic{'WITHIN'}</font>\n" if ($_ ne $hardware_q[$#hardware_q]);
|
|
}
|
|
print "<b>Hardware</b>";
|
|
}
|
|
print "</dl>\n";
|
|
print "</td>";
|
|
print "</tr>";
|
|
print "</table>\n";
|
|
print "</center>\n";
|
|
}
|
|
|
|
sub Find_Demos_By_Title {
|
|
local(@match_demos, %demo_list);
|
|
# List all demos
|
|
&Assoc_Demos_In_All_Trees; # produces %demo_list
|
|
@match_demos = grep(/$_[0]/i, keys %demo_list);
|
|
foreach $i (0 .. $#match_demos) {
|
|
$match_demos[$i] = "$match_demos[$i]$HTTP_TREES_DELIM$demo_list{$match_demos[$i]}";
|
|
}
|
|
grep( (s/$TREES_DELIM/$HTTP_TREES_DELIM/g), @match_demos);
|
|
grep( (s/\s/$HTTP_GET_DELIM/g), @match_demos);
|
|
return(&alpha(@match_demos));
|
|
}
|
|
|
|
sub Print_Search_Form_Page {
|
|
&Print_Search_Form_Top;
|
|
&Print_Search_Form_Bottom;
|
|
}
|
|
|
|
sub Print_Search_Form_Top {
|
|
&Print_HTTP_Header;
|
|
print "<body bgcolor=white>\n";
|
|
print "<table width=100%>\n";
|
|
print "<tr><td align=right><img src=\"$IMGSRC_HEADER_SEARCH\"></td></tr></table>\n";
|
|
print "<center>\n";
|
|
print "<font color=red size=+3>Search For Demos</font>\n";
|
|
print "</center>\n";
|
|
print "<table width=100%>\n";
|
|
print "<tr><td>\n";
|
|
print "<pre> </pre>\n";
|
|
print "</td><td>\n";
|
|
print "<p>\n";
|
|
print "<center><img src=\"$IMGSRC_GRADHRY\"></center>\n";
|
|
print "<p>\n";
|
|
}
|
|
|
|
sub Print_Search_Form_Results_Mid {
|
|
# print "<p>\n";
|
|
# print "<hr>\n";
|
|
print "<center>\n";
|
|
print "<font size=2 color=red> <<<--- Results Are Displayed In The Left Frame.</font>\n";
|
|
print "</center>\n";
|
|
print "<hr size=\"4\">\n";
|
|
print "<p>\n";
|
|
}
|
|
|
|
sub Print_Search_Form_Bottom {
|
|
print "<i><font color=red size=+1>TITLE SEARCH</font></i>\n";
|
|
print "<center>\n";
|
|
print "<font size=-1 color=blue>\n";
|
|
print "<form method=\"GET\" action=\"$WWW_SCRIPT\">\n";
|
|
print "<input type=hidden name=$CGI_SWITCH value=$FRAME_MAIN>\n";
|
|
print "<input type=hidden name=$CGI_SUB_SWITCH value=$CGI_SEARCH_FLAG>\n";
|
|
print "<table bgcolor=\"$INPUT_BGCOLOR\">\n";
|
|
print "<tr>\n<td>\n";
|
|
print "<font color=blue>Title:</font> <input name=$CGI_SEARCH_NAME_SWITCH value=\"$in{$CGI_SEARCH_NAME_SWITCH}\" ";
|
|
print "size=30> <font color=blue><input type=submit value=\"Search\"></font><br>\n";
|
|
print "</td>\n</tr>\n";
|
|
print "</table>\n";
|
|
print "</form>\n";
|
|
print "</font>\n";
|
|
print "</center>\n";
|
|
print "<p>\n";
|
|
print "<center><img src=\"$IMGSRC_GRADHRY\"></center>\n";
|
|
print "<p>\n";
|
|
print "<i><font color=red size=+1>CATEGORY SEARCH</font></i>\n";
|
|
|
|
print "<p>\n";
|
|
print "<center>\n";
|
|
print "<table width=380>\n";
|
|
print "<tr><td>\n";
|
|
print "Select any combination of Industries, Features, and/or\n";
|
|
print "Hardware, then click on the "Submit Query" button.\n";
|
|
print "</td></tr>\n";
|
|
print "</table>\n";
|
|
print "</center>\n";
|
|
|
|
print "<form method=\"GET\" action=\"$WWW_SCRIPT\">\n";
|
|
print "<input type=hidden name=$CGI_SWITCH value=$FRAME_MAIN>\n";
|
|
print "<input type=hidden name=$CGI_SUB_SWITCH value=$CGI_SEARCH_FLAG>\n";
|
|
print "</td></tr>\n";
|
|
print "</table>\n";
|
|
print "<center><table>\n";
|
|
print "<tr>\n";
|
|
print "<td bgcolor=$INPUT_BGCOLOR align=center>\n";
|
|
print "<font color=blue>INDUSTRIES:</font><br>\n";
|
|
print "<font size=-1><select name=MARKETS multiple size=8>\n";
|
|
for $market (@markets_categories) {
|
|
print "<option value=\"$market\" ";
|
|
print "selected" if (grep(/^$market$/i, @markets_q));
|
|
print " >\U$market\E\n";
|
|
}
|
|
print "</select><br></td>\n";
|
|
print "<td bgcolor=$INPUT_BGCOLOR align=center><font color=blue>FEATURES:</font><br>\n";
|
|
print "<font size=-1><select name=\"FEATURES\" multiple size=8>\n";
|
|
for $feature (@features_categories) {
|
|
print "<option value=\"$feature\" ";
|
|
print "selected" if (grep(/^$feature$/i, @features_q));
|
|
print " >\U$feature\E\n";
|
|
}
|
|
print "</select></td>\n</tr>\n</table><br>\n";
|
|
print "<table bgcolor=$INPUT_BGCOLOR>\n<tr>\n<td align=center>\n";
|
|
print "<font color=blue>HARDWARE:</font><br>\n";
|
|
print "<font size=-1><select name=\"HARDWARE\" multiple size=8>\n";
|
|
for $hardware (@hardware_categories) {
|
|
print "<option value=\"$hardware\" ";
|
|
print "selected" if (grep(/^$hardware$/i, @hardware_q));
|
|
print " >\U$hardware\E\n";
|
|
}
|
|
print "</select>\n";
|
|
print "</td>\n</tr>\n</table>\n";
|
|
print "</center>\n";
|
|
print "<center>\n";
|
|
print "<table bgcolor=$INPUT_BGCOLOR>\n<tr>\n<td>\n";
|
|
print "<font size=2 color=blue>\n";
|
|
print "<select name=$CGI_SEARCH_ADV_SWITCH>\n";
|
|
print "<option value=\"$SEARCH_DEFAULT_LOGIC\" ";
|
|
print "selected" if ("$in{$CGI_SEARCH_ADV_SWITCH}" eq "$SEARCH_DEFAULT_LOGIC");
|
|
print " >Normal Search\n";
|
|
# print "<option value=\"$SEARCH_DEFAULT_LOGIC\">------------------\n";
|
|
print "<option value=\"$SEARCH_ANY_LOGIC\" ";
|
|
print "selected" if ("$in{$CGI_SEARCH_ADV_SWITCH}" eq "$SEARCH_ANY_LOGIC");
|
|
print " >Match ANY Selected Items\n";
|
|
print "<option value=\"$SEARCH_ALL_LOGIC\" ";
|
|
print "selected" if ("$in{$CGI_SEARCH_ADV_SWITCH}" eq "$SEARCH_ALL_LOGIC");
|
|
print " >Match ALL Selected Items\n";
|
|
print "</select>\n";
|
|
print "</font><br>\n";
|
|
print "</td>\n</tr>\n</table>\n";
|
|
print "<table bgcolor=$INPUT_BGCOLOR>\n<tr>\n<td>\n";
|
|
print "<font color=blue><input type=reset value=\"Reset Forms\">\n";
|
|
print "<input type=submit value=\"Submit Query\"><br>\n";
|
|
print "</font>\n";
|
|
print "</td>\n</tr>\n</table>\n";
|
|
print "</form>\n";
|
|
print "<p>\n";
|
|
print "<center><img src=\"$IMGSRC_GRADHRY\"></center>\n";
|
|
print "<p>\n";
|
|
&Print_HTTP_Footer;
|
|
}
|