use strict; use Pos::Webtop::Toolbox (); use Pos::Policy::LayeredBurrito (); use Pos::Webtop::Web::ContentModule::UserPrefs::PrefModule (); # derived class package Pos::Webtop::Web::ContentModule::UserPrefs::PrefModule::DesktopWallpaper; my $className = "Pos::Webtop::Web::ContentModule::UserPrefs::PrefModule::DesktopWallpaper"; our @ISA = qw( Pos::Webtop::Web::ContentModule::UserPrefs::PrefModule ); sub new { my $this = shift; my $class = ref($this) || $this; my ($self) = @{{@_}}{qw/self/}; if ( not defined $self ) { $self = {}; bless($self,$class); } my %args = @_; $args{'self'} = $self; Pos::Webtop::Web::ContentModule::UserPrefs::PrefModule->new( %args ); $self->setPreferenceName( preferenceName=> "Desktop Wallpaper" ); $self->setPolicyTypeId( policyTypeId=> 160 ); return $self; } # these can be cut and pasted from the polyp script .. I have # made the pref form use the same hash to generate the color # map on the page for the end user my %colors = (); $colors{'BLACK'} = "0 0 0"; $colors{'BLUE'} = "0 0 255"; $colors{'DARK BLUE'} = "0 0 139"; $colors{'DARK GREEN'} = "0 139 0"; $colors{'DARK RED'} = "139 0 0"; $colors{'GREEN'} = "0 255 0"; $colors{'LIGHT BLUE'} = "173 216 230"; $colors{'PINK'} = "255 20 147"; $colors{'PURPLE'} = "160 32 240"; $colors{'TURQOISE'} = "64 224 208"; $colors{'RED'} = "255 0 0"; $colors{'WHITE'} = "255 255 255"; $colors{'YELLOW'} = "255 255 0"; $colors{'GREY'} = "100 100 100"; $colors{'LIGHT GREY'} = "238 238 238"; # implemented pure virtual sub getEmbeddedHtml { my $self = shift; my $toolBox = $self->getToolBox(); my $client = $toolBox->getClient(); my $cgi = $toolBox->getCgi(); my $pdb = $toolBox->getPolicyDb(); my $dbr = $toolBox->getWebtopDbReader(); my $policyValues = $self->getPolicyValues(); my $value = ""; foreach my $val ( @{ $policyValues } ) { $value = $val->{'policyValue'}; } my @info = (); my ($file,$align,$color) = split /\s*;\s*/, $value; $file = "" unless defined $file; $align = 'CENTER' unless defined $align; $color = 'WHITE' unless defined $color; # we also check the persisted values just in case we are moving back or between steps my $persistedFile = $client->getPersistedValue( name=> "file" ); my $persistedAlign = $client->getPersistedValue( name=> "align" ); my $persistedColor = $client->getPersistedValue( name=> "color" ); if ( defined $persistedFile ) { $file = $persistedFile; $client->repersistValues( values=> ["file"] ); } if ( defined $persistedAlign ) { $align = $persistedAlign; $client->repersistValues( values=> ["align"] ); } if ( defined $persistedColor ) { $color = $persistedColor; $client->repersistValues( values=> ["color"] ); } my $providedFileId = ""; my $existingFile = ""; if ( $file =~ /^\d+$/ ) { # it's a pk $providedFileId = $file; } else { $existingFile = $file; } my $totalSteps = 3; my $ret = ""; $ret .= $self->getEmbeddedHeader(); $ret .= "
\n"; $ret .= $self->getEmbeddedFooter(); return $ret; } # implemented pure virtual sub getPreviewText { my $self = shift; my $policyValues = $self->getPolicyValues(); my $value = ""; my $tb = $self->getToolBox(); my $client = $tb->getClient(); foreach my $val ( @{ $policyValues } ) { $value = $val->{'policyValue'}; } my @info = (); my ($file,$align,$color) = split /\s*;\s*/, $value; if ( defined $file and length($file) ) { if ( $file =~ /^\d+$/ ) { # if all digits, it's a pk to customer file table my $db = $tb->getWebtopDbReader(); my $customerId = $client->getCustomerId(); ($file) = $db->query( sql=> " select source_name from customer_queue_files where customer_id = $customerId and queue_file_id = $file "); } push @info, "Background Image '$file' with $align orientation" } if ( defined $color and length( $color ) ) { push @info, "Background Color $color"; } return join(", ", @info); } 1;