CGI-Panel
view release on metacpan or search on metacpan
lib/CGI/Panel.pm view on Meta::CPAN
=head2 get_localised_name
Return a name that has the panel id encoded into it. This is
used by the local_... functions and can be used to build a custom
html input control that will deliver its value when the panel's
local_params method is called.
Example:
$output .= $cgi->textfield({name => $self->get_localised_name('sometext')});
The equivalent could be done by calling:
$output .= $self->local_textfield({name => 'sometext'});
=cut
###############################################################
sub get_localised_name {
my ($self, $name) = @_;
my $localised_name = $self->get_id . $self->SEP . $name;
return $localised_name;
}
###############################################################
=head2 local_textfield
Generate a localised textfield
Example:
$output .= $self->local_textfield({name => 'sometext'});
=cut
###############################################################
sub local_textfield {
my ($self, $args) = @_;
my $cgi = new CGI;
$args->{name} = $self->get_localised_name($args->{name});
return $cgi->textfield($args);
}
###############################################################
sub local_textarea {
my ($self, $args) = @_;
my $cgi = new CGI;
$args->{name} = $self->get_localised_name($args->{name});
return $cgi->textarea($args);
}
###############################################################
sub local_popup_menu {
my ($self, $args) = @_;
my $cgi = new CGI;
$args->{name} = $self->get_localised_name($args->{name});
return $cgi->popup_menu($args);
}
###############################################################
sub local_radio_group {
my ($self, $args) = @_;
my $cgi = new CGI;
$args->{name} = $self->get_localised_name($args->{name});
return $cgi->radio_group($args);
}
###############################################################
# Define the separator used when passing panel ids etc
# and a version which can be used in regexps
sub SEP { ':.:' }
sub SEPRE { qr{:\.:} }
###############################################################
=head2 MAIN PANEL METHODS
These methods provide extra functionality useful for the main
panel of an application. Apache::Session is used to handle session
information. An application built using the CGI::Panel framework should
typically have one main panel and a hierarchy of other panels, all of
which inherit from CGI::Panel.
=head2 obtain
Obtains the master panel object
This will either restore the current master panel session
or create a new one
Use:
my $shop = obtain Shop;
=cut
###############################################################
sub obtain
{
my ($class) = @_;
my $messages = $class->interpret_messages();
my $session_id = $messages->{session_id} || undef;
my %session = $class->get_or_create_apache_session($session_id);
my $panel;
if ($session{mainpanel}) {
$panel = $session{mainpanel};
}
else {
( run in 0.703 second using v1.01-cache-2.11-cpan-364913b4093 )