#!/usr/bin/perl -Tw -I. -I/usr/local/positive/Perl use strict; use Pos::Web::Widget; package Pos::Webtop::Web::ContentLayout; our @ISA = qw( Pos::Web::Widget ); =head1 ContentLayout object The ContentLayout object is the interface for working with content layouts. This will be used to display a gui for laying out the content modules for a user. The object will be used by the webtop gui and the policy manager. =head1 METHODS =over 4 =cut sub new { my $this = shift; my $class = ref($this) || $this; my ($self,$title,$userId) = @{{@_}}{qw/self title userId/}; if ( not defined $self ) { $self = {}; bless($self,$class); } # setup base class Pos::Web::Widget->new( self=> $self, id=> "1" ); # setup css defaults $self->setTagClass( tag=> "TABLE", class=> "BOXTABLE" ); $self->setTagClass( tag=> "MODULE", class=> "CLMODULECELL" ); $self->setTagClass( tag=> "TOPIC", class=> "CLPREVIEWTITLE" ); $self->setTagClass( tag=> "TD1", class=> "BOXTD1" ); $self->setTagClass( tag=> "TD2", class=> "BOXTD2" ); $self->{'userId'} = $userId; return $self; } # required pure virtual from Pos::Web::Widget sub getIdPrefix { return "ContentLayoutWidget"; } =item B Gets the Perl::Class modules from the db per column... multi dim array. =cut sub getColumnModules { my $self = shift; my @columns = ( ['dog','cat','bird'], ['car','truck','boat'], ['bob','jane','carl'] ); # read columns for user from db... # hard coded for test. return @columns; } =item B Returns the design html for use in the admintool policy type and on the webtop prefs page =cut sub getDesignHtml { my $self = shift; my $ret = ""; my $TABLE = $self->getTagClass( tag=> "TABLE" ); my $MODULE = $self->getTagClass( tag=> "MODULE" ); my $TOPIC = $self->getTagClass( tag=> "TOPIC" ); my $TD1 = $self->getTagClass( tag=> "TD1" ); my $TD2 = $self->getTagClass( tag=> "TD2" ); my $idPrefix = $self->getIdPrefix(); my $udPrefix = Pos::Web::Widget::FormWidget::MultiselectUpDown::getIdPrefix(); $ret .= Pos::Web::Widget::FormWidget::MultiselectUpDown::getLibHtml(); my @columns = $self->getColumnModules(); my $colNum; my $lastPopulated = 0; # at most, 10 columns foreach $colNum ( 0..9 ) { # setup columns array so we zap the last empties if ( defined $columns[ $colNum ] and @{ $columns[ $colNum ] } ) { $lastPopulated = $colNum; } } $ret .= " "; $ret .= "
Available Content


"; for $colNum ( 0..9 ) { my $tdStyle = ""; if ( not defined $columns[ $colNum ] or not @{ $columns[ $colNum ] } ) { # assign to empty array so errors won't be generated by updown class $columns[ $colNum ] = [()]; # hide this td if greater than lastPopulated if ( $colNum > $lastPopulated ) { $tdStyle = " style='display: none;'"; } } my $tdId = $idPrefix . "COL" . $colNum; $ret .= " "; } $ret .= "
Content Columns
Below are columns that represent the columns used in the Webtop. You may add content to a
column by selecting content from the 'Available Content' list above and clicking the 'Add' button
above the column you wish you add it to. You may remove content from a column by selecting the
content from the column and clicking the 'Remove' button above the column. You may add and remove
columns available via the 'Add Column' and 'Remove Column' buttons below the columns.
"; my $ud = Pos::Web::Widget::FormWidget::MultiselectUpDown->new( name=> "mods$colNum", width=> "150px", size=> "10" ); $ud->setTagClass( tag=> "TD", class=> $MODULE ); foreach my $moduleClass ( @{ $columns[ $colNum ] } ) { $ud->addOption( text=> "$moduleClass", value=> "$moduleClass" ); } $ret .= "

"; $ret .= $ud->getHtml(); $ret .= "

"; return $ret; } 1; =back =cut