From 8bfaac26482a050f4f931bc858c64323f303fdcf Mon Sep 17 00:00:00 2001 From: Jacques Le Roux Date: Sun, 4 Jan 2009 21:44:14 +0000 Subject: [PATCH] A modified patch from Marco Risaliti "New tool to get labels information" (https://issues.apache.org/jira/browse/OFBIZ-2070) - OFBIZ-2070 I have already commited merged changes in labels files. I commented out for now the lines in SaveLabelsToXmlFile.java which write the XML changes. We have, at least, known 2 issued related to SaveLabelsToXmlFile : . adding the ASL header . taking care of labels sorting in a case described here https://issues.apache.org/jira/browse/OFBIZ-2070?focusedCommentId=12660632#action_12660632 git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@731370 13f79535-47bb-0310-9956-ffa450edef68 --- .../webtools/data/WebtoolsSecurityData.xml | 6 + framework/webtools/servicedef/services.xml | 21 +- .../webtools/labelmanager/LabelInfo.java | 87 +++++++ .../labelmanager/LabelManagerFactory.java | 233 ++++++++++++++++++ .../labelmanager/SaveLabelsToXmlFile.java | 113 +++++++++ .../actions/labelmanager/LabelManager.groovy | 29 +++ .../actions/labelmanager/UpdateManager.groovy | 31 +++ .../webapp/webtools/WEB-INF/controller.xml | 33 ++- .../webtools/labelmanager/SearchLabels.ftl | 84 +++++++ .../webtools/labelmanager/UpdateLabel.ftl | 97 ++++++++ .../webtools/labelmanager/ViewLabels.ftl | 94 +++++++ framework/webtools/webapp/webtools/main.ftl | 8 +- .../webtools/widget/LabelManagerScreens.xml | 72 ++++++ 13 files changed, 902 insertions(+), 6 deletions(-) create mode 100644 framework/webtools/src/org/ofbiz/webtools/labelmanager/LabelInfo.java create mode 100644 framework/webtools/src/org/ofbiz/webtools/labelmanager/LabelManagerFactory.java create mode 100644 framework/webtools/src/org/ofbiz/webtools/labelmanager/SaveLabelsToXmlFile.java create mode 100644 framework/webtools/webapp/webtools/WEB-INF/actions/labelmanager/LabelManager.groovy create mode 100644 framework/webtools/webapp/webtools/WEB-INF/actions/labelmanager/UpdateManager.groovy create mode 100644 framework/webtools/webapp/webtools/labelmanager/SearchLabels.ftl create mode 100644 framework/webtools/webapp/webtools/labelmanager/UpdateLabel.ftl create mode 100644 framework/webtools/webapp/webtools/labelmanager/ViewLabels.ftl create mode 100644 framework/webtools/widget/LabelManagerScreens.xml diff --git a/framework/webtools/data/WebtoolsSecurityData.xml b/framework/webtools/data/WebtoolsSecurityData.xml index b886ad9367..7d221606f1 100644 --- a/framework/webtools/data/WebtoolsSecurityData.xml +++ b/framework/webtools/data/WebtoolsSecurityData.xml @@ -36,6 +36,12 @@ under the License. + + + + + + diff --git a/framework/webtools/servicedef/services.xml b/framework/webtools/servicedef/services.xml index a921217441..cd40a9549d 100644 --- a/framework/webtools/servicedef/services.xml +++ b/framework/webtools/servicedef/services.xml @@ -20,9 +20,9 @@ under the License. - OFBiz WebTools Services - OFBiz - 1.0 + OFBiz WebTools Services + OFBiz + 1.0 @@ -123,4 +123,19 @@ under the License. + + Save labels to xml file + + + + Update Label Key + + + + + + + diff --git a/framework/webtools/src/org/ofbiz/webtools/labelmanager/LabelInfo.java b/framework/webtools/src/org/ofbiz/webtools/labelmanager/LabelInfo.java new file mode 100644 index 0000000000..797646e322 --- /dev/null +++ b/framework/webtools/src/org/ofbiz/webtools/labelmanager/LabelInfo.java @@ -0,0 +1,87 @@ +/* + * 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. + */ +package org.ofbiz.webtools.labelmanager; + +import java.util.Map; + +import javolution.util.FastMap; + +import org.ofbiz.base.util.Debug; +import org.ofbiz.base.util.GeneralException; +import org.ofbiz.base.util.UtilValidate; + +public class LabelInfo { + + public static final String module = LabelInfo.class.getName(); + + protected String labelKey = ""; + protected String fileName = ""; + protected String componentName = ""; + protected Map labelValues = FastMap.newInstance(); + + public LabelInfo(String labelKey, String fileName, String componentName, String localeStr, String labelValue) throws GeneralException { + this.labelKey = labelKey; + this.fileName = fileName; + this.componentName = componentName; + setLabelValue(localeStr, labelValue, false); + } + + public String getLabelKey() { + return labelKey; + } + + public String getFileName() { + return fileName; + } + + public String getComponentName() { + return componentName; + } + + public String getLabelValue(String localeStr) { + return (String)labelValues.get(localeStr); + } + + public int getLabelValueSize() { + return labelValues.size(); + } + + public boolean setLabelValue(String localeStr, String labelValue, boolean update) { + String localeFound = getLabelValue(localeStr); + boolean isDuplicatedLocales = false; + + if (UtilValidate.isEmpty(localeFound)) { + if (UtilValidate.isNotEmpty(labelValue)) { + labelValues.put(localeStr, labelValue); + } + } else { + if (update) { + if (UtilValidate.isNotEmpty(labelValue)) { + labelValues.put(localeStr, labelValue); + } else { + labelValues.remove(localeStr); + } + } else { + Debug.logWarning("Already found locale " + localeStr + " for label " + labelKey + " into the file " + fileName, module); + isDuplicatedLocales = true; + } + } + return isDuplicatedLocales; + } +} diff --git a/framework/webtools/src/org/ofbiz/webtools/labelmanager/LabelManagerFactory.java b/framework/webtools/src/org/ofbiz/webtools/labelmanager/LabelManagerFactory.java new file mode 100644 index 0000000000..e4afba7c9c --- /dev/null +++ b/framework/webtools/src/org/ofbiz/webtools/labelmanager/LabelManagerFactory.java @@ -0,0 +1,233 @@ +/* + * 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. + */ +package org.ofbiz.webtools.labelmanager; + +import java.io.File; +import java.io.IOException; +import java.util.Collection; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Set; +import java.util.TreeMap; +import java.util.TreeSet; + +import org.ofbiz.base.component.ComponentConfig; +import org.ofbiz.base.util.FileUtil; +import org.ofbiz.base.util.GeneralException; +import org.ofbiz.base.util.UtilGenerics; +import org.ofbiz.base.util.UtilMisc; +import org.ofbiz.base.util.UtilProperties; +import org.ofbiz.base.util.UtilXml; + +import org.ofbiz.base.util.UtilValidate; +import org.ofbiz.base.util.cache.UtilCache; +import org.ofbiz.service.DispatchContext; +import org.ofbiz.service.ServiceUtil; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +public class LabelManagerFactory { + + public static final String module = LabelManagerFactory.class.getName(); + public static final String resource = "WebtoolsUiLabels"; + + protected static UtilCache labelManagerFactoryCache = new UtilCache("LabelManagerFactory"); + + protected static Map labels = null; + protected static Map fileNamesFound = null; + protected static Map fileComponent = null; + protected static Set localesFound = null; + protected static Set componentNamesFound = null; + protected static int duplicatedLocalesLabels = 0; + + protected static String delegatorName; + + public static LabelManagerFactory getLabelManagerFactory(String delegatorName) throws GeneralException { + if (UtilValidate.isEmpty(delegatorName)) { + delegatorName = "default"; + } + + LabelManagerFactory lmf = labelManagerFactoryCache.get(delegatorName); + + if (lmf == null) { + lmf = new LabelManagerFactory(delegatorName); + labelManagerFactoryCache.put(delegatorName, lmf); + } + return lmf; + } + + protected LabelManagerFactory(String delegatorName) throws GeneralException { + LabelManagerFactory.delegatorName = delegatorName; + + prepareAll(); + } + + private static void prepareAll() throws GeneralException { + labels = new TreeMap(); + fileNamesFound = new TreeMap(); + fileComponent = new TreeMap(); + localesFound = new TreeSet(); + componentNamesFound = new TreeSet(); + int duplicatedLocales = 0; + + try { + Collection componentConfigs = ComponentConfig.getAllComponents(); + + for (ComponentConfig componentConfig: componentConfigs) { + String componentName = componentConfig.getComponentName(); + List resourceFiles = FileUtil.findXmlFiles(componentConfig.getRootLocation(), null, "resource", null); + + for (File resourceFile: resourceFiles) { + String fileName = resourceFile.getName(); + Document resourceDocument = UtilXml.readXmlDocument(resourceFile.toURI().toURL()); + Element resourceElem = resourceDocument.getDocumentElement(); + + for (Element propertyElem: UtilXml.childElementList(resourceElem, "property")) { + String labelKey = propertyElem.getAttribute("key"); + + for (Element valueElem: UtilXml.childElementList(propertyElem, "value")) { + String localeName = valueElem.getAttribute("xml:lang"); + String labelValue = UtilXml.elementValue(valueElem); + LabelInfo label = (LabelInfo)labels.get(labelKey + "_" + fileName); + + if (UtilValidate.isEmpty(label)) { + label = new LabelInfo(labelKey, fileName, componentName, localeName, labelValue); + labels.put(labelKey + "_" + fileName, label); + } else { + if (label.setLabelValue(localeName, labelValue, false)) { + duplicatedLocales++; + } + } + localesFound.add(localeName); + componentNamesFound.add(componentName); + fileNamesFound.put(fileName, resourceFile.toURI().toString()); + fileComponent.put(fileName, componentName); + } + } + } + } + } catch(IOException ioe) { + throw new GeneralException(ioe.getMessage()); + } catch(Exception e) { + throw new GeneralException(e.getMessage()); + } + duplicatedLocalesLabels = duplicatedLocales; + } + + public static Map getLabels() { + return labels; + } + + public static Set getLocalesFound() { + return localesFound; + } + + public static Map getFileNamesFound() { + return fileNamesFound; + } + + public static String getFileComponent(String fileName) { + String componentName = null; + if (UtilValidate.isNotEmpty(fileName)) { + componentName = fileComponent.get(fileName); + } + return componentName; + } + + public static Set getComponentNamesFound() { + return componentNamesFound; + } + + public static Set getLabelsList() { + return labels.keySet(); + } + + public static int getDuplicatedLocalesLabels() { + return duplicatedLocalesLabels; + } + + public static Map updateLabelKey(DispatchContext dctx, Map context) { + String key = (String)context.get("key"); + String update_label = (String)context.get("update_label"); + String fileName = (String)context.get("fileName"); + String confirm = (String)context.get("confirm"); + List localeNames = UtilGenerics.cast(context.get("localeNames")); + List localeValues = UtilGenerics.cast(context.get("localeValues")); + Locale locale = (Locale) context.get("locale"); + + if (UtilValidate.isNotEmpty(confirm)) { + LabelInfo label = labels.get(key + "_" + fileName); + + // Update a Label + if (update_label.equalsIgnoreCase("Y")) { + if (UtilValidate.isNotEmpty(label)) { + updateLabelValue(localeNames, localeValues, label, key, fileName); + } + // Insert a new Label + } else { + if (UtilValidate.isNotEmpty(label)) { + return ServiceUtil.returnError(UtilProperties.getMessage(resource, "WebtoolsLabelManagerNewLabelExisting", UtilMisc.toMap("key", key, "fileName", fileName), locale)); + } else { + if (UtilValidate.isEmpty(key)) { + return ServiceUtil.returnError(UtilProperties.getMessage(resource, "WebtoolsLabelManagerNewLabelEmptyKey", locale)); + } else { + int notEmptyLabels = updateLabelValue(localeNames, localeValues, null, key, fileName); + if (notEmptyLabels == 0) { + return ServiceUtil.returnError(UtilProperties.getMessage(resource, "WebtoolsLabelManagerNewLabelEmpty", locale)); + } + } + } + } + } + + return ServiceUtil.returnSuccess(); + } + + private static int updateLabelValue(List localeNames, List localeValues, LabelInfo label, String key, String fileName) { + int notEmptyLabels = 0; + int i = 0; + while (i < localeNames.size()) { + String localeName = (String)localeNames.get(i); + String localeValue = (String)localeValues.get(i); + + if (UtilValidate.isNotEmpty(localeValue)) { + if (label == null) { + try { + String componentName = getFileComponent(fileName); + label = new LabelInfo(key, fileName, componentName, localeName, localeValue); + labels.put(key + "_" + fileName, label); + } catch(Exception e) { + e.printStackTrace(); + } + } + label.setLabelValue(localeName, localeValue, true); + notEmptyLabels++; + } + i++; + } + + if (UtilValidate.isNotEmpty(label) && label.getLabelValueSize() == 0) { + labels.remove(key + "_" + fileName); + } + + return notEmptyLabels; + } +} diff --git a/framework/webtools/src/org/ofbiz/webtools/labelmanager/SaveLabelsToXmlFile.java b/framework/webtools/src/org/ofbiz/webtools/labelmanager/SaveLabelsToXmlFile.java new file mode 100644 index 0000000000..a12702e4b2 --- /dev/null +++ b/framework/webtools/src/org/ofbiz/webtools/labelmanager/SaveLabelsToXmlFile.java @@ -0,0 +1,113 @@ +/* +* 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. +*/ +package org.ofbiz.webtools.labelmanager; + +import java.io.File; +import java.io.FileOutputStream; +import java.net.URI; +import java.util.Locale; +import java.util.Map; +import java.util.Set; + +import org.apache.xml.serialize.OutputFormat; +import org.ofbiz.base.util.Debug; +import org.ofbiz.base.util.UtilProperties; +import org.ofbiz.base.util.UtilValidate; +import org.ofbiz.base.util.UtilXml; +import org.ofbiz.base.util.cache.UtilCache; + +import org.ofbiz.service.DispatchContext; +import org.ofbiz.service.ServiceUtil; + +import org.w3c.dom.Comment; +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +public class SaveLabelsToXmlFile { + + private static final String resource = "WebtoolsUiLabels"; + private static final String module = SaveLabelsToXmlFile.class.getName(); + + public static Map saveLabelsToXmlFile(DispatchContext dctx, Map context) { + Locale locale = (Locale)context.get("locale"); + String labelFileName = (String)context.get("labelFileName"); + + try { + LabelManagerFactory.getLabelManagerFactory(dctx.getDelegator().getDelegatorName()); + Map labels = LabelManagerFactory.getLabels(); + Map fileNamesFound = LabelManagerFactory.getFileNamesFound(); + Set labelsList = LabelManagerFactory.getLabelsList(); + Set localesFound = LabelManagerFactory.getLocalesFound(); + + for (String fileName : fileNamesFound.keySet()) { + if (UtilValidate.isNotEmpty(labelFileName) && !(labelFileName.equalsIgnoreCase(fileName))) { + continue; + } + + String uri = (String)fileNamesFound.get(fileName); + Document resourceDocument = UtilXml.makeEmptyXmlDocument("resource"); + Element resourceElem = resourceDocument.getDocumentElement(); + Comment comment = resourceDocument.createComment("A Document Comment"); + resourceElem.getParentNode().insertBefore(comment, resourceElem); + resourceElem.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"); + + for (String labelKey : labelsList) { + LabelInfo labelInfo = (LabelInfo)labels.get(labelKey); + + if (!(labelInfo.getFileName().equalsIgnoreCase(fileName))) { + continue; + } + + Element propertyElem = UtilXml.addChildElement(resourceElem, "property", resourceDocument); + propertyElem.setAttribute("key", labelInfo.getLabelKey()); + + for (String localeFound : localesFound) { + String labelValue = labelInfo.getLabelValue(localeFound); + + if (UtilValidate.isNotEmpty(labelValue)) { + Element valueElem = UtilXml.addChildElementValue(propertyElem, "value", labelValue, resourceDocument); + valueElem.setAttribute("xml:lang", localeFound); + } + } + } + +// if (resourceElem != null && uri != null) { +// File outFile = new File(new URI(uri)); +// FileOutputStream fos = new FileOutputStream(outFile); +// +// try { +// OutputFormat format = new OutputFormat(resourceDocument.getDocumentElement().getOwnerDocument(), "UTF-8", true); +// format.setIndent(4); +// format.setOmitComments(false); +// UtilXml.writeXmlDocument(fos, resourceElem, format); +// } finally { +// if (fos != null) { +// fos.close(); +// } +// } +// } + UtilCache.clearCache("properties.UtilPropertiesBundleCache"); + } + } catch (Exception e) { + Debug.logError(e, "Exception during save labels to xml file:", module); + return ServiceUtil.returnFailure(UtilProperties.getMessage(resource, "saveLabelsToXmlFile.exceptionDuringSaveLabelsToXmlFile", locale)); + } + return ServiceUtil.returnSuccess(); + } +} diff --git a/framework/webtools/webapp/webtools/WEB-INF/actions/labelmanager/LabelManager.groovy b/framework/webtools/webapp/webtools/WEB-INF/actions/labelmanager/LabelManager.groovy new file mode 100644 index 0000000000..9d5460875e --- /dev/null +++ b/framework/webtools/webapp/webtools/WEB-INF/actions/labelmanager/LabelManager.groovy @@ -0,0 +1,29 @@ +/* + * 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 org.ofbiz.entity.GenericDelegator; +import org.ofbiz.webtools.labelmanager.*; + +LabelManagerFactory.getLabelManagerFactory(delegator.getDelegatorName()); +context.labels = LabelManagerFactory.getLabels(); +context.labelsList = LabelManagerFactory.getLabelsList(); +context.localesFound = LabelManagerFactory.getLocalesFound(); +context.fileNamesFound = LabelManagerFactory.getFileNamesFound(); +context.componentNamesFound = LabelManagerFactory.getComponentNamesFound(); +context.duplicatedLocalesLabels = LabelManagerFactory.getDuplicatedLocalesLabels(); diff --git a/framework/webtools/webapp/webtools/WEB-INF/actions/labelmanager/UpdateManager.groovy b/framework/webtools/webapp/webtools/WEB-INF/actions/labelmanager/UpdateManager.groovy new file mode 100644 index 0000000000..8101186f6a --- /dev/null +++ b/framework/webtools/webapp/webtools/WEB-INF/actions/labelmanager/UpdateManager.groovy @@ -0,0 +1,31 @@ +/* + * 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 org.ofbiz.entity.GenericDelegator; +import org.ofbiz.webtools.labelmanager.*; + +LabelManagerFactory.getLabelManagerFactory(delegator.getDelegatorName()); +context.labels = LabelManagerFactory.getLabels(); +context.localesFound = LabelManagerFactory.getLocalesFound(); +context.fileNamesFound = LabelManagerFactory.getFileNamesFound(); +context.componentNamesFound = LabelManagerFactory.getComponentNamesFound(); + +if (parameters.sourceKey != null && parameters.sourceFileName != null) { + context.label = context.labels.get(parameters.sourceKey + "_" + parameters.sourceFileName); +} diff --git a/framework/webtools/webapp/webtools/WEB-INF/controller.xml b/framework/webtools/webapp/webtools/WEB-INF/controller.xml index 5e59dac59a..b937bfa6ba 100644 --- a/framework/webtools/webapp/webtools/WEB-INF/controller.xml +++ b/framework/webtools/webapp/webtools/WEB-INF/controller.xml @@ -461,7 +461,34 @@ under the License. - + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -608,6 +635,10 @@ under the License. + + + + diff --git a/framework/webtools/webapp/webtools/labelmanager/SearchLabels.ftl b/framework/webtools/webapp/webtools/labelmanager/SearchLabels.ftl new file mode 100644 index 0000000000..f2e2c02e77 --- /dev/null +++ b/framework/webtools/webapp/webtools/labelmanager/SearchLabels.ftl @@ -0,0 +1,84 @@ +<#-- +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. +--> +
+
+ + + + + + + + + + + + + + + + +
+ ${uiLabelMap.WebtoolsLabelManagerKey} + + + + ${uiLabelMap.WebtoolsLabelManagerComponentName} + + +
+ ${uiLabelMap.WebtoolsLabelManagerFileName} + + + + ${uiLabelMap.WebtoolsLabelManagerLocale} + + +
+ <#if (duplicatedLocalesLabels > 0)> +
+ ${uiLabelMap.WebtoolsLabelManagerWarningMessage} (${duplicatedLocalesLabels}) + <#else> + + +
+
+
diff --git a/framework/webtools/webapp/webtools/labelmanager/UpdateLabel.ftl b/framework/webtools/webapp/webtools/labelmanager/UpdateLabel.ftl new file mode 100644 index 0000000000..bd3524ec9e --- /dev/null +++ b/framework/webtools/webapp/webtools/labelmanager/UpdateLabel.ftl @@ -0,0 +1,97 @@ +<#-- +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. +--> +
+
+ + + + + + + + + + + + + + + + <#list localesFound as localeFound> + <#if parameters.sourceKey?exists> + <#assign labelVal = label.getLabelValue(localeFound)?if_exists> + <#else> + <#assign labelVal = ""> + + <#assign showLocale = true> + <#if parameters.labelLocaleName?exists && parameters.labelLocaleName != "" && parameters.labelLocaleName != localeFound> + <#assign showLocale = false> + + <#if showLocale == true> + + <#assign locale = Static["org.ofbiz.base.util.UtilMisc"].parseLocale(localeFound)?if_exists/> + <#if locale?exists && locale?has_content> + <#assign langAttr = localeFound.toString()?replace("_", "-")> + <#assign langDir = "ltr"> + <#if "ar.iw"?contains(langAttr?substring(0, 2))> + <#assign langDir = "rtl"> + + + <#else> + + + + + + + + + +
 
${uiLabelMap.WebtoolsLabelManagerKey} + <#if parameters.sourceKey?exists> + ${parameters.sourceKey} + + + <#else> + + + +
${uiLabelMap.WebtoolsLabelManagerFileName} + <#if parameters.sourceFileName?exists> + ${parameters.sourceFileName} + + <#else> + + +
 
+ ${locale.getDisplayName(locale)} + ${localeFound} + + +
+ + +
+
+
diff --git a/framework/webtools/webapp/webtools/labelmanager/ViewLabels.ftl b/framework/webtools/webapp/webtools/labelmanager/ViewLabels.ftl new file mode 100644 index 0000000000..2ee3f3eaeb --- /dev/null +++ b/framework/webtools/webapp/webtools/labelmanager/ViewLabels.ftl @@ -0,0 +1,94 @@ +<#-- +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. +--> +
+ <#if parameters.searchLabels?exists> + ${uiLabelMap.WebtoolsLabelManagerAddNew} + ${uiLabelMap.WebtoolsLabelManagerUpdateFile} + + + + + + <#list localesFound as localeFound> + <#assign showLocale = true> + <#if parameters.labelLocaleName?exists && parameters.labelLocaleName != "" && parameters.labelLocaleName != localeFound> + <#assign showLocale = false> + + <#if showLocale == true> + <#assign locale = Static["org.ofbiz.base.util.UtilMisc"].parseLocale(localeFound)?if_exists/> + <#if locale?exists && locale?has_content> + <#assign langAttr = localeFound.toString()?replace("_", "-")> + <#assign langDir = "ltr"> + <#if "ar.iw"?contains(langAttr?substring(0, 2))> + <#assign langDir = "rtl"> + + + <#else> + + + + + + <#if parameters.searchLabels?exists> + <#assign rowNum = "2"> + <#assign previousKey = ""> + <#list labelsList as labelList> + <#assign label = labels.get(labelList)> + <#assign showLabel = true> + <#if parameters.labelKey?exists && parameters.labelKey != "" && parameters.labelKey != label.labelKey> + <#assign showLabel = false> + + <#if showLabel && parameters.labelFileName?exists && parameters.labelFileName != "" && parameters.labelFileName != label.fileName> + <#assign showLabel = false> + + <#if showLabel && parameters.labelComponentName?exists && parameters.labelComponentName != "" && parameters.labelComponentName != label.componentName> + <#assign showLabel = false> + + <#if showLabel == true> + class="alternate-row"> + + + <#list localesFound as localeFound> + <#assign labelVal = label.getLabelValue(localeFound)?if_exists> + <#assign showLocale = true> + <#if parameters.labelLocaleName?exists && parameters.labelLocaleName != "" && parameters.labelLocaleName != localeFound> + <#assign showLocale = false> + + <#if showLocale == true> + <#if labelVal?has_content> + + <#else> + + + + + + <#if rowNum == "2"> + <#assign rowNum = "1"> + <#else> + <#assign rowNum = "2"> + + <#assign previousKey = label.labelKey> + + + +
${uiLabelMap.WebtoolsLabelManagerKey}${uiLabelMap.WebtoolsLabelManagerFileName} + ${locale.getDisplayName(locale)} + ${localeFound}
class="submenutext">${label.labelKey}${label.fileName}${labelVal} 
+
diff --git a/framework/webtools/webapp/webtools/main.ftl b/framework/webtools/webapp/webtools/main.ftl index 2a3a068ef2..9e89b202fe 100644 --- a/framework/webtools/webapp/webtools/main.ftl +++ b/framework/webtools/webapp/webtools/main.ftl @@ -70,13 +70,17 @@ text-decoration: underline; <#if security.hasPermission("ARTIFACT_INFO_VIEW", session)>
  • ${uiLabelMap.WebtoolsGeneralArtifactInfoTools}

  • ${uiLabelMap.WebtoolsArtifactInfo}
  • -
  • ${uiLabelMap.WebtoolsEntityReference} - Interactive
  • +
  • ${uiLabelMap.WebtoolsEntityReference} - ${uiLabelMap.WebtoolsEntityReferenceInteractiveVersion}
  • ${uiLabelMap.WebtoolsServiceReference}
  • + <#if security.hasPermission("LABEL_MANAGER_VIEW", session)> +
  • ${uiLabelMap.WebtoolsLabelManager}

  • +
  • ${uiLabelMap.WebtoolsLabelManager}
  • + <#if security.hasPermission("ENTITY_MAINT", session)>
  • ${uiLabelMap.WebtoolsEntityEngineTools}

  • ${uiLabelMap.WebtoolsEntityDataMaintenance}
  • -
  • ${uiLabelMap.WebtoolsEntityReference} - Interactive
  • +
  • ${uiLabelMap.WebtoolsEntityReference} - ${uiLabelMap.WebtoolsEntityReferenceInteractiveVersion}
  • ${uiLabelMap.WebtoolsEntityReference} - ${uiLabelMap.WebtoolsEntityReferenceStaticVersion}
  • ${uiLabelMap.WebtoolsEntityReferencePdf}
  • ${uiLabelMap.PageTitleEntitySQLProcessor}
  • diff --git a/framework/webtools/widget/LabelManagerScreens.xml b/framework/webtools/widget/LabelManagerScreens.xml new file mode 100644 index 0000000000..1a2d0b81ec --- /dev/null +++ b/framework/webtools/widget/LabelManagerScreens.xml @@ -0,0 +1,72 @@ + + + + + +
    + + + + + +