diff --git a/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachmentConfig.java b/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachmentConfig.java index d6b29029c..12f264029 100755 --- a/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachmentConfig.java +++ b/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachmentConfig.java @@ -12,14 +12,20 @@ import org.apache.log4j.Logger; public class FileAttachmentConfig extends AbstractConfig { - /** A logger instance to assist debugging. */ - private static final Logger s_log = Logger.getLogger(FileAttachmentConfig.class); - /** Singelton config object. */ + /** + * A logger instance to assist debugging. + */ + private static final Logger s_log = Logger.getLogger( + FileAttachmentConfig.class); + /** + * Singelton config object. + */ private static FileAttachmentConfig s_conf; /** * Singleton pattern, don't instantiate a config object using the * constructor directly! + * * @return */ public static synchronized FileAttachmentConfig instanceOf() { @@ -35,41 +41,46 @@ public class FileAttachmentConfig extends AbstractConfig { // // set of configuration parameters /** - * A form which should be used for editing file asset properties. - * Default implementation edits Assets.description property. + * A form which should be used for editing file asset properties. Default + * implementation edits Assets.description property. */ - private final Parameter editFormClass = - new SpecificClassParameter( - "com.arsdigita.cms.contentassets.file_edit_form", - Parameter.REQUIRED, - FileDescriptionForm.class, - FormSection.class); + private final Parameter editFormClass = new SpecificClassParameter( + "com.arsdigita.cms.contentassets.file_edit_form", + Parameter.REQUIRED, + FileDescriptionForm.class, + FormSection.class); + /** * Optional parameter if set to TRUE will disply the asset URL instead of * the description on AttachFile Authroing step. Default: FALSE */ - private final Parameter showAssetID = - new BooleanParameter( - "com.arsdigita.cms.contentassets.file_show_asset_id", - Parameter.OPTIONAL, - Boolean.FALSE); - private final Parameter fileAttachmentStepSortKey = - new IntegerParameter( - "com.arsdigita.cms.contentassets.file_attchment_step_sort_key", - Parameter.REQUIRED, - 2); + private final Parameter showAssetID = new BooleanParameter( + "com.arsdigita.cms.contentassets.file_show_asset_id", + Parameter.OPTIONAL, + Boolean.FALSE); + private final Parameter fileAttachmentStepSortKey = new IntegerParameter( + "com.arsdigita.cms.contentassets.file_attchment_step_sort_key", + Parameter.REQUIRED, + 2); + + private final Parameter fileAttachmentDescriptionMaxLength + = new IntegerParameter( + "com.arsdigita.cms.contentassets.file_attachment_description_max_length", + Parameter.REQUIRED, 400); + /** * Constructor, don't use it directly! */ public FileAttachmentConfig() { super(); - + register(editFormClass); register(showAssetID); register(fileAttachmentStepSortKey); - + register(fileAttachmentDescriptionMaxLength); + loadInfo(); } @@ -80,9 +91,14 @@ public class FileAttachmentConfig extends AbstractConfig { public boolean isShowAssetIDEnabled() { return get(showAssetID).equals(Boolean.TRUE); } - + public Integer getFileAttachmentStepSortKey() { return (Integer) get(fileAttachmentStepSortKey); } + + public Integer getFileAttachmentDescriptionMaxLength() { + return (Integer) get(fileAttachmentDescriptionMaxLength); + } + } diff --git a/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachmentConfig_parameter.properties b/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachmentConfig_parameter.properties index a3980fd85..8ab69999d 100755 --- a/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachmentConfig_parameter.properties +++ b/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachmentConfig_parameter.properties @@ -11,4 +11,9 @@ com.arsdigita.cms.contentassets.file_show_asset_id.format=[boolean] com.arsdigita.cms.contentassets.file_attchment_step_sort_key.title = Sort key for the file attachment step com.arsdigita.cms.contentassets.file_attchment_step_sort_key.purpose = Sort key for the file attachment step com.arsdigita.cms.contentassets.file_attchment_step_sort_key.example = 2 -com.arsdigita.cms.contentassets.file_attchment_step_sort_key.format = [Integer] \ No newline at end of file +com.arsdigita.cms.contentassets.file_attchment_step_sort_key.format = [Integer] + +com.arsdigita.cms.contentassets.file_attachment_description_max_length.title = Maximum length for the description of a file attachments +com.arsdigita.cms.contentassets.file_attachment_description_max_length.purpose = Maximum length for the description of a file attachments +com.arsdigita.cms.contentassets.file_attachment_description_max_length.example = 400 +com.arsdigita.cms.contentassets.file_attachment_description_max_length.format = [Integer] diff --git a/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachmentGlobalize.java b/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachmentGlobalize.java index 48d081b16..cf8941722 100644 --- a/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachmentGlobalize.java +++ b/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachmentGlobalize.java @@ -12,9 +12,9 @@ * rights and limitations under the License. * */ - package com.arsdigita.cms.contentassets; +import com.arsdigita.cms.contentassets.util.FileAttachmentGlobalizationUtil; import com.arsdigita.globalization.GlobalizedMessage; /** @@ -26,7 +26,6 @@ import com.arsdigita.globalization.GlobalizedMessage; */ public class FileAttachmentGlobalize { - /** * The label for the authoring step */ @@ -72,6 +71,10 @@ public class FileAttachmentGlobalize { "com.arsdigita.cms.contentassets.FileAttachmentResources"); } - - + public static GlobalizedMessage DescriptionTooLong(final Integer limit) { + return FileAttachmentGlobalizationUtil.globalize( + "cms.contentassets.file_attachment.description.too_long", + new Object[]{limit}); + } + } diff --git a/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachmentResources.properties b/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachmentResources.properties index b1a95aec0..5904cc1a4 100755 --- a/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachmentResources.properties +++ b/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachmentResources.properties @@ -18,3 +18,5 @@ cms.contentassets.file_attachment.table_edit=edit cms.contentassets.file_attachment.table_up=up cms.contentassets.file_attachment.table_down=down cms.contentassets.file_attachment.table_delete=delete +cms.contentassets.file_attachment.description.too_long=The description execceds the limit of {0} characters. +cms.contentassets.file_attachment.caption.too_long=The caption execceds the limit of {0} characters. diff --git a/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachmentResources_de.properties b/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachmentResources_de.properties index 9633be664..a2df1f9a4 100644 --- a/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachmentResources_de.properties +++ b/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachmentResources_de.properties @@ -17,3 +17,5 @@ cms.contentassets.file_attachment.table_edit=bearbeiten cms.contentassets.file_attachment.table_up=nach oben cms.contentassets.file_attachment.table_down=nach unten cms.contentassets.file_attachment.table_delete=l\u00f6schen +cms.contentassets.file_attachment.description.too_long=Die Beschreibung ist l\u00e4nger als {0} Zeichen. +cms.contentassets.file_attachment.caption.too_long=Die Zwischen\u00fcberschrift ist l\u00e4nger als {0} Zeichen. diff --git a/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/ui/FileAttachmentCaptionForm.java b/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/ui/FileAttachmentCaptionForm.java index d3d408d5e..61774486f 100644 --- a/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/ui/FileAttachmentCaptionForm.java +++ b/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/ui/FileAttachmentCaptionForm.java @@ -25,18 +25,18 @@ import com.arsdigita.bebop.event.FormInitListener; import com.arsdigita.bebop.event.FormProcessListener; import com.arsdigita.bebop.event.FormSectionEvent; import com.arsdigita.bebop.event.FormValidationListener; -import com.arsdigita.bebop.form.CheckboxGroup; -import com.arsdigita.bebop.form.DHTMLEditor; -import com.arsdigita.bebop.form.Option; -import com.arsdigita.bebop.form.RadioGroup; import com.arsdigita.bebop.form.TextArea; import com.arsdigita.bebop.parameters.NotNullValidationListener; +import com.arsdigita.bebop.parameters.StringInRangeValidationListener; import com.arsdigita.cms.ContentItem; import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.contentassets.FileAttachment; +import com.arsdigita.cms.contentassets.FileAttachmentConfig; +import com.arsdigita.cms.contentassets.FileAttachmentGlobalize; import com.arsdigita.cms.contentassets.util.FileAttachmentGlobalizationUtil; import com.arsdigita.cms.ui.FileUploadSection; import com.arsdigita.dispatcher.DispatcherHelper; + import java.io.IOException; import org.apache.log4j.Logger; @@ -55,6 +55,8 @@ public class FileAttachmentCaptionForm extends Form private ItemSelectionModel m_itemModel; private SaveCancelSection m_saveCancelSection; private TextArea m_captionText; + private static final FileAttachmentConfig s_config = FileAttachmentConfig + .instanceOf(); /** * Construct a new FileCaptionForm @@ -131,6 +133,10 @@ public class FileAttachmentCaptionForm extends Form m_captionText.setCols(10); m_captionText.setRows(1); m_captionText.addValidationListener(new NotNullValidationListener()); + m_captionText.addValidationListener(new StringInRangeValidationListener( + 0, + s_config.getFileAttachmentDescriptionMaxLength(), + FileAttachmentGlobalize.DescriptionTooLong(s_config.getFileAttachmentDescriptionMaxLength()))); m_captionText.lock(); add(new Label(FileAttachmentGlobalizationUtil.globalize( "cms.contentassets.file_attachment.caption"))); diff --git a/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/ui/FileAttachmentUpload.java b/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/ui/FileAttachmentUpload.java index 3772e5a22..ca0092c42 100755 --- a/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/ui/FileAttachmentUpload.java +++ b/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/ui/FileAttachmentUpload.java @@ -27,9 +27,11 @@ import com.arsdigita.bebop.event.FormSectionEvent; import com.arsdigita.bebop.event.FormValidationListener; import com.arsdigita.bebop.form.TextArea; import com.arsdigita.bebop.parameters.NotNullValidationListener; +import com.arsdigita.bebop.parameters.StringInRangeValidationListener; import com.arsdigita.cms.ContentItem; import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.contentassets.FileAttachment; +import com.arsdigita.cms.contentassets.FileAttachmentConfig; import com.arsdigita.cms.contentassets.FileAttachmentGlobalize; import com.arsdigita.cms.contentassets.util.FileAttachmentGlobalizationUtil; import com.arsdigita.cms.ui.FileUploadSection; @@ -52,21 +54,24 @@ import org.apache.log4j.Logger; * @version $Id: FileAttachmentUpload.java 287 2005-02-22 00:29:02Z sskracic $ */ public class FileAttachmentUpload extends Form - implements FormInitListener, FormProcessListener, FormValidationListener { + implements FormInitListener, FormProcessListener, FormValidationListener { - private static final Logger s_log = Logger.getLogger(FileAttachmentUpload.class); + private static final Logger s_log = Logger.getLogger( + FileAttachmentUpload.class); private FileUploadSection m_fileUploadSection; private TextArea m_description; private ItemSelectionModel m_itemModel; private SaveCancelSection m_saveCancelSection; private TextArea m_captionText; + private static final FileAttachmentConfig s_config = FileAttachmentConfig + .instanceOf(); /** * Construct a new FileAttachmentUpload * * @param itemModel The {@link ItemSelectionModel} which will be responsible - * for loading the current item + * for loading the current item * */ public FileAttachmentUpload(ItemSelectionModel itemModel) { @@ -131,17 +136,24 @@ public class FileAttachmentUpload extends Form // Add the widgets public void addWidgets() { - m_fileUploadSection = new FileUploadSection(FileAttachmentGlobalize.FileTypeLabel(), - "file", - ImageMimeType.MIME_IMAGE_JPEG); + m_fileUploadSection = new FileUploadSection(FileAttachmentGlobalize + .FileTypeLabel(), + "file", + ImageMimeType.MIME_IMAGE_JPEG); m_fileUploadSection.getFileUploadWidget() - .addValidationListener(new NotNullValidationListener()); + .addValidationListener(new NotNullValidationListener()); add(m_fileUploadSection, ColumnPanel.INSERT); m_description = new TextArea("description"); m_description.setRows(5); m_description.setCols(60); - add(new Label(GlobalizationUtil.globalize("cms.contentassets.ui.description"))); + m_description.addValidationListener(new StringInRangeValidationListener( + 0, + s_config.getFileAttachmentDescriptionMaxLength(), + FileAttachmentGlobalize.DescriptionTooLong(s_config + .getFileAttachmentDescriptionMaxLength()))); + add(new Label(GlobalizationUtil.globalize( + "cms.contentassets.ui.description"))); m_description.lock(); add(m_description); } @@ -157,18 +169,21 @@ public class FileAttachmentUpload extends Form } @Override - public void validate(final FormSectionEvent event) throws FormProcessException { + public void validate(final FormSectionEvent event) throws + FormProcessException { final PageState state = event.getPageState(); final ContentItem item = getContentItem(state); final String fileName = m_fileUploadSection.getFileName(event); final DataCollection attachments = FileAttachment.getAttachments(item); - + while (attachments.next()) { final DataObject attachment = attachments.getDataObject(); if (attachment.get(FileAttachment.NAME).equals(fileName)) { attachments.close(); - throw new FormProcessException(FileAttachmentGlobalizationUtil.globalize( - "cms.contentassets.file_attachment.already_attached", new String[]{fileName})); + throw new FormProcessException(FileAttachmentGlobalizationUtil + .globalize( + "cms.contentassets.file_attachment.already_attached", + new String[]{fileName})); } } attachments.close(); @@ -177,21 +192,22 @@ public class FileAttachmentUpload extends Form // process: update the mime type and content @Override - public void process(final FormSectionEvent event) throws FormProcessException { + public void process(final FormSectionEvent event) throws + FormProcessException { s_log.debug("Uploading File"); final PageState state = event.getPageState(); final ContentItem item = getContentItem(state); // Get the text asset or create a new one final FileAttachment attachment = new FileAttachment(); - final File file = m_fileUploadSection.getFile(event); - final String fileName = m_fileUploadSection.getFileName(event); + final File file = m_fileUploadSection.getFile(event); + final String fileName = m_fileUploadSection.getFileName(event); - try { - attachment.loadFromFile(fileName, file, "application/octet-stream"); - } catch (IOException ex) { - throw new FormProcessException(ex); - } + try { + attachment.loadFromFile(fileName, file, "application/octet-stream"); + } catch (IOException ex) { + throw new FormProcessException(ex); + } attachment.setDescription((String) m_description.getValue(state)); attachment.setFileOwner(item); attachment.save(); diff --git a/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/ui/FileDescriptionForm.java b/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/ui/FileDescriptionForm.java index 0a187f272..993376389 100755 --- a/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/ui/FileDescriptionForm.java +++ b/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/ui/FileDescriptionForm.java @@ -28,7 +28,10 @@ import com.arsdigita.bebop.event.FormSubmissionListener; import com.arsdigita.bebop.event.FormValidationListener; import com.arsdigita.bebop.form.Submit; import com.arsdigita.bebop.form.TextArea; +import com.arsdigita.bebop.parameters.StringInRangeValidationListener; import com.arsdigita.cms.contentassets.FileAttachment; +import com.arsdigita.cms.contentassets.FileAttachmentConfig; +import com.arsdigita.cms.contentassets.FileAttachmentGlobalize; import com.arsdigita.cms.contentassets.util.FileAttachmentGlobalizationUtil; /** @@ -40,6 +43,9 @@ public class FileDescriptionForm extends FormSection implements FormInitListener, FormProcessListener, FormValidationListener, FormSubmissionListener { + private static final FileAttachmentConfig s_config = FileAttachmentConfig + .instanceOf(); + private TextArea m_description; private FileAttachmentSelectionModel m_fileModel; @@ -76,6 +82,10 @@ public class FileDescriptionForm extends FormSection implements m_description = new TextArea("description"); m_description.setCols(40); m_description.setRows(5); + m_description.addValidationListener(new StringInRangeValidationListener( + 0, + s_config.getFileAttachmentDescriptionMaxLength(), + FileAttachmentGlobalize.DescriptionTooLong(s_config.getFileAttachmentDescriptionMaxLength()))); add(new Label(FileAttachmentGlobalizationUtil .globalize("cms.contentassets.file_attachment.caption_or_description"))); diff --git a/ccm-core/web/themes/foundry/foundry/lib/template-parser.xsl b/ccm-core/web/themes/foundry/foundry/lib/template-parser.xsl index d235e7e1b..58a08b47c 100644 --- a/ccm-core/web/themes/foundry/foundry/lib/template-parser.xsl +++ b/ccm-core/web/themes/foundry/foundry/lib/template-parser.xsl @@ -683,19 +683,19 @@ - + - + - + @@ -733,7 +733,7 @@ - + + + - + diff --git a/ccm-sci-bundle/web/templates/ccm-navigation/navigation/sci-welcome.jsp b/ccm-sci-bundle/web/templates/ccm-navigation/navigation/sci-welcome.jsp index 70ef190e5..4171db1ca 100644 --- a/ccm-sci-bundle/web/templates/ccm-navigation/navigation/sci-welcome.jsp +++ b/ccm-sci-bundle/web/templates/ccm-navigation/navigation/sci-welcome.jsp @@ -21,8 +21,10 @@ } - + @@ -33,6 +35,8 @@ + defaultItemPage.setClassAttr("welcomePage"); + ((com.arsdigita.navigation.ui.object.SimpleObjectList) itemList).setDefinition(new CMSDataCollectionDefinition()); ((com.arsdigita.navigation.ui.object.SimpleObjectList) itemList).setRenderer(new CMSDataCollectionRenderer()); ((com.arsdigita.navigation.ui.object.SimpleObjectList) itemList).getDefinition().setObjectType("com.arsdigita.cms.ContentPage");