package JCRUtil; # -------------------------------------------------------------------- # 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: JCRUtil.pm,v 1.9 2008/10/30 20:13:18 ssidanal Exp $ use strict; use Data::Dumper; use ISIBench; use JCRErrorList; use JCR::MarkedList; use Log::Log4perl qw(get_logger); =head1 NAME JCRUtil - General utility functions for JCRWeb =head2 METHODS =over 4 =cut =item build_sort_box('selected' => ('title'||'cites_all'||'impact_current'||'immediacy'||'source_current'||'cited_hlife') Creates a sort box and sets the selected value if provided. If no selected value is provided 'title' will be the default. =cut sub build_sort_box { ISIBench::start(); my $logger = get_logger("JCRUtil"); my $args = (ref $_[0] eq 'HASH') ? shift : { @_ }; my %selection; my $html; my $year = $args->{year}; $logger->debug("build_sort_box params are: ", sub{Dumper($args)}); if ( $args->{sort_box_type} =~ /journal/i ) { if ($args->{selected} =~ /(title|cites_all|impact_current|immediacy|source_current|cited_hlife|impact_5year|eigen_factor|article_influence)/i) { $selection{$1} = 'SELECTED'; } else { $selection{title} = 'SELECTED'; } if ($year >= $CF::data_eigen_impact_start){ $html = qq| |; }else{ $html = qq| |; } $logger->debug("build_sort_box data is: ", sub{Dumper(\%selection)}); ISIBench::stop(); return { 'html' => $html } } sub build_search_box { ISIBench::start(); my $logger = get_logger("JCRUtil"); my $args = (ref $_[0] eq 'HASH') ? shift : { @_ }; my %selection; $logger->debug("build_search_box params are: ", sub{Dumper($args)}); if ($args->{selected} =~ /(search_full_title|search_j20|search_title_word|search_issn)/i) { $selection{$1} = 'SELECTED'; } else { $selection{search_full_title} = 'SELECTED'; } $logger->debug("build_search_box data is: ", sub{Dumper(\%selection)}); my $html = qq| |; ISIBench::stop(); return { 'html' => $html } } sub map_sort_names { ISIBench::start(); my $logger = get_logger("JCRUtil"); my $args = (ref $_[0] eq 'HASH') ? shift : { @_ }; my $sort_by = $args->{sort}; my %sort_hash = ( 'title' => 'Journal Title', 'cites_all' => 'Total Cites', 'impact_current' => 'Impact Factor', 'immediacy' => 'Immediacy Index', 'source_current' => 'Current Articles', 'cited_hlife' => 'Cited Half-Life', 'eigen_factor' => 'Eigenfactor(TM) Score', 'article_influence' => 'Article Influence(TM) Score', 'impact_5year' => '5 Year Impact Factor', ); ISIBench::stop(); return $sort_hash{$sort_by}; } =item purge_marked_list('session' => $session, 'db' => $db) Purges the user's marked list. =cut sub purge_marked_list { ISIBench::start(); my $logger = get_logger("JCRUtil"); my $args = (ref $_[0] eq 'HASH') ? shift : { @_ }; my $session = $args->{session}; my $db = $args->{db}; my $edition = $session->get( 'value' => 'edition' ); my $year = $session->get( 'value' => 'year' ); $logger->debug("Purging existing marked list..."); my $marked_list = JCR::MarkedList->new( 'session' => $session, 'max_marked' => $CF::marked_list_max, 'db' => $db, 'edition' => $edition->{edition}, 'year' => $year->{year}, ); if (defined($marked_list) && (ref($marked_list) =~ /markedlist/i)) { $marked_list->clear_marked_list(); } ISIBench::stop(); return 0; } 1;