You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2010/12/03 23:05:19 UTC

svn commit: r1042024 - in /ofbiz/trunk: applications/product/config/ applications/product/data/ applications/product/src/org/ofbiz/product/image/ applications/product/src/org/ofbiz/product/product/ specialpurpose/ecommerce/webapp/ecommerce/catalog/

Author: jleroux
Date: Fri Dec  3 22:05:19 2010
New Revision: 1042024

URL: http://svn.apache.org/viewvc?rev=1042024&view=rev
Log:
A patch from Anne Jessel "Improve handling and display of additional product images" (https://issues.apache.org/jira/browse/OFBIZ-4024) - OFBIZ-4024

This patch adds several closely-related features, intended to improve the display of products and their images in the ecommerce webapp.

When additional images for a product are uploaded via the Catalog, the scaled versions that were already being created in service addAdditionalViewForProduct are now recorded as ProductContent. This makes them easily available for use elsewhere.

New ProductContentType values were added to identify these content types. The obviously consistent string to use for these was too long, and so I had to choose something less consistent, but shorter and hopefully still clear. I used XTRA instead of ADDITIONAL.

The sizes to which additional images are rescaled has been changed, so they better fit in the ecommerce display. Relevant sizes in productdetail.ftl have been updated to match these sizes.

The ecommerce product display now uses the scaled additional images if available, rather than relying on the web browser to scale the images.

When displaying a single product in ecommerce, the main image is larger than the additional images. Hovering over an additional image displays a larger version in place of the main image.

Clicking on an additional image displays a popup with a detailed version of the image.

To use the new features, one or more large images (suggest at least 600x600) should be attached as additional images to a product, using the form on the bottom of the content tab for a product in Catalog. Viewing the product in ecommerce should then exhibit the above behaviour.

I have tried to maintain backwards compatibility, so that products with the old-style use of additional images will continue to display as they did previously. This means some of the code is not as streamlined as it might be.

JLR: You might prefer to keep the old ImageProperties.xml values...

Modified:
    ofbiz/trunk/applications/product/config/ImageProperties.xml
    ofbiz/trunk/applications/product/config/ProductEntityLabels.xml
    ofbiz/trunk/applications/product/data/ProductTypeData.xml
    ofbiz/trunk/applications/product/src/org/ofbiz/product/image/ScaleImage.java
    ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductServices.java
    ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/catalog/productdetail.ftl

Modified: ofbiz/trunk/applications/product/config/ImageProperties.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/config/ImageProperties.xml?rev=1042024&r1=1042023&r2=1042024&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/config/ImageProperties.xml (original)
+++ ofbiz/trunk/applications/product/config/ImageProperties.xml Fri Dec  3 22:05:19 2010
@@ -20,19 +20,19 @@ under the License.
 <imageSize xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
     <format name="extension" value="jpg"/>
     <size name="small">
+        <dimension name="height" value="50"/>
+        <dimension name="width" value="50"/>
+    </size>
+    <size name="medium">
         <dimension name="height" value="100"/>
         <dimension name="width" value="100"/>
     </size>
-    <size name="medium">
+    <size name="large">
         <dimension name="height" value="200"/>
         <dimension name="width" value="200"/>
     </size>
-    <size name="large">
+    <size name="detail">
         <dimension name="height" value="600"/>
         <dimension name="width" value="600"/>
     </size>
-    <size name="detail">
-        <dimension name="height" value="1500"/>
-        <dimension name="width" value="1500"/>
-    </size>
 </imageSize>

Modified: ofbiz/trunk/applications/product/config/ProductEntityLabels.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/config/ProductEntityLabels.xml?rev=1042024&r1=1042023&r2=1042024&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/config/ProductEntityLabels.xml (original)
+++ ofbiz/trunk/applications/product/config/ProductEntityLabels.xml Fri Dec  3 22:05:19 2010
@@ -1028,24 +1028,88 @@
         <value xml:lang="zh">图像 - 额外检查1</value>
         <value xml:lang="zh_TW">圖像 - 額外檢查1</value>
     </property>
+    <property key="ProductContentType.description.XTRA_IMG_1_SMALL">
+        <value xml:lang="en">Image - Additional View 1 Small</value>
+        <value xml:lang="it">Immagine - Vista adggiuntiva 1 piccola</value>
+    </property>
+    <property key="ProductContentType.description.XTRA_IMG_1_MEDIUM">
+        <value xml:lang="en">Image - Additional View 1 Medium</value>
+        <value xml:lang="it">Immagine - Vista adggiuntiva 1 media</value>
+    </property>
+    <property key="ProductContentType.description.XTRA_IMG_1_LARGE">
+        <value xml:lang="en">Image - Additional View 1 Large</value>
+        <value xml:lang="it">Immagine - Vista adggiuntiva 1 grande</value>
+    </property>
+    <property key="ProductContentType.description.XTRA_IMG_1_DETAIL">
+        <value xml:lang="en">Image - Additional View 1 Detail</value>
+        <value xml:lang="it">Immagine - Vista adggiuntiva 1 dettaglio</value>
+    </property>
     <property key="ProductContentType.description.ADDITIONAL_IMAGE_2">
         <value xml:lang="en">Image - Additional View 2</value>
         <value xml:lang="it">Immagine - Vista adggiuntiva 2</value>
         <value xml:lang="zh">图像 - 额外检查2</value>
         <value xml:lang="zh_TW">圖像 - 額外檢查2</value>
     </property>
+    <property key="ProductContentType.description.XTRA_IMG_2_SMALL">
+        <value xml:lang="en">Image - Additional View 2 Small</value>
+        <value xml:lang="it">Immagine - Vista adggiuntiva 2 piccola</value>
+    </property>
+    <property key="ProductContentType.description.XTRA_IMG_2_MEDIUM">
+        <value xml:lang="en">Image - Additional View 2 Medium</value>
+        <value xml:lang="it">Immagine - Vista adggiuntiva 2 media</value>
+    </property>
+    <property key="ProductContentType.description.XTRA_IMG_2_LARGE">
+        <value xml:lang="en">Image - Additional View 2 Large</value>
+        <value xml:lang="it">Immagine - Vista adggiuntiva 2 grande</value>
+    </property>
+    <property key="ProductContentType.description.XTRA_IMG_2_DETAIL">
+        <value xml:lang="en">Image - Additional View 2 Detail</value>
+        <value xml:lang="it">Immagine - Vista adggiuntiva 2 dettaglio</value>
+    </property>
     <property key="ProductContentType.description.ADDITIONAL_IMAGE_3">
         <value xml:lang="en">Image - Additional View 3</value>
         <value xml:lang="it">Immagine - Vista adggiuntiva 3</value>
         <value xml:lang="zh">图像 - 额外检查3</value>
         <value xml:lang="zh_TW">圖像 - 額外檢查3</value>
     </property>
+    <property key="ProductContentType.description.XTRA_IMG_3_SMALL">
+        <value xml:lang="en">Image - Additional View 3 Small</value>
+        <value xml:lang="it">Immagine - Vista adggiuntiva 3 piccola</value>
+    </property>
+    <property key="ProductContentType.description.XTRA_IMG_3_MEDIUM">
+        <value xml:lang="en">Image - Additional View 3 Medium</value>
+        <value xml:lang="it">Immagine - Vista adggiuntiva 3 media</value>
+    </property>
+    <property key="ProductContentType.description.XTRA_IMG_3_LARGE">
+        <value xml:lang="en">Image - Additional View 3 Large</value>
+        <value xml:lang="it">Immagine - Vista adggiuntiva 3 grande</value>
+    </property>
+    <property key="ProductContentType.description.XTRA_IMG_3_DETAIL">
+        <value xml:lang="en">Image - Additional View 3 Detail</value>
+        <value xml:lang="it">Immagine - Vista adggiuntiva 3 dettaglio</value>
+    </property>
     <property key="ProductContentType.description.ADDITIONAL_IMAGE_4">
         <value xml:lang="en">Image - Additional View 4</value>
         <value xml:lang="it">Immagine - Vista adggiuntiva 4</value>
         <value xml:lang="zh">图像 - 额外检查4</value>
         <value xml:lang="zh_TW">圖像 - 額外檢查4</value>
     </property>
+    <property key="ProductContentType.description.XTRA_IMG_4_SMALL">
+        <value xml:lang="en">Image - Additional View 4 Small</value>
+        <value xml:lang="it">Immagine - Vista adggiuntiva 4 piccola</value>
+    </property>
+    <property key="ProductContentType.description.XTRA_IMG_4_MEDIUM">
+        <value xml:lang="en">Image - Additional View 4 Medium</value>
+        <value xml:lang="it">Immagine - Vista adggiuntiva 4 media</value>
+    </property>
+    <property key="ProductContentType.description.XTRA_IMG_4_LARGE">
+        <value xml:lang="en">Image - Additional View 4 Large</value>
+        <value xml:lang="it">Immagine - Vista adggiuntiva 4 grande</value>
+    </property>
+    <property key="ProductContentType.description.XTRA_IMG_4_DETAIL">
+        <value xml:lang="en">Image - Additional View 4 Detail</value>
+        <value xml:lang="it">Immagine - Vista adggiuntiva 4 dettaglio</value>
+    </property>
     <property key="ProductContentType.description.ADDTOCART_IMAGE">
         <value xml:lang="en">Add To Cart Image</value>
         <value xml:lang="it">Aggiungi immagine al carrello</value>

Modified: ofbiz/trunk/applications/product/data/ProductTypeData.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/data/ProductTypeData.xml?rev=1042024&r1=1042023&r2=1042024&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/data/ProductTypeData.xml (original)
+++ ofbiz/trunk/applications/product/data/ProductTypeData.xml Fri Dec  3 22:05:19 2010
@@ -255,6 +255,22 @@ under the License.
     <ProductContentType description="Image - Additional View 2" hasTable="N" parentTypeId="" productContentTypeId="ADDITIONAL_IMAGE_2"/>
     <ProductContentType description="Image - Additional View 3" hasTable="N" parentTypeId="" productContentTypeId="ADDITIONAL_IMAGE_3"/>
     <ProductContentType description="Image - Additional View 4" hasTable="N" parentTypeId="" productContentTypeId="ADDITIONAL_IMAGE_4"/>
+    <ProductContentType description="Image - Additional View 1 Small" hasTable="N" parentTypeId="" productContentTypeId="XTRA_IMG_1_SMALL"/>
+    <ProductContentType description="Image - Additional View 1 Medium" hasTable="N" parentTypeId="" productContentTypeId="XTRA_IMG_1_MEDIUM"/>
+    <ProductContentType description="Image - Additional View 1 Large" hasTable="N" parentTypeId="" productContentTypeId="XTRA_IMG_1_LARGE"/>
+    <ProductContentType description="Image - Additional View 1 Detail" hasTable="N" parentTypeId="" productContentTypeId="XTRA_IMG_1_DETAIL"/>
+    <ProductContentType description="Image - Additional View 2 Small" hasTable="N" parentTypeId="" productContentTypeId="XTRA_IMG_2_SMALL"/>
+    <ProductContentType description="Image - Additional View 2 Medium" hasTable="N" parentTypeId="" productContentTypeId="XTRA_IMG_2_MEDIUM"/>
+    <ProductContentType description="Image - Additional View 2 Large" hasTable="N" parentTypeId="" productContentTypeId="XTRA_IMG_2_LARGE"/>
+    <ProductContentType description="Image - Additional View 2 Detail" hasTable="N" parentTypeId="" productContentTypeId="XTRA_IMG_2_DETAIL"/>
+    <ProductContentType description="Image - Additional View 3 Small" hasTable="N" parentTypeId="" productContentTypeId="XTRA_IMG_3_SMALL"/>
+    <ProductContentType description="Image - Additional View 3 Medium" hasTable="N" parentTypeId="" productContentTypeId="XTRA_IMG_3_MEDIUM"/>
+    <ProductContentType description="Image - Additional View 3 Large" hasTable="N" parentTypeId="" productContentTypeId="XTRA_IMG_3_LARGE"/>
+    <ProductContentType description="Image - Additional View 3 Detail" hasTable="N" parentTypeId="" productContentTypeId="XTRA_IMG_3_DETAIL"/>
+    <ProductContentType description="Image - Additional View 4 Small" hasTable="N" parentTypeId="" productContentTypeId="XTRA_IMG_4_SMALL"/>
+    <ProductContentType description="Image - Additional View 4 Medium" hasTable="N" parentTypeId="" productContentTypeId="XTRA_IMG_4_MEDIUM"/>
+    <ProductContentType description="Image - Additional View 4 Large" hasTable="N" parentTypeId="" productContentTypeId="XTRA_IMG_4_LARGE"/>
+    <ProductContentType description="Image - Additional View 4 Detail" hasTable="N" parentTypeId="" productContentTypeId="XTRA_IMG_4_DETAIL"/>
     <ProductContentType description="Add To Cart Label" hasTable="N" parentTypeId="" productContentTypeId="ADDTOCART_LABEL"/>
     <ProductContentType description="Add To Cart Image" hasTable="N" parentTypeId="" productContentTypeId="ADDTOCART_IMAGE"/>
     <ProductContentType description="Short Sales Pitch" hasTable="N" parentTypeId="" productContentTypeId="SHORT_SALES_PITCH"/>

Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/image/ScaleImage.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/image/ScaleImage.java?rev=1042024&r1=1042023&r2=1042024&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/image/ScaleImage.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/image/ScaleImage.java Fri Dec  3 22:05:19 2010
@@ -50,6 +50,9 @@ public class ScaleImage {
 
     public static final String module = ScaleImage.class.getName();
     public static final String resource = "ProductErrorUiLabels";
+    /* public so that other code can easily use the imageUrlMap returned by scaleImageInAllSize */
+    public static final List<String> sizeTypeList = UtilMisc.toList("small", "medium", "large", "detail");
+
 
     public ScaleImage() {
     }
@@ -74,7 +77,6 @@ public class ScaleImage {
 
         /* VARIABLES */
         Locale locale = (Locale) context.get("locale");
-        List<String> sizeTypeList = UtilMisc.toList("small", "medium", "large", "detail");
         int index;
         Map<String, Map<String, String>> imgPropertyMap = FastMap.newInstance();
         BufferedImage bufImg, bufNewImg;

Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductServices.java?rev=1042024&r1=1042023&r2=1042024&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductServices.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductServices.java Fri Dec  3 22:05:19 2010
@@ -955,7 +955,6 @@ public class ProductServices {
 
         LocalDispatcher dispatcher = dctx.getDispatcher();
         Delegator delegator = dctx.getDelegator();
-        GenericValue userLogin = (GenericValue) context.get("userLogin");
         String productId = (String) context.get("productId");
         String productContentTypeId = (String) context.get("productContentTypeId");
         ByteBuffer imageData = (ByteBuffer) context.get("uploadedFile");
@@ -1018,113 +1017,139 @@ public class ProductServices {
             }
 
             String imageUrl = imageUrlPrefix + "/" + filePathPrefix + filenameToUse;
+            /* store the imageUrl version of the image, for backwards compatibility with code that does not use scaled versions */
+            Map<String, Object> result = addImageResource(dispatcher, delegator, context, imageUrl, productContentTypeId);
 
-            if (UtilValidate.isNotEmpty(imageUrl) && imageUrl.length() > 0) {
-                String contentId = (String) context.get("contentId");
+            if( ServiceUtil.isError(result)) {
+                return result;
+            }
 
-                Map<String, Object> dataResourceCtx = FastMap.newInstance();
-                dataResourceCtx.put("objectInfo", imageUrl);
-                dataResourceCtx.put("dataResourceName", (String) context.get("_uploadedFile_fileName"));
-                dataResourceCtx.put("userLogin", userLogin);
+            /* now store the image versions created by ScaleImage.scaleImageInAllSize */
+            /* have to shrink length of productContentTypeId, as otherwise value is too long for database field */
+            Map<String,String> imageUrlMap = (Map<String, String>)resultResize.get("imageUrlMap");
+            for( String sizeType : ScaleImage.sizeTypeList ) {
+                imageUrl = imageUrlMap.get(sizeType);
+                if( UtilValidate.isNotEmpty(imageUrl)) {
+                    result = addImageResource(dispatcher, delegator, context, imageUrl, "XTRA_IMG_" + viewNumber + "_" + sizeType.toUpperCase());
+                    if( ServiceUtil.isError(result)) {
+                        return result;
+                    }
+                }
+            }
+        }
+        return ServiceUtil.returnSuccess();
+    }
 
-                Map<String, Object> productContentCtx = FastMap.newInstance();
-                productContentCtx.put("productId", productId);
-                productContentCtx.put("productContentTypeId", productContentTypeId);
-                productContentCtx.put("fromDate", (Timestamp) context.get("fromDate"));
-                productContentCtx.put("thruDate", (Timestamp) context.get("thruDate"));
-                productContentCtx.put("userLogin", userLogin);
+    private static Map<String,Object> addImageResource( LocalDispatcher dispatcher, Delegator delegator, Map<String, ? extends Object> context, 
+            String imageUrl, String productContentTypeId ) {
+        GenericValue userLogin = (GenericValue) context.get("userLogin");
+        String productId = (String) context.get("productId");
 
-                if (UtilValidate.isNotEmpty(contentId)) {
-                    GenericValue content = null;
+        if (UtilValidate.isNotEmpty(imageUrl) && imageUrl.length() > 0) {
+            String contentId = (String) context.get("contentId");
+
+            Map<String, Object> dataResourceCtx = FastMap.newInstance();
+            dataResourceCtx.put("objectInfo", imageUrl);
+            dataResourceCtx.put("dataResourceName", (String) context.get("_uploadedFile_fileName"));
+            dataResourceCtx.put("userLogin", userLogin);
+
+            Map<String, Object> productContentCtx = FastMap.newInstance();
+            productContentCtx.put("productId", productId);
+            productContentCtx.put("productContentTypeId", productContentTypeId);
+            productContentCtx.put("fromDate", (Timestamp) context.get("fromDate"));
+            productContentCtx.put("thruDate", (Timestamp) context.get("thruDate"));
+            productContentCtx.put("userLogin", userLogin);
+
+            if (UtilValidate.isNotEmpty(contentId)) {
+                GenericValue content = null;
+                try {
+                    content = delegator.findOne("Content", UtilMisc.toMap("contentId", contentId), false);
+                } catch (GenericEntityException e) {
+                    Debug.logError(e, module);
+                    return ServiceUtil.returnError(e.getMessage());
+                }
+
+                if (content != null) {
+                    GenericValue dataResource = null;
                     try {
-                        content = delegator.findOne("Content", UtilMisc.toMap("contentId", contentId), false);
+                        dataResource = content.getRelatedOne("DataResource");
                     } catch (GenericEntityException e) {
                         Debug.logError(e, module);
                         return ServiceUtil.returnError(e.getMessage());
                     }
 
-                    if (content != null) {
-                        GenericValue dataResource = null;
+                    if (dataResource != null) {
+                        dataResourceCtx.put("dataResourceId", dataResource.getString("dataResourceId"));
                         try {
-                            dataResource = content.getRelatedOne("DataResource");
-                        } catch (GenericEntityException e) {
+                            dispatcher.runSync("updateDataResource", dataResourceCtx);
+                        } catch (GenericServiceException e) {
                             Debug.logError(e, module);
                             return ServiceUtil.returnError(e.getMessage());
                         }
-
-                        if (dataResource != null) {
-                            dataResourceCtx.put("dataResourceId", dataResource.getString("dataResourceId"));
-                            try {
-                                dispatcher.runSync("updateDataResource", dataResourceCtx);
-                            } catch (GenericServiceException e) {
-                                Debug.logError(e, module);
-                                return ServiceUtil.returnError(e.getMessage());
-                            }
-                        } else {
-                            dataResourceCtx.put("dataResourceTypeId", "SHORT_TEXT");
-                            dataResourceCtx.put("mimeTypeId", "text/html");
-                            Map<String, Object> dataResourceResult = FastMap.newInstance();
-                            try {
-                                dataResourceResult = dispatcher.runSync("createDataResource", dataResourceCtx);
-                            } catch (GenericServiceException e) {
-                                Debug.logError(e, module);
-                                return ServiceUtil.returnError(e.getMessage());
-                            }
-
-                            Map<String, Object> contentCtx = FastMap.newInstance();
-                            contentCtx.put("contentId", contentId);
-                            contentCtx.put("dataResourceId", dataResourceResult.get("dataResourceId"));
-                            contentCtx.put("userLogin", userLogin);
-                            try {
-                                dispatcher.runSync("updateContent", contentCtx);
-                            } catch (GenericServiceException e) {
-                                Debug.logError(e, module);
-                                return ServiceUtil.returnError(e.getMessage());
-                            }
+                    } else {
+                        dataResourceCtx.put("dataResourceTypeId", "SHORT_TEXT");
+                        dataResourceCtx.put("mimeTypeId", "text/html");
+                        Map<String, Object> dataResourceResult = FastMap.newInstance();
+                        try {
+                            dataResourceResult = dispatcher.runSync("createDataResource", dataResourceCtx);
+                        } catch (GenericServiceException e) {
+                            Debug.logError(e, module);
+                            return ServiceUtil.returnError(e.getMessage());
                         }
 
-                        productContentCtx.put("contentId", contentId);
+                        Map<String, Object> contentCtx = FastMap.newInstance();
+                        contentCtx.put("contentId", contentId);
+                        contentCtx.put("dataResourceId", dataResourceResult.get("dataResourceId"));
+                        contentCtx.put("userLogin", userLogin);
                         try {
-                            dispatcher.runSync("updateProductContent", productContentCtx);
+                            dispatcher.runSync("updateContent", contentCtx);
                         } catch (GenericServiceException e) {
                             Debug.logError(e, module);
                             return ServiceUtil.returnError(e.getMessage());
                         }
                     }
-                } else {
-                    dataResourceCtx.put("dataResourceTypeId", "SHORT_TEXT");
-                    dataResourceCtx.put("mimeTypeId", "text/html");
-                    Map<String, Object> dataResourceResult = FastMap.newInstance();
-                    try {
-                        dataResourceResult = dispatcher.runSync("createDataResource", dataResourceCtx);
-                    } catch (GenericServiceException e) {
-                        Debug.logError(e, module);
-                        return ServiceUtil.returnError(e.getMessage());
-                    }
 
-                    Map<String, Object> contentCtx = FastMap.newInstance();
-                    contentCtx.put("contentTypeId", "DOCUMENT");
-                    contentCtx.put("dataResourceId", dataResourceResult.get("dataResourceId"));
-                    contentCtx.put("userLogin", userLogin);
-                    Map<String, Object> contentResult = FastMap.newInstance();
+                    productContentCtx.put("contentId", contentId);
                     try {
-                        contentResult = dispatcher.runSync("createContent", contentCtx);
+                        dispatcher.runSync("updateProductContent", productContentCtx);
                     } catch (GenericServiceException e) {
                         Debug.logError(e, module);
                         return ServiceUtil.returnError(e.getMessage());
                     }
+                }
+            } else {
+                dataResourceCtx.put("dataResourceTypeId", "SHORT_TEXT");
+                dataResourceCtx.put("mimeTypeId", "text/html");
+                Map<String, Object> dataResourceResult = FastMap.newInstance();
+                try {
+                    dataResourceResult = dispatcher.runSync("createDataResource", dataResourceCtx);
+                } catch (GenericServiceException e) {
+                    Debug.logError(e, module);
+                    return ServiceUtil.returnError(e.getMessage());
+                }
 
-                    productContentCtx.put("contentId", contentResult.get("contentId"));
-                    try {
-                        dispatcher.runSync("createProductContent", productContentCtx);
-                    } catch (GenericServiceException e) {
-                        Debug.logError(e, module);
-                        return ServiceUtil.returnError(e.getMessage());
-                    }
+                Map<String, Object> contentCtx = FastMap.newInstance();
+                contentCtx.put("contentTypeId", "DOCUMENT");
+                contentCtx.put("dataResourceId", dataResourceResult.get("dataResourceId"));
+                contentCtx.put("userLogin", userLogin);
+                Map<String, Object> contentResult = FastMap.newInstance();
+                try {
+                    contentResult = dispatcher.runSync("createContent", contentCtx);
+                } catch (GenericServiceException e) {
+                    Debug.logError(e, module);
+                    return ServiceUtil.returnError(e.getMessage());
+                }
+
+                productContentCtx.put("contentId", contentResult.get("contentId"));
+                try {
+                    dispatcher.runSync("createProductContent", productContentCtx);
+                } catch (GenericServiceException e) {
+                    Debug.logError(e, module);
+                    return ServiceUtil.returnError(e.getMessage());
                 }
             }
         }
-           return ServiceUtil.returnSuccess();
+       return ServiceUtil.returnSuccess();
     }
 
     /**

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=1042024&r1=1042023&r2=1042024&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/catalog/productdetail.ftl (original)
+++ ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/catalog/productdetail.ftl Fri Dec  3 22:05:19 2010
@@ -94,14 +94,19 @@ ${virtualJavaScript?if_exists}
        }
     }
 
-    function popupDetail() {
-        var defaultDetailImage = "${firstDetailImage?default(mainDetailImageUrl?default("_NONE_"))}";
-        if (defaultDetailImage == null || defaultDetailImage == "null" || defaultDetailImage == "") {
-            defaultDetailImage = "_NONE_";
-        }
+    function popupDetail(specificDetailImageUrl) {
+        if( specificDetailImageUrl ) {
+            detailImageUrl = specificDetailImageUrl;
+        }
+        else {
+            var defaultDetailImage = "${firstDetailImage?default(mainDetailImageUrl?default("_NONE_"))}";
+            if (defaultDetailImage == null || defaultDetailImage == "null" || defaultDetailImage == "") {
+               defaultDetailImage = "_NONE_";
+            }
 
-        if (detailImageUrl == null || detailImageUrl == "null") {
-            detailImageUrl = defaultDetailImage;
+            if (detailImageUrl == null || detailImageUrl == "null") {
+                detailImageUrl = defaultDetailImage;
+            }
         }
 
         if (detailImageUrl == "_NONE_") {
@@ -111,7 +116,7 @@ ${virtualJavaScript?if_exists}
             return;
         }
         detailImageUrl = detailImageUrl.replace(/\&\#47;/g, "/");
-        popUp("<@ofbizUrl>detailImage?detail=" + detailImageUrl + "</...@ofbizUrl>", 'detailImage', '400', '550');
+        popUp("<@ofbizUrl>detailImage?detail=" + detailImageUrl + "</...@ofbizUrl>", 'detailImage', '600', '600');
     }
 
     function toggleAmt(toggle) {
@@ -322,7 +327,7 @@ ${virtualJavaScript?if_exists}
         <#assign productLargeImageUrl = firstLargeImage />
       </#if>
       <#if productLargeImageUrl?string?has_content>
-        <a href="javascript:popupDetail();"><img id="detailImage" src="<@o...@ofbizContentUrl>" name="mainImage" vspace="5" hspace="5" width="200" alt="" /></a>
+        <a href="javascript:popupDetail('${firstDetailImage?default(mainDetailImageUrl?default("_NONE_"))}');"><img id="detailImage" src="<@o...@ofbizContentUrl>" name="mainImage" vspace="5" hspace="5"  alt="" /></a>
         <input type="hidden" id="originalImage" name="originalImage" value="<@o...@ofbizContentUrl>" />
       </#if>
       <#if !productLargeImageUrl?string?has_content>
@@ -331,26 +336,71 @@ ${virtualJavaScript?if_exists}
     </div>
     <div id="additionalImageBox">
       <#if productAdditionalImage1?string?has_content>
+        <#assign productAdditionalImage1Small = productContentWrapper.get("XTRA_IMG_1_SMALL")?if_exists />
+        <#assign productAdditionalImage1Large = productContentWrapper.get("XTRA_IMG_1_LARGE")?if_exists />
+        <#assign productAdditionalImage1Detail = productContentWrapper.get("XTRA_IMG_1_DETAIL")?if_exists />
         <div class="additionalImage">
+          <#if productAdditionalImage1Small?string?has_content && productAdditionalImage1Large?string?has_content>
+            <#if productAdditionalImage1Detail?string?has_content>
+              <a href="javascript:popupDetail('${productAdditionalImage1Detail}');" swapDetail="<@o...@ofbizContentUrl>"><img src="<@o...@ofbizContentUrl>" vspace="5" hspace="5" alt="" /></a>
+            <#else>
+            <a href="javascript:void(0);" swapDetail="<@o...@ofbizContentUrl>"><img src="<@o...@ofbizContentUrl>" vspace="5" hspace="5" alt="" /></a>
+            </#if>
+          <#else>
           <a href="javascript:void(0);" swapDetail="<@o...@ofbizContentUrl>"><img src="<@o...@ofbizContentUrl>" vspace="5" hspace="5" width="200" alt="" /></a>
+          </#if>
         </div>
       </#if>
       <#if productAdditionalImage2?string?has_content>
+        <#assign productAdditionalImage2Small = productContentWrapper.get("XTRA_IMG_2_SMALL")?if_exists />
+        <#assign productAdditionalImage2Large = productContentWrapper.get("XTRA_IMG_2_LARGE")?if_exists />
+        <#assign productAdditionalImage2Detail = productContentWrapper.get("XTRA_IMG_2_DETAIL")?if_exists />
         <div class="additionalImage">
+          <#if productAdditionalImage2Small?string?has_content && productAdditionalImage2Large?string?has_content>
+            <#if productAdditionalImage2Detail?string?has_content>
+              <a href="javascript:popupDetail('${productAdditionalImage2Detail}');" swapDetail="<@o...@ofbizContentUrl>"><img src="<@o...@ofbizContentUrl>" vspace="5" hspace="5" alt="" /></a>
+            <#else>
+            <a href="javascript:void(0);" swapDetail="<@o...@ofbizContentUrl>"><img src="<@o...@ofbizContentUrl>" vspace="5" hspace="5" alt="" /></a>
+            </#if>
+          <#else>
           <a href="javascript:void(0);" swapDetail="<@o...@ofbizContentUrl>"><img src="<@o...@ofbizContentUrl>" vspace="5" hspace="5" width="200" alt="" /></a>
+          </#if>
          </div>
       </#if>
       <#if productAdditionalImage3?string?has_content>
+        <#assign productAdditionalImage3Small = productContentWrapper.get("XTRA_IMG_3_SMALL")?if_exists />
+        <#assign productAdditionalImage3Large = productContentWrapper.get("XTRA_IMG_3_LARGE")?if_exists />
+        <#assign productAdditionalImage3Detail = productContentWrapper.get("XTRA_IMG_3_DETAIL")?if_exists />
         <div class="additionalImage">
+          <#if productAdditionalImage3Small?string?has_content && productAdditionalImage3Large?string?has_content>
+            <#if productAdditionalImage3Detail?string?has_content>
+              <a href="javascript:popupDetail('${productAdditionalImage3Detail}');" swapDetail="<@o...@ofbizContentUrl>"><img src="<@o...@ofbizContentUrl>" vspace="5" hspace="5" alt="" /></a>
+            <#else>
+            <a href="javascript:void(0);" swapDetail="<@o...@ofbizContentUrl>"><img src="<@o...@ofbizContentUrl>" vspace="5" hspace="5" alt="" /></a>
+            </#if>
+          <#else>
           <a href="javascript:void(0);" swapDetail="<@o...@ofbizContentUrl>"><img src="<@o...@ofbizContentUrl>" vspace="5" hspace="5" width="200" alt="" /></a>
+          </#if>
         </div>
       </#if>
       <#if productAdditionalImage4?string?has_content>
+        <#assign productAdditionalImage4Small = productContentWrapper.get("XTRA_IMG_4_SMALL")?if_exists />
+        <#assign productAdditionalImage4Large = productContentWrapper.get("XTRA_IMG_4_LARGE")?if_exists />
+        <#assign productAdditionalImage4Detail = productContentWrapper.get("XTRA_IMG_4_DETAIL")?if_exists />
         <div class="additionalImage">
+          <#if productAdditionalImage4Small?string?has_content && productAdditionalImage4Large?string?has_content>
+            <#if productAdditionalImage4Detail?string?has_content>
+              <a href="javascript:popupDetail('${productAdditionalImage4Detail}');" swapDetail="<@o...@ofbizContentUrl>"><img src="<@o...@ofbizContentUrl>" vspace="5" hspace="5" alt="" /></a>
+            <#else>
+            <a href="javascript:void(0);" swapDetail="<@o...@ofbizContentUrl>"><img src="<@o...@ofbizContentUrl>" vspace="5" hspace="5" alt="" /></a>
+            </#if>
+          <#else>
           <a href="javascript:void(0);" swapDetail="<@o...@ofbizContentUrl>"><img src="<@o...@ofbizContentUrl>" vspace="5" hspace="5" width="200" alt="" /></a>
+          </#if>
         </div>
       </#if>
     </div>
+    </div>
     <div id="productDetailBox">
       <h2>${productContentWrapper.get("PRODUCT_NAME")?if_exists}</h2>
       <div>${productContentWrapper.get("DESCRIPTION")?if_exists}</div>
@@ -477,7 +527,7 @@ ${virtualJavaScript?if_exists}
             <div>&nbsp;</div>
       </#if>
     </div>
-</div>
+
     <div id="addItemForm">
       <form method="post" action="<@o...@ofbizUrl>" name="addform"  style="margin: 0;">
       <fieldset>