Author: hansbak
Date: Fri Feb 4 03:21:17 2011 New Revision: 1067073 URL: http://svn.apache.org/viewvc?rev=1067073&view=rev Log: several enhancements on the product image management system including adding the proper permissions to the fulladmin security group to be able to approve images Modified: ofbiz/trunk/applications/product/data/ProductDemoData.xml ofbiz/trunk/applications/product/data/ProductSecurityData.xml ofbiz/trunk/applications/product/data/ProductTypeData.xml ofbiz/trunk/applications/product/data/helpdata/HELP_IMAGEMANAGEMENT.xml ofbiz/trunk/applications/product/entitydef/entitymodel.xml ofbiz/trunk/applications/product/script/org/ofbiz/product/imagemanagement/ImageManagementServices.xml ofbiz/trunk/applications/product/servicedef/services.xml ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/CropImage.java ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/FrameImage.java ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/ImageManagementServices.java ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/RotateImage.java ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/WatermarkImage.java ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/controller.xml ofbiz/trunk/applications/product/webapp/catalog/imagemanagement/ImageGallery.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/data/DemoProductAdditionalViewData.xml ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/catalog/productdetail.ftl Modified: ofbiz/trunk/applications/product/data/ProductDemoData.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/data/ProductDemoData.xml?rev=1067073&r1=1067072&r2=1067073&view=diff ============================================================================== --- ofbiz/trunk/applications/product/data/ProductDemoData.xml (original) +++ ofbiz/trunk/applications/product/data/ProductDemoData.xml Fri Feb 4 03:21:17 2011 @@ -29,18 +29,17 @@ under the License. <UserLogin userLoginId="imageAdmin" partyId="imageAdmin" currentPassword="{SHA}47b56994cbc2b6d10aa1be30f70165adb305a41a"/> <UserLoginSecurityGroup userLoginId="imageAdmin" groupId="FULLADMIN" fromDate="2010-01-01 12:00:00.0"/> <UserLoginSecurityGroup userLoginId="imageAdmin" groupId="IMAGEADMIN" fromDate="2010-01-01 12:00:00.0"/> - <UserLoginSecurityGroup userLoginId="imageAdmin" groupId="IMAGEUPLOAD" fromDate="2010-01-01 12:00:00.0"/> - <Party partyId="imageAdmin2" partyTypeId="PERSON" statusId="PARTY_ENABLED"/> - <Person partyId="imageAdmin2" firstName="Image Management" lastName="Administrator 2"/> - <UserLogin userLoginId="imageAdmin2" partyId="imageAdmin2" currentPassword="{SHA}47b56994cbc2b6d10aa1be30f70165adb305a41a"/> - <UserLoginSecurityGroup userLoginId="imageAdmin2" groupId="FULLADMIN" fromDate="2010-01-01 12:00:00.0"/> - <UserLoginSecurityGroup userLoginId="imageAdmin2" groupId="IMAGEAPPROVE" fromDate="2010-01-01 12:00:00.0"/> + <Party partyId="imageApprove" partyTypeId="PERSON" statusId="PARTY_ENABLED"/> + <Person partyId="imageApprove" firstName="Image Management" lastName="Approve"/> + <UserLogin userLoginId="imageApprove" partyId="imageApprove" currentPassword="{SHA}47b56994cbc2b6d10aa1be30f70165adb305a41a"/> + <UserLoginSecurityGroup userLoginId="imageApprove" groupId="FLEXADMIN" fromDate="2010-01-01 12:00:00.0"/> + <UserLoginSecurityGroup userLoginId="imageApprove" groupId="IMAGEAPPROVE" fromDate="2010-01-01 12:00:00.0"/> <Party partyId="imageUpload" partyTypeId="PERSON" statusId="PARTY_ENABLED"/> <Person partyId="imageUpload" firstName="Image Management" lastName="Upload"/> <UserLogin userLoginId="imageUpload" partyId="imageUpload" currentPassword="{SHA}47b56994cbc2b6d10aa1be30f70165adb305a41a"/> - <UserLoginSecurityGroup userLoginId="imageUpload" groupId="FULLADMIN" fromDate="2010-01-01 12:00:00.0"/> + <UserLoginSecurityGroup userLoginId="imageUpload" groupId="CATALOGADMIN" fromDate="2010-01-01 12:00:00.0"/> <UserLoginSecurityGroup userLoginId="imageUpload" groupId="IMAGEUPLOAD" fromDate="2010-01-01 12:00:00.0"/> - + </entity-engine-xml> Modified: ofbiz/trunk/applications/product/data/ProductSecurityData.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/data/ProductSecurityData.xml?rev=1067073&r1=1067072&r2=1067073&view=diff ============================================================================== --- ofbiz/trunk/applications/product/data/ProductSecurityData.xml (original) +++ ofbiz/trunk/applications/product/data/ProductSecurityData.xml Fri Feb 4 03:21:17 2011 @@ -108,4 +108,6 @@ under the License. <SecurityGroup description="Image Management Upload." groupId="IMAGEUPLOAD"/> <SecurityPermission description="Upload photos in the Image Management." permissionId="IMAGE_MANAGEMENT_UPLOAD"/> <SecurityGroupPermission groupId="IMAGEUPLOAD" permissionId="IMAGE_MANAGEMENT_UPLOAD"/> + + <PartyRole partyId="admin" roleTypeId="IMAGEAPPROVER"/> </entity-engine-xml> Modified: ofbiz/trunk/applications/product/data/ProductTypeData.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/data/ProductTypeData.xml?rev=1067073&r1=1067072&r2=1067073&view=diff ============================================================================== --- ofbiz/trunk/applications/product/data/ProductTypeData.xml (original) +++ ofbiz/trunk/applications/product/data/ProductTypeData.xml Fri Feb 4 03:21:17 2011 @@ -632,4 +632,9 @@ under the License. <ProductFeature productFeatureId="TEXT_BLUE" productFeatureTypeId="COLOR" productFeatureCategoryId="TEXT" description="Blue" defaultSequenceNum="6"/> <ProductFeature productFeatureId="TEXT_YELLOW" productFeatureTypeId="COLOR" productFeatureCategoryId="TEXT" description="Yellow" defaultSequenceNum="7"/> + <EnumerationType description="Image Reject Reason" enumTypeId="IMAGE_REJECT_REASON" hasTable="N" parentTypeId=""/> + <Enumeration description="Re-take Photo" enumCode="RETAKE_PHOTO" enumId="RETAKE_PHOTO" sequenceId="01" enumTypeId="IMAGE_REJECT_REASON"/> + <Enumeration description="Remove Logo" enumCode="REMOVE_LOGO" enumId="REMOVE_LOGO" sequenceId="02" enumTypeId="IMAGE_REJECT_REASON"/> + <Enumeration description="Other" enumCode="OTHER" enumId="OTHER" sequenceId="03" enumTypeId="IMAGE_REJECT_REASON"/> + </entity-engine-xml> Modified: ofbiz/trunk/applications/product/data/helpdata/HELP_IMAGEMANAGEMENT.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/data/helpdata/HELP_IMAGEMANAGEMENT.xml?rev=1067073&r1=1067072&r2=1067073&view=diff ============================================================================== --- ofbiz/trunk/applications/product/data/helpdata/HELP_IMAGEMANAGEMENT.xml (original) +++ ofbiz/trunk/applications/product/data/helpdata/HELP_IMAGEMANAGEMENT.xml Fri Feb 4 03:21:17 2011 @@ -27,7 +27,6 @@ </listitem> </orderedlist> </para> - <section> <title>How To Add Security Group For Image Management User</title> <para>There are three security groups related in the Image Management including 'IMAGEADMIN', 'IMAGEAPPROVE' and ' IMAGEUPLOAD'.</para> @@ -167,31 +166,31 @@ </orderedlist> </section> </section> - </section> - <section> - <title>- Crop</title> <section> - <para>You can crop any images in this function.</para> - <orderedlist> - <listitem> - <para>Choose 'Crop' then choose your image.</para> - <para>Move your cursor on the image, then drag your mouse to crop image.</para> - <para>You can see the preview image in the right hand side.</para> - <para>Finally, you click 'Crop' button.</para> - </listitem> - </orderedlist> + <title>- Crop</title> + <section> + <para>You can crop any images in this function.</para> + <orderedlist> + <listitem> + <para>Choose 'Crop' then choose your image.</para> + <para>Move your cursor on the image, then drag your mouse to crop image.</para> + <para>You can see the preview image in the right hand side.</para> + <para>Finally, you click 'Crop' button.</para> + </listitem> + </orderedlist> + </section> </section> - </section> - <section> - <title>- Rotate</title> <section> - <para>You can rotate images in this function.</para> - <orderedlist> - <listitem> - <para>Choose 'Rotate' then click clockwise or counterclockwise button for ratating image.</para> - <para>Click 'Submit' button</para> - </listitem> - </orderedlist> + <title>- Rotate</title> + <section> + <para>You can rotate images in this function.</para> + <orderedlist> + <listitem> + <para>Choose 'Rotate' then click clockwise or counterclockwise button for ratating image.</para> + <para>Click 'Submit' button</para> + </listitem> + </orderedlist> + </section> </section> </section> </section> Modified: ofbiz/trunk/applications/product/entitydef/entitymodel.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/entitydef/entitymodel.xml?rev=1067073&r1=1067072&r2=1067073&view=diff ============================================================================== --- ofbiz/trunk/applications/product/entitydef/entitymodel.xml (original) +++ ofbiz/trunk/applications/product/entitydef/entitymodel.xml Fri Feb 4 03:21:17 2011 @@ -4818,7 +4818,7 @@ under the License. <!-- Image Management --> <extend-entity entity-name="ProductContent"> <field name="defaultSequenceNum" type="numeric"/> - <field name="enable" type="indicator"/> + <field name="exclude" type="indicator"/> <field name="thumbnail" type="indicator"/> </extend-entity> Modified: ofbiz/trunk/applications/product/script/org/ofbiz/product/imagemanagement/ImageManagementServices.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/script/org/ofbiz/product/imagemanagement/ImageManagementServices.xml?rev=1067073&r1=1067072&r2=1067073&view=diff ============================================================================== --- ofbiz/trunk/applications/product/script/org/ofbiz/product/imagemanagement/ImageManagementServices.xml (original) +++ ofbiz/trunk/applications/product/script/org/ofbiz/product/imagemanagement/ImageManagementServices.xml Fri Feb 4 03:21:17 2011 @@ -185,7 +185,7 @@ under the License. <set field="removeImageFile.productId" from-field="parameters.productId"/> <set field="removeImageFile.contentId" from-field="parameters.contentId"/> - <set field="removeImageFile.dataResourceName" from-field="dataResource.dataResourceName"/> + <set field="removeImageFile.objectInfo" from-field="dataResource.objectInfo"/> <set-service-fields service-name="removeImageFileForImageManagement" map="removeImageFile" to-map="removeImageFileMap"/> <call-service service-name="removeImageFileForImageManagement" in-map-name="removeImageFileMap"/> @@ -195,7 +195,7 @@ under the License. </simple-method> <simple-method method-name="setImageDetail" short-description="Set Image Detail"> - <!-- set sort order (defaultSequenceNum) and exclude (enable) --> + <!-- set sort order (defaultSequenceNum) and exclude --> <entity-one value-field="productContent" entity-name="ProductContent"/> <set field="productContent.defaultSequenceNum" from-field="parameters.defaultSequenceNum" type="Long"/> <store-value value-field="productContent"/> @@ -204,13 +204,7 @@ under the License. <set field="productContent.defaultSequenceNum" from-field="parameters.defaultSequenceNum" type="Long"/> <store-value value-field="productContent"/> </if-not-empty> - <if-compare operator="equals" value="false" field="parameters.enable"> <!-- if ticked checked box = false --> - <set field="parameters.enable" value="true"/> - <else> - <set field="parameters.enable" value="false"/> - </else> - </if-compare> - <set field="productContent.enable" from-field="parameters.enable" type="Boolean"/> + <set field="productContent.exclude" from-field="parameters.exclude" type="String"/> <store-value value-field="productContent"/> <!-- set caption --> @@ -271,7 +265,7 @@ under the License. </entity-and> <first-from-list entry="productContent" list="productContents"/> <set field="productContent.purchaseFromDate" from-field="nowTimestamp"/> - <set field="productContent.enable" value="N"/> + <set field="productContent.exclude" value="N"/> <set field="productContent.thumbnail" value="N"/> <store-value value-field="productContent"/> <else> @@ -293,7 +287,7 @@ under the License. </entity-and> <first-from-list entry="productContent" list="productContents"/> <set field="productContent.purchaseFromDate" from-field="nowTimestamp"/> - <set field="productContent.enable" value="N"/> + <set field="productContent.exclude" value="N"/> <set field="productContent.thumbnail" value="N"/> <store-value value-field="productContent"/> Modified: ofbiz/trunk/applications/product/servicedef/services.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/servicedef/services.xml?rev=1067073&r1=1067072&r2=1067073&view=diff ============================================================================== --- ofbiz/trunk/applications/product/servicedef/services.xml (original) +++ ofbiz/trunk/applications/product/servicedef/services.xml Fri Feb 4 03:21:17 2011 @@ -1407,7 +1407,7 @@ under the License. location="org.ofbiz.product.imagemanagement.ImageManagementServices" invoke="removeImageFileForImageManagement" auth="true"> <description>Delete Image File</description> <attribute mode="IN" name="contentId" optional="false" type="String"/> - <attribute mode="IN" name="dataResourceName" optional="false" type="String"/> + <attribute mode="IN" name="objectInfo" optional="false" type="String"/> <attribute mode="IN" name="productId" optional="false" type="String"/> </service> @@ -1460,7 +1460,7 @@ under the License. <auto-attributes include="pk" mode="IN" optional="false"/> <auto-attributes include="nonpk" mode="IN" optional="true"/> <attribute name="defaultSequenceNum" mode="IN" type="Integer" optional="true"/> - <attribute name="enable" mode="IN" type="Boolean" optional="true" default-value="true"/> + <attribute name="exclude" mode="IN" type="String" optional="true" default-value="N"/> <attribute name="description" mode="IN" type="String" optional="true"/> </service> Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/CropImage.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/CropImage.java?rev=1067073&r1=1067072&r2=1067073&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/CropImage.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/CropImage.java Fri Feb 4 03:21:17 2011 @@ -107,8 +107,8 @@ public class CropImage { String imageUrlResource = "/images/products/management/" + productId + "/" + filenameToUse; String imageUrlThumb = "/images/products/management/" + productId + "/" + filenameTouseThumb; - ImageManagementServices.createContentAndDataResource(dctx, userLogin, filenameToUse, imageUrlResource, contentId); - ImageManagementServices.createContentAndDataResource(dctx, userLogin, filenameTouseThumb, imageUrlThumb, contentIdThumb); + ImageManagementServices.createContentAndDataResource(dctx, userLogin, filenameToUse, imageUrlResource, contentId, "image/jpeg"); + ImageManagementServices.createContentAndDataResource(dctx, userLogin, filenameTouseThumb, imageUrlThumb, contentIdThumb, "image/jpeg"); Map<String, Object> createContentAssocMap = FastMap.newInstance(); createContentAssocMap.put("contentAssocTypeId", "IMAGE_THUMBNAIL"); Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/FrameImage.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/FrameImage.java?rev=1067073&r1=1067072&r2=1067073&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/FrameImage.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/FrameImage.java Fri Feb 4 03:21:17 2011 @@ -163,8 +163,8 @@ public class FrameImage { String imageUrlResource = "/images/products/management/" + productId + "/" + filenameToUse; String imageUrlThumb = "/images/products/management/" + productId + "/" + filenameTouseThumb; - ImageManagementServices.createContentAndDataResource(dctx, userLogin, filenameToUse, imageUrlResource, contentId); - ImageManagementServices.createContentAndDataResource(dctx, userLogin, filenameTouseThumb, imageUrlThumb, contentIdThumb); + ImageManagementServices.createContentAndDataResource(dctx, userLogin, filenameToUse, imageUrlResource, contentId, "image/jpeg"); + ImageManagementServices.createContentAndDataResource(dctx, userLogin, filenameTouseThumb, imageUrlThumb, contentIdThumb, "image/jpeg"); Map<String, Object> createContentAssocMap = FastMap.newInstance(); createContentAssocMap.put("contentAssocTypeId", "IMAGE_THUMBNAIL"); 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=1067073&r1=1067072&r2=1067073&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 Feb 4 03:21:17 2011 @@ -81,6 +81,8 @@ public class ImageManagementServices { public static final String module = ImageManagementServices.class.getName(); public static final String resource = "ProductErrorUiLabels"; private static List<Map<String,Object>> josonMap = null; + private static int imageCount = 0; + private static String imagePath; public static Map<String, Object> addMultipleuploadForProduct(DispatchContext dctx, Map<String, ? extends Object> context) throws IOException, JDOMException { @@ -154,7 +156,7 @@ public class ImageManagementServices { result.put("contentId", (String) context.get("contentId")); result.put("dataResourceId", (String) context.get("dataResourceId")); - // File to use for image original + // File to use for original image FlexibleStringExpander filenameExpander = FlexibleStringExpander.getInstance(imageFilenameFormat); String fileLocation = filenameExpander.expandString(UtilMisc.toMap("location", "products", "type", sizeType, "id", contentId)); String filenameToUse = fileLocation; @@ -193,27 +195,38 @@ public class ImageManagementServices { return ServiceUtil.returnError(errMsg); } } - - // Create image file original to folder product id. - File file = new File(imageServerPath + "/products/management/" + productId + "/" + filenameToUse); - try { - RandomAccessFile out = new RandomAccessFile(file, "rw"); - out.write(imageData.array()); - out.close(); - } catch (FileNotFoundException e) { - Debug.logError(e, module); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, - "ProductImageViewUnableWriteFile", UtilMisc.toMap("fileName", file.getAbsolutePath()), locale)); - } catch (IOException e) { - Debug.logError(e, module); - return ServiceUtil.returnError(UtilProperties.getMessage(resource, - "ProductImageViewUnableWriteBinaryData", UtilMisc.toMap("fileName", file.getAbsolutePath()), locale)); + File file = new File(imageServerPath + "/products/management/" + productId + "/" + uploadFileName); + String imageName = null; + imagePath = imageServerPath + "/products/management/" + productId + "/" + uploadFileName; + file = checkExistsImage(file); + if (UtilValidate.isNotEmpty(file)) { + imageName = file.getPath(); + imageName = imageName.substring(imageName.lastIndexOf("/") + 1); } + if (UtilValidate.isEmpty(imageResize)) { + // Create image file original to folder product id. + try { + RandomAccessFile out = new RandomAccessFile(file, "rw"); + out.write(imageData.array()); + out.close(); + } catch (FileNotFoundException e) { + Debug.logError(e, module); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "ProductImageViewUnableWriteFile", UtilMisc.toMap("fileName", file.getAbsolutePath()), locale)); + } catch (IOException e) { + Debug.logError(e, module); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, + "ProductImageViewUnableWriteBinaryData", UtilMisc.toMap("fileName", file.getAbsolutePath()), locale)); + } + } // Scale Image in different sizes if (UtilValidate.isNotEmpty(imageResize)) { - File fileOriginal = new File(imageServerPath + "/products/management/" + filenameToUse); + File fileOriginal = new File(imageServerPath + "/products/management/" + imageName); + fileOriginal = checkExistsImage(fileOriginal); + uploadFileName = fileOriginal.getName(); + try { RandomAccessFile outFile = new RandomAccessFile(fileOriginal, "rw"); outFile.write(imageData.array()); @@ -221,16 +234,16 @@ public class ImageManagementServices { } catch (FileNotFoundException e) { Debug.logError(e, module); return ServiceUtil.returnError(UtilProperties.getMessage(resource, - "ProductImageViewUnableWriteFile", UtilMisc.toMap("fileName", file.getAbsolutePath()), locale)); + "ProductImageViewUnableWriteFile", UtilMisc.toMap("fileName", fileOriginal.getAbsolutePath()), locale)); } catch (IOException e) { Debug.logError(e, module); return ServiceUtil.returnError(UtilProperties.getMessage(resource, - "ProductImageViewUnableWriteBinaryData", UtilMisc.toMap("fileName", file.getAbsolutePath()), locale)); + "ProductImageViewUnableWriteBinaryData", UtilMisc.toMap("fileName", fileOriginal.getAbsolutePath()), locale)); } Map<String, Object> resultResize = FastMap.newInstance(); try { - resultResize.putAll(ImageManagementServices.scaleImageMangementInAllSize(context, filenameToUse, sizeType, productId)); + resultResize.putAll(ImageManagementServices.scaleImageMangementInAllSize(context, imageName, sizeType, productId)); } catch (IOException e) { String errMsg = "Scale additional image in all different sizes is impossible : " + e.toString(); Debug.logError(e, errMsg, module); @@ -242,15 +255,15 @@ public class ImageManagementServices { } } - Map<String, Object> contentThumbnail = createContentThumbnail(dctx, context, userLogin, imageData, productId); + Map<String, Object> contentThumbnail = createContentThumbnail(dctx, context, userLogin, imageData, productId, imageName); String filenameToUseThumb = (String) contentThumbnail.get("filenameToUseThumb"); String contentIdThumb = (String) contentThumbnail.get("contentIdThumb"); - String imageUrl = "/images/products/management/" + productId + "/" + filenameToUse; + String imageUrl = "/images/products/management/" + productId + "/" + imageName; String imageUrlThumb = "/images/products/management/" + productId + "/" + filenameToUseThumb; - createContentAndDataResource(dctx, userLogin, filenameToUse, imageUrl, contentId); - createContentAndDataResource(dctx, userLogin, filenameToUseThumb, imageUrlThumb, contentIdThumb); + createContentAndDataResource(dctx, userLogin, imageName, imageUrl, contentId, fileContentType); + createContentAndDataResource(dctx, userLogin, filenameToUseThumb, imageUrlThumb, contentIdThumb, fileContentType); Map<String, Object> createContentAssocMap = FastMap.newInstance(); createContentAssocMap.put("contentAssocTypeId", "IMAGE_THUMBNAIL"); @@ -293,32 +306,13 @@ public class ImageManagementServices { public static Map<String, Object> removeImageFileForImageManagement(DispatchContext dctx, Map<String, ? extends Object> context){ String contentId = (String) context.get("contentId"); - String dataResourceName = (String) context.get("dataResourceName"); + String objectInfo = (String) context.get("objectInfo"); String productId = (String) context.get("productId"); - try { if (UtilValidate.isNotEmpty(contentId)) { - String imageFilenameFormat = UtilProperties.getPropertyValue("catalog", "image.filename.format"); String imageServerPath = FlexibleStringExpander.expandString(UtilProperties.getPropertyValue("catalog", "image.server.path"), context); - FlexibleStringExpander filenameExpander = FlexibleStringExpander.getInstance(imageFilenameFormat); - String fileLocation = filenameExpander.expandString(UtilMisc.toMap("location", "products", "type", "management/" + productId , "id", contentId)); - String filenameToUse = fileLocation; - - if (fileLocation.lastIndexOf("/") != -1) { - filenameToUse = fileLocation.substring(fileLocation.lastIndexOf("/") + 1); - } - - String fileName = dataResourceName; - if (fileName.lastIndexOf(".") > 0) { - String fileType = fileName.substring(fileName.lastIndexOf(".")); - if (fileType.equals(".jpeg") || fileType.equals(".jpg")) { - filenameToUse += ".jpg"; - } else { - filenameToUse += fileName.substring(fileName.lastIndexOf(".")); - } - } - - File file = new File(imageServerPath + "/products/management/" + productId + "/" + filenameToUse); + imageServerPath.substring(0, imageServerPath.lastIndexOf("/")); + File file = new File(imageServerPath.substring(0, imageServerPath.lastIndexOf("/")) + objectInfo); file.delete(); } } catch (Exception e) { @@ -431,7 +425,7 @@ public class ImageManagementServices { try { ImageIO.write((RenderedImage) bufNewImg, imgExtension, new File(imageServerPath + "/" + newFilePathPrefix + filenameToUse)); File deleteFile = new File(imageServerPath + "/products/management/" + filenameToUse); - deleteFile.delete(); + boolean check = deleteFile.delete(); } catch (IllegalArgumentException e) { String errMsg = UtilProperties.getMessage(resource, "ScaleImage.one_parameter_is_null", locale) + e.toString(); Debug.logError(errMsg, module); @@ -464,7 +458,7 @@ public class ImageManagementServices { } } - public static Map<String, Object> createContentAndDataResource(DispatchContext dctx, GenericValue userLogin, String filenameToUse, String imageUrl, String contentId){ + public static Map<String, Object> createContentAndDataResource(DispatchContext dctx, GenericValue userLogin, String filenameToUse, String imageUrl, String contentId, String fileContentType){ Map<String, Object> result = FastMap.newInstance(); LocalDispatcher dispatcher = dctx.getDispatcher(); Delegator delegator = dctx.getDelegator(); @@ -474,8 +468,8 @@ public class ImageManagementServices { dataResourceCtx.put("objectInfo", imageUrl); dataResourceCtx.put("dataResourceName", filenameToUse); dataResourceCtx.put("userLogin", userLogin); - dataResourceCtx.put("dataResourceTypeId", "SHORT_TEXT"); - dataResourceCtx.put("mimeTypeId", "text/html"); + dataResourceCtx.put("dataResourceTypeId", "IMAGE_OBJECT"); + dataResourceCtx.put("mimeTypeId", fileContentType); dataResourceCtx.put("isPublic", "Y"); Map<String, Object> dataResourceResult = FastMap.newInstance(); @@ -530,7 +524,7 @@ public class ImageManagementServices { return result; } - public static Map<String, Object> createContentThumbnail(DispatchContext dctx, Map<String, ? extends Object> context, GenericValue userLogin, ByteBuffer imageData, String productId){ + public static Map<String, Object> createContentThumbnail(DispatchContext dctx, Map<String, ? extends Object> context, GenericValue userLogin, ByteBuffer imageData, String productId, String imageName){ Map<String, Object> result = FastMap.newInstance(); LocalDispatcher dispatcher = dctx.getDispatcher(); Delegator delegator = dctx.getDelegator(); @@ -553,7 +547,7 @@ 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; @@ -579,6 +573,28 @@ public class ImageManagementServices { GenericValue extensionThumb = EntityUtil.getFirst(fileExtensionThumb); if (extensionThumb != null) { filenameToUseThumb += "." + extensionThumb.getString("fileExtensionId"); + }*/ + //String uploadFileName = (String) context.get("_uploadedFile_fileName"); + String filenameToUseThumb = imageName.substring(0 , imageName.indexOf(".")) + "_Thumbnail"; + String fileContentType = (String) context.get("_uploadedFile_contentType"); + if (fileContentType.equals("image/pjpeg")) { + fileContentType = "image/jpeg"; + } else if (fileContentType.equals("image/x-png")) { + fileContentType = "image/png"; + } + + List<GenericValue> fileExtensionThumb = FastList.newInstance(); + try { + fileExtensionThumb = delegator.findByAnd("FileExtension", UtilMisc.toMap("mimeTypeId", fileContentType)); + } catch (GenericEntityException e) { + Debug.logError(e, module); + return ServiceUtil.returnError(e.getMessage()); + } + + GenericValue extensionThumb = EntityUtil.getFirst(fileExtensionThumb); + if (extensionThumb != null) { + + filenameToUseThumb += "." + extensionThumb.getString("fileExtensionId"); } result.put("filenameToUseThumb", filenameToUseThumb); // Create image file thumbnail to folder product id. @@ -854,4 +870,18 @@ public class ImageManagementServices { } return ServiceUtil.returnSuccess(); } + + public static File checkExistsImage(File file) { + if (!file.exists()) { + imageCount = 0; + imagePath = null; + return file; + } + imageCount++; + String filePath = imagePath.substring(0, imagePath.indexOf(".")); + String type = imagePath.substring(imagePath.indexOf(".") + 1); + file = new File(filePath + "(" + imageCount + ")." + type); + return checkExistsImage(file); + } + } Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/RotateImage.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/RotateImage.java?rev=1067073&r1=1067072&r2=1067073&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/RotateImage.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/RotateImage.java Fri Feb 4 03:21:17 2011 @@ -115,8 +115,8 @@ public class RotateImage { String imageUrlResource = "/images/products/management/" + productId + "/" + filenameToUse; String imageUrlThumb = "/images/products/management/" + productId + "/" + filenameTouseThumb; - ImageManagementServices.createContentAndDataResource(dctx, userLogin, filenameToUse, imageUrlResource, contentId); - ImageManagementServices.createContentAndDataResource(dctx, userLogin, filenameTouseThumb, imageUrlThumb, contentIdThumb); + ImageManagementServices.createContentAndDataResource(dctx, userLogin, filenameToUse, imageUrlResource, contentId, "image/jpeg"); + ImageManagementServices.createContentAndDataResource(dctx, userLogin, filenameTouseThumb, imageUrlThumb, contentIdThumb, "image/jpeg"); Map<String, Object> createContentAssocMap = FastMap.newInstance(); createContentAssocMap.put("contentAssocTypeId", "IMAGE_THUMBNAIL"); Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/WatermarkImage.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/WatermarkImage.java?rev=1067073&r1=1067072&r2=1067073&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/WatermarkImage.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/product/imagemanagement/WatermarkImage.java Fri Feb 4 03:21:17 2011 @@ -191,8 +191,8 @@ public class WatermarkImage{ String imageUrlThumb = "/images/products/management/" + productId + "/" + filenameTouseThumb; - createContentAndDataResourceWaterMark(request, userLogin, filenameToUse, imageUrlResource, contentId); - createContentAndDataResourceWaterMark(request, userLogin, filenameTouseThumb, imageUrlThumb, contentIdThumb); + createContentAndDataResourceWaterMark(request, userLogin, filenameToUse, imageUrlResource, contentId, "image/jpeg"); + createContentAndDataResourceWaterMark(request, userLogin, filenameTouseThumb, imageUrlThumb, contentIdThumb, "image/jpeg"); Map<String, Object> createContentAssocMap = FastMap.newInstance(); createContentAssocMap.put("contentAssocTypeId", "IMAGE_THUMBNAIL"); @@ -241,7 +241,7 @@ public class WatermarkImage{ return "success"; } - public static Map<String, Object> createContentAndDataResourceWaterMark(HttpServletRequest request, GenericValue userLogin, String filenameToUse, String imageUrl, String contentId){ + public static Map<String, Object> createContentAndDataResourceWaterMark(HttpServletRequest request, GenericValue userLogin, String filenameToUse, String imageUrl, String contentId, String mimeTypeId){ Map<String, Object> result = FastMap.newInstance(); LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher"); Delegator delegator = (Delegator) request.getAttribute("delegator"); @@ -251,8 +251,8 @@ public class WatermarkImage{ dataResourceCtx.put("objectInfo", imageUrl); dataResourceCtx.put("dataResourceName", filenameToUse); dataResourceCtx.put("userLogin", userLogin); - dataResourceCtx.put("dataResourceTypeId", "SHORT_TEXT"); - dataResourceCtx.put("mimeTypeId", "text/html"); + dataResourceCtx.put("dataResourceTypeId", "IMAGE_OBJECT"); + dataResourceCtx.put("mimeTypeId", mimeTypeId); dataResourceCtx.put("isPublic", "Y"); Map<String, Object> dataResourceResult = FastMap.newInstance(); 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=1067073&r1=1067072&r2=1067073&view=diff ============================================================================== --- ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/controller.xml (original) +++ ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/controller.xml Fri Feb 4 03:21:17 2011 @@ -2785,6 +2785,12 @@ under the License. <response name="success" type="view" value="ImageUpload"/> <response name="error" type="view" value="ImageUpload"/> </request-map> + <request-map uri="removeImage"> + <security https="true" auth="true"/> + <event type="service" path="" invoke="removeProductContentAndImageFile"/> + <response name="success" type="view" value="ListImageRemove"/> + <response name="error" type="view" value="ListImageRemove"/> + </request-map> <request-map uri="createWatermarkImage"> <security https="true" auth="true"/> <event type="java" path="org.ofbiz.product.imagemanagement.WatermarkImage" invoke="createWatermarkImage"/> @@ -2817,11 +2823,6 @@ under the License. <response name="success" type="view" value="viewImage"/> <response name="error" type="view" value="viewImage"/> </request-map> - <request-map uri="viewImages"> - <security https="true" auth="true"/> - <response name="success" type="view" value="viewImages"/> - <response name="error" type="view" value="viewImages"/> - </request-map> <request-map uri="viewPreviewImage"> <security https="true" auth="true"/> <response name="success" type="view" value="viewPreviewImage"/> @@ -2970,6 +2971,14 @@ under the License. <response name="success" type="view" value="ListImageManage"/> <response name="error" type="view" value="ImageWatermarking"/> </request-map> + <request-map uri="ImageRemove"> + <security https="true" auth="true"/> + <response name="success" type="view" value="ImageRemove"/> + </request-map> + <request-map uri="ListImageRemove"> + <security https="true" auth="true"/> + <response name="success" type="view" value="ListImageRemove"/> + </request-map> <!-- ================ Lookup Requests ================= --> <request-map uri="LookupContent"><security auth="true" https="true"/><response name="success" type="view" value="LookupContent"/></request-map> @@ -3221,7 +3230,6 @@ under the License. <view-map name="ImageShare" page="component://product/widget/catalog/ImageManagementScreens.xml#ImageShare" type="screen"/> <view-map name="ImageReplace" page="component://product/widget/catalog/ImageManagementScreens.xml#ImageReplace" type="screen"/> <view-map name="viewImage" page="component://product/widget/catalog/ImageManagementScreens.xml#ViewImage" type="screen"/> - <view-map name="viewImages" page="component://product/widget/catalog/ImageManagementScreens.xml#ViewImages" type="screen"/> <view-map name="viewPreviewImage" page="component://product/widget/catalog/ImageManagementScreens.xml#ViewPreviewImage" type="screen"/> <view-map name="LookupImage" page="component://product/widget/catalog/ImageManagementScreens.xml#LookupImage" type="screen"/> <view-map name="LookupProduct" type="screen" page="component://product/widget/catalog/LookupScreens.xml#LookupProduct"/> @@ -3236,5 +3244,7 @@ under the License. <view-map name="AutomaticResize" type="screen" page="component://product/widget/catalog/ImageManagementScreens.xml#AutomaticResize"/> <view-map name="ListAutomaticResize" type="screen" page="component://product/widget/catalog/ImageManagementScreens.xml#ListAutomaticResize"/> <view-map name="LookupImageFrame" type="screen" page="component://product/widget/catalog/ImageManagementScreens.xml#LookupImageFrame"/> + <view-map name="ImageRemove" type="screen" page="component://product/widget/catalog/ImageManagementScreens.xml#ImageRemove"/> + <view-map name="ListImageRemove" type="screen" page="component://product/widget/catalog/ImageManagementScreens.xml#ListImageRemove"/> <!-- end of view mappings --> </site-conf> 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=1067073&r1=1067072&r2=1067073&view=diff ============================================================================== --- ofbiz/trunk/applications/product/webapp/catalog/imagemanagement/ImageGallery.ftl (original) +++ ofbiz/trunk/applications/product/webapp/catalog/imagemanagement/ImageGallery.ftl Fri Feb 4 03:21:17 2011 @@ -23,8 +23,8 @@ under the License. <#if product?has_content> <h1><b>${product.productId}</b></h1> </#if> - <#assign productName = productTextData > - <#assign seoUrl = productName.replaceAll(" ", "-") > + <#-- <#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"))/> @@ -38,10 +38,12 @@ under the License. <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="/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>${(contentDataResourceView.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}&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> @@ -55,10 +57,12 @@ under the License. <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="/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>${(contentDataResourceView.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}&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> Modified: ofbiz/trunk/applications/product/widget/catalog/CatalogMenus.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/widget/catalog/CatalogMenus.xml?rev=1067073&r1=1067072&r2=1067073&view=diff ============================================================================== --- ofbiz/trunk/applications/product/widget/catalog/CatalogMenus.xml (original) +++ ofbiz/trunk/applications/product/widget/catalog/CatalogMenus.xml Fri Feb 4 03:21:17 2011 @@ -476,8 +476,16 @@ under the License. </menu> <menu name="ImageManagementTabBar" extends="CommonTabBarMenu" extends-resource="component://common/widget/CommonMenus.xml" selected-menuitem-context-field-name="userTabButtonImage"> + <menu-item name="main" title="${uiLabelMap.main}"> + <condition> + <if-has-permission permission="IMAGE_MANAGEMENT_ADMIN"/> + </condition> + <link target="Imagemanagement"/> + </menu-item> <menu-item name="ImageGallery" title="${uiLabelMap.Gallery}"> - <link target="ImageGallery"/> + <link target="ListImageGallery"> + <parameter param-name="productId"/> + </link> </menu-item> <menu-item name="ImageUpload" title="${uiLabelMap.ImageUpload}"> <condition> @@ -488,14 +496,13 @@ under the License. </condition> <link target="ImageUpload"/> </menu-item> - <menu-item name="ImageRecentlyApproved" title="${uiLabelMap.ImageRecentlyApproved}"> + <menu-item name="ImageManage" title="${uiLabelMap.Manage}"> <condition> - <or> - <if-has-permission permission="IMAGE_MANAGEMENT_APPROVE"/> - <if-has-permission permission="IMAGE_MANAGEMENT_ADMIN"/> - </or> + <if-has-permission permission="IMAGE_MANAGEMENT_ADMIN"/> </condition> - <link target="ImageRecentlyApproved"/> + <link target="ListImageManage"> + <parameter param-name="productId"/> + </link> </menu-item> <menu-item name="ImageApprove" title="${uiLabelMap.ImageApprove}"> <condition> @@ -515,17 +522,30 @@ under the License. </condition> <link target="ImageRejected"/> </menu-item> - <menu-item name="ImageManage" title="${uiLabelMap.Manage}"> + <menu-item name="ImageRecentlyApproved" title="${uiLabelMap.ImageRecentlyApproved}"> <condition> - <if-has-permission permission="IMAGE_MANAGEMENT_ADMIN"/> + <or> + <if-has-permission permission="IMAGE_MANAGEMENT_APPROVE"/> + <if-has-permission permission="IMAGE_MANAGEMENT_ADMIN"/> + </or> </condition> - <link target="ImageManage"/> + <link target="ImageRecentlyApproved"/> </menu-item> <menu-item name="ImageReplace" title="${uiLabelMap.Replace}"> <condition> <if-has-permission permission="IMAGE_MANAGEMENT_ADMIN"/> </condition> - <link target="ImageReplace"/> + <link target="ListImageReplace"> + <parameter param-name="productId"/> + </link> + </menu-item> + <menu-item name="ImageRemove" title="${uiLabelMap.Remove}"> + <condition> + <if-has-permission permission="IMAGE_MANAGEMENT_ADMIN"/> + </condition> + <link target="ListImageRemove"> + <parameter param-name="productId"/> + </link> </menu-item> <!--<menu-item name="AutomaticResize" title="${uiLabelMap.AutomaticResize}"> <condition> Modified: ofbiz/trunk/applications/product/widget/catalog/ImageManagementForms.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/widget/catalog/ImageManagementForms.xml?rev=1067073&r1=1067072&r2=1067073&view=diff ============================================================================== --- ofbiz/trunk/applications/product/widget/catalog/ImageManagementForms.xml (original) +++ ofbiz/trunk/applications/product/widget/catalog/ImageManagementForms.xml Fri Feb 4 03:21:17 2011 @@ -59,9 +59,7 @@ under the License. <display-entity entity-name="StatusItem" key-field-name="statusId" description="${description}"/> </field> <field name="viewButton" title="${uiLabelMap.CommonView}" widget-style="buttontext"> - <hyperlink target="viewImages" target-window="new" description="${uiLabelMap.CommonView}" also-hidden="false"> - <parameter param-name="drObjectInfo" from-field="origContentDataResourceViews[0].drObjectInfo"/> - </hyperlink> + <hyperlink target="${origContentDataResourceViews[0].drObjectInfo}" target-window="new" description="${uiLabelMap.CommonView}" also-hidden="false" target-type="content"/> </field> </form> @@ -121,9 +119,7 @@ under the License. <field name="dataResourceId" position="2"><display/></field> <field name="fromDate" position="2"><display/></field> <field name="viewButton" position="2" title="${uiLabelMap.CommonView}" widget-style="buttontext"> - <hyperlink target="viewImages" target-window="new" description="${uiLabelMap.CommonView}" also-hidden="false"> - <parameter param-name="drObjectInfo" from-field="origContentDataResourceViews[0].drObjectInfo"/> - </hyperlink> + <hyperlink target="${origContentDataResourceViews[0].drObjectInfo}" target-window="new" description="${uiLabelMap.CommonView}" also-hidden="false" target-type="content"/> </field> <field name="submitButton" title="${uiLabelMap.CommonSubmit}" widget-style="smallSubmit"><submit button-type="button"/></field> </form> @@ -163,9 +159,7 @@ under the License. <field name="dataResourceId" position="2"><display/></field> <field name="fromDate" position="2"><display/></field> <field name="viewButton" position="2" title="${uiLabelMap.CommonView}" widget-style="buttontext"> - <hyperlink target="viewImages" target-window="new" description="${uiLabelMap.CommonView}" also-hidden="false"> - <parameter param-name="drObjectInfo" from-field="origContentDataResourceViews[0].drObjectInfo"/> - </hyperlink> + <hyperlink target="${origContentDataResourceViews[0].drObjectInfo}" target-window="new" description="${uiLabelMap.CommonView}" also-hidden="false" target-type="content"/> </field> </form> @@ -209,15 +203,13 @@ under the License. </field> <field name="description" position="2" title="Rejected Reason"> <drop-down allow-empty="true"> - <option key="RETAKE_PHOTO" description="Re-take Photo"/> - <option key="REMOVE_LOGO" description="Remove Logo"/> - <option key="OTHER" description="Other"/> + <entity-options entity-name="Enumeration" key-field-name="enumId" description="${description}"> + <entity-constraint name="enumTypeId" operator="equals" value="IMAGE_REJECT_REASON"/> + </entity-options> </drop-down> </field> <field name="viewButton" position="2" title="${uiLabelMap.CommonView}" widget-style="buttontext"> - <hyperlink target="viewImages" target-window="new" description="${uiLabelMap.CommonView}" also-hidden="false"> - <parameter param-name="drObjectInfo" from-field="origContentDataResourceViews[0].drObjectInfo"/> - </hyperlink> + <hyperlink target="${origContentDataResourceViews[0].drObjectInfo}" target-window="new" description="${uiLabelMap.CommonView}" also-hidden="false" target-type="content"/> </field> <field name="submitButton" title="${uiLabelMap.CommonSubmit}" widget-style="smallSubmit"><submit button-type="button"/></field> </form> @@ -267,10 +259,8 @@ under the License. <field name="rejectedBy" position="2" title="Rejected By"><display/></field> <field name="description" position="2" title="Rejected Reason"><display/></field> <field name="viewButton" position="2" title="${uiLabelMap.CommonView}" widget-style="buttontext"> - <hyperlink target="viewImages" target-window="new" description="${uiLabelMap.CommonView}" also-hidden="false"> - <parameter param-name="drObjectInfo" from-field="origContentDataResourceViews[0].drObjectInfo"/> - </hyperlink> - </field> + <hyperlink target="${origContentDataResourceViews[0].drObjectInfo}" target-window="new" description="${uiLabelMap.CommonView}" also-hidden="false" target-type="content"/> + </field> </form> <form name="ImageManage" type="single" title="" header-row-style="header-row" default-table-style="basic-table" target="ListImageManage"> @@ -328,7 +318,7 @@ under the License. </field> <field name="description" use-when="${groovy: return context.statusId == 'IM_APPROVED'; }" title="Caption"><text/></field> <field name="defaultSequenceNum" use-when="${groovy: return context.statusId == 'IM_APPROVED'; }" title="Sort Order"><text maxlength="2" size="5"/></field> - <field name="enable" use-when="${groovy: return context.statusId == 'IM_APPROVED'; }" title="Exclude"><check/></field> + <field name="exclude" use-when="${groovy: return context.statusId == 'IM_APPROVED'; }" title="Exclude"><check/></field> <field name="thumbnail"> <hyperlink target="setImageThumbnail" description=" ${thumbnail}"> <parameter param-name="productId"/> @@ -336,13 +326,12 @@ under the License. <parameter param-name="contentIdTo"/> </hyperlink> </field> + <field name="drDataResourceName" title="Image Name"><display/></field> <field name="statusId" title="Status"> <display-entity entity-name="StatusItem" key-field-name="statusId" description="${description}"/> </field> <field name="viewButton" title="${uiLabelMap.CommonView}" widget-style="buttontext"> - <hyperlink target="viewImages" target-window="new" description="${uiLabelMap.CommonView}" also-hidden="false"> - <parameter param-name="drObjectInfo" from-field="origContentDataResourceViews[0].drObjectInfo"/> - </hyperlink> + <hyperlink target="${origContentDataResourceViews[0].drObjectInfo}" target-window="new" description="${uiLabelMap.CommonView}" also-hidden="false" target-type="content"/> </field> <field name="submitButton" title="${uiLabelMap.CommonSubmit}" widget-style="smallSubmit"><submit button-type="button"/></field> <sort-order> @@ -350,8 +339,9 @@ under the License. <sort-field name="action"/> <sort-field name="description"/> <sort-field name="defaultSequenceNum"/> - <sort-field name="enable"/> + <sort-field name="exclude"/> <sort-field name="thumbnail"/> + <sort-field name="drDataResourceName"/> <sort-field name="statusId"/> </sort-order> </form> @@ -642,9 +632,7 @@ under the License. <display-entity entity-name="StatusItem" key-field-name="statusId" description="${description}"/> </field> <field name="viewButton" title="${uiLabelMap.CommonView}" widget-style="buttontext"> - <hyperlink target="viewImages" target-window="new" description="${uiLabelMap.CommonView}" also-hidden="false"> - <parameter param-name="drObjectInfo" from-field="origContentDataResourceViews[0].drObjectInfo"/> - </hyperlink> + <hyperlink target="${origContentDataResourceViews[0].drObjectInfo}" target-window="new" description="${uiLabelMap.CommonView}" also-hidden="false" target-type="content"/> </field> </form> @@ -693,9 +681,7 @@ under the License. </field> <field name="purchaseFromDate" title="Approved Date"><display/></field> <field name="viewButton" title="${uiLabelMap.CommonView}" widget-style="buttontext"> - <hyperlink target="viewImages" target-window="new" description="${uiLabelMap.CommonView}" also-hidden="false"> - <parameter param-name="drObjectInfo" from-field="origContentDataResourceViews[0].drObjectInfo"/> - </hyperlink> + <hyperlink target="${origContentDataResourceViews[0].drObjectInfo}" target-window="new" description="${uiLabelMap.CommonView}" also-hidden="false" target-type="content"/> </field> </form> @@ -736,9 +722,7 @@ under the License. <display-entity entity-name="StatusItem" key-field-name="statusId" description="${description}"/> </field> <field name="viewButton" title="${uiLabelMap.CommonView}" widget-style="buttontext"> - <hyperlink target="viewImages" target-window="new" description="${uiLabelMap.CommonView}" also-hidden="false"> - <parameter param-name="drObjectInfo" from-field="origContentDataResourceViews[0].drObjectInfo"/> - </hyperlink> + <hyperlink target="${origContentDataResourceViews[0].drObjectInfo}" target-window="new" description="${uiLabelMap.CommonView}" also-hidden="false" target-type="content"/> </field> </form> @@ -781,9 +765,7 @@ under the License. <display-entity entity-name="StatusItem" key-field-name="statusId" description="${description}"/> </field> <field name="viewButton" title="${uiLabelMap.CommonView}" widget-style="buttontext"> - <hyperlink target="viewImages" target-window="new" description="${uiLabelMap.CommonView}" also-hidden="false"> - <parameter param-name="drObjectInfo" from-field="origContentDataResourceViews[0].drObjectInfo"/> - </hyperlink> + <hyperlink target="${origContentDataResourceViews[0].drObjectInfo}" target-window="new" description="${uiLabelMap.CommonView}" also-hidden="false" target-type="content"/> </field> </form> @@ -811,4 +793,56 @@ under the License. </hyperlink> </field>--> </form> + + <form name="ImageRemove" type="single" title="" header-row-style="header-row" default-table-style="basic-table" target="ListImageRemove"> + <field name="productId" title="${uiLabelMap.ChooseProductID}"><lookup target-form-name="LookupProduct"/></field> + <field name="submitButton" title="${uiLabelMap.CommonSubmit}" widget-style="smallSubmit"><submit button-type="button"/></field> + </form> + + <form name="ListImageRemove" type="list" title="" odd-row-style="alternate-row" default-table-style="basic-table" use-row-submit="true" separate-columns="true"> + <actions> + <entity-condition entity-name="ProductContentAndInfo"> + <condition-list combine="and"> + <condition-expr field-name="productId" from-field="parameters.productId"/> + <condition-expr field-name="productContentTypeId" value="IMAGE"/> + </condition-list> + </entity-condition> + </actions> + <row-actions> + <entity-and entity-name="ContentAssoc" list="contentAssocs"> + <field-map field-name="contentId"/> + <field-map field-name="contentAssocTypeId" value="IMAGE_THUMBNAIL"/> + </entity-and> + <set field="contentIdTo" from-field="contentAssocs[0].contentIdTo"/> + <entity-and entity-name="ContentDataResourceView" list="contentDataResourceViews"> + <field-map field-name="contentId" from-field="contentIdTo"/> + </entity-and> + <set field="drObjectInfo" from-field="contentDataResourceViews[0].drObjectInfo"/> + <entity-and entity-name="ContentDataResourceView" list="origContentDataResourceViews"> + <field-map field-name="contentId"/> + </entity-and> + </row-actions> + <field name="drObjectInfo" title="Image"><image/></field> + <field name="drDataResourceName" title="Image Name"> + <hyperlink target="${currentFormName}" description="${drDataResourceName}"> + <parameter param-name="productId"/> + <parameter param-name="contentId"/> + <parameter param-name="dataResourceId"/> + </hyperlink> + </field> + <field name="contentId"><display/></field> + <field name="dataResourceId"><display/></field> + <field name="fromDate"><display/></field> + <field name="statusId" title="Status"> + <display-entity entity-name="StatusItem" key-field-name="statusId" description="${description}"/> + </field> + <field name="deleteButton" title="${uiLabelMap.CommonRemove}" widget-style="buttontext"> + <hyperlink target="removeImage" description="${uiLabelMap.CommonRemove}" also-hidden="false" confirmation-message="Do you want to remove this image?"> + <parameter param-name="productId" from-field="productId"/> + <parameter param-name="contentId" from-field="contentId"/> + <parameter param-name="productContentTypeId" from-field="productContentTypeId"/> + <parameter param-name="fromDate" from-field="fromDate"/> + </hyperlink> + </field> + </form> </forms> Modified: ofbiz/trunk/applications/product/widget/catalog/ImageManagementScreens.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/widget/catalog/ImageManagementScreens.xml?rev=1067073&r1=1067072&r2=1067073&view=diff ============================================================================== --- ofbiz/trunk/applications/product/widget/catalog/ImageManagementScreens.xml (original) +++ ofbiz/trunk/applications/product/widget/catalog/ImageManagementScreens.xml Fri Feb 4 03:21:17 2011 @@ -29,9 +29,23 @@ under the License. <widgets> <decorator-screen name="ImageManagementDecorator" location="${parameters.mainDecoratorLocation}"> <decorator-section name="body"> - <screenlet title="${uiLabelMap.ImageManagementApplication}"> - <container><label style="label" text="${uiLabelMap.WelcomeMessage}"/></container> - </screenlet> + <section> + <condition> + <or> + <if-has-permission permission="IMAGE_MANAGEMENT_ADMIN"/> + </or> + </condition> + <widgets> + <screenlet title="${uiLabelMap.ImageManagementApplication}"> + <include-form name="ImageGallery" location="component://product/widget/catalog/ImageManagementForms.xml"/> + </screenlet> + </widgets> + <fail-widgets> + <screenlet title="${uiLabelMap.ImageManagementApplication}"> + <container><label style="label" text="${uiLabelMap.WelcomeMessage}"/></container> + </screenlet> + </fail-widgets> + </section> </decorator-section> </decorator-screen> </widgets> @@ -48,7 +62,7 @@ under the License. <decorator-section name="body"> <screenlet title="${uiLabelMap.Gallery}"> <include-form name="ImageGallery" location="component://product/widget/catalog/ImageManagementForms.xml"/> - </screenlet> + </screenlet> </decorator-section> </decorator-screen> </widgets> @@ -61,6 +75,7 @@ under the License. <not><if-empty field="parameters.productId"/></not> </condition> <actions> + <set field="productId" from-field="parameters.productId"/> <entity-one entity-name="Product" value-field="product"/> </actions> <widgets> @@ -96,6 +111,7 @@ under the License. <widgets> <decorator-screen name="ImageManagementDecorator" location="${parameters.mainDecoratorLocation}"> <decorator-section name="body"> + <label style="h1">${uiLabelMap.Product} ${uiLabelMap.CommonFor}: ${product.internalName} [${uiLabelMap.CommonId}:${product.productId}]</label> <screenlet title="${uiLabelMap.Gallery}"> <platform-specific> <html><html-template location="component://product/webapp/catalog/imagemanagement/ImageGallery.ftl"/></html> @@ -126,7 +142,7 @@ under the License. <section> <actions> <set field="userTabButtonImage" value="ImageGallery"/> - <set field="errorMessage" value="There is no a selected product, please insert or select the product to view image(s)."/> + <!--<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}"> @@ -406,6 +422,7 @@ under the License. </condition> <actions> <set field="userTabButtonImage" value="ImageManage"/> + <set field="productId" from-field="parameters.productId"/> <entity-one value-field="product" entity-name="Product"/> </actions> <widgets> @@ -421,6 +438,7 @@ under the License. <not><if-empty field="product"/></not> </condition> <widgets> + <label style="h1">${uiLabelMap.Product} ${uiLabelMap.CommonFor}: ${product.internalName} [${uiLabelMap.CommonId}:${product.productId}]</label> <screenlet title="${uiLabelMap.Manage}"> <include-form name="ListImageManage" location="component://product/widget/catalog/ImageManagementForms.xml"/> </screenlet> @@ -441,7 +459,7 @@ under the License. <section> <actions> <set field="userTabButtonImage" value="ImageManage"/> - <set field="errorMessage" value="There is no a selected product, please insert or select the product to view image(s)."/> + <!--<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}"> @@ -663,6 +681,7 @@ under the License. <set field="userTabButtonImage" value="ImageReplace"/> <set field="currentFormName" value="ListImageReplace"/> <set field="statusForm" value="IM_APPROVED"/> + <set field="productId" from-field="parameters.productId"/> <entity-one value-field="product" entity-name="Product"/> </actions> <widgets> @@ -678,16 +697,17 @@ under the License. <not><if-empty field="product"/></not> </condition> <widgets> + <label style="h1">${uiLabelMap.Product} ${uiLabelMap.CommonFor}: ${product.internalName} [${uiLabelMap.CommonId}:${product.productId}]</label> <container style="lefthalf"> - <screenlet title="${uiLabelMap.ChooseReplacementImage}"> - <include-form name="ListImageExist" location="component://product/widget/catalog/ImageManagementForms.xml"/> - </screenlet> + <screenlet title="${uiLabelMap.ChooseReplacementImage}"> + <include-form name="ListImageExist" location="component://product/widget/catalog/ImageManagementForms.xml"/> + </screenlet> + </container> + <container style="righthalf"> + <screenlet title="${uiLabelMap.ChooseImageToReplace}"> + <include-form name="ListImageReplace" location="component://product/widget/catalog/ImageManagementForms.xml"/> + </screenlet> </container> - <container style="righthalf"> - <screenlet title="${uiLabelMap.ChooseImageToReplace}"> - <include-form name="ListImageReplace" location="component://product/widget/catalog/ImageManagementForms.xml"/> - </screenlet> - </container> <container style="clear"/> <screenlet title="${uiLabelMap.Replace}"> <include-form name="ImageReplace" location="component://product/widget/catalog/ImageManagementForms.xml"/> @@ -709,7 +729,7 @@ under the License. <section> <actions> <set field="userTabButtonImage" value="ImageReplace"/> - <set field="errorMessage" value="There is no a selected product, please insert or select the product to view image(s)."/> + <!--<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}"> @@ -746,14 +766,6 @@ under the License. </section> </screen> - <screen name="ViewImages"> - <section> - <widgets> - <image src="${parameters.drObjectInfo}"></image> - </widgets> - </section> - </screen> - <screen name="ViewPreviewImage"> <section> <widgets> @@ -785,7 +797,10 @@ under the License. <decorator-section name="body"> <section> <condition> - <if-has-permission permission="IMAGE_MANAGEMENT_ADMIN"/> + <or> + <if-has-permission permission="IMAGE_MANAGEMENT_APPROVE"/> + <if-has-permission permission="IMAGE_MANAGEMENT_ADMIN"/> + </or> </condition> <widgets> <screenlet title="${uiLabelMap.RecentlyApproved}"> @@ -942,4 +957,102 @@ under the License. </widgets> </section> </screen> + + <screen name="ImageRemove"> + <section> + <actions> + <set field="userTabButtonImage" value="ImageRemove"/> + <set field="productId" from-field="parameters.productId"/> + </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="${parameters.productId}"> + <include-form name="ImageRemove" 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="ListImageRemove"> + <section> + <condition> + <not><if-empty field="parameters.productId"/></not> + </condition> + <actions> + <set field="userTabButtonImage" value="ImageRemove"/> + <set field="productId" from-field="parameters.productId"/> + <entity-one value-field="product" entity-name="Product"/> + </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> + <label style="h1">${uiLabelMap.Product} ${uiLabelMap.CommonFor}: ${product.internalName} [${uiLabelMap.CommonId}:${product.productId}]</label> + <screenlet title="${uiLabelMap.CommonRemove}"> + <include-form name="ListImageRemove" location="component://product/widget/catalog/ImageManagementForms.xml"/> + </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="ImageRemove"/> + <!--<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.CommonRemove}"> + <include-form name="ImageManage" 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> </screens> |
Free forum by Nabble | Edit this page |