^AssetProxy("flexmenu");
package WebGUI::Content::Setup; =head1 LEGAL ------------------------------------------------------------------- WebGUI is Copyright 2001-2009 Plain Black Corporation. ------------------------------------------------------------------- Please read the legal notices (docs/legal.txt) and the license (docs/license.txt) that came with this distribution before using this software. ------------------------------------------------------------------- http://www.plainblack.com info@plainblack.com ------------------------------------------------------------------- =cut use strict; use Digest::MD5; use WebGUI::Asset; use WebGUI::HTMLForm; use WebGUI::International; use WebGUI::Storage; use WebGUI::VersionTag; use WebGUI::Utility; use WebGUI::Operation::Statistics; =head1 NAME Package WebGUI::Setup =head1 DESCRIPTION Initializes a new WebGUI install. =head1 SYNOPSIS use WebGUI::Setup; WebGUI::Content::Setup::handler(); =head1 SUBROUTINES These subroutines are available from this package: =cut #------------------------------------------------------------------- =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 } ); } #------------------------------------------------------------------- =head2 handler ( session ) Handles a specialState: "init" =head3 session The current WebGUI::Session object. =cut sub handler { my $session = shift; my $form = $session->form; unless ( $session->setting->get("specialState") eq "init" ) { return undef; } $session->http->setCacheControl("none"); my $i18n = WebGUI::International->new( $session, "WebGUI" ); my ( $output, $legend ) = ""; if ( $form->process("step") eq "2" ) { $legend = $i18n->get('company information'); my $timezone = $form->timeZone("timeZone"); my $language = $form->selectBox("language"); ##update Admin and Visitor users my $u = WebGUI::User->new( $session, "3" ); $u->username( $form->process( "username", "text", "Admin" ) ); $u->profileField( "email", $form->email("email") ); $u->profileField( "timeZone", $timezone ); $u->profileField( "language", $language ); $u->identifier( Digest::MD5::md5_base64( $form->process( "identifier", "password", "123qwe" ) ) ); $u = WebGUI::User->new( $session, "1" ); $u->profileField( "timeZone", $timezone ); $u->profileField( "language", $language ); ##update ProfileField defaults so new users the get the defaults, too my $properties; my $zoneField = WebGUI::ProfileField->new( $session, 'timeZone' ); $properties = $zoneField->get(); $properties->{dataDefault} = $timezone; $zoneField->set($properties); my $languageField = WebGUI::ProfileField->new( $session, 'language' ); $properties = $languageField->get(); $properties->{dataDefault} = $language; $languageField->set($properties); my $f = WebGUI::HTMLForm->new( $session, action => $session->url->gateway() ); $f->hidden( name => "step", value => "3" ); $f->text( name => "companyName", value => $session->setting->get("companyName"), label => $i18n->get(125), hoverHelp => $i18n->get('125 description'), ); $f->email( name => "companyEmail", value => $session->setting->get("companyEmail"), label => $i18n->get(126), hoverHelp => $i18n->get('126 description'), ); $f->url( name => "companyURL", value => $session->setting->get("companyURL"), label => $i18n->get(127), hoverHelp => $i18n->get('127 description'), ); $f->submit; $output .= $f->print; } ## end if ( $form->process("step"...)) elsif ( $session->form->process("step") eq "3" ) { my $form = $session->form; $session->setting->set( 'companyName', $form->text("companyName") ) if ( $form->get("companyName") ); $session->setting->set( 'companyURL', $form->url("companyURL") ) if ( $form->get("companyURL") ); $session->setting->set( 'companyEmail', $form->email("companyEmail") ) if ( $form->get("companyEmail") ); $legend = $i18n->get( 'topicName', 'Activity_SendWebguiStats' ); $output .= '
' . $i18n->get( 'why to send', 'Activity_SendWebguiStats' ) . '
' . $i18n->get( 'would you participate', 'Activity_SendWebguiStats' ) . '
' . $i18n->get( 'disable', 'Activity_SendWebguiStats' ) . ' ' . $i18n->get( 'enable', 'Activity_SendWebguiStats' ) . '
'; } ## end elsif ( $session->form->process...) elsif ( $session->form->process("step") eq "sitestarter" ) { my $form = $session->form; WebGUI::Operation::Statistics::www_enableSendWebguiStats($session) if ( $form->get("enableStats") ); $legend = $i18n->get('site starter title'); $output .= '' . $i18n->get('site starter body') . '
' . $i18n->get('no thanks') . ' ' . $i18n->get('yes please') . '
'; } elsif ( $session->form->process("step") eq "4" ) { my $f = WebGUI::HTMLForm->new( $session, action => $session->url->gateway() ); $f->hidden( name => "step", value => "5", ); $f->file( name => "logo", label => $i18n->get('logo') ); $f->submit; $legend = $i18n->get('upload logo'); $output .= $f->print; } elsif ( $session->form->process("step") eq "5" ) { my $storageId = $session->form->process( "logo", "image" ); my $url = $session->url; my $logoUrl = $url->extras("plainblack.gif"); if ( defined $storageId ) { my $storage = WebGUI::Storage->get( $session, $storageId ); my $importNode = WebGUI::Asset->getImportNode($session); my $logo = addAsset( $importNode, { title => $storage->getFiles->[0], filename => $storage->getFiles->[0], isHidden => 1, storageId => $storageId, className => "WebGUI::Asset::File::Image", parameters => 'alt="' . $storage->getFiles->[0] . '"' } ); $logoUrl = $logo->getStorageLocation->getUrl( $logo->get("filename") ); } my $style = $session->style; $style->setLink( $url->extras('/yui/build/container/assets/skins/sam/container.css'), { type => 'text/css', rel => "stylesheet" } ); $style->setLink( $url->extras('/yui/build/colorpicker/assets/skins/sam/colorpicker.css'), { type => 'text/css', rel => "stylesheet" } ); $style->setScript( $url->extras('/yui/build/yahoo/yahoo-min.js'), { type => 'text/javascript' } ); $style->setScript( $url->extras('/yui/build/event/event-min.js'), { type => 'text/javascript' } ); $style->setScript( $url->extras('/yui/build/dom/dom-min.js'), { type => 'text/javascript' } ); $style->setScript( $url->extras('/yui/build/dragdrop/dragdrop-min.js'), { type => 'text/javascript' } ); $style->setScript( $url->extras('/yui/build/utilities/utilities.js'), { type => 'text/javascript' } ); $style->setScript( $url->extras('/yui/build/container/container-min.js'), { type => 'text/javascript' } ); $style->setScript( $url->extras('/yui/build/slider/slider-min.js'), { type => 'text/javascript' } ); $style->setScript( $url->extras('/yui/build/colorpicker/colorpicker-min.js'), { type => 'text/javascript' } ); $style->setLink( $url->extras('/colorpicker/colorpicker.css'), { type => 'text/css', rel => "stylesheet" } ); $style->setScript( $url->extras('/colorpicker/colorpicker.js'), { type => 'text/javascript' } ); $style->setScript( $url->extras("/styleDesigner/styleDesigner.js"), { type => "text/javascript" } ); $style->setLink( $url->extras("/styleDesigner/styleDesigner.css"), { rel => "stylesheet", type => "text/css" } ); $legend = $i18n->get("style designer"); $output .= ' '; } ## end elsif ( $session->form->process...) elsif ( $session->form->process("step") eq "6" ) { my $importNode = WebGUI::Asset->getImportNode($session); my $form = $session->form; my $snippet = '/* auto generated by WebGUI ' . $WebGUI::VERSION . ' */ .clearFloat { clear: both; } body { background-color: ' . $form->get("pageBackgroundColor") . '; color: ' . $form->get("contentTextColor") . '} a { color: ' . $form->get("linkColor") . ';} a:visited { color: ' . $form->get("visitedLinkColor") . '; } #editToggleContainer { padding: 1px; } #utilityLinksContainer { float: right; padding: 1px; } #pageUtilityContainer { font-size: 9pt; background-color: ' . $form->get("utilityBackgroundColor") . '; color: ' . $form->get("utilityTextColor") . '; } #pageHeaderContainer { background-color: ' . $form->get("headerBackgroundColor") . '; color: ' . $form->get("headerTextColor") . '; } #pageHeaderLogoContainer { float: left; padding: 5px; background-color: ' . $form->get("headerBackgroundColor") . ';} #logo { border: 0px; max-width: 300px; } #companyNameContainer { float: right; padding: 5px; font-size: 16pt; } #pageBodyContainer { background-color: ' . $form->get("contentBackgroundColor") . '; color: ' . $form->get("contentTextColor") . '; } #mainNavigationContainer { min-height: 300px; padding: 5px; float: left; width: 180px; font-size: 10pt; background-color: ' . $form->get("navigationBackgroundColor") . '; } #mainNavigationContainer A, #mainNavigationContainer A:link { color: ' . $form->get("navigationTextColor") . '; } #mainBodyContentContainer { padding: 5px; margin-left: 200px; font-family: serif, times new roman; font-size: 12pt; overflow: auto; } #pageFooterContainer { text-align: center; background-color: ' . $form->get("footerBackgroundColor") . '; color: ' . $form->get("footerTextColor") . '; } #copyrightContainer { font-size: 8pt; } #pageWidthContainer { width: 80%; margin-left: auto; margin-right: auto; font-family: sans-serif, helvetica, arial; border: 3px solid black; } '; my $css = addAsset( $importNode, { title => "my-style.css", className => "WebGUI::Asset::Snippet", snippet => $snippet, isHidden => 1, mimeType => "text/css", } ); my $styleTemplate = '
';
$session->http->setMimeType("text/html");
return $page;
} ## end sub handler
1;