AcePerl
view release on metacpan or search on metacpan
Ace/Browser/AceSubs.pm view on Meta::CPAN
my %searches = map {$_=>1} Configuration()->searches;
my $quovadis = url(-relative=>1);
my $db = get_symbolic();
my $referer = referer();
$referer =~ s!^http://[^/]+!! if defined $referer;
my $home = Configuration()->Home->[0] if Configuration()->Home;
if ($referer && $home && index($referer,$home) >= 0) {
my $bookmark = cookie(
-name=>"HOME_${db}",
-value=>$referer,
-path=>'/');
push(@COOKIES,$bookmark);
}
if ($searches{$quovadis}) {
Delete('Go');
my $search_name = "SEARCH_${db}_${quovadis}";
my $search_data = cookie(-name => $search_name,
-value => query_string(),
-path=>'/',
);
my $last_search = cookie(-name=>"ACEDB_$db",
-value=>$quovadis,
-path=>'/');
push(@COOKIES,$search_data,$last_search);
}
print @COOKIES ? header(-cookie=>\@COOKIES,@_) : header(@_);
@COOKIES = ();
$HEADER++;
}
=item AceInit()
This subroutine initializes the AcePerl connection to the configured
database. If the database cannot be opened, it generates an error
message and exits. This subroutine is not exported by default, but is
called by PrintTop() and Header() internally.
=cut
# Subroutines used by all scripts.
# Will generate an HTTP 'document not found' error if you try to get an
# undefined database name. Check the return code from this function and
# return immediately if not true (actually, not needed because we exit).
sub AceInit {
$HEADER = 0;
$TOP = 0;
@COOKIES = ();
# keeps track of what sections should be open
%OPEN = param('open') ? map {$_ => 1} split(' ',param('open')) : () ;
return 1 if Configuration();
# if we get here, it is a big NOT FOUND error
print header(-status=>'404 Not Found',-type=>'text/html');
$HEADER++;
print start_html(-title => 'Database Not Found',
-style => Ace::Browser::SiteDefs->getConfig(DEFAULT_DATABASE)->Style,
),
h1('Database not found'),
p('The requested database',i(get_symbolic()),'is not recognized',
'by this server.');
print p('Please return to the',a({-href=>referer()},'referring page.')) if referer();
print end_html;
Apache::exit(0) if defined &Apache::exit; # bug out of here!
exit(0);
}
=item AceMissing([$class,$name])
This subroutine will print out an error message indicating that an
object is present in AceDB, but that the information the user
requested is absent. It will then exit the script. This is
infrequently encountered when following XREFed objects. If the class
and name of the object are not provided as arguments, they are taken
from CGI's param() function.
=cut
sub AceMissing {
my ($class,$name) = @_;
$class ||= param('class');
$name ||= param('name');
PrintTop(undef,undef,$name);
print strong('There is no further information about this object in the database.');
PrintBottom();
Apache->exit(0) if defined &Apache::exit;
exit(0);
}
=item AceMultipleChoices($symbol,$report,$objects)
This function is called when a search has recovered multiple objects
and the user must make a choice among them. The user is presented
with an ordered list of the objects, and asked to click on one of
them.
The three arguements are:
$symbol The keyword or query string the user was searching
on, undef if none.
$report The symbolic name of the current display, or undef
if none.
$objects An array reference containing the Ace objects in
question.
This subroutine is not exported by default.
=cut
sub AceMultipleChoices {
my ($symbol,$report,$objects) = @_;
if ($objects && @$objects == 1) {
( run in 1.239 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )