You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jo...@apache.org on 2009/02/09 13:20:55 UTC

svn commit: r742442 - in /ofbiz/trunk: applications/ecommerce/webapp/ecommerce/cart/ applications/order/webapp/ordermgr/entry/cart/ applications/product/servicedef/ framework/base/src/org/ofbiz/base/util/ framework/base/src/org/ofbiz/base/util/template/

Author: jonesde
Date: Mon Feb  9 12:20:55 2009
New Revision: 742442

URL: http://svn.apache.org/viewvc?rev=742442&view=rev
Log:
Added new shorter method to StringUtil called wrapString for getting a StringWrapper; added shared variable for StringUtil that is always there in FTL files so when string wrapping is needed one can just use StringUtil.wrapString(); added examples of this for the ProductPromo.promoText field in ecommerce; also set services for that field to allow safe html

Modified:
    ofbiz/trunk/applications/ecommerce/webapp/ecommerce/cart/minipromotext.ftl
    ofbiz/trunk/applications/order/webapp/ordermgr/entry/cart/promotiondetails.ftl
    ofbiz/trunk/applications/product/servicedef/services_pricepromo.xml
    ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java
    ofbiz/trunk/framework/base/src/org/ofbiz/base/util/template/FreeMarkerWorker.java

Modified: ofbiz/trunk/applications/ecommerce/webapp/ecommerce/cart/minipromotext.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/ecommerce/webapp/ecommerce/cart/minipromotext.ftl?rev=742442&r1=742441&r2=742442&view=diff
==============================================================================
--- ofbiz/trunk/applications/ecommerce/webapp/ecommerce/cart/minipromotext.ftl (original)
+++ ofbiz/trunk/applications/ecommerce/webapp/ecommerce/cart/minipromotext.ftl Mon Feb  9 12:20:55 2009
@@ -25,7 +25,10 @@
     <div class="screenlet-body">
         <#-- show promotions text -->
         <#list productPromos as productPromo>
-            <p><a href="<@o...@ofbizUrl>" class="linktext">${uiLabelMap.CommonDetails}</a> ${productPromo.promoText}</p>
+            <p>
+                <a href="<@o...@ofbizUrl>" class="linktext">${uiLabelMap.CommonDetails}</a> 
+                ${StringUtil.wrapString(productPromo.promoText?if_exists)}
+            </p>
             <#if productPromo_has_next>
                 <div><hr/></div>
             </#if>

Modified: ofbiz/trunk/applications/order/webapp/ordermgr/entry/cart/promotiondetails.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/entry/cart/promotiondetails.ftl?rev=742442&r1=742441&r2=742442&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/webapp/ordermgr/entry/cart/promotiondetails.ftl (original)
+++ ofbiz/trunk/applications/order/webapp/ordermgr/entry/cart/promotiondetails.ftl Mon Feb  9 12:20:55 2009
@@ -22,7 +22,7 @@
         <div class="boxhead">&nbsp;${uiLabelMap.OrderPromotionDetails}:</div>
     </div>
     <div class="screenlet-body">
-        <div>${productPromo.promoText?if_exists}</div>
+        <div>${StringUtil.wrapString(productPromo.promoText?if_exists)}</div>
         <div>Generated Description: ${promoAutoDescription?if_exists}</div>
     </div>
 </div>

Modified: ofbiz/trunk/applications/product/servicedef/services_pricepromo.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/servicedef/services_pricepromo.xml?rev=742442&r1=742441&r2=742442&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/servicedef/services_pricepromo.xml (original)
+++ ofbiz/trunk/applications/product/servicedef/services_pricepromo.xml Mon Feb  9 12:20:55 2009
@@ -134,6 +134,7 @@
             <exclude field-name="lastModifiedByUserLogin"/>
         </auto-attributes>
         <override name="promoName" optional="false"/>
+        <override name="promoText" allow-html="safe"/>
     </service>
     <service name="updateProductPromo" default-entity-name="ProductPromo" engine="simple"
                 location="org/ofbiz/product/promo/PromoServices.xml" invoke="updateProductPromo" auth="true">
@@ -145,6 +146,7 @@
             <exclude field-name="lastModifiedDate"/>
             <exclude field-name="lastModifiedByUserLogin"/>
         </auto-attributes>
+        <override name="promoText" allow-html="safe"/>
     </service>
     <service name="deleteProductPromo" default-entity-name="ProductPromo" engine="simple"
                 location="org/ofbiz/product/promo/PromoServices.xml" invoke="deleteProductPromo" auth="true">

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java?rev=742442&r1=742441&r2=742442&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java Mon Feb  9 12:20:55 2009
@@ -626,7 +626,10 @@
 
         return sb.toString();
     }
-    
+
+    public static StringWrapper wrapString(String theString) {
+        return makeStringWrapper(theString);
+    }
     public static StringWrapper makeStringWrapper(String theString) {
         if (theString == null) return null;
         if (theString.length() == 0) return StringWrapper.EMPTY_STRING_WRAPPER; 

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/template/FreeMarkerWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/template/FreeMarkerWorker.java?rev=742442&r1=742441&r2=742442&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/template/FreeMarkerWorker.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/template/FreeMarkerWorker.java Mon Feb  9 12:20:55 2009
@@ -45,6 +45,7 @@
 
 import org.ofbiz.base.location.FlexibleLocation;
 import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.StringUtil;
 import org.ofbiz.base.util.UtilGenerics;
 import org.ofbiz.base.util.UtilMisc;
 import org.ofbiz.base.util.UtilProperties;
@@ -81,6 +82,7 @@
         newConfig.setObjectWrapper(wrapper);
         newConfig.setSharedVariable("Static", wrapper.getStaticModels());
         newConfig.setLocalizedLookup(false);
+        newConfig.setSharedVariable("StringUtil", new BeanModel(new StringUtil(), wrapper));
         newConfig.setTemplateLoader(new FlexibleTemplateLoader());
         try {
             newConfig.setSetting("datetime_format", "yyyy-MM-dd HH:mm:ss.SSS");