Merge commit '41575d24bb' into webgui8. Some tests still failing.

Conflicts:
	docs/gotcha.txt
	lib/WebGUI.pm
	lib/WebGUI/Asset.pm
	lib/WebGUI/Asset/File/GalleryFile/Photo.pm
	lib/WebGUI/Asset/Post.pm
	lib/WebGUI/Asset/Template.pm
	lib/WebGUI/Asset/WikiPage.pm
	lib/WebGUI/Asset/Wobject/WikiMaster.pm
	lib/WebGUI/Cache.pm
	lib/WebGUI/Content/Setup.pm
	lib/WebGUI/Role/Asset/Subscribable.pm
	lib/WebGUI/Shop/Cart.pm
	lib/WebGUI/Shop/Pay.pm
	lib/WebGUI/Shop/PayDriver/ITransact.pm
	sbin/testEnvironment.pl
	t/Asset/WikiPage.t
	t/Shop/PayDriver.t
	t/Shop/PayDriver/ITransact.t
	t/Shop/PayDriver/Ogone.t
	t/Shop/TaxDriver/EU.t
	t/Shop/TaxDriver/Generic.t
	t/Workflow/Activity/RemoveOldCarts.t
	t/lib/WebGUI/Test.pm
This commit is contained in:
Colin Kuskie 2010-06-25 23:25:26 -07:00
commit 5febc0ebbc
258 changed files with 5528 additions and 2230 deletions

View file

@ -96,6 +96,10 @@ override applyConstraints => sub {
my $storage = $self->getStorageLocation;
my $file = $self->filename;
# Adjust orientation based on exif data. Do this before we start to
# generate resolutions so that all images have the correct orientation.
$self->adjustOrientation;
# Make resolutions before fixing image, so that we can get higher quality
# resolutions
$self->makeResolutions;
@ -110,6 +114,60 @@ override applyConstraints => sub {
super();
};
#----------------------------------------------------------------------------
=head2 adjustOrientation ( )
Read orientation information from EXIF data and rotate image if required.
EXIF data is updated to reflect the new orientation of the image.
=cut
sub adjustOrientation {
my $self = shift;
my $storage = $self->getStorageLocation;
# Extract orientation information from EXIF data
my $exifTool = Image::ExifTool->new;
$exifTool->ExtractInfo( $storage->getPath( $self->get('filename') ) );
my $orientation = $exifTool->GetValue('Orientation', 'ValueConv');
# Check whether orientation information is present and transform image if
# required. At the moment we handle only images that need to be rotated by
# (-)90 or 180 deg. Flipping of images is not supported yet.
if ( $orientation ) {
# We are going to update orientation information before the image is
# rotated. Otherwise we would have to re-extract EXIF data due to
# manipulation by Image Magick.
# Update orientation information
$exifTool->SetNewValue( 'Exif:Orientation' => 1, Type => 'ValueConv');
# Set the following options to make this as robust as possible
$exifTool->Options( 'IgnoreMinorErrors', FixBase => '' );
# Write updated exif data to disk
$exifTool->WriteInfo( $storage->getPath( $self->get('filename') ) );
# Log any errors
my $error = $exifTool->GetValue('Error');
$self->session->log->error( "Error on updating exif data: $error" ) if $error;
# Image rotated by 180°
if ( $orientation == 3 || $orientation == 4 ) {
$self->rotate(180);
}
# Image rotated by 90° CCW
elsif ( $orientation == 5 || $orientation == 6 ) {
$self->rotate(90);
}
# Image rotated by 90° CW
elsif ( $orientation == 7 || $orientation == 8 ) {
$self->rotate(-90);
}
}
}
#-------------------------------------------------------------------
=head2 generateThumbnail ( )

View file

@ -54,10 +54,10 @@ property address2 => (
property city => (
tab => "properties",
fieldType => "text",
label => $i18n->get("city label"),
hoverHelp => $i18n->get("city description"),
},
property region => {
label => ["city label", 'Asset_MapPoint'],
hoverHelp => ["city description", 'Asset_MapPoint'],
);
property region => (
tab => "properties",
fieldType => "text",
label => ["state label", 'Asset_MapPoint'],

View file

@ -77,6 +77,8 @@ with 'WebGUI::Role::Asset::AlwaysHidden';
with 'WebGUI::Role::Asset::SetStoragePermissions';
with 'WebGUI::Role::Asset::AutoSynopsis';
use WebGUI::Group;
use WebGUI::HTML;
use WebGUI::HTMLForm;
@ -170,7 +172,7 @@ Extend the master class to make the default group 7.
sub canAdd {
my $class = shift;
my $session = shift;
$class->SUPER::canAdd($session, undef, '7');
$class->next::method($session, undef, '7');
}
#-------------------------------------------------------------------
@ -617,49 +619,6 @@ sub getStorageLocation {
#-------------------------------------------------------------------
=head2 getSynopsisAndContent ($synopsis, $body)
Returns a synopsis taken from the body of the Post, based on either the separator
macro, the first html paragraph, or the first physical line of text as defined by
newlines.
Returns both the synopsis, and the original body content.
=head3 $synopsis
If passed in, it returns that instead of the calculated synopsis.
=head3 $body
Body of the Post to use a source for the synopsis.
=cut
sub getSynopsisAndContent {
my $self = shift;
my $synopsis = shift;
my $body = shift;
unless ($synopsis) {
my @content;
if( $body =~ /\^\-\;/ ) {
my @pieces = WebGUI::HTML::splitSeparator($body);
$content[0] = shift @pieces;
$content[1] = join '', @pieces;
}
elsif( $body =~ /<p>/ ) {
@content = WebGUI::HTML::splitTag($body);
}
else {
@content = split("\n",$body);
}
shift @content if $content[0] =~ /^\s*$/;
$synopsis = WebGUI::HTML::filter($content[0],"all");
}
return ($synopsis,$body);
}
#-------------------------------------------------------------------
=head2 getTemplateMetadataVars ( $var )
Append metadata as template variables.
@ -1352,6 +1311,7 @@ override trash => sub {
}
};
#-------------------------------------------------------------------
=head2 prepareView
@ -1362,7 +1322,7 @@ Extend the base method to also prepare the Thread containing this Post.
sub prepareView {
my $self = shift;
$self->SUPER::prepareView;
$self->next::method;
unless ($self->getThread->getId eq $self->getId) {
# Need the unless to avoid infinite recursion.
$self->getThread->prepareView;

View file

@ -95,11 +95,9 @@ sub _karma_noFormPost {
use WebGUI::Asset::Template;
use WebGUI::Form;
use WebGUI::Storage;
use WebGUI::Shop::Pay;
use WebGUI::AssetCollateral::Sku::Ad::Ad;
use WebGUI::AdSpace;
use WebGUI::AdSpace::Ad;
use Data::Dumper;
=head1 NAME

View file

@ -383,7 +383,7 @@ sub view {
;
# instanciate address
my $address = WebGUI::Shop::AddressBook->newBySession($self->session)->getAddress($form->get("addressId")) if ($form->get("addressId"));
my $address = WebGUI::Shop::AddressBook->newByUserId($self->session)->getAddress($form->get("addressId")) if ($form->get("addressId"));
# build the form that the user needs to fill out with badge holder information
$vars{formHeader} = WebGUI::Form::formHeader($session, {action => $self->getUrl})

View file

@ -97,6 +97,12 @@ property usePacked => (
hoverHelp => ['usePacked description', 'Asset_Template'],
);
property storageIdExample => (
fieldType => 'image',
label => ['field storageIdExample', 'Asset_Template'],
hoverHelp => ['field storageIdExample description', 'Asset_Template'],
);
use WebGUI::International;
use WebGUI::Asset::Template::HTMLTemplate;
use WebGUI::Utility;
@ -202,6 +208,10 @@ override duplicate => sub {
my $newTemplate = super();
$newTemplate->update({isDefault => 0});
$newTemplate->addAttachments($self->getAttachments);
if ( my $storageId = $self->get('storageIdExample') ) {
my $newStorage = WebGUI::Storage->get( $self->session, $storageId )->copy;
$newTemplate->update({ storageIdExample => $newStorage->getId });
}
return $newTemplate;
};
@ -217,6 +227,9 @@ override exportAssetData => sub {
my ( $self ) = @_;
my $data = super();
$data->{template_attachments} = $self->getAttachments;
if ( $self->get('storageIdExample') ) {
push @{$data->{storage}}, $self->get('storageIdExample');
}
return $data;
};
@ -399,9 +412,32 @@ override getEditForm => sub {
$label = $i18n->get('attachment add field label');
$properties->raw("<tr><td>$label</td><td>$table</td></tr>");
$properties->image(
name => 'storageIdExample',
value => $self->getValue('storageIdExample'),
label => $i18n->get('field storageIdExample'),
hoverHelp => $i18n->get('field storageIdExample description'),
);
return $tabform;
};
#-------------------------------------------------------------------
=head2 getExampleImageUrl ( )
Get the URL to the example image of this template, if any
=cut
sub getExampleImageUrl {
my ( $self ) = @_;
if ( my $storageId = $self->get('storageIdExample') ) {
my $storage = WebGUI::Storage->get( $self->session, $storageId );
return $storage->getUrl( $storage->getFiles->[0] );
}
return;
}
#-------------------------------------------------------------------

View file

@ -54,6 +54,7 @@ property isFeatured => (
with 'WebGUI::Role::Asset::AlwaysHidden';
with 'WebGUI::Role::Asset::Subscribable';
with 'WebGUI::Role::Asset::Comments';
with 'WebGUI::Role::Asset::AutoSynopsis';
use WebGUI::International;
@ -274,35 +275,11 @@ sub getTemplateVars {
$self->scrubContent,
{skipTitles => [$self->title]},
),
isKeywordPage => $self->isKeywordPage,
isSubscribed => $self->isSubscribed,
subscribeUrl => $self->getSubscribeUrl,
unsubscribeUrl => $self->getUnsubscribeUrl,
owner => $owner->get('alias'),
};
my @keyword_pages = ();
if ($var->{isKeywordPage}) {
my $paginator = $keyObj->getMatchingAssets({
startAsset => $self->getWiki,
keyword => $self->get('title'),
usePaginator => 1,
});
PAGE: foreach my $assetId (@{ $paginator->getPageData }) {
next PAGE if $assetId->{assetId} eq $self->getId;
my $asset = eval { WebGUI::Asset->newById($session, $assetId->{assetId}); };
next PAGE if Exception::Class->caught();
push @keyword_pages, {
title => $asset->getTitle,
url => $asset->getUrl,
};
}
$paginator->appendTemplateVars($var);
@keyword_pages = map { $_->[1] }
sort
map { [ lc $_->{title}, $_ ] }
@keyword_pages;
}
$var->{keyword_page_loop} = \@keyword_pages;
return $var;
}
@ -340,24 +317,6 @@ around indexContent => sub {
#-------------------------------------------------------------------
=head2 isKeywordPage
Returns a boolean indicating whether or not the name of this WikiPage matches any keyword in the Wiki that
contains it.
=cut
sub isKeywordPage {
my $self = shift;
my $keywords = WebGUI::Keyword->new($self->session)->getMatchingAssets({
asset => $self->getWiki,
keyword => $self->get('title'),
});
return scalar @{ $keywords };
}
#-------------------------------------------------------------------
=head2 preparePageTemplate
This is essentially prepareView, but is smart and will only do the template
@ -415,6 +374,8 @@ sub processPropertiesFromFormPost {
$properties->{isFeatured} = $session->form->get("isFeatured");
}
($properties->{synopsis}) = $self->getSynopsisAndContent(undef, $self->get('content'));
$self->update($properties);
# deal with attachments from the attachments form control
@ -468,7 +429,8 @@ sub scrubContent {
my $self = shift;
my $content = shift || $self->content;
my $scrubbedContent = WebGUI::HTML::filter($content, $self->getWiki->filterCode);
$content =~ s/\^-\;//g;
my $scrubbedContent = WebGUI::HTML::filter($content, $self->getWiki->get("filterCode"));
if ($self->getWiki->useContentFilter) {
$scrubbedContent = WebGUI::HTML::processReplacements($self->session, $scrubbedContent);

View file

@ -181,6 +181,14 @@ property filterCode => (
label => ['filter code', 'Asset_WikiMaster'],
hoverHelp => ['filter code description', 'Asset_WikiMaster'],
);
property topLevelKeywords => (
fieldType => "keywords",
default => '',
tab => 'properties',
label => ['top level keywords', 'Asset_WikiMaster'],
hoverHelp => ['top level keywords description', 'Asset_WikiMaster'],
);
with 'WebGUI::Role::Asset::Subscribable';
with 'WebGUI::Role::Asset::RssFeed';
@ -213,13 +221,12 @@ sub appendFeaturedPageVars {
=head2 appendKeywordPageVars ( var )
Append the template variables to C<var> for keyword (catagory) pages.
Append the template variables to C<var> for keyword (category) 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 );
@ -228,6 +235,7 @@ sub appendKeywordPageVars {
#-------------------------------------------------------------------
=head2 appendMostPopular ($var, [ $limit ])
=head3 $var
@ -242,10 +250,10 @@ If passed in, this will override the mostPopularCount set in the object.
=cut
sub appendMostPopular {
my $self = shift;
my $var = shift;
my $limit = shift || $self->mostPopularCount;
foreach my $asset (@{$self->getLineage(["children"],{returnObjects=>1, limit=>$limit, includeOnlyClasses=>["WebGUI::Asset::WikiPage"]})}) {
my $self = shift;
my $var = shift;
my $limit = shift || $self->get("mostPopularCount");
foreach my $asset (@{$self->getLineage(["children"],{returnObjects=>1, limit=>$limit, includeOnlyClasses=>["WebGUI::Asset::WikiPage"], joinClass => 'WebGUI::Asset::WikiPage', orderByClause => 'WikiPage.views DESC'})}) {
if (defined $asset) {
push(@{$var->{mostPopular}}, {
title=>$asset->getTitle,
@ -461,177 +469,20 @@ sub canEditPages {
}
#-------------------------------------------------------------------
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') },
=head2 deleteSubKeywords ( $keyword )
groupToAdminister => { fieldType => 'group',
defaultValue => ['3'],
tab => 'security',
hoverHelp => $i18n->get('groupToAdminister hoverHelp'),
label => $i18n->get('groupToAdminister label') },
Delete all keywords that are associated with a particular keyword for this wiki.
richEditor => { fieldType => 'selectRichEditor',
defaultValue => 'PBrichedit000000000001',
tab => 'display',
hoverHelp => $i18n->get('richEditor hoverHelp'),
label => $i18n->get('richEditor label') },
=head3 $keyword
frontPageTemplateId => { fieldType => 'template',
namespace => 'WikiMaster_front',
defaultValue => 'WikiFrontTmpl000000001',
tab => 'display',
hoverHelp => $i18n->get('frontPageTemplateId hoverHelp'),
label => $i18n->get('frontPageTemplateId label') },
The main keyword to key off of.
pageTemplateId => { fieldType => 'template',
namespace => 'WikiPage',
defaultValue => 'WikiPageTmpl0000000001',
tab => 'display',
hoverHelp => $i18n->get('pageTemplateId hoverHelp'),
label => $i18n->get('pageTemplateId label') },
=cut
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
sub deleteSubKeywords {
my ( $self, $keyword ) = @_;
return $self->session->db->write('delete from WikiMasterKeywords where assetId=? and keyword=?', [$self->getId, $keyword]);
}
#-------------------------------------------------------------------
@ -664,14 +515,15 @@ 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
keyword => 'keyword', # 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
children => [ # Array reference of sub-categories referenced by this category
{ # If there are no children, this key/value pair will not be present
...
}
]
],
descendants => 25, # The total number of wiki pages that this keyword, and any other sub-keywords
# of this keyword, refer to.
}
]
@ -693,25 +545,21 @@ sub getKeywordHierarchy {
my $hierarchy = [];
$keywords ||= $self->getTopLevelKeywordsList;
$seen ||= {};
my $assetKeyword = WebGUI::Keyword->new($session);
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,
title => $keyword, ##Note, same as keyword
url => $self->getUrl('func=byKeyword;keyword='.$keyword),
descendants => scalar @{ $assetKeyword->getMatchingAssets( { startAsset => $self, keyword => $keyword, }) },
};
##Prevent recursion if seen again
if (! $seen->{$keyword}++) {
my $children = $self->getKeywordHierarchy(WebGUI::Keyword::string2list($page->get('keywords')), $seen, );
##Replace this with a call to getSubKeywords.
my $children = $self->getKeywordHierarchy($self->getSubKeywords($keyword), $seen, );
if (@{ $children } ) {
foreach my $child (@{ $children }) {
$datum->{descendants} += $child->{descendants};
}
$datum->{children} = $children;
}
}
@ -722,6 +570,26 @@ sub getKeywordHierarchy {
#-------------------------------------------------------------------
=head2 getSubKeywords ( $keyword )
Return all keywords that are associated with a particular keyword for this wiki.
=head3 $keyword
The main keyword to key off of.
=cut
sub getSubKeywords {
my ( $self, $keyword ) = @_;
return $self->session->db->buildArrayRef(
'select subKeyword from WikiMasterKeywords where assetId=? and keyword=?',
[$self->getId, $keyword]
);
}
#-------------------------------------------------------------------
=head2 getKeywordVariables ( $hierarchy, $level )
Take a data structure representing a hierarchy of keywords, and append template variables
@ -745,6 +613,7 @@ sub getKeywordVariables {
KEYWORD: foreach my $member (@{ $hierarchy }) {
my $varBlock = clone $member;
$varBlock->{level} = $level;
$varBlock->{isTopLevel} = $level == 0;
$varBlock->{indent_loop} = [ map { { indent => $_ } } 1..$level ];
delete $varBlock->{children};
push @{$variables}, $varBlock;
@ -877,6 +746,48 @@ sub processPropertiesFromFormPost {
#-------------------------------------------------------------------
=head2 purge
Extend the master method to delete all keyword entries.
=cut
sub purge {
my $self = shift;
$self->session->db->write('delete from WikiMasterKeywords where assetId=?',[$self->getId]);
return $self->SUPER::purge;
}
#-------------------------------------------------------------------
=head2 setSubKeywords ( $keyword, @keywords )
Store the set of keywords for this WikiMaster in the db. Returns true.
=head3 $keyword
The keyword that gets the new keywords.
=head3 @keywords
The new set of keywords.
=cut
sub setSubKeywords {
my ( $self, $keyword, @subKeywords ) = @_;
$self->deleteSubKeywords($keyword);
my $stuffIt = $self->session->db->prepare('insert into WikiMasterKeywords (assetId, keyword, subKeyword) values (?,?,?)');
KEYWORD: foreach my $subKeyword (@subKeywords) {
next unless $keyword;
$stuffIt->execute([$self->getId, $keyword, $subKeyword]);
}
$stuffIt->finish;
return 1;
}
#-------------------------------------------------------------------
=head2 shouldSkipNotification ( )
WikiMasters do not send notification
@ -933,30 +844,55 @@ Return search results that match the keyword from the form variable C<keyword>.
=cut
sub www_byKeyword {
my $self = shift;
my $keyword = $self->session->form->process("keyword");
my @pages = ();
my $p = WebGUI::Keyword->new($self->session)->getMatchingAssets({
my $self = shift;
my $session = $self->session;
my $keyword = $session->form->process("keyword");
my $p = WebGUI::Keyword->new($session)->getMatchingAssets({
startAsset => $self,
keyword => $keyword,
usePaginator => 1,
});
});
$p->setBaseUrl($self->getUrl("func=byKeyword;keyword=".$keyword));
my @pages = ();
foreach my $assetData (@{$p->getPageData}) {
my $asset = WebGUI::Asset->newById($self->session, $assetData->{assetId});
next unless defined $asset;
push(@pages, {
title => $asset->getTitle,
url => $asset->getUrl,
title => $asset->getTitle,
url => $asset->getUrl,
synopsis => $asset->get('synopsis'),
});
}
@pages = sort { lc($a->{title}) cmp lc($b->{title}) } @pages;
my $var = {
keyword => $keyword,
pagesLoop => \@pages,
};
keyword => $keyword,
pagesLoop => \@pages,
canAdminister => $self->canAdminister,
recentChangesUrl => $self->getUrl("func=recentChanges"),
mostPopularUrl => $self->getUrl("func=mostPopular"),
wikiHomeUrl => $self->getUrl,
};
$p->appendTemplateVars($var);
return $self->processStyle($self->processTemplate($var, $self->byKeywordTemplateId));
my $subKeywords = $self->getSubKeywords($keyword);
my $keywordHierarchy = $self->getKeywordHierarchy($subKeywords);
$var->{keywords_loop} = $self->getKeywordVariables($keywordHierarchy);
if ($var->{canAdminister}) {
$var->{formHeader} = WebGUI::Form::formHeader($session, {action => $self->getUrl})
. WebGUI::Form::hidden($session, { name => 'func', value => 'subKeywordSave',})
. WebGUI::Form::hidden($session, { name => 'keyword', value => $keyword,});
my $subKeywords = join ', ', @{ $self->getSubKeywords($keyword) };
$var->{keywordForm} = WebGUI::Form::keywords($session, {
name => 'subKeywords',
value => $session->form->get('subKeywords') || $subKeywords,
});
$var->{submitForm} = WebGUI::Form::submit($session, {});
$var->{formFooter} = WebGUI::Form::formFooter($session);
}
return $self->processStyle($self->processTemplate($var, $self->get('byKeywordTemplateId')));
}
@ -1061,5 +997,25 @@ sub www_search {
return $self->processStyle($self->processTemplate($var, $self->searchTemplateId));
}
#-------------------------------------------------------------------
=head2 www_subKeywordSave
Process the form from www_byKeyword and update the subkeywords for a keyword in this wiki.
=cut
sub www_subKeywordSave {
my $self = shift;
my $form = $self->session->form;
my $subKeywords = $form->process('subKeywords', 'keywords');
my $keyword = $form->process('keyword');
my @subKeywords = @{ WebGUI::Keyword::string2list($subKeywords) };
$self->setSubKeywords($keyword, @subKeywords);
return $self->www_byKeyword;
}
__PACKAGE__->meta->make_immutable;
1;