Foundational work for wiki sub-keywords.
This commit is contained in:
parent
b2dd6135b6
commit
5afdefe4fb
1 changed files with 100 additions and 9 deletions
|
|
@ -47,7 +47,7 @@ sub appendFeaturedPageVars {
|
||||||
|
|
||||||
=head2 appendKeywordPageVars ( var )
|
=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
|
=cut
|
||||||
|
|
||||||
|
|
@ -62,6 +62,7 @@ sub appendKeywordPageVars {
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
=head2 appendMostPopular ($var, [ $limit ])
|
=head2 appendMostPopular ($var, [ $limit ])
|
||||||
|
|
||||||
=head3 $var
|
=head3 $var
|
||||||
|
|
@ -468,6 +469,23 @@ sub definition {
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
=head2 deleteSubKeywords ( $keyword )
|
||||||
|
|
||||||
|
Delete all keywords that are associated with a particular keyword for this wiki.
|
||||||
|
|
||||||
|
=head3 $keyword
|
||||||
|
|
||||||
|
The main keyword to key off of.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub deleteSubKeywords {
|
||||||
|
my ( $self, $keyword ) = @_;
|
||||||
|
return $self->session->db->buildArrayRef('delete from WikiMasterKeywords where assetId=? and keyword=?', [$self->getId, $keyword]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 getFeaturedPageIds ( )
|
=head2 getFeaturedPageIds ( )
|
||||||
|
|
||||||
Get the asset IDs of the pages that are marked as Featured.
|
Get the asset IDs of the pages that are marked as Featured.
|
||||||
|
|
@ -554,6 +572,23 @@ 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 )
|
=head2 getKeywordVariables ( $hierarchy, $level )
|
||||||
|
|
||||||
Take a data structure representing a hierarchy of keywords, and append template variables
|
Take a data structure representing a hierarchy of keywords, and append template variables
|
||||||
|
|
@ -709,6 +744,47 @@ 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 WikiMasterKeyword (assetId, keyword, subKeyword) values (?,?,?))');
|
||||||
|
KEYWORD: foreach my $subKeyword (@subKeywords) {
|
||||||
|
next unless $keyword;
|
||||||
|
$stuffIt->execute([$self->getId, $keyword, $subKeyword]);
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 shouldSkipNotification ( )
|
=head2 shouldSkipNotification ( )
|
||||||
|
|
||||||
WikiMasters do not send notification
|
WikiMasters do not send notification
|
||||||
|
|
@ -765,21 +841,25 @@ Return search results that match the keyword from the form variable C<keyword>.
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub www_byKeyword {
|
sub www_byKeyword {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $keyword = $self->session->form->process("keyword");
|
my $session = $self->session;
|
||||||
my @pages = ();
|
my $keyword = $session->form->process("keyword");
|
||||||
my $p = WebGUI::Keyword->new($self->session)->getMatchingAssets({
|
|
||||||
|
my $p = WebGUI::Keyword->new($session)->getMatchingAssets({
|
||||||
startAsset => $self,
|
startAsset => $self,
|
||||||
keyword => $keyword,
|
keyword => $keyword,
|
||||||
usePaginator => 1,
|
usePaginator => 1,
|
||||||
});
|
});
|
||||||
$p->setBaseUrl($self->getUrl("func=byKeyword;keyword=".$keyword));
|
$p->setBaseUrl($self->getUrl("func=byKeyword;keyword=".$keyword));
|
||||||
|
|
||||||
|
my @pages = ();
|
||||||
foreach my $assetData (@{$p->getPageData}) {
|
foreach my $assetData (@{$p->getPageData}) {
|
||||||
my $asset = WebGUI::Asset->newByDynamicClass($self->session, $assetData->{assetId});
|
my $asset = WebGUI::Asset->newByDynamicClass($session, $assetData->{assetId});
|
||||||
next unless defined $asset;
|
next unless defined $asset;
|
||||||
push(@pages, {
|
push(@pages, {
|
||||||
title => $asset->getTitle,
|
title => $asset->getTitle,
|
||||||
url => $asset->getUrl,
|
url => $asset->getUrl,
|
||||||
|
synopsis => $asset->get('synopsis'),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@pages = sort { lc($a->{title}) cmp lc($b->{title}) } @pages;
|
@pages = sort { lc($a->{title}) cmp lc($b->{title}) } @pages;
|
||||||
|
|
@ -788,6 +868,17 @@ sub www_byKeyword {
|
||||||
pagesLoop => \@pages,
|
pagesLoop => \@pages,
|
||||||
};
|
};
|
||||||
$p->appendTemplateVars($var);
|
$p->appendTemplateVars($var);
|
||||||
|
if ($self->canAdminister) {
|
||||||
|
$var->{formHeader} = WebGUI::Form::formHeader($session, {action => $self->getUrl, method => 'GET'})
|
||||||
|
. WebGUI::Form::hidden($session, { name => 'func', value => 'keywordKeywordSave',})
|
||||||
|
. WebGUI::Form::hidden($session, { name => 'thisKeyword', value => $keyword,});
|
||||||
|
my $subKeywords = join ', ', $self->getSubKeywords($keyword);
|
||||||
|
$var->{keywordForm} = WebGUI::Form::keyword($session, {
|
||||||
|
name => 'subKeywords',
|
||||||
|
value => $session->form->get('subKeywords') || $subKeywords,
|
||||||
|
});
|
||||||
|
$var->{formFooter} = WebGU::Form::formHeader($session);
|
||||||
|
}
|
||||||
return $self->processStyle($self->processTemplate($var, $self->get('byKeywordTemplateId')));
|
return $self->processStyle($self->processTemplate($var, $self->get('byKeywordTemplateId')));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue