diff --git a/ccm-cms-types-image/pdl/com/arsdigita/content-types/Image.pdl b/ccm-cms-types-image/pdl/com/arsdigita/content-types/Image.pdl
index 655dec8a1..291721528 100755
--- a/ccm-cms-types-image/pdl/com/arsdigita/content-types/Image.pdl
+++ b/ccm-cms-types-image/pdl/com/arsdigita/content-types/Image.pdl
@@ -11,19 +11,21 @@ object type Image extends ContentPage {
BigDecimal[0..1] width = ct_images.width INTEGER;
BigDecimal[0..1] height = ct_images.height INTEGER;
- String[0..1] caption = ct_images.caption VARCHAR(400);
- String[0..1] description = ct_images.description VARCHAR(500);
- String[0..1] artist = ct_images.artist VARCHAR(200);
- Date [0..1] publishDate = ct_images.publish_date DATE;
- String[0..1] source = ct_images.source VARCHAR(600);
- String[0..1] media = ct_images.media VARCHAR(300);
- String[0..1] copyright = ct_images.copyright VARCHAR(400);
- String[0..1] site = ct_images.site VARCHAR(500);
- String[0..1] license = ct_images.license VARCHAR(300);
- String[0..1] material = ct_images.material VARCHAR(200);
- String[0..1] technique = ct_images.technique VARCHAR(200);
- String[0..1] origin = ct_images.origin VARCHAR(200);
- String[0..1] origSize = ct_images.origSize VARCHAR(100);
+ String [0..1] caption = ct_images.caption VARCHAR(400);
+ String [0..1] description = ct_images.description VARCHAR(500);
+ String [0..1] artist = ct_images.artist VARCHAR(200);
+ Date [0..1] publishDate = ct_images.publish_date DATE;
+ Boolean[0..1] skipDay = ct_images.skip_day;
+ Boolean[0..1] skipMonth = ct_images.skip_month;
+ String [0..1] source = ct_images.source VARCHAR(600);
+ String [0..1] media = ct_images.media VARCHAR(300);
+ String [0..1] copyright = ct_images.copyright VARCHAR(400);
+ String [0..1] site = ct_images.site VARCHAR(500);
+ String [0..1] license = ct_images.license VARCHAR(300);
+ String [0..1] material = ct_images.material VARCHAR(200);
+ String [0..1] technique = ct_images.technique VARCHAR(200);
+ String [0..1] origin = ct_images.origin VARCHAR(200);
+ String [0..1] origSize = ct_images.origSize VARCHAR(100);
reference key (ct_images.item_id);
}
diff --git a/ccm-cms-types-image/src/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/Image.xml b/ccm-cms-types-image/src/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/Image.xml
index 698ece8ab..2018aaa9a 100644
--- a/ccm-cms-types-image/src/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/Image.xml
+++ b/ccm-cms-types-image/src/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/Image.xml
@@ -3,7 +3,7 @@
-
+
@@ -14,4 +14,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ccm-cms-types-image/src/com/arsdigita/cms/contenttypes/Image.java b/ccm-cms-types-image/src/com/arsdigita/cms/contenttypes/Image.java
index 5e937b7b5..1688fc045 100755
--- a/ccm-cms-types-image/src/com/arsdigita/cms/contenttypes/Image.java
+++ b/ccm-cms-types-image/src/com/arsdigita/cms/contenttypes/Image.java
@@ -47,6 +47,8 @@ public class Image extends ContentPage {
public static final String CAPTION = "caption";
public static final String DESCRIPTION = "description";
public static final String ARTIST = "artist";
+ public static final String SKIPDAY= "skipDay";
+ public static final String SKIPMONTH= "skipMonth";
public static final String PUBLISHDATE = "publishDate";
public static final String SOURCE = "source";
public static final String MEDIA = "media";
@@ -207,6 +209,30 @@ public class Image extends ContentPage {
set(ARTIST, artist);
}
+ public Boolean getSkipDay() {
+ try {
+ return ((Boolean) get(SKIPDAY)).booleanValue();
+ } catch (NullPointerException ex) {
+ return Boolean.FALSE;
+ }
+ }
+
+ public void setSkipDay(Boolean skipDay) {
+ set(SKIPDAY, skipDay);
+ }
+
+ public Boolean getSkipMonth() {
+ try {
+ return ((Boolean) get(SKIPMONTH)).booleanValue();
+ } catch (NullPointerException ex) {
+ return Boolean.FALSE;
+ }
+ }
+
+ public void setSkipMonth(Boolean skipMonth) {
+ set(SKIPMONTH, skipMonth);
+ }
+
public Date getPublishDate() {
return (Date) get(PUBLISHDATE);
}
diff --git a/ccm-cms-types-image/src/com/arsdigita/cms/contenttypes/ui/ImagePropertiesStep.java b/ccm-cms-types-image/src/com/arsdigita/cms/contenttypes/ui/ImagePropertiesStep.java
index ee33de006..d88a85cd7 100755
--- a/ccm-cms-types-image/src/com/arsdigita/cms/contenttypes/ui/ImagePropertiesStep.java
+++ b/ccm-cms-types-image/src/com/arsdigita/cms/contenttypes/ui/ImagePropertiesStep.java
@@ -48,10 +48,13 @@ import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
import com.arsdigita.cms.ui.authoring.BasicPageForm;
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
+import com.arsdigita.dispatcher.DispatcherHelper;
import java.io.File;
import java.io.IOException;
import java.text.DateFormat;
+import java.text.DateFormatSymbols;
import java.util.HashMap;
+import java.util.Locale;
import java.util.Map;
/**
@@ -152,7 +155,23 @@ public class ImagePropertiesStep extends SimpleEditStep {
public String format(DomainObject item, String attribute, PageState state) {
Image image = (Image) item;
if ((image.getPublishDate()) != null) {
- return DateFormat.getDateInstance(DateFormat.LONG).format(image.getPublishDate());
+ if (image.getSkipDay().booleanValue() == true || image.getSkipMonth().booleanValue() == true) {
+ String month = "";
+ if (image.getSkipMonth().booleanValue() == false) {
+ Locale locale = DispatcherHelper.getNegotiatedLocale();
+
+ if (locale != null) {
+
+ DateFormatSymbols dfs = new DateFormatSymbols(locale);
+ String[] months = dfs.getMonths();
+ month = months[image.getPublishDate().getMonth()] + " ";
+ }
+ }
+ String year = Integer.toString(image.getPublishDate().getYear() + 1900);
+ return month + year;
+ } else {
+ return DateFormat.getDateInstance(DateFormat.LONG).format(image.getPublishDate());
+ }
} else {
return (String) ImageGlobalizationUtil.globalize("cms.ui.unknown").localize();
}
diff --git a/ccm-cms-types-image/src/com/arsdigita/cms/contenttypes/ui/ImagePropertyForm.java b/ccm-cms-types-image/src/com/arsdigita/cms/contenttypes/ui/ImagePropertyForm.java
index 14bc23c63..fd02399a6 100755
--- a/ccm-cms-types-image/src/com/arsdigita/cms/contenttypes/ui/ImagePropertyForm.java
+++ b/ccm-cms-types-image/src/com/arsdigita/cms/contenttypes/ui/ImagePropertyForm.java
@@ -27,9 +27,13 @@ import com.arsdigita.bebop.event.FormProcessListener;
import com.arsdigita.bebop.event.FormSubmissionListener;
import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.form.Date;
+import com.arsdigita.bebop.form.Hidden;
+import com.arsdigita.bebop.form.Option;
+import com.arsdigita.bebop.form.RadioGroup;
import com.arsdigita.bebop.form.TextArea;
import com.arsdigita.bebop.form.TextField;
-import com.arsdigita.bebop.parameters.DateParameter;
+import com.arsdigita.bebop.parameters.BooleanParameter;
+import com.arsdigita.bebop.parameters.IncompleteDateParameter;
import com.arsdigita.bebop.parameters.ParameterModel;
import com.arsdigita.bebop.parameters.StringInRangeValidationListener;
import com.arsdigita.bebop.parameters.StringParameter;
@@ -102,8 +106,18 @@ public class ImagePropertyForm
TextField artist = new TextField(artistParam);
add(artist);
+ ParameterModel skipDayParam = new BooleanParameter(Image.SKIPDAY);
+ Hidden skipDay = new Hidden(skipDayParam);
+ add(skipDay);
+
+ ParameterModel skipMonthParam = new BooleanParameter(Image.SKIPMONTH);
+ Hidden skipMonth = new Hidden(skipMonthParam);
+ add(skipMonth);
+
add(new Label(ImageGlobalizationUtil.globalize("cms.contenttypes.ui.image.publishDate")));
- ParameterModel publishDateParam = new DateParameter(Image.PUBLISHDATE);
+ IncompleteDateParameter publishDateParam = new IncompleteDateParameter(Image.PUBLISHDATE);
+ publishDateParam.allowSkipDay(true);
+ publishDateParam.allowSkipMonth(true);
Date publishDate = new Date(publishDateParam);
publishDate.setYearRange(Image.getConfig().getStartYear(),
GregorianCalendar.getInstance().get(Calendar.YEAR) + Image.getConfig().getEndYearDelta());
@@ -176,6 +190,8 @@ public class ImagePropertyForm
data.put(Image.CAPTION, image.getCaption());
data.put(Image.DESCRIPTION, image.getDescription());
data.put(Image.ARTIST, image.getArtist());
+ data.put(Image.SKIPDAY, image.getSkipDay());
+ data.put(Image.SKIPMONTH, image.getSkipMonth());
data.put(Image.PUBLISHDATE, image.getPublishDate());
data.put(Image.SOURCE, image.getSource());
data.put(Image.MEDIA, image.getMedia());
@@ -215,6 +231,8 @@ public class ImagePropertyForm
image.setCaption((String) data.get(Image.CAPTION));
image.setDescription((String) data.get(Image.DESCRIPTION));
image.setArtist((String) data.get(Image.ARTIST));
+ image.setSkipDay(((IncompleteDateParameter) data.getParameter(Image.PUBLISHDATE).getModel()).isDaySkipped());
+ image.setSkipMonth(((IncompleteDateParameter) data.getParameter(Image.PUBLISHDATE).getModel()).isMonthSkipped());
image.setPublishDate((java.util.Date) data.get(Image.PUBLISHDATE));
image.setSource((String) data.get(Image.SOURCE));
image.setMedia((String) data.get(Image.MEDIA));
diff --git a/ccm-cms/src/WEB-INF/resources/cms-item-adapters.xml b/ccm-cms/src/WEB-INF/resources/cms-item-adapters.xml
index cf8168272..057b3a8a7 100755
--- a/ccm-cms/src/WEB-INF/resources/cms-item-adapters.xml
+++ b/ccm-cms/src/WEB-INF/resources/cms-item-adapters.xml
@@ -166,6 +166,8 @@
+
+
+
diff --git a/ccm-cms/src/com/arsdigita/cms/CMSConfig_parameter.properties b/ccm-cms/src/com/arsdigita/cms/CMSConfig_parameter.properties
index 1eff79c25..7ec30fc15 100755
--- a/ccm-cms/src/com/arsdigita/cms/CMSConfig_parameter.properties
+++ b/ccm-cms/src/com/arsdigita/cms/CMSConfig_parameter.properties
@@ -228,7 +228,7 @@ com.arsdigita.cms.allow_content_create_in_section_listing.purpose=Allows you to
com.arsdigita.cms.allow_content_create_in_section_listing.example=true
com.arsdigita.cms.allow_content_create_in_section_listing.format=[boolean]
-com.arsdigita.cms.item_search.default_tab.title=Set the default tabe for ItemSearchWidget
+com.arsdigita.cms.item_search.default_tab.title=Set the default table for ItemSearchWidget
com.arsdigita.cms.item_search.default_tab.purpose=Select either "browse" or "search" for default tab
com.arsdigita.cms.item_search.default_tab.example=browse
com.arsdigita.cms.item_search.default_tab.format=[string]
diff --git a/ccm-core/src/com/arsdigita/bebop/form/Date.java b/ccm-core/src/com/arsdigita/bebop/form/Date.java
index 9a6f89af3..4b5e54b97 100755
--- a/ccm-core/src/com/arsdigita/bebop/form/Date.java
+++ b/ccm-core/src/com/arsdigita/bebop/form/Date.java
@@ -31,6 +31,7 @@ import com.arsdigita.bebop.parameters.ParameterData;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.Form;
import com.arsdigita.bebop.FormData;
+import com.arsdigita.bebop.parameters.IncompleteDateParameter;
import com.arsdigita.bebop.parameters.NotNullValidationListener;
// This interface contains the XML element name of this class
// in a constant which is used when generating XML
@@ -80,6 +81,12 @@ public class Date extends Widget implements BebopConstants {
@Override
public Object getValue(PageState ps) {
+ ParameterModel model = parent.getParameterModel();
+ if (model instanceof IncompleteDateParameter) {
+ if (((IncompleteDateParameter) model).isYearSkipped()) {
+ return null;
+ }
+ }
Object value = parent.getFragmentValue(ps, Calendar.YEAR);
if (value == null) {
Calendar currentTime = GregorianCalendar.getInstance();
@@ -110,6 +117,12 @@ public class Date extends Widget implements BebopConstants {
@Override
public Object getValue(PageState ps) {
+ ParameterModel model = parent.getParameterModel();
+ if (model instanceof IncompleteDateParameter) {
+ if (((IncompleteDateParameter) model).isMonthSkipped()) {
+ return null;
+ }
+ }
return parent.getFragmentValue(ps, Calendar.MONTH);
}
}
@@ -134,6 +147,12 @@ public class Date extends Widget implements BebopConstants {
@Override
public Object getValue(PageState ps) {
+ ParameterModel model = parent.getParameterModel();
+ if (model instanceof IncompleteDateParameter) {
+ if (((IncompleteDateParameter) model).isDaySkipped()) {
+ return null;
+ }
+ }
return parent.getFragmentValue(ps, Calendar.DATE);
}
}
@@ -182,6 +201,11 @@ public class Date extends Widget implements BebopConstants {
m_year_end = yearEnd;
m_year.clearOptions();
+ if (this.getParameterModel() instanceof IncompleteDateParameter) {
+ if (((IncompleteDateParameter) this.getParameterModel()).isSkipYearAllowed()) {
+ m_year.addOption(new Option("", ""));
+ }
+ }
for (int year = m_year_begin; year <= m_year_end; year += 1) {
m_year.addOption(new Option(String.valueOf(year)));
}
@@ -356,6 +380,11 @@ public class Date extends Widget implements BebopConstants {
m_month.clearOptions();
+ if (this.getParameterModel() instanceof IncompleteDateParameter) {
+ if (((IncompleteDateParameter) this.getParameterModel()).isSkipMonthAllowed()) {
+ m_month.addOption(new Option("", ""));
+ }
+ }
for (int i = 0; i < months.length; i += 1) {
// This check is necessary because
// java.text.DateFormatSymbols.getMonths() returns an array
diff --git a/ccm-core/src/com/arsdigita/bebop/parameters/DateParameter.java b/ccm-core/src/com/arsdigita/bebop/parameters/DateParameter.java
index 7532af7c8..b548e0699 100755
--- a/ccm-core/src/com/arsdigita/bebop/parameters/DateParameter.java
+++ b/ccm-core/src/com/arsdigita/bebop/parameters/DateParameter.java
@@ -37,7 +37,6 @@ public class DateParameter extends ParameterModel {
super(name);
}
-
/**
* This method returns a new Calendar object that is manipulated
* within transformValue to create a Date Object. This method should
@@ -62,6 +61,7 @@ public class DateParameter extends ParameterModel {
* SECOND to 0, since they are by default the current
* time.
* */
+ @Override
public Object transformValue(HttpServletRequest request)
throws IllegalArgumentException {
Calendar c = null;
diff --git a/ccm-core/src/com/arsdigita/bebop/parameters/IncompleteDateParameter.java b/ccm-core/src/com/arsdigita/bebop/parameters/IncompleteDateParameter.java
new file mode 100644
index 000000000..8b3d1abda
--- /dev/null
+++ b/ccm-core/src/com/arsdigita/bebop/parameters/IncompleteDateParameter.java
@@ -0,0 +1,145 @@
+/*
+ * Copyright (C) 2001-2004 Red Hat Inc. 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.bebop.parameters;
+
+import com.arsdigita.globalization.Globalization;
+import java.util.Calendar;
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * A class that represents the model for date form parameters.
+ * This one will allow incomplete entry on date. Should be used in
+ * combination with an additional Boolean DB field to keep track
+ * of the incomplete entry.
+ *
+ * @author Sören Bernstein
+ */
+public class IncompleteDateParameter extends DateParameter {
+
+ private boolean allowSkipYear = false;
+ private boolean allowSkipMonth = false;
+ private boolean allowSkipDay = false;
+ private boolean skippedYear = false;
+ private boolean skippedMonth = false;
+ private boolean skippedDay = false;
+
+ public IncompleteDateParameter(String name) {
+ super(name);
+ }
+
+ public void allowSkipYear(boolean bool) {
+ this.allowSkipYear = bool;
+ }
+
+ public boolean isSkipYearAllowed() {
+ return this.allowSkipYear;
+ }
+
+ public void allowSkipMonth(boolean bool) {
+ this.allowSkipMonth = bool;
+ }
+
+ public boolean isSkipMonthAllowed() {
+ return this.allowSkipMonth;
+ }
+
+ public void allowSkipDay(boolean bool) {
+ this.allowSkipDay = bool;
+ }
+
+ public boolean isSkipDayAllowed() {
+ return this.allowSkipDay;
+ }
+
+ public boolean isDaySkipped() {
+ return this.skippedDay;
+ }
+
+ public boolean isMonthSkipped() {
+ return this.skippedMonth;
+ }
+
+ public boolean isYearSkipped() {
+ return this.skippedYear;
+ }
+
+ public boolean isSkipped() {
+ return this.skippedDay || this.skippedMonth || this.skippedYear;
+ }
+
+ /**
+ * Computes a date object from multiple parameters in the
+ * request. This method searches for parameters named
+ * getName() + ".year", getName() +
+ * ".month" and getName() + ".day". It sets the
+ * fields HOUR, MINUTE and
+ * SECOND to 0, since they are by default the current
+ * time.
+ * */
+ @Override
+ public Object transformValue(HttpServletRequest request)
+ throws IllegalArgumentException {
+ Calendar c = null;
+ Object outVal = null;
+ try {
+
+ c = getCalendar(request);
+ c.clear();
+ //don't accept lenient dates like June 44
+ c.setLenient(false);
+
+ String year = Globalization.decodeParameter(request, getName() + ".year");
+ String month = Globalization.decodeParameter(request, getName() + ".month");
+ String day = Globalization.decodeParameter(request, getName() + ".day");
+
+ // If non-skippable field missing return null
+ if ((this.allowSkipYear == false && (year == null || year.length() == 0))
+ || (this.allowSkipMonth == false && (month == null || month.length() == 0))
+ || (this.allowSkipDay == false && (day == null || day.length() == 0))) {
+ return null;
+ }
+
+ if (year != null && year.length() > 0) {
+ this.skippedYear = false;
+ c.set(Calendar.YEAR, Integer.parseInt(year));
+ } else {
+ this.skippedYear = true;
+ c.set(Calendar.YEAR, 0);
+ }
+ if (month != null && month.length() > 0) {
+ this.skippedMonth = false;
+ c.set(Calendar.MONTH, Integer.parseInt(month));
+ } else {
+ this.skippedMonth = true;
+ c.set(Calendar.MONTH, 1);
+ }
+ if (day != null && day.length() > 0) {
+ this.skippedDay = false;
+ c.set(Calendar.DATE, Integer.parseInt(day));
+ } else {
+ this.skippedDay = true;
+ c.set(Calendar.DATE, 1);
+ }
+ outVal = c.getTime();
+ } catch (IllegalArgumentException e) {
+ throw new IllegalArgumentException("Invalid Day of Month");
+ }
+ return outVal;
+ }
+}