package SBEAMS::ProteinStructure::HTMLPrinter; ############################################################################### # Program : SBEAMS::ProteinStructure::HTMLPrinter # Author : Eric Deutsch # $Id$ # # Description : This is part of the SBEAMS::WebInterface 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(fatalsToBrowser croak); use SBEAMS::Connection::DBConnector; use SBEAMS::Connection::Settings; use SBEAMS::Connection::TableInfo; use SBEAMS::Connection::Tables; use SBEAMS::ProteinStructure::Settings; use SBEAMS::ProteinStructure::TableInfo; ############################################################################### # printPageHeader ############################################################################### sub printPageHeader { my $self = shift; $self->display_page_header(@_); } ############################################################################### # display_page_header ############################################################################### sub display_page_header { 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(); my $http_header = $sbeams->get_http_header(); #### Begin the page with the HTTP header and then the TITLE print qq~$http_header $DBTITLE - $SBEAMS_PART ~; #### Check to see if the PI of the project is Halo User. #### If so, print the halo skin. NOTE: you also need to adjust the halo_footer my $current_project = $sbeams->getCurrent_project_id(); my $sql = qq~ SELECT UWG.contact_id FROM $TB_WORK_GROUP WG JOIN $TB_USER_WORK_GROUP UWG ON (WG.work_group_id = UWG.work_group_id) JOIN $TB_PROJECT P ON (P.PI_contact_id = UWG.contact_id) WHERE WG.work_group_name = 'HaloPIs' AND P.project_id = $current_project ~; my @rows = $sbeams->selectOneColumn($sql); # if (scalar(@rows) > 0 ) { if ( $sbeams->is_ext_halo_user() ) { $self->display_ext_halo_template( %args ); return; } $self->printJavascriptFunctions(); $self->printStyleSheet(); my $loadscript = "$args{onload};" || ''; #### Determine the Title bar background decoration my $header_bkg = "bgcolor=\"$BGCOLOR\""; $header_bkg = "background=\"/images/plaintop.jpg\"" if ($DBVERSION =~ /Primary/); print qq~ ~; #print ">>>http_header=$http_header
\n"; if ($navigation_bar eq "YES") { print qq~
ISB DBSBEAMS

$DBTITLE - $SBEAMS_PART
$DBVERSION

~; #### Special links to show if the current user is using the admin group my $current_work_group_name = $sbeams->getCurrent_work_group_name(); if ($current_work_group_name eq 'ProteinStructure_admin') { print qq~ ~; } print qq~
$DBTITLE Home
$SBEAMS_PART Home
Logout
 
Browse Data:
   Browse BioSeqs
   Browse Domain Hits
 
Manage Tables:
   Projects
   BioSequenceSets
   Match Types
   Match Sources
   DB xRefs
 
Documentation:
   Column Definitions
 
~; } 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(); } ############################################################################### # 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; $self->display_page_footer(@_); } ############################################################################### # display_page_footer ############################################################################### sub display_page_footer { my $self = shift; my %args = @_; my $tooltip_footer = $self->getToolTip(); #### 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'; #### Check to see if the PI of the curernt project is a Halobacterium guy. #### If so, print the halo skin if ($display_footer eq 'YES') { my $current_project = $sbeams->getCurrent_project_id(); my $sql = qq~ SELECT UWG.contact_id FROM $TB_WORK_GROUP WG JOIN $TB_USER_WORK_GROUP UWG ON (WG.work_group_id = UWG.work_group_id) JOIN $TB_PROJECT P ON (P.PI_contact_id = UWG.contact_id) WHERE WG.work_group_name = 'HaloPIs' AND P.project_id = $current_project ~; my @rows = $sbeams->selectOneColumn($sql); #### If closing the content tables is desired if ($args{'close_tables'} eq 'YES') { print qq~
~; } #### If displaying a fat bar separtor is desired if ($separator_bar eq 'YES') { print "


\n"; } # if (scalar(@rows) > 0 ) { # Note that we are using is_ext_user as opposed to is PI logic above if ( $sbeams->is_ext_halo_user() ) { $self->display_ext_halo_footer(); return; }else { print $tooltip_footer; $sbeams->display_page_footer(display_footer=>'YES'); } } } ############################################################################### # getToolTipFooter ############################################################################### sub getToolTip { my $self = shift; my $footer = qq~ ~; return $footer; } ############################################################################### # display_ext_halo_template ############################################################################### sub display_ext_halo_template { my $self = shift; my %args = @_; my $loadscript = "$args{onload};" || ''; $self->printJavascriptFunctions(); $self->display_ext_halo_style_sheet(); my $LOGIN_URI = "$SERVER_BASE_DIR$ENV{REQUEST_URI}"; if ($LOGIN_URI =~ /\?/) { $LOGIN_URI .= "&force_login=yes"; } else { $LOGIN_URI .= "?force_login=yes"; } my $HALO_HOME = 'http://halo.systemsbiology.net'; my $buf = qq~
  Halo Research at ISB
~; $buf .= qq~
  Halo Home

Project Information

 Background
 Systems Approach
 Data Integration
 Publications
 Contacts

Organisms

 Halobacterium     sp.NRC-1
 Haloarcula     marismortui

Halo Group Resources

 Oligo Search     (Internal)
 Data FAQ (Internal)
 Student Intern Site
 High School     Education
 Purple Membrane     Model
 Cell Phone Simulation

Software Links

 Cytoscape
 SBEAMS

Baliga Group Links

 Baliga Group
 Dr. Nitin Baliga\'s     Profile
  

~; $buf .= qq~
Proteome Search Results
~; $buf =~ s/=\"\/images/=\"$HALO_HOME\/images/g; #$buf =~ s/href=\"\//href=\"$HTML_BASE_DIR\//g; $buf =~ s/href=\"\//href=\"http:\/\/halo.systemsbiology.net\//g; print $buf; return; } ############################################################################### # display_ext_halo_style_sheet ############################################################################### sub display_ext_halo_style_sheet { my $self = shift; my %args = @_; my $FONT_SIZE=9; my $FONT_SIZE_SM=8; my $FONT_SIZE_LG=12; my $FONT_SIZE_HG=14; if ( $ENV{HTTP_USER_AGENT} =~ /Mozilla\/4.+X11/ ) { $FONT_SIZE=12; $FONT_SIZE_SM=11; $FONT_SIZE_LG=14; $FONT_SIZE_HG=19; } print qq~ ~; return; } ############################################################################### # display_ext_halo_footer ############################################################################### sub display_ext_halo_footer { my $self = shift; my %args = @_; my $tooltip_footer = $self->getToolTip; my $buf = qq~
HOME | BACKGROUND | SYSTEMS APPROACH | DATA INTEGRATION | CONTACTS | PUBLICATIONS | ORGANISMS | INTRANET
© 2005, Institute for Systems Biology, All Rights Reserved
$tooltip_footer ~; $buf =~ s/=\"\/images/=\"$HTML_BASE_DIR\/images/g; print $buf; return; } ############################################################################### 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