Fixed: One can now turn off inheritUrlFromParent, and the code is now more
robust: moved from Asset->update to Asset->fixUrl.
This commit is contained in:
parent
d387536807
commit
05cf8fa24c
3 changed files with 22 additions and 35 deletions
|
|
@ -4,6 +4,8 @@
|
|||
- fixed: Thingy Data now retains File and Images if they aren't explicitly deleted
|
||||
- fixed: Rich Editor no longer makes other form controls show up as code in Safari 3
|
||||
- fixed: Shop->hasShippingAddress help grammatical error
|
||||
- fixed: can now turn off inheritUrlFromParent and the code is now more
|
||||
robust, moved from Asset->update to Asset->fixUrl.
|
||||
|
||||
7.5.13
|
||||
- fixed: storage locations for some assets in packages not imported correctly
|
||||
|
|
|
|||
|
|
@ -598,6 +598,16 @@ sub fixUrl {
|
|||
}
|
||||
$url = $self->session->url->urlize($url);
|
||||
|
||||
# if we're inheriting the URL from our parent, set that appropriately
|
||||
if($self->get('inheritUrlFromParent')) {
|
||||
my @parts = split(m{/},$url);
|
||||
|
||||
# don't do anything unless we need to
|
||||
if("/$url" ne $self->getParent->getUrl . '/' . $parts[-1]) {
|
||||
$url = $self->getParent->getUrl . '/' . $parts[-1];
|
||||
}
|
||||
}
|
||||
|
||||
# fix urls used by uploads and extras
|
||||
# and those beginning with http
|
||||
my @badUrls = (
|
||||
|
|
@ -2006,38 +2016,6 @@ sub update {
|
|||
next;
|
||||
}
|
||||
|
||||
# similarly, if this is the new-to-7.5 inheritUrlFromParent field,
|
||||
# do the same.
|
||||
if($property eq 'inheritUrlFromParent') {
|
||||
next unless $properties->{inheritUrlFromParent} == 1;
|
||||
|
||||
# if we're still here, we have the property in the DB. so process it.
|
||||
# only prepend the URL once
|
||||
my $parentUrl = $self->getParent->getUrl;
|
||||
|
||||
# handle either being passed a new URL or updating the current one
|
||||
my $currentUrl;
|
||||
if(exists $properties->{url}) {
|
||||
$currentUrl = $properties->{url};
|
||||
}
|
||||
else {
|
||||
$currentUrl = $self->getUrl;
|
||||
}
|
||||
|
||||
# if there's only one / then leave it alone.
|
||||
unless($currentUrl =~ tr{/}{} == 1) {
|
||||
$currentUrl =~ s{/[^/]+$}{};
|
||||
}
|
||||
|
||||
# prepend if it's not a match
|
||||
my $newUrl = $currentUrl;
|
||||
if($currentUrl ne $parentUrl) {
|
||||
$newUrl = $parentUrl . '/' . $currentUrl;
|
||||
}
|
||||
|
||||
# replace the non-prepended value in the properties hash with this value
|
||||
$self->{_properties}{url} = $newUrl;
|
||||
}
|
||||
|
||||
# use the update value
|
||||
my $value = $properties->{$property};
|
||||
|
|
@ -2568,7 +2546,7 @@ sub outputWidgetMarkup {
|
|||
my $storage = WebGUI::Storage->get($session, $assetId);
|
||||
my $content = $self->view;
|
||||
WebGUI::Macro::process($session, \$content);
|
||||
my $jsonContent = objToJson( { "asset$assetId" => { content => $content } } );
|
||||
my $jsonContent = to_json( { "asset$assetId" => { content => $content } } );
|
||||
$storage->addFileFromScalar("$assetId.js", "data = $jsonContent");
|
||||
my $jsonUrl = $storage->getUrl("$assetId.js");
|
||||
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ $canViewMaker->prepare(
|
|||
},
|
||||
);
|
||||
|
||||
plan tests => 97
|
||||
plan tests => 98
|
||||
+ scalar(@fixIdTests)
|
||||
+ scalar(@fixTitleTests)
|
||||
+ 2*scalar(@getTitleTests) #same tests used for getTitle and getMenuTitle
|
||||
|
|
@ -766,15 +766,19 @@ $properties2 = {
|
|||
url => 'inheriturlfromparent02',
|
||||
};
|
||||
|
||||
|
||||
my $iufpAsset2 = $iufpAsset->addChild($properties2, $properties2->{id});
|
||||
$iufpAsset2->update( { inheritUrlFromParent => 1 } );
|
||||
$iufpAsset2->commit;
|
||||
is($iufpAsset2->getUrl, '/inheriturlfromparent01/inheriturlfromparent02', 'inheritUrlFromParent works');
|
||||
|
||||
# works for setting, now try disabling. Should not change the URL.
|
||||
$iufpAsset2->update( { inheritUrlFromParent => 0 } );
|
||||
$iufpAsset2->commit;
|
||||
is($iufpAsset2->getUrl, '/inheriturlfromparent01/inheriturlfromparent02', 'setting inheritUrlFromParent to 0 works');
|
||||
|
||||
# also make sure that it is actually disabled
|
||||
is($iufpAsset2->get('inheritUrlFromParent'), 0, "disabling inheritUrlFromParent actually works");
|
||||
|
||||
# works for setting and disabling, now ensure it recurses
|
||||
|
||||
my $properties3 = {
|
||||
|
|
@ -785,8 +789,11 @@ my $properties3 = {
|
|||
url => 'inheriturlfromparent03',
|
||||
};
|
||||
my $iufpAsset3 = $iufpAsset2->addChild($properties3, $properties3->{id});
|
||||
$iufpAsset3->commit;
|
||||
$iufpAsset2->update( { inheritUrlFromParent => 1 } );
|
||||
$iufpAsset2->commit;
|
||||
$iufpAsset3->update( { inheritUrlFromParent => 1 } );
|
||||
$iufpAsset3->commit;
|
||||
is($iufpAsset3->getUrl, '/inheriturlfromparent01/inheriturlfromparent02/inheriturlfromparent03', 'inheritUrlFromParent recurses properly');
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue