| MySQL-Admin documentation | Contained in the MySQL-Admin distribution. |
HTML::Window.pm - move-,resize-,collapse- and closeable Html Window.
use HTML::Window qw(:all);
my %parameter =(
path => "path to cgi-bin",
style => "style to use",
title => "title",
server => "http://servername",
id => $id,
class => min or max,
);
$m_bMod_perl = ($ENV{MOD_PERL}) ? 1 : 0;
initWindow(\%parameter) unless($m_bMod_perl);
windowHeader();
print 'this is the content';
windowFooter();
Produce a move-,resize-,collapse- and closeable Html Window.
This Module is mainly written for MySQL::Admin::GUI.
But there is no reason to use it not standalone. Also it is much more easier
to update, test and distribute it standalone.
my %parameter =(
path => "path to template",
style => "style to use",
title => "title
server => "http://servername",
id => $id,
class => min or max,
);
my $window = new window(\%parameter);
default: lze;
default: 0;
default = 0;
default = 0;
default = 0;
default = 0;
default = 0;
my %parameter =(
path => "path to templates",
style => "style to use",
title => "title
server => "http://servername",
id => $id,
class => min or max,
hidden => '', #set the window hidden
);
initWindow(\%parameter);
Dirk Lindner <lze@cpan.org>
Copyright (C) 2005 - 2009 by Hr. Dirk Lindner
This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; This program 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 Lesser General Public License for more details.
| MySQL-Admin documentation | Contained in the MySQL-Admin distribution. |
package HTML::Window; use strict; use warnings; require Exporter; use utf8; use vars qw($DefaultClass @EXPORT @ISA $class $server $hidden $template); our $m_sStyle = 'lze'; our $m_sTitle = ''; our $id = 'a'; our ( $collapse, $resizeable, $closeable, $moveable ) = (0) x 4; @ISA = qw(Exporter); use Template::Quick; @HTML::Window::ISA = qw(Template::Quick); @HTML::Window::EXPORT_OK = qw( set_title set_class set_style set_closeable set_resizeable set_collapse set_moveable initWindow windowHeader windowFooter); %HTML::Window::EXPORT_TAGS = ( 'all' => [ qw(set_title set_class set_style set_closeable set_resizeable set_collapse set_moveable initWindow windowHeader windowFooter) ] ); $HTML::Window::VERSION = '0.62'; $DefaultClass = 'HTML::Window' unless defined $HTML::Window::DefaultClass; %HTML::Window::EXPORT_TAGS = ( 'all' => [ qw(set_title set_class set_style set_closeable set_resizeable set_collapse set_moveable initWindow windowHeader windowFooter) ], );
sub new { my ( $class, @initializer ) = @_; my $self = { closeable => 0, resizeable => 0, collapse => 1, moveable => 0, }; bless $self, ref $class || $class || $DefaultClass; $self->initWindow(@initializer) if(@initializer); return $self; }
sub set_style { my ( $self, @p ) = getSelf(@_); if( defined $p[0] && $p[0] =~ /(\w+)/ ) { $m_sStyle = $1; } else { return $m_sStyle; } }
sub set_closeable { my ( $self, @p ) = getSelf(@_); if( defined $p[0] && $p[0] =~ /(0|1)/ ) { $closeable = $1; } else { return $closeable; } }
sub set_resizeable { my ( $self, @p ) = getSelf(@_); if( defined $p[0] && $p[0] =~ /(0|1)/ ) { $resizeable = $1; } else { return $resizeable; } }
sub set_collapse { my ( $self, @p ) = getSelf(@_); if( defined $p[0] && $p[0] =~ /(0|1)/ ) { $collapse = $1; } else { return $collapse; } }
sub set_moveable { my ( $self, @p ) = getSelf(@_); if( defined $p[0] && $p[0] =~ /(0|1)/ ) { $moveable = $1; } else { return $moveable; } }
sub set_title { my ( $self, @p ) = getSelf(@_); if( defined $p[0] && $p[0] =~ /(\w+)/ ) { $m_sTitle = $1; } else { return $m_sTitle; } }
sub set_class { my ( $self, @p ) = getSelf(@_); if( defined $p[0] && $p[0] =~ /(\w+)/ ) { $class = $1; } else { return $class; } }
sub initWindow { my ( $self, @p ) = getSelf(@_); my $hash = $p[0]; $server = $hash->{server}; $m_sStyle = defined $hash->{style} ? $hash->{style} : 'lze'; $m_sTitle = defined $hash->{title} ? $hash->{title} : $m_sTitle; $id = defined $hash->{id} ? $hash->{id} : $id; $class = defined $hash->{class} ? $hash->{class} : 'min'; $hidden = defined $hash->{hidden} ? 'style="visibility:hidden;position:absolute;' : ''; $template = defined $hash->{template} ? $hash->{template} : "window.htm"; my %template = ( path => $hash->{path}, style => $m_sStyle, template => $template, ); $self->SUPER::initTemplate( \%template ); }
sub windowHeader { my ( $self, @p ) = getSelf(@_); eval 'use CGI qw(cookie)'; unless ($@) { my $co = cookie( -name => 'windowStatus' ) ? cookie( -name => 'windowStatus' ) : ''; my @wins = split /:/, $co; for( my $i = 0; $i <= $#wins; $i++ ) { $hidden = 'style="visibility:hidden;position:absolute;"' if( $id eq $wins[$i] ); } } my $menu = " "; unless ( $moveable eq 0 && $collapse eq 0 && $resizeable eq 0 && $closeable eq 0 ) { $menu .= qq(<script language="javascript" type="text/javascript">menu('$id','$moveable','$collapse','$resizeable','$closeable');</script>); } my %header = ( name => 'windowheader', server => $server, style => $m_sStyle, title => $m_sTitle, menu => $menu, id => $id, class => $class, hidden => $hidden, ); $self->SUPER::appendHash( \%header ); }
sub windowFooter { my ( $self, @p ) = getSelf(@_); my %footer = ( name => 'windowfooter', style => $m_sStyle, id => $id, ); $self->SUPER::appendHash( \%footer ); }
sub getSelf { return @_ if defined( $_[0] ) && ( !ref( $_[0] ) ) && ( $_[0] eq 'HTML::Window' ); return ( defined( $_[0] ) && ( ref( $_[0] ) eq 'HTML::Window' || UNIVERSAL::isa( $_[0], 'HTML::Window' ) ) ) ? @_ : ( $HTML::Window::DefaultClass->new, @_ ); }
1;