added Subscribable AssetAspect to Wiki

This commit is contained in:
Doug Bell 2009-09-09 17:24:00 -05:00
parent b838102df5
commit 0697673846
15 changed files with 936 additions and 56 deletions

View file

@ -12,7 +12,11 @@ package WebGUI::Asset::WikiPage;
use strict;
use Class::C3;
use base qw(WebGUI::AssetAspect::Comments WebGUI::Asset);
use base qw(
WebGUI::AssetAspect::Subscribable
WebGUI::AssetAspect::Comments
WebGUI::Asset
);
use Tie::IxHash;
use WebGUI::International;
use WebGUI::Utility;
@ -236,6 +240,73 @@ sub getEditForm {
#-------------------------------------------------------------------
=head2 getSubscriptionTemplate ( )
=cut
sub getSubscriptionTemplate {
my ( $self ) = @_;
return $self->getParent->getSubscriptionTemplate;
}
#-------------------------------------------------------------------
=head2 getTemplateVars ( )
Get the common template vars for this asset
=cut
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->get('ownerUserId') );
my $keywords = WebGUI::Keyword->new($self->session)->getKeywordsForAsset({
asset => $self,
asArrayRef => 1,
});
my @keywordsLoop = ();
foreach my $word (@{$keywords}) {
push @keywordsLoop, {
keyword => $word,
url => $wiki->getUrl("func=byKeyword;keyword=".$word),
};
}
my $var = {
%{ $self->get },
url => $self->getUrl,
keywordsLoop => \@keywordsLoop,
viewLabel => $i18n->get("viewLabel"),
editLabel => $i18n->get("editLabel"),
historyLabel => $i18n->get("historyLabel"),
wikiHomeLabel => $i18n->get("wikiHomeLabel", "Asset_WikiMaster"),
searchLabel => $i18n->get("searchLabel", "Asset_WikiMaster"),
searchUrl => $wiki->getUrl("func=search"),
recentChangesUrl => $wiki->getUrl("func=recentChanges"),
recentChangesLabel => $i18n->get("recentChangesLabel", "Asset_WikiMaster"),
mostPopularUrl => $wiki->getUrl("func=mostPopular"),
mostPopularLabel => $i18n->get("mostPopularLabel", "Asset_WikiMaster"),
wikiHomeUrl => $wiki->getUrl,
historyUrl => $self->getUrl("func=getHistory"),
editContent => $self->getEditForm,
allowsAttachments => $wiki->get("allowAttachments"),
comments => $self->getFormattedComments(),
canEdit => $self->canEdit,
content => $wiki->autolinkHtml(
$self->scrubContent,
{skipTitles => [$self->get('title')]},
),
isSubscribed => $self->isSubscribed,
subscribeUrl => $self->getSubscribeUrl,
unsubscribeUrl => $self->getUnsubscribeUrl,
owner => $owner->get('alias'),
};
return $var;
}
#-------------------------------------------------------------------
=head2 getWiki
Returns an object referring to the wiki that contains this page. If it is not a WikiMaster,
@ -438,43 +509,7 @@ Renders this asset.
sub view {
my $self = shift;
my $i18n = WebGUI::International->new($self->session, "Asset_WikiPage");
my $keywords = WebGUI::Keyword->new($self->session)->getKeywordsForAsset({
asset=>$self,
asArrayRef=>1,
});
my $wiki = $self->getWiki;
my @keywordsLoop = ();
foreach my $word (@{$keywords}) {
push(@keywordsLoop, {
keyword=>$word,
url=>$wiki->getUrl("func=byKeyword;keyword=".$word),
});
}
my $var = {
keywordsLoop => \@keywordsLoop,
viewLabel => $i18n->get("viewLabel"),
editLabel => $i18n->get("editLabel"),
historyLabel => $i18n->get("historyLabel"),
wikiHomeLabel => $i18n->get("wikiHomeLabel", "Asset_WikiMaster"),
searchLabel => $i18n->get("searchLabel", "Asset_WikiMaster"),
searchUrl => $self->getParent->getUrl("func=search"),
recentChangesUrl => $self->getParent->getUrl("func=recentChanges"),
recentChangesLabel => $i18n->get("recentChangesLabel", "Asset_WikiMaster"),
mostPopularUrl => $self->getParent->getUrl("func=mostPopular"),
mostPopularLabel => $i18n->get("mostPopularLabel", "Asset_WikiMaster"),
wikiHomeUrl => $self->getParent->getUrl,
historyUrl => $self->getUrl("func=getHistory"),
editContent => $self->getEditForm,
allowsAttachments => $self->getWiki->get("allowAttachments"),
comments => $self->getFormattedComments(),
canEdit => $self->canEdit,
content => $self->getWiki->autolinkHtml(
$self->scrubContent,
{skipTitles => [$self->get('title')]},
),
};
return $self->processTemplate($var, $self->getWiki->get("pageTemplateId"));
return $self->processTemplate($self->getTemplateVars, $self->getWiki->get("pageTemplateId"));
}
#-------------------------------------------------------------------

View file

@ -11,7 +11,11 @@ package WebGUI::Asset::Wobject::WikiMaster;
#-------------------------------------------------------------------
use Class::C3;
use base qw(WebGUI::AssetAspect::RssFeed WebGUI::Asset::Wobject);
use base qw(
WebGUI::AssetAspect::Subscribable
WebGUI::AssetAspect::RssFeed
WebGUI::Asset::Wobject
);
use strict;
use Tie::IxHash;
use WebGUI::International;
@ -444,6 +448,36 @@ sub getRssFeedItems {
return $var;
}
#----------------------------------------------------------------------------
=head2 getTemplateVars ( )
Get the common template variables for all views of the wiki.
=cut
sub getTemplateVars {
my ( $self ) = @_;
my $i18n = WebGUI::International->new($self->session, "Asset_WikiMaster");
my $var = { %{$self->get},
url => $self->getUrl,
searchLabel => $i18n->get("searchLabel"),
mostPopularUrl => $self->getUrl("func=mostPopular"),
mostPopularLabel => $i18n->get("mostPopularLabel"),
addPageLabel => $i18n->get("addPageLabel"),
addPageUrl => $self->getUrl("func=add;class=WebGUI::Asset::WikiPage"),
recentChangesUrl => $self->getUrl("func=recentChanges"),
recentChangesLabel => $i18n->get("recentChangesLabel"),
restoreLabel => $i18n->get("restoreLabel"),
canAdminister => $self->canAdminister,
isSubscribed => $self->isSubscribed,
subscribeUrl => $self->getSubscribeUrl,
unsubscribeUrl => $self->getUnsubscribeUrl,
};
return $var;
}
#-------------------------------------------------------------------
=head2 prepareView
@ -492,6 +526,19 @@ sub processPropertiesFromFormPost {
#-------------------------------------------------------------------
=head2 shouldSkipNotification ( )
WikiMasters do not send notification
=cut
sub shouldSkipNotification {
my ( $self ) = @_;
return 1;
}
#-------------------------------------------------------------------
=head2 view
Render the front page of the wiki.
@ -500,23 +547,13 @@ Render the front page of the wiki.
sub view {
my $self = shift;
my $i18n = WebGUI::International->new($self->session, "Asset_WikiMaster");
my $var = {
description => $self->autolinkHtml($self->get('description')),
searchLabel=>$i18n->get("searchLabel"),
mostPopularUrl=>$self->getUrl("func=mostPopular"),
mostPopularLabel=>$i18n->get("mostPopularLabel"),
addPageLabel=>$i18n->get("addPageLabel"),
addPageUrl=>$self->getUrl("func=add;class=WebGUI::Asset::WikiPage"),
recentChangesUrl=>$self->getUrl("func=recentChanges"),
recentChangesLabel=>$i18n->get("recentChangesLabel"),
restoreLabel => $i18n->get("restoreLabel"),
canAdminister => $self->canAdminister,
keywordCloud => WebGUI::Keyword->new($self->session)->generateCloud({
startAsset=>$self,
displayFunc=>"byKeyword",
}),
};
my $var = $self->getTemplateVars;
$var->{ description } = $self->autolinkHtml( $var->{ description } );
$var->{ keywordCloud }
= WebGUI::Keyword->new($self->session)->generateCloud({
startAsset=>$self,
displayFunc=>"byKeyword",
});
my $template = $self->{_frontPageTemplate};
$self->appendSearchBoxVars($var);
$self->appendRecentChanges($var, $self->get('recentChangesCountFront'));