diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 44e9aae5f..fa8b6c189 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -5,6 +5,7 @@ WebGUI::Operation::Workflow::www_activityHelper for details. - Added pagination to purchase history in commerce. - Added keyword tagging api. + - Added keyword tagging to Wiki. - improved performance of EMS - upgraded YUI to 2.2.2 and YUI-ext to 1.0.1a - Improved error handling in Spectre when WebGUI hands it bad data. diff --git a/docs/upgrades/templates-7.3.19/PBtmpl0000000000000207.tmpl b/docs/upgrades/templates-7.3.19/PBtmpl0000000000000207.tmpl deleted file mode 100644 index f128803bc..000000000 --- a/docs/upgrades/templates-7.3.19/PBtmpl0000000000000207.tmpl +++ /dev/null @@ -1,58 +0,0 @@ -#PBtmpl0000000000000207 -#title: Article with Files -#url: article-with-files -#menutitle: - - - - -

-
- - -

-
- - - - - - - - - - - -

- - - - -

<tmpl_var filename>


- -
- - - -· - -· - - - - - - - - -

- - - - - -
()
- - - - diff --git a/docs/upgrades/templates-7.4.0/wikibykeyword.tmpl b/docs/upgrades/templates-7.4.0/wikibykeyword.tmpl new file mode 100644 index 000000000..979f671ed --- /dev/null +++ b/docs/upgrades/templates-7.4.0/wikibykeyword.tmpl @@ -0,0 +1,15 @@ +#WikiKeyword00000000001 +#url: wiki-master-by-keyword-template.tmpl +#title: Wiki Pages By Keyword (default) +#menuTitle: Wiki Pages By Keyword +#namespace:WikiMaster_byKeyword +#create + +

+ +
    + +
  • +
    +
+ diff --git a/docs/upgrades/templates-7.4.0/wikifrontpage.tmpl b/docs/upgrades/templates-7.4.0/wikifrontpage.tmpl new file mode 100644 index 000000000..90eef51fd --- /dev/null +++ b/docs/upgrades/templates-7.4.0/wikifrontpage.tmpl @@ -0,0 +1,33 @@ +#WikiFrontTmpl000000001 +

+

+ + +

+ +
+ +
+

+
    +
  • + + + + () + +
  • +
+
+
+

+
    +
  1. +
+ +
+
+ +
+ + diff --git a/docs/upgrades/templates-7.4.0/wikipage.tmpl b/docs/upgrades/templates-7.4.0/wikipage.tmpl new file mode 100644 index 000000000..9491cab03 --- /dev/null +++ b/docs/upgrades/templates-7.4.0/wikipage.tmpl @@ -0,0 +1,110 @@ +#WikiPageTmpl0000000001 +

+

+ +
+
    +
  • +
  • +
+
+
+ +

^International("keywords","Asset");:

+
+
+ +
+
+
+ +
| | |
+~~~ + + + + + + + + diff --git a/docs/upgrades/templates-7.4.0/wikipageedit.tmpl b/docs/upgrades/templates-7.4.0/wikipageedit.tmpl new file mode 100644 index 000000000..944e07605 --- /dev/null +++ b/docs/upgrades/templates-7.4.0/wikipageedit.tmpl @@ -0,0 +1,28 @@ +#WikiPageEditTmpl000001 + + + + + + + + + + + + + +
+ + + + + + +~~~ + diff --git a/docs/upgrades/upgrade_7.3.18-7.3.19.pl b/docs/upgrades/upgrade_7.3.18-7.3.19.pl deleted file mode 100644 index c5f946bfc..000000000 --- a/docs/upgrades/upgrade_7.3.18-7.3.19.pl +++ /dev/null @@ -1,146 +0,0 @@ -#------------------------------------------------------------------- -# WebGUI is Copyright 2001-2007 Plain Black Corporation. -#------------------------------------------------------------------- -# Please read the legal notices (docs/legal.txt) and the license -# (docs/license.txt) that came with this distribution before using -# this software. -#------------------------------------------------------------------- -# http://www.plainblack.com info@plainblack.com -#------------------------------------------------------------------- - -use lib "../../lib"; -use strict; -use Getopt::Long; -use WebGUI::Session; -use WebGUI::Asset; -use WebGUI::Workflow; - - -my $toVersion = "7.3.19"; # make this match what version you're going to -my $quiet; # this line required - - -my $session = start(); # this line required - -# upgrade functions go here -fixAssetSizes($session); -resequenceWorkflowActivities($session); - -finish($session); # this line required - - -#------------------------------------------------- -sub fixAssetSizes { - my $session = shift; - print "\tFix the sizes of ALL Image and Size assets. This will take a while.\n" unless ($quiet); - my $root = WebGUI::Asset->getRoot($session); - foreach my $fileAsset ( @{ $root->getLineage(["self","descendants"],{returnObjects=>1,includeOnlyClasses=>['WebGUI::Asset::File','WebGUI::Asset::Image']}) } ) { - $fileAsset->setSize(); - } -} - -#------------------------------------------------- -sub resequenceWorkflowActivities { - my $session = shift; - print "\tFix sequencing problems in Workflow Activities. This will take a while.\n" unless ($quiet); - my $workflows = WebGUI::Workflow->getList($session, undef, 1); ##Hack to get around non-existant mode column - my ($workflowId, $title); - while ( ($workflowId, $title) = each %{ $workflows } ) { - my $workflow = WebGUI::Workflow->new($session, $workflowId); - next unless defined $workflow; - $workflow->reorderActivities; - } -} - - - - -# ---- DO NOT EDIT BELOW THIS LINE ---- - -#------------------------------------------------- -sub start { - my $configFile; - $|=1; #disable output buffering - GetOptions( - 'configFile=s'=>\$configFile, - 'quiet'=>\$quiet - ); - my $session = WebGUI::Session->open("../..",$configFile); - $session->user({userId=>3}); - my $versionTag = WebGUI::VersionTag->getWorking($session); - $versionTag->set({name=>"Upgrade to ".$toVersion}); - $session->db->write("insert into webguiVersion values (".$session->db->quote($toVersion).",'upgrade',".$session->datetime->time().")"); - updateTemplates($session); - return $session; -} - -#------------------------------------------------- -sub finish { - my $session = shift; - my $versionTag = WebGUI::VersionTag->getWorking($session); - $versionTag->commit; - $session->close(); -} - -#------------------------------------------------- -sub updateTemplates { - my $session = shift; - return undef unless (-d "templates-".$toVersion); - print "\tUpdating templates.\n" unless ($quiet); - opendir(DIR,"templates-".$toVersion); - my @files = readdir(DIR); - closedir(DIR); - my $importNode = WebGUI::Asset->getImportNode($session); - my $newFolder = undef; - foreach my $file (@files) { - next unless ($file =~ /\.tmpl$/); - open(FILE,""WebGUI::Asset::Template"); - while (my $line = ) { - if ($first) { - $line =~ m/^\#(.*)$/; - $properties{id} = $1; - $first = 0; - } elsif ($line =~ m/^\#create$/) { - $create = 1; - } elsif ($line =~ m/^\#(.*):(.*)$/) { - $properties{$1} = $2; - } elsif ($line =~ m/^~~~$/) { - $head = 1; - } elsif ($head) { - $properties{headBlock} .= $line; - } else { - $properties{template} .= $line; - } - } - close(FILE); - if ($create) { - $newFolder = createNewTemplatesFolder($importNode) unless (defined $newFolder); - my $template = $newFolder->addChild(\%properties, $properties{id}); - } else { - my $template = WebGUI::Asset->new($session,$properties{id}, "WebGUI::Asset::Template"); - if (defined $template) { - my $newRevision = $template->addRevision(\%properties); - } - } - } -} - -#------------------------------------------------- -sub createNewTemplatesFolder { - my $importNode = shift; - my $newFolder = $importNode->addChild({ - className=>"WebGUI::Asset::Wobject::Folder", - title => $toVersion." New Templates", - menuTitle => $toVersion." New Templates", - url=> $toVersion."_new_templates", - groupIdView=>"12" - }); - return $newFolder; -} - - - diff --git a/docs/upgrades/upgrade_7.3.19-7.4.0.pl b/docs/upgrades/upgrade_7.3.19-7.4.0.pl index 818a49918..eb88ac5a0 100644 --- a/docs/upgrades/upgrade_7.3.19-7.4.0.pl +++ b/docs/upgrades/upgrade_7.3.19-7.4.0.pl @@ -45,6 +45,8 @@ sub addKeywordTagging { index keyword (keyword), index assetId (assetId) )"); + $session->db->write("alter table WikiMaster add column byKeywordTemplateId varchar(22) binary + not null default 'WikiKeyword00000000001'"); } #------------------------------------------------- diff --git a/lib/WebGUI/Asset.pm b/lib/WebGUI/Asset.pm index b2651a49b..8d06edbbd 100644 --- a/lib/WebGUI/Asset.pm +++ b/lib/WebGUI/Asset.pm @@ -1787,6 +1787,9 @@ sub processPropertiesFromFormPost { ); } } + if ($form->process("keywords")) { + $data{keywords} = $form->process("keywords"); + } if ($self->session->setting->get("metaDataEnabled")) { my $meta = $self->getMetaDataFields; foreach my $field (keys %{$meta}) { diff --git a/lib/WebGUI/Asset/WikiPage.pm b/lib/WebGUI/Asset/WikiPage.pm index 68fd66b04..442abe985 100644 --- a/lib/WebGUI/Asset/WikiPage.pm +++ b/lib/WebGUI/Asset/WikiPage.pm @@ -158,7 +158,7 @@ sub getEditForm { formKeywords => WebGUI::Form::text($session, { name => "keywords", value => WebGUI::Keyword->new($session)->getKeywordsForAsset({asset=>$self}), - }); + }), allowsAttachments => $wiki->get("maxAttachments"), formFooter => WebGUI::Form::formFooter($session), isNew => ($self->getId eq "new"), @@ -319,7 +319,20 @@ sub update { 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"), diff --git a/lib/WebGUI/Asset/Wobject/WikiMaster.pm b/lib/WebGUI/Asset/Wobject/WikiMaster.pm index de142d847..89bdb3d44 100644 --- a/lib/WebGUI/Asset/Wobject/WikiMaster.pm +++ b/lib/WebGUI/Asset/Wobject/WikiMaster.pm @@ -233,6 +233,13 @@ sub definition { 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', @@ -361,6 +368,10 @@ sub view { recentChangesLabel=>$i18n->get("recentChangesLabel"), restoreLabel => $i18n->get("restoreLabel"), canAdminister => $self->canAdminister, + keywordCloud => WebGUI::Keyword->new($self->session)->generateCloud({ + startAsset=>$self, + displayFunc=>"byKeyword", + }), }; my $template = $self->{_frontPageTemplate}; $self->appendSearchBoxVars($var); @@ -370,6 +381,35 @@ sub view { } +#------------------------------------------------------------------- +sub www_byKeyword { + my $self = shift; + my $keyword = $self->session->form->process("keyword"); + my @pages = (); + my $p = WebGUI::Keyword->new($self->session)->getMatchingAssets({ + startAsset => $self, + keyword => $keyword, + usePaginator => 1, + }); + $p->setBaseUrl($self->getUrl("func=byKeyword")); + foreach my $assetData (@{$p->getPageData}) { +$self->session->errorHandler->warn($assetData->{assetId}); + my $asset = WebGUI::Asset->newByDynamicClass($self->session, $assetData->{assetId}); + next unless defined $asset; + push(@pages, { + title => $asset->getTitle, + url => $asset->getUrl, + }); + } + my $var = { + keyword => $keyword, + pagesLoop => \@pages, + }; + $p->appendTemplateVars($var); + return $self->processStyle($self->processTemplate($var, $self->get('byKeywordTemplateId'))); +} + + #------------------------------------------------------------------- sub www_mostPopular { my $self = shift; diff --git a/lib/WebGUI/Keyword.pm b/lib/WebGUI/Keyword.pm index 16172d772..e6586ca10 100644 --- a/lib/WebGUI/Keyword.pm +++ b/lib/WebGUI/Keyword.pm @@ -17,6 +17,7 @@ package WebGUI::Keyword; use strict; use Class::InsideOut qw(public register id); use HTML::TagCloud; +use WebGUI::Paginator; =head1 NAME @@ -104,7 +105,7 @@ The www func that will be called on the displayAsset to display the list of asse =head3 cloudLevels -How many levels of keyword sizes should there be displayed in the cloud. Defaults to 10. +How many levels of keyword sizes should there be displayed in the cloud. Defaults to 24. Range between 2 and 24. =head3 startAsset @@ -124,7 +125,7 @@ sub generateCloud { my $sth = $self->session->db->read("select count(*) as keywordTotal, keyword from assetKeyword left join asset using (assetId) where lineage like ? group by keyword order by keywordTotal limit 50", [ $options->{startAsset}->get("lineage").'%' ]); - my $cloud = HTML::TagCloud->new(levels=>$options->{cloudLevels} || 10); + my $cloud = HTML::TagCloud->new(levels=>$options->{cloudLevels} || 24); while (my ($count, $keyword) = $sth->array) { $cloud->add($keyword, $display->getUrl("func=".$options->{displayFunc}.";keyword=".$keyword), $count); } @@ -148,8 +149,7 @@ A boolean, that if set to 1 will return the keywords as an array reference rathe =cut sub getKeywordsForAsset { - my $self = shift; - my $options = shift; + my ($self, $options) = @_; my @keywords = $self->session->db->buildArray("select keyword from assetKeyword where assetId=?", [$options->{asset}->getId]); if ($options->{asArrayRef}) { @@ -163,7 +163,43 @@ sub getKeywordsForAsset { #------------------------------------------------------------------- -=head2 new ( session ) +=head2 getMatchingAssets ( { startAsset => $asset, keyword => $keyword } ) + +Returns an array reference of asset ids matching the start point + keyword. + +=head3 startAsset + +An asset object where you'd like to start searching for matching keywords. + +=head3 keyword + +The keyword to match. + +=head3 usePaginator + +Instead of returning an array reference of assetId's, return a paginator object. + +=cut + +sub getMatchingAssets { + my ($self, $options) = @_; + my $query = "select assetKeyword.assetId from assetKeyword left join asset using (assetId) + where lineage like ? and keyword=? order by creationDate desc"; + my $params = [$options->{startAsset}->get("lineage").'%', $options->{keyword}]; + if ($options->{usePaginator}) { + my $p = WebGUI::Paginator->new($self->session); + $p->setDataByQuery($query, undef, undef, $params); + return $p; + } + else { + return $self->session->db->buildArrayRef($query, $params); + } +} + + +#------------------------------------------------------------------- + +=head2 new ( $session ) Constructor. diff --git a/lib/WebGUI/Paginator.pm b/lib/WebGUI/Paginator.pm index 5380e8ae0..348ce1033 100644 --- a/lib/WebGUI/Paginator.pm +++ b/lib/WebGUI/Paginator.pm @@ -549,7 +549,7 @@ sub getRowCount { #------------------------------------------------------------------- -=head2 new ( session, currentURL [, paginateAfter, formVar, pageNumber ] ) +=head2 new ( session, baseUrl [, paginateAfter, formVar, pageNumber ] ) Constructor. @@ -557,7 +557,7 @@ Constructor. A reference to the current session. -=head3 currentURL +=head3 baseUrl The URL of the current page including attributes. The page number will be appended to this in all links generated by the paginator. @@ -599,6 +599,24 @@ sub session { } +#------------------------------------------------------------------- + +=head2 setBaseUrl ( url ) + +Override the baseUrl set in the constructor. + +=head3 url + +The new URL. + +=cut + +sub setBaseUrl { + my ($self, $url) = @_; + $self->{_url} = $url; +} + + #------------------------------------------------------------------- =head2 setDataByArrayRef ( arrayRef ) diff --git a/lib/WebGUI/i18n/English/Asset.pm b/lib/WebGUI/i18n/English/Asset.pm index 47cc44559..dfc55fafc 100644 --- a/lib/WebGUI/i18n/English/Asset.pm +++ b/lib/WebGUI/i18n/English/Asset.pm @@ -7,6 +7,12 @@ our $I18N = { context => q|A button added to all asset properties pages when save and commit mode is enabled.| }, + 'keywords' => { + message => q|Keywords|, + lastUpdated => 0, + context => q|A label for the property that relates assets to keywords.| + }, + 'add the missing page' => { message => q|Add the missing page.|, lastUpdated => 0, diff --git a/lib/WebGUI/i18n/English/Asset_WikiMaster.pm b/lib/WebGUI/i18n/English/Asset_WikiMaster.pm index 241f12ffc..bde1643c8 100644 --- a/lib/WebGUI/i18n/English/Asset_WikiMaster.pm +++ b/lib/WebGUI/i18n/English/Asset_WikiMaster.pm @@ -132,6 +132,10 @@ our $I18N = { lastUpdated => 1160157064, }, + 'byKeywordTemplateId hoverHelp' => { lastUpdated => 1160157064, message => q|Which template to use to display a +listing of pages that are related to a specific keyword?| }, + 'byKeywordTemplateId label' => { lastUpdated => 1160157064, message => q|By Keyword Template| }, + 'pageTemplateId hoverHelp' => { lastUpdated => 1160157064, message => q|Which template to use to display pages?| }, 'pageTemplateId label' => { lastUpdated => 1160157064, message => q|Page Template| }, diff --git a/sbin/upgrade.pl b/sbin/upgrade.pl index 2b4951771..c3525836a 100644 --- a/sbin/upgrade.pl +++ b/sbin/upgrade.pl @@ -325,6 +325,10 @@ if ($notRun) { UPGRADES COMPLETE Please restart your web server and test your sites. +WARNING: If you saw any errors in the output during the upgrade, restore +your install and databases from backup immediately. Do not continue using +your site EVEN IF IT SEEMS TO WORK. + NOTE: If you have not already done so, please consult docs/gotcha.txt for possible upgrade complications. diff --git a/t/Keyword.t b/t/Keyword.t index 40a144eb2..8214e2bf6 100644 --- a/t/Keyword.t +++ b/t/Keyword.t @@ -48,5 +48,6 @@ unlike($keyword->getKeywordsForAsset({asset=>$home }), qr/owns/, "getLatestVersi $keyword->deleteKeywordsForAsset($home); is(scalar(@{$keyword->getKeywordsForAsset({ asset=>$home, asArrayRef=>1})}), 0, "getKeywordsForAsset()"); - +undef $keyword; +undef $home;