Author: hansbak
Date: Tue Aug 9 07:28:04 2011
New Revision: 1155240
URL: http://svn.apache.org/viewvc?rev=1155240&view=rev
Log:
add three optional parameters to the macro: <@ofbizUrl fullPath=true
encode=false secure=false> which are pretty self explanatory and are needed to
generate a proper url within emails
Modified:
ofbiz/trunk/applications/product/src/org/ofbiz/product/category/OfbizCatalogAltUrlTransform.java
ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/catalog/productdetail.ftl
ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/catalog/tellafriend.ftl
ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/order/orderitems.ftl
Modified:
ofbiz/trunk/applications/product/src/org/ofbiz/product/category/OfbizCatalogAltUrlTransform.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/category/OfbizCatalogAltUrlTransform.java?rev=1155240&r1=1155239&r2=1155240&view=diff
==============================================================================
---
ofbiz/trunk/applications/product/src/org/ofbiz/product/category/OfbizCatalogAltUrlTransform.java
(original)
+++
ofbiz/trunk/applications/product/src/org/ofbiz/product/category/OfbizCatalogAltUrlTransform.java
Tue Aug 9 07:28:04 2011
@@ -25,6 +25,7 @@ import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.ofbiz.base.util.UtilValidate;
+import org.ofbiz.webapp.control.RequestHandler;
import freemarker.core.Environment;
import freemarker.ext.beans.BeanModel;
@@ -53,11 +54,27 @@ public class OfbizCatalogAltUrlTransform
return null;
}
+ public boolean checkArg(Map args, String key, boolean defaultValue) {
+ if (!args.containsKey(key)) {
+ return defaultValue;
+ } else {
+ Object o = args.get(key);
+ if (o instanceof SimpleScalar) {
+ SimpleScalar s = (SimpleScalar) o;
+ return "true".equalsIgnoreCase(s.getAsString());
+ }
+ return defaultValue;
+ }
+ }
+
@Override
@SuppressWarnings("unchecked")
public Writer getWriter(final Writer out, final Map args)
throws TemplateModelException, IOException {
final StringBuilder buf = new StringBuilder();
+ final boolean fullPath = checkArg(args, "fullPath", false);
+ final boolean secure = checkArg(args, "secure", false);
+
return new Writer(out) {
public void write(char[] cbuf, int off, int len) throws
IOException {
@@ -79,6 +96,7 @@ public class OfbizCatalogAltUrlTransform
HttpServletRequest request = (HttpServletRequest)
req.getWrappedObject();
String url = "";
+ StringBuilder newURL = new StringBuilder();
if (UtilValidate.isNotEmpty(productId)) {
url = CatalogUrlFilter.makeProductUrl(request,
previousCategoryId, productCategoryId, productId);
} else {
@@ -88,7 +106,13 @@ public class OfbizCatalogAltUrlTransform
String searchString = getStringArg(args,
"searchString");
url = CatalogUrlFilter.makeCategoryUrl(request,
previousCategoryId, productCategoryId, productId, viewSize, viewIndex,
viewSort, searchString);
}
- out.write(url);
+ // make the link
+ if (fullPath){
+ String serverRootUrl =
RequestHandler.getDefaultServerRootUrl(request, secure);
+ newURL.append(serverRootUrl);
+ }
+ newURL.append(url);
+ out.write(newURL.toString());
}
} catch (TemplateModelException e) {
throw new IOException(e.getMessage());
Modified:
ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/catalog/productdetail.ftl
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/catalog/productdetail.ftl?rev=1155240&r1=1155239&r2=1155240&view=diff
==============================================================================
---
ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/catalog/productdetail.ftl
(original)
+++
ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/catalog/productdetail.ftl
Tue Aug 9 07:28:04 2011
@@ -522,7 +522,7 @@ ${virtualVariantJavaScript?if_exists}
<#-- show tell a friend details only in ecommerce application -->
<div> </div>
<div>
- <a
href="javascript:popUpSmall('<@ofbizUrl>tellafriend?productId=${product.productId}</@ofbizUrl>','tellafriend');"
class="buttontext">${uiLabelMap.CommonTellAFriend}</a>
+ <a
href="javascript:popUpSmall('<@ofbizUrl>tellafriend?productId=${product.productId}<#if
categoryId?exists>&categoryId=${categoryId}/</#if></@ofbizUrl>','tellafriend');"
class="buttontext">${uiLabelMap.CommonTellAFriend}</a>
</div>
<#if disFeatureList?exists && 0 < disFeatureList.size()>
Modified:
ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/catalog/tellafriend.ftl
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/catalog/tellafriend.ftl?rev=1155240&r1=1155239&r2=1155240&view=diff
==============================================================================
---
ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/catalog/tellafriend.ftl
(original)
+++
ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/catalog/tellafriend.ftl
Tue Aug 9 07:28:04 2011
@@ -23,13 +23,11 @@ under the License.
</head>
<body class="ecbody">
<form name="tellafriend" action="<@ofbizUrl>emailFriend</@ofbizUrl>"
method="post">
- <#if requestParameters.productId?exists>
- <input type="hidden" name="pageUrl" value="<@ofbizUrl fullPath="true"
encode="false"
secure="false">/product?product_id=${requestParameters.productId}</@ofbizUrl>"
/>
- <#elseif requestParameters.categoryId?exists>
- <input type="hidden" name="pageUrl" value="<@ofbizUrl fullPath="true"
encode="false"
secure="false">/category?category_id=${requestParameters.categoryId}</@ofbizUrl>"
/>
- <#else>
- <#assign cancel = "Y">
- </#if>
+ <#if (requestParameters.productId)?exists ||
(requestParameters.productId)?exists>
+ <input type="hidden" name="pageUrl" value="<@ofbizCatalogAltUrl
fullPath="true" secure="false"
productCategoryId=requestParameters.categoryId!""
productId=requestParameters.productId!""/>" />
+ <#else>
+ <#assign cancel = "Y">
+ </#if>
<#if !cancel?exists>
<table>
<tr>
Modified:
ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/order/orderitems.ftl
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/order/orderitems.ftl?rev=1155240&r1=1155239&r2=1155240&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/order/orderitems.ftl
(original)
+++ ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/order/orderitems.ftl
Tue Aug 9 07:28:04 2011
@@ -122,7 +122,7 @@ under the License.
<#else>
<#assign product =
orderItem.getRelatedOneCache("Product")?if_exists/> <#-- should always exist
because of FK constraint, but just in case -->
<td >
- <a href="<@ofbizUrl
fullPath="true">product?product_id=${orderItem.productId}</@ofbizUrl>"
class="linktext">${orderItem.productId} -
${orderItem.itemDescription?default("")}</a>
+ <a href="<@ofbizCatalogAltUrl fullPath="true" secure="false"
productId=orderItem.productId/>" class="linktext">${orderItem.productId} -
${orderItem.itemDescription?default("")}</a>
<#if product?has_content>
<#if product.piecesIncluded?exists &&
product.piecesIncluded?long != 0>
[${uiLabelMap.OrderPieces}: ${product.piecesIncluded}]