Merge commit 'f2e0fb509a' into WebGUI8. Some tests still failing.

This commit is contained in:
Colin Kuskie 2010-06-27 22:32:31 -07:00
commit 385931aaab
92 changed files with 1966 additions and 650 deletions

View file

@ -474,13 +474,19 @@ use WebGUI::Workflow::Cron;
#-------------------------------------------------------------------
sub _computePostCount {
my $self = shift;
return scalar @{$self->getLineage(['descendants'], {includeOnlyClasses => ['WebGUI::Asset::Post']})};
return $self->getDescendantCount({
includeOnlyClasses => ['WebGUI::Asset::Post'],
statusToInclude => ['approved'],
});
}
#-------------------------------------------------------------------
sub _computeThreadCount {
my $self = shift;
return scalar @{$self->getLineage(['children'], {includeOnlyClasses => ['WebGUI::Asset::Post::Thread']})};
return $self->getChildCount({
includeOnlyClasses => ['WebGUI::Asset::Post::Thread'],
statusToInclude => ['approved'],
});
}
#-------------------------------------------------------------------
@ -1393,21 +1399,29 @@ and direction.
sub processPropertiesFromFormPost {
my $self = shift;
my $updatePrivs = ($self->session->form->process("groupIdView") ne $self->groupIdView || $self->session->form->process("groupIdEdit") ne $self->groupIdEdit);
my $updatePrivs = ($self->session->form->process("groupIdView") ne $self->groupIdView || $self->session->form->process("groupIdEdit") ne $self->groupIdEdit);
$self->next::method;
if ($self->subscriptionGroupId eq "") {
$self->createSubscriptionGroup;
}
if ($updatePrivs) {
foreach my $descendant (@{$self->getLineage(["descendants"],{returnObjects=>1})}) {
$descendant->update({
groupIdView=>$self->groupIdView,
groupIdEdit=>$self->groupIdEdit
});
}
if ($updatePrivs) {
my $descendantIter = $self->getLineageIterator(['descendants']);
while ( 1 ) {
my $descendant;
eval { $descendant = $descendantIter->() };
if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) {
$self->session->log->error($x->full_message);
next;
}
last unless $descendant;
$descendant->update({
groupIdView=>$self->groupIdView,
groupIdEdit=>$self->groupIdEdit
});
}
$self->session->scratch->delete($self->getId."_sortBy");
$self->session->scratch->delete($self->getId."_sortDir");
}
$self->session->scratch->delete($self->getId."_sortBy");
$self->session->scratch->delete($self->getId."_sortDir");
}
@ -1702,16 +1716,21 @@ sub www_unarchiveAll {
my $pb = WebGUI::ProgressBar->new($session);
my $i18n = WebGUI::International->new($session, 'Asset_Collaboration');
$pb->start($i18n->get('unarchive all'), $self->getUrl('func=edit'));
my $threadIds = $self->getLineage(['children'],{
my $threadIter = $self->getLineageIterator(['children'],{
includeOnlyClasses => [ 'WebGUI::Asset::Post::Thread' ],
statusToInclude => [ 'archived' ],
} );
ASSET: foreach my $threadId (@$threadIds) {
my $thread = WebGUI::Asset->newPending($session, $threadId);
if (!$thread || !$thread->canEdit) {
next ASSET;
ASSET: while ( 1 ) {
my $thread;
eval { $thread = $threadIter->() };
if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) {
$session->log->error($x->full_message);
next;
}
last unless $thread;
if ($thread->canEdit) {
$thread->unarchive;
}
$thread->unarchive;
}
return $pb->finish( $self->getUrl('func=edit') );
}

View file

@ -175,6 +175,45 @@ sub getContentPositionsDefault {
#-------------------------------------------------------------------
=head2 getEditForm
Extend the base method to display lists of assets to hide or show.
=cut
sub getEditForm {
my $self = shift;
my $tabform = $self->SUPER::getEditForm;
my $i18n = WebGUI::International->new($self->session, "Asset_Dashboard");
if ($self->session->form->process("func") ne "add") {
my @assetsToHide = split("\n",$self->getValue("assetsToHide"));
my $childIter = $self->getLineageIterator(["children"],{excludeClasses=>["WebGUI::Asset::Wobject::Layout"]});
my %childIds;
while ( 1 ) {
my $child;
eval { $child = $childIter->() };
if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) {
$self->session->log->error($x->full_message);
next;
}
last unless $child;
$childIds{$child->getId} = $child->getTitle.' ['.ref($child).']';
}
$tabform->getTab("display")->checkList(
-name=>"assetsToHide",
-value=>\@assetsToHide,
-options=>\%childIds,
-label=>$i18n->get('assets to hide'),
-hoverHelp=>$i18n->get('assets to hide description'),
-vertical=>1,
-uiLevel=>9
);
}
return $tabform;
}
#-------------------------------------------------------------------
=head2 initialize
Add the unique profile field that holds content positions for this dashboard.
@ -218,18 +257,25 @@ their templates.
=cut
sub prepareView {
override prepareView => sub {
my $self = shift;
$self->SUPER::prepareView;
my $children = $self->getLineage( ["children"], { returnObjects=>1, excludeClasses=>["WebGUI::Asset::Wobject::Layout","WebGUI::Asset::Wobject::Dashboard"] });
super();
my @hidden = split("\n",$self->assetsToHide);
foreach my $child (@{$children}) {
my $childIter = $self->getLineageIterator( ["children"], {excludeClasses=>["WebGUI::Asset::Wobject::Layout","WebGUI::Asset::Wobject::Dashboard"] });
while ( 1 ) {
my $child;
eval { $child = $childIter->() };
if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) {
$self->session->log->error($x->full_message);
next;
}
last unless $child;
unless (isIn($child->getId, @hidden) || !($child->canView)) {
$self->session->style->setRawHeadTags($child->getExtraHeadTags);
$child->prepareView;
}
}
}
};
#-------------------------------------------------------------------
@ -286,8 +332,9 @@ sub view {
$self->session->style->setScript( $self->session->url->extras('yui/build/utilities/utilities.js'));
my $templateId = $self->templateId;
my $children = $self->getLineage( ["children"], { returnObjects=>1, excludeClasses=>["WebGUI::Asset::Wobject::Layout","WebGUI::Asset::Wobject::Dashboard"] });
# XXX Not using getLineageIterator because we loop over the children three times...
# I'm sure there's a more efficient way to do this. We'll figure it out someday.
my $children = $self->getLineage( ["children"], { returnObjects=>1, excludeClasses=>["WebGUI::Asset::Wobject::Layout","WebGUI::Asset::Wobject::Dashboard"] });
my @positions = split(/\./,$self->getContentPositions);
my @hidden = split("\n",$self->assetsToHide);
foreach my $child (@{$children}) {

View file

@ -615,10 +615,10 @@ returns true if the EMS has subission forms attached
sub hasSubmissionForms {
my $self = shift;
# are there ~any~ forms attached to this ems?
my $res = $self->getLineage(['children'],{ limit => 1,
my $count = $self->getDescendantCount({
includeOnlyClasses => ['WebGUI::Asset::EMSSubmissionForm'],
} );
return scalar(@$res);
return $count;
}
#-------------------------------------------------------------------
@ -1046,12 +1046,12 @@ then call www_editSubmission on it
sub www_editSubmission {
my $self = shift;
my $submissionId = $self->session->form->get('submissionId');
my $asset = $self->getLineage(['descendants'], { returnObjects => 1,
my $asset = $self->getLineageIterator(['descendants'], {
joinClass => "WebGUI::Asset::EMSSubmission",
whereClause => 'submissionId = ' . int($submissionId),
includeOnlyClasses => ['WebGUI::Asset::EMSSubmission'],
} );
return $asset->[0]->www_editSubmission;
return $asset->()->www_editSubmission;
}
@ -1397,6 +1397,7 @@ sub www_getBadgesAsJson {
my ($db, $form) = $session->quick(qw(db form));
my %results = ();
$results{records} = [];
# TODO: Use getLineageIterator here instead
BADGE: foreach my $badge (@{$self->getBadges}) {
next BADGE unless $badge->canView;
push(@{$results{records}}, {
@ -1965,7 +1966,8 @@ sub www_getTokensAsJson {
my ($db, $form) = $session->quick(qw(db form));
my %results = ();
$results{records} = []; ##Initialize to an empty array
foreach my $token (@{$self->getTokens}) {
TOKEN: foreach my $token (@{$self->getTokens}) {
next TOKEN unless $token->canView;
push(@{$results{records}}, {
title => $token->getTitle,
description => $token->description,

View file

@ -104,7 +104,15 @@ Overridden to check the revision dates of children as well
sub getContentLastModified {
my $self = shift;
my $mtime = $self->revisionDate;
foreach my $child (@{ $self->getLineage(["children"],{returnObjects=>1}) }) {
my $childIter = $self->getLineageIterator(["children"]);
while ( 1 ) {
my $child;
eval { $child = $childIter->() };
if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) {
$self->session->log->error($x->full_message);
next;
}
last unless $child;
my $child_mtime = $child->getContentLastModified;
$mtime = $child_mtime if ($child_mtime > $mtime);
}
@ -216,17 +224,24 @@ sub view {
my $vars = $self->getTemplateVars;
# TODO: Getting the children template vars should be a seperate method.
my %rules = ( returnObjects => 1);
my %rules = ( );
if ( $self->sortAlphabetically ) {
$rules{ orderByClause } = "assetData.title " . $self->sortOrder;
$rules{ orderByClause } = "assetData.title " . $self->get( "sortOrder" );
}
else {
$rules{ orderByClause } = "asset.lineage " . $self->sortOrder;
}
my $children = $self->getLineage( ["children"], \%rules);
foreach my $child ( @{ $children } ) {
# TODO: Instead of this it should be using $child->getTemplateVars || $child->get
my $childIter = $self->getLineageIterator( ["children"], \%rules);
while ( 1 ) {
my $child;
eval { $child = $childIter->() };
if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) {
$self->session->log->error($x->full_message);
next;
}
last unless $child;
# TODO: Instead of this it should be using $child->getTemplateVars || $child->get
if ( $child->isa("WebGUI::Asset::Wobject::Folder") ) {
push @{ $vars->{ "subfolder_loop" } }, {
id => $child->getId,

View file

@ -325,8 +325,8 @@ with 'WebGUI::Role::Asset::RssFeed';
use JSON;
use Tie::IxHash;
use WebGUI::International;
use WebGUI::Search;
use XML::Simple;
use WebGUI::HTML;
@ -388,7 +388,13 @@ sub appendTemplateVarsSearchForm {
name => "keywords",
value => scalar $form->get("keywords"),
});
$var->{ searchForm_location }
= WebGUI::Form::text( $session, {
name => "location",
value => $form->get("location"),
});
# Search classes
tie my %searchClassOptions, 'Tie::IxHash', (
'WebGUI::Asset::File::GalleryFile::Photo' => $i18n->get("search class photo"),
@ -763,6 +769,7 @@ Other keys are valid, see C<WebGUI::Search::search()> for details.
sub getSearchPaginator {
my $self = shift;
my $rules = shift;
my $session = $self->session;
$rules->{ lineage } = [ $self->lineage ];
@ -913,17 +920,21 @@ sub hasSpaceAvailable {
# Compile the amount of disk space used
my $maxSpace = $self->maxSpacePerUser * ( 1_024 ** 2 ); # maxSpacePerUser is in MB
my $spaceUsed = 0;
my $fileIds
= $self->getLineage( [ 'descendants' ], {
my $fileIter
= $self->getLineageIterator( [ 'descendants' ], {
joinClass => 'WebGUI::Asset::File::GalleryFile',
whereClause => 'ownerUserId = ' . $db->quote( $userId ),
} );
for my $assetId ( @{ $fileIds } ) {
my $asset = WebGUI::Asset->newById( $self->session, $assetId );
next unless $asset;
$spaceUsed += $asset->assetSize;
while ( 1 ) {
my $file;
eval { $file = $fileIter->() };
if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) {
$self->session->log->error($x->full_message);
next;
}
last unless $file;
$spaceUsed += $file->get( 'assetSize' );
return 0 if ( $spaceUsed + $spaceWanted >= $maxSpace );
}
@ -1340,45 +1351,61 @@ sub www_listAlbumsService {
return JSON->new->pretty->encode($document);
}
#----------------------------------------------------------------------------
=head2 www_search ( )
=head2 search ( )
Search through the GalleryAlbums and files in this gallery. Show the form to
search and display the results if necessary.
Helper method for C<www_search> containing all the search logic. Executes a
search depending on search form parameters. Returns undef if no search was
executed. Otherwise an array is returned containing the following elements:
=head3 paginator
A paginator object containing the search results.
=head3 keywords
Search keywords assembled from search form fields.
=cut
sub www_search {
sub search {
my $self = shift;
my $session = $self->session;
my $form = $session->form;
my $db = $session->db;
my $columns;
my $var = $self->getTemplateVars;
# NOTE: Search form is added as part of getTemplateVars()
# Get search results, if necessary.
# Check whether we have to do a search
my $doSearch
= (
$form->get( 'basicSearch' ) || $form->get( 'keywords' )
|| $form->get( 'title' ) || $form->get( 'description' )
|| $form->get( 'userId' ) || $form->get( 'className' )
|| $form->get( 'creationDate_after' ) || $form->get( 'creationDate_before' )
$form->get( 'basicSearch' ) || $form->get( 'keywords' )
|| $form->get( 'location' ) || $form->get( 'title' )
|| $form->get( 'description' ) || $form->get( 'userId' )
|| $form->get( 'className' ) || $form->get( 'creationDate_after' )
|| $form->get( 'creationDate_before' )
);
if ( $doSearch ) {
# Keywords to search on
# Do not add a space to the
if ( $doSearch ) {
# Keywords to search on.
my $keywords;
FORMVAR: foreach my $formVar (qw/ basicSearch keywords title description /) {
FORMVAR: foreach my $formVar (qw/ basicSearch keywords location title description /) {
my $var = $form->get($formVar);
next FORMVAR unless $var;
$keywords = join ' ', $keywords, $var;
}
# Remove leading whitespace
$keywords =~ s/^\s+//;
# Build a where clause from the advanced options
# Lineage search can capture gallery
# Note that adding criteria to the where clause alone will not work. If
# you want to cover additional properties you need to make sure that
# - the property is added to $keywords above
# - the property is included in index keywords by overriding the indexContent method of respective classes (usually Photo or GalleryFile)
# - the respective table is joined in (usually via joinClass parameter of getSearchPaginator)
# - the column containing the property is included in the query (usually via column parameter of getSearchPaginator)
my $where = q{assetIndex.assetId <> '} . $self->getId . q{'};
if ( $form->get("title") ) {
$where .= q{ AND assetData.title LIKE }
@ -1390,11 +1417,18 @@ sub www_search {
. $db->quote( '%' . $form->get("description") . '%' )
;
}
if ( $form->get("location") && ( $form->get("className") eq 'WebGUI::Asset::File::GalleryFile::Photo'
|| $form->get("className") eq '' ) ) {
$where .= q{ AND Photo.location LIKE }
. $db->quote( '%' . $form->get("location") . '%' )
;
push (@{$columns}, 'Photo.location');
}
if ( $form->get("userId") ) {
$where .= q{ AND assetData.ownerUserId = }
. $db->quote( $form->get("userId") )
;
}
}
my $oneYearAgo = WebGUI::DateTime->new( $session, time )->add( years => -1 )->epoch;
my $dateAfter = $form->get("creationDate_after", "dateTime", $oneYearAgo);
@ -1408,45 +1442,75 @@ sub www_search {
}
# Classes
my $joinClass = [
my $classes = [
'WebGUI::Asset::Wobject::GalleryAlbum',
'WebGUI::Asset::File::GalleryFile::Photo',
];
if ( $form->get("className") ) {
$joinClass = [ $form->get('className') ];
$classes = [ $form->get('className') ];
}
$where .= q{ AND assetIndex.className IN ( } . $db->quoteAndJoin( $joinClass ) . q{ ) };
# Build a URL for the pagination
my $url
= $self->getUrl(
'func=search;'
. 'basicSearch=' . $form->get('basicSearch') . ';'
. 'keywords=' . $form->get('keywords') . ';'
. 'location=' . $form->get('location') . ';'
. 'title=' . $form->get('title') . ';'
. 'description=' . $form->get('description') . ';'
. 'creationDate_after=' . $dateAfter . ';'
. 'creationDate_before=' . $dateBefore . ';'
. 'userId=' . $form->get("userId") . ';'
);
for my $class ( @$joinClass ) {
for my $class ( @$classes ) {
$url .= 'className=' . $class . ';';
}
my $p
my $paginator
= $self->getSearchPaginator( {
url => $url,
keywords => $keywords,
where => $where,
joinClass => $joinClass,
classes => $classes,
joinClass => $classes,
columns => $columns,
creationDate => $creationDate,
} );
} );
return ( $paginator, $keywords );
}
# Return undef to indicate that no search was executed
return undef;
}
#----------------------------------------------------------------------------
=head2 www_search ( )
Search through the GalleryAlbums and files in this gallery. Show the form to
search and display the results if necessary.
=cut
sub www_search {
my $self = shift;
my $session = $self->session;
my $var = $self->getTemplateVars;
# NOTE: Search form is added as part of getTemplateVars()
# Execute search and retrieve search result paginator and keywords
my ( $paginator, $keywords ) = $self->search;
if( $paginator ) {
# Provide search keywords as template variable
$var->{ keywords } = $keywords;
$p->appendTemplateVars( $var );
for my $result ( @{ $p->getPageData } ) {
# Add search results
$paginator->appendTemplateVars( $var );
for my $result ( @{ $paginator->getPageData } ) {
my $asset = WebGUI::Asset->newById( $session, $result->{assetId} );
push @{ $var->{search_results} }, {
%{ $asset->getTemplateVars },

View file

@ -1438,9 +1438,9 @@ sub www_edit {
elsif ( grep { $_ =~ /^rotateLeft-(.{22})$/ } $form->param ) {
my $assetId = ( grep { $_ =~ /^rotateLeft-(.{22})$/ } $form->param )[0];
$assetId =~ s/^rotateLeft-//;
my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId );
my $asset = eval { WebGUI::Asset->newById( $session, $assetId ); };
if ( $asset ) {
if ( ! Exception::Class->caught() ) {
# Add revision and create a new version tag by doing so
my $newRevision = $asset->addRevision;
# Rotate photo (i.e. all attached image files) by 90° CCW
@ -1456,9 +1456,9 @@ sub www_edit {
elsif ( grep { $_ =~ /^rotateRight-(.{22})$/ } $form->param ) {
my $assetId = ( grep { $_ =~ /^rotateRight-(.{22})$/ } $form->param )[0];
$assetId =~ s/^rotateRight-//;
my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId );
my $asset = WebGUI::Asset->newById( $session, $assetId );
if ( $asset ) {
if ( Exception::Class->caught() ) {
# Add revision and create a new version tag by doing so
my $newRevision = $asset->addRevision;
# Rotate photo (i.e. all attached image files) by 90° CW

View file

@ -160,9 +160,16 @@ override getEditForm => sub {
}
else {
my @assetsToHide = split("\n",$self->assetsToHide);
my $children = $self->getLineage(["children"],{"returnObjects"=>1, excludeClasses=>["WebGUI::Asset::Wobject::Layout"]});
my $childIter = $self->getLineageIterator(["children"],{excludeClasses=>["WebGUI::Asset::Wobject::Layout"]});
my %childIds;
foreach my $child (@{$children}) {
while ( 1 ) {
my $child;
eval { $child = $childIter->() };
if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) {
$self->session->log->error($x->full_message);
next;
}
last unless $child;
$childIds{$child->getId} = $child->getTitle;
}
$extraFields{assetsToHide} = {
@ -236,11 +243,18 @@ sub prepareView {
my %placeHolder;
my @children;
for my $child ( @{ $self->getLineage( ["children"], {
returnObjects => 1,
my $childIter = $self->getLineageIterator( ["children"], {
excludeClasses => ["WebGUI::Asset::Wobject::Layout"],
} ) } ) {
} );
while ( 1 ) {
my $child;
eval { $child = $childIter->() };
if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) {
$session->log->error($x->full_message);
next;
}
last unless $child;
my $assetId = $child->getId;
next
if ($hidden{$assetId} || ! $child->canView);
@ -393,7 +407,15 @@ override getContentLastModified => sub {
# Buggo: this is a little too conservative. Children that are hidden maybe shouldn't count. Hm.
my $self = shift;
my $mtime = super();
foreach my $child (@{$self->getLineage(["children"],{returnObjects=>1, excludeClasses=>['WebGUI::Asset::Wobject::Layout']})}) {
my $childIter = $self->getLineageIterator(["children"],{excludeClasses=>['WebGUI::Asset::Wobject::Layout']});
while ( 1 ) {
my $child;
eval { $child = $childIter->() };
if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) {
$self->session->log->error($x->full_message);
next;
}
last unless $child;
my $child_mtime = $child->getContentLastModified;
$mtime = $child_mtime if ($child_mtime > $mtime);
}

View file

@ -300,11 +300,17 @@ sub deleteAttribute {
[$attributeId,$self->getId]);
# recalculate scores for MatrixListings
my @listings = @{ $self->getLineage(['descendants'], {
my $listingIter = $self->getLineageIterator(['descendants'], {
includeOnlyClasses => ['WebGUI::Asset::MatrixListing'],
returnObjects => 1,
}) };
foreach my $listing (@listings){
});
while ( 1 ) {
my $listing;
eval { $listing = $listingIter->() };
if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) {
$self->session->log->error($x->full_message);
next;
}
last unless $listing;
$listing->updateScore;
}
@ -618,17 +624,23 @@ sub view {
if ($self->canEdit){
# Get all the MatrixListings that are still pending.
my @pendingListings = @{ $self->getLineage(['descendants'], {
my $pendingIter = $self->getLineageIterator(['descendants'], {
includeOnlyClasses => ['WebGUI::Asset::MatrixListing'],
orderByClause => "revisionDate asc",
returnObjects => 1,
statusToInclude => ['pending'],
}) };
foreach my $pendingListing (@pendingListings){
});
while ( 1 ) {
my $pending;
eval { $pending = $pendingIter->() };
if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) {
$session->log->error($x->full_message);
next;
}
last unless $pending;
push (@{ $var->{pending_loop} }, {
url => $pendingListing->getUrl
."?func=view;revision=".$pendingListing->revisionDate,
name => $pendingListing->title,
url => $pending->getUrl
."?func=view;revision=".$pending->revisionDate,
name => $pending->title,
});
}
}
@ -705,18 +717,23 @@ sub view {
# Get the 5 MatrixListings that were last updated as objects using getLineage.
my @lastUpdatedListings = @{ $self->getLineage(['descendants'], {
my $lastUpdatedIter = $self->getLineageIterator(['descendants'], {
includeOnlyClasses => ['WebGUI::Asset::MatrixListing'],
joinClass => "WebGUI::Asset::MatrixListing",
orderByClause => "lastUpdated desc",
limit => 5,
returnObjects => 1,
}) };
foreach my $lastUpdatedListing (@lastUpdatedListings){
});
for ( 1..5 ) {
my $lastUpdated;
eval { $lastUpdated = $lastUpdatedIter->() };
if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) {
$session->log->error($x->full_message);
next;
}
last unless $lastUpdated;
push (@{ $varStatistics->{last_updated_loop} }, {
url => $lastUpdatedListing->getUrl,
name => $lastUpdatedListing->title,
lastUpdated => $session->datetime->epochToHuman($lastUpdatedListing->lastUpdated,"%z")
url => $lastUpdated->getUrl,
name => $lastUpdated->title,
lastUpdated => $session->datetime->epochToHuman($lastUpdated->lastUpdated,"%z")
});
}
$varStatistics->{lastUpdated_sortButton} = "<span id='sortByUpdated'><button type='button'>"

View file

@ -96,8 +96,15 @@ sub view {
my $first;
my @forum_loop;
my $i18n = WebGUI::International->new($self->session,"Asset_MessageBoard");
my $children = $self->getLineage(["children"],{includeOnlyClasses=>["WebGUI::Asset::Wobject::Collaboration"],returnObjects=>1});
foreach my $child (@{$children}) {
my $childIter = $self->getLineageIterator(["children"],{includeOnlyClasses=>["WebGUI::Asset::Wobject::Collaboration"]});
while ( 1 ) {
my $child;
eval { $child = $childIter->() };
if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) {
$self->session->log->error($x->full_message);
next;
}
last unless $child;
$count++;
next unless ($child->canView);
if ($count == 1) {

View file

@ -369,44 +369,49 @@ sub view {
# we've got to determine what our start point is based upon user conditions
my $start;
$self->session->asset(WebGUI::Asset->newByUrl($self->session)) unless ($self->session->asset);
my $current = $self->session->asset;
my $var = {'page_loop' => []};
my $current = $self->session->asset;
# no current asset is set
unless (defined $current) {
$current = WebGUI::Asset->getDefault($self->session);
}
my @interestingProperties = ('assetId', 'parentId', 'ownerUserId', 'synopsis', 'newWindow');
# Add properties from current asset
foreach my $property (@interestingProperties) {
$var->{'currentPage.'.$property} = $current->$property;
}
$var->{'currentPage.menuTitle'} = $current->getMenuTitle;
$var->{'currentPage.title'} = $current->getTitle;
$var->{'currentPage.isHome'} = ($current->getId eq $self->session->setting->get("defaultPage"));
$var->{'currentPage.url'} = $current->getUrl;
$var->{'currentPage.hasChild'} = $current->hasChildren;
$var->{'currentPage.rank'} = $current->getRank;
$var->{'currentPage.rankIs'.$current->getRank} = 1;
# Build the asset tree
if ($self->startType eq "specificUrl") {
$start = WebGUI::Asset->newByUrl($self->session,$self->startPoint);
} elsif ($self->startType eq "relativeToRoot") {
}
elsif ($self->startType eq "relativeToRoot") {
unless (($self->startPoint+1) >= $current->getLineageLength) {
$start = WebGUI::Asset->newByLineage($self->session,substr($current->lineage,0, ($self->startPoint + 1) * 6));
}
} elsif ($self->startType eq "relativeToCurrentUrl") {
}
elsif ($self->startType eq "relativeToCurrentUrl") {
$start = WebGUI::Asset->newByLineage($self->session,substr($current->lineage,0, ($current->getLineageLength + $self->startPoint) * 6));
}
$start = $current unless (defined $start); # if none of the above results in a start point, then the current page must be it
my @includedRelationships = split("\n",$self->assetsToInclude);
my %rules;
$rules{returnObjects} = 1;
$rules{endingLineageLength} = $start->getLineageLength+$self->descendantEndPoint;
$rules{assetToPedigree} = $current if (isIn("pedigree",@includedRelationships));
$rules{ancestorLimit} = $self->ancestorEndPoint;
$rules{orderByClause} = 'rpad(asset.lineage, 255, 9) desc' if ($self->reversePageLoop);
my @interestingProperties = ('assetId', 'parentId', 'ownerUserId', 'synopsis', 'newWindow');
my $assets = $start->getLineage(\@includedRelationships,\%rules);
my $var = {'page_loop' => []};
foreach my $property (@interestingProperties) {
$var->{'currentPage.'.$property} = $current->$property;
}
$var->{'currentPage.menuTitle'} = $current->getMenuTitle;
$var->{'currentPage.title'} = $current->getTitle;
$var->{'currentPage.isHome'} = ($current->getId eq $self->session->setting->get("defaultPage"));
$var->{'currentPage.url'} = $current->getUrl;
$var->{'currentPage.hasChild'} = $current->hasChildren;
$var->{'currentPage.rank'} = $current->getRank;
$var->{'currentPage.rankIs'.$current->getRank} = 1;
my $currentLineage = $current->lineage;
my $lineageToSkip = "noskip";
my $absoluteDepthOfLastPage;
@ -414,8 +419,7 @@ sub view {
my %lastChildren;
my $previousPageData = undef;
my $eh = $self->session->errorHandler;
foreach my $asset (@{$assets}) {
while ( my $asset = $assets->() ) {
# skip pages we shouldn't see
my $pageLineage = $asset->lineage;
next if ($pageLineage =~ m/^$lineageToSkip/);

View file

@ -266,12 +266,20 @@ sub view {
# get other shelves
my @childShelves = ();
SHELF: foreach my $child (@{$self->getLineage(['children'],{returnObjects=>1,includeOnlyClasses=>['WebGUI::Asset::Wobject::Shelf']})}) {
my $childIter = $self->getLineageIterator(['children'],{includeOnlyClasses=>['WebGUI::Asset::Wobject::Shelf']});
SHELF: while ( 1 ) {
my $child;
eval { $child = $childIter->() };
if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) {
$session->log->error($x->full_message);
next;
}
last unless $child;
next SHELF unless $child->canView;
my $properties = $child->get;
$child->{url} = $child->getUrl;
$child->{title} = $child->getTitle;
push @childShelves, $child;
$properties->{url} = $child->getUrl;
$properties->{title} = $child->getTitle;
push @childShelves, $properties;
}
# get other child skus

View file

@ -369,14 +369,21 @@ for generating an RSS and Atom feeds.
sub getRssFeedItems {
my $self = shift;
my $stories = $self->getLineageIterator(['descendants'],{
my $storyIter = $self->getLineageIterator(['descendants'],{
excludeClasses => ['WebGUI::Asset::Wobject::Folder'],
orderByClause => 'creationDate desc, lineage',
returnObjects => 1,
limit => $self->itemsPerFeed,
});
my $storyData = [];
while (my $story = $stories->()) {
while ( 1 ) {
my $story;
eval { $story = $storyIter->() };
if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) {
$self->session->log->error($x->full_message);
next;
}
last unless $story;
push @{ $storyData }, $story->getRssData;
}
return $storyData;

View file

@ -280,17 +280,19 @@ sub getTemplateVariables {
$item{guid} = WebGUI::HTML::filter(scalar $object->guid, 'javascript');
$item{link} = WebGUI::HTML::filter(scalar $object->link, 'javascript');
my $description = WebGUI::HTML::filter(scalar($object->description), 'javascript');
my $raw_description = WebGUI::HTML::filter($description, 'all');
$raw_description =~ s/^\s+//s;
$item{description} = defined $description ? $description : '';
$item{descriptionFirst100words} = $item{description};
$item{descriptionFirst100words} =~ s/(((\S+)\s+){100}).*/$1/s;
$item{descriptionFirst100words} = $raw_description;
$item{descriptionFirst100words} =~ s/(((\S+)\s+){1,100}).*/$1/ms;
$item{descriptionFirst75words} = $item{descriptionFirst100words};
$item{descriptionFirst75words} =~ s/(((\S+)\s+){75}).*/$1/s;
$item{descriptionFirst75words} =~ s/(((\S+)\s+){1,75}).*/$1/ms;
$item{descriptionFirst50words} = $item{descriptionFirst75words};
$item{descriptionFirst50words} =~ s/(((\S+)\s+){50}).*/$1/s;
$item{descriptionFirst50words} =~ s/(((\S+)\s+){1,50}).*/$1/ms;
$item{descriptionFirst25words} = $item{descriptionFirst50words};
$item{descriptionFirst25words} =~ s/(((\S+)\s+){25}).*/$1/s;
$item{descriptionFirst25words} =~ s/(((\S+)\s+){1,25}).*/$1/ms;
$item{descriptionFirst10words} = $item{descriptionFirst25words};
$item{descriptionFirst10words} =~ s/(((\S+)\s+){10}).*/$1/s;
$item{descriptionFirst10words} =~ s/(((\S+)\s+){1,10}).*/$1/ms;
if ($description =~ /<p>/) {
my $html = $description;
$html =~ tr/\n/ /s;
@ -304,12 +306,12 @@ sub getTemplateVariables {
$item{descriptionFirstParagraph} = $item{descriptionFirst2paragraphs};
$item{descriptionFirstParagraph} =~ s/^(.*?\n).*/$1/s;
}
$item{descriptionFirst4sentences} = $item{description};
$item{descriptionFirst4sentences} =~ s/^((.*?\.){4}).*/$1/s;
$item{descriptionFirst4sentences} = $raw_description;
$item{descriptionFirst4sentences} =~ s/^((.*?\.){1,4}).*/$1/s;
$item{descriptionFirst3sentences} = $item{descriptionFirst4sentences};
$item{descriptionFirst3sentences} =~ s/^((.*?\.){3}).*/$1/s;
$item{descriptionFirst3sentences} =~ s/^((.*?\.){1,3}).*/$1/s;
$item{descriptionFirst2sentences} = $item{descriptionFirst3sentences};
$item{descriptionFirst2sentences} =~ s/^((.*?\.){2}).*/$1/s;
$item{descriptionFirst2sentences} =~ s/^((.*?\.){1,2}).*/$1/s;
$item{descriptionFirstSentence} = $item{descriptionFirst2sentences};
$item{descriptionFirstSentence} =~ s/^(.*?\.).*/$1/s;
push @{$var{item_loop}}, \%item;

View file

@ -3299,18 +3299,20 @@ sequenceNumber');
$self->session->cache->set("query_".$thingId, $query, 30*60);
$paginatePage = $self->session->form->param('pn') || 1;
$currentUrl = $self->session->url->append($currentUrl, "orderBy=".$orderBy) if $orderBy;
$currentUrl = $self->session->url->append($currentUrl, "orderBy=".$orderBy) if $orderBy;
$p = WebGUI::Paginator->new($self->session,$currentUrl,$thingProperties->{thingsPerPage}, undef, $paginatePage);
my $sth = $self->session->db->read($query) if ! $noFields;
my @visibleResults;
while (my $result = $sth->hashRef){
if ($self->canViewThingData($thingId,$result->{thingDataId})){
push(@visibleResults,$result);
if (! $noFields) {
my $sth = $self->session->db->read($query) if ! $noFields;
while (my $result = $sth->hashRef){
if ($self->canViewThingData($thingId,$result->{thingDataId})){
push(@visibleResults,$result);
}
}
}
$p->setDataByArrayRef(\@visibleResults) if ! $noFields;
$p->setDataByArrayRef(\@visibleResults);
$searchResults = $p->getPageData($paginatePage);
foreach my $searchResult (@$searchResults){

View file

@ -253,15 +253,19 @@ sub appendMostPopular {
my $self = shift;
my $var = shift;
my $limit = shift || $self->get("mostPopularCount");
foreach my $asset (@{$self->getLineage(["children"],{returnObjects=>1, limit=>$limit, includeOnlyClasses=>["WebGUI::Asset::WikiPage"], joinClass => 'WebGUI::Asset::WikiPage', orderByClause => 'WikiPage.views DESC'})}) {
if (defined $asset) {
my $assetIter = $self->getLineageIterator(["children"],{limit=>$limit, includeOnlyClasses=>["WebGUI::Asset::WikiPage"], joinClass => 'WebGUI::Asset::WikiPage', orderByClause => 'WikiPage.views DESC'});
while ( 1 ) {
my $asset;
eval { $asset = $assetIter->() };
if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) {
$self->session->log->error($x->full_message);
next;
}
last unless $asset;
push(@{$var->{mostPopular}}, {
title=>$asset->getTitle,
url=>$asset->getUrl,
});
} else {
$self->session->errorHandler->error("Couldn't instanciate wikipage for master ".$self->getId);
}
}
}
@ -729,20 +733,31 @@ Extend the master method to propagate view and edit permissions down to the wiki
=cut
sub processPropertiesFromFormPost {
override processPropertiesFromFormPost => sub {
my $self = shift;
my $groupsChanged =
(($self->session->form->process('groupIdView') ne $self->groupIdView)
or ($self->session->form->process('groupIdEdit') ne $self->groupIdEdit));
my $ret = $self->next::method(@_);
my $ret = super();
if ($groupsChanged) {
foreach my $child (@{$self->getLineage(['children'], {returnObjects => 1})}) {
$child->update({ groupIdView => $self->groupIdView,
groupIdEdit => $self->groupIdEdit });
# XXX Should this do descendants for WikiPage attachments?
my $childIter = $self->getLineageIterator(['children']);
while ( 1 ) {
my $child;
eval { $child = $childIter->() };
if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) {
$self->session->log->error($x->full_message);
next;
}
last unless $child;
$child->update({
groupIdView => $self->get('groupIdView'),
groupIdEdit => $self->get('groupIdEdit')
});
}
}
return $ret;
}
};
#-------------------------------------------------------------------