diff --git a/ccm-cms-types-xmlfeed/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/XMLFeed.xml b/ccm-cms-types-xmlfeed/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/XMLFeed.xml index fae4f8a3a..24195bd44 100755 --- a/ccm-cms-types-xmlfeed/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/XMLFeed.xml +++ b/ccm-cms-types-xmlfeed/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/XMLFeed.xml @@ -1,21 +1,45 @@ - + + - - - - + + + + + + + + + + + diff --git a/ccm-cms-types-xmlfeed/src/com/arsdigita/cms/contenttypes/xmlfeed/XMLFeedResources.properties b/ccm-cms-types-xmlfeed/src/com/arsdigita/cms/contenttypes/xmlfeed/XMLFeedResources.properties new file mode 100755 index 000000000..6133e7851 --- /dev/null +++ b/ccm-cms-types-xmlfeed/src/com/arsdigita/cms/contenttypes/xmlfeed/XMLFeedResources.properties @@ -0,0 +1,13 @@ +cms.contenttypes.ui.xmlfeed.xsl_file_upload=Upload the XSL file +cms.contenttypes.ui.xmlfeed.xsl_file=XSL File +#URL: +cms.contenttypes.ui.xmlfeed.feed_url=Feed URL: +cms.contenttypes.ui.xmlfeed.url=URL: +cms.contenttypes.ui.xmlfeed.feed_url_hint=Enter the URL of the feed, eg http://freesoftware.org/xml/education.php +cms.contenttypes.ui.xmlfeed.xsl_file_type=File Type +xmlfeed.authoring.styling_step.title=Edit Styling +xmlfeed.authoring.styling_step.description=Upload the XSL file that transforms the XML feed into bebop XML or HTML. +xmlfeed.authoring.query_form_step.title=Edit Query Form +xmlfeed.authoring.query_form.description=The form that supplies the query fields. +cms.contenttypes.ui.xmlfeed.xsl_file_type_error=File is not the correct type. +cms.contenttypes.ui.xmlfeed.xsl_file_validation_error=Cannot verify the file is valid, please try again. diff --git a/ccm-cms-types-xmlfeed/src/com/arsdigita/cms/contenttypes/xmlfeed/XMLFeedResources_de.properties b/ccm-cms-types-xmlfeed/src/com/arsdigita/cms/contenttypes/xmlfeed/XMLFeedResources_de.properties new file mode 100644 index 000000000..58f8c15bb --- /dev/null +++ b/ccm-cms-types-xmlfeed/src/com/arsdigita/cms/contenttypes/xmlfeed/XMLFeedResources_de.properties @@ -0,0 +1,13 @@ +cms.contenttypes.ui.xmlfeed.xsl_file_upload=XSL Datei hochladen +cms.contenttypes.ui.xmlfeed.xsl_file=XSL Datei +#URL: +cms.contenttypes.ui.xmlfeed.feed_url=Feed URL: +cms.contenttypes.ui.xmlfeed.url=URL: +cms.contenttypes.ui.xmlfeed.feed_url_hint=Geben Sie die URL des Feed, z.B. http://freesoftware.org/xml/education.php +cms.contenttypes.ui.xmlfeed.xsl_file_type=Datei Typ +xmlfeed.authoring.styling_step.title=Design bearbeiten +xmlfeed.authoring.styling_step.description=XSL Datei hochladen, die den XML Feed in Bebop xml oder HTML transformiert. +xmlfeed.authoring.query_form_step.title=Abfrageformular bearbeiten +xmlfeed.authoring.query_form.description=Das Formular, das die Eingabefelder f\u00fcr die Abfrage enth\u00e4lt. +cms.contenttypes.ui.xmlfeed.xsl_file_type_error=Der Dateityp ist falsch. +cms.contenttypes.ui.xmlfeed.xsl_file_validation_error=Dateityp kann nicht best\u00e4tigt werden, bitte erneut probieren. diff --git a/ccm-cms-types-xmlfeed/src/com/arsdigita/cms/contenttypes/xmlfeed/listener/RetrieveListener.java b/ccm-cms-types-xmlfeed/src/com/arsdigita/cms/contenttypes/xmlfeed/listener/RetrieveListener.java index 6f6f85c98..6385ec3c8 100755 --- a/ccm-cms-types-xmlfeed/src/com/arsdigita/cms/contenttypes/xmlfeed/listener/RetrieveListener.java +++ b/ccm-cms-types-xmlfeed/src/com/arsdigita/cms/contenttypes/xmlfeed/listener/RetrieveListener.java @@ -131,7 +131,7 @@ public class RetrieveListener implements FormProcessListener{ String value = (String) data.get(field); if (s_log.isDebugEnabled()) { - s_log.debug("Addng parameter " + field + " -> " + value); + s_log.debug("Adding parameter " + field + " -> " + value); } params.setParameter(field.trim(), value.trim()); } diff --git a/ccm-cms-types-xmlfeed/src/com/arsdigita/cms/contenttypes/xmlfeed/ui/XMLFeedProperties.java b/ccm-cms-types-xmlfeed/src/com/arsdigita/cms/contenttypes/xmlfeed/ui/XMLFeedProperties.java index d9f728809..7e59eed98 100755 --- a/ccm-cms-types-xmlfeed/src/com/arsdigita/cms/contenttypes/xmlfeed/ui/XMLFeedProperties.java +++ b/ccm-cms-types-xmlfeed/src/com/arsdigita/cms/contenttypes/xmlfeed/ui/XMLFeedProperties.java @@ -30,6 +30,7 @@ import com.arsdigita.cms.ui.authoring.AuthoringKitWizard; import com.arsdigita.cms.ui.authoring.BasicPageForm; import com.arsdigita.cms.ui.formbuilder.FormProperties; import com.arsdigita.cms.contenttypes.xmlfeed.XMLFeed; +import com.arsdigita.cms.contenttypes.xmlfeed.util.XMLFeedGlobalizationUtil; public class XMLFeedProperties extends FormProperties { @@ -62,10 +63,11 @@ public class XMLFeedProperties extends FormProperties { super.addWidgets(); m_url = new TextField(new StringParameter("url")); - m_url.setHint("Enter the URL of the feed, " + - "eg http://upmystreet.co.uk/xml/education.php3"); + m_url.setHint(XMLFeedGlobalizationUtil.globalize( + "cms.contenttypes.ui.xmlfeed.feed_url_hint")); m_url.setSize(50); - add(new Label("Feed URL:")); + add(new Label(XMLFeedGlobalizationUtil.globalize( + "cms.contenttypes.ui.xmlfeed.feed_url")) ); add(m_url); } @@ -91,7 +93,9 @@ public class XMLFeedProperties extends FormProperties { public XMLFeedPropertySheet(ItemSelectionModel model) { super(model); - add("URL:", XMLFeed.URL); + add(XMLFeedGlobalizationUtil.globalize( + "cms.contenttypes.ui.xmlfeed.url"), + XMLFeed.URL); } } diff --git a/ccm-cms-types-xmlfeed/src/com/arsdigita/cms/contenttypes/xmlfeed/ui/XSLFileProperties.java b/ccm-cms-types-xmlfeed/src/com/arsdigita/cms/contenttypes/xmlfeed/ui/XSLFileProperties.java index cfbdaaf9b..4548e6a0c 100755 --- a/ccm-cms-types-xmlfeed/src/com/arsdigita/cms/contenttypes/xmlfeed/ui/XSLFileProperties.java +++ b/ccm-cms-types-xmlfeed/src/com/arsdigita/cms/contenttypes/xmlfeed/ui/XSLFileProperties.java @@ -17,7 +17,6 @@ package com.arsdigita.cms.contenttypes.xmlfeed.ui; -import com.arsdigita.cms.contenttypes.xmlfeed.XMLFeed; import com.arsdigita.bebop.ColumnPanel; import com.arsdigita.bebop.Form; @@ -26,43 +25,32 @@ import com.arsdigita.bebop.FormProcessException; import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.Resettable; import com.arsdigita.bebop.SaveCancelSection; - import com.arsdigita.bebop.event.FormProcessListener; import com.arsdigita.bebop.event.FormSectionEvent; import com.arsdigita.bebop.event.FormValidationListener; - import com.arsdigita.bebop.form.FormErrorDisplay; import com.arsdigita.bebop.form.Option; import com.arsdigita.bebop.form.SingleSelect; - import com.arsdigita.bebop.parameters.NotNullValidationListener; - import com.arsdigita.cms.FileAsset; import com.arsdigita.cms.ItemSelectionModel; -import com.arsdigita.mimetypes.MimeType; - +import com.arsdigita.cms.contenttypes.xmlfeed.XMLFeed; +import com.arsdigita.cms.contenttypes.xmlfeed.util.XMLFeedGlobalizationUtil; import com.arsdigita.cms.ui.FileUploadSection; import com.arsdigita.cms.ui.SecurityPropertyEditor; - import com.arsdigita.cms.ui.authoring.AuthoringKitWizard; import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess; - -import com.arsdigita.toolbox.ui.DomainObjectPropertySheet; - +import com.arsdigita.mimetypes.MimeType; import com.arsdigita.templating.XSLTemplate; import com.arsdigita.templating.Templating; - +import com.arsdigita.toolbox.ui.DomainObjectPropertySheet; import com.arsdigita.util.UncheckedWrapperException; - import java.io.File; import java.io.IOException; - - import java.net.URL; import java.net.MalformedURLException; - import org.apache.log4j.Logger; @@ -78,13 +66,13 @@ import org.apache.log4j.Logger; * {@link com.arsdigita.aplaws.xmlfeed.XmlFeedInitializer XmlFeedInitializer} *

* + * @see com.arsdigita.aplaws.xmlfeed.XmlFeedInitializer + * * @author Miles Barr * @version $Id: XSLFileProperties.java 755 2005-09-02 13:42:47Z sskracic $ - * - * @see com.arsdigita.aplaws.xmlfeed.XmlFeedInitializer */ public final class XSLFileProperties extends SecurityPropertyEditor - implements Resettable { + implements Resettable { /** The logger object for this class. */ private static Logger s_log = Logger.getLogger(XSLFileProperties.class); @@ -114,14 +102,18 @@ public final class XSLFileProperties extends SecurityPropertyEditor // Set up the form that actually allows the uploading of the XSL XSLFilePropertiesForm form = new XSLFilePropertiesForm(itemModel); - add(FILE_UPLOAD, "Upload the XSL file", + add(FILE_UPLOAD, + XMLFeedGlobalizationUtil.globalize( + "cms.contenttypes.ui.xmlfeed.xsl_file_upload"), new WorkflowLockedComponentAccess(form, itemModel), form.getSaveCancelSection().getCancelButton()); // Specify full path to properties of the XSL file. DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(itemModel); - sheet.add("XSL File", XMLFeed.XSL_FILE + ".name"); + sheet.add(XMLFeedGlobalizationUtil.globalize( + "cms.contenttypes.ui.xmlfeed.xsl_file"), + XMLFeed.XSL_FILE + ".name"); setDisplayComponent(sheet); @@ -200,7 +192,11 @@ public final class XSLFileProperties extends SecurityPropertyEditor // Set up the file upload widget. m_fileUploadSection = - new FileUploadSection("File Type","application", MIME_TYPE); + new FileUploadSection( + XMLFeedGlobalizationUtil.globalize( + "cms.contenttypes.ui.xmlfeed.xsl_file_type"), + "application", + MIME_TYPE); m_fileUploadSection.getFileUploadWidget() .addValidationListener(new NotNullValidationListener()); @@ -297,6 +293,7 @@ public final class XSLFileProperties extends SecurityPropertyEditor * the form of a standard url. */ public void validate(FormSectionEvent e) throws FormProcessException { + FormData data = e.getFormData(); // Verify the file is an XML document. @@ -306,7 +303,10 @@ public final class XSLFileProperties extends SecurityPropertyEditor XSLTemplate xsl = Templating.getTemplate(url); } catch (UncheckedWrapperException ex) { s_log.error("cannot instantiate XSL file", ex); - data.addError("Cannot verify the file is valid, please try again."); + data.addError(XMLFeedGlobalizationUtil.globalize( + "cms.contenttypes.ui.xmlfeed.xsl_file_validation_error") + // "Cannot verify the file is valid, please try again." + ); } catch (MalformedURLException ex) { throw new UncheckedWrapperException("bad filename " + file, ex); } @@ -319,7 +319,10 @@ public final class XSLFileProperties extends SecurityPropertyEditor boolean isCorrectType = MIME_TYPE.equals(mime.getPrefix()); if (!isCorrectType) { - data.addError("File is not the correct type."); + data.addError(XMLFeedGlobalizationUtil.globalize( + "cms.contenttypes.ui.xmlfeed.xsl_file_type_error") ); + // "File is not the correct type."); + } } } diff --git a/ccm-cms-types-xmlfeed/src/com/arsdigita/cms/contenttypes/xmlfeed/util/XMLFeedGlobalizationUtil.java b/ccm-cms-types-xmlfeed/src/com/arsdigita/cms/contenttypes/xmlfeed/util/XMLFeedGlobalizationUtil.java new file mode 100644 index 000000000..35e40e63a --- /dev/null +++ b/ccm-cms-types-xmlfeed/src/com/arsdigita/cms/contenttypes/xmlfeed/util/XMLFeedGlobalizationUtil.java @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2013 Peter Boy, University of Bremen. All Rights Reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +package com.arsdigita.cms.contenttypes.xmlfeed.util; + +import com.arsdigita.globalization.Globalized; +import com.arsdigita.globalization.GlobalizedMessage; + +/** + * Compilation of methods to simplify the handling of globalizing keys. + * Basically it adds the name of package's resource bundle files to the + * globalize methods and forwards to GlobalizedMessage, shortening the + * method invocation in the various application classes. + * + * @author pb + */ +public class XMLFeedGlobalizationUtil { + + /** Name of Java resource files to handle XMLFeed's globalisation. */ + final public static String BUNDLE_NAME = + "com.arsdigita.cms.contenttypes.xmlfeed.XMLFeedResources"; + + /** Name of Java resource files to handle CMS globalisation. */ + final public static String ALTERNATE_BUNDLE_NAME = + "com.arsdigita.cms.CMSResources"; + + /** + * Returns a globalized message using the appropriate bundle. + * If the key string contains the modules name xmlfeed the package specific + * bundle is used, otherwise the CMS ResourceBundle. + */ + public static GlobalizedMessage globalize(String key) { + if (key.indexOf(".xmlfeed.") > 0) { + return new GlobalizedMessage(key, BUNDLE_NAME); + } else { + return new GlobalizedMessage(key, ALTERNATE_BUNDLE_NAME); + } + } + + /** + * Returns a globalized message object, using the approprate bundle, + * takeing in an Object[] of arguments to interpolate into the retrieved + * message using the MessageFormat class. + * If the key string contains the modules name xmlfeed the package specific + * bundle is used, otherwise the CMS ResourceBundle. + */ + public static GlobalizedMessage globalize(String key, Object[] args) { + if (key.indexOf(".xmlfeed.") > 0) { + return new GlobalizedMessage(key, BUNDLE_NAME, args); + } else { + return new GlobalizedMessage(key, ALTERNATE_BUNDLE_NAME, args); + } + } + +} diff --git a/ccm-cms/src/com/arsdigita/cms/ui/FileUploadSection.java b/ccm-cms/src/com/arsdigita/cms/ui/FileUploadSection.java index 42478c5d7..953ce84c4 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/FileUploadSection.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/FileUploadSection.java @@ -189,7 +189,10 @@ public class FileUploadSection extends FormSection { add(new Label(mimeLabel, false)); m_mimeWidget = new SingleSelect(getMimeTypeWidgetName()); addMimeOptions(m_mimeWidget, mimePrefix); - m_mimeWidget.addOption(new Option(GUESS_MIME, new Label(GlobalizationUtil.globalize("cms.ui.authoring.file_upload.auto_detect")))); + m_mimeWidget.addOption(new + Option(GUESS_MIME, + new Label(GlobalizationUtil.globalize( + "cms.ui.authoring.file_upload.auto_detect")))); m_mimeWidget.setDefaultValue(GUESS_MIME); add(m_mimeWidget); @@ -270,8 +273,8 @@ public class FileUploadSection extends FormSection { * @param mimeLabel The label for the mime type widget * * @param mimePrefix Populate the mime type widget with all - * mime types that match the prefix. Some of the possible - * prefixes are "text", "image", "binary", etc. + * mime types that match the prefix. Some of the possible + * prefixes are "text", "image", "binary", etc. * * @param defaultMimeType The default mime type that should be * assumed if the guessing fails @@ -301,7 +304,8 @@ public class FileUploadSection extends FormSection { * assumed if the guessing fails * */ - public FileUploadSection(GlobalizedMessage mimeLabel, String mimePrefix, + public FileUploadSection(GlobalizedMessage mimeLabel, + String mimePrefix, String defaultMimeType) { this(mimeLabel, mimePrefix, defaultMimeType, ""); } diff --git a/ccm-core/src/com/arsdigita/bebop/FormData.java b/ccm-core/src/com/arsdigita/bebop/FormData.java index d7a9a7f24..2b4e2fb56 100755 --- a/ccm-core/src/com/arsdigita/bebop/FormData.java +++ b/ccm-core/src/com/arsdigita/bebop/FormData.java @@ -317,6 +317,7 @@ public class FormData implements Map, Cloneable { * * @param message a String of the error message * @pre message != null + * @deprecated refactor and use addError(GlobalizedMessage) instead */ public void addError(String message) { addError(new GlobalizedMessage(message)); diff --git a/ccm-core/src/com/arsdigita/bebop/form/Widget.java b/ccm-core/src/com/arsdigita/bebop/form/Widget.java index 5cbb659a3..b3b1d2bc7 100755 --- a/ccm-core/src/com/arsdigita/bebop/form/Widget.java +++ b/ccm-core/src/com/arsdigita/bebop/form/Widget.java @@ -376,10 +376,20 @@ public abstract class Widget extends BlockStylable implements Cloneable, /** * Sets a popup hint for the widget. + * @deprecated refactor to use a GlobalizedMessage instead and use + * setHint(GlobalizedMessage hint) */ public void setHint(String hint) { Assert.isUnlocked(this); - setAttribute("title", hint); + setAttribute("hint", hint); + } + + /** + * Sets a popup hint for the widget. + */ + public void setHint(GlobalizedMessage hint) { + Assert.isUnlocked(this); + setAttribute("hint", (String)hint.localize() ); }