<commit_before>
my $publication_detail_page=CXGN::Chado::PublicationDetailPage->new();

package CXGN::Chado::PublicationDetailPage;

use base qw/CXGN::Page::Form::SimpleFormPage/;

use strict;

use CXGN::Page;
use CXGN::Page::FormattingHelpers qw/info_section_html
                                     page_title_html
                                     columnar_table_html
                                     info_table_html
                                     html_optional_show
                                     tooltipped_text
                                   /;
use CXGN::People::Person;
use CXGN::Chado::Publication;
use CXGN::Chado::Pubauthor;
use CXGN::Phenome::Locus;
use CXGN::Phenome::Locus::LocusRanking;
use CXGN::Phenome::Allele;
use CXGN::Chado::Dbxref;
use CXGN::Contact;
use CXGN::People::PageComment;
use CXGN::Tools::Text qw / sanitize_string /;
sub new {
    my $class=shift;
    my $self= $class->SUPER::new(@_);
    $self->set_script_name("publication.pl");
    return $self;
}


sub define_object {
    my $self=shift;
    $self->set_dbh(CXGN::DB::Connection->new() );
    my %args= $self->get_args();
    foreach my $k (keys %args) {
	$args{$k} = sanitize_string($args{$k});
    }
    my $pub_id= $args{pub_id};
    
    unless (!$pub_id || $pub_id =~m /^\d+$/) { $self->get_page->message_page("No publication exists for identifier: $pub_id"); }
    $self->set_object_id($pub_id);
    $self->set_object(CXGN::Chado::Publication->new($self->get_dbh, $self->get_object_id));
    
    $self->set_primary_key("pub_id");
    $self->set_owners();
}


sub display_page {
    my $self=shift;
    my %args = $self->get_args();
    my $publication=$self->get_object();
    my $pub_id = $self->get_object_id();
    my $pub_title = $publication->get_title();
    my $page="/chado/publication.pl?pub_id=?";
    my $action= $args{action} || "";
    if (!$pub_title && $action ne 'new' && $action ne  'store') { $self->get_page->message_page("No publication exists for this identifier");}
    #import javascript libraries    
    $self->get_page()->jsan_use("CXGN.Phenome.Locus");
    $self->get_page()->jsan_use("Prototype");
    $self->get_page()->jsan_use("CXGN.Phenome.Publication");
    
    $self->get_page->header("SGN publication $pub_title");
    print page_title_html("Publication:\t$pub_title\n");
    
    my $edit_links=$self->get_edit_links();
    
    my $pub_html=$edit_links. "<br />". $self->get_form->as_table_string(). "<br />";
    if ($action eq 'new') { print qq |<p><b><a href = "/chado/add_publication.pl?action=new&amp;type=$args{type}&amp;type_id=$args{type_id}&amp;reffering_page=$args{reffering_page}">Store PubMed publication.</a></b></p>|; }
    print info_section_html(title    => 'Publication details',
                            contents => $pub_html ,
			    );
    if ($args{refering_page}) { print qq |<a href="$args{refering_page}">Go back to refering page.</a><br />|; }
    
    my $dbxref_html=$self->get_dbxref_html($publication->get_dbxrefs());
    
    print info_section_html(title    => 'External resources',
                            contents => $dbxref_html ,
			    );
    my $loci_link;
    my @loci= $publication->get_loci();
    foreach my $locus(@loci)  {
	my $locus_id = $locus->get_locus_id();
	my $locus_symbol= $locus->get_locus_symbol();
	my $cname=$locus->get_common_name();
	$loci_link .= qq|<a href="/phenome/locus_display.pl?locus_id=$locus_id">$cname '$locus_symbol'</a><br />| if $locus->get_obsolete() eq 'f';
    }<commit_msg>Fix JS import bugs on /chado/publication.pl<commit_after>package CXGN::Chado::PublicationDetailPage;

use base qw/CXGN::Page::Form::SimpleFormPage/;

use strict;
use warnings;

use CXGN::Page;
use CXGN::Page::FormattingHelpers qw/info_section_html
                                     page_title_html
                                     columnar_table_html
                                     info_table_html
                                     html_optional_show
                                     tooltipped_text
                                   /;
use CXGN::People::Person;
use CXGN::Chado::Publication;
use CXGN::Chado::Pubauthor;
use CXGN::Phenome::Locus;
use CXGN::Phenome::Locus::LocusRanking;
use CXGN::Phenome::Allele;
use CXGN::Chado::Dbxref;
use CXGN::Contact;
use CXGN::People::PageComment;
use CXGN::Tools::Text qw/ sanitize_string /;

my $publication_detail_page=CXGN::Chado::PublicationDetailPage->new();

sub new {
    my $class=shift;
    my $self= $class->SUPER::new(@_);
    $self->set_script_name("publication.pl");
    return $self;
}


sub define_object {
    my $self=shift;
    $self->set_dbh(CXGN::DB::Connection->new() );
    my %args= $self->get_args();
    foreach my $k (keys %args) {
	$args{$k} = sanitize_string($args{$k});
    }
    my $pub_id= $args{pub_id};
    
    unless (!$pub_id || $pub_id =~m /^\d+$/) { $self->get_page->message_page("No publication exists for identifier: $pub_id"); }
    $self->set_object_id($pub_id);
    $self->set_object(CXGN::Chado::Publication->new($self->get_dbh, $self->get_object_id));
    
    $self->set_primary_key("pub_id");
    $self->set_owners();
}


sub display_page {
    my $self=shift;
    my %args = $self->get_args();
    my $publication=$self->get_object();
    my $pub_id = $self->get_object_id();
    my $pub_title = $publication->get_title();
    my $page="/chado/publication.pl?pub_id=?";
    my $action= $args{action} || "";

    #import javascript libraries
    $self->get_page()->jsan_use("jquery");
    $self->get_page()->jsan_use("CXGN.Phenome.Locus");
    $self->get_page()->jsan_use("CXGN.Phenome.Publication");

    if (!$pub_title && $action ne 'new' && $action ne  'store') { $self->get_page->message_page("No publication exists for this identifier");}

    
    $self->get_page->header("SGN publication $pub_title");
    print page_title_html("Publication:\t$pub_title\n");
    
    my $edit_links=$self->get_edit_links();
    
    my $pub_html=$edit_links. "<br />". $self->get_form->as_table_string(). "<br />";
    if ($action eq 'new') { print qq |<p><b><a href = "/chado/add_publication.pl?action=new&amp;type=$args{type}&amp;type_id=$args{type_id}&amp;reffering_page=$args{reffering_page}">Store PubMed publication.</a></b></p>|; }
    print info_section_html(title    => 'Publication details',
                            contents => $pub_html ,
			    );
    if ($args{refering_page}) { print qq |<a href="$args{refering_page}">Go back to refering page.</a><br />|; }
    
    my $dbxref_html=$self->get_dbxref_html($publication->get_dbxrefs());
    
    print info_section_html(title    => 'External resources',
                            contents => $dbxref_html ,
			    );
    my $loci_link;
    my @loci= $publication->get_loci();
    foreach my $locus(@loci)  {
	my $locus_id = $locus->get_locus_id();
	my $locus_symbol= $locus->get_locus_symbol();
	my $cname=$locus->get_common_name();
	$loci_link .= qq|<a href="/phenome/locus_display.pl?locus_id=$locus_id">$cname '$locus_symbol'</a><br />| if $locus->get_obsolete() eq 'f';
    }
{'fraction_non_alphanumeric': 0.17159847090471472, 'fraction_numerical': 0.0, 'mean_word_length': 3.2375524895020997, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 117, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6316540', 'n_tokens_mistral': 2555, 'n_tokens_neox': 2477, 'n_words': 400}