From d37cd047e397dca27ce8c583098e124a661ebc40 Mon Sep 17 00:00:00 2001 From: Wouter van Oijen Date: Fri, 21 Jul 2006 13:04:17 +0000 Subject: [PATCH] fix: FileUrl doesn't handle Snippets --- docs/changelog/7.x.x.txt | 1 + lib/WebGUI/Macro/FileUrl.pm | 14 ++++++++++---- lib/WebGUI/i18n/English/Macro_FileUrl.pm | 4 ++-- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 77b50a6fe..38985677c 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -9,6 +9,7 @@ - fix: Indent Navigation broken (Wouter van Oijen / ProcoliX) - fix: HttpProxy not working (with fix) (Eric Kennedy) - fix: Copyright on Default Template (Wouter van Oijen / ProcoliX) + - fix: FileUrl macro doesn't handle snippets (Wouter van Oijen / ProcoliX) 7.0.2 diff --git a/lib/WebGUI/Macro/FileUrl.pm b/lib/WebGUI/Macro/FileUrl.pm index 4abfc23e9..c8b939f4a 100644 --- a/lib/WebGUI/Macro/FileUrl.pm +++ b/lib/WebGUI/Macro/FileUrl.pm @@ -43,13 +43,19 @@ sub process { my $session = shift; my $url = shift; my $asset = WebGUI::Asset->newByUrl($session,$url); - if (defined $asset) { - my $storage = WebGUI::Storage->get($session,$asset->get("storageId")); - return $storage->getUrl($asset->get("filename")); - } else { + if (not defined $asset) { + $session->errorHandler->warn("^FileUrl($url): asset not found"); my $i18n = WebGUI::International->new($session, 'Macro_FileUrl'); return $i18n->get('invalid url'); } + my $storageId = $asset->get('storageId'); + if (not defined $storageId) { + $session->errorHandler->warn("^FileUrl($url): asset is not a file"); + my $i18n = WebGUI::International->new($session, 'Macro_FileUrl'); + return $i18n->get('invalid url'); + } + my $storage = WebGUI::Storage->get($session,$storageId); + return $storage->getUrl($asset->get("filename")); } diff --git a/lib/WebGUI/i18n/English/Macro_FileUrl.pm b/lib/WebGUI/i18n/English/Macro_FileUrl.pm index 42ec8fab9..7cef4afdc 100644 --- a/lib/WebGUI/i18n/English/Macro_FileUrl.pm +++ b/lib/WebGUI/i18n/English/Macro_FileUrl.pm @@ -16,9 +16,9 @@ our $I18N = { message => q|

^FileUrl();
^FileUrl(Asset URL);
-This macro is used to return a filesystem URL to an File, Image or Snippet Asset identified by its Asset URL.

+This macro is used to return a filesystem URL to a File or Image Asset identified by its Asset URL.

|, - lastUpdated => 1146679314, + lastUpdated => 1153476000, }, 'invalid url' => {