#!/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_add.pl # # Routines to add or edit demos 1; # return true # INPUT: %in {global} # Based on the CGI input, we can take the appropriate actions and generate # the appropriate pages. sub Generate_Maint_Add_Page { if ($in{$CGI_ADD_NAME_SWITCH}) { if ($in{$CGI_ADD_WRITE_SWITCH}) { &Generate_Example_Page; } else { &Generate_Edit_Info_Page("$in{$CGI_ADD_NAME_SWITCH}","$in{$CGI_TREE_SWITCH}"); } } else { # Print the default top level page &Print_Add_Front_Page; } } # INPUT: %in # Given the user input to the add/edit forms page, take the following actions # - Create header image with the demos title on top # - Write a new .index file # - Update the tables in the background # - Notify user that we are updating tables # - Print a message to the error log # - Finally, display what the page will look like sub Generate_Example_Page { $tree_path = &Tree_Path_From_Name("$in{$CGI_TREE_SWITCH}"); &Create_Header_Image; &Write_Index_File; &Update_Tables; # &Notify_User; &Print_Error("$ERROR_INFO","Added $in{$CGI_ADD_NAME_SWITCH} to interface.","$STATUS_MINOR"); &Display_Example_Page; } # INPUT: %in # After add/editing a page, display it by calling a routine from DEMO_main.pl sub Display_Example_Page { &Print_Demo_Info_Page($in{$CGI_ADD_NAME_SWITCH}, $in{$CGI_TREE_SWITCH}, 1); } # INPUT: # Notify the user about updating tables by calling routine from DEMO_pop.pl sub Notify_User { &Pop("Updating Demo Information", "$FILE_UPDATE_NOTIFY") if ($NOTIFY_USER); } # INPUT: %in # Write user input data to the .index file of a demo sub Write_Index_File { open(INDEX, ">$tree_path/$in{$CGI_ADD_NAME_SWITCH}/$DEMOSRC_INDEX"); select(INDEX); print "MARKETS:\n"; print "$in{'MARKETS'}\n"; print "END_MARKETS\n"; print "\n"; print "FEATURES:\n"; print "$in{'FEATURES'}\n"; print "END_FEATURES\n"; print "\n"; print "HARDWARE:\n"; print "$in{'HARDWARE'}\n"; print "END_HARDWARE\n"; print "\n"; print "OTHER_INFORMATION:\n"; print "$in{'OTHER_INFORMATION'}\n"; print "END_OTHER_INFORMATION\n"; print "\n"; print "TITLE:\n"; print "$in{'TITLE'}\n"; print "END_TITLE\n"; print "\n"; print "AUTHOR:\n"; print "$in{'AUTHOR'}\n"; print "END_AUTHOR\n"; print "\n"; print "DESCRIPTION:\n"; print "$in{'DESCRIPTION'}\n"; print "END_DESCRIPTION\n"; print "\n"; print "BRIEF_INSTRUCTIONS:\n"; print "$in{'BRIEF_INSTRUCTIONS'}\n"; print "END_BRIEF_INSTRUCTIONS\n"; print "\n"; print "DETAILED_INSTRUCTIONS:\n"; print "$in{'DETAILED_INSTRUCTIONS'}\n"; print "END_DETAILED_INSTRUCTIONS\n"; print "\n"; print "SYSTEM_REQS:\n"; print "$in{'SYSTEM_REQS'}\n"; print "END_SYSTEM_REQS\n"; print "\n"; print "END_HTMLUI\n"; print "# Information in this section is either not used by\n"; print "# the HTML interface or is misformatted and can't\n"; print "# be read by the HTML interface.\n"; print "#\n"; print "\n"; select(STDOUT); close(INDEX); } # INPUT: %in # Create a header image using the appropriate text string using the "imgcomp" # script by Paul Harberli sub Create_Header_Image { # Make imgcomp script open(IMGSCRIPT, ">$FILE_IMGCOMP_TMP"); print IMGSCRIPT "GLOBALSCALE 1.0\n"; print IMGSCRIPT "IMGSIZE 617 134\n"; print IMGSCRIPT "SETCOLOR 253 186 53\n"; print IMGSCRIPT "CLEARSCREEN\n"; print IMGSCRIPT "SETFONT Times-Roman 33\n"; print IMGSCRIPT "SHOWIMAGE $FILE_HEADER_BACK 0 0\n"; print IMGSCRIPT "SETCOLOR 253 186 53\n"; print IMGSCRIPT "CHARPOS 600 80\n"; print IMGSCRIPT "LEFTTEXT $in{'TITLE'}\n"; close(IMGSCRIPT); # Set environment vaiable $ENV{'IL_READ_THREADS'} = 0; # Generate the header image `$CMD_IMGCOMP $FILE_IMGCOMP_TMP $FILE_HEADER_TMP.$EXT_RGB 1$CMD_NULLIFY 2>&1 `; `$CMD_IMGCOPY $CMD_IMGCOPY_FLAGS $FILE_HEADER_TMP.$EXT_RGB $FILE_HEADER_TMP.$EXT_JPG 1$CMD_NULLIFY 2>&1 `; # Move the image `$CMD_MV $FILE_HEADER_TMP.$EXT_JPG $tree_path/$in{$CGI_ADD_NAME_SWITCH}/$DEMOSRC_HEADER 2>&1 `; # Remove the comp file `$CMD_RM $FILE_IMGCOMP_TMP`; } # INPUT: ($demo_name, $tree_name) # Manage the editing of an already existing demo. This includes adding default # images, checking permissions and setup, and creating info forms. sub Generate_Edit_Info_Page { &Add_Thumbnail_Image("$_[0]", "$_[1]") if ("$in{$CGI_ADD_THUMBNAIL_SWITCH}" eq "$CGI_MAINT_TRUE_FLAG"); &Add_Pic_Image("$_[0]", "$_[1]") if ("$in{$CGI_ADD_PIC_SWITCH}" eq "$CGI_MAINT_TRUE_FLAG"); if (!&Demo_Dir_Exists("$_[0]", "$_[1]")) { &Print_No_Dir_Error_Page; } elsif (!&Dir_Setup_Legal("$_[0]", "$_[1]")) { &Print_Not_Legal_Error_Page; } else { &Print_Edit_Info_Page; } } # INPUT: %in # Create the edit info forms, the last step in editing a demo. sub Print_Edit_Info_Page { local($path); $path = &Tree_Path_From_Name("$in{$CGI_TREE_SWITCH}"); &Parse_Demo_Info("$path/$in{$CGI_ADD_NAME_SWITCH}/$DEMOSRC_INDEX") if ($indexfound); &Print_Maint_Top("Edit Demo: Customize Demo Information", "$IMGSRC_HEADER_EDITINFO"); print "INFORMATION

\n"; print "\n \n"; print "\n"; print " \n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
"; print "
\n"; print "
DEMO NAME:$in{$CGI_ADD_NAME_SWITCH}
DEMO PATH:$path/$in{$CGI_ADD_NAME_SWITCH}/
TITLE:
AUTHOR:
DESCRIPTION:
\n"; print "
BRIEF INSTRUCTIONS:
\n"; print "
DETAILED INSTRUCTIONS:
\n"; print "
OTHER INFORMATION:
\n"; print "
SYSTEM REQUIREMENTS:
\n"; print "
\n"; print "\n"; print "\n"; print "\n\n
\n"; print "INDUSTRIES:
\n"; &Print_Category_Chooser("MARKETS", @markets_categories); print "
\n

\n"; print "FEATURES:
\n"; &Print_Category_Chooser("FEATURES", @features_categories); print "

\n

\n"; print "\n\n\n\n
\n"; print "HARDWARE:
\n"; &Print_Category_Chooser("HARDWARE", @hardware_categories); print "\n

\n"; print "\n"; print "

\n"; print "

\n"; print "
\n"; print "\n"; print "\n"; &Print_Look_At_Help; &Print_Maint_Bottom; &Print_HTTP_Footer; } # INPUT: ($category) # Create the category chooser as part of the edit info page sub Print_Category_Chooser { local($category, $bullet, @links); $category = shift(@_); @links = split(/\n/, $demo_info{$category}); print "\n"; } # INPUT: ($demo_name, $tree_name) # Add a thumbnail image to a demo directory sub Add_Thumbnail_Image { local($path); $path = &Tree_Path_From_Name("$_[1]"); &Copy_File("$FILE_DEFAULT_THUMB", "$path/$_[0]/$DEMOSRC_THUMBNAIL"); } # INPUT: ($demo_name, $tree_name) # Add a demo image to a demo directory sub Add_Pic_Image { local($path); $path = &Tree_Path_From_Name("$_[1]"); &Copy_File("$FILE_DEFAULT_DEMO", "$path/$_[0]/$DEMOSRC_DEMOPIC"); } # INPUT: ($location1, $location2) # Copy a file from one location to another sub Copy_File { `cp $_[0] $_[1]`; } # INPUT: ($demo_name, $tree_name) # Test the permissions and setup of a particular demo directory sub Dir_Setup_Legal { local($path); $path = &Tree_Path_From_Name("$_[1]"); &Legal_Properties("$path/$_[0]"); if (!$indexfound) { $indexVal = 1; } else { $indexVal = $indexstate; } if (!$headerfound) { $headerVal = 1; } else { $headerVal = $headerstate; } return( $directorystate && $demostate && $thumbstate && $headerVal && $picstate && $indexVal ); } # INPUT: %in # Print out an error page if the directory setup is not legal sub Print_Not_Legal_Error_Page { local($path); $path = &Tree_Path_From_Name("$in{$CGI_TREE_SWITCH}"); &Print_Maint_Top("Error: Necessary Files/Permissions Not Found", "$IMGSRC_HEADER_ADDEDIT"); print "INFORMATION

\n"; print "The directory
\n"; print "

$path/$in{$CGI_ADD_NAME_SWITCH}
\n
\n"; print "did not contain the necessary files and/or permissions\n"; print "
\n

\n


\n
\n"; &Print_Not_Legal_Error_List; &Print_Look_At_Help; &Print_Maint_Bottom; &Print_HTTP_Footer; } # INPUT: %in # Print out the body of the error page, with pop-up links sub Print_Not_Legal_Error_List { print "ERRORS

\n"; print "

\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; &Print_Directorystate_Error if (! $directorystate); &Print_Indexstate_Error if (! $indexVal); &Print_Thumbfound_Error if (! $thumbfound); &Print_Thumbstate_Error if ( (!$thumbstate) && ($thumbfound) ); &Print_Picfound_Error if (! $picfound); &Print_Picstate_Error if ( (!$picstate) && ($picfound) ); &Print_Demofound_Error if (! $demofound); &Print_Demostate_Error if ( (!$demostate) && ($demofound) ); &Print_Headerstate_Error if ( !$headerVal); print "
\n"; print "\n"; print ""; print "\n"; print "\n"; print "
\n"; } # INPUT: ($demo_name, $tree_name) # Test to see if a demo dir exists sub Demo_Dir_Exists { local($path); $path = &Tree_Path_From_Name("$_[1]"); return(chdir("$path/$_[0]")); } # INPUT: %in # Print error page when a directory does not exist sub Print_No_Dir_Error_Page { &Print_Maint_Top("Error: Directory Not Found", "$IMGSRC_HEADER_ADDEDIT"); print "INFORMATION

\n"; print "The directory
\n"; $path = &Tree_Path_From_Name("$in{$CGI_TREE_SWITCH}"); print "

$path/$in{$CGI_ADD_NAME_SWITCH}
\n
\n"; print "was not found. Please specify a new demo. \n"; # print "
\n

\n


\n
\n"; # &Print_Add_Form; print "
\n

\n


\n
\n"; &Print_Edit_Form; &Print_Look_At_Help; &Print_Maint_Bottom; &Print_HTTP_Footer; } # INPUT: # Print out the from page for adding a demo sub Print_Add_Front_Page { &Print_Maint_Top("Add a Demo", "$IMGSRC_HEADER_ADDEDIT"); print "INSTRUCTIONS

\n"; print "

  • Select a demo list and enter the demo name.
    \n"; print "
  • The named demo must reside in the same directory as the rest of the demos in the tree that it is being added to.
    \n"; print "
  • If you wish to add a group of new of demos, please use the \n"; print ""Add a Group of Demos" utility.\n"; print "

    \n


    \n"; &Print_Add_Form; # print "
    \n

    \n


    \n"; # &Print_Edit_Form; &Print_Look_At_Help; &Print_Maint_Bottom; &Print_HTTP_Footer; } # INPUT: # Print out the from page for adding a demo sub Print_Edit_Front_Page { &Print_Maint_Top("Edit Demo", "$IMGSRC_HEADER_EDITINFO"); print "INSTRUCTIONS

    \n"; print "Select a demo name and edit that demo's detailed information. \n"; # print "

    \n


    \n"; # &Print_Add_Form; print "
    \n

    \n


    \n"; &Print_Edit_Form; &Print_Look_At_Help; &Print_Maint_Bottom; &Print_HTTP_Footer; } # INPUT: # Print out the edit a demo chooser form sub Print_Edit_Form { local($curr_col, $demo, $tree); print "EDIT

    \n"; for $tree ( &List_Tree_Names ) { print "

    $tree

    \n"; print "\n"; print "\n"; $curr_col = 1; for $demo (&Demos_In_Tree("$tree")) { if (&Is_Basically_Legal(&Tree_Path_From_Name("$tree"), "$demo") ) { print "\n" if ($curr_col == 1); print "\n"; print "\n" if ($curr_col == $ADD_COLUMNS); $curr_col = 0 if ($curr_col == $ADD_COLUMNS); ++$curr_col; } } print "
    \n"; print "$demo\n"; print "
    \n"; print "
    \n"; } } # INPUT: # Print out the add a demo form sub Print_Add_Form { local($tree); print "ADD

    \n"; print "

    \n"; print "\n"; print "\n"; print "\n"; print "\n\n\n"; print "\n\n"; print "\n"; print "\n\n
    \n"; @tree_names = &List_Tree_Names; if ($#tree_names >= 1) { print "List: "; print "\n"; print "\n"; } else { print "\n"; } print "\n"; print "
    Name:
    \n"; print "
    \n"; }