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 {
/** 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);
}
}

View File

@ -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]
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.
*
*/
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});
}
}

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_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.

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_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.

View File

@ -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")));

View File

@ -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();

View File

@ -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")));

View File

@ -683,19 +683,19 @@
</xsl:choose>
</xsl:template>
<xsl:template match="date-format/short-date">
<xsl:template match="date-format//short-date">
<xsl:param name="date-elem" tunnel="yes"/>
<xsl:value-of select="$date-elem/@date"/>
</xsl:template>
<xsl:template match="date-format/long-date">
<xsl:template match="date-format//long-date">
<xsl:param name="date-elem" tunnel="yes"/>
<xsl:value-of select="$date-elem/@longDate"/>
</xsl:template>
<xsl:template match="date-format/iso-date">
<xsl:template match="date-format//iso-date">
<xsl:param name="date-elem" tunnel="yes"/>
<xsl:variable name="year" select="$date-elem/@year"/>
@ -733,7 +733,7 @@
<xsl:value-of select="concat($year, '-', $month, '-', $day)"/>
</xsl:template>
<xsl:template match="date-format/year">
<xsl:template match="date-format//year">
<xsl:param name="date-elem" tunnel="yes"/>
<xsl:value-of select="if (foundry:boolean(./@short))
@ -752,7 +752,7 @@
</xsl:choose>-->
</xsl:template>
<xsl:template match="date-format/month">
<xsl:template match="date-format//month">
<xsl:param name="date-elem" tunnel="yes"/>
<xsl:value-of select="if (string-length($date-elem/@month) &lt; 2
@ -772,13 +772,13 @@
</xsl:choose>-->
</xsl:template>
<xsl:template match="date-format/month-name">
<xsl:template match="date-format//month-name">
<xsl:param name="date-elem" tunnel="yes"/>
<xsl:value-of select="$date-elem/@monthName"/>
</xsl:template>
<xsl:template match="date-format/day">
<xsl:template match="date-format//day">
<xsl:param name="date-elem" tunnel="yes"/>
<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"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:bebop="http://www.arsdigita.com/bebop/1.0"
xmlns:foundry="http://foundry.libreccm.org"
xmlns:nav="http://ccm.redhat.com/navigation"
xmlns:ui="http://www.arsdigita.com/ui/1.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
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">
<foundry:doc-file>

View File

@ -21,8 +21,10 @@
}
</jsp:scriptlet>
<define:page name="defaultItemPage" application="navigation"
title="Navigation" cache="true">
<define:page name="defaultItemPage"
application="navigation"
title="Navigation"
cache="true">
<define:component name="greetingItem"
classname="com.arsdigita.navigation.ui.GreetingItem"/>
@ -33,6 +35,8 @@
<define:component name="itemList"
classname="com.arsdigita.navigation.ui.object.SimpleObjectList"/>
<jsp:scriptlet>
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");