package JCRPage; # -------------------------------------------------------------------- # The copyright and all other proprietary rights in this Database # (including software - SEE LICENSING AGREEMENT) are the sole and # exclusive property of the Institute for Scientific Information # (ISI). This Database and source code, or any derivative works # thereof, are confidential and proprietary to ISI . Therefore, # duplication, reuse, redistribution, reverse assembling, reverse # compiling, or translation of the Database, source code, or any # portion thereof IS NOT PERMITTED. Consult Licensing Agreement. # -------------------------------------------------------------------- # $Id: JCRPage.pm,v 1.2 2006/07/31 17:37:14 pfoley Exp $ use strict; use base qq(Page); use ISIBench; use Template; use Log::Log4perl qw(get_logger); use JCR::MarkedList; use Toolbar; use Data::Dumper; =head1 NAME JCRPage - JCR Page object which overrides some methods of Page.pm =head2 METHODS =over 4 =cut =item get_content(); Method used by JCRDispatcher.pm to get the page content. =cut sub get_content { ISIBench::start(); my $logger = get_logger("Page"); my $self = shift; my $ret; # Add on the toolbar if it has been built if (exists $self->{toolbar}) { my $toolbar_html = $self->{toolbar}->build(); $self->set( 'name' => 'toolbar', 'value' => $toolbar_html->{html}, ); } # Set some JCR specific values from session if (defined $self->{session}) { my $edition = $self->{session}->get('value' => 'edition'); my $year = $self->{session}->get('value' => 'year'); $self->set( 'name' => 'year', 'value' => $year->{year}, ); $self->set( 'name' => 'edition', 'value' => ($edition->{edition} eq 'social') ? 'Social Science' : 'Science', ); } # Set the page title if it is set if (exists $self->{title}) { $self->set( 'name' => 'title', 'value' => $self->{title}, ); } # Process the template if (defined $self->{template} && (ref($self->{template}) =~ /template/i)) { $ret = $self->{template}->dump(); } else { $ret = $self->{content}; } ISIBench::stop(); return $ret; } =item build_toolbar( 'help' => $help_tag, # OPTIONAL: Tag to help placeholder for context # sensitive help ); Creates and returns a toolbar object. =cut sub build_toolbar { ISIBench::start(); my $logger = get_logger("Page"); my $self = shift; my $args = (ref $_[0] eq 'HASH') ? shift : { @_ }; my $session = $self->{session}; my $request = $self->{request}; my $toolbar = Toolbar->new( 'buttons' => $CF::buttons, 'path' => $CF::image_path, 'default' => ['TB_HOME'], 'SID' => $session->{SID}, ); unless (defined($toolbar) && (ref($toolbar) =~ /toolbar/i)) { ISIBench::stop(); return $toolbar; } # Now that we have the toolbar, add any other buttons needed # Add the Help Button $toolbar->add( 'button' => 'TB_HELP', 'params' => { 'help_context' => $args->{help} }, ); # Note that these are only for buttons that 'could' appear on # all toolbars. # Add the marked list button unless ($request->{RQ} =~ /list_marked/i) { my $edition = $session->get( 'value' => 'edition' ); my $year = $session->get( 'value' => 'year' ); my $marked_list = JCR::MarkedList->new( 'session' => $session, 'max_marked' => $CF::marked_list_max, 'db' => $self->{db}, 'edition' => $edition->{edition}, 'year' => $year->{year}, ); if (defined($marked_list) && (ref($marked_list) =~ /markedlist/i)) { my $count = $marked_list->get_marked_list_count(); if ((ref($count) =~ /hash/i) && ($count->{count} > 0)) { $toolbar->add( 'button' => 'TB_MARKED' ); } } } else { # FIXME - Return to summary is not present if user 'Link'ed into JCR $toolbar->add( 'button' => 'TB_RET2SUMMARY_JOURNAL', ); } my $source_app = $session->get( 'value' => 'source_app_URI' ); my $source_app_image = $session->get( 'value' => 'source_image_URI' ); my $source_app_alttext = $session->get( 'value' => 'source_image_alttext' ); if (defined ($source_app->{source_app_URI})) { $toolbar->add( 'button' => 'TB_RET2APP', 'URI' => $source_app->{source_app_URI}, 'filename' => $source_app_image->{source_image_URI}, 'alttext' => $source_app_alttext->{source_image_alttext}, ); } $self->{toolbar} = $toolbar; ISIBench::stop(); return $self->{toolbar}; } 1;