Author: hansbak
Date: Fri Apr 1 06:49:06 2011 New Revision: 1087599 URL: http://svn.apache.org/viewvc?rev=1087599&view=rev Log: Updates to the image management system: - Fixed the resize function can resize any format flie - Fixed share image screen to get host from contentURL (if it has content) - Fixed product detail screen in ecommerce - Create the function for set default image to product content screen Modified: ofbiz/trunk/applications/content/script/org/ofbiz/content/data/DataServices.xml ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/ProductDetail.groovy ofbiz/trunk/applications/product/config/ProductErrorUiLabels.xml ofbiz/trunk/applications/product/data/ProductTypeData.xml ofbiz/trunk/applications/product/script/org/ofbiz/product/imagemanagement/ImageManagementEvents.xml ofbiz/trunk/applications/product/servicedef/services.xml ofbiz/trunk/applications/product/src/org/ofbiz/product/image/ScaleImage.java ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/ImageManagementServices.java ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/product/EditProductContent.groovy ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/controller.xml ofbiz/trunk/applications/product/webapp/catalog/imagemanagement/ImageGallery.ftl ofbiz/trunk/applications/product/webapp/catalog/imagemanagement/ImageShare.ftl ofbiz/trunk/applications/product/widget/catalog/CatalogMenus.xml ofbiz/trunk/applications/product/widget/catalog/ImageManagementForms.xml ofbiz/trunk/applications/product/widget/catalog/ImageManagementScreens.xml ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/catalog/productdetail.ftl Modified: ofbiz/trunk/applications/content/script/org/ofbiz/content/data/DataServices.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/script/org/ofbiz/content/data/DataServices.xml?rev=1087599&r1=1087598&r2=1087599&view=diff ============================================================================== --- ofbiz/trunk/applications/content/script/org/ofbiz/content/data/DataServices.xml (original) +++ ofbiz/trunk/applications/content/script/org/ofbiz/content/data/DataServices.xml Fri Apr 1 06:49:06 2011 @@ -51,9 +51,11 @@ under the License. </if-empty> <if-empty field="newEntity.mimeTypeId"> - <call-class-method class-name="org.ofbiz.content.data.DataResourceWorker" method-name="getMimeTypeWithByteBuffer" ret-field="newEntity.mimeTypeId"> - <field field="parameters.uploadedFile" type="java.nio.ByteBuffer"/> - </call-class-method> + <if-not-empty field="parameters.objectInfo"> + <call-class-method class-name="org.ofbiz.content.data.DataResourceWorker" method-name="getMimeTypeWithByteBuffer" ret-field="newEntity.mimeTypeId"> + <field field="parameters.uploadedFile" type="java.nio.ByteBuffer"/> + </call-class-method> + </if-not-empty> </if-empty> <create-value value-field="newEntity"/> Modified: ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/ProductDetail.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/ProductDetail.groovy?rev=1087599&r1=1087598&r2=1087599&view=diff ============================================================================== --- ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/ProductDetail.groovy (original) +++ ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/ProductDetail.groovy Fri Apr 1 06:49:06 2011 @@ -625,4 +625,25 @@ if (product) { // not the best to save info in an action, but this is probably the best place to count a view; it is done async dispatcher.runAsync("countProductView", [productId : productId, weight : new Long(1)], false); + + //get product image from image management + productImageList = []; + productContentAndInfoImageManamentList = delegator.findByAnd("ProductContentAndInfo", ["productId": productId, productContentTypeId : "IMAGE", "statusId" : "IM_APPROVED", "drIsPublic" : "Y"], ["sequenceNum"]); + if(productContentAndInfoImageManamentList) { + productContentAndInfoImageManamentList.each { productContentAndInfoImageManament -> + contentAssocThumbList = delegator.findByAnd("ContentAssoc", [contentId : productContentAndInfoImageManament.contentId, contentAssocTypeId : "IMAGE_THUMBNAIL"]); + contentAssocThumb = EntityUtil.getFirst(contentAssocThumbList); + if(contentAssocThumb) { + imageContentThumb = delegator.findByPrimaryKey("Content", [contentId : contentAssocThumb.contentIdTo]); + if(imageContentThumb) { + productImageThumb = delegator.findByPrimaryKey("ContentDataResourceView", [contentId : imageContentThumb.contentId, drDataResourceId : imageContentThumb.dataResourceId]); + productImageMap = [:]; + productImageMap.productImageThumb = productImageThumb.drObjectInfo; + productImageMap.productImage = productContentAndInfoImageManament.drObjectInfo; + productImageList.add(productImageMap); + } + } + } + context.productImageList = productImageList; + } } Modified: ofbiz/trunk/applications/product/config/ProductErrorUiLabels.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/config/ProductErrorUiLabels.xml?rev=1087599&r1=1087598&r2=1087599&view=diff ============================================================================== --- ofbiz/trunk/applications/product/config/ProductErrorUiLabels.xml (original) +++ ofbiz/trunk/applications/product/config/ProductErrorUiLabels.xml Fri Apr 1 06:49:06 2011 @@ -77,9 +77,6 @@ <value xml:lang="zh">æ æ³ç¼©æ¾åå§å¾å</value> <value xml:lang="zh_TW">ç¡æ³ç¸®æ¾åå§åå</value> </property> - <property key="ImageManagementErrorMessageResizeImage"> - <value xml:lang="en">Cannot resize image format not jpg.</value> - </property> <property key="ProductCreateCommunicationEventProductPermissionError"> <value xml:lang="en">Create Communication Event Product Permission Error</value> <value xml:lang="it">Errore di permesso durante la creazione evento comunicazione prodotto</value> Modified: ofbiz/trunk/applications/product/data/ProductTypeData.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/data/ProductTypeData.xml?rev=1087599&r1=1087598&r2=1087599&view=diff ============================================================================== --- ofbiz/trunk/applications/product/data/ProductTypeData.xml (original) +++ ofbiz/trunk/applications/product/data/ProductTypeData.xml Fri Apr 1 06:49:06 2011 @@ -603,8 +603,7 @@ under the License. <RoleType roleTypeId="IMAGEAPPROVER" hasTable="N" description="Image Approver"/> <ProductContentType description="Image" hasTable="N" parentTypeId="" productContentTypeId="IMAGE"/> - <ProductContentType description="Image Thumbnail" hasTable="N" parentTypeId="" productContentTypeId="DEFAULT_IMAGE"/> - <ProductContentType description="Frame" hasTable="N" parentTypeId="" productContentTypeId="FRAME"/> + <ProductContentType description="Default Image" hasTable="N" parentTypeId="" productContentTypeId="DEFAULT_IMAGE"/> <ContentType contentTypeId="IMAGE_FRAME" description="Frame Image"/> Modified: ofbiz/trunk/applications/product/script/org/ofbiz/product/imagemanagement/ImageManagementEvents.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/script/org/ofbiz/product/imagemanagement/ImageManagementEvents.xml?rev=1087599&r1=1087598&r2=1087599&view=diff ============================================================================== --- ofbiz/trunk/applications/product/script/org/ofbiz/product/imagemanagement/ImageManagementEvents.xml (original) +++ ofbiz/trunk/applications/product/script/org/ofbiz/product/imagemanagement/ImageManagementEvents.xml Fri Apr 1 06:49:06 2011 @@ -46,15 +46,14 @@ under the License. </entity-and> <if-not-empty field="productContentAndInfos"> <first-from-list entry="productContentAndInfo" list="productContentAndInfos"/> + + <script location="component://product/webapp/catalog/WEB-INF/actions/imagemanagement/SetDefaultImage.groovy"/> + <entity-one value-field="product" entity-name="Product"> <field-map field-name="productId" from-field="parameters.productId"/> </entity-one> <set field="product.originalImageUrl" from-field="productContentAndInfo.drObjectInfo"/> <store-value value-field="product"/> - - <!--<set field="setThumbnailMap.productId" from-field="parameters.productId"/> - <set field="setThumbnailMap.contentIdTo" from-field="parameters.contentIdTo"/> - <call-service service-name="setThumbnail" in-map-name="setThumbnailMap"/>--> </if-not-empty> </simple-method> </simple-methods> Modified: ofbiz/trunk/applications/product/servicedef/services.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/servicedef/services.xml?rev=1087599&r1=1087598&r2=1087599&view=diff ============================================================================== --- ofbiz/trunk/applications/product/servicedef/services.xml (original) +++ ofbiz/trunk/applications/product/servicedef/services.xml Fri Apr 1 06:49:06 2011 @@ -1497,13 +1497,6 @@ under the License. <attribute name="partyId" mode="IN" type="String" optional="false"/> </service> - <service name="setThumbnail" engine="java" - location="org.ofbiz.product.imagemanagement.ImageManagementServices" invoke="setThumbnail" auth="true"> - <description>Set Thumbnail for product</description> - <attribute mode="IN" name="contentIdTo" optional="false" type="String"/> - <attribute mode="IN" name="productId" optional="false" type="String"/> - </service> - <service name="resizeAllImageOfProduct" engine="simple" location="component://product/script/org/ofbiz/product/imagemanagement/ImageManagementServices.xml" invoke="resizeAllImageOfProduct" auth="true"> <description>Resize All Image Of Product.</description> 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=1087599&r1=1087598&r2=1087599&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 Apr 1 06:49:06 2011 @@ -197,7 +197,7 @@ public class ScaleImage { for(File file : files) { if (file.isFile() && file.getName().startsWith(id)) { file.delete(); - } + } } } catch (SecurityException e) { Debug.logError(e,module); @@ -243,10 +243,10 @@ public class ScaleImage { return ServiceUtil.returnError(errMsg); } } - + public static Map<String, Object> scaleImageManageInAllSize(Map<String, ? extends Object> context, String filenameToUse, String viewType, String viewNumber , String imageType) throws IllegalArgumentException, ImagingOpException, IOException, JDOMException { - + /* VARIABLES */ Locale locale = (Locale) context.get("locale"); List<String> sizeTypeList = null; @@ -265,7 +265,7 @@ public class ScaleImage { Map<String, Object> resultBufImgMap = FastMap.newInstance(); Map<String, Object> resultScaleImgMap = FastMap.newInstance(); Map<String, Object> result = FastMap.newInstance(); - + /* ImageProperties.xml */ String imgPropertyFullPath = System.getProperty("ofbiz.home") + "/applications/product/config/ImageProperties.xml"; resultXMLMap.putAll(ImageTransform.getXMLValue(imgPropertyFullPath, locale)); @@ -277,7 +277,7 @@ public class ScaleImage { result.put("errorMessage", errMsg); return result; } - + /* IMAGE */ // get Name and Extension index = filenameToUse.lastIndexOf("."); @@ -287,7 +287,7 @@ public class ScaleImage { String mainFilenameFormat = UtilProperties.getPropertyValue("catalog", "image.filename.format"); String imageServerPath = FlexibleStringExpander.expandString(UtilProperties.getPropertyValue("catalog", "image.server.path"), context); String imageUrlPrefix = UtilProperties.getPropertyValue("catalog", "image.url.prefix"); - + String id = null; String type = null; if (viewType.toLowerCase().contains("main")) { @@ -316,7 +316,7 @@ public class ScaleImage { if (resultBufImgMap.containsKey("responseMessage") && resultBufImgMap.get("responseMessage").equals("success")) { bufImg = (BufferedImage) resultBufImgMap.get("bufferedImage"); - + // get Dimensions imgHeight = (double) bufImg.getHeight(); imgWidth = (double) bufImg.getWidth(); @@ -326,23 +326,23 @@ public class ScaleImage { result.put("errorMessage", errMsg); return result; } - + // new Filename Format FlexibleStringExpander addFilenameExpander = mainFilenameExpander; if (viewType.toLowerCase().contains("additional")) { String addFilenameFormat = UtilProperties.getPropertyValue("catalog", "image.filename.additionalviewsize.format"); addFilenameExpander = FlexibleStringExpander.getInstance(addFilenameFormat); } - + /* scale Image for each Size Type */ Iterator<String> sizeIter = sizeTypeList.iterator(); while (sizeIter.hasNext()) { String sizeType = sizeIter.next(); resultScaleImgMap.putAll(ImageTransform.scaleImage(bufImg, imgHeight, imgWidth, imgPropertyMap, sizeType, locale)); - + if (resultScaleImgMap.containsKey("responseMessage") && resultScaleImgMap.get("responseMessage").equals("success")) { bufNewImg = (BufferedImage) resultScaleImgMap.get("bufferedImage"); - + // write the New Scaled Image String newFileLocation = null; if (viewType.toLowerCase().contains("main")) { @@ -354,7 +354,7 @@ public class ScaleImage { if (newFileLocation.lastIndexOf("/") != -1) { newFilePathPrefix = newFileLocation.substring(0, newFileLocation.lastIndexOf("/") + 1); // adding 1 to include the trailing slash } - + String targetDirectory = imageServerPath + "/" + newFilePathPrefix; File targetDir = new File(targetDirectory); if (!targetDir.exists()) { @@ -365,7 +365,7 @@ public class ScaleImage { return ServiceUtil.returnError(errMsg); } } - + // write new image try { ImageIO.write((RenderedImage) bufNewImg, imgExtension, new File(imageServerPath + "/" + newFilePathPrefix + filenameToUse)); @@ -380,19 +380,19 @@ public class ScaleImage { result.put("errorMessage", errMsg); return result; } - + /* write Return Result */ String imageUrl = imageUrlPrefix + "/" + newFilePathPrefix + filenameToUse; imgUrlMap.put(sizeType, imageUrl); - + } // scaleImgMap } // sizeIter - + result.put("responseMessage", "success"); result.put("imageUrlMap", imgUrlMap); result.put("original", resultBufImgMap); return result; - + } else { String errMsg = UtilProperties.getMessage(resource, "ScaleImage.unable_to_scale_original_image", locale) + " : " + filenameToUse; Debug.logError(errMsg, module); Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/ImageManagementServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/ImageManagementServices.java?rev=1087599&r1=1087598&r2=1087599&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/ImageManagementServices.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/ImageManagementServices.java Fri Apr 1 06:49:06 2011 @@ -535,14 +535,14 @@ public class ImageManagementServices { String contentIdThumb = (String) contentThumbResult.get("contentId"); result.put("contentIdThumb", contentIdThumb); -/* // File to use for image thumbnail + /*// File to use for image thumbnail FlexibleStringExpander filenameExpanderThumb = FlexibleStringExpander.getInstance(imageFilenameFormat); String fileLocationThumb = filenameExpanderThumb.expandString(UtilMisc.toMap("location", "products", "type", "small", "id", contentIdThumb)); String filenameToUseThumb = fileLocationThumb; if (fileLocationThumb.lastIndexOf("/") != -1) { filenameToUseThumb = fileLocationThumb.substring(fileLocationThumb.lastIndexOf("/") + 1); } - + String fileContentType = (String) context.get("_uploadedFile_contentType"); if (fileContentType.equals("image/pjpeg")) { fileContentType = "image/jpeg"; @@ -788,77 +788,6 @@ public class ImageManagementServices { } } - public static Map<String, Object> setThumbnail(DispatchContext dctx, Map<String, ? extends Object> context) { - LocalDispatcher dispatcher = dctx.getDispatcher(); - Delegator delegator = dctx.getDelegator(); - GenericValue userLogin = (GenericValue) context.get("userLogin"); - String productId = (String) context.get("productId"); - String contentIdTo = (String) context.get("contentIdTo"); - - try { - if (UtilValidate.isNotEmpty(contentIdTo)) { - String imageFilenameFormat = UtilProperties.getPropertyValue("catalog", "image.filename.format"); - String imageServerPath = FlexibleStringExpander.expandString(UtilProperties.getPropertyValue("catalog", "image.management.path"), context); - - FlexibleStringExpander filenameExpander = FlexibleStringExpander.getInstance(imageFilenameFormat); - String fileLocation = filenameExpander.expandString(UtilMisc.toMap("location", "products", "type", "medium", "id", productId)); - String filePathPrefix = ""; - String filenameToUse = fileLocation; - if (fileLocation.lastIndexOf("/") != -1) { - filePathPrefix = fileLocation.substring(0, fileLocation.lastIndexOf("/") + 1); // adding 1 to include the trailing slash - filenameToUse = fileLocation.substring(fileLocation.lastIndexOf("/") + 1); - } - - GenericValue content = null; - try { - content = delegator.findOne("Content", UtilMisc.toMap("contentId", contentIdTo), false); - } catch (GenericEntityException e) { - Debug.logError(e, module); - return ServiceUtil.returnError(e.getMessage()); - } - - String contentName = (String) content.get("contentName"); - - if (contentName.lastIndexOf(".") > 0 && contentName.lastIndexOf(".") < contentName.length()) { - filenameToUse += contentName.substring(contentName.lastIndexOf(".")); - } else { - filenameToUse += ".jpg"; - } - - try { - File f1 = new File(imageServerPath + "/" + productId + "/" + contentName); - File f2 = new File(imageServerPath + "/" + filePathPrefix, filenameToUse); - InputStream input = new FileInputStream(f1); - OutputStream out = new FileOutputStream(f2); - - byte[] buf = new byte[1024]; - int len; - while ((len = input.read(buf)) > 0){ - out.write(buf, 0, len); - } - input.close(); - out.close(); - - Map<String, Object> updateProductMap = FastMap.newInstance(); - updateProductMap.put("userLogin", userLogin); - updateProductMap.put("productId", productId); - updateProductMap.put("smallImageUrl", "/images/products/small/" + filenameToUse); - try { - dispatcher.runSync("updateProduct", updateProductMap); - } catch (GenericServiceException e) { - Debug.logError(e, module); - return ServiceUtil.returnError(e.getMessage()); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - } catch (Exception e) { - return ServiceUtil.returnError(e.getMessage()); - } - return ServiceUtil.returnSuccess(); - } - public static File checkExistsImage(File file) { if (!file.exists()) { imageCount = 0; @@ -928,6 +857,7 @@ public class ImageManagementServices { String contentId = (String) context.get("contentId"); String dataResourceName = (String) context.get("dataResourceName"); String width = (String) context.get("resizeWidth"); + String imageType = ".jpg"; int resizeWidth = Integer.parseInt(width); int resizeHeight = resizeWidth; @@ -935,46 +865,43 @@ public class ImageManagementServices { BufferedImage bufImg = ImageIO.read(new File(imageServerPath + "/" + productId + "/" + dataResourceName)); double imgHeight = bufImg.getHeight(); double imgWidth = bufImg.getWidth(); - String filenameToUse = dataResourceName.substring(0, dataResourceName.length() - 4) + "-" + resizeWidth + ".jpg"; + if (dataResourceName.lastIndexOf(".") > 0 && dataResourceName.lastIndexOf(".") < dataResourceName.length()) { + imageType = dataResourceName.substring(dataResourceName.lastIndexOf(".")); + } + + String filenameToUse = dataResourceName.substring(0, dataResourceName.length() - 4) + "-" + resizeWidth + imageType; if (dataResourceName.length() > 3) { String mimeType = dataResourceName.substring(dataResourceName.length() - 3, dataResourceName.length()); - if (mimeType.equals("jpg")) { - Map<String, Object> resultResize = ImageManagementServices.resizeImage(bufImg, imgHeight, imgWidth, resizeHeight, resizeWidth); - ImageIO.write((RenderedImage) resultResize.get("bufferedImage"), mimeType, new File(imageServerPath + "/" + productId + "/" + filenameToUse)); - - Map<String, Object> contentThumb = FastMap.newInstance(); - contentThumb.put("contentTypeId", "DOCUMENT"); - contentThumb.put("userLogin", userLogin); - Map<String, Object> contentThumbResult = FastMap.newInstance(); - try { - contentThumbResult = dispatcher.runSync("createContent", contentThumb); - } catch (GenericServiceException e) { - Debug.logError(e, module); - return ServiceUtil.returnError(e.getMessage()); - } - - String contentIdThumb = (String) contentThumbResult.get("contentId"); - String imageUrlThumb = imageServerUrl + "/" + productId + "/" + filenameToUse; - ImageManagementServices.createContentAndDataResource(dctx, userLogin, filenameToUse, imageUrlThumb, contentIdThumb, "image/jpeg"); - - Map<String, Object> createContentAssocMap = FastMap.newInstance(); - createContentAssocMap.put("contentAssocTypeId", "IMAGE_THUMBNAIL"); - createContentAssocMap.put("contentId", contentId); - createContentAssocMap.put("contentIdTo", contentIdThumb); - createContentAssocMap.put("userLogin", userLogin); - createContentAssocMap.put("mapKey", width); - try { - dispatcher.runSync("createContentAssoc", createContentAssocMap); - } catch (GenericServiceException e) { - Debug.logError(e, module); - return ServiceUtil.returnError(e.getMessage()); - } + Map<String, Object> resultResize = ImageManagementServices.resizeImage(bufImg, imgHeight, imgWidth, resizeHeight, resizeWidth); + ImageIO.write((RenderedImage) resultResize.get("bufferedImage"), mimeType, new File(imageServerPath + "/" + productId + "/" + filenameToUse)); + + Map<String, Object> contentThumb = FastMap.newInstance(); + contentThumb.put("contentTypeId", "DOCUMENT"); + contentThumb.put("userLogin", userLogin); + Map<String, Object> contentThumbResult = FastMap.newInstance(); + try { + contentThumbResult = dispatcher.runSync("createContent", contentThumb); + } catch (GenericServiceException e) { + Debug.logError(e, module); + return ServiceUtil.returnError(e.getMessage()); } - else{ - String errMsg = UtilProperties.getMessage(resource, "ImageManagementErrorMessageResizeImage", locale); - Debug.logError(errMsg, module); - return ServiceUtil.returnError(errMsg); + + String contentIdThumb = (String) contentThumbResult.get("contentId"); + String imageUrlThumb = imageServerUrl + "/" + productId + "/" + filenameToUse; + ImageManagementServices.createContentAndDataResource(dctx, userLogin, filenameToUse, imageUrlThumb, contentIdThumb, "image/jpeg"); + + Map<String, Object> createContentAssocMap = FastMap.newInstance(); + createContentAssocMap.put("contentAssocTypeId", "IMAGE_THUMBNAIL"); + createContentAssocMap.put("contentId", contentId); + createContentAssocMap.put("contentIdTo", contentIdThumb); + createContentAssocMap.put("userLogin", userLogin); + createContentAssocMap.put("mapKey", width); + try { + dispatcher.runSync("createContentAssoc", createContentAssocMap); + } catch (GenericServiceException e) { + Debug.logError(e, module); + return ServiceUtil.returnError(e.getMessage()); } } } catch (Exception e) { @@ -994,17 +921,19 @@ public class ImageManagementServices { String productId = (String) context.get("productId"); String contentId = (String) context.get("contentId"); String filenameToUse = (String) context.get("drDataResourceName"); - String mimeType = filenameToUse.substring(filenameToUse.length() - 3, filenameToUse.length()); + String imageType = filenameToUse.substring(filenameToUse.lastIndexOf(".")); + String imgExtension = filenameToUse.substring(filenameToUse.length() - 3, filenameToUse.length()); String imageUrl = imageServerUrl + "/" + productId + "/" + filenameToUse; try { - if (mimeType.equals("jpg")) { - List<GenericValue> productContentList = delegator.findByAnd("ProductContentAndInfo", UtilMisc.toMap("productId", productId, "contentId", contentId, "productContentTypeId", "IMAGE")); - GenericValue productContent = EntityUtil.getFirst(productContentList); - String dataResourceName = (String) productContent.get("drDataResourceName"); - + List<GenericValue> productContentList = delegator.findByAnd("ProductContentAndInfo", UtilMisc.toMap("productId", productId, "contentId", contentId, "productContentTypeId", "IMAGE")); + GenericValue productContent = EntityUtil.getFirst(productContentList); + String dataResourceName = (String) productContent.get("drDataResourceName"); + String mimeType = filenameToUse.substring(filenameToUse.lastIndexOf(".")); + + if (imageType.equals(mimeType)) { BufferedImage bufImg = ImageIO.read(new File(imageServerPath + "/" + productId + "/" + dataResourceName)); - ImageIO.write((RenderedImage) bufImg, "jpg", new File(imageServerPath + "/" + productId + "/" + filenameToUse)); + ImageIO.write((RenderedImage) bufImg, imgExtension, new File(imageServerPath + "/" + productId + "/" + filenameToUse)); File file = new File(imageServerPath + "/" + productId + "/" + dataResourceName); file.delete(); @@ -1059,11 +988,11 @@ public class ImageManagementServices { GenericValue dataResourceAssoc = EntityUtil.getFirst(dataResourceAssocList); String drDataResourceNameAssoc = (String) dataResourceAssoc.get("drDataResourceName"); - String filenameToUseAssoc = filenameToUse.substring(0, filenameToUse.length() - 4) + "-" + contentAssoc.get("mapKey") + ".jpg"; + String filenameToUseAssoc = filenameToUse.substring(0, filenameToUse.length() - 4) + "-" + contentAssoc.get("mapKey") + imageType; String imageUrlAssoc = imageServerUrl + "/" + productId + "/" + filenameToUseAssoc; BufferedImage bufImgAssoc = ImageIO.read(new File(imageServerPath + "/" + productId + "/" + drDataResourceNameAssoc)); - ImageIO.write((RenderedImage) bufImgAssoc, "jpg", new File(imageServerPath + "/" + productId + "/" + filenameToUseAssoc)); + ImageIO.write((RenderedImage) bufImgAssoc, imgExtension, new File(imageServerPath + "/" + productId + "/" + filenameToUseAssoc)); File fileAssoc = new File(imageServerPath + "/" + productId + "/" + drDataResourceNameAssoc); fileAssoc.delete(); Modified: ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/product/EditProductContent.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/product/EditProductContent.groovy?rev=1087599&r1=1087598&r2=1087599&view=diff ============================================================================== --- ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/product/EditProductContent.groovy (original) +++ ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/product/EditProductContent.groovy Fri Apr 1 06:49:06 2011 @@ -122,7 +122,7 @@ if (fileType) { } else { File[] files = targetDir.listFiles(); for(File file : files) { - if (file.isFile() && !file.getName().equals(defaultFileName) && file.getName().startsWith(productId + ".")) file.delete(); + if (file.isFile() && !file.getName().equals(defaultFileName) && file.getName().startsWith(productId + ".")) file.delete(); } } } catch (Exception e) { Modified: ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/controller.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/controller.xml?rev=1087599&r1=1087598&r2=1087599&view=diff ============================================================================== --- ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/controller.xml (original) +++ ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/controller.xml Fri Apr 1 06:49:06 2011 @@ -2937,20 +2937,6 @@ under the License. <event type="java" path="org.ofbiz.virtualvillage.imagemanagement.ImageManagementServices" invoke="progressUploadImage"/> <response name="success" type="view" value="main"/> </request-map> - <request-map uri="AutomaticResize"> - <security https="true" auth="true"/> - <response name="success" type="view" value="AutomaticResize"/> - <response name="error" type="view" value="AutomaticResize"/> - </request-map> - <request-map uri="ListAutomaticResize"> - <security https="true" auth="true"/> - <response name="success" type="view" value="ListAutomaticResize"/> - <response name="error" type="view" value="ListAutomaticResize"/> - </request-map> - <request-map uri="UploadProductImageForManageMent"> - <security https="true" auth="true"/> - <response name="success" type="view" value="ListAutomaticResize"/> - </request-map> <request-map uri="chooseFrameImage"> <security https="true" auth="true"/> <event type="java" path="org.ofbiz.product.imagemanagement.FrameImage" invoke="chooseFrameImage"/> Modified: ofbiz/trunk/applications/product/webapp/catalog/imagemanagement/ImageGallery.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/imagemanagement/ImageGallery.ftl?rev=1087599&r1=1087598&r2=1087599&view=diff ============================================================================== --- ofbiz/trunk/applications/product/webapp/catalog/imagemanagement/ImageGallery.ftl (original) +++ ofbiz/trunk/applications/product/webapp/catalog/imagemanagement/ImageGallery.ftl Fri Apr 1 06:49:06 2011 @@ -19,57 +19,50 @@ under the License. <table cellspacing="0" cellpadding="0" border="0" align="center" width="100%"> <#assign imageIndex = 0> - <#if productContentAndInfos?has_content> + <#if productImageList?has_content> <#if product?has_content> <h1><b>${product.productId}</b></h1> </#if> <#-- <#assign productName = productTextData > <#assign seoUrl = productName.replaceAll(" ", "-") > --> <#assign alt_row = false> - <#list productContentAndInfos as productContentAndInfo> - <#assign contentAssocs = delegator.findByAnd("ContentAssoc",Static["org.ofbiz.base.util.UtilMisc"].toMap("contentId", productContentAndInfo.contentId?if_exists, "contentAssocTypeId", "IMAGE_THUMBNAIL"))/> - <#if contentAssocs?has_content> - <#assign contentAssoc = Static["org.ofbiz.entity.util.EntityUtil"].getFirst(contentAssocs) /> - <#assign ImageContent = delegator.findByPrimaryKey("Content", Static["org.ofbiz.base.util.UtilMisc"].toMap("contentId", contentAssoc.contentIdTo))?if_exists> - <#assign contentDataResourceView = delegator.findByPrimaryKey("ContentDataResourceView", Static["org.ofbiz.base.util.UtilMisc"].toMap("contentId", contentAssoc.contentIdTo, "drDataResourceId", ImageContent.dataResourceId))?if_exists> - <#assign contentName = productContentAndInfo.contentName> - <#if imageIndex < 5> - <td style="vertical-align:bottom"> - <table> - <tbody> - <tr valign="middle"> - <#-- <td align="center"><a href="/catalog/images/${seoUrl}-${product.productId}/${seoUrl}-${contentName}" target="_blank"><img src="<@ofbizContentUrl>${(contentDataResourceView.drObjectInfo)?if_exists}</@ofbizContentUrl>" vspace="5" hspace="5" alt=""/></a></td> --> - <td align="center"><a href="<@ofbizContentUrl>${(productContentAndInfo.drObjectInfo)?if_exists}</@ofbizContentUrl>" target="_blank"><img src="<@ofbizContentUrl>${(contentDataResourceView.drObjectInfo)?if_exists}</@ofbizContentUrl>" vspace="5" hspace="5" alt=""/></a></td> - </tr> - <tr valign="middle"> - <#-- <td align="center"><a href="javascript:lookup_popup2('ImageShare?contentId=${productContentAndInfo.contentId}&dataResourceId=${productContentAndInfo.dataResourceId}&seoUrl=/catalog/images/${seoUrl}-${product.productId}/${seoUrl}-${contentName}','' ,500,500);" class="buttontext">Share</a></td> --> - <td align="center"><a href="javascript:lookup_popup2('ImageShare?contentId=${productContentAndInfo.contentId}&dataResourceId=${productContentAndInfo.dataResourceId}','' ,500,500);" class="buttontext">Share</a></td> - </tr> - <br/> - </tbody> - </table> - </td> - <#assign imageIndex = imageIndex+1> - <#else> - <#assign imageIndex = 0> - <tr></tr> - <td style="vertical-align:bottom"> - <table> - <tbody> - <tr valign="middle"> - <#-- <td align="center"><a href="/catalog/images/${seoUrl}-${product.productId}/${seoUrl}-${contentName}" target="_blank"><img src="<@ofbizContentUrl>${(contentDataResourceView.drObjectInfo)?if_exists}</@ofbizContentUrl>" vspace="5" hspace="5" alt=""/></a></td> --> - <td align="center"><a href="<@ofbizContentUrl>${(productContentAndInfo.drObjectInfo)?if_exists}</@ofbizContentUrl>" target="_blank"><img src="<@ofbizContentUrl>${(contentDataResourceView.drObjectInfo)?if_exists}</@ofbizContentUrl>" vspace="5" hspace="5" alt=""/></a></td> - </tr> - <tr valign="middle"> - <#-- <td align="center"><a href="javascript:lookup_popup2('ImageShare?contentId=${productContentAndInfo.contentId}&dataResourceId=${productContentAndInfo.dataResourceId}&seoUrl=/catalog/images/${seoUrl}-${product.productId}/${seoUrl}-${contentName}','' ,500,500);" class="buttontext">Share</a></td> --> - <td align="center"><a href="javascript:lookup_popup2('ImageShare?contentId=${productContentAndInfo.contentId}&dataResourceId=${productContentAndInfo.dataResourceId}','' ,500,500);" class="buttontext">Share</a></td> - </tr> - <br/> - </tbody> - </table> - </td> - <#assign imageIndex = imageIndex+1> - </#if> + <#list productImageList as productImage> + <#if imageIndex < 5> + <td style="vertical-align:bottom"> + <table> + <tbody> + <tr valign="middle"> + <#-- <td align="center"><a href="/catalog/images/${seoUrl}-${product.productId}/${seoUrl}-${contentName}" target="_blank"><img src="<@ofbizContentUrl>${(contentDataResourceView.drObjectInfo)?if_exists}</@ofbizContentUrl>" vspace="5" hspace="5" alt=""/></a></td> --> + <td align="center"><a href="<@ofbizContentUrl>${(productImage.productImage)?if_exists}</@ofbizContentUrl>" target="_blank"><img src="<@ofbizContentUrl>${(productImage.productImageThumb)?if_exists}</@ofbizContentUrl>" vspace="5" hspace="5" alt=""/></a></td> + </tr> + <tr valign="middle"> + <#-- <td align="center"><a href="javascript:lookup_popup2('ImageShare?contentId=${productContentAndInfo.contentId}&dataResourceId=${productContentAndInfo.dataResourceId}&seoUrl=/catalog/images/${seoUrl}-${product.productId}/${seoUrl}-${contentName}','' ,500,500);" class="buttontext">Share</a></td> --> + <td align="center"><a href="javascript:lookup_popup2('ImageShare?contentId=${productImage.contentId}&dataResourceId=${productImage.dataResourceId}','' ,500,500);" class="buttontext">Share</a></td> + </tr> + <br/> + </tbody> + </table> + </td> + <#assign imageIndex = imageIndex+1> + <#else> + <#assign imageIndex = 0> + <tr></tr> + <td style="vertical-align:bottom"> + <table> + <tbody> + <tr valign="middle"> + <#-- <td align="center"><a href="/catalog/images/${seoUrl}-${product.productId}/${seoUrl}-${contentName}" target="_blank"><img src="<@ofbizContentUrl>${(contentDataResourceView.drObjectInfo)?if_exists}</@ofbizContentUrl>" vspace="5" hspace="5" alt=""/></a></td> --> + <td align="center"><a href="<@ofbizContentUrl>${(productImage.productImage)?if_exists}</@ofbizContentUrl>" target="_blank"><img src="<@ofbizContentUrl>${(productImage.productImageThumb)?if_exists}</@ofbizContentUrl>" vspace="5" hspace="5" alt=""/></a></td> + </tr> + <tr valign="middle"> + <#-- <td align="center"><a href="javascript:lookup_popup2('ImageShare?contentId=${productContentAndInfo.contentId}&dataResourceId=${productContentAndInfo.dataResourceId}&seoUrl=/catalog/images/${seoUrl}-${product.productId}/${seoUrl}-${contentName}','' ,500,500);" class="buttontext">Share</a></td> --> + <td align="center"><a href="javascript:lookup_popup2('ImageShare?contentId=${productImage.contentId}&dataResourceId=${productImage.dataResourceId}','' ,500,500);" class="buttontext">Share</a></td> + </tr> + <br/> + </tbody> + </table> + </td> + <#assign imageIndex = imageIndex+1> </#if> </#list> </#if> Modified: ofbiz/trunk/applications/product/webapp/catalog/imagemanagement/ImageShare.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/imagemanagement/ImageShare.ftl?rev=1087599&r1=1087598&r2=1087599&view=diff ============================================================================== --- ofbiz/trunk/applications/product/webapp/catalog/imagemanagement/ImageShare.ftl (original) +++ ofbiz/trunk/applications/product/webapp/catalog/imagemanagement/ImageShare.ftl Fri Apr 1 06:49:06 2011 @@ -16,29 +16,41 @@ KIND, either express or implied. See th specific language governing permissions and limitations under the License. --> +<#assign contentURL = Static["org.ofbiz.base.util.UtilProperties"].getPropertyValue("url.properties", "content.url.prefix.standard")> <script type="text/javascript"> -var form = document.ImageShare; -var protocol = document.location.protocol; -var host = document.location.host; -var imageUrl = form.imageURL.value; -var imageThumbUrl = form.imageThumbnail.value; -form.direct.setAttribute('readOnly','readonly'); -form.html.setAttribute('readOnly','readonly'); -form.forumCode.setAttribute('readOnly','readonly'); -form.altForumCode.setAttribute('readOnly','readonly'); - -var pathImageUrl = "http://" + host + imageUrl; -var pathImageThumbnailUrl = "http://"+ host + imageThumbUrl; - -if (form.contentId.value != "") { - form.link.value = "http://" + host + form.seoURL.value; - form.direct.value = pathImageUrl; - form.html.value = "<a target='_blank' title='Image' href='" + pathImageUrl + "'><img src='" + pathImageUrl + "' border='0'/></a>Uploaded with <a target='_blank' href='http://images.ofbiz.com'>ofbiz.com</a>"; - form.forumCode.value = "[URL=" + pathImageUrl + "/][IMG]" + pathImageUrl + "[/IMG][/URL]Uploaded with [URL=http://images.ofbiz.com]ofbiz.com[/URL]"; - form.altForumCode.value = "[URL=" + pathImageUrl + "/][IMG]" + pathImageUrl + "[/IMG][/URL]Uploaded with [URL=http://images.ofbiz.com]ofbiz.com[/URL]"; - form.forumThumbnail.value = "[URL=" + pathImageThumbnailUrl + "/][IMG]" + pathImageThumbnailUrl + "[/IMG][/URL]Uploaded with [URL=http://images.ofbiz.com]ofbiz.com[/URL]"; - form.altForumThumbnail.value = "[URL=" + pathImageThumbnailUrl + "/][IMG]" + pathImageThumbnailUrl + "[/IMG][/URL]Uploaded with [URL=http://images.ofbiz.com]ofbiz.com[/URL]"; - form.htmlThumbnail.value = "<a target='_blank' title='Image' href='" + pathImageThumbnailUrl + "'><img src='" + pathImageThumbnailUrl + "' border='0'/></a>Uploaded with <a target='_blank' href='http://images.ofbiz.com'>ofbiz.com</a>"; -} +$(document).ready(function(){ + var form = document.ImageShare; + var protocol = document.location.protocol; + var host = document.location.host; + var contentURL = '${contentURL}'; + var imageUrl = form.imageURL.value; + var imageThumbUrl = form.imageThumbnail.value; + form.direct.setAttribute('readOnly','readonly'); + form.html.setAttribute('readOnly','readonly'); + form.forumCode.setAttribute('readOnly','readonly'); + form.altForumCode.setAttribute('readOnly','readonly'); + + if (contentURL != "") { + var pathImageUrl = contentURL + imageUrl; + var pathImageThumbnailUrl = contentURL + imageThumbUrl; + } + else { + var pathImageUrl = "http://" + host + imageUrl; + var pathImageThumbnailUrl = "http://"+ host + imageThumbUrl; + } + + if (form.contentId.value != "") { + pathImageUrl = $('#ImageShare_direct').html(pathImageUrl).text(); + pathImageThumbnailUrl = $('#ImageShare_direct').html(pathImageThumbnailUrl).text(); + form.link.value = "http://" + host + form.seoURL.value; + form.direct.value = pathImageUrl; + form.html.value = "<a target='_blank' title='Image' href='" + pathImageUrl + "'><img src='" + pathImageUrl + "' border='0'/></a>Uploaded with <a target='_blank' href='http://images.ofbiz.com'>ofbiz.com</a>"; + form.forumCode.value = "[URL=" + pathImageUrl + "/][IMG]" + pathImageUrl + "[/IMG][/URL]Uploaded with [URL=http://images.ofbiz.com]ofbiz.com[/URL]"; + form.altForumCode.value = "[URL=" + pathImageUrl + "/][IMG]" + pathImageUrl + "[/IMG][/URL]Uploaded with [URL=http://images.ofbiz.com]ofbiz.com[/URL]"; + form.forumThumbnail.value = "[URL=" + pathImageThumbnailUrl + "/][IMG]" + pathImageThumbnailUrl + "[/IMG][/URL]Uploaded with [URL=http://images.ofbiz.com]ofbiz.com[/URL]"; + form.altForumThumbnail.value = "[URL=" + pathImageThumbnailUrl + "/][IMG]" + pathImageThumbnailUrl + "[/IMG][/URL]Uploaded with [URL=http://images.ofbiz.com]ofbiz.com[/URL]"; + form.htmlThumbnail.value = "<a target='_blank' title='Image' href='" + pathImageThumbnailUrl + "'><img src='" + pathImageThumbnailUrl + "' border='0'/></a>Uploaded with <a target='_blank' href='http://images.ofbiz.com'>ofbiz.com</a>"; + } +}); </script> Modified: ofbiz/trunk/applications/product/widget/catalog/CatalogMenus.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/widget/catalog/CatalogMenus.xml?rev=1087599&r1=1087598&r2=1087599&view=diff ============================================================================== --- ofbiz/trunk/applications/product/widget/catalog/CatalogMenus.xml (original) +++ ofbiz/trunk/applications/product/widget/catalog/CatalogMenus.xml Fri Apr 1 06:49:06 2011 @@ -563,12 +563,5 @@ under the License. <parameter param-name="productId"/> </link> </menu-item> - <!--<menu-item name="AutomaticResize" title="${uiLabelMap.AutomaticResize}"> - <condition> - <if-has-permission permission="IMAGE_MANAGEMENT_ADMIN"/> - </condition> - <link target="AutomaticResize"/> - </menu-item>--> </menu> - </menus> Modified: ofbiz/trunk/applications/product/widget/catalog/ImageManagementForms.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/widget/catalog/ImageManagementForms.xml?rev=1087599&r1=1087598&r2=1087599&view=diff ============================================================================== --- ofbiz/trunk/applications/product/widget/catalog/ImageManagementForms.xml (original) +++ ofbiz/trunk/applications/product/widget/catalog/ImageManagementForms.xml Fri Apr 1 06:49:06 2011 @@ -193,7 +193,7 @@ under the License. <display-entity entity-name="Product" key-field-name="productId" description="${internalName} [${productId}] - ${productCategory.categoryName}" also-hidden="false"/> </field> <field name="_rowSubmit" position="2" title=" " widget-style="hidden"><check all-checked="true"/></field> - <field name="drObjectInfo" position="2" title="Image"><image width="100"/></field> + <field name="drObjectInfo" position="2" title="Image"><image width="100"/></field> <field name="drDataResourceName" position="2" title="Image Name"><display/></field> <field name="contentId" position="2"><display/></field> <field name="dataResourceId" position="2"><display/></field> @@ -793,11 +793,6 @@ under the License. </field> </form> - <form name="AutomaticResize" type="single" title="" header-row-style="header-row" default-table-style="basic-table" target="ListAutomaticResize"> - <field name="productId" title="Choose Product ID"><lookup target-form-name="LookupProduct"/></field> - <field name="submitButton" title="${uiLabelMap.CommonSubmit}" widget-style="smallSubmit"><submit button-type="button"/></field> - </form> - <form name="ListLookupImageFrame" type="list" list-name="listIt" paginate-target="ListLookupImageFrame" odd-row-style="alternate-row" default-table-style="basic-table hover-bar"> <actions> <entity-condition entity-name="ContentDataResourceView"> @@ -882,7 +877,7 @@ under the License. </entity-condition> </actions> <field name="mapKey" title="Size"><display/></field> - <field name="deleteButton" title="${uiLabelMap.CommonRemove}" widget-style="buttontext"> + <field name="deleteButton" title="${uiLabelMap.CommonRemove}" use-when="${groovy: return context.mapKey != '100';}" widget-style="buttontext"> <hyperlink target="removeImageBySize" description="${uiLabelMap.CommonRemove}" also-hidden="false" confirmation-message="Do you want to remove this size?"> <parameter param-name="productId" from-field="parameters.productId"/> <parameter param-name="mapKey" from-field="mapKey"/> @@ -901,7 +896,6 @@ under the License. <condition-list combine="and"> <condition-expr field-name="productId" from-field="parameters.productId"/> <condition-expr field-name="productContentTypeId" value="IMAGE"/> - <condition-expr field-name="drMimeTypeId" value="image/jpeg"/> <!--<condition-expr field-name="statusId" from-field="statusForm"/>--> </condition-list> </entity-condition> Modified: ofbiz/trunk/applications/product/widget/catalog/ImageManagementScreens.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/widget/catalog/ImageManagementScreens.xml?rev=1087599&r1=1087598&r2=1087599&view=diff ============================================================================== --- ofbiz/trunk/applications/product/widget/catalog/ImageManagementScreens.xml (original) +++ ofbiz/trunk/applications/product/widget/catalog/ImageManagementScreens.xml Fri Apr 1 06:49:06 2011 @@ -87,17 +87,7 @@ under the License. <section> <actions> <set field="userTabButtonImage" value="ImageGallery"/> - <entity-condition entity-name="ProductContentAndInfo" list="productContentAndInfos"> - <condition-list combine="and"> - <condition-expr field-name="productId" from-field="parameters.productId"/> - <condition-expr field-name="productContentTypeId" value="IMAGE"/> - <condition-expr field-name="statusId" value="IM_APPROVED"/> - <condition-expr field-name="drIsPublic" value="Y"/> - </condition-list> - <order-by field-name="sequenceNum"/> - </entity-condition> - - <entity-and list="productContents" entity-name="ProductContent"> + <!--<entity-and list="productContents" entity-name="ProductContent"> <field-map field-name="productId" from-field="parameters.productId" /> <field-map field-name="productContentTypeId" value="PRODUCT_NAME" /> </entity-and> @@ -105,10 +95,11 @@ under the License. <entity-and list="contentAssocs" entity-name="ContentAssoc"> <field-map field-name="contentId" from-field="productContents[0].contentId" /> <field-map field-name="contentAssocTypeId" value="ALTERNATE_LOCALE" /> - </entity-and> + </entity-and>--> <!--<entity-one value-field="product" entity-name="Product"/>--> - <script location="component://product/webapp/catalog/WEB-INF/actions/imagemanagement/seoLocales.groovy"/> + <!--<script location="component://product/webapp/catalog/WEB-INF/actions/imagemanagement/seoLocales.groovy"/>--> + <script location="component://product/webapp/catalog/WEB-INF/actions/imagemanagement/ImageGallery.groovy"/> </actions> <widgets> <decorator-screen name="ImageManagementDecorator" location="${parameters.mainDecoratorLocation}"> @@ -856,106 +847,6 @@ under the License. </section> </screen> - <screen name="AutomaticResize"> - <section> - <actions> - <set field="userTabButtonImage" value="AutomaticResize"/> - </actions> - <widgets> - <decorator-screen name="ImageManagementDecorator" location="${parameters.mainDecoratorLocation}"> - <decorator-section name="body"> - <section> - <condition> - <if-has-permission permission="IMAGE_MANAGEMENT_ADMIN"/> - </condition> - <widgets> - <screenlet title="${uiLabelMap.AutomaticResize}"> - <include-form name="AutomaticResize" location="component://product/widget/catalog/ImageManagementForms.xml"/> - </screenlet> - </widgets> - <fail-widgets> - <label text="You do not have permission to access this page. ("IMAGE_MANAGEMENT_ADMIN" needed)"/> - </fail-widgets> - </section> - </decorator-section> - </decorator-screen> - </widgets> - </section> - </screen> - - <screen name="ListAutomaticResize"> - <section> - <condition> - <not><if-empty field="parameters.productId"/></not> - </condition> - <actions> - <set field="userTabButtonImage" value="AutomaticResize"/> - <set field="productId" from-field="parameters.productId"/> - <entity-one entity-name="Product" value-field="product"/> - <set field="layoutSettings.javaScripts[]" value="/ecommerce/images/productAdditionalView.js" global="true"/> - <script location="component://product/webapp/catalog/WEB-INF/actions/imagemanagement/automaticResize.groovy"/> - </actions> - <widgets> - <decorator-screen name="ImageManagementDecorator" location="${parameters.mainDecoratorLocation}"> - <decorator-section name="body"> - <section> - <condition> - <if-has-permission permission="IMAGE_MANAGEMENT_ADMIN"/> - </condition> - <widgets> - <section> - <condition> - <not><if-empty field="product"/></not> - </condition> - <widgets> - <screenlet title="${uiLabelMap.AutomaticResize}"> - <platform-specific> - <html><html-template location="component://product/webapp/catalog/imagemanagement/AutomaticResize.ftl"/></html> - </platform-specific> - </screenlet> - </widgets> - <fail-widgets> - <label text="${uiLabelMap.ProductNoExistingProductsFound}"/> - </fail-widgets> - </section> - </widgets> - <fail-widgets> - <label text="You do not have permission to access this page. ("IMAGE_MANAGEMENT_ADMIN" needed)"/> - </fail-widgets> - </section> - </decorator-section> - </decorator-screen> - </widgets> - <fail-widgets> - <section> - <actions> - <set field="userTabButtonImage" value="AutomaticResize"/> - <set field="errorMessage" value="There is no a selected product, please insert or select the product to view image(s)."/> - </actions> - <widgets> - <decorator-screen name="ImageManagementDecorator" location="${parameters.mainDecoratorLocation}"> - <decorator-section name="body"> - <section> - <condition> - <if-has-permission permission="IMAGE_MANAGEMENT_ADMIN"/> - </condition> - <widgets> - <screenlet title="${uiLabelMap.AutomaticResize}"> - <include-form name="AutomaticResize" location="component://product/widget/catalog/ImageManagementForms.xml"/> - </screenlet> - </widgets> - <fail-widgets> - <label text="You do not have permission to access this page. ("IMAGE_MANAGEMENT_ADMIN" needed)"/> - </fail-widgets> - </section> - </decorator-section> - </decorator-screen> - </widgets> - </section> - </fail-widgets> - </section> - </screen> - <screen name="LookupImageFrame"> <section> <widgets> 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=1087599&r1=1087598&r2=1087599&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/catalog/productdetail.ftl (original) +++ ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/catalog/productdetail.ftl Fri Apr 1 06:49:06 2011 @@ -343,8 +343,7 @@ ${virtualVariantJavaScript?if_exists} <hr /> <div id="productImageBox"> - <#assign userLoginSecurityGroup = delegator.findByAnd("UserLoginSecurityGroup", Static["org.ofbiz.base.util.UtilMisc"].toMap("groupId", "IMAGEADMIN"))> - <#if userLoginSecurityGroup != null && userLoginSecurityGroup?has_content> + <#if productImageList != null && productImageList?has_content> <#-- Product image/name/price --> <div id="detailImageBox"> <#assign productLargeImageUrl = productContentWrapper.get("LARGE_IMAGE_URL")?if_exists /> @@ -361,20 +360,12 @@ ${virtualVariantJavaScript?if_exists} </#if> </div> <#-- Show Image Approved --> - <#assign productContentAndInfos = delegator.findByAnd("ProductContentAndInfo", {"productId", product.productId?if_exists, "productContentTypeId", "IMAGE", "statusId", "IM_APPROVED", "drIsPublic", "Y"}, Static["org.ofbiz.base.util.UtilMisc"].toList("sequenceNum"))> <div id="additionalImageBox"> - <#if productContentAndInfos?has_content> - <#list productContentAndInfos as productContentAndInfo> - <#assign contentAssocs = delegator.findByAnd("ContentAssoc",Static["org.ofbiz.base.util.UtilMisc"].toMap("contentId", productContentAndInfo.contentId?if_exists, "contentAssocTypeId", "IMAGE_THUMBNAIL"))/> - <#if contentAssocs?has_content> - <#list contentAssocs as contentAssoc> - <#assign ImageContent = delegator.findByPrimaryKey("Content", Static["org.ofbiz.base.util.UtilMisc"].toMap("contentId", contentAssoc.contentIdTo))?if_exists> - <#assign contentDataResourceView = delegator.findByPrimaryKey("ContentDataResourceView", Static["org.ofbiz.base.util.UtilMisc"].toMap("contentId", contentAssoc.contentIdTo, "drDataResourceId", ImageContent.dataResourceId))?if_exists> - <div class="additionalImage"> - <a href="javascript:void(0);" swapDetail="<@ofbizContentUrl>${productContentAndInfo.drObjectInfo}</@ofbizContentUrl>"><img src="<@ofbizContentUrl>${contentDataResourceView.drObjectInfo}</@ofbizContentUrl>" vspace="5" hspace="5" alt="" /></a> - </div> - </#list> - </#if> + <#if productImageList?has_content> + <#list productImageList as productImage> + <div class="additionalImage"> + <a href="javascript:void(0);" swapDetail="<@ofbizContentUrl>${productImage.productImage}</@ofbizContentUrl>"><img src="<@ofbizContentUrl>${productImage.productImageThumb}</@ofbizContentUrl>" vspace="5" hspace="5" alt="" /></a> + </div> </#list> </#if> </div> |
Free forum by Nabble | Edit this page |