VersionPage.pm 5.89 KB
Newer Older
Keith Jolley's avatar
Keith Jolley committed
1
#Written by Keith Jolley
2
#Copyright (c) 2010-2012, University of Oxford
Keith Jolley's avatar
Keith Jolley committed
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#E-mail: keith.jolley@zoo.ox.ac.uk
#
#This file is part of Bacterial Isolate Genome Sequence Database (BIGSdb).
#
#BIGSdb is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation, either version 3 of the License, or
#(at your option) any later version.
#
#BIGSdb is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.
#
#You should have received a copy of the GNU General Public License
#along with BIGSdb.  If not, see <http://www.gnu.org/licenses/>.

package BIGSdb::VersionPage;
use strict;
22
use warnings;
Keith Jolley's avatar
Keith Jolley committed
23
use parent qw(BIGSdb::Page);
Keith Jolley's avatar
Keith Jolley committed
24

25
26
27
28
29
30
sub set_pref_requirements {
	my ($self) = @_;
	$self->{'pref_requirements'} = { 'general' => 0, 'main_display' => 0, 'isolate_display' => 0, 'analysis' => 0, 'query_field' => 0 };
	return;
}

Keith Jolley's avatar
Keith Jolley committed
31
sub print_content {
32
	my ($self) = @_;
Keith Jolley's avatar
Keith Jolley committed
33
34
	print <<"HTML";

35
<h1>Bacterial Isolate Genome Sequence Database (BIGSdb)</h1>
Keith Jolley's avatar
Keith Jolley committed
36
<div class="box" id="resultstable">
37
38
<h2>Version $BIGSdb::main::VERSION</h2>
<p>Written by Keith Jolley<br />
39
Copyright &copy; University of Oxford, 2010-2012.<br />
Keith Jolley's avatar
Keith Jolley committed
40
<a href="http://www.biomedcentral.com/1471-2105/11/595">Jolley &amp; Maiden <i>BMC Bioinformatics</i> 2010, <b>11:</b>595</a></p>
Keith Jolley's avatar
Keith Jolley committed
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<p>
BIGSdb is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.</p>

<p>BIGSdb is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.</p>

<p>Full details of the GNU General Public License
can be found at <a href="http://www.gnu.org/licenses/gpl.html">http://www.gnu.org/licenses/gpl.html</a>.</p>

<p>Details of this software and the latest version can be downloaded from 
56
<a href="http://pubmlst.org/software/database/bigsdb/">
Keith Jolley's avatar
Keith Jolley committed
57
58
http://pubmlst.org/software/database/bigsdb/</a>.</p>
HTML
59
60
61
	$self->_print_plugins;
	print "</div>\n";
	return;
Keith Jolley's avatar
Keith Jolley committed
62
63
64
65
66
67
}

sub get_title {
	return "BIGSdb Version $BIGSdb::main::VERSION";
}

68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
sub _print_plugins {
	my ($self) = @_;
	print "<h2>Installed plugins</h2>\n";
	my $plugins = $self->{'pluginManager'}->get_installed_plugins;
	if (!keys %{$plugins}){
		print "<p>No plugins installed</p>\n";
		return;
	}
	print "<p>Plugins may be disabled by the system administrator for specific databases where either they're not appropriate"
	. " or if they may take up too many resources on a public database.</p>\n";
	my ($enabled_buffer, $disabled_buffer, %disabled_reason);
	my $dbtype = $self->{'system'}->{'dbtype'};
	my $etd = 1;
	my $dtd = 1;
	foreach (sort {$a cmp $b} keys %{$plugins}){
		my $attr = $plugins->{$_};
		if ( $attr->{'requires'} ) {
			$disabled_reason{$_} = 'Chartdirector not installed.'
			  if !$self->{'config'}->{'chartdirector'}
				  && $attr->{'requires'} =~ /chartdirector/;
			$disabled_reason{$_} = 'Reference database not configured.'
			  if !$self->{'config'}->{'refdb'}
				  && $attr->{'requires'} =~ /refdb/;
			$disabled_reason{$_} = 'EMBOSS not installed.'
			  if !$self->{'config'}->{'emboss_path'}
				  && $attr->{'requires'} =~ /emboss/;
			$disabled_reason{$_} = 'MUSCLE not installed.'
			  if !$self->{'config'}->{'muscle_path'}
				  && $attr->{'requires'} =~ /muscle/;
			$disabled_reason{$_} = 'ImageMagick mogrify not installed.'
			  if !$self->{'config'}->{'mogrify_path'}
				  && $attr->{'requires'} =~ /mogrify/;
			$disabled_reason{$_} = 'Offline job manager not running.'
			  if !$self->{'config'}->{'jobs_db'}
				  && $attr->{'requires'} =~ /offline_jobs/;
		}
		$disabled_reason{$_} = 'Not specifically enabled for this database.'
		  if (
			$attr->{'system_flag'}
			&& (  !$self->{'system'}->{ $attr->{'system_flag'} }
				|| $self->{'system'}->{ $attr->{'system_flag'} } eq 'no' )
		  );
		$disabled_reason{$_} = 'Only for ' . ($dbtype eq 'isolates' ? 'seqdef' : 'isolate') . ' databases.'
			if $attr->{'dbtype'} !~ /$dbtype/;
		my $comments = '';
		if (defined $attr->{'min'} && defined $attr->{'max'}){
			$comments .= "Limited to queries with between $attr->{'min'} and $attr->{'max'} results.";
		} elsif (defined $attr->{'min'}){
			$comments .= "Limited to queries with at least $attr->{'min'} results.";
		} elsif (defined $attr->{'max'}){
			$comments .= "Limited to queries with fewer than $attr->{'max'} results.";
		}
		my $author = defined $attr->{'email'} && $attr->{'email'} ne '' ? "<a href=\"mailto:$attr->{'email'}\">$attr->{'author'}</a>" : $attr->{'author'};
		$author .=  " ($attr->{'affiliation'})" if $attr->{'affiliation'};
		my $name = defined $attr->{'url'} ? "<a href=\"$attr->{'url'}\">$attr->{'name'}</a>" : $attr->{'name'};
		my $row_buffer = "<td>$name</td><td>$author</td><td>$attr->{'description'}</td><td>$attr->{'version'}</td>";
		if ($disabled_reason{$_}){
			$disabled_buffer .= "<tr class=\"td$dtd\">$row_buffer<td>$disabled_reason{$_}</td></tr>";
			$dtd = $dtd == 1 ? 2 : 1;
		} else {
			$enabled_buffer .= "<tr class=\"td$etd\">$row_buffer<td>$comments</td></tr>";
			$etd = $etd == 1 ? 2 : 1;
		}
	}
	if ($enabled_buffer || $disabled_buffer){
		print "<table class=\"resultstable\">";
		if ($enabled_buffer){
			print "<tr><th colspan=\"5\">Enabled plugins</th></tr>\n";	
			print "<tr><th>Name</th><th>Author</th><th>Description</th><th>Version</th><th>Comments</th></tr>\n";
			print $enabled_buffer;
		}
		if ($disabled_buffer){
			print "<tr><th colspan=\"5\">Disabled plugins</th></tr>\n";	
			print "<tr><th>Name</th><th>Author</th><th>Description</th><th>Version</th><th>Disabled because</th></tr>\n";
			print $disabled_buffer;			
		}
		print "</table>\n";
	} 
	return;
}


Keith Jolley's avatar
Keith Jolley committed
150
1;