Add RFE #10944, keyword pages.
Keyword pages are any page where the title is exactly the same as any keyword for any page in the wiki. Keyword pages work the same as any wiki page, but also may display a list of pages that are tagged with the keyword.
This commit is contained in:
parent
55ceb579fb
commit
1395fcc411
5 changed files with 147 additions and 9 deletions
|
|
@ -265,13 +265,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->get('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->get('ownerUserId') );
|
||||
my $keyObj = WebGUI::Keyword->new($session);
|
||||
|
||||
my $keywords = $keyObj->getKeywordsForAsset({
|
||||
asset => $self,
|
||||
asArrayRef => 1,
|
||||
});
|
||||
|
||||
my @keywordsLoop = ();
|
||||
foreach my $word (@{$keywords}) {
|
||||
push @keywordsLoop, {
|
||||
|
|
@ -305,11 +309,35 @@ sub getTemplateVars {
|
|||
$self->scrubContent,
|
||||
{skipTitles => [$self->get('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->appendTemplateVariables($var);
|
||||
@keyword_pages = map { $_->[1] }
|
||||
sort
|
||||
map { [ lc $_->{title}, $_ ] }
|
||||
@keyword_pages;
|
||||
}
|
||||
$var->{keyword_page_loop} = \@keyword_pages;
|
||||
return $var;
|
||||
}
|
||||
|
||||
|
|
@ -359,6 +387,24 @@ sub isProtected {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=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
|
||||
|
|
|
|||
|
|
@ -48,6 +48,9 @@ our $HELP = {
|
|||
{ tag => 'wiki page asset template variables',
|
||||
namespace => 'Asset_WikiPage'
|
||||
},
|
||||
{ tag => 'pagination template variables',
|
||||
namespace => 'WebGUI'
|
||||
},
|
||||
],
|
||||
variables => [
|
||||
{ name => 'viewLabel',
|
||||
|
|
@ -104,6 +107,17 @@ our $HELP = {
|
|||
name => 'owner',
|
||||
description => 'help owner',
|
||||
},
|
||||
{ 'name' => 'isKeywordPage', },
|
||||
{ 'name' => 'keyword_page_loop',
|
||||
'variables' => [
|
||||
{ 'name' => 'title',
|
||||
'description' => 'keyword page title',
|
||||
},
|
||||
{ 'name' => 'url',
|
||||
'description' => 'keyword page url',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
related => [],
|
||||
},
|
||||
|
|
|
|||
|
|
@ -327,12 +327,36 @@ our $I18N =
|
|||
context => 'Body text for help page',
|
||||
},
|
||||
|
||||
|
||||
'isFeatured label' => {
|
||||
message => q{Feature this on the front page},
|
||||
lastUpdated => 0,
|
||||
context => 'Label for asset property',
|
||||
},
|
||||
|
||||
'isKeywordPage' => {
|
||||
message => q{A boolean that is true if this page is a keyword page.},
|
||||
lastUpdated => 0,
|
||||
context => 'template variable help',
|
||||
},
|
||||
|
||||
'keyword_page_loop' => {
|
||||
message => q{If this page is a keyword page, then this loop will contain a list of all pages tagged with this page's keyword. The pagination variables will apply to the list of pages in this loop. If this page is not a keyword page, the loop will be blank, and the pagination variables will not be present.},
|
||||
lastUpdated => 0,
|
||||
context => 'template variable help',
|
||||
},
|
||||
|
||||
'keyword page title' => {
|
||||
message => q{The title of a page that has this keyword.},
|
||||
lastUpdated => 0,
|
||||
context => 'template variable help',
|
||||
},
|
||||
|
||||
'keyword page url' => {
|
||||
message => q{The URL to a page that has this keyword.},
|
||||
lastUpdated => 0,
|
||||
context => 'template variable help',
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue