Merge branch 'WebGUI8' into psgi

This commit is contained in:
Graham Knop 2010-05-10 17:03:17 -05:00
commit 65dfb6e683
36 changed files with 378 additions and 741 deletions

View file

@ -110,7 +110,8 @@
#
"cache" : {
"driver" : "FastMmap",
"expires_variance" : "0.10"
"expires_variance" : "0.10",
"root_dir" : "/tmp/WebGUICache"
},
# Sessions that are "hot", those that are not only not expired,

View file

@ -209,7 +209,7 @@ sub www_getTreeData {
childCount => $asset->getChildCount,
assetSize => $asset->assetSize,
lockedBy => ($asset->isLockedBy ? $asset->lockedBy->username : ''),
actions => $asset->canEdit && $asset->canEditIfLocked,
canEdit => $asset->canEdit && $asset->canEditIfLocked,
helpers => $asset->getHelpers,
);
@ -226,7 +226,13 @@ sub www_getTreeData {
$assetInfo->{ totalAssets } = $p->getRowCount;
$assetInfo->{ sort } = $session->form->get( 'orderByColumn' );
$assetInfo->{ dir } = lc $session->form->get( 'orderByDirection' );
$assetInfo->{ currentAsset } = { title => $asset->getTitle, helpers => $asset->getHelpers };
$assetInfo->{ currentAsset } = {
assetId => $asset->getId,
url => $asset->getUrl,
title => $asset->getTitle,
icon => $asset->getIcon("small"),
helpers => $asset->getHelpers,
};
$assetInfo->{ crumbtrail } = [];
for my $asset ( @{ $asset->getLineage( ['ancestors'], { returnObjects => 1 } ) } ) {

View file

@ -14,10 +14,134 @@ package WebGUI::Asset::EMSSubmission;
=cut
use Class::C3;
use strict;
use Moose;
use WebGUI::Definition::Asset;
use WebGUI::Asset;
use WebGUI::International;
extends 'WebGUI::Asset';
define tableName => 'EMSSubmission';
define assetNae => ['assetName', 'Asset_EMSSubmission'];
define icon => 'EMSSubmission.gif';
property submissionId => (
noFormPost => 1,
fieldType => "hidden",
default => undef,
);
property submissionStatus => (
fieldType => "selectList",
default => 'pending',
customDrawMethod => 'drawStatusField',
label => [ "submission status", 'Asset_EMSSubmission' ],
hoverHelp => [ "submission status help", 'Asset_EMSSubmission' ]
);
property description => (
tab => "properties",
fieldType => "HTMLArea",
default => undef,
label => [ "description", 'Asset_Sku' ],
hoverHelp => [ "description help", 'Asset_Sku' ]
);
property sku => (
tab => "shop",
fieldType => "text",
builder => '_builder_sku',
lazy => 1,
label => [ "sku", 'Asset_Sku' ],
hoverHelp => [ "sku help", 'Asset_Sku' ]
);
sub _builder_sku {
my $self = shift;
return $self->session->id->generate;
}
property displayTitle => (
tab => "display",
fieldType => "yesNo",
default => 1,
label => [ "display title", 'Asset_Sku' ],
hoverHelp => [ "display title help", 'Asset_Sku' ]
);
property vendorId => (
tab => "shop",
fieldType => "vendor",
default => 'defaultvendor000000000',
label => [ "vendor", 'Asset_Sku' ],
hoverHelp => [ "vendor help", 'Asset_Sku' ]
);
property shipsSeparately => (
tab => 'shop',
fieldType => 'yesNo',
default => 0,
label => [ 'shipsSeparately', 'Asset_Sku' ],
hoverHelp => [ 'shipsSeparately help', 'Asset_Sku' ],
);
property price => (
tab => "shop",
fieldType => "float",
default => 0.00,
label => [ "price", 'Asset_EMSSubmission' ],
hoverHelp => [ "price help", 'Asset_EMSSubmission' ],
);
property seatsAvailable => (
tab => "shop",
fieldType => "integer",
default => 25,
label => [ "seats available", 'Asset_EMSSubmission' ],
hoverHelp => [ "seats available help", 'Asset_EMSSubmission' ],
);
property startDate => (
noFormPost => 1,
fieldType => "dateTime",
default => '',
label => [ "add/edit event start date", 'Asset_EMSSubmission' ],
hoverHelp => [ "add/edit event start date help", 'Asset_EMSSubmission' ],
autoGenerate => 0,
);
property duration => (
tab => "properties",
fieldType => "float",
default => 1.0,
subtext => [ 'hours', 'Asset_EMSSubmission' ],
label => [ "duration", 'Asset_EMSSubmission' ],
hoverHelp => [ "duration help", 'Asset_EMSSubmission' ],
);
property location => (
fieldType => "combo",
tab => "properties",
customDrawMethod => 'drawLocationField',
label => [ "location", 'Asset_EMSSubmission' ],
hoverHelp => [ "location help", 'Asset_EMSSubmission' ],
);
property relatedBadgeGroups => (
tab => "properties",
fieldType => "checkList",
customDrawMethod => 'drawRelatedBadgeGroupsField',
label => [ "related badge groups", 'Asset_EMSSubmission' ],
hoverHelp => [ "related badge groups ticket help", 'Asset_EMSSubmission' ],
);
property relatedRibbons => (
tab => "properties",
fieldType => "checkList",
customDrawMethod => 'drawRelatedRibbonsField',
label => [ "related ribbons", 'Asset_EMSSubmission' ],
hoverHelp => [ "related ribbons help", 'Asset_EMSSubmission' ],
);
property eventMetaData => (
noFormPost => 1,
fieldType => "hidden",
default => '{}',
);
property ticketId => (
noFormPost => 1,
fieldType => "hidden",
default => '',
);
with 'WebGUI::Role::Asset::Comments';
use Tie::IxHash;
use base qw(WebGUI::AssetAspect::Comments WebGUI::Asset);
use WebGUI::Utility;
use WebGUI::Inbox;
@ -58,173 +182,15 @@ send email when a comment is added
=cut
sub addComment {
around addComment => sub {
my $orig = shift;
my $self = shift;
$self->update({lastReplyBy => $self->session->user->userId});
$self->next::method(@_);
$self->$orig(@_);
$self->sendEmailUpdate;
}
};
#-------------------------------------------------------------------
=head2 addRevision
This method exists for demonstration purposes only. The superclass
handles revisions to NewAsset Assets.
=cut
#sub addRevision {
# my $self = shift;
# my $newSelf = $self->next::method(@_);
# return $newSelf;
#}
#-------------------------------------------------------------------
=head2 definition ( session, definition )
defines asset properties for New Asset instances. You absolutely need
this method in your new Assets.
=head3 session
=head3 definition
A hash reference passed in from a subclass definition.
=cut
sub definition {
my $class = shift;
my $session = shift;
my $definition = shift;
my $i18n = WebGUI::International->new( $session, "Asset_EMSSubmission" );
my $EMS_i18n = WebGUI::International->new($session, "Asset_EventManagementSystem");
my $SKU_i18n = WebGUI::International->new($session, "Asset_Sku");
tie my %properties, 'Tie::IxHash', (
submissionId => {
noFormPost => 1,
fieldType => "hidden",
defaultValue => undef,
},
submissionStatus => {
fieldType =>"selectList",
defaultValue => 'pending',
customDrawMethod=> 'drawStatusField',
label => $i18n->get("submission status"),
hoverHelp => $i18n->get("submission status help")
},
description => {
tab => "properties",
fieldType => "HTMLArea",
defaultValue => undef,
label => $SKU_i18n->get("description"),
hoverHelp => $SKU_i18n->get("description help")
},
sku => {
tab => "shop",
fieldType => "text",
defaultValue => $session->id->generate,
label => $SKU_i18n->get("sku"),
hoverHelp => $SKU_i18n->get("sku help")
},
displayTitle => {
tab => "display",
fieldType => "yesNo",
defaultValue => 1,
label => $SKU_i18n->get("display title"),
hoverHelp => $SKU_i18n->get("display title help")
},
vendorId => {
tab => "shop",
fieldType => "vendor",
defaultValue => 'defaultvendor000000000',
label => $SKU_i18n->get("vendor"),
hoverHelp => $SKU_i18n->get("vendor help")
},
shipsSeparately => {
tab => 'shop',
fieldType => 'yesNo',
defaultValue => 0,
label => $SKU_i18n->get('shipsSeparately'),
hoverHelp => $SKU_i18n->get('shipsSeparately help'),
},
price => {
tab => "shop",
fieldType => "float",
defaultValue => 0.00,
label => $EMS_i18n->get("price"),
hoverHelp => $EMS_i18n->get("price help"),
},
seatsAvailable => {
tab => "shop",
fieldType => "integer",
defaultValue => 25,
label => $EMS_i18n->get("seats available"),
hoverHelp => $EMS_i18n->get("seats available help"),
},
startDate => {
noFormPost => 1,
fieldType => "dateTime",
defaultValue => '',
label => $EMS_i18n->get("add/edit event start date"),
hoverHelp => $EMS_i18n->get("add/edit event start date help"),
autoGenerate => 0,
},
duration => {
tab => "properties",
fieldType => "float",
defaultValue => 1.0,
subtext => $EMS_i18n->get('hours'),
label => $EMS_i18n->get("duration"),
hoverHelp => $EMS_i18n->get("duration help"),
},
location => {
fieldType => "combo",
tab => "properties",
customDrawMethod=> 'drawLocationField',
label => $EMS_i18n->get("location"),
hoverHelp => $EMS_i18n->get("location help"),
},
relatedBadgeGroups => {
tab => "properties",
fieldType => "checkList",
customDrawMethod=> 'drawRelatedBadgeGroupsField',
label => $EMS_i18n->get("related badge groups"),
hoverHelp => $EMS_i18n->get("related badge groups ticket help"),
},
relatedRibbons => {
tab => "properties",
fieldType => "checkList",
customDrawMethod=> 'drawRelatedRibbonsField',
label => $EMS_i18n->get("related ribbons"),
hoverHelp => $EMS_i18n->get("related ribbons help"),
},
eventMetaData => {
noFormPost => 1,
fieldType => "hidden",
defaultValue => '{}',
},
ticketId => {
noFormPost => 1,
fieldType => "hidden",
defaultValue => '',
},
);
push @{$definition}, {
assetName => $i18n->get('assetName'),
icon => 'EMSSubmission.gif',
autoGenerateForms => 1,
tableName => 'EMSSubmission',
className => 'WebGUI::Asset::EMSSubmission',
properties => \%properties,
};
return $class->next::method( $session, $definition );
} ## end sub definition
#-------------------------------------------------------------------
=head2 drawLocationField ()
@ -313,22 +279,6 @@ sub drawStatusField {
}
#-------------------------------------------------------------------
=head2 duplicate
This method exists for demonstration purposes only. The superclass
handles duplicating NewAsset Assets. This method will be called
whenever a copy action is executed
=cut
#sub duplicate {
# my $self = shift;
# my $newAsset = $self->next::method(@_);
# return $newAsset;
#}
#-------------------------------------------------------------------
=head2 ems
@ -527,31 +477,6 @@ sub www_view { $_[0]->ems->www_viewSubmissionQueue }
#-------------------------------------------------------------------
=head2 getEditForm ( )
Extends the base class to add Tax information for the Sku, in a new tab.
=cut
sub getEditForm {
my $self = shift;
my $session = $self->session;
my $tabform = $self->SUPER::getEditForm;
# TODO once comments can be submitted using AJAX this will work...
# be sure to uncomment the tab in the next function also...
#my $comments = $tabform->getTab( 'comments' );
# $comments->div({name => 'comments',
# contentCallback => sub { $self->getFormattedComments },
# });
return $tabform;
}
#-------------------------------------------------------------------
=head2 getEditTabs ( )
defines 2 new tabs.
@ -561,15 +486,11 @@ in the future when the sku asset is created from this data.
=cut
sub getEditTabs {
my $self = shift;
my $i18n = WebGUI::International->new($self->session,"Asset_EMSSubmission");
my $sku_i18n = WebGUI::International->new($self->session,"Asset_Sku");
return ($self->SUPER::getEditTabs(), ['shop', $sku_i18n->get('shop'), 9],
# The comment tab is not available because comments are not AJAX yet...
# ['comments', $i18n->get('comments'), 9]
);
}
override getEditTabs => sub {
my $self = shift;
my $sku_i18n = WebGUI::International->new($self->session,"Asset_Sku");
return (super(), ['shop', $sku_i18n->get('shop'), 9],);
};
#-------------------------------------------------------------------
@ -592,11 +513,11 @@ Making private. See WebGUI::Asset::indexContent() for additonal details.
=cut
sub indexContent {
override indexContent => sub {
my $self = shift;
my $indexer = $self->next::method;
my $indexer = super();
$indexer->setIsPublic(0);
}
};
#-------------------------------------------------------------------
@ -609,10 +530,6 @@ See WebGUI::Asset::prepareView() for details.
sub prepareView {
my $self = shift;
$self->ems->prepareView;
#$self->next::method();
#my $template = WebGUI::Asset::Template->new( $self->session, $self->get("templateId") );
#$template->prepare($self->getMetaDataAsTemplateVariables);
#$self->{_viewTemplate} = $template;
}
#----------------------------------------------------------------
@ -659,50 +576,6 @@ sub processForm {
return $params;
}
#-------------------------------------------------------------------
=head2 processPropertiesFromFormPost ( )
Used to process properties from the form posted. Do custom things with
noFormPost fields here, or do whatever you want. This method is called
when /yourAssetUrl?func=editSave is requested/posted.
=cut
sub processPropertiesFromFormPost {
my $self = shift;
$self->next::method;
}
#-------------------------------------------------------------------
=head2 purge ( )
This method is called when data is purged by the system.
removes collateral data associated with a NewAsset when the system
purges it's data. This method is unnecessary, but if you have
auxiliary, ancillary, or "collateral" data or files related to your
asset instances, you will need to purge them here.
=cut
#sub purge {
# my $self = shift;
# return $self->next::method;
#}
#-------------------------------------------------------------------
=head2 purgeRevision ( )
This method is called when data is purged by the system.
=cut
#sub purgeRevision {
# my $self = shift;
# return $self->next::method;
#}
#-------------------------------------------------------------------

View file

@ -63,6 +63,7 @@ use Archive::Any;
=head1 DIAGNOSTICS
=head1 METHODS
=cut
#----------------------------------------------------------------------------

View file

@ -306,7 +306,7 @@ sub getFolder {
$oldVersionTag->setWorking() if $oldVersionTag;
##Get a new version of the asset from the db with the correct state
$folder = WebGUI::Asset->newByUrl($session, $folderUrl);
$folder = $folder->cloneFromDb();
return $folder;
}

View file

@ -1975,7 +1975,7 @@ sub prepareShowSurveyTemplate {
Serializes the SurveyJSON instance and persists it to the database.
Calling this method is only required if you have directly accessed and modified
the L<"surveyJSON"> object.
the L<WebGUI::Asset::Wobject::Survey::surveyJSON> object.
=cut

View file

@ -733,7 +733,7 @@ sub getParent {
return $self if ($self->getId eq "PBasset000000000000001");
unless ( $self->{_parent} ) {
$self->{_parent} = WebGUI::Asset->newById($self->session,$self->parentId);
$self->{_parent} = eval { WebGUI::Asset->newById($self->session, $self->parentId); };
}
return $self->{_parent};

View file

@ -76,7 +76,7 @@ Returns an array of the names of all tables in every class used by this class.
=cut
sub get_tables {
my $self = shift;
my ($self) = @_;
if ($self->is_immutable) {
return @{ $self->{__immutable}{get_tables_methods} ||= [ $self->_get_tables ] };
}

View file

@ -76,7 +76,7 @@ Returns an array of all attribute names across all meta classes.
=cut
sub get_all_attributes_list {
my $self = shift;
my ($self) = @_;
if ($self->is_immutable) {
return @{ $self->{__immutable}{get_all_attributes_list} ||= [ $self->_get_all_attributes_list ] };
}

View file

@ -3,6 +3,7 @@ package WebGUI::FilePump::Bundle;
use base qw/WebGUI::Crud WebGUI::JSONCollateral/;
use strict;
use WebGUI::International;
use WebGUI::Exception;
use WebGUI::Utility;
use URI;
use Path::Class;
@ -508,8 +509,8 @@ sub fetchAsset {
my $url = $uri->opaque;
$url =~ s{^/+}{};
my $asset = WebGUI::Asset->newByUrl($self->session, $url);
return {} unless $asset;
my $asset = eval {WebGUI::Asset->newByUrl($self->session, $url);};
return {} if Exception::Class->caught();
##Check for a snippet, or snippet subclass?
my $guts = {
lastModified => $asset->get('lastModified'),

View file

@ -17,6 +17,7 @@ package WebGUI::Form::Email;
use strict;
use base 'WebGUI::Form::Text';
use WebGUI::International;
use WebGUI::Utility;
=head1 NAME

View file

@ -48,7 +48,7 @@ This is an aspect which makes adding comments to existing assets trivial.
=head1 SYNOPSIS
with 'WebGUI::Role::Asset::Comments';
=head1 METHODS
These methods are available from this class:

View file

@ -897,7 +897,6 @@ sub setRow {
return $id;
}
#-------------------------------------------------------------------
=head2 unconditionalRead ( sql [, placeholders ] )

View file

@ -45,7 +45,7 @@ pod2usage( verbose => 2 ) if $help;
pod2usage() unless $configFile;
print "Starting up...\n" unless ($quiet);
my $session = WebGUI::Session->open($webguiRoot,$configFile);
my $session = WebGUI::Session->open($configFile);
if ($userMessageFile) {
print "Opening message file.." unless ($quiet);

View file

@ -140,7 +140,6 @@ checkModule('Digest::SHA', '5.47' );
checkModule("CSS::Minifier::XS", "0.03" );
checkModule("JavaScript::Minifier::XS", "0.05" );
checkModule("Readonly", "1.03" );
checkModule("Memcached::libmemcached", "0.3102" );
checkModule("Moose", "0.93" );
checkModule("MooseX::Storage", "0.23" );
checkModule("MooseX::NonMoose", '0.07' );

145
t/Cache.t
View file

@ -1,145 +0,0 @@
# vim:syntax=perl
#-------------------------------------------------------------------
# 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
#------------------------------------------------------------------
# Write a little about what this script tests.
#
#
use FindBin;
use strict;
use lib "$FindBin::Bin/lib";
use Test::More;
use WebGUI::Test; # Must use this before any other WebGUI modules
use WebGUI::Session;
use WebGUI::Cache;
#----------------------------------------------------------------------------
# Init
my $session = WebGUI::Test->session;
#----------------------------------------------------------------------------
# Tests
plan tests => 11; # Increment this number for each test you create
#----------------------------------------------------------------------------
my $cache = WebGUI::Cache->new($session, 1);
isa_ok($cache, 'WebGUI::Cache');
is($cache->parseKey("andy"), $session->config->getFilename.":andy", "parseKey single key");
is($cache->parseKey(["andy","red"]), $session->config->getFilename.":andy:red", "parseKey composite key");
$cache->set("Shawshank","Prison");
is($cache->get("Shawshank"), "Prison", "set/get");
$cache->set(["andy", "dufresne"], "Prisoner");
is($cache->get(["andy", "dufresne"]), "Prisoner", "set/get composite");
my ($a, $b) = @{$cache->mget(["Shawshank",["andy", "dufresne"]])};
is($a, "Prison", "mget first value");
is($b, "Prisoner", "mget second value");
$cache->delete("Shawshank");
is(eval{$cache->get("Shawshank")}, undef, 'delete');
$cache->flush;
is(eval{$cache->get(["andy", "dufresne"])}, undef, 'flush');
$cache->setByHttp("http://www.google.com/");
cmp_ok($cache->get("http://www.google.com/"), 'ne', '', 'setByHttp');
my $longValue ='abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
abcdefghijklmnopqrstuvwxyz 0123456789 !@#$%^&*(
';
$cache->set("really-long-value",$longValue);
is($cache->get("really-long-value"), $longValue, "set/get really long value");
#----------------------------------------------------------------------------
# Cleanup
END {
}
#vim:ft=perl

View file

@ -1,79 +0,0 @@
# vim:syntax=perl
#-------------------------------------------------------------------
# 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
#------------------------------------------------------------------
# Write a little about what this script tests.
#
#
use FindBin;
use strict;
use lib "$FindBin::Bin/../lib";
use Storable qw(freeze thaw);
use Test::More;
use Time::HiRes;
use WebGUI::Test; # Must use this before any other WebGUI modules
use WebGUI::Session;
use WebGUI::Cache::Database;
#----------------------------------------------------------------------------
# Init
my $session = WebGUI::Test->session;
# presupposes that there are cached items to test
my $cacheEntries = $session->db->buildArrayRefOfHashRefs("select expires,cachekey,namespace,content from cache order by rand() limit 100");
#----------------------------------------------------------------------------
# Tests
plan tests => 2 + scalar(@{$cacheEntries}); # Increment this number for each test you create
#----------------------------------------------------------------------------
# put your tests here
my $cache = WebGUI::Cache::Database->new($session, "this", "that");
my $testValue = "a rock that has no earthly business in that field";
$cache->set($testValue);
is($cache->get, $testValue, "set/get works");
$cache->delete;
is($cache->get, undef, "delete works");
# performance tests
my $numTests = 0;
my $totalTime = 0;
foreach my $entry (@{$cacheEntries}) {
my $start = [Time::HiRes::gettimeofday];
my $cache = WebGUI::Cache::Database->new($session, $entry->{cachekey}, $entry->{namespace});
$cache->{_key} = $entry->{cachekey}; # evil: don't do this at home kids
my $value = $cache->get;
if ($entry->{expires} > time()) {
my $entryValue = $entry->{content};
eval { $entryValue = thaw($entryValue); };
$entryValue = ($entryValue && ref $entryValue) ? $$entryValue : undef;
is_deeply($value, $entryValue, "cache entry is valid");
}
else {
is($value, undef, "cache entry has timed out");
}
$numTests++;
$totalTime += Time::HiRes::tv_interval($start);
}
print "\nTime to run $numTests cache tests is $totalTime seconds. Average time per test is ".($totalTime/$numTests)." seconds.\n" if ($numTests > 0);
# end performance tests
#----------------------------------------------------------------------------
# Cleanup
END {
}

View file

@ -1,115 +0,0 @@
# vim:syntax=perl
#-------------------------------------------------------------------
# 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
#------------------------------------------------------------------
# Write a little about what this script tests.
#
#
use FindBin;
use strict;
use lib "$FindBin::Bin/../lib";
use Test::More;
use Test::Deep;
use Path::Class;
use File::Path;
use File::Basename qw(basename);
use WebGUI::Test; # Must use this before any other WebGUI modules
use WebGUI::Session;
use WebGUI::Cache;
#----------------------------------------------------------------------------
# Init
my $session = WebGUI::Test->session;
#----------------------------------------------------------------------------
# Tests
my $tests = 14;
plan tests => 1 + $tests;
#----------------------------------------------------------------------------
# put your tests here
my $origCacheType = $session->config->get('cacheType');
$session->config->set('cacheType', 'WebGUI::Cache::FileCache');
my $origCacheRoot = $session->config->get('fileCacheRoot');
$session->config->delete('fileCacheRoot');
my $loaded = use_ok('WebGUI::Cache::FileCache');
SKIP: {
skip 'Unable to load module WebGUI::Cache::FileCache', $tests unless $loaded;
my $cacher = WebGUI::Cache->new($session, 'ReservedForTests');
isa_ok($cacher, 'WebGUI::Cache::FileCache', 'WebGUI::Cache creates the correct object type');
isa_ok($cacher->session, 'WebGUI::Session', 'session method returns a session object');
cmp_deeply(
$cacher,
noclass({
_session => ignore(),
_namespace => basename(WebGUI::Test->file),
_key => re('[a-zA-Z0-9+\-]{22}'),
}),
'New FileCache object has correct defaults',
);
$cacher = WebGUI::Cache->new($session, 'ReservedForTests', 'ReservedForTests');
cmp_deeply(
$cacher,
noclass({
_session => ignore(),
_namespace => 'ReservedForTests',
_key => re('[a-zA-Z0-9+\-]{22}'),
}),
'Second fileCache object was recreated with custom namespace',
);
my $root = '/tmp'; ##Default for Unix testing. Need to extend this for Windows someday...
my $namespace = Path::Class::Dir->new($root, qw/WebGUICache ReservedForTests/);
is($cacher->getNamespaceRoot, $namespace->stringify, 'getNamespaceRoot returns the correct path');
ok(! -e $cacher->getNamespaceRoot, 'The namespace does not exist in the filesystem');
my $folder = $namespace->subdir($cacher->{_key});
is($cacher->getFolder, $folder->stringify, 'getFolder returns the correct path, which is the namespace with a key subdirectory');
ok(! -e $cacher->getFolder, 'The folder does not exist in the filesystem');
$cacher->set('Some value');
ok( -e $namespace->stringify, 'setting data into the cache creates the namespace dir');
ok( -e $folder->stringify, 'setting data into the cache creates the folder dir');
ok( -e $folder->file('expires')->stringify, 'expiry file was created');
ok( -e $folder->file('cache')->stringify, 'cache file was created');
$cacher->delete();
ok(! -e $cacher->getFolder, 'delete removes the cache folder');
$cacher->flush();
ok(! -e $cacher->getNamespaceRoot, 'purge removes the namespace folder');
undef $cacher;
}
#----------------------------------------------------------------------------
# Cleanup
END {
$session->config->set('cacheType', $origCacheType);
if ($origCacheRoot) {
$session->config->get('fileCacheRoot', $origCacheRoot);
}
}

View file

@ -14,6 +14,7 @@ use lib "$FindBin::Bin/../lib";
use WebGUI::Test;
use WebGUI::Session;
use WebGUI::Pluggable;
use WebGUI::Operation::Help;
#The goal of this test is to verify that all entries in the lib/WebGUI/Help
@ -26,14 +27,14 @@ my $numTests = 0;
my $session = WebGUI::Test->session;
my @helpFileSet = WebGUI::Operation::Help::_getHelpFilesList($session);
my @helpFileSet = WebGUI::Pluggable::findAndLoad('WebGUI::Help');
$numTests = scalar @helpFileSet; #One for each help compile
plan tests => $numTests;
foreach my $helpSet (@helpFileSet) {
my $helpName = $helpSet->[1];
my $help = WebGUI::Operation::Help::_load($session, $helpName);
ok(keys %{ $help }, "$helpName compiled");
foreach my $helpFile (@helpFileSet) {
my ($namespace) = $helpFile =~ m{WebGUI::Help::(.+$)};
my $help = WebGUI::Operation::Help::_load($session, $namespace);
ok(keys %{ $help }, "$namespace compiled");
}

View file

@ -33,7 +33,7 @@ WebGUI::Test->usersToDelete($newUser);
#----------------------------------------------------------------------------
# Tests
plan tests => 48; # Increment this number for each test you create
plan tests => 50; # Increment this number for each test you create
#----------------------------------------------------------------------------
# Test the creation of ProfileField
@ -91,6 +91,8 @@ my $newProfileField = WebGUI::ProfileField->create($session, 'testField', {
});
is($newProfileField->get('fieldType'), 'Float', 'create: makes field with correct type');
is $newProfileField->get('fieldName'), 'testField', '...correct fieldName';
is $newProfileField->getId, 'testField', '...correct id';
is($newProfileField->get('label'), 'Test Field', 'correct label');
is($newProfileField->getLabel, 'Test Field', 'getLabel works, too');

View file

@ -17,7 +17,7 @@ use WebGUI::Session;
use Data::Dumper;
use Test::Deep;
use Test::More tests => 56; # increment this value for each test you create
use Test::More tests => 57; # increment this value for each test you create
my $session = WebGUI::Test->session;
@ -145,6 +145,8 @@ my $setRowId = $session->db->setRow("incrementer","incrementerId",{incrementerId
ok($setRowId ne "", "setRow() - return ID");
my ($setRowResult) = $session->db->quickArray("select nextValue from incrementer where incrementerId=".$session->db->quote($setRowId));
is($setRowResult, 47, "setRow() - set data");
is $session->db->setRow("incrementer", "incrementerId",{incrementerId=>'new', nextValue => 48}, 'oogeyBoogeyBoo'),
'oogeyBoogeyBoo', 'overriding default id with a custom one';
# getRow
my $getRow = $session->db->getRow("incrementer","incrementerId",$setRowId);

View file

@ -328,14 +328,14 @@ TODO: {
####################################################
#
# process
# no duped headBlockContent
# no duped extraHeadTagsContent
#
####################################################
$style->useEmptyStyle(1);
$style->sent(0);
$session->scratch->set('personalStyleId', $templates->{headBlock}->getId);
$session->scratch->set('personalStyleId', $templates->{extraHeadTags}->getId);
$styled = $style->process('body.content', 'notATemplateId');
@ -369,7 +369,8 @@ $expectedMetas = [
'content' => 'must-revalidate'
},
];
cmp_bag(\@metas, $expectedMetas, 'process, headBlock:no duped headBlock from style template');
cmp_bag(\@metas, $expectedMetas, 'process, extraHeadTags:no duped extraHeadTags from style template');
####################################################
#
# process
@ -480,16 +481,16 @@ sub setup_assets {
};
$templates->{personal} = $importNode->addChild($properties, $properties->{id});
$properties = {
title => 'personal style test template with headBlock',
title => 'personal style test template with extraHeadTags',
className => 'WebGUI::Asset::Template',
url => 'headblock_style',
namespace => 'Style',
template => 'HEADBLOCK STYLE TEMPLATE\n\nBODY=<tmpl_var body.content>\n\nHEAD=<tmpl_var head.tags>',
headBlock => q|<meta name="keywords" content="keyword1,keyword2" />|,
extraHeadTags => q|<meta name="keywords" content="keyword1,keyword2" />|,
id => 'testTemplate_headblock',
# '1234567890123456789012'
};
$templates->{headBlock} = $importNode->addChild($properties, $properties->{id});
$templates->{extraHeadTags} = $importNode->addChild($properties, $properties->{id});
$properties = {
title => 'personal style test template for printing',
className => 'WebGUI::Asset::Template',

View file

@ -417,21 +417,21 @@ my $statefulAsset = WebGUI::Asset->getRoot($session)->addChild({ className => 'W
$versionTag->commit;
$session->asset( $statefulAsset );
$statefulAsset->{_properties}{state} = 'published';
$statefulAsset->state('published');
is(
$session->url->getBackToSiteURL,
WebGUI::Asset->getRoot($session)->getUrl,
q!getBackToSiteURL: When asset state is published, it returns you to the Assets container!
);
$statefulAsset->{_properties}{state} = 'trash';
$statefulAsset->state( 'trash');
is(
$session->url->getBackToSiteURL,
$defaultAssetUrl,
q!getBackToSiteURL: When asset state is trash, it returns you to the default Asset!
);
$statefulAsset->{_properties}{state} = 'clipboard';
$statefulAsset->state('clipboard');
is(
$session->url->getBackToSiteURL,
$defaultAssetUrl,

View file

@ -138,13 +138,13 @@ $session->db->write("update userSession set expires=? where sessionId=?",
my %copyOfVar2 = %{$var2->{_var}};
$copyOfVar2{expires} = $var2->get('lastPageView')-1;
$copyOfVar2{userId} = 3;
$session->cache->set(['session',$var2->getId], \%copyOfVar2);
$session->cache->set($var2->getId, \%copyOfVar2);
my $var3 = WebGUI::Session::Var->new($session, $var2->getId);
is($var3->getId, $var2->getId, 'new Var object has correct id');
isnt($var3->isAdminOn, $var2->isAdminOn, 'new adminOn not equal to old adminOn');
is($var3->isAdminOn, 0, 'new Var object has default adminOn');
isnt($var3->get('userId'), 3, 'new userId not equal to old userId');
is $var3->getId, $var2->getId, 'new Var object has correct id';
isnt $var3->isAdminOn, $var2->isAdminOn, 'new adminOn not equal to old adminOn';
is $var3->isAdminOn, 0, 'new Var object has default adminOn';
isnt $var3->get('userId'), 3, 'new userId not equal to old userId';
$var2->end;
$var3->end;

View file

@ -289,7 +289,7 @@ ok (!(-e $storage1->getPath("testfile-hash.file")), "rename file original file i
####################################################
$storage1->addFileFromFilesystem(
WebGUI::Test->getTestCollateralPath('WebGUI.pm'),
WebGUI::Test->getTestCollateralPath('International/lib/WebGUI/i18n/PigLatin/WebGUI.pm'),
);
ok(
@ -473,7 +473,7 @@ is($formStore->addFileFromFormPost('files'), undef, 'addFileFromFormPost returns
$session->request->uploadFiles(
'oneFile',
[ WebGUI::Test->getTestCollateralPath('WebGUI.pm') ],
[ WebGUI::Test->getTestCollateralPath('International/lib/WebGUI/i18n/PigLatin/WebGUI.pm') ],
);
is($formStore->addFileFromFormPost('oneFile'), 'WebGUI.pm', '... returns the name of the uploaded file');
cmp_bag($formStore->getFiles, [ qw/WebGUI.pm/ ], '... adds the file to the storage location');

View file

@ -15,7 +15,6 @@ use lib "$FindBin::Bin/lib";
use WebGUI::Test;
use WebGUI::Session;
use WebGUI::Utility;
use WebGUI::Cache;
#use Exception::Class;
use WebGUI::User;
@ -28,8 +27,7 @@ use Data::Dumper;
my $session = WebGUI::Test->session;
my $testCache = WebGUI::Cache->new($session, 'myTestKey');
$testCache->flush;
$session->cache->remove('myTestKey');
my $user;
my $lastUpdate;
@ -1063,6 +1061,6 @@ END {
$newProfileField->delete() if $newProfileField;
$testCache->flush;
$session->cache->remove('myTestKey');
}

View file

@ -236,7 +236,7 @@ is($siteWideTag->getId(), $siteWideTagId, 'versionTagMode siteWide: reclaim site
## Through in a new session as different user
my $admin_session = WebGUI::Session->open($WebGUI::Test->file);
my $admin_session = WebGUI::Session->open(WebGUI::Test->file);
$admin_session->user({'userId' => 3});
WebGUI::Test->sessionsToDelete($admin_session);
@ -301,7 +301,7 @@ $adminUserTag->rollback();
is($tag->getAssetCount, 1, qq{$test_prefix [singlePerUser] tag with 1 asset});
# create admin session
my $admin_session = WebGUI::Session->open($WebGUI::Test->file);
my $admin_session = WebGUI::Session->open(WebGUI::Test->file);
addToCleanup($session);
$admin_session->user({'userId' => 3});

View file

@ -16,7 +16,7 @@ use lib "$FindBin::Bin/../lib"; ##t/lib
use WebGUI::Test;
use WebGUI::Operation::Help;
use WebGUI::International;
use WebGUI::Session;
use WebGUI::Pluggable;
use Data::Dumper;
#The goal of this test is to verify all the i18n labels in
@ -28,14 +28,14 @@ my $numTests = 0;
my $session = WebGUI::Test->session;
my @helpFileSet = WebGUI::Operation::Help::_getHelpFilesList($session);
my @helpFileSet = WebGUI::Pluggable::findAndLoad('WebGUI::Help');
my %helpTable;
foreach my $helpSet (@helpFileSet) {
my $helpName = $helpSet->[1];
my $help = WebGUI::Operation::Help::_load($session, $helpName);
$helpTable{ $helpName } = $help;
foreach my $helpFile (@helpFileSet) {
my ($namespace) = $helpFile =~ m{WebGUI::Help::(.+$)};
my $help = WebGUI::Operation::Help::_load($session, $namespace);
$helpTable{ $namespace } = $help;
}
##Scan #1, find all labels in the help system. body, title, @fields

View file

@ -74,7 +74,7 @@ Usage:
# Reset the session back
$session->{_request} = $old_session;
=cut
sub get_request

View file

@ -57,8 +57,6 @@ our @EXPORT_OK = qw(session config collateral);
my $CLASS = __PACKAGE__;
my @guarded;
sub import {
our $CONFIG_FILE = $ENV{ WEBGUI_CONFIG };
@ -80,7 +78,7 @@ sub _initSession {
my $session = our $SESSION = $CLASS->newSession(1);
my $originalSetting = clone $session->setting->get;
push @guarded, Scope::Guard->new(sub {
$CLASS->addToCleanup(sub {
while (my ($param, $value) = each %{ $originalSetting }) {
$session->setting->set($param, $value);
}
@ -110,7 +108,7 @@ sub _initSession {
my ($label, $table) = @checkCount[$i, $i+1];
$initCounts{$table} = $session->db->quickScalar('SELECT COUNT(*) FROM ' . $table);
}
push @guarded, Scope::Guard->new(sub {
$CLASS->addToCleanup(sub {
for ( my $i = 0; $i < @checkCount; $i += 2) {
my ($label, $table) = @checkCount[$i, $i+1];
my $quant = $session->db->quickScalar('SELECT COUNT(*) FROM ' . $table);
@ -127,19 +125,6 @@ END {
$CLASS->cleanup;
}
sub cleanup {
# remove guards in reverse order they were added, triggering all of the
# requested cleanup operations
pop @guarded
while @guarded;
if ( our $SESSION ) {
$SESSION->var->end;
$SESSION->close;
undef $SESSION;
}
}
#----------------------------------------------------------------------------
=head2 newSession ( $noCleanup )
@ -159,7 +144,7 @@ sub newSession {
my $session = WebGUI::Session->open( $CLASS->config );
$session->{_request} = $pseudoRequest;
if ( ! $noCleanup ) {
$CLASS->sessionsToDelete($session);
$CLASS->addToCleanup($session);
}
return $session;
}
@ -444,7 +429,7 @@ Returns the full path to the WebGUI lib directory, usually /data/WebGUI/lib.
=cut
our $WEBGUI_LIB = File::Spec->catdir( $WEBGUI_TEST_ROOT, File::Spec->updir );
our $WEBGUI_LIB = File::Spec->catdir( $WEBGUI_TEST_ROOT, File::Spec->updir, 'lib' );
sub lib {
return our $WEBGUI_LIB;
@ -543,7 +528,7 @@ sub prepareMailServer {
# Let it start up yo
sleep 2;
push @guarded, Scope::Guard->new(sub {
$CLASS->addToCleanup(sub {
# Close SMTPD
if ($smtpdPid) {
kill INT => $smtpdPid;
@ -576,7 +561,7 @@ sub originalConfig {
}
# add cleanup handler if this is the first time we were run
if (! keys %originalConfig) {
push @guarded, Scope::Guard->new(sub {
$class->addToCleanup(sub {
while (my ($key, $value) = each %originalConfig) {
if (defined $value) {
$CLASS->session->config->set($key, $value);
@ -592,7 +577,7 @@ sub originalConfig {
#----------------------------------------------------------------------------
=head2 getMail ( )
=head2 getMail ( )
Read a sent mail from the prepared mail server (L<prepareMailServer>)
@ -600,7 +585,7 @@ Read a sent mail from the prepared mail server (L<prepareMailServer>)
sub getMail {
my $json;
if ( !$smtpdSelect ) {
return from_json ' { "error": "mail server not prepared" }';
}
@ -611,11 +596,11 @@ sub getMail {
else {
$json = ' { "error": "mail not sent" } ';
}
if (!$json) {
$json = ' { "error": "error in getting mail" } ';
}
return from_json( $json );
}
@ -635,7 +620,7 @@ sub getMailFromQueue {
if ( !$smtpdSelect ) {
$class->prepareMailServer;
}
my $messageId = $CLASS->session->db->quickScalar( "SELECT messageId FROM mailQueue" );
warn $messageId;
return unless $messageId;
@ -646,6 +631,7 @@ sub getMailFromQueue {
return $class->getMail;
}
#----------------------------------------------------------------------------
=head2 sessionsToDelete ( $session, [$session, ...] )
@ -660,7 +646,7 @@ This is a class method.
sub sessionsToDelete {
my $class = shift;
push @guarded, cleanupGuard(@_);
$class->addToCleanup(@_);
}
#----------------------------------------------------------------------------
@ -677,7 +663,7 @@ This is a class method.
sub assetsToPurge {
my $class = shift;
push @guarded, cleanupGuard(@_);
$class->addToCleanup(@_);
}
#----------------------------------------------------------------------------
@ -693,7 +679,7 @@ This is a class method.
sub groupsToDelete {
my $class = shift;
push @guarded, cleanupGuard(@_);
$class->addToCleanup(@_);
}
@ -710,7 +696,7 @@ This is a class method.
sub storagesToDelete {
my $class = shift;
push @guarded, cleanupGuard(map {
$class->addToCleanup(map {
ref $_ ? $_ : ('WebGUI::Storage' => $_)
} @_);
}
@ -727,7 +713,7 @@ This is a class method.
sub tagsToRollback {
my $class = shift;
push @guarded, cleanupGuard(@_);
$class->addToCleanup(@_);
}
#----------------------------------------------------------------------------
@ -743,7 +729,7 @@ This is a class method.
sub usersToDelete {
my $class = shift;
push @guarded, cleanupGuard(@_);
$class->addToCleanup(@_);
}
#----------------------------------------------------------------------------
@ -759,7 +745,7 @@ This is a class method.
sub workflowsToDelete {
my $class = shift;
push @guarded, cleanupGuard(@_);
$class->addToCleanup(@_);
}
@ -973,12 +959,26 @@ This is a class method.
=cut
my @guarded;
sub addToCleanup {
shift
if eval { $_[0]->isa($CLASS) };
push @guarded, cleanupGuard(@_);
}
sub cleanup {
# remove guards in reverse order they were added, triggering all of the
# requested cleanup operations
pop @guarded
while @guarded;
if ( our $SESSION ) {
$SESSION->var->end;
$SESSION->close;
undef $SESSION;
}
}
#----------------------------------------------------------------------------
=head1 BUGS

View file

@ -3,16 +3,16 @@ package WebGUI::Test::Activity;
use WebGUI::Workflow;
use WebGUI::Test;
=head Name
=head1 Name
package WebGUI::Test::Activity;
=head Description
=head1 Description
This package encapsulates the code required to run
an activity.
=head Usage
=head1 Usage
use WebGUI::Test::Activity;
@ -27,17 +27,21 @@ is( $instance->run, 'complete', 'activity complete' );
is( $instance->run, 'done', 'activity done' );
$instance->delete;
=head methods
=head1 methods
=head2 create
=params
=head3 session
session -- the session variable
the session variable
class -- the class for the activity to run
=head3 class
params -- params to set in the workflow
the class for the activity to run
=head3 params
params to set in the workflow
=cut

View file

@ -26,6 +26,7 @@ functions _quiet_caller and _try_as_caller are directly copied from Test::Except
hocuspocus is being in that module however, since doing 'eval { uplevel 1, $codeRef }' seems to work too. On my
platform at least =). For the time being, I leave those subs in here so that they may be used. They are commented
out by default, though.
=cut
#----------------------------------------------------------------------------

View file

@ -165,7 +165,7 @@ plan tests => $numTests;
foreach my $tmpl ( @tmplVarTable ) {
my $tmplId = $tmpl->{id};
my $tmplAsset = WebGUI::Asset->newByDynamicClass($session, $tmplId);
my $tmplAsset = eval { WebGUI::Asset->newById($session, $tmplId); };
my $tmplExists = is(ref($tmplAsset), 'WebGUI::Asset::Template', "$tmplId exists");
SKIP: {
skip("$tmplId could not be found", $tmpl->{numTests} ) unless $tmplExists;

View file

@ -32,7 +32,8 @@ sub _00_init : Test(startup => 1) {
my $session = WebGUI::Test->session;
$test->session($session);
my $class = ref $test;
$class =~ s/Test:://;
$class =~ s/^Test:://;
return ('Not a WebGUI class') unless $class =~ /^WebGUI/;
$test->class($class);
lives_ok { WebGUI::Asset->loadModule($class); } "loaded module class $class";
}

View file

@ -92,6 +92,11 @@
margin: 0; padding: 0;
}
.clickable {
cursor: pointer;
color: blue;
}
img.icon {
vertical-align: baseline;
}

View file

@ -79,10 +79,37 @@ WebGUI.Admin.prototype.afterShowViewTab
};
/**
* go( url )
* Open the view tab and go to the given URL.
* Should not be used for assets, use gotoAsset() instead
* appendToUrl( url, params )
* Add URL components to a URL;
*/
appendToUrl
= function ( url, params ) {
var components = [ url ];
if (url.match(/\?/)) {
components.push(";");
}
else {
components.push("?");
}
components.push(params);
return components.join('');
};
/**
* editAsset( url )
* Show the edit form for the asset at the given URL
*/
WebGUI.Admin.prototype.editAsset
= function ( url ) {
// Open the edit form
window.frames["view"].location.href = appendToUrl( url, "func=edit" );
// Mark undirty, as we'll clean it ourselves
this.viewDirty = 0;
// Show the view tab
this.tabBar.selectTab( 0 );
};
/**
* gotoAsset( url )
@ -96,14 +123,38 @@ WebGUI.Admin.prototype.gotoAsset
}
else if ( this.currentTab == "tree" ) {
// Make tree request
this.tree.goto( this.currentAssetDef.url );
this.tree.goto( url );
this.viewDirty = 1;
}
};
/**
* makeEditAsset( url )
* Create a callback to edit an asset. Use when attaching to event listeners
*/
WebGUI.Admin.prototype.makeEditAsset
= function (url) {
var self = this;
return function() {
self.editAsset( url );
};
};
/**
* makeGotoAsset( url )
* Create a callback to view an asset. Use when attaching to event listeners
*/
WebGUI.Admin.prototype.makeGotoAsset
= function ( url ) {
var self = this;
return function() {
self.gotoAsset( url );
};
};
/**
* navigate( assetDef )
* We've navigated to a new asset. Called by one of the iframes when a new
* We've navigated to a new asset. Called by the view iframe when a new
* page is reached
*/
WebGUI.Admin.prototype.navigate
@ -122,7 +173,10 @@ WebGUI.Admin.prototype.navigate
// Update the location bar
this.locationBar.navigate( assetDef );
this.currentAssetDef = assetDef;
if ( !this.currentAssetDef || this.currentAssetDef.assetId != assetDef.assetId ) {
this.currentAssetDef = assetDef;
this.treeDirty = 1;
}
};
/****************************************************************************
@ -442,7 +496,7 @@ WebGUI.Admin.Tree
fields: [
{ key: 'assetId' },
{ key: 'lineage' },
{ key: 'actions' },
{ key: 'canEdit' },
{ key: 'title' },
{ key: 'className' },
{ key: 'revisionDate' },
@ -453,7 +507,9 @@ WebGUI.Admin.Tree
{ key: 'childCount' }
],
metaFields: {
totalRecords: "totalAssets" // Access to value in the server response
totalRecords: "totalAssets", // Access to value in the server response
crumbtrail : "crumbtrail",
currentAsset : "currentAsset"
}
};
@ -493,23 +549,6 @@ WebGUI.Admin.Tree
};
/**
* appendToUrl( url, params )
* Add URL components to a URL;
*/
appendToUrl
= function ( url, params ) {
var components = [ url ];
if (url.match(/\?/)) {
components.push(";");
}
else {
components.push("?");
}
components.push(params);
return components.join('');
};
/**
* addHighlightToRow ( child )
* Highlight the row containing this element by adding to it the "highlight"
@ -605,16 +644,17 @@ WebGUI.Admin.Tree.prototype.findRow
*/
WebGUI.Admin.Tree.prototype.formatActions
= function ( elCell, oRecord, oColumn, orderNumber ) {
if ( oRecord.getData( 'actions' ) ) {
elCell.innerHTML
= '<a href="' + appendToUrl(oRecord.getData( 'url' ), 'func=edit;proceed=manageAssets') + '">'
+ window.admin.i18n.get('Asset', 'edit') + '</a>'
+ ' | '
;
}
else {
elCell.innerHTML = "";
if ( oRecord.getData( 'canEdit' ) ) {
var edit = document.createElement("span");
edit.className = "clickable";
YAHOO.util.Event.addListener( edit, "click", function(){
window.admin.editAsset( oRecord.getData('url') );
}, window.admin, true );
edit.appendChild( document.createTextNode( window.admin.i18n.get('Asset', 'edit') ) );
elCell.appendChild( edit );
elCell.appendChild( document.createTextNode( " | " ) );
}
return; // TODO
var more = document.createElement( 'a' );
elCell.appendChild( more );
@ -627,7 +667,7 @@ WebGUI.Admin.Tree.prototype.formatActions
oldMenu.parentNode.removeChild( oldMenu );
}
var options = this.buildMoreMenu(oRecord.getData( 'url' ), more, oRecord.getData( 'actions' ));
var options = this.buildMoreMenu(oRecord.getData( 'url' ), more, oRecord.getData( 'canEdit' ));
var menu = new YAHOO.widget.Menu( "moreMenu" + oRecord.getData( 'assetId' ), options );
YAHOO.util.Event.onDOMReady( function () { menu.render( document.getElementById( 'assetManager' ) ); } );
@ -674,11 +714,11 @@ WebGUI.Admin.Tree.prototype.formatLockedBy
elCell.innerHTML
= oRecord.getData( 'lockedBy' )
? '<a href="' + appendToUrl(oRecord.getData( 'url' ), 'func=manageRevisions') + '">'
+ '<img src="' + extras + '/assetManager/locked.gif" alt="' + window.admin.i18n.get('WebGUI', 'locked by') + ' ' + oRecord.getData( 'lockedBy' ) + '" '
+ '<img src="' + extras + '/icon/lock.png" alt="' + window.admin.i18n.get('WebGUI', 'locked by') + ' ' + oRecord.getData( 'lockedBy' ) + '" '
+ 'title="' + window.admin.i18n.get('WebGUI', 'locked by') + ' ' + oRecord.getData( 'lockedBy' ) + '" border="0" />'
+ '</a>'
: '<a href="' + appendToUrl(oRecord.getData( 'url' ), 'func=manageRevisions') + '">'
+ '<img src="' + extras + '/assetManager/unlocked.gif" alt="' + window.admin.i18n.get('Asset', 'unlocked') + '" '
+ '<img src="' + extras + '/icon/lock_open.png" alt="' + window.admin.i18n.get('Asset', 'unlocked') + '" '
+ 'title="' + window.admin.i18n.get('Asset', 'unlocked') + '" border="0" />'
+ '</a>'
;
@ -721,16 +761,30 @@ WebGUI.Admin.Tree.prototype.formatRevisionDate
*/
WebGUI.Admin.Tree.prototype.formatTitle
= function ( elCell, oRecord, oColumn, orderNumber ) {
elCell.innerHTML = '<span class="hasChildren">'
+ ( oRecord.getData( 'childCount' ) > 0 ? "+" : "&nbsp;" )
+ '</span> <span class="clickable">'
+ oRecord.getData( 'title' )
+ '</span>'
;
var hasChildren = document.createElement("span");
hasChildren.className = "hasChildren";
if ( oRecord.getData('childCount') > 0 ) {
hasChildren.appendChild( document.createTextNode( "+" ) );
}
else {
hasChildren.appendChild( document.createTextNode( " " ) );
}
elCell.appendChild( hasChildren );
var title = document.createElement("span");
title.className = "clickable";
title.appendChild( document.createTextNode( oRecord.getData('title') ) );
YAHOO.util.Event.addListener( title, "click", function(){ window.admin.gotoAsset(oRecord.getData('url')) }, this, true );
elCell.appendChild( title );
};
/**
* Update the tree with a new asset
* Do not call this directly, use Admin.gotoAsset(url)
*/
WebGUI.Admin.Tree.prototype.goto
= function ( assetUrl ) {
// TODO: Show loading screen
var callback = {
success : this.onDataReturnInitializeTable,
failure : this.onDataReturnInitializeTable,
@ -756,6 +810,32 @@ WebGUI.Admin.Tree.prototype.onDataReturnInitializeTable
= function ( sRequest, oResponse, oPayload ) {
this.dataTable.onDataReturnInitializeTable.call( this.dataTable, sRequest, oResponse, oPayload );
// Rebuild the crumbtrail
var crumb = oResponse.meta.crumbtrail;
var elCrumb = document.getElementById( "treeCrumbtrail" );
elCrumb.innerHTML = '';
for ( var i = 0; i < crumb.length; i++ ) {
var item = crumb[i];
var elItem = document.createElement( "span" );
elItem.className = "clickable";
YAHOO.util.Event.addListener( elItem, "click", window.admin.makeGotoAsset(item.url) );
elItem.appendChild( document.createTextNode( item.title ) );
elCrumb.appendChild( elItem );
elCrumb.appendChild( document.createTextNode( " > " ) );
}
// Final crumb item has a menu
var elItem = document.createElement( "span" );
elItem.className = "clickable";
YAHOO.util.Event.addListener( elItem, "click", function(){ alert( "TOADO" ) }, this, true );
elItem.appendChild( document.createTextNode( oResponse.meta.currentAsset.title ) );
elCrumb.appendChild( elItem );
// TODO: Update current asset
window.admin.navigate( oResponse.meta.currentAsset );
// TODO Hide loading screen
};
/**
@ -834,7 +914,7 @@ WebGUI.Admin.Tree.prototype.toggleHighlightForRow
*/
WebGUI.Admin.Tree.prototype.toggleRow = function ( child ) {
var row = this.findRow( child );
// Find the checkbox
var inputs = row.getElementsByTagName( "input" );
for ( var i = 0; i < inputs.length; i++ ) {