Merge branch 'master' into WebGUI8

This commit is contained in:
Graham Knop 2010-04-16 20:45:22 -05:00
commit e4e27d6e96
23 changed files with 555 additions and 260 deletions

View file

@ -119,10 +119,19 @@ A hash reference of optional parameters. None at this time.
sub applyConstraints {
my $self = shift;
$self->getStorageLocation->setPrivileges($self->ownerUserId, $self->groupIdView, $self->groupIdEdit);
$self->setPrivileges;
$self->setSize;
}
sub setPrivileges {
my $self = shift;
$self->getStorageLocation->setPrivileges(
$self->ownerUserId,
$self->groupIdView,
$self->groupIdEdit,
);
}
#-------------------------------------------------------------------

View file

@ -1178,5 +1178,10 @@ sub www_view {
return "chunked";
}
sub setPrivileges {
my $self = shift;
$self->getStorageLocation->setPrivileges($self);
}
1; # Who knew the truth would be so obvious?

View file

@ -230,13 +230,17 @@ Get the common template vars for this asset
sub getTemplateVars {
my ( $self ) = @_;
my $i18n = WebGUI::International->new($self->session, "Asset_WikiPage");
my $wiki = $self->getWiki;
my $owner = WebGUI::User->new( $self->session, $self->ownerUserId );
my $keywords = WebGUI::Keyword->new($self->session)->getKeywordsForAsset({
my $session = $self->session;
my $i18n = WebGUI::International->new($session, "Asset_WikiPage");
my $wiki = $self->getWiki;
my $owner = WebGUI::User->new( $session, $self->ownerUserId );
my $keyObj = WebGUI::Keyword->new($session);
my $keywords = $keyObj->getKeywordsForAsset({
asset => $self,
asArrayRef => 1,
});
my @keywordsLoop = ();
foreach my $word (@{$keywords}) {
push @keywordsLoop, {
@ -270,11 +274,35 @@ 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 = WebGUI::Asset->newByDynamicClass($session, $assetId->{assetId});
next PAGE unless $asset;
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;
}
@ -312,6 +340,24 @@ 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