#!/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 "\n"; print "\n"; print "\n"; print "
\n"; print "
\n"; print "Search Results\n"; print "
\n"; print "

\n"; } sub Print_Search_Name_Top { print "

\n"; print "

\n"; print "TITLE: $in{$CGI_SEARCH_NAME_SWITCH}\n"; print "

\n"; print "

\n"; } sub Print_Search_Category_Top { print "
\n"; print "\n"; print "\n"; print ""; print ""; print "
\n"; print "
Searched for demos that\n"; # if market is selected then print that info if ( $#markets_q != -1 ) { print "
were in the\n"; for (@markets_q) { print "\U$_\E\n"; print "$logic{'WITHIN'}\n" if ($_ ne $markets_q[$#markets_q]); } print "Industry"; # If features or hardware are selected then print AND/OR if ( ($#features_q != -1) || ($#hardware_q != -1) ) { print ",
\n"; print "
$logic{'BETWEEN'}\n"; } else { print "
\n"; } } # if last category was empty indent else { print "
"; } # if feature is selected then print that info if ( $#features_q != -1 ) { print "had\n"; for (@features_q) { print "\U$_\E\n"; print "$logic{'WITHIN'}\n" if ($_ ne $features_q[$#features_q]); } print "Features"; # If hardware are selected then print AND/OR if ( $#hardware_q != -1 ) { print ",
\n"; print "
$logic{'BETWEEN'}\n"; } else { print "
\n"; } } # if hardware is selected then print that info if ( $#hardware_q != -1 ) { if ( ($#markets_q == -1) && ($#features_q == -1) ) { print "
"; } # if last category was empty indent print "uses\n"; for (@hardware_q) { print "\U$_\E\n"; print "$logic{'WITHIN'}\n" if ($_ ne $hardware_q[$#hardware_q]); } print "Hardware"; } print "
\n"; print "
\n"; print "
\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 "\n"; print "\n"; print "
\n"; print "
\n"; print "Search For Demos\n"; print "
\n"; print "\n"; print "\n"; print "
\n"; print "
  
\n"; print "
\n"; print "

\n"; print "

\n"; print "

\n"; } sub Print_Search_Form_Results_Mid { # print "

\n"; # print "


\n"; print "
\n"; print " <<<--- Results Are Displayed In The Left Frame.\n"; print "
\n"; print "
\n"; print "

\n"; } sub Print_Search_Form_Bottom { print "TITLE SEARCH\n"; print "

\n"; print "\n"; print "
\n"; print "\n"; print "\n"; print "\n"; print "\n\n\n"; print "
\n"; print "Title:
\n"; print "
\n"; print "
\n"; print "
\n"; print "
\n"; print "

\n"; print "

\n"; print "

\n"; print "CATEGORY SEARCH\n"; print "

\n"; print "

\n"; print "\n"; print "\n"; print "
\n"; print "Select any combination of Industries, Features, and/or\n"; print "Hardware, then click on the "Submit Query" button.\n"; print "
\n"; print "
\n"; print "
\n"; print "\n"; print "\n"; print "
\n"; print "
\n"; print "\n"; print "\n"; print "\n\n
\n"; print "INDUSTRIES:
\n"; print "
FEATURES:
\n"; print "

\n"; print "\n\n\n\n
\n"; print "HARDWARE:
\n"; print "\n"; print "
\n"; print "
\n"; print "
\n"; print "\n\n\n\n
\n"; print "\n"; print "\n"; print "
\n"; print "
\n"; print "\n\n\n\n
\n"; print "\n"; print "
\n"; print "
\n"; print "
\n"; print "\n"; print "

\n"; print "

\n"; print "

\n"; &Print_HTTP_Footer; }