Merge commit '808a866c8b' into webgui8. 7.9.4 release point

Conflicts:
	docs/upgrades/packages-7.9.3/root_import_gallery-templates_default-gallery-edit-album.wgpkg
	docs/upgrades/upgrade_7.9.2-7.9.3.pl
	lib/WebGUI.pm
	lib/WebGUI/Asset/MapPoint.pm
	lib/WebGUI/Asset/Wobject/Calendar.pm
	lib/WebGUI/Asset/Wobject/Gallery.pm
	lib/WebGUI/Asset/Wobject/GalleryAlbum.pm
	lib/WebGUI/Asset/Wobject/WikiMaster.pm
	lib/WebGUI/AssetClipboard.pm
	lib/WebGUI/AssetVersioning.pm
	lib/WebGUI/Auth.pm
	t/Asset/Asset.t
This commit is contained in:
Colin Kuskie 2010-06-25 20:08:11 -07:00
commit b30491f3a6
31 changed files with 1974 additions and 415 deletions

View file

@ -1,3 +1,5 @@
7.9.4
7.9.3
- added #11477: No synopsis in asset now means no synopsis in search index
- added #11007: Added drag'n'drop sorting in Gallery Album Edit View (Bernd Kalbfuß-Zimmermann)
@ -5,6 +7,16 @@
- fixed #11520: Wiki Locked
- fixed Missing Template variables for the Wiki Page view template.
- added #10944: Wiki Keyword Page
- added #10946: Wiki - Hierarchical Keyword Report
- added #10945: Wiki - Top-level keyword list
- fixed #11444: Strange spectre problem
- fixed #10189: pbworkflow000000000007 Hanging
- fixed #11526: Wrong log error in file AssetClipboard.pm
- fixed #11525: Paste assets inside CS
- added #620: Add buttons to the GalleryAlbum edit view so users can rotate photos by 90 deg (Bernd Kalbfuß-Zimmermann)
- fixed #11530: account deactivation not working (United Knowledge)
- fixed #11531: MapPoint property conflict
- fixed #11532: MapPoint, no i18n
7.9.2
- added: Workflow to extend recurring Calendar events 2 years from the

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,176 @@
#!/usr/bin/env 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
#-------------------------------------------------------------------
our ($webguiRoot);
BEGIN {
$webguiRoot = "../..";
unshift (@INC, $webguiRoot."/lib");
}
use strict;
use Getopt::Long;
use WebGUI::Session;
use WebGUI::Storage;
use WebGUI::Asset;
my $toVersion = '7.9.3';
my $quiet; # this line required
my $session = start(); # this line required
reindexSiteForDefaultSynopsis( $session );
addTopLevelWikiKeywords( $session );
renameMapPointStateColumn( $session );
finish($session); # this line required
#----------------------------------------------------------------------------
# Describe what our function does
#sub exampleFunction {
# my $session = shift;
# print "\tWe're doing some stuff here that you should know about... " unless $quiet;
# # and here's our code
# print "DONE!\n" unless $quiet;
#}
#----------------------------------------------------------------------------
sub renameMapPointStateColumn {
my $session = shift;
print "\tRename the MapPoint column state to region... " unless $quiet;
$session->db->write('ALTER TABLE MapPoint CHANGE state region char(35)');
print "Done.\n" unless $quiet;
}
#----------------------------------------------------------------------------
sub addTopLevelWikiKeywords {
my $session = shift;
print "\tAdding top level keywords page to WikiMaster... " unless $quiet;
my $sth = $session->db->read('DESCRIBE `WikiMaster`');
while (my ($col) = $sth->array) {
if ($col eq 'topLevelKeywords') {
print "Skipped.\n" unless $quiet;
return;
}
}
$session->db->write('ALTER TABLE WikiMaster ADD COLUMN topLevelKeywords LONGTEXT');
print "Done.\n" unless $quiet;
}
#----------------------------------------------------------------------------
# Reindex the site to clear out default synopsis
sub reindexSiteForDefaultSynopsis {
my $session = shift;
print "\tRe-indexing site to clear out default synopses... " unless $quiet;
my $rs = $session->db->read("select assetId, className from asset where state='published'");
my @searchableAssetIds;
while (my ($id, $class) = $rs->array) {
my $asset = WebGUI::Asset->new($session,$id,$class);
if (defined $asset && $asset->get("state") eq "published" && ($asset->get("status") eq "approved" || $asset->get("status") eq "archived")) {
$asset->indexContent;
push (@searchableAssetIds, $id);
}
}
# delete indexes of assets that are no longer searchable
my $list = $session->db->quoteAndJoin(\@searchableAssetIds) if scalar(@searchableAssetIds);
$session->db->write("delete from assetIndex where assetId not in (".$list.")") if $list;
print "DONE!\n" unless $quiet;
}
# -------------- DO NOT EDIT BELOW THIS LINE --------------------------------
#----------------------------------------------------------------------------
# Add a package to the import node
sub addPackage {
my $session = shift;
my $file = shift;
print "\tUpgrading package $file\n" unless $quiet;
# Make a storage location for the package
my $storage = WebGUI::Storage->createTemp( $session );
$storage->addFileFromFilesystem( $file );
# Import the package into the import node
my $package = eval {
my $node = WebGUI::Asset->getImportNode($session);
$node->importPackage( $storage, {
overwriteLatest => 1,
clearPackageFlag => 1,
setDefaultTemplate => 1,
} );
};
if ($package eq 'corrupt') {
die "Corrupt package found in $file. Stopping upgrade.\n";
}
if ($@ || !defined $package) {
die "Error during package import on $file: $@\nStopping upgrade\n.";
}
return;
}
#-------------------------------------------------
sub start {
my $configFile;
$|=1; #disable output buffering
GetOptions(
'configFile=s'=>\$configFile,
'quiet'=>\$quiet
);
my $session = WebGUI::Session->open($webguiRoot,$configFile);
$session->user({userId=>3});
my $versionTag = WebGUI::VersionTag->getWorking($session);
$versionTag->set({name=>"Upgrade to ".$toVersion});
return $session;
}
#-------------------------------------------------
sub finish {
my $session = shift;
updateTemplates($session);
my $versionTag = WebGUI::VersionTag->getWorking($session);
$versionTag->commit;
$session->db->write("insert into webguiVersion values (".$session->db->quote($toVersion).",'upgrade',".time().")");
$session->close();
}
#-------------------------------------------------
sub updateTemplates {
my $session = shift;
return undef unless (-d "packages-".$toVersion);
print "\tUpdating packages.\n" unless ($quiet);
opendir(DIR,"packages-".$toVersion);
my @files = readdir(DIR);
closedir(DIR);
my $newFolder = undef;
foreach my $file (@files) {
next unless ($file =~ /\.wgpkg$/);
# Fix the filename to include a path
$file = "packages-" . $toVersion . "/" . $file;
addPackage( $session, $file );
}
}
#vim:ft=perl

View file

@ -0,0 +1,123 @@
#!/usr/bin/env 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
#-------------------------------------------------------------------
our ($webguiRoot);
BEGIN {
$webguiRoot = "../..";
unshift (@INC, $webguiRoot."/lib");
}
use strict;
use Getopt::Long;
use WebGUI::Session;
use WebGUI::Storage;
use WebGUI::Asset;
my $toVersion = '7.9.4';
my $quiet; # this line required
my $session = start(); # this line required
# upgrade functions go here
finish($session); # this line required
#----------------------------------------------------------------------------
# Describe what our function does
#sub exampleFunction {
# my $session = shift;
# print "\tWe're doing some stuff here that you should know about... " unless $quiet;
# # and here's our code
# print "DONE!\n" unless $quiet;
#}
# -------------- DO NOT EDIT BELOW THIS LINE --------------------------------
#----------------------------------------------------------------------------
# Add a package to the import node
sub addPackage {
my $session = shift;
my $file = shift;
print "\tUpgrading package $file\n" unless $quiet;
# Make a storage location for the package
my $storage = WebGUI::Storage->createTemp( $session );
$storage->addFileFromFilesystem( $file );
# Import the package into the import node
my $package = eval {
my $node = WebGUI::Asset->getImportNode($session);
$node->importPackage( $storage, {
overwriteLatest => 1,
clearPackageFlag => 1,
setDefaultTemplate => 1,
} );
};
if ($package eq 'corrupt') {
die "Corrupt package found in $file. Stopping upgrade.\n";
}
if ($@ || !defined $package) {
die "Error during package import on $file: $@\nStopping upgrade\n.";
}
return;
}
#-------------------------------------------------
sub start {
my $configFile;
$|=1; #disable output buffering
GetOptions(
'configFile=s'=>\$configFile,
'quiet'=>\$quiet
);
my $session = WebGUI::Session->open($webguiRoot,$configFile);
$session->user({userId=>3});
my $versionTag = WebGUI::VersionTag->getWorking($session);
$versionTag->set({name=>"Upgrade to ".$toVersion});
return $session;
}
#-------------------------------------------------
sub finish {
my $session = shift;
updateTemplates($session);
my $versionTag = WebGUI::VersionTag->getWorking($session);
$versionTag->commit;
$session->db->write("insert into webguiVersion values (".$session->db->quote($toVersion).",'upgrade',".time().")");
$session->close();
}
#-------------------------------------------------
sub updateTemplates {
my $session = shift;
return undef unless (-d "packages-".$toVersion);
print "\tUpdating packages.\n" unless ($quiet);
opendir(DIR,"packages-".$toVersion);
my @files = readdir(DIR);
closedir(DIR);
my $newFolder = undef;
foreach my $file (@files) {
next unless ($file =~ /\.wgpkg$/);
# Fix the filename to include a path
$file = "packages-" . $toVersion . "/" . $file;
addPackage( $session, $file );
}
}
#vim:ft=perl

View file

@ -367,6 +367,29 @@ override processPropertiesFromFormPost => sub {
return undef;
};
#----------------------------------------------------------------------------
=head2 rotate ( angle )
Rotate the photo clockwise by the specified C<angle> (in degrees) including the
thumbnail and all resolutions.
=cut
sub rotate {
my $self = shift;
my $angle = shift;
my $storage = $self->getStorageLocation;
# Rotate all files in the storage
foreach my $file (@{$storage->getFiles}) {
$storage->rotate($file, $angle);
}
# Re-create thumbnail
$self->generateThumbnail;
}
#----------------------------------------------------------------------------
=head2 setFile ( filename )

View file

@ -54,10 +54,10 @@ property address2 => (
property city => (
tab => "properties",
fieldType => "text",
label => ["city label", 'Asset_MapPoint'],
hoverHelp => ["city description", 'Asset_MapPoint'],
);
property state => (
label => $i18n->get("city label"),
hoverHelp => $i18n->get("city description"),
},
property region => {
tab => "properties",
fieldType => "text",
label => ["state label", 'Asset_MapPoint'],
@ -276,6 +276,8 @@ sub getTemplateVarsEditForm {
my $definition = __PACKAGE__->definition($session)->[0]->{properties};
for my $key ( keys %{$definition} ) {
next if $definition->{$key}->{noFormPost};
next if $key eq 'latitude'
|| $key eq 'longitude';
$definition->{$key}->{name} = $key;
$definition->{$key}->{value} = $self->$key;
$var->{ "form_$key" }

View file

@ -51,6 +51,7 @@ use JSON qw();
use WebGUI::International;
use WebGUI::HTML;
use WebGUI::ProgressBar;
use WebGUI::Storage;
use Archive::Any;
@ -931,6 +932,7 @@ sub www_addArchive {
$var->{ form_start }
= WebGUI::Form::formHeader( $session, {
action => $self->getUrl('func=addArchiveSave'),
name => 'name="galleryAlbumAddArchive"',
});
$var->{ form_end }
= WebGUI::Form::formFooter( $session );
@ -1362,6 +1364,43 @@ sub www_edit {
$session->errorHandler->error("Couldn't demote asset '$assetId' because we couldn't instantiate it.");
}
}
# Rotate to the left
elsif ( grep { $_ =~ /^rotateLeft-(.{22})$/ } $form->param ) {
my $assetId = ( grep { $_ =~ /^rotateLeft-(.{22})$/ } $form->param )[0];
$assetId =~ s/^rotateLeft-//;
my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId );
if ( $asset ) {
# Add revision and create a new version tag by doing so
my $newRevision = $asset->addRevision;
# Rotate photo (i.e. all attached image files) by 90° CCW
$newRevision->rotate(-90);
# Auto-commit version tag
$newRevision->requestAutoCommit;
}
else {
$session->log->error("Couldn't rotate asset '$assetId' because we couldn't instantiate it.");
}
}
# Rotate to the right
elsif ( grep { $_ =~ /^rotateRight-(.{22})$/ } $form->param ) {
my $assetId = ( grep { $_ =~ /^rotateRight-(.{22})$/ } $form->param )[0];
$assetId =~ s/^rotateRight-//;
my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId );
if ( $asset ) {
# Add revision and create a new version tag by doing so
my $newRevision = $asset->addRevision;
# Rotate photo (i.e. all attached image files) by 90° CW
$newRevision->rotate(90);
# Auto-commit version tag
$newRevision->requestAutoCommit;
}
else {
$session->log->error("Couldn't rotate asset '$assetId' because we couldn't instantiate it.");
}
}
# Delete the file
elsif ( grep { $_ =~ /^delete-(.{22})$/ } $form->param ) {
my $assetId = ( grep { $_ =~ /^delete-(.{22})$/ } $form->param )[0];
$assetId =~ s/^delete-//;
@ -1381,6 +1420,7 @@ sub www_edit {
$var->{ form_start }
= WebGUI::Form::formHeader( $session, {
action => $self->getParent->getUrl('func=editSave;assetId=new;class='.__PACKAGE__),
extras => 'name="galleryAlbumAdd"',
})
. WebGUI::Form::hidden( $session, {
name => "ownerUserId",
@ -1399,6 +1439,7 @@ sub www_edit {
$var->{ form_start }
= WebGUI::Form::formHeader( $session, {
action => $self->getUrl('func=edit'),
extras => 'name="galleryAlbumEdit"',
})
. WebGUI::Form::hidden( $session, {
name => "ownerUserId",
@ -1460,23 +1501,44 @@ sub www_edit {
id => "assetIdThumbnail_$file->{ assetId }",
} );
# Raw HTML here to provide proper value for the image
my $promoteLabel = $i18n->get( 'Move Up', 'Icon' );
$file->{ form_promote }
= qq{<input type="submit" name="promote-$file->{assetId}" class="promote" value="$promoteLabel" />}
;
= WebGUI::Form::submit( $session, {
name => "promote-$file->{assetId}",
value => $i18n->get( 'Move Up', 'Icon' ),
class => "promote",
});
my $demoteLabel = $i18n->get( 'Move Down', 'Icon' );
$file->{ form_demote }
= qq{<input type="submit" name="demote-$file->{assetId}" class="demote" value="$demoteLabel" />}
;
= WebGUI::Form::submit( $session, {
name => "demote-$file->{assetId}",
value => $i18n->get( 'Move Down', 'Icon' ),
class => "demote",
});
my $deleteConfirm = $i18n->get( 'template delete message', 'Asset_Photo' );
my $deleteLabel = $i18n->get( 'Delete', 'Icon' );
$file->{ form_delete }
= qq{<input type="submit" name="delete-$file->{assetId}" class="delete" value="$deleteLabel" }
. qq{ onclick="return confirm('$deleteConfirm')" />}
;
= WebGUI::Form::submit( $session, {
name => "delete-$file->{assetId}",
value => $i18n->get( 'Delete', 'Icon' ),
class => "delete",
extras => "onclick=\"return confirm('$deleteConfirm')\"",
});
$file->{ form_rotateLeft }
= WebGUI::Form::submit( $session, {
name => "rotateLeft-$file->{assetId}",
value => $i18n->get( 'rotate left' ),
class => "rotateLeft",
});
$file->{ form_rotateRight }
= WebGUI::Form::submit( $session, {
name => "rotateRight-$file->{assetId}",
value => $i18n->get( 'rotate right' ),
class => "rotateRight",
});
$file->{ form_synopsis }
= WebGUI::Form::HTMLArea( $session, {

View file

@ -188,6 +188,8 @@ use WebGUI::International;
use HTML::Parser;
use URI::Escape;
use WebGUI::Utility qw/isIn/;
use WebGUI::Form;
use Clone qw/clone/;
#-------------------------------------------------------------------
@ -209,12 +211,29 @@ sub appendFeaturedPageVars {
#-------------------------------------------------------------------
=head2 appendKeywordPageVars ( var )
Append the template variables to C<var> for keyword (catagory) pages.
=cut
sub appendKeywordPageVars {
my ( $self, $var ) = @_;
my $session = $self->session;
my $topKeywords = $self->getTopLevelKeywordsList;
my $keywordHierarchy = $self->getKeywordHierarchy( $topKeywords, );
$var->{keywords_loop} = $self->getKeywordVariables( $keywordHierarchy );
return $var;
}
#-------------------------------------------------------------------
=head2 appendMostPopular ($var, [ $limit ])
=head3 $var
A hash reference of template variables. An array reference containing the most popular wiki pages
in order of popularity.
in order of popularity will be appended to it.
=head3 $limit
@ -441,6 +460,180 @@ sub canEditPages {
return $self->session->user->isInGroup($self->groupToEditPages) || $self->canAdminister;
}
#-------------------------------------------------------------------
sub definition {
my $class = shift;
my $session = shift;
my $definition = shift;
my $i18n = WebGUI::International->new($session, 'Asset_WikiMaster');
my %properties;
tie %properties, 'Tie::IxHash';
%properties =
(
groupToEditPages => { fieldType => 'group',
defaultValue => ['2'],
tab => 'security',
hoverHelp => $i18n->get('groupToEditPages hoverHelp'),
label => $i18n->get('groupToEditPages label') },
groupToAdminister => { fieldType => 'group',
defaultValue => ['3'],
tab => 'security',
hoverHelp => $i18n->get('groupToAdminister hoverHelp'),
label => $i18n->get('groupToAdminister label') },
richEditor => { fieldType => 'selectRichEditor',
defaultValue => 'PBrichedit000000000001',
tab => 'display',
hoverHelp => $i18n->get('richEditor hoverHelp'),
label => $i18n->get('richEditor label') },
frontPageTemplateId => { fieldType => 'template',
namespace => 'WikiMaster_front',
defaultValue => 'WikiFrontTmpl000000001',
tab => 'display',
hoverHelp => $i18n->get('frontPageTemplateId hoverHelp'),
label => $i18n->get('frontPageTemplateId label') },
pageTemplateId => { fieldType => 'template',
namespace => 'WikiPage',
defaultValue => 'WikiPageTmpl0000000001',
tab => 'display',
hoverHelp => $i18n->get('pageTemplateId hoverHelp'),
label => $i18n->get('pageTemplateId label') },
pageHistoryTemplateId => { fieldType => 'template',
namespace => 'WikiPage_pageHistory',
defaultValue => 'WikiPHTmpl000000000001',
tab => 'display',
hoverHelp => $i18n->get('pageHistoryTemplateId hoverHelp'),
label => $i18n->get('pageHistoryTemplateId label') },
mostPopularTemplateId => { fieldType => 'template',
namespace => 'WikiMaster_mostPopular',
defaultValue => 'WikiMPTmpl000000000001',
tab => 'display',
hoverHelp => $i18n->get('mostPopularTemplateId hoverHelp'),
label => $i18n->get('mostPopularTemplateId label') },
recentChangesTemplateId => { fieldType => 'template',
namespace => 'WikiMaster_recentChanges',
defaultValue => 'WikiRCTmpl000000000001',
tab => 'display',
hoverHelp => $i18n->get('recentChangesTemplateId hoverHelp'),
label => $i18n->get('recentChangesTemplateId label') },
byKeywordTemplateId => { fieldType => 'template',
namespace => 'WikiMaster_byKeyword',
defaultValue => 'WikiKeyword00000000001',
tab => 'display',
hoverHelp => $i18n->get('byKeywordTemplateId hoverHelp'),
label => $i18n->get('byKeywordTemplateId label') },
searchTemplateId => { fieldType => 'template',
namespace => 'WikiMaster_search',
defaultValue => 'WikiSearchTmpl00000001',
tab => 'display',
hoverHelp => $i18n->get('searchTemplateId hoverHelp'),
label => $i18n->get('searchTemplateId label') },
pageEditTemplateId => { fieldType => 'template',
namespace => 'WikiPage_edit',
defaultValue => 'WikiPageEditTmpl000001',
tab => 'display',
hoverHelp => $i18n->get('pageEditTemplateId hoverHelp'),
label => $i18n->get('pageEditTemplateId label') },
recentChangesCount => { fieldType => 'integer',
defaultValue => 50,
tab => 'display',
hoverHelp => $i18n->get('recentChangesCount hoverHelp'),
label => $i18n->get('recentChangesCount label') },
recentChangesCountFront => { fieldType => 'integer',
defaultValue => 10,
tab => 'display',
hoverHelp => $i18n->get('recentChangesCountFront hoverHelp'),
label => $i18n->get('recentChangesCountFront label') },
mostPopularCount => { fieldType => 'integer',
defaultValue => 50,
tab => 'display',
hoverHelp => $i18n->get('mostPopularCount hoverHelp'),
label => $i18n->get('mostPopularCount label') },
mostPopularCountFront => { fieldType => 'integer',
defaultValue => 10,
tab => 'display',
hoverHelp => $i18n->get('mostPopularCountFront hoverHelp'),
label => $i18n->get('mostPopularCountFront label') },
approvalWorkflow =>{
fieldType=>"workflow",
defaultValue=>"pbworkflow000000000003",
type=>'WebGUI::VersionTag',
tab=>'security',
label=>$i18n->get('approval workflow'),
hoverHelp=>$i18n->get('approval workflow description'),
},
thumbnailSize => {
fieldType => "integer",
defaultValue => 0,
tab => "display",
label => $i18n->get("thumbnail size"),
hoverHelp => $i18n->get("thumbnail size help")
},
maxImageSize => {
fieldType => "integer",
defaultValue => 0,
tab => "display",
label => $i18n->get("max image size"),
hoverHelp => $i18n->get("max image size help")
},
allowAttachments => {
fieldType => "integer",
defaultValue => 0,
tab => "security",
label => $i18n->get("allow attachments"),
hoverHelp => $i18n->get("allow attachments help"),
},
useContentFilter =>{
fieldType=>"yesNo",
defaultValue=>1,
tab=>'display',
label=>$i18n->get('content filter'),
hoverHelp=>$i18n->get('content filter description'),
},
filterCode =>{
fieldType=>"filterContent",
defaultValue=>'javascript',
tab=>'security',
label=>$i18n->get('filter code'),
hoverHelp=>$i18n->get('filter code description'),
},
topLevelKeywords =>{
fieldType => "keywords",
defaultValue => '',
tab => 'properties',
label => $i18n->get('top level keywords'),
hoverHelp => $i18n->get('top level keywords description'),
},
);
push @$definition,
{
assetName => $i18n->get('assetName'),
icon => 'wikiMaster.gif',
autoGenerateForms => 1,
tableName => 'WikiMaster',
className => 'WebGUI::Asset::Wobject::WikiMaster',
properties => \%properties,
};
return $class->next::method($session, $definition);
>>>>>>> 808a866c8b2a426e4958d38c34e8753a8555fc90
}
#-------------------------------------------------------------------
=head2 getFeaturedPageIds ( )
@ -462,6 +655,108 @@ sub getFeaturedPageIds {
#-------------------------------------------------------------------
=head2 getKeywordHierarchy ( $keywords, $seen )
Starting with the top level keywords, return the hierarchy of keywords as a recursive arrayref of hashrefs.
The traversal is left-most, depth first.
The hierarchy data structure that looks like this:
[
{
title => 'title', # same as the keyword, since this is a keyword (category) page
url => 'url', # url from the keyword page, via getUrl so it contains the gateway URL
# If a keyword page does not exist for the keyword, this key/value pair will not be present.
children => [ # Array reference of sub-categories referenced by this category
{ # If there are no children, this key/value pair will not be present
...
}
]
}
]
=head3 $keywords
An array reference of keywords. If this is blank, then it will use the top level keywords from
itself as a default.
=head3 $seen
A hash reference that keeps track of which keywords have already been seen. This prevents
infinite loops from happening during the traversal.
=cut
sub getKeywordHierarchy {
my ( $self, $keywords, $seen ) = @_;
my $session = $self->session;
my $hierarchy = [];
$keywords ||= $self->getTopLevelKeywordsList;
$seen ||= {};
KEYWORD: foreach my $keyword (sort @{ $keywords }) {
my $page = $self->getLineage(['children'], {
returnObjects => 1,
whereClause => 'assetData.title = '.$session->db->quote($keyword),
limit => 1,
includeOnlyClasses => [qw/WebGUI::Asset::WikiPage/],
})->[0];
if (! $page) {
push @{ $hierarchy }, { title => $keyword, url => '', };
next KEYWORD;
}
my $datum = {
title => $keyword, ##Note, same as keyword
url => $page->getUrl,
};
##Prevent recursion if seen again
if (! $seen->{$keyword}++) {
my $children = $self->getKeywordHierarchy(WebGUI::Keyword::string2list($page->get('keywords')), $seen, );
if (@{ $children } ) {
$datum->{children} = $children;
}
}
push @{ $hierarchy }, $datum;
}
return $hierarchy;
}
#-------------------------------------------------------------------
=head2 getKeywordVariables ( $hierarchy, $level )
Take a data structure representing a hierarchy of keywords, and append template variables
to them similar to a Navigation so you can build useful things with them.
=head3 $hierarchy
A data structure similar to that produced by getKeywordHierarchy
=head3 $level
The current level in any part of the hierarchy.
=cut
sub getKeywordVariables {
my ( $self, $hierarchy, $level ) = @_;
$level ||= 0;
my $variables = [];
KEYWORD: foreach my $member (@{ $hierarchy }) {
my $varBlock = clone $member;
$varBlock->{level} = $level;
$varBlock->{indent_loop} = [ map { { indent => $_ } } 1..$level ];
delete $varBlock->{children};
push @{$variables}, $varBlock;
if ( exists $member->{children} ) {
push @{$variables}, @{ $self->getKeywordVariables($member->{children}, $level+1) };
}
}
return $variables;
}
#-------------------------------------------------------------------
=head2 getRssFeedItems ()
Returns an array reference of hash references. Each hash reference has a title,
@ -521,6 +816,19 @@ sub getTemplateVars {
return $var;
}
#----------------------------------------------------------------------------
=head2 getTopLevelKeywordsList ( )
Return the top level keywords as an array reference.
=cut
sub getTopLevelKeywordsList {
my ( $self ) = @_;
return WebGUI::Keyword::string2list($self->get('topLevelKeywords'));
}
#-------------------------------------------------------------------
=head2 prepareView
@ -611,6 +919,7 @@ sub view {
$self->appendSearchBoxVars($var);
$self->appendRecentChanges($var, $self->recentChangesCountFront);
$self->appendMostPopular($var, $self->mostPopularCountFront);
$self->appendKeywordPageVars($var);
return $self->processTemplate($var, undef, $template);
}

View file

@ -100,9 +100,12 @@ sub duplicate {
my $newAsset
= $parent->addChild( $self->get, undef, $self->get("revisionDate"), { skipAutoCommitWorkflows => $options->{skipAutoCommitWorkflows} } );
$session->log->error(
sprintf "Unable to add child %s (%s) to %s (%s)", $self->getTitle, $self->getId, $parent->getTitle, $parent->getId
);
if (! $newAsset) {
$self->session->log->error(
sprintf "Unable to add child %s (%s) to %s (%s)", $self->getTitle, $self->getId, $parent->getTitle, $parent->getId
);
return undef;
}
# Duplicate metadata fields
my $sth = $session->db->read(
"select * from metaData_values where assetId = ?",

View file

@ -397,7 +397,7 @@ sub deactivateAccount {
$var{'yes.label'} = $i18n->get(44);
$var{'no.url'} = $self->session->url->page();
$var{'no.label'} = $i18n->get(45);
return WebGUI::Asset::Template->newById($self->session,$self->get('getDeactivateAccountTemplateId'))->process(\%var);
return WebGUI::Asset::Template->new($self->session,$self->getDeactivateAccountTemplateId)->process(\%var);
}
#-------------------------------------------------------------------

View file

@ -331,6 +331,14 @@ our $HELP = {
name => 'form_demote',
description => 'helpvar form_demote',
},
{
name => 'form_rotateLeft',
description => 'helpvar form_rotateLeft',
},
{
name => 'form_rotateRight',
description => 'helpvar form_rotateRight',
},
{
name => 'form_synopsis',
description => 'helpvar form_synopsis',

View file

@ -0,0 +1,69 @@
package WebGUI::Help::Asset_MapPoint;
use strict;
our $HELP = {
'edit template' => {
title => 'edit template',
body => '',
isa => [
{ namespace => 'Asset_Template',
tag => 'template variables'
},
],
fields => [],
variables => [
{ name => 'form_header', required => 1, },
{ name => 'form_footer', required => 1, },
{ name => 'form_submit', },
{ name => 'form_title', },
{ name => 'form_synopsis', },
{ name => 'form_storageIdPhoto', },
{ name => 'currentPhoto', },
{ name => 'form_website', },
{ name => 'form_address1', },
{ name => 'form_address2', },
{ name => 'form_address3', },
{ name => 'form_city', },
{ name => 'form_region', },
{ name => 'form_zipCode', },
{ name => 'form_country', },
{ name => 'form_phone', },
{ name => 'form_fax', },
{ name => 'form_email', },
],
related => []
},
'map point asset template variables' => {
private => 1,
title => 'map point asset template variables',
body => '',
isa => [
{ namespace => 'Asset',
tag => 'asset template asset variables'
},
],
fields => [],
variables => [
{ name => 'latitude', },
{ name => 'longitude', },
{ name => 'storageIdPhoto', },
{ name => 'website', },
{ name => 'address1', },
{ name => 'address2', },
{ name => 'address3', },
{ name => 'city', },
{ name => 'region', },
{ name => 'zipCode', },
{ name => 'country', },
{ name => 'phone', },
{ name => 'fax', },
{ name => 'email', },
],
related => []
},
};
1;

View file

@ -102,6 +102,26 @@ our $HELP = {
{ 'name' => 'recentChangesLabel variable', },
{ 'name' => 'addPageUrl', },
{ 'name' => 'addPageLabel', },
{ 'name' => 'keywords_loop',
'variables' => [
{ 'name' => 'title',
'description' => 'keyword title',
},
{ 'name' => 'url',
'description' => 'keyword url',
},
{ 'name' => 'level',
'description' => 'keyword level',
},
{ 'name' => 'indent_loop',
'variables' => [
{ 'name' => 'indent',
'description' => 'keyword indent',
},
],
},
],
},
],
fields => [],
related => [],

View file

@ -306,9 +306,13 @@ sub www_runCronJob {
}
# Run the instance
$instance->start( 1 );
$task->delete( 1 ) if ( $task->get("runOnce") );
return "done";
my $error = $instance->start( 1 );
if ($error) {
$task->delete(1);
return "error";
}
$task->delete( 1 ) if ( $task->get("runOnce") );
return "done";
}
$session->errorHandler->warn("No task ID passed to cron job runner.");
return "error";

View file

@ -23,6 +23,18 @@ our $I18N = {
context => "Label for Save button",
},
'rotate left' => {
message => "90&deg; CCW",
lastUpdated => 1270582436,
context => "Label for rotate left button",
},
'rotate right' => {
message => "90&deg; CW",
lastUpdated => 1270582436,
context => "Label for rotate right button",
},
'save message' => {
message => 'Album settings saved.',
lastUpdated => 0,
@ -38,12 +50,11 @@ our $I18N = {
lastUpdated => 0,
},
'delete message' => {
message => 'Album has been deleted. <a href="%s">Return to Gallery</a>',
lastUpdated => 0,
},
'help common title' => {
message => 'Gallery Album Variables (Common)',
lastUpdated => 0,
@ -524,6 +535,18 @@ our $I18N = {
lastUpdated => 1213631346,
context => q{Description of template variable},
},
'helpvar form_rotateLeft' => {
message => q{A button to rotate the photo by 90&deg; counter clockwise.},
lastUpdated => 1270582436,
context => q{Description of template variable},
},
'helpvar form_rotateRight' => {
message => q{A button to rotate the photo by 90&deg; clockwise.},
lastUpdated => 1270582436,
context => q{Description of template variable},
},
'helpvar form_delete' => {
message => q{A button to delete the image.},

View file

@ -133,11 +133,217 @@ our $I18N = {
lastUpdated => 0,
context => 'Description of asset property',
},
'assetName' => {
message => "MapPoint",
lastUpdated => 0,
context => "Name of this asset",
},
'edit template' => {
message => "MapPoint Edit Point Template",
lastUpdated => 0,
context => "template variable section title",
},
'form_header' => {
message => "HTML code to start the edit form.",
lastUpdated => 0,
context => "template variable help",
},
'form_footer' => {
message => "HTML code to end the edit form.",
lastUpdated => 0,
context => "template variable help",
},
'form_submit' => {
message => "A button to submit the edit form.",
lastUpdated => 0,
context => "template variable help",
},
'form_title' => {
message => "A text form element for entering the title.",
lastUpdated => 0,
context => "template variable help",
},
'form_synopsis' => {
message => "A textarea form element for entering the synopsis.",
lastUpdated => 0,
context => "template variable help",
},
'form_storageIdPhoto' => {
message => "A file form element for uploading a photo relating to the map point.",
lastUpdated => 0,
context => "template variable help",
},
'currentPhoto' => {
message => "An image tag linking to any currently uploaded photo.",
lastUpdated => 0,
context => "template variable help",
},
'form_website' => {
message => "A text field for entering in a URL related to the map point.",
lastUpdated => 0,
context => "template variable help",
},
'form_address1' => {
message => "A text field for entering in one part of an address.",
lastUpdated => 0,
context => "template variable help",
},
'form_address2' => {
message => "A text field for entering in another part of an address.",
lastUpdated => 0,
context => "template variable help",
},
'form_address3' => {
message => "A text field for entering in the last past of an address.",
lastUpdated => 0,
context => "template variable help",
},
'form_city' => {
message => "A text field for entering in city part of the address.",
lastUpdated => 0,
context => "template variable help",
},
'form_region' => {
message => "A text field for entering in region, or state, part of the address.",
lastUpdated => 0,
context => "template variable help",
},
'form_zipCode' => {
message => "A text field for entering in the zip code part of the address.",
lastUpdated => 0,
context => "template variable help",
},
'form_country' => {
message => "A text field for entering in the country part of the address.",
lastUpdated => 0,
context => "template variable help",
},
'form_phone' => {
message => "A text field for entering in a phone number.",
lastUpdated => 0,
context => "template variable help",
},
'form_fax' => {
message => "A text field for entering in a phone number.",
lastUpdated => 0,
context => "template variable help",
},
'form_email' => {
message => "A text field for entering in an email address.",
lastUpdated => 0,
context => "template variable help",
},
'storageIdPhoto' => {
message => "The storage location for this MapPoint.",
lastUpdated => 0,
context => "template variable help",
},
'website' => {
message => "The website for this MapPoint.",
lastUpdated => 0,
context => "template variable help",
},
'address1' => {
message => "The first line of the address.",
lastUpdated => 0,
context => "template variable help",
},
'address2' => {
message => "The second line of the address.",
lastUpdated => 0,
context => "template variable help",
},
'address3' => {
message => "The third line of the address.",
lastUpdated => 0,
context => "template variable help",
},
'city' => {
message => "The city for this MapPoint.",
lastUpdated => 0,
context => "template variable help",
},
'region' => {
message => "The region, or state or province, for this MapPoint.",
lastUpdated => 0,
context => "template variable help",
},
'zipCode' => {
message => "The zip code for this MapPoint.",
lastUpdated => 0,
context => "template variable help",
},
'country' => {
message => "The country for this MapPoint.",
lastUpdated => 0,
context => "template variable help",
},
'phone' => {
message => "The phone number for this MapPoint.",
lastUpdated => 0,
context => "template variable help",
},
'fax' => {
message => "The fax number for this MapPoint.",
lastUpdated => 0,
context => "template variable help",
},
'email' => {
message => "The email address for this MapPoint.",
lastUpdated => 0,
context => "template variable help",
},
'map point asset template variables' => {
message => "Map Point Asset Template Variables",
lastUpdated => 0,
context => "template variable help",
},
'latitude' => {
message => "The latitude of the MapPoint",
lastUpdated => 0,
context => "template variable help",
},
'longitude' => {
message => "The longitude of the MapPoint",
lastUpdated => 0,
context => "template variable help",
},
};
1;

View file

@ -42,6 +42,18 @@ our $I18N = {
context => q|Hover help for edit wobject screen|,
},
'top level keywords' => {
message => q|Top Level Keywords|,
lastUpdated => 0,
context => q|Label for edit wobject screen|,
},
'top level keywords description' => {
message => q|These keywords provide the root for the hierarchial keyword display.|,
lastUpdated => 0,
context => q|Hover help for edit wobject screen|,
},
'content filter' => {
message => q|Use Content Filter?|,
lastUpdated => 0,
@ -523,6 +535,43 @@ listing of pages that are related to a specific keyword?| },
lastUpdated => 0,
context => q{Label for link to unsubscribe from e-mail notifications},
},
'keywords_loop' => {
message => q{A loop containing all the top level keywords, links to their keyword pages, and all sub pages below them.},
lastUpdated => 0,
context => q{Help for template variable},
},
'keyword title' => {
message => q{The name of a keyword.},
lastUpdated => 0,
context => q{Help for template variable},
},
'keyword url' => {
message => q{The URL to the keyword page for that keyword. If no page exists, this variable will be empty.},
lastUpdated => 0,
context => q{Help for template variable},
},
'keyword level' => {
message => q{The depth of this keyword. Top-level keywords for the wiki are level 0.},
lastUpdated => 0,
context => q{Help for template variable},
},
'indent_loop' => {
message => q{A loop that runs 1 time for each level.},
lastUpdated => 0,
context => q{Help for template variable},
},
'keyword indent' => {
message => q{The loop iterator for the indent_loop.},
lastUpdated => 0,
context => q{Help for template variable},
},
};
1;

View file

@ -4680,6 +4680,12 @@ Users may override this setting in their profile.
context => 'Message shown to the user when data is being loaded, typically via AJAX, like in the Survey.'
},
'Go' => {
message => 'Go',
lastUpdated => 0,
context => 'Label for buttons that take you someplace else'
},
};
1;

View file

@ -104,7 +104,7 @@ installClass.pl -- Run class install methods
=head1 SYNOPSIS
installAsset.pl [--remove|--check|--upgrade] <class> --configFile=<configFile>
installClass.pl [--remove|--check|--upgrade] <class> --configFile=<configFile>
=head1 DESCRIPTION
@ -118,7 +118,7 @@ If your class has not told you to use this script, then it probably won't work!
=item class
The class name of the class to install. Something like WebGUI::Asset::Yourasset
The class name of the asset to install. Something like WebGUI::Asset::Yourasset
=back

View file

@ -448,11 +448,24 @@ is($fixTitleAsset->getUiLevel, 8, 'getUiLevel: Snippet has a configured uiLevel
################################################################
#
# isValidRssItem
# assetExists
#
################################################################
#is($canViewAsset->isValidRssItem, 1, 'isValidRssItem: By default, all Assets are valid RSS items');
{
my $id = $canViewAsset->getId;
my $class = 'WebGUI::Asset';
my $date = $canViewAsset->get('revisionDate');
ok ( WebGUI::Asset->assetExists($session, $id, $class, $date), 'assetExists with proper class, id and revisionDate');
ok (!WebGUI::Asset->assetExists($session, $id, 'WebGUI::Asset::Snippet', $date), 'assetExists with wrong class does not exist');
my $id2 = $id;
++$id2;
ok (!WebGUI::Asset->assetExists($session, $id2, $class, $date), 'assetExists with wrong id does not exist');
ok (!WebGUI::Asset->assetExists($session, $id, $class, $date+1), 'assetExists with wrong revisionDate does not exist');
}
################################################################
#

View file

@ -0,0 +1,109 @@
#-------------------------------------------------------------------
# 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
#-------------------------------------------------------------------
use FindBin;
use strict;
use lib "$FindBin::Bin/../../../../lib";
# The goal of this test is to confirm correct rotation of all files attached
# to a Photo asset after calling the rotate method.
# We will only do a quick check by comparing dimensions of all attached files
# after rotation. Checks on individual pixels are alreay done in testing code
# for WebGUI::Storage
use WebGUI::Test;
use WebGUI::Session;
use Test::More;
use Test::Deep;
#----------------------------------------------------------------------------
# Init
my $session = WebGUI::Test->session;
my $node = WebGUI::Asset->getImportNode($session);
my $versionTag = WebGUI::VersionTag->getWorking($session);
# Name version tag and make sure it gets cleaned up
$versionTag->set({name=>"Photo rotation test"});
addToCleanup($versionTag);
# Create gallery and a single album
my $gallery
= $node->addChild({
className => "WebGUI::Asset::Wobject::Gallery",
imageResolutions => "1024x768",
},
undef,
undef,
{
skipAutoCommitWorkflows => 1,
});
my $album
= $gallery->addChild({
className => "WebGUI::Asset::Wobject::GalleryAlbum",
},
undef,
undef,
{
skipAutoCommitWorkflows => 1,
});
# Create single photo inside the album
my $photo
= $album->addChild({
className => "WebGUI::Asset::File::GalleryFile::Photo",
},
undef,
undef,
{
skipAutoCommitWorkflows => 1,
});
# Attach image file to photo asset (setFile also makes download versions)
$photo->setFile( WebGUI::Test->getTestCollateralPath("rotation_test.png") );
my $storage = $photo->getStorageLocation;
# Commit all changes
$versionTag->commit;
#----------------------------------------------------------------------------
plan tests => 2;
#----------------------------------------------------------------------------
# Save dimensions of images
my @oldDims;
foreach my $file ( @{$storage->getFiles('showAll') } ) {
push ( @oldDims, [ $storage->getSizeInPixels($file) ] ) unless $file eq '.';
}
# Rotate photo (i.e. all attached images) by 90° CW
$photo->rotate(90);
# Save new dimensions of images in reverse order
my @newDims;
foreach my $file ( @{$storage->getFiles('showAll') } ) {
push ( @newDims, [ reverse($storage->getSizeInPixels($file)) ] ) unless $file eq '.';
}
# Compare dimensions
cmp_deeply( \@oldDims, \@newDims, "Check if all files were rotated by 90° CW" );
# Rotate photo (i.e. all attached images) by 90° CCW
$photo->rotate(-90);
# Save new dimensions of images in original order
my @newerDims;
foreach my $file ( @{$storage->getFiles('showAll') } ) {
push ( @newerDims, [ $storage->getSizeInPixels($file) ] ) unless $file eq '.';
}
# Compare dimensions
cmp_deeply( \@oldDims, \@newerDims, "Check if all files were rotated by 90° CCW" );

View file

@ -266,10 +266,6 @@ is(scalar @{ $windowCal->getLineage(['children'])}, 13, 'added events to the win
my @window = $windowCal->getEventsIn($startDt->toDatabase, $endDt->toDatabase);
#note $startDt->toDatabase;
#note join "\n", map { join ' ', $_->get('title'), $_->get('startDate'), $_->get('startTime')} @window;
#note $endDt->toDatabase;
cmp_bag(
[ map { $_->get('title') } @window ],
[ map { $_->get('title') }
@ -499,9 +495,6 @@ my $listCal = $node->addChild({
$allDayDt = $bday->cloneToUserTimeZone->truncate( to => 'day' );
my $prevDayDt = $bday->cloneToUserTimeZone->truncate( to => 'day' )->subtract(days => 1)->add(hours => 19);
note $allDayDt->toDatabase;
note $prevDayDt->toDatabase;
$allDay = $listCal->addChild({
className => 'WebGUI::Asset::Event',
title => 'An event with explicit times that lasts all day',

View file

@ -9,9 +9,10 @@
# http://www.plainblack.com info@plainblack.com
#------------------------------------------------------------------
# Test editing a GalleryAlbum from the web interface
#
#
# Test editing a GalleryAlbum from the web interface. Currently, it
# is tested whether...
# - users can add albums.
# - photos can be rotated.
use FindBin;
use strict;
@ -73,7 +74,7 @@ if ( !$mech->success ) {
plan skip_all => "Cannot load URL '$baseUrl'. Will not test.";
}
plan tests => 6; # Increment this number for each test you create
plan tests => 11; # Increment this number for each test you create
#----------------------------------------------------------------------------
# Visitor user cannot add albums
@ -112,6 +113,65 @@ $mech->content_contains(
my $album = WebGUI::Asset->newById( $session, $gallery->getAlbumIds->[0] );
cmp_deeply( $properties, subhashof( $album->get ), "Properties from edit form are set correctly" );
#----------------------------------------------------------------------------
# Photos can be rotated using the respective form buttons
# Use album from previous test
my $album = $gallery->getFirstChild;
# Add single photo to this album. No need to commit since auto-commit was
# enabled for the Gallery asset.
my $photo
= $album->addChild({
className => "WebGUI::Asset::File::GalleryFile::Photo",
});
my $photoId = $photo->getId;
# Attach image file to photo asset (setFile also makes download versions)
$photo->setFile( WebGUI::Test->getTestCollateralPath("rotation_test.png") );
my $storage = $photo->getStorageLocation;
# Save dimensions of images
my @oldDims;
foreach my $file ( @{$storage->getFiles('showAll') } ) {
push ( @oldDims, [ $storage->getSizeInPixels($file) ] ) unless $file eq '.';
}
# Rotate photo (i.e. all attached images) by 90° CW
$mech->get_ok( $baseUrl . $album->getUrl('func=edit'), 'Request GalleryAlbum edit screen' );
# Select the proper form
$mech->form_name( 'galleryAlbumEdit' );
# Try to click the "rotate right" button
$mech->submit_form_ok( {
button => 'rotateRight-' . $photoId,
}, 'Request rotation of photo by 90° CW' );
# Save new dimensions of images in reverse order
my @newDims;
foreach my $file ( @{$storage->getFiles('showAll') } ) {
push ( @newDims, [ reverse($storage->getSizeInPixels($file)) ] ) unless $file eq '.';
}
# Compare dimensions
cmp_deeply( \@oldDims, \@newDims, "Check if all files were rotated by 90° CW" );
# Rotate photo (i.e. all attached images) by 90° CCW. No need to request the edit view since
# an updated view was returned after the last form submittal.
$mech->form_name( 'galleryAlbumEdit' );
# Try to click the "rotate left" button
$mech->submit_form_ok( {
button => 'rotateLeft-' . $photoId,
}, 'Request rotation of photo by 90° CCW' );
# Save new dimensions of images in original order
my @newerDims;
foreach my $file ( @{$storage->getFiles('showAll') } ) {
push ( @newerDims, [ $storage->getSizeInPixels($file) ] ) unless $file eq '.';
}
# Compare dimensions
cmp_deeply( \@oldDims, \@newerDims, "Check if all files were rotated by 90° CCW" );
#----------------------------------------------------------------------------
# getMechLogin( baseUrl, WebGUI::User, "identifier" )
# Returns a Test::WWW::Mechanize session after logging in the given user using

View file

@ -411,12 +411,15 @@ $archive->update({storiesPerPage => 25});
$templateVars = $archive->viewTemplateVariables('search');
is($templateVars->{mode}, 'search', 'viewTemplateVariables mode == search');
use Data::Dumper;
diag Dumper $templateVars->{date_loop};
cmp_bag(
$templateVars->{date_loop},
[
{
epochDate => ignore(),
story_loop => [
story_loop => bag(
{
creationDate => ignore(),
url => ignore(),
@ -431,7 +434,7 @@ cmp_bag(
editIcon => ignore(),
deleteIcon => ignore(),
},
],
),
},
{
epochDate => $wgBdayMorn,

View file

@ -0,0 +1,250 @@
# 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
#------------------------------------------------------------------
# Test the featured page of the Wiki
#
#
use FindBin;
use strict;
use lib "$FindBin::Bin/../../lib";
use Test::More;
use Test::Differences;
use Test::Deep;
use Data::Dumper;
use WebGUI::Test; # Must use this before any other WebGUI modules
use WebGUI::Session;
#----------------------------------------------------------------------------
# Init
my $session = WebGUI::Test->session;
my $import = WebGUI::Asset->getImportNode( $session );
my @childCoda = (undef, undef, { skipAutoCommitWorkflows => 1, skipNotification => 1, } );
my @revCoda = (undef, { skipAutoCommitWorkflows => 1, skipNotification => 1, } );
my $wiki
= $import->addChild( {
className => 'WebGUI::Asset::Wobject::WikiMaster',
topLevelKeywords => 'criminals,inmates,staff',
url => 'testwiki',
title => 'testwiki',
}, @childCoda );
my $wikitag = WebGUI::VersionTag->getWorking( $session );
$wikitag->commit;
WebGUI::Test->addToCleanup($wikitag);
$wiki = $wiki->cloneFromDb;
my %page_set = ();
foreach my $keywords (qw/staff inmates criminals/) {
$page_set{$keywords} = $wiki->addChild({
className => 'WebGUI::Asset::WikiPage',
title => $keywords,
}, @childCoda);
}
my $tag_set1 = WebGUI::VersionTag->getWorking($session);
$tag_set1->commit;
WebGUI::Test->addToCleanup($tag_set1);
#----------------------------------------------------------------------------
# Tests
plan tests => 11; # Increment this number for each test you create
#----------------------------------------------------------------------------
#
is $wiki->get('topLevelKeywords'), 'criminals,inmates,staff', 'checking wiki setup';
cmp_deeply($wiki->getTopLevelKeywordsList, [qw/criminals inmates staff/], 'getTopLevelKeywordList returns keywords');
cmp_deeply(
$wiki->getKeywordHierarchy(),
[
superhashof({ title => 'criminals', }),
superhashof({ title => 'inmates', }),
superhashof({ title => 'staff', }),
],
"getKeywordHierarchy, simple setup",
);
my $hierarchy = $wiki->getKeywordHierarchy();
my $variables = $wiki->getKeywordVariables($hierarchy);
cmp_deeply(
$hierarchy->[0],
{
title => 'criminals',
url => '/testwiki/criminals',
},
"getKeywordVariables, does not alter the original hierarchy passed in",
);
cmp_deeply(
$variables,
[
{
title => 'criminals',
url => '/testwiki/criminals',
level => 0,
indent_loop => [],
},
{
title => 'inmates',
url => '/testwiki/inmates',
level => 0,
indent_loop => [],
},
{
title => 'staff',
url => '/testwiki/staff',
level => 0,
indent_loop => [],
},
],
"... variables",
);
$wiki->update({topLevelKeywords => 'criminals,criminals,inmates,staff'});
is $wiki->get('topLevelKeywords'), 'criminals,criminals,inmates,staff', 'checking wiki setup 2';
cmp_deeply($wiki->getTopLevelKeywordsList, [qw/criminals criminals inmates staff/], 'getTopLevelKeywordList returns keywords, even with duplicates');
cmp_deeply(
$wiki->getKeywordHierarchy(),
[
superhashof({ title => 'criminals', }),
superhashof({ title => 'criminals', }),
superhashof({ title => 'inmates', }),
superhashof({ title => 'staff', }),
],
"getKeywordHierarchy, simple setup, duplicates listed",
);
$wiki->update({topLevelKeywords => 'criminals,inmates,staff'});
$page_set{criminals}->update({keywords => 'red,andy'});
$page_set{inmates}->update({keywords => 'brooks,heywood'});
$page_set{staff}->update({keywords => 'norton,hadley'});
foreach my $title (qw/red andy brooks heywood norton hadley/) {
$page_set{$title} = $wiki->addChild({
className => 'WebGUI::Asset::WikiPage',
title => $title,
}, @childCoda);
}
my $tag_set2 = WebGUI::VersionTag->getWorking($session);
$tag_set2->commit;
WebGUI::Test->addToCleanup($tag_set2);
cmp_bag(
$wiki->getKeywordHierarchy(),
[
{
title => 'criminals', url => '/testwiki/criminals',
children => bag(
superhashof({ title => 'red', }),
superhashof({ title => 'andy', }),
),
},
{
title => 'inmates', url => '/testwiki/inmates',
children => bag(
superhashof({ title => 'heywood', }),
superhashof({ title => 'brooks', }),
),
},
{
title => 'staff', url => '/testwiki/staff',
children => bag(
superhashof({ title => 'norton', }),
superhashof({ title => 'hadley', }),
),
},
],
"getKeywordHierarchy: simple hierarchy",
);
##Check depth-first display, and try to make a keyword loop
$page_set{andy}->update({keywords => 'criminals,inmates'});
$page_set{brooks}->update({keywords => 'criminals'});
my $tag_set3 = WebGUI::VersionTag->getWorking($session);
$tag_set3->commit;
WebGUI::Test->addToCleanup($tag_set3);
cmp_bag(
$wiki->getKeywordHierarchy(),
[
superhashof({
title => 'criminals',
children => bag(
superhashof({
title => 'andy',
children => bag(
superhashof({
title => 'inmates',
children => bag(
superhashof({ title => 'heywood', }),
superhashof({
title => 'brooks',
children => bag(
superhashof({ title => 'criminals', }),
),
}),
),
}),
superhashof({ title => 'criminals', }),
),
}),
superhashof({ title => 'red', }),
),
}),
superhashof({
title => 'inmates',
}),
superhashof({
title => 'staff',
children => bag(
superhashof({ title => 'norton', }),
superhashof({ title => 'hadley', }),
),
}),
],
"getKeywordHierarchy: complex hierarcy, depth-first display and loop handling",
);
cmp_deeply(
$wiki->getKeywordVariables([
{
title => 'title 0', url => 'url 0',
children => [ {
title => 'title 1', url => 'url 1',
children => [ {
title => 'title 2', url => 'url 2',
}, ],
}, ],
},
]),
[
{ title => 'title 0', url => 'url 0', level => 0, indent_loop => [], },
{ title => 'title 1', url => 'url 1', level => 1, indent_loop => [{indent => 1}], },
{ title => 'title 2', url => 'url 2', level => 2, indent_loop => [{indent => 1,}, {indent => 2,},], },
],
'getKeywordVariables: checking deeply'
);
$page_set{criminals}->update({keywords => 'red,andy,tommy'});
#vim:ft=perl

View file

@ -65,7 +65,7 @@ my $extensionTests = [
},
];
plan tests => 49 + scalar @{ $extensionTests }; # increment this value for each test you create
plan tests => 54 + scalar @{ $extensionTests }; # increment this value for each test you create
my $session = WebGUI::Test->session;
@ -276,6 +276,40 @@ foreach my $testImage (@testImages) {
});
####################################################
#
# rotate
#
####################################################
my $rotateTest = WebGUI::Storage->create( $session );
WebGUI::Test->storagesToDelete($rotateTest);
# Add test image to the storage
ok( $rotateTest->addFileFromFilesystem(WebGUI::Test->getTestCollateralPath("rotation_test.png")), "Can add test image to storage" );
# Rotate test image by 90° CW
my $file = $rotateTest->getFiles->[0];
$rotateTest->rotate($file, 90);
# Check dimensions
cmp_bag( [$rotateTest->getSizeInPixels( $file )], [2,3], "Check size of photo after rotating 90° CW" );
# Check pixels
my $image = Image::Magick->new;
$image->Read( $rotateTest->getPath($file) );
is( $image->GetPixel(x=>2, y=>0), 0, "Pixel at location [2,0] should be black" );
# Rotate test image by 90° CCW
my $file = $rotateTest->getFiles->[0];
$rotateTest->rotate($file, -90);
# Check dimensions
cmp_bag( [$rotateTest->getSizeInPixels( $file )], [3,2], "Check size of photo after rotating 90° CCW" );
# Check pixels
$image = Image::Magick->new;
$image->Read( $rotateTest->getPath($file) );
is( $image->GetPixel(x=>0, y=>0), 0, "Pixel at location [0,0] should be black" );
TODO: {
local $TODO = "Methods that need to be tested";
ok(0, 'resize');

Binary file not shown.

After

Width:  |  Height:  |  Size: 189 B