package WebGUI::Wizard::HomePage;
use strict;
use base 'WebGUI::Wizard';
=head1 NAME
WebGUI::Wizard::HomePage - Create or replace a Home Page with new content
=cut
sub _get_steps {
return [ qw(
pickStyle
chooseContent
finalize
)
];
}
#-------------------------------------------------------------------
=head2 addAsset ( parent, properties )
A helper to add assets with less code.
=head3 parent
The parent asset to add to.
=head3 properties
A hash ref of properties to attach to the asset. One must be className.
=cut
sub addAsset {
my $parent = shift;
my $properties = shift;
$properties->{url} = $parent->get("url") . "/" . $properties->{title};
$properties->{groupIdEdit} = $parent->get("groupIdEdit");
$properties->{groupIdView} = $parent->get("groupIdView");
$properties->{ownerUserId} = $parent->get("ownerUserId");
$properties->{styleTemplateId} = $parent->get("styleTemplateId");
$properties->{printableStyleTemplateId} = $parent->get("styleTemplateId");
return $parent->addChild($properties);
}
#-------------------------------------------------------------------
=head2 addPage ( parent, title )
Adds a page to a parent page.
=head3 parent
A parent page asset.
=head3 title
The title of the new page.
=cut
sub addPage {
my $parent = shift;
my $title = shift;
return addAsset( $parent, { title => $title, className => "WebGUI::Asset::Wobject::Layout", displayTitle => 0 } );
}
sub wrapStyle {
return WebGUI::Wizard::Setup::wrapStyle( @_ );
}
sub www_pickStyle {
my ( $self ) = @_;
my $session = $self->session;
my $f = $self->getForm;
my $i18n = WebGUI::International->new( $session, "WebGUI" );
my $output = '
' . $i18n->get('1073') . '
';
my @styleIds
= $session->db->buildArray(
q{SELECT DISTINCT(assetId) FROM template WHERE namespace="style"}
);
# Verboten:
# PBtmpl0000000000000060
# PBtmpl0000000000000111
# PBtmpl0000000000000137
# PBtmpl0000000000000132
# Blank style:
# PBtmplBlankStyle000001
my @skipStyleIds = qw( PBtmpl0000000000000060 PBtmpl0000000000000111 PBtmpl0000000000000137
PBtmpl0000000000000132 PBtmplBlankStyle000001 );
# Instantiate the objects
my @styles;
for my $styleId ( @styleIds ) {
next if grep { $_ eq $styleId } @skipStyleIds;
my $style = WebGUI::Asset->newByDynamicClass( $session, $styleId );
push @styles, $style;
}
my $row = 0;
for my $style ( sort { $a->getTitle cmp $b->getTitle } @styles ) {
my $class = ++$row % 2 ? " odd" : "";
# Prepare the synopsis
my $synopsis = WebGUI::HTML::format( $style->get('synopsis') );
$synopsis =~ s{(https?://\S+)}{$1}g;
$f->raw(
'