package SBEAMS::Microarray::HTMLPrinter; ############################################################################### # Program : SBEAMS::Microarray::HTMLPrinter # Author : Eric Deutsch # $Id$ # # Description : This is part of the SBEAMS::Microarray module which handles # standardized parts of generating HTML. # # This really begs to get a lot more object oriented such that # there are several different contexts under which the a user # can be in, and the header, button bar, etc. vary by context ############################################################################### use strict; use vars qw($sbeams $current_contact_id $current_username $current_work_group_id $current_work_group_name $current_project_id $current_project_name $current_user_context_id); use CGI::Carp qw( croak); use SBEAMS::Connection qw( $log ); use SBEAMS::Connection::DBConnector; use SBEAMS::Connection::Settings; use SBEAMS::Connection::TableInfo; use SBEAMS::Microarray::Settings; use SBEAMS::Microarray::TableInfo; ############################################################################### # Constructor ############################################################################### sub new { my $this = shift; my $class = ref($this) || $this; my $self = {}; bless $self, $class; return($self); } ############################################################################### # printPageHeader ############################################################################### sub printPageHeader { my $self = shift; my %args = @_; my $navigation_bar = $args{'navigation_bar'} || "YES"; #### If the output mode is interactive text, display text header my $sbeams = $self->getSBEAMS(); if ($sbeams->output_mode() eq 'interactive') { $sbeams->printTextHeader(); return; } #### If the output mode is not html, then we don't want a header here if ($sbeams->output_mode() ne 'html') { return; } #### Obtain main SBEAMS object and use its http_header $sbeams = $self->getSBEAMS(); $current_contact_id = $sbeams->getCurrent_contact_id(); if ($sbeams->getCurrent_contact_id() ne 107) { $self->displaySBEAMSPageHeader(@_); } else # Currently only guest mode is SCGAP, will likely change... { $self->displaySCGAPPageHeader(@_); } } sub displaySCGAPPageHeader { my $self = shift; my %args = @_; #### Obtain main SBEAMS object and use its http_header my $sbeams = $self->getSBEAMS(); my $http_header = $sbeams->get_http_header(); use LWP::UserAgent; use HTTP::Request; my $ua = LWP::UserAgent->new(); my $scgapLink = 'http://scgap.systemsbiology.net'; my $response = $ua->request( HTTP::Request->new( GET => "$scgapLink/skin.php" ) ); my @page = split( "\r", $response->content() ); my $skin = ''; for ( @page ) { last if $_ =~ / End of main content/; $skin .= $_; } $skin =~ s/\/images\//\/sbeams\/images\//gm; my $affy_css = $self->getAffyCSS(); print "$http_header\n\n"; print <<" END_PAGE"; $affy_css; $skin END_PAGE $self->printJavascriptFunctions(); } sub getAffyCSS { my $self = shift; my $FONT_SIZE=10; my $FONT_SIZE_SM=9; my $FONT_SIZE_MED=10; my $FONT_SIZE_LG=11; my $FONT_SIZE_HG=12; my $css =<<" END"; END return $css; } sub displaySBEAMSPageHeader { my $self = shift; my %args = @_; #### Obtain main SBEAMS object and use its http_header my $sbeams = $self->getSBEAMS(); my $http_header = $sbeams->get_http_header(); my $navigation_bar = $args{'navigation_bar'} || "YES"; print qq~$http_header $DBTITLE - $SBEAMS_PART ~; $self->printJavascriptFunctions(); $self->printStyleSheet(); #### Determine the Title bar background decoration my $header_bkg = "bgcolor=\"$BGCOLOR\""; $header_bkg = "background=\"$HTML_BASE_DIR/images/plaintop.jpg\"" if ($DBVERSION =~ /Primary/); print qq~ ~; if ($navigation_bar eq "YES") { my $pad = '   '; my $affy_docs = ( $CONFIG_SETTING{MA_AFFY_HELPDOCS_URL} =~ /http/ ) ? "" : ""; $current_work_group_name = $sbeams->getCurrent_work_group_name(); my $mod_link = ucfirst( lc($SBEAMS_PART) ); my $affy =<<" END";
ISB DBSBEAMS

$DBTITLE - $SBEAMS_PART
$DBVERSION

$pad Affy Help Docs
$pad Affy Help Docs
$pad Data Pipeline
$pad Download Data
$pad Get Expression
$pad Affy Gene Intensity
$pad Annotate Files
$affy_docs
 
END my ($af_content, $af_link) = $sbeams->make_toggle_section( content => $affy, name => 'ma_affy_toggle', sticky => 1, visible => 1 ); print qq~ ~; my $two_color_section = ''; unless ( $CONFIG_SETTING{MA_HIDE_TWO_COLOR} ) { my $two_color =<<" END";
$DBTITLE Home
$mod_link Home
Logout
 
$af_link Affymetrix Arrays:
$af_content
$pad Data Pipeline
$pad Download Data
$pad Get Expression
$pad Graphical Overview
$pad Array Requests
$pad Labeling
$pad Hybridization
$pad Quantitation
$pad Check Alignment
$pad MIAME Status
$pad Manage Arrays
$pad Pipeline Help
 
END my ($tc_content, $tc_link) = $sbeams->make_toggle_section( content => $two_color, sticky => 1, name => 'ma_twocolor_toggle'); $two_color_section = qq~ $tc_link Two Color Arrays: $tc_content ~; } my $admin_section = ''; if ($current_work_group_name eq "Microarray_admin" || $current_work_group_name eq "Admin" ) { my $admin =<<" END";
$pad Arrays
$pad Array scans
$pad Slide Lots
$pad Array Layouts
$pad Printing Batches
$pad Slide Types
$pad Protocols
END my ($ad_content, $ad_link) = $sbeams->make_toggle_section( content => $admin, name => 'ma_admin_toggle', sticky => 1, visible => 1 ); $admin_section =<<" END"; $ad_link Administration: $ad_content   END } my $message = $sbeams->get_page_message(); my $notice = $sbeams->get_notice( 'Microarray' ); if ( $message ) { $message .= "
$notice\n" if $message; } else { $message = $notice if $notice; } print qq~ $two_color_section $admin_section
$message ~; } else { print qq~
~; } } ############################################################################### # printStyleSheet # # Print the standard style sheet for pages. Use a font size of 10pt if # remote client is on Windows, else use 12pt. This ends up making fonts # appear the same size on Windows+IE and Linux+Netscape. Other tweaks for # different browsers might be appropriate. ############################################################################### sub printStyleSheet { my $self = shift; #### Obtain main SBEAMS object and use its style sheet $sbeams = $self->getSBEAMS(); $sbeams->printStyleSheet(); } sub getBanner { my $this = shift; my $header_bkg = "bgcolor=\"$BGCOLOR\""; $header_bkg = "background=\"/images/plaintop.jpg\"" if ($DBVERSION =~ /Primary/); return <<" END_BANNER";

$DBTITLE - $SBEAMS_PART
$DBVERSION

END_BANNER return <<" END_BANNER"
MICROARRAY LOGOUT
END_BANNER } sub getMenu { my $self = shift; my $sbeams = $self->getSBEAMS(); my $pad = '
   '; my $affy_docs = ( $CONFIG_SETTING{Microarray_affy_help_docs_url} =~ /http/ ) ? "$pad Affy Help Docs" : "$pad Affy Help Docs"; $current_work_group_name = $sbeams->getCurrent_work_group_name(); my $admin_menu; if ($current_work_group_name eq "Microarray_admin" || $current_work_group_name eq "Admin" ) { $admin_menu =<<" END"; Administration: $pad Arrays $pad Array scans $pad Slide Lots $pad Array Layouts $pad Printing Batches $pad Slide Types $pad Protocols END } $BARCOLOR ||= '#FFFFFF'; my $mod_link = ucfirst( lc($SBEAMS_PART) ); my $menu =<<" END"; END unless ( $CONFIG_SETTING{MA_HIDE_TWO_COLOR} ) { $menu .=<<" END"; END } $menu .=<<" END"; $admin_menu
$DBTITLE Home
$mod_link Home
Logout
 
Affymetrix Arrays:
$pad Data Pipeline
$pad Download Data
$pad Get Expression
$pad Affy Gene Intensity
$pad Annotate Files
$affy_docs
 
Two Color Arrays:
$pad Data Pipeline
$pad Download Data
$pad Get Expression
$pad Graphical Overview
$pad Array Requests
$pad Labeling
$pad Hybridization
$pad Quantitation
$pad Check Alignment
$pad MIAME Status
$pad Manage Arrays
$pad Pipeline Help
END return $menu; # This code never gets reached for now, update when needed. if ( exists $CONFIG_SETTING{MA_AFFY_HELPDOCS_URL} && $CONFIG_SETTING{MA_AFFY_HELPDOCS_URL} =~ /http/){ $menu .=<<" END"; Affy Help Docs END } else { $menu .=<<" END"; Affy Help Docs END } } ############################################################################### # printJavascriptFunctions # # Print the standard Javascript functions that should appear at the top of # most pages. There probably should be some customization allowance here. # Not sure how to design that yet. ############################################################################### sub printJavascriptFunctions { my $self = shift; my $javascript_includes = shift; print qq~ ~; } ############################################################################### # printPageFooter ############################################################################### sub printPageFooter { my $self = shift; #### Allow old-style single argument my $n_params = scalar @_; my %args; #### If the old-style single argument exists, create args hash with it if ($n_params == 1) { my $flag = shift; $args{close_tables} = 'NO'; $args{close_tables} = 'YES' if ($flag =~ /CloseTables/); $args{display_footer} = 'NO'; $args{display_footer} = 'YES' if ($flag =~ /Footer/); } else { %args = @_; } #### If the output mode is interactive text, display text header my $sbeams = $self->getSBEAMS(); if ($sbeams->output_mode() eq 'interactive') { $sbeams->printTextHeader(%args); return; } #### If the output mode is not html, then we don't want a header here if ($sbeams->output_mode() ne 'html') { return; } #### Process the arguments list my $close_tables = $args{'close_tables'} || 'YES'; my $display_footer = $args{'display_footer'} || 'YES'; my $separator_bar = $args{'separator_bar'} || 'NO'; #### If closing the content tables is desired if ($close_tables eq 'YES') { print qq~ ~; } #### If displaying a fat bar separtor is desired if ($separator_bar eq 'YES') { print "


\n"; } #### If finishing up the page completely is desired if ($display_footer eq 'YES') { #### Default to the Core footer $sbeams->display_page_footer(display_footer=>'YES'); } } ############################################################################### # print_tabs ############################################################################### sub print_tabs { my $self= shift; my %args = @_; my $SUB_NAME = "print_tabs"; ## Decode argument list my $tab_titles_ref = $args{'tab_titles_ref'} || die "ERROR[$SUB_NAME]:tab_titles_ref not passed"; my $selected_tab = $args{'selected_tab'} || 0; my $parent_tab = $args{'parent_tab'}; my $page_link = $args{'page_link'} || die "ERROR[$SUB_NAME]:page_link not passed"; my $unselected_bg_color = $args{'unselected_bg_color'} || "\#224499"; my $unselected_font_color = $args{'unselected_font_color'} || "\#ffffff"; my $selected_bg_color = $args{'selected_bg_color'} || "\#ffcc33"; my $selected_font_color = $args{'selected_font_color'} || "\#000000"; my $line_color = $args{'line_color'} || "\#3366cc"; ## Define standard variables my @tab_titles = @{$tab_titles_ref}; my $counter = 0; ## Start TABLE print qq~ ~; ## for each desired tab, make one while (@tab_titles) { my $tab_title = shift(@tab_titles); my $link = $tab_title; while ($link =~ /\s+/) { $link =~ s(\s+)(_); } $link =~ tr/A-Z/a-z/; if ($counter == $selected_tab) { print qq~ ~; }else { my $print_parent_tab = $parent_tab ? "&tab=$parent_tab": ''; print qq~ ~; } $counter++; } ## Draw line underneath tabs print qq~ ~; ## Finish table print qq~
  $tab_title  $tab_title 
~; return; } ############################################################################### # Print QuickLinks ############################################################################### sub printQuickLinks { my $self = shift; my $q = shift; } ############################################################################### # change_views_javascript ############################################################################### sub change_views_javascript { print qq~ ~; } ############################################################################### # updateCheckBoxButtons_javascript ############################################################################### sub updateCheckBoxButtons_javascript { print getUpdateCheckBoxButtonsJavascript(); } #+ # #- sub getUpdateCheckBoxButtonsJavascript { return <<" END_JAVASCRIPT"; END_JAVASCRIPT } ############################################################################### # make_checkbox_contol_table ############################################################################### sub get_file_cbox { my $self = shift; my %args = @_; my @box_names = @{$args{box_names}}; my @default_file_types = @ {$args{default_file_types}}; my %cbox; foreach my $file_type (@box_names){ my $checked = ''; if ( grep {$file_type eq $_} @default_file_types) { $checked = "CHECKED"; } $cbox{$file_type} ="" } return \%cbox; } sub make_checkbox_control_table { my $self = shift; my %args = @_; my $cbox = $self->get_file_cbox( %args ); my $table =<<' END'; END for my $bname ( @{$args{box_names}} ){ $table .= ""; } $table .= '
Click to select or de-select all arrays
$bname$cbox->{$bname}
'; # Ouch! I'd rather return the scalar and print from the source. print $table; } ############################################################################### 1; __END__ ############################################################################### ############################################################################### ############################################################################### =head1 NAME SBEAMS::WebInterface::HTMLPrinter - Perl extension for common HTML printing methods =head1 SYNOPSIS Used as part of this system use SBEAMS::WebInterface; $adb = new SBEAMS::WebInterface; $adb->printPageHeader(); $adb->printPageFooter(); $adb->getGoBackButton(); =head1 DESCRIPTION This module is inherited by the SBEAMS::WebInterface module, although it can be used on its own. Its main function is to encapsulate common HTML printing routines used by this application. =head1 METHODS =item B Prints the common HTML header used by all HTML pages generated by theis application =item B Prints the common HTML footer used by all HTML pages generated by this application =item B Returns a form button, coded with javascript, so that when it is clicked the user is returned to the previous page in the browser history. =head1 AUTHOR Eric Deutsch =head1 SEE ALSO perl(1). =cut