AssetProxy macro can now use asset id as a parameter like so: ^AssetProxy(abcdefghijklmnopqrstuv,assetId);

subscriptionitem macro is now autoconverted to assetproxy
This commit is contained in:
JT Smith 2008-05-28 17:14:05 +00:00
parent 3ad1668a21
commit 17c7a0ad7a
3 changed files with 58 additions and 78 deletions

View file

@ -1,5 +1,7 @@
7.5.11
- rfe: Not being limited to single-worded Tags
- AssetProxy macro can now use asset id as a parameter like so:
^AssetProxy(abcdefghijklmnopqrstuv,assetId);
- Exposed keywords API to all assets through edit screen. Now keywords are
searchable and add metatags for all assets.
- fix: template variable isUncommitted is not documented in the help
@ -237,20 +239,6 @@
- add: Photos now track views
- fix: Multiple Gallery template fixes.
7.4.24
- fix: https and extra / in urls (perlDreamer Consulting, LLC.)
http://www.webgui.org/bugs/tracker/https-and-extra-/-in-urls
7.4.23
- fix: CalendarUpdateFeeds workflow causes errors in log
- autocommit for packages is handled by web method, not API method
- fix: importing packages generates orphaned duplicates of all attached storage locations
- fix: error rolling back version tags if a parent has a later revision date than its child
- show fields in tabs on DataForm default email template
- fix: don't show Admin mode toggle when not in adminModeSubnets
- fix regression: Site starter style displays incorrectly in IE
- really show fields in tabs on DataForm default email template
7.5.1
- fix: Extra head tags of unplaced assets included twice
- improve rebuildLineage.pl behavior. protect against assets that are too deep and don't destroy search index.
@ -328,6 +316,7 @@
instead of a silly HTML area
- fix: rating archived posts causes error
7.4.21
- fix: Mails sent from WebGUI now wrap at 78 characters, as the SMTP
RFC asks, to fix problems with some SMTP servers when lines exceed

View file

@ -39,6 +39,7 @@ addingInStoreCredit($session);
insertCommerceTaxTable($session);
migrateOldTaxTable($session);
insertCommerceShipDriverTable($session);
removeOldCommerceCode($session);
migrateToNewCart($session);
createSkuAsset($session);
createDonationAsset($session);
@ -51,7 +52,6 @@ convertTransactionLog($session);
upgradeEMS($session);
migrateOldProduct($session);
mergeProductsWithCommerce($session);
updateUsersOfProductMacro($session);
deleteOldProductTemplates($session);
addCaptchaToDataForm( $session );
addArchiveEnabledToCollaboration( $session );
@ -61,6 +61,7 @@ addVendors($session);
modifyThingyPossibleValues( $session );
removeLegacyTable($session);
migrateSubscriptions( $session );
updateUsersOfCommerceMacros($session);
addDBLinkAccessToSQLMacro($session);
addAssetManager( $session );
@ -1010,6 +1011,8 @@ sub mergeProductsWithCommerce {
#-------------------------------------------------
sub removeOldCommerceCode {
my $session = shift;
print "\tRemoving old commerce code.\n" unless ($quiet);
my $config = $session->config;
unlink '../../lib/WebGUI/Asset/Wobject/Product.pm';
@ -1054,68 +1057,48 @@ sub removeOldCommerceCode {
delete $macros{$key} if $value eq 'SubscriptionItemPurchaseUrl';
}
$config->set('macros', \%macros);
$config->deleteFromArray('WebGUI::Asset::Wobject::Product');
$config->deleteFromArray('assets','WebGUI::Asset::Wobject::Product');
return 1;
}
#-------------------------------------------------
sub updateUsersOfProductMacro {
sub updateUsersOfCommerceMacros {
my $session = shift;
print "\tUpdate assets which might be using the Product macro.\n" unless ($quiet);
my $wobjSth = $session->db->read('select assetId, revisionDate, description from wobject order by assetId, revisionDate');
my $fixed = $session->db->prepare('update wobject set description=? where assetId=? and revisionDate=?');
while (my $wobject = $wobjSth->hashRef) {
while ($wobject->{description} =~ m/\^Product\('? ([^),']+) /xg) {
#printf "\t\tWorking on %s\n", $wobject->{assetId};
my $identifier = $1; ##If this is a product sku, need to look up by productId;
#printf "\t\t\tFound argument of %s\n", $identifier;
my $assetId = $session->db->quickScalar('select distinct(assetId) from sku where sku=?',[$identifier]);
#printf "\t\t\tsku assetId: %s\n", $assetId;
my $productAssetId = $assetId ? $assetId : $identifier;
$wobject->{description} =~ s/\^Product\( [^)]+ \)/^AssetProxy($productAssetId)/x;
#printf "\t\t\tUpdated description to%s\n", $wobject->{description};
$fixed->execute([ $wobject->{description}, $wobject->{assetId}, $wobject->{revisionDate}, ]);
}
}
$wobjSth->finish;
$fixed->finish;
print "\tUpdate assets which might be using the Product and SubscriptionItem macros.\n" unless ($quiet);
my $db = $session->db;
my %tables = (
wobject => 'description',
snippet => 'snippet',
template => 'template',
Post => 'content',
);
my $snipSth = $session->db->read('select assetId, revisionDate, snippet from snippet order by assetId, revisionDate');
$fixed = $session->db->prepare('update snippet set snippet=? where assetId=? and revisionDate=?');
while (my $snippet = $snipSth->hashRef) {
while ($snippet->{snippet} =~ m/\^Product\('? ([^),']+) /xg) {
#printf "\t\tWorking on %s\n", $snippet->{assetId};
my $identifier = $1; ##If this is a product sku, need to look up by productId;
#printf "\t\t\tFound argument of %s\n", $identifier;
my $assetId = $session->db->quickScalar('select distinct(assetId) from sku where sku=?',[$identifier]);
#printf "\t\t\tsku assetId: %s\n", $assetId;
my $productAssetId = $assetId ? $assetId : $identifier;
$snippet->{snippet} =~ s/\^Product\( [^)]+ \)/^AssetProxy($productAssetId)/x;
#printf "\t\t\tUpdated snippet to%s\n", $snippet->{snippet};
$fixed->execute([ $snippet->{snippet}, $snippet->{assetId}, $snippet->{revisionDate}, ]);
foreach my $table (keys %tables) {
print "\t\tUpdating ".$table."s.\n" unless ($quiet);
my $sth = $db->read('select assetId, revisionDate, '.$tables{$table}.' from '.$table.' order by assetId, revisionDate');
while (my ($id, $rev, $content) = $sth->array) {
my $fixed = $content;
# handle normal subscription item
$fixed =~ s{\^SubscriptionItem\(([A-Za-z0-9_-]{22})\);}{^AssetProxy($1,assetId);}xg;
# handle one with an optional template id attached
$fixed =~ s{\^SubscriptionItem\(([A-Za-z0-9_-]{22}),[A-Za-z0-9_-]{22}\);}{^AssetProxy($1,assetId);}xg;
# handle product macros
while ($fixed =~ m/\^Product\('? ([^),']+) /xg) {
#printf "\t\tWorking on %s\n", $id;
my $identifier = $1; ##If this is a product sku, need to look up by productId;
#printf "\t\t\tFound argument of %s\n", $identifier;
my $assetId = $db->quickScalar('select distinct(assetId) from sku where sku=?',[$identifier]);
#printf "\t\t\tsku assetId: %s\n", $id;
my $productAssetId = $assetId ? $assetId : $identifier;
$fixed =~ s/\^Product\( [^)]+ \)/^AssetProxy($productAssetId,assetId)/x;
#printf "\t\t\tUpdated ".$tables{$table}." to%s\n", $fixed;
}
if ($fixed ne $content) {
$db->write('update '.$table.' set '.$tables{$table}.'=? where assetId=? and revisionDate=?', [$fixed, $id, $rev]);
}
}
}
$snipSth->finish;
$fixed->finish;
my $tempSth = $session->db->read('select assetId, revisionDate, template from template order by assetId, revisionDate');
$fixed = $session->db->prepare('update template set template=? where assetId=? and revisionDate=?');
while (my $template = $tempSth->hashRef) {
while ($template->{template} =~ m/\^Product\('? ([^),']+) /xg) {
#printf "\t\tWorking on %s\n", $template->{assetId};
my $identifier = $1; ##If this is a product sku, need to look up by productId;
#printf "\t\t\tFound argument of %s\n", $identifier;
my $assetId = $session->db->quickScalar('select distinct(assetId) from sku where sku=?',[$identifier]);
#printf "\t\t\tsku assetId: %s\n", $assetId;
my $productAssetId = $assetId ? $assetId : $identifier;
$template->{template} =~ s/\^Product\( [^)]+ \)/^AssetProxy($productAssetId)/x;
#printf "\t\t\tUpdated template to%s\n", $template->{template};
$fixed->execute([ $template->{template}, $template->{assetId}, $template->{revisionDate}, ]);
}
}
$tempSth->finish;
$fixed->finish;
return 1;
}

View file

@ -23,26 +23,33 @@ Package WebGUI::Macro::AssetProxy
Macro for displaying the output of an Asset in another location.
=head2 process ( url )
=head2 process ( url | assetId, [ type ] )
=head3 url
=head3 url | assetId
The URL of the Asset whose output will be returned. If no Asset with that URL
can be found, an internationalized error message will be returned instead.
My specify either the asset url or the asset id. If no Asset with that URL or id can be found, an internationalized error message will be returned instead.
No editing controls (toolbar) will be displayed in the Asset output, even if
Admin is turned on.
No editing controls (toolbar) will be displayed in the Asset output, even if Admin is turned on.
The Not Found Page may not be Asset Proxied.
=head3 type
Defaults to 'url'. But if you want to use an assetId as the first parameter, then this parameter must be 'assetId'.
=cut
#-------------------------------------------------------------------
sub process {
my $session = shift;
my $url = shift;
my ($session, $identifier, $type) = @_;
my $t = ($session->errorHandler->canShowPerformanceIndicators()) ? [Time::HiRes::gettimeofday()] : undef;
my $asset = WebGUI::Asset->newByUrl($session,$url);
my $asset;
if ($type eq 'assetId') {
$asset = WebGUI::Asset->newByDynamicClass($session, $identifier);
}
else {
$asset = WebGUI::Asset->newByUrl($session,$identifier);
}
#Sorry, you cannot proxy the notfound page.
if (defined $asset && $asset->getId ne $session->setting->get("notFoundPage")) {
if ($asset->canView) {
@ -53,7 +60,8 @@ sub process {
return $output;
}
return undef;
} else {
}
else {
my $i18n = WebGUI::International->new($session, 'Macro_AssetProxy');
return $i18n->get('invalid url');
}