diff --git a/lib/WebGUI/Asset.pm b/lib/WebGUI/Asset.pm index cf26a2b28..d58332b7c 100644 --- a/lib/WebGUI/Asset.pm +++ b/lib/WebGUI/Asset.pm @@ -845,6 +845,25 @@ sub getAssetsInTrash { +#------------------------------------------------------------------- + +=head2 getContainer () + +Returns a reference to the container asset. If this asset is a container it returns a reference to itself. If this asset is not attached to a container it returns its parent. + +=cut + +sub getContainer { + my $self = shift; + if (WebGUI::Utility::isIn(ref $self, @{$session{config}{assetContainers}})) { + return $self; + } else { + $session{asset} = $self->getParent; + return $self->getParent; + } +} + + #------------------------------------------------------------------- =head2 getEditForm ( ) @@ -2065,6 +2084,7 @@ sub www_add { startDate => $self->get("startDate"), endDate => $self->get("endDate") ); + $properties{isHidden} = 1 unless (WebGUI::Utility::isIn(ref $session{form}{class}, @{$session{config}{assetContainers}})); my $newAsset = WebGUI::Asset->newByDynamicClass("new",$session{form}{class},\%properties); return $newAsset->www_edit(); } @@ -2082,7 +2102,7 @@ sub www_copy { return $self->getAdminConsole->render(WebGUI::Privilege::insufficient()) unless $self->canEdit; my $newAsset = $self->duplicate; $newAsset->cut; - return ""; + return $self->getContainer->www_view; } #------------------------------------------------------------------- @@ -2204,7 +2224,7 @@ sub www_demote { my $self = shift; return $self->getAdminConsole->render(WebGUI::Privilege::insufficient()) unless $self->canEdit; $self->demote; - return ""; + return $self->getContainer->www_view; } #------------------------------------------------------------------- @@ -2941,7 +2961,7 @@ sub www_promote { my $self = shift; return $self->getAdminConsole->render(WebGUI::Privilege::insufficient()) unless $self->canEdit; $self->promote; - return ""; + return $self->getContainer->www_view; } diff --git a/lib/WebGUI/Asset/Wobject/Layout.pm b/lib/WebGUI/Asset/Wobject/Layout.pm index 32e21c05a..a9c44cf3d 100644 --- a/lib/WebGUI/Asset/Wobject/Layout.pm +++ b/lib/WebGUI/Asset/Wobject/Layout.pm @@ -142,7 +142,7 @@ sub getUiLevel { #------------------------------------------------------------------- sub view { my $self = shift; - my $children = $self->getLineage( ["children"], { returnObjects=>1 }); + my $children = $self->getLineage( ["children"], { returnObjects=>1, excludeClasses=>["WebGUI::Asset::Wobject::Layout"] }); my %vars; # I'm sure there's a more efficient way to do this. We'll figure it out someday. my @positions = split(/\./,$self->get("contentPositions")); @@ -165,19 +165,11 @@ sub view { } # deal with unplaced children foreach my $child (@{$children}) { - if (ref $child eq "WebGUI::Asset::Wobject::Layout") { - push(@{$vars{"sublayout_loop"}}, { - id => $child->getId, - url => $child->getUrl, - title => $child->get("title") + unless (isIn($child->getId, @found)) { + push(@{$vars{"position1_loop"}},{ + id=>$child->getId, + content=>$child->view }); - } else { - unless (isIn($child->getId, @found)) { - push(@{$vars{"position1_loop"}},{ - id=>$child->getId, - content=>$child->view - }); - } } } $vars{showAdmin} = ($session{var}{adminOn} && $self->canEdit);