Various things:

* Limited length of the description of file attachments (can be configured, default: 400 characters)
* Some code beautifing in Foundry
* Change the class attribute of sci-welcome.jsp to welcome-page so that is possible to distiguish between welcome page and other navigation pages in the theme.


git-svn-id: https://svn.libreccm.org/ccm/trunk@3433 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2015-05-27 12:01:28 +00:00
parent 1686144c79
commit 87d96404d4
11 changed files with 128 additions and 64 deletions

View File

@ -12,14 +12,20 @@ import org.apache.log4j.Logger;
public class FileAttachmentConfig extends AbstractConfig { public class FileAttachmentConfig extends AbstractConfig {
/** A logger instance to assist debugging. */ /**
private static final Logger s_log = Logger.getLogger(FileAttachmentConfig.class); * A logger instance to assist debugging.
/** Singelton config object. */ */
private static final Logger s_log = Logger.getLogger(
FileAttachmentConfig.class);
/**
* Singelton config object.
*/
private static FileAttachmentConfig s_conf; private static FileAttachmentConfig s_conf;
/** /**
* Singleton pattern, don't instantiate a config object using the * Singleton pattern, don't instantiate a config object using the
* constructor directly! * constructor directly!
*
* @return * @return
*/ */
public static synchronized FileAttachmentConfig instanceOf() { public static synchronized FileAttachmentConfig instanceOf() {
@ -35,30 +41,34 @@ public class FileAttachmentConfig extends AbstractConfig {
// //
// set of configuration parameters // set of configuration parameters
/** /**
* A form which should be used for editing file asset properties. * A form which should be used for editing file asset properties. Default
* Default implementation edits Assets.description property. * implementation edits Assets.description property.
*/ */
private final Parameter editFormClass = private final Parameter editFormClass = new SpecificClassParameter(
new SpecificClassParameter(
"com.arsdigita.cms.contentassets.file_edit_form", "com.arsdigita.cms.contentassets.file_edit_form",
Parameter.REQUIRED, Parameter.REQUIRED,
FileDescriptionForm.class, FileDescriptionForm.class,
FormSection.class); FormSection.class);
/** /**
* Optional parameter if set to TRUE will disply the asset URL instead of * Optional parameter if set to TRUE will disply the asset URL instead of
* the description on AttachFile Authroing step. Default: FALSE * the description on AttachFile Authroing step. Default: FALSE
*/ */
private final Parameter showAssetID = private final Parameter showAssetID = new BooleanParameter(
new BooleanParameter(
"com.arsdigita.cms.contentassets.file_show_asset_id", "com.arsdigita.cms.contentassets.file_show_asset_id",
Parameter.OPTIONAL, Parameter.OPTIONAL,
Boolean.FALSE); Boolean.FALSE);
private final Parameter fileAttachmentStepSortKey =
new IntegerParameter( private final Parameter fileAttachmentStepSortKey = new IntegerParameter(
"com.arsdigita.cms.contentassets.file_attchment_step_sort_key", "com.arsdigita.cms.contentassets.file_attchment_step_sort_key",
Parameter.REQUIRED, Parameter.REQUIRED,
2); 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! * Constructor, don't use it directly!
*/ */
@ -69,6 +79,7 @@ public class FileAttachmentConfig extends AbstractConfig {
register(editFormClass); register(editFormClass);
register(showAssetID); register(showAssetID);
register(fileAttachmentStepSortKey); register(fileAttachmentStepSortKey);
register(fileAttachmentDescriptionMaxLength);
loadInfo(); loadInfo();
} }
@ -85,4 +96,9 @@ public class FileAttachmentConfig extends AbstractConfig {
return (Integer) get(fileAttachmentStepSortKey); return (Integer) get(fileAttachmentStepSortKey);
} }
public Integer getFileAttachmentDescriptionMaxLength() {
return (Integer) get(fileAttachmentDescriptionMaxLength);
}
} }

View File

@ -12,3 +12,8 @@ com.arsdigita.cms.contentassets.file_attchment_step_sort_key.title = Sort key fo
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.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.example = 2
com.arsdigita.cms.contentassets.file_attchment_step_sort_key.format = [Integer] 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]

View File

@ -12,9 +12,9 @@
* rights and limitations under the License. * rights and limitations under the License.
* *
*/ */
package com.arsdigita.cms.contentassets; package com.arsdigita.cms.contentassets;
import com.arsdigita.cms.contentassets.util.FileAttachmentGlobalizationUtil;
import com.arsdigita.globalization.GlobalizedMessage; import com.arsdigita.globalization.GlobalizedMessage;
/** /**
@ -26,7 +26,6 @@ import com.arsdigita.globalization.GlobalizedMessage;
*/ */
public class FileAttachmentGlobalize { public class FileAttachmentGlobalize {
/** /**
* The label for the authoring step * The label for the authoring step
*/ */
@ -72,6 +71,10 @@ public class FileAttachmentGlobalize {
"com.arsdigita.cms.contentassets.FileAttachmentResources"); "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});
}
} }

View File

@ -18,3 +18,5 @@ cms.contentassets.file_attachment.table_edit=edit
cms.contentassets.file_attachment.table_up=up cms.contentassets.file_attachment.table_up=up
cms.contentassets.file_attachment.table_down=down cms.contentassets.file_attachment.table_down=down
cms.contentassets.file_attachment.table_delete=delete 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.

View File

@ -17,3 +17,5 @@ cms.contentassets.file_attachment.table_edit=bearbeiten
cms.contentassets.file_attachment.table_up=nach oben cms.contentassets.file_attachment.table_up=nach oben
cms.contentassets.file_attachment.table_down=nach unten cms.contentassets.file_attachment.table_down=nach unten
cms.contentassets.file_attachment.table_delete=l\u00f6schen 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.

View File

@ -25,18 +25,18 @@ import com.arsdigita.bebop.event.FormInitListener;
import com.arsdigita.bebop.event.FormProcessListener; import com.arsdigita.bebop.event.FormProcessListener;
import com.arsdigita.bebop.event.FormSectionEvent; import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.event.FormValidationListener; 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.form.TextArea;
import com.arsdigita.bebop.parameters.NotNullValidationListener; import com.arsdigita.bebop.parameters.NotNullValidationListener;
import com.arsdigita.bebop.parameters.StringInRangeValidationListener;
import com.arsdigita.cms.ContentItem; import com.arsdigita.cms.ContentItem;
import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.contentassets.FileAttachment; 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.contentassets.util.FileAttachmentGlobalizationUtil;
import com.arsdigita.cms.ui.FileUploadSection; import com.arsdigita.cms.ui.FileUploadSection;
import com.arsdigita.dispatcher.DispatcherHelper; import com.arsdigita.dispatcher.DispatcherHelper;
import java.io.IOException; import java.io.IOException;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
@ -55,6 +55,8 @@ public class FileAttachmentCaptionForm extends Form
private ItemSelectionModel m_itemModel; private ItemSelectionModel m_itemModel;
private SaveCancelSection m_saveCancelSection; private SaveCancelSection m_saveCancelSection;
private TextArea m_captionText; private TextArea m_captionText;
private static final FileAttachmentConfig s_config = FileAttachmentConfig
.instanceOf();
/** /**
* Construct a new FileCaptionForm * Construct a new FileCaptionForm
@ -131,6 +133,10 @@ public class FileAttachmentCaptionForm extends Form
m_captionText.setCols(10); m_captionText.setCols(10);
m_captionText.setRows(1); m_captionText.setRows(1);
m_captionText.addValidationListener(new NotNullValidationListener()); m_captionText.addValidationListener(new NotNullValidationListener());
m_captionText.addValidationListener(new StringInRangeValidationListener(
0,
s_config.getFileAttachmentDescriptionMaxLength(),
FileAttachmentGlobalize.DescriptionTooLong(s_config.getFileAttachmentDescriptionMaxLength())));
m_captionText.lock(); m_captionText.lock();
add(new Label(FileAttachmentGlobalizationUtil.globalize( add(new Label(FileAttachmentGlobalizationUtil.globalize(
"cms.contentassets.file_attachment.caption"))); "cms.contentassets.file_attachment.caption")));

View File

@ -27,9 +27,11 @@ import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.event.FormValidationListener; import com.arsdigita.bebop.event.FormValidationListener;
import com.arsdigita.bebop.form.TextArea; import com.arsdigita.bebop.form.TextArea;
import com.arsdigita.bebop.parameters.NotNullValidationListener; import com.arsdigita.bebop.parameters.NotNullValidationListener;
import com.arsdigita.bebop.parameters.StringInRangeValidationListener;
import com.arsdigita.cms.ContentItem; import com.arsdigita.cms.ContentItem;
import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.contentassets.FileAttachment; import com.arsdigita.cms.contentassets.FileAttachment;
import com.arsdigita.cms.contentassets.FileAttachmentConfig;
import com.arsdigita.cms.contentassets.FileAttachmentGlobalize; import com.arsdigita.cms.contentassets.FileAttachmentGlobalize;
import com.arsdigita.cms.contentassets.util.FileAttachmentGlobalizationUtil; import com.arsdigita.cms.contentassets.util.FileAttachmentGlobalizationUtil;
import com.arsdigita.cms.ui.FileUploadSection; import com.arsdigita.cms.ui.FileUploadSection;
@ -54,13 +56,16 @@ import org.apache.log4j.Logger;
public class FileAttachmentUpload extends Form 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 FileUploadSection m_fileUploadSection;
private TextArea m_description; private TextArea m_description;
private ItemSelectionModel m_itemModel; private ItemSelectionModel m_itemModel;
private SaveCancelSection m_saveCancelSection; private SaveCancelSection m_saveCancelSection;
private TextArea m_captionText; private TextArea m_captionText;
private static final FileAttachmentConfig s_config = FileAttachmentConfig
.instanceOf();
/** /**
* Construct a new FileAttachmentUpload * Construct a new FileAttachmentUpload
@ -131,7 +136,8 @@ public class FileAttachmentUpload extends Form
// Add the widgets // Add the widgets
public void addWidgets() { public void addWidgets() {
m_fileUploadSection = new FileUploadSection(FileAttachmentGlobalize.FileTypeLabel(), m_fileUploadSection = new FileUploadSection(FileAttachmentGlobalize
.FileTypeLabel(),
"file", "file",
ImageMimeType.MIME_IMAGE_JPEG); ImageMimeType.MIME_IMAGE_JPEG);
m_fileUploadSection.getFileUploadWidget() m_fileUploadSection.getFileUploadWidget()
@ -141,7 +147,13 @@ public class FileAttachmentUpload extends Form
m_description = new TextArea("description"); m_description = new TextArea("description");
m_description.setRows(5); m_description.setRows(5);
m_description.setCols(60); 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(); m_description.lock();
add(m_description); add(m_description);
} }
@ -157,7 +169,8 @@ public class FileAttachmentUpload extends Form
} }
@Override @Override
public void validate(final FormSectionEvent event) throws FormProcessException { public void validate(final FormSectionEvent event) throws
FormProcessException {
final PageState state = event.getPageState(); final PageState state = event.getPageState();
final ContentItem item = getContentItem(state); final ContentItem item = getContentItem(state);
final String fileName = m_fileUploadSection.getFileName(event); final String fileName = m_fileUploadSection.getFileName(event);
@ -167,8 +180,10 @@ public class FileAttachmentUpload extends Form
final DataObject attachment = attachments.getDataObject(); final DataObject attachment = attachments.getDataObject();
if (attachment.get(FileAttachment.NAME).equals(fileName)) { if (attachment.get(FileAttachment.NAME).equals(fileName)) {
attachments.close(); attachments.close();
throw new FormProcessException(FileAttachmentGlobalizationUtil.globalize( throw new FormProcessException(FileAttachmentGlobalizationUtil
"cms.contentassets.file_attachment.already_attached", new String[]{fileName})); .globalize(
"cms.contentassets.file_attachment.already_attached",
new String[]{fileName}));
} }
} }
attachments.close(); attachments.close();
@ -177,7 +192,8 @@ public class FileAttachmentUpload extends Form
// process: update the mime type and content // process: update the mime type and content
@Override @Override
public void process(final FormSectionEvent event) throws FormProcessException { public void process(final FormSectionEvent event) throws
FormProcessException {
s_log.debug("Uploading File"); s_log.debug("Uploading File");
final PageState state = event.getPageState(); final PageState state = event.getPageState();

View File

@ -28,7 +28,10 @@ import com.arsdigita.bebop.event.FormSubmissionListener;
import com.arsdigita.bebop.event.FormValidationListener; import com.arsdigita.bebop.event.FormValidationListener;
import com.arsdigita.bebop.form.Submit; import com.arsdigita.bebop.form.Submit;
import com.arsdigita.bebop.form.TextArea; import com.arsdigita.bebop.form.TextArea;
import com.arsdigita.bebop.parameters.StringInRangeValidationListener;
import com.arsdigita.cms.contentassets.FileAttachment; 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.contentassets.util.FileAttachmentGlobalizationUtil;
/** /**
@ -40,6 +43,9 @@ public class FileDescriptionForm extends FormSection implements
FormInitListener, FormProcessListener, FormValidationListener, FormInitListener, FormProcessListener, FormValidationListener,
FormSubmissionListener { FormSubmissionListener {
private static final FileAttachmentConfig s_config = FileAttachmentConfig
.instanceOf();
private TextArea m_description; private TextArea m_description;
private FileAttachmentSelectionModel m_fileModel; private FileAttachmentSelectionModel m_fileModel;
@ -76,6 +82,10 @@ public class FileDescriptionForm extends FormSection implements
m_description = new TextArea("description"); m_description = new TextArea("description");
m_description.setCols(40); m_description.setCols(40);
m_description.setRows(5); m_description.setRows(5);
m_description.addValidationListener(new StringInRangeValidationListener(
0,
s_config.getFileAttachmentDescriptionMaxLength(),
FileAttachmentGlobalize.DescriptionTooLong(s_config.getFileAttachmentDescriptionMaxLength())));
add(new Label(FileAttachmentGlobalizationUtil add(new Label(FileAttachmentGlobalizationUtil
.globalize("cms.contentassets.file_attachment.caption_or_description"))); .globalize("cms.contentassets.file_attachment.caption_or_description")));

View File

@ -683,19 +683,19 @@
</xsl:choose> </xsl:choose>
</xsl:template> </xsl:template>
<xsl:template match="date-format/short-date"> <xsl:template match="date-format//short-date">
<xsl:param name="date-elem" tunnel="yes"/> <xsl:param name="date-elem" tunnel="yes"/>
<xsl:value-of select="$date-elem/@date"/> <xsl:value-of select="$date-elem/@date"/>
</xsl:template> </xsl:template>
<xsl:template match="date-format/long-date"> <xsl:template match="date-format//long-date">
<xsl:param name="date-elem" tunnel="yes"/> <xsl:param name="date-elem" tunnel="yes"/>
<xsl:value-of select="$date-elem/@longDate"/> <xsl:value-of select="$date-elem/@longDate"/>
</xsl:template> </xsl:template>
<xsl:template match="date-format/iso-date"> <xsl:template match="date-format//iso-date">
<xsl:param name="date-elem" tunnel="yes"/> <xsl:param name="date-elem" tunnel="yes"/>
<xsl:variable name="year" select="$date-elem/@year"/> <xsl:variable name="year" select="$date-elem/@year"/>
@ -733,7 +733,7 @@
<xsl:value-of select="concat($year, '-', $month, '-', $day)"/> <xsl:value-of select="concat($year, '-', $month, '-', $day)"/>
</xsl:template> </xsl:template>
<xsl:template match="date-format/year"> <xsl:template match="date-format//year">
<xsl:param name="date-elem" tunnel="yes"/> <xsl:param name="date-elem" tunnel="yes"/>
<xsl:value-of select="if (foundry:boolean(./@short)) <xsl:value-of select="if (foundry:boolean(./@short))
@ -752,7 +752,7 @@
</xsl:choose>--> </xsl:choose>-->
</xsl:template> </xsl:template>
<xsl:template match="date-format/month"> <xsl:template match="date-format//month">
<xsl:param name="date-elem" tunnel="yes"/> <xsl:param name="date-elem" tunnel="yes"/>
<xsl:value-of select="if (string-length($date-elem/@month) &lt; 2 <xsl:value-of select="if (string-length($date-elem/@month) &lt; 2
@ -772,13 +772,13 @@
</xsl:choose>--> </xsl:choose>-->
</xsl:template> </xsl:template>
<xsl:template match="date-format/month-name"> <xsl:template match="date-format//month-name">
<xsl:param name="date-elem" tunnel="yes"/> <xsl:param name="date-elem" tunnel="yes"/>
<xsl:value-of select="$date-elem/@monthName"/> <xsl:value-of select="$date-elem/@monthName"/>
</xsl:template> </xsl:template>
<xsl:template match="date-format/day"> <xsl:template match="date-format//day">
<xsl:param name="date-elem" tunnel="yes"/> <xsl:param name="date-elem" tunnel="yes"/>
<xsl:value-of select="if (string-length($date-elem/@day) &lt; 2 <xsl:value-of select="if (string-length($date-elem/@day) &lt; 2

View File

@ -22,13 +22,13 @@
--> -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:bebop="http://www.arsdigita.com/bebop/1.0" xmlns:bebop="http://www.arsdigita.com/bebop/1.0"
xmlns:foundry="http://foundry.libreccm.org" xmlns:foundry="http://foundry.libreccm.org"
xmlns:nav="http://ccm.redhat.com/navigation" xmlns:nav="http://ccm.redhat.com/navigation"
xmlns:ui="http://www.arsdigita.com/ui/1.0" xmlns:ui="http://www.arsdigita.com/ui/1.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/xhtml"
exclude-result-prefixes="xsl xs bebop foundry ui" exclude-result-prefixes="xsl xs bebop foundry nav ui"
version="2.0"> version="2.0">
<foundry:doc-file> <foundry:doc-file>

View File

@ -21,8 +21,10 @@
} }
</jsp:scriptlet> </jsp:scriptlet>
<define:page name="defaultItemPage" application="navigation" <define:page name="defaultItemPage"
title="Navigation" cache="true"> application="navigation"
title="Navigation"
cache="true">
<define:component name="greetingItem" <define:component name="greetingItem"
classname="com.arsdigita.navigation.ui.GreetingItem"/> classname="com.arsdigita.navigation.ui.GreetingItem"/>
@ -33,6 +35,8 @@
<define:component name="itemList" <define:component name="itemList"
classname="com.arsdigita.navigation.ui.object.SimpleObjectList"/> classname="com.arsdigita.navigation.ui.object.SimpleObjectList"/>
<jsp:scriptlet> <jsp:scriptlet>
defaultItemPage.setClassAttr("welcomePage");
((com.arsdigita.navigation.ui.object.SimpleObjectList) itemList).setDefinition(new CMSDataCollectionDefinition()); ((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).setRenderer(new CMSDataCollectionRenderer());
((com.arsdigita.navigation.ui.object.SimpleObjectList) itemList).getDefinition().setObjectType("com.arsdigita.cms.ContentPage"); ((com.arsdigita.navigation.ui.object.SimpleObjectList) itemList).getDefinition().setObjectType("com.arsdigita.cms.ContentPage");