Modified: ofbiz/branches/jackrabbit20100709/applications/product/src/org/ofbiz/product/imagemanagement/ImageManagementServices.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/applications/product/src/org/ofbiz/product/imagemanagement/ImageManagementServices.java?rev=1090153&r1=1090152&r2=1090153&view=diff ============================================================================== --- ofbiz/branches/jackrabbit20100709/applications/product/src/org/ofbiz/product/imagemanagement/ImageManagementServices.java (original) +++ ofbiz/branches/jackrabbit20100709/applications/product/src/org/ofbiz/product/imagemanagement/ImageManagementServices.java Fri Apr 8 08:07:00 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/branches/jackrabbit20100709/applications/product/src/org/ofbiz/product/product/ProductServices.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/applications/product/src/org/ofbiz/product/product/ProductServices.java?rev=1090153&r1=1090152&r2=1090153&view=diff ============================================================================== --- ofbiz/branches/jackrabbit20100709/applications/product/src/org/ofbiz/product/product/ProductServices.java (original) +++ ofbiz/branches/jackrabbit20100709/applications/product/src/org/ofbiz/product/product/ProductServices.java Fri Apr 8 08:07:00 2011 @@ -22,6 +22,8 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.io.RandomAccessFile; +import java.lang.NullPointerException; +import java.lang.SecurityException; import java.math.BigDecimal; import java.nio.ByteBuffer; import java.sql.Timestamp; @@ -1015,28 +1017,59 @@ public class ProductServices { /* Write the new image file */ String targetDirectory = imageServerPath + "/" + filePathPrefix; - File targetDir = new File(targetDirectory); - if (!targetDir.exists()) { - boolean created = targetDir.mkdirs(); - if (!created) { - String errMsg = UtilProperties.getMessage(resource, "ScaleImage.unable_to_create_target_directory", locale) + " - " + targetDirectory; - Debug.logFatal(errMsg, module); - return ServiceUtil.returnError(errMsg); + try { + File targetDir = new File(targetDirectory); + // Create the new directory + if (!targetDir.exists()) { + boolean created = targetDir.mkdirs(); + if (!created) { + String errMsg = UtilProperties.getMessage(resource, "ScaleImage.unable_to_create_target_directory", locale) + " - " + targetDirectory; + Debug.logFatal(errMsg, module); + return ServiceUtil.returnError(errMsg); + } + // Delete existing image files + // Images are ordered by productId (${location}/${id}/${viewtype}/${sizetype}) + } else if (!filenameToUse.contains(productId)) { + try { + File[] files = targetDir.listFiles(); + for(File file : files) { + if (file.isFile()) file.delete(); + } + } catch (SecurityException e) { + Debug.logError(e,module); + } + // Images aren't ordered by productId (${location}/${viewtype}/${sizetype}/${id}) + } else { + try { + File[] files = targetDir.listFiles(); + for(File file : files) { + if (file.isFile() && file.getName().startsWith(productId + "_View_" + viewNumber)) file.delete(); + } + } catch (SecurityException e) { + Debug.logError(e,module); + } } + } catch (NullPointerException e) { + Debug.logError(e,module); } - File file = new File(imageServerPath + "/" + fileLocation + "." + extension.getString("fileExtensionId")); + // Write 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 + "/" + fileLocation + "." + extension.getString("fileExtensionId")); + 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)); + } + } catch (NullPointerException e) { + Debug.logError(e,module); } /* scale Image in different sizes */ Modified: ofbiz/branches/jackrabbit20100709/applications/product/src/org/ofbiz/shipment/shipment/ShipmentServices.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/applications/product/src/org/ofbiz/shipment/shipment/ShipmentServices.java?rev=1090153&r1=1090152&r2=1090153&view=diff ============================================================================== --- ofbiz/branches/jackrabbit20100709/applications/product/src/org/ofbiz/shipment/shipment/ShipmentServices.java (original) +++ ofbiz/branches/jackrabbit20100709/applications/product/src/org/ofbiz/shipment/shipment/ShipmentServices.java Fri Apr 8 08:07:00 2011 @@ -281,8 +281,7 @@ public class ShipmentServices { } if (estimates == null || estimates.size() < 1) { if (initialEstimateAmt.compareTo(BigDecimal.ZERO) == 0) { - Debug.logWarning("Using the passed context : " + context, module); - Debug.logWarning("No shipping estimates found; the shipping amount returned is 0! Condition used was: " + estFieldsCond, module); + Debug.logWarning("No shipping estimates found; the shipping amount returned is 0! Condition used was: " + estFieldsCond + "; Using the passed context: " + context, module); } Map<String, Object> respNow = ServiceUtil.returnSuccess(); Modified: ofbiz/branches/jackrabbit20100709/applications/product/webapp/catalog/WEB-INF/actions/category/CategoryTree.groovy URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/applications/product/webapp/catalog/WEB-INF/actions/category/CategoryTree.groovy?rev=1090153&r1=1090152&r2=1090153&view=diff ============================================================================== --- ofbiz/branches/jackrabbit20100709/applications/product/webapp/catalog/WEB-INF/actions/category/CategoryTree.groovy (original) +++ ofbiz/branches/jackrabbit20100709/applications/product/webapp/catalog/WEB-INF/actions/category/CategoryTree.groovy Fri Apr 8 08:07:00 2011 @@ -31,46 +31,37 @@ import javolution.util.FastList.*; import org.ofbiz.entity.*; import java.util.List; -// Put the result of CategoryWorker.getRelatedCategories into the fillTree function as attribute. -// The fillTree function will return the complete list of category of given catalog. -// PLEASE NOTE : The structure of the complete list of fillTree function is according to the JSON_DATA plugin of the jsTree. - -List fillTree(rootCat) { - if (rootCat) { - rootCat.sort{ it.productCategoryId } - def listTree = FastList.newInstance(); - for (root in rootCat) { - preCatChilds = delegator.findByAnd("ProductCategoryRollup", ["parentProductCategoryId": root.productCategoryId]); - catChilds = EntityUtil.getRelated("CurrentProductCategory",preCatChilds); - def childList = FastList.newInstance(); - def rootMap = FastMap.newInstance(); - category = delegator.findByPrimaryKey("ProductCategory", ["productCategoryId": root.productCategoryId]); - categoryContentWrapper = new CategoryContentWrapper(category, request); - context.title = categoryContentWrapper.CATEGORY_NAME; - categoryDescription = categoryContentWrapper.DESCRIPTION; +// Put the result of CategoryWorker.getRelatedCategories into the separateRootType function as attribute. +// The separateRootType function will return the list of category of given catalog. +// PLEASE NOTE : The structure of the list of separateRootType function is according to the JSON_DATA plugin of the jsTree. + +completedTree = FastList.newInstance(); + +List separateRootType(roots) { + if(roots) { + prodRootTypeTree = FastList.newInstance(); + def i = 0; + for(root in roots) { + prodCatalogMap2 = FastMap.newInstance(); + prodCatalogTree2 = FastList.newInstance(); + prodCatalogCategories = FastList.newInstance(); + prodCatalog = root.getRelatedOne("ProductCategory"); + + productCat = root.getRelatedOne("ProductCategory"); + prodCatalogId = productCat.getString("productCategoryId"); + prodCatalogMap2.put("productCategoryId", prodCatalogId); + prodCatalogMap2.put("categoryName", productCat.getString("categoryName")); + prodCatalogMap2.put("isCatalog", false) + prodCatalogMap.put("isCategoryType", true); - if (categoryContentWrapper.CATEGORY_NAME) { - rootMap["categoryName"] = categoryContentWrapper.CATEGORY_NAME; - } else { - rootMap["categoryName"] = root.categoryName; - } - if (categoryContentWrapper.DESCRIPTION) { - rootMap["categoryDescription"] = categoryContentWrapper.DESCRIPTION; - } else { - rootMap["categoryDescription"] = root.description; - } - rootMap["productCategoryId"] = root.productCategoryId; - rootMap["child"] = catChilds; - rootMap["isCatalog"] = false; - listTree.add(rootMap); + i++; + prodRootTypeTree.add(prodCatalogMap2); } - return listTree; + return prodRootTypeTree; } } -completedTree = FastList.newInstance(); - // Get the Catalogs prodCatalogs = delegator.findByAnd("ProdCatalog"); @@ -83,14 +74,14 @@ if (prodCatalogs.size() > 0) { prodCatalogMap.put("productCategoryId", prodCatalogId); prodCatalogMap.put("categoryName", prodCatalog.getString("catalogName")); prodCatalogMap.put("isCatalog", true); + prodCatalogMap.put("isCategoryType", false); + + prodCatalogCategories = EntityUtil.filterByDate(delegator.findByAnd("ProdCatalogCategory", ["prodCatalogId" : prodCatalog.prodCatalogId])); - CategoryWorker.getRelatedCategories(request, "CatalogList_"+i, CatalogWorker.getCatalogTopCategoryId(request, prodCatalogId), true); - categoryList = null; - categoryList = request.getAttribute("CatalogList_"+i); prodCatalogTree = FastList.newInstance(); - if (categoryList) { - prodCatalogTree = fillTree(categoryList); + if (prodCatalogCategories) { + prodCatalogTree = separateRootType(prodCatalogCategories); prodCatalogMap.put("child", prodCatalogTree); completedTree.add(prodCatalogMap); } Added: ofbiz/branches/jackrabbit20100709/applications/product/webapp/catalog/WEB-INF/actions/imagemanagement/ImageGallery.groovy URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/applications/product/webapp/catalog/WEB-INF/actions/imagemanagement/ImageGallery.groovy?rev=1090153&view=auto ============================================================================== --- ofbiz/branches/jackrabbit20100709/applications/product/webapp/catalog/WEB-INF/actions/imagemanagement/ImageGallery.groovy (added) +++ ofbiz/branches/jackrabbit20100709/applications/product/webapp/catalog/WEB-INF/actions/imagemanagement/ImageGallery.groovy Fri Apr 8 08:07:00 2011 @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* + * This script is also referenced by the ecommerce's screens and + * should not contain order component's specific code. + */ + +import org.ofbiz.base.util.*; +import org.ofbiz.entity.*; +import org.ofbiz.entity.condition.*; +import org.ofbiz.entity.util.*; + +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.contentId = productContentAndInfoImageManament.contentId; + productImageMap.dataResourceId = productContentAndInfoImageManament.dataResourceId; + productImageMap.productImageThumb = productImageThumb.drObjectInfo; + productImageMap.productImage = productContentAndInfoImageManament.drObjectInfo; + productImageList.add(productImageMap); + } + } + } + context.productImageList = productImageList; +} Added: ofbiz/branches/jackrabbit20100709/applications/product/webapp/catalog/WEB-INF/actions/imagemanagement/SetDefaultImage.groovy URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/applications/product/webapp/catalog/WEB-INF/actions/imagemanagement/SetDefaultImage.groovy?rev=1090153&view=auto ============================================================================== --- ofbiz/branches/jackrabbit20100709/applications/product/webapp/catalog/WEB-INF/actions/imagemanagement/SetDefaultImage.groovy (added) +++ ofbiz/branches/jackrabbit20100709/applications/product/webapp/catalog/WEB-INF/actions/imagemanagement/SetDefaultImage.groovy Fri Apr 8 08:07:00 2011 @@ -0,0 +1,175 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.awt.image.BufferedImage; +import java.awt.image.RenderedImage; +import java.io.File; +import java.util.List; + +import javax.imageio.ImageIO; + +import org.ofbiz.entity.*; +import org.ofbiz.entity.util.EntityUtil; +import org.ofbiz.base.util.*; +import org.ofbiz.base.util.string.*; +import org.ofbiz.product.image.ScaleImage; + +context.nowTimestampString = UtilDateTime.nowTimestamp().toString(); + +imageManagementPath = FlexibleStringExpander.expandString(UtilProperties.getPropertyValue("catalog", "image.management.path"), context); + +String fileType = "original"; +String productId = request.getParameter("productId"); + +productContentList = delegator.findByAnd("ProductContentAndInfo", UtilMisc.toMap("productId", productId, "productContentTypeId", "DEFAULT_IMAGE")); +if (productContentList) { + dataResourceName = productContentList.get(0).drDataResourceName +} + +// make the image file formats +imageFilenameFormat = UtilProperties.getPropertyValue('catalog', 'image.filename.format'); +imageServerPath = FlexibleStringExpander.expandString(UtilProperties.getPropertyValue("catalog", "image.server.path"), context); +imageUrlPrefix = UtilProperties.getPropertyValue('catalog', 'image.url.prefix'); +context.imageFilenameFormat = imageFilenameFormat; +context.imageServerPath = imageServerPath; +context.imageUrlPrefix = imageUrlPrefix; + +filenameExpander = FlexibleStringExpander.getInstance(imageFilenameFormat); +context.imageNameSmall = imageUrlPrefix + "/" + filenameExpander.expandString([location : 'products', id : productId, type : 'small']); +context.imageNameMedium = imageUrlPrefix + "/" + filenameExpander.expandString([location : 'products', id : productId, type : 'medium']); +context.imageNameLarge = imageUrlPrefix + "/" + filenameExpander.expandString([location : 'products', id : productId, type : 'large']); +context.imageNameDetail = imageUrlPrefix + "/" + filenameExpander.expandString([location : 'products', id : productId, type : 'detail']); +context.imageNameOriginal = imageUrlPrefix + "/" + filenameExpander.expandString([location : 'products', id : productId, type : 'original']); + +// Start ProductContent stuff +if (productId) { + product = delegator.findByPrimaryKey("Product",["productId" : productId]); + context.productId = productId; +} + +productContent = null; +if (product) { + productContent = product.getRelated('ProductContent', null, ['productContentTypeId']); +} +context.productContent = productContent; +// End ProductContent stuff + +tryEntity = true; +if (request.getAttribute("_ERROR_MESSAGE_")) { + tryEntity = false; +} +if (!product) { + tryEntity = false; +} + +if ("true".equalsIgnoreCase((String) request.getParameter("tryEntity"))) { + tryEntity = true; +} +context.tryEntity = tryEntity; + +//UPLOADING STUFF +forLock = new Object(); +contentType = null; +if (fileType) { + + context.fileType = fileType; + + fileLocation = filenameExpander.expandString([location : 'products', id : productId, type : fileType]); + filePathPrefix = ""; + 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); + } + + int i1; + if (contentType && (i1 = contentType.indexOf("boundary=")) != -1) { + contentType = contentType.substring(i1 + 9); + contentType = "--" + contentType; + } + + defaultFileName = "temp_" + dataResourceName; + BufferedImage bufImg = ImageIO.read(new File(imageManagementPath + "/" + productId + "/" + dataResourceName)); + ImageIO.write((RenderedImage) bufImg, "jpg", new File(imageManagementPath + "/" + productId + "/" + defaultFileName)); + + clientFileName = dataResourceName; + if (clientFileName) { + context.clientFileName = clientFileName; + } + + if (clientFileName && clientFileName.length() > 0) { + if (clientFileName.lastIndexOf(".") > 0 && clientFileName.lastIndexOf(".") < clientFileName.length()) { + filenameToUse += clientFileName.substring(clientFileName.lastIndexOf(".")); + } else { + filenameToUse += ".jpg"; + } + + context.clientFileName = clientFileName; + context.filenameToUse = filenameToUse; + + characterEncoding = request.getCharacterEncoding(); + imageUrl = imageUrlPrefix + "/" + filePathPrefix + java.net.URLEncoder.encode(filenameToUse, characterEncoding); + + try { + file = new File(imageManagementPath + "/" + productId + "/" + defaultFileName); + file1 = new File(imageServerPath + "/" + filePathPrefix, filenameToUse); + try { + // Delete existing image files + File targetDir = new File(imageServerPath + "/" + filePathPrefix); + // Images are ordered by productId (${location}/${id}/${viewtype}/${sizetype}) + if (!filenameToUse.startsWith(productId + ".")) { + File[] files = targetDir.listFiles(); + for(File file : files) { + if (file.isFile() && !file.getName().equals(defaultFileName)) file.delete(); + } + // Images aren't ordered by productId (${location}/${viewtype}/${sizetype}/${id}) !!! BE CAREFUL !!! + } else { + File[] files = targetDir.listFiles(); + for(File file : files) { + if (file.isFile() && !file.getName().equals(defaultFileName) && file.getName().startsWith(productId + ".")) file.delete(); + } + } + } catch (Exception e) { + System.out.println("error deleting existing file (not neccessarily a problem)"); + } + file.renameTo(file1); + } catch (Exception e) { + e.printStackTrace(); + } + + if (imageUrl && imageUrl.length() > 0) { + context.imageUrl = imageUrl; + product.set(fileType + "ImageUrl", imageUrl); + + // call scaleImageInAllSize + if (fileType.equals("original")) { + result = ScaleImage.scaleImageInAllSize(context, filenameToUse, "main", "0"); + + if (result.containsKey("responseMessage") && result.get("responseMessage").equals("success")) { + imgMap = result.get("imageUrlMap"); + imgMap.each() { key, value -> + product.set(key + "ImageUrl", value); + } + } + } + + product.store(); + } + } +} Modified: ofbiz/branches/jackrabbit20100709/applications/product/webapp/catalog/WEB-INF/actions/product/EditProductContent.groovy URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/applications/product/webapp/catalog/WEB-INF/actions/product/EditProductContent.groovy?rev=1090153&r1=1090152&r2=1090153&view=diff ============================================================================== --- ofbiz/branches/jackrabbit20100709/applications/product/webapp/catalog/WEB-INF/actions/product/EditProductContent.groovy (original) +++ ofbiz/branches/jackrabbit20100709/applications/product/webapp/catalog/WEB-INF/actions/product/EditProductContent.groovy Fri Apr 8 08:07:00 2011 @@ -110,7 +110,21 @@ if (fileType) { file = new File(imageServerPath + "/" + filePathPrefix, defaultFileName); file1 = new File(imageServerPath + "/" + filePathPrefix, filenameToUse); try { - file1.delete(); + // Delete existing image files + File targetDir = new File(imageServerPath + "/" + filePathPrefix); + // Images are ordered by productId (${location}/${id}/${viewtype}/${sizetype}) + if (!filenameToUse.startsWith(productId + ".")) { + File[] files = targetDir.listFiles(); + for(File file : files) { + if (file.isFile() && !file.getName().equals(defaultFileName)) file.delete(); + } + // Images aren't ordered by productId (${location}/${viewtype}/${sizetype}/${id}) !!! BE CAREFUL !!! + } else { + File[] files = targetDir.listFiles(); + for(File file : files) { + if (file.isFile() && !file.getName().equals(defaultFileName) && file.getName().startsWith(productId + ".")) file.delete(); + } + } } catch (Exception e) { System.out.println("error deleting existing file (not neccessarily a problem)"); } Modified: ofbiz/branches/jackrabbit20100709/applications/product/webapp/catalog/WEB-INF/controller.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/applications/product/webapp/catalog/WEB-INF/controller.xml?rev=1090153&r1=1090152&r2=1090153&view=diff ============================================================================== --- ofbiz/branches/jackrabbit20100709/applications/product/webapp/catalog/WEB-INF/controller.xml (original) +++ ofbiz/branches/jackrabbit20100709/applications/product/webapp/catalog/WEB-INF/controller.xml Fri Apr 8 08:07:00 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/branches/jackrabbit20100709/applications/product/webapp/catalog/category/CategoryTree.ftl URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/applications/product/webapp/catalog/category/CategoryTree.ftl?rev=1090153&r1=1090152&r2=1090153&view=diff ============================================================================== --- ofbiz/branches/jackrabbit20100709/applications/product/webapp/catalog/category/CategoryTree.ftl (original) +++ ofbiz/branches/jackrabbit20100709/applications/product/webapp/catalog/category/CategoryTree.ftl Fri Apr 8 08:07:00 2011 @@ -36,7 +36,7 @@ var rawdata = [ <#list rootCat as root> { "data": {"title" : unescapeHtmlText("<#if root.categoryName?exists>${root.categoryName?js_string} [${root.productCategoryId}]<#else>${root.productCategoryId?js_string}</#if>"), "attr": {"onClick" : "window.location.href='<@ofbizUrl>/EditProdCatalog?prodCatalogId=${root.productCategoryId}</@ofbizUrl>'; return false;"}}, - "attr": {"id" : "${root.productCategoryId}", "rel" : "root", "isCatalog" : "${root.isCatalog?string}"} + "attr": {"id" : "${root.productCategoryId}", "rel" : "root", "isCatalog" : "${root.isCatalog?string}" ,"isCategoryType" : "${root.isCategoryType?string}"} <#if root.child?exists> ,"state" : "closed" </#if> @@ -68,12 +68,24 @@ var rawdata = [ "ajax" : { "url" : "<@ofbizUrl>getChild</@ofbizUrl>", "type" : "POST", "data" : function (n) { return { + "isCategoryType" : n.attr ? n.attr("isCatalog").replace("node_","") : 1 , "isCatalog" : n.attr ? n.attr("isCatalog").replace("node_","") : 1 , "productCategoryId" : n.attr ? n.attr("id").replace("node_","") : 1 }; } } - } + }, + "types" : { + "valid_children" : [ "root" ], + "types" : { + "CATEGORY" : { + "icon" : { + "image" : "/images/jquery/plugins/jsTree/themes/apple/d.png", + "position" : "10px40px" + } + } + } + } }); }); } Modified: ofbiz/branches/jackrabbit20100709/applications/product/webapp/catalog/imagemanagement/ImageGallery.ftl URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/applications/product/webapp/catalog/imagemanagement/ImageGallery.ftl?rev=1090153&r1=1090152&r2=1090153&view=diff ============================================================================== --- ofbiz/branches/jackrabbit20100709/applications/product/webapp/catalog/imagemanagement/ImageGallery.ftl (original) +++ ofbiz/branches/jackrabbit20100709/applications/product/webapp/catalog/imagemanagement/ImageGallery.ftl Fri Apr 8 08:07:00 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/branches/jackrabbit20100709/applications/product/webapp/catalog/imagemanagement/ImageShare.ftl URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/applications/product/webapp/catalog/imagemanagement/ImageShare.ftl?rev=1090153&r1=1090152&r2=1090153&view=diff ============================================================================== --- ofbiz/branches/jackrabbit20100709/applications/product/webapp/catalog/imagemanagement/ImageShare.ftl (original) +++ ofbiz/branches/jackrabbit20100709/applications/product/webapp/catalog/imagemanagement/ImageShare.ftl Fri Apr 8 08:07:00 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/branches/jackrabbit20100709/applications/product/webapp/catalog/product/ProductBarCode.fo.ftl URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/applications/product/webapp/catalog/product/ProductBarCode.fo.ftl?rev=1090153&r1=1090152&r2=1090153&view=diff ============================================================================== --- ofbiz/branches/jackrabbit20100709/applications/product/webapp/catalog/product/ProductBarCode.fo.ftl (original) +++ ofbiz/branches/jackrabbit20100709/applications/product/webapp/catalog/product/ProductBarCode.fo.ftl Fri Apr 8 08:07:00 2011 @@ -32,7 +32,7 @@ under the License. <fo:page-sequence master-reference="main"> <fo:flow flow-name="xsl-region-body" font-family="Helvetica"> <fo:block text-align="center"> - ${productName} + ${productName!} </fo:block> <fo:block text-align="center"> <fo:instream-foreign-object> Modified: ofbiz/branches/jackrabbit20100709/applications/product/webapp/catalog/promo/EditProductPromoRules.ftl URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/applications/product/webapp/catalog/promo/EditProductPromoRules.ftl?rev=1090153&r1=1090152&r2=1090153&view=diff ============================================================================== --- ofbiz/branches/jackrabbit20100709/applications/product/webapp/catalog/promo/EditProductPromoRules.ftl (original) +++ ofbiz/branches/jackrabbit20100709/applications/product/webapp/catalog/promo/EditProductPromoRules.ftl Fri Apr 8 08:07:00 2011 @@ -232,7 +232,7 @@ under the License. </#list> </select> <input type="text" size="25" name="condValue" /> - ${uiLabelMap.CommonOther}:<input type="text" size="10" name="otherValue" /> + ${uiLabelMap.CommonOther}:<input type="text" size="10" name="otherValue" /><br /> <label>${uiLabelMap.OrderSelectShippingMethod}:</label> <select name = "carrierShipmentMethod"> <option value = "">--${uiLabelMap.OrderSelectShippingMethod}--</option> @@ -278,8 +278,8 @@ under the License. ${uiLabelMap.ProductQuantity}: <input type="text" size="5" name="quantity" value="${(productPromoAction.quantity)?if_exists}" /> ${uiLabelMap.ProductAmount}: <input type="text" size="5" name="amount" value="${(productPromoAction.amount)?if_exists}" /> ${uiLabelMap.ProductItemId}: <input type="text" size="15" name="productId" value="${(productPromoAction.productId)?if_exists}" /> - ${uiLabelMap.PartyParty}: <input type="text" size="10" name="partyId" value="${(productPromoAction.partyId)?if_exists}" /> - ${uiLabelMap.ServiceName}: <input type="text" size="20" name="serviceName" value="${(productPromoAction.serviceName)?if_exists}" /> + ${uiLabelMap.PartyParty}: <input type="text" size="10" name="partyId" value="${(productPromoAction.partyId)?if_exists}" /><br /> + ${uiLabelMap.ProductServiceName}: <input type="text" size="20" name="serviceName" value="${(productPromoAction.serviceName)?if_exists}" /> ${uiLabelMap.UseCartQuantity}: <select name="useCartQuantity"> <#if (productPromoAction.useCartQuantity)?exists> @@ -404,8 +404,8 @@ under the License. ${uiLabelMap.ProductQuantity}: <input type="text" size="5" name="quantity" /> ${uiLabelMap.ProductAmount}: <input type="text" size="5" name="amount" /> ${uiLabelMap.ProductItemId}: <input type="text" size="15" name="productId" /> - ${uiLabelMap.PartyParty}: <input type="text" size="10" name="partyId" /> - ${uiLabelMap.ServiceName}: <input type="text" size="20" name="serviceName" /> + ${uiLabelMap.PartyParty}: <input type="text" size="10" name="partyId" /><br /> + ${uiLabelMap.ProductServiceName}: <input type="text" size="20" name="serviceName" /> ${uiLabelMap.UseCartQuantity}: <select name="useCartQuantity"> <option value="N">${uiLabelMap.CommonN}</option> Modified: ofbiz/branches/jackrabbit20100709/applications/product/webapp/facility/inventory/receiveInventory.ftl URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/applications/product/webapp/facility/inventory/receiveInventory.ftl?rev=1090153&r1=1090152&r2=1090153&view=diff ============================================================================== --- ofbiz/branches/jackrabbit20100709/applications/product/webapp/facility/inventory/receiveInventory.ftl (original) +++ ofbiz/branches/jackrabbit20100709/applications/product/webapp/facility/inventory/receiveInventory.ftl Fri Apr 8 08:07:00 2011 @@ -207,7 +207,7 @@ under the License. <#else> <#assign LookupFacilityLocationView="LookupFacilityLocation"> </#if> - <@htmlTemplate.lookupField formName="selectAllForm" name="locationSeqId_o_${rowCount}" id="locationSeqId_o_${rowCount}" fieldFormName="${LookupFacilityLocationView}"/> + <@htmlTemplate.lookupField formName="selectAllForm" name="locationSeqId" id="locationSeqId" fieldFormName="${LookupFacilityLocationView}"/> </#if> </td> </tr> @@ -459,7 +459,7 @@ under the License. <td> </td> <td align="right">${uiLabelMap.ProductFacilityOwner}:</td> <td align="right"><input type="text" name="ownerPartyId_o_${rowCount}" size="20" maxlength="20" value="${facility.ownerPartyId}"/></td> - <#if currencyUomId != orderCurrencyUomId> + <#if currencyUomId?default('') != orderCurrencyUomId?default('')> <td>${uiLabelMap.ProductPerUnitPriceOrder}:</td> <td> <input type="hidden" name="orderCurrencyUomId_o_${rowCount}" value="${orderCurrencyUomId?if_exists}" /> Modified: ofbiz/branches/jackrabbit20100709/applications/product/widget/catalog/CatalogMenus.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/applications/product/widget/catalog/CatalogMenus.xml?rev=1090153&r1=1090152&r2=1090153&view=diff ============================================================================== --- ofbiz/branches/jackrabbit20100709/applications/product/widget/catalog/CatalogMenus.xml (original) +++ ofbiz/branches/jackrabbit20100709/applications/product/widget/catalog/CatalogMenus.xml Fri Apr 8 08:07:00 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/branches/jackrabbit20100709/applications/product/widget/catalog/CategoryForms.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/applications/product/widget/catalog/CategoryForms.xml?rev=1090153&r1=1090152&r2=1090153&view=diff ============================================================================== --- ofbiz/branches/jackrabbit20100709/applications/product/widget/catalog/CategoryForms.xml (original) +++ ofbiz/branches/jackrabbit20100709/applications/product/widget/catalog/CategoryForms.xml Fri Apr 8 08:07:00 2011 @@ -192,12 +192,8 @@ under the License. <field name="imageUrl" tooltip="${uiLabelMap.ProductImageUrlTooltip}"><text size="60" maxlength="255"/></field> <field name="linkTypeEnumId" title="${uiLabelMap.ProductLinkTypeEnumId}"> <drop-down allow-empty = "false"> - <entity-options description="${description}" entity-name="Enumeration" key-field-name="enumId"> - <entity-constraint name="enumId" operator="equals" value="PCLT_SEARCH_PARAM"/> - <entity-order-by field-name="description"/> - </entity-options> - <entity-options description="${description}" entity-name="Enumeration" key-field-name="enumId"> - <entity-constraint name="enumId" operator="equals" value="PCLT_ABS_URL"/> + <entity-options description="${groovy: uiLabelMap.get("ProductCategoryLinkType.description."+enumId)}" entity-name="Enumeration" key-field-name="enumId"> + <entity-constraint name="enumTypeId" operator="equals" value="PCAT_LINK_TYPE"/> <entity-order-by field-name="description"/> </entity-options> </drop-down> Modified: ofbiz/branches/jackrabbit20100709/applications/product/widget/catalog/CategoryScreens.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/applications/product/widget/catalog/CategoryScreens.xml?rev=1090153&r1=1090152&r2=1090153&view=diff ============================================================================== --- ofbiz/branches/jackrabbit20100709/applications/product/widget/catalog/CategoryScreens.xml (original) +++ ofbiz/branches/jackrabbit20100709/applications/product/widget/catalog/CategoryScreens.xml Fri Apr 8 08:07:00 2011 @@ -483,6 +483,8 @@ under the License. <screen name="EditProductCategoryLinks"> <section> <actions> + <property-map resource="ProductEntityLabels" map-name="uiLabelMap" global="true"/> + <set field="titleProperty" value="PageTitleEditProductCategoryLink"/> <set field="headerItem" value="categories"/> <set field="tabButtonItem" value="EditProductCategoryLinks"/> Modified: ofbiz/branches/jackrabbit20100709/applications/product/widget/catalog/CommonScreens.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/applications/product/widget/catalog/CommonScreens.xml?rev=1090153&r1=1090152&r2=1090153&view=diff ============================================================================== --- ofbiz/branches/jackrabbit20100709/applications/product/widget/catalog/CommonScreens.xml (original) +++ ofbiz/branches/jackrabbit20100709/applications/product/widget/catalog/CommonScreens.xml Fri Apr 8 08:07:00 2011 @@ -43,7 +43,7 @@ under the License. <set field="applicationTitle" value="${uiLabelMap.ProductCatalogManagerApplication}" global="true"/> <set field="layoutSettings.javaScripts[+0]" value="/images/jquery/ui/development-bundle/external/jquery.cookie.js" global="true"/> <set field="layoutSettings.javaScripts[+0]" value="/images/jquery/plugins/jsTree/jquery.jstree.js" global="true"/> - <set field="layoutSettings.javaScripts[+0]" value="/images/jquery/jquery-1.5.1.min.js" global="true"/> + <set field="layoutSettings.javaScripts[+0]" value="/images/jquery/jquery-1.5.2.min.js" global="true"/> </actions> <widgets> <include-screen name="ApplicationDecorator" location="component://commonext/widget/CommonScreens.xml"/> @@ -379,7 +379,7 @@ under the License. </decorator-screen> </widgets> </section> - </screen> + </screen> <screen name="ImageManagementDecorator"> <section> Modified: ofbiz/branches/jackrabbit20100709/applications/product/widget/catalog/ImageManagementForms.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/applications/product/widget/catalog/ImageManagementForms.xml?rev=1090153&r1=1090152&r2=1090153&view=diff ============================================================================== --- ofbiz/branches/jackrabbit20100709/applications/product/widget/catalog/ImageManagementForms.xml (original) +++ ofbiz/branches/jackrabbit20100709/applications/product/widget/catalog/ImageManagementForms.xml Fri Apr 8 08:07:00 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/branches/jackrabbit20100709/applications/product/widget/catalog/ImageManagementScreens.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/applications/product/widget/catalog/ImageManagementScreens.xml?rev=1090153&r1=1090152&r2=1090153&view=diff ============================================================================== --- ofbiz/branches/jackrabbit20100709/applications/product/widget/catalog/ImageManagementScreens.xml (original) +++ ofbiz/branches/jackrabbit20100709/applications/product/widget/catalog/ImageManagementScreens.xml Fri Apr 8 08:07:00 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> |
Free forum by Nabble | Edit this page |