CT Image
* Thumbnails werden nun automatisch erzeugt und gespeichert * Anzeige im CC wird nun auf ein definiertes Maß proportional verkleinert * Lizenzfeld * TextAsset-Feld für den ausführlichen Text * Beschribungsfeld auf 500 Zeichen gekürzt * AuthoringStep "Bild hinzufügen" läßt sich per cms.properties Schlüssel ausblenden git-svn-id: https://svn.libreccm.org/ccm/trunk@764 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
dd645e695c
commit
b78a52057d
|
|
@ -51,17 +51,12 @@ public class ItemImageAttachment extends ACSObject implements CustomCopy {
|
|||
public static final String ITEM_ATTACHMENTS = "itemAttachments";
|
||||
public static final String IMAGE_LINK = "imageLink";
|
||||
/** Data object type for this domain object */
|
||||
public static final String BASE_DATA_OBJECT_TYPE =
|
||||
"com.arsdigita.cms.contentassets.ItemImageAttachment";
|
||||
private static final Logger s_log = Logger.getLogger(
|
||||
ItemImageAttachment.class);
|
||||
private static final ItemImageAttachmentConfig s_config =
|
||||
new ItemImageAttachmentConfig();
|
||||
public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.cms.contentassets.ItemImageAttachment";
|
||||
private static final Logger s_log = Logger.getLogger(ItemImageAttachment.class);
|
||||
private static final ItemImageAttachmentConfig s_config = new ItemImageAttachmentConfig();
|
||||
|
||||
static {
|
||||
s_log.debug("Static initalizer starting...");
|
||||
s_config.load();
|
||||
s_log.debug("Static initalizer finished.");
|
||||
}
|
||||
|
||||
private ItemImageAttachment() {
|
||||
|
|
@ -131,8 +126,7 @@ public class ItemImageAttachment extends ACSObject implements CustomCopy {
|
|||
s_log.debug("Getting attachments for " + item.getOID());
|
||||
}
|
||||
|
||||
DataCollection attachments = SessionManager.getSession().retrieve(
|
||||
BASE_DATA_OBJECT_TYPE);
|
||||
DataCollection attachments = SessionManager.getSession().retrieve(BASE_DATA_OBJECT_TYPE);
|
||||
attachments.addEqualsFilter(ITEM + ".id", item.getID());
|
||||
|
||||
return attachments;
|
||||
|
|
@ -174,16 +168,16 @@ public class ItemImageAttachment extends ACSObject implements CustomCopy {
|
|||
* Automatically publish an unpublished image
|
||||
*/
|
||||
public boolean copyProperty(final CustomCopy source,
|
||||
final Property property,
|
||||
final ItemCopier copier) {
|
||||
final Property property,
|
||||
final ItemCopier copier) {
|
||||
String attribute = property.getName();
|
||||
if (ItemCopier.VERSION_COPY == copier.getCopyType() && IMAGE.equals(
|
||||
attribute)) {
|
||||
if (ItemCopier.VERSION_COPY == copier.getCopyType()
|
||||
&& IMAGE.equals(attribute)) {
|
||||
ItemImageAttachment attachment = (ItemImageAttachment) source;
|
||||
ReusableImageAsset image = attachment.getImage();
|
||||
|
||||
ReusableImageAsset liveImage =
|
||||
(ReusableImageAsset) image.getLiveVersion();
|
||||
(ReusableImageAsset) image.getLiveVersion();
|
||||
|
||||
if (null == liveImage) {
|
||||
liveImage = (ReusableImageAsset) image.createLiveVersion();
|
||||
|
|
@ -216,8 +210,7 @@ public class ItemImageAttachment extends ACSObject implements CustomCopy {
|
|||
// when we delete the link, the image still references it in DB
|
||||
// can't make it composite because then image is deleted if we delete
|
||||
// link. Have to set link to null first (I think)
|
||||
DomainObject link = DomainObjectFactory.newInstance((DataObject) get(
|
||||
IMAGE_LINK));
|
||||
DomainObject link = DomainObjectFactory.newInstance((DataObject) get(IMAGE_LINK));
|
||||
set(IMAGE_LINK, null);
|
||||
save();
|
||||
link.delete();
|
||||
|
|
|
|||
|
|
@ -65,45 +65,45 @@ public class ItemImageAttachmentInitializer extends ContentAssetInitializer {
|
|||
}
|
||||
);
|
||||
|
||||
removeDeprecatedImageSteps();
|
||||
// removeDeprecatedImageSteps();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private void removeDeprecatedImageSteps() {
|
||||
DataCollection steps = SessionManager.getSession().retrieve
|
||||
( AuthoringStep.BASE_DATA_OBJECT_TYPE );
|
||||
|
||||
// Don't use defined constant to reduce dependency on GenericArticle
|
||||
steps.addEqualsFilter( "component",
|
||||
"com.arsdigita.cms.ui.authoring.ArticleImage" );
|
||||
|
||||
while( steps.next() ) {
|
||||
DataObject step = steps.getDataObject();
|
||||
|
||||
DataCollection kits = SessionManager.getSession().retrieve
|
||||
( AuthoringKitStepAssociation.BASE_DATA_OBJECT_TYPE );
|
||||
kits.addEqualsFilter( "stepId", step.get( "id" ) );
|
||||
|
||||
while( kits.next() ) {
|
||||
DataObject kitStep = kits.getDataObject();
|
||||
AuthoringKitStepAssociation kitStepAsso = new AuthoringKitStepAssociation(kitStep);
|
||||
// Check whether the content type is (persistence-wise) subtype
|
||||
// of com.ad.cms.GenericArticle. This is lame, but I couldn't find a better API to do this:
|
||||
AuthoringKit kit = new AuthoringKit (kitStepAsso.getKitID());
|
||||
try {
|
||||
ObjectType.verifySubtype(GenericArticle.BASE_DATA_OBJECT_TYPE,
|
||||
kit.getContentType().getAssociatedObjectType());
|
||||
kitStepAsso.delete();
|
||||
} catch (PersistenceException pe) {
|
||||
// Do nothing, the content type is not subtyping com.arsdigita.cms.GenericArticle
|
||||
}
|
||||
}
|
||||
|
||||
// DomainObjectFactory.newInstance( step ).delete();
|
||||
}
|
||||
}
|
||||
// private void removeDeprecatedImageSteps() {
|
||||
// DataCollection steps = SessionManager.getSession().retrieve
|
||||
// ( AuthoringStep.BASE_DATA_OBJECT_TYPE );
|
||||
//
|
||||
// // Don't use defined constant to reduce dependency on GenericArticle
|
||||
// steps.addEqualsFilter( "component",
|
||||
// "com.arsdigita.cms.ui.authoring.ArticleImage" );
|
||||
//
|
||||
// while( steps.next() ) {
|
||||
// DataObject step = steps.getDataObject();
|
||||
//
|
||||
// DataCollection kits = SessionManager.getSession().retrieve
|
||||
// ( AuthoringKitStepAssociation.BASE_DATA_OBJECT_TYPE );
|
||||
// kits.addEqualsFilter( "stepId", step.get( "id" ) );
|
||||
//
|
||||
// while( kits.next() ) {
|
||||
// DataObject kitStep = kits.getDataObject();
|
||||
// AuthoringKitStepAssociation kitStepAsso = new AuthoringKitStepAssociation(kitStep);
|
||||
// // Check whether the content type is (persistence-wise) subtype
|
||||
// // of com.ad.cms.GenericArticle. This is lame, but I couldn't find a better API to do this:
|
||||
// AuthoringKit kit = new AuthoringKit (kitStepAsso.getKitID());
|
||||
// try {
|
||||
// ObjectType.verifySubtype(GenericArticle.BASE_DATA_OBJECT_TYPE,
|
||||
// kit.getContentType().getAssociatedObjectType());
|
||||
// kitStepAsso.delete();
|
||||
// } catch (PersistenceException pe) {
|
||||
// // Do nothing, the content type is not subtyping com.arsdigita.cms.GenericArticle
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // DomainObjectFactory.newInstance( step ).delete();
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
public String getTraversalXML() {
|
||||
|
|
|
|||
|
|
@ -4,15 +4,22 @@ import com.arsdigita.cms.*;
|
|||
|
||||
object type Image extends ContentPage {
|
||||
|
||||
component ImageAsset[0..1] image = join ct_images.image_id to cms_images.image_id;
|
||||
String[0..1] caption = ct_images.caption VARCHAR(400);
|
||||
String[0..1] description = ct_images.description VARCHAR(2000);
|
||||
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);
|
||||
component ImageAsset[0..1] image = join ct_images.image_id to cms_images.image_id;
|
||||
component ImageAsset[0..1] thumbnail = join ct_images.thumbnail_id to cms_images.image_id;
|
||||
component TextAsset [0..1] textAsset = join ct_images.text_id to cms_text.text_id;
|
||||
|
||||
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);
|
||||
|
||||
reference key (ct_images.item_id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,13 @@
|
|||
descriptionBundle="com.arsdigita.cms.CMSResources"
|
||||
component="com.arsdigita.cms.contenttypes.ui.ImagePropertiesStep"/>
|
||||
|
||||
<ctd:authoring-step
|
||||
labelKey="cms.contenttypes.shared.body_text.title"
|
||||
labelBundle="com.arsdigita.cms.CMSResources"
|
||||
descriptionKey="cms.contenttypes.shared.body_text.description"
|
||||
descriptionBundle="com.arsdigita.cms.CMSResources"
|
||||
component="com.arsdigita.cms.contenttypes.ui.ImageTextBody"/>
|
||||
|
||||
<ctd:include href="/WEB-INF/content-types/assign-categories-step.xml"/>
|
||||
</ctd:authoring-kit>
|
||||
</ctd:content-type>
|
||||
|
|
|
|||
|
|
@ -7,7 +7,9 @@
|
|||
<xrd:formatter property="/object/publishDate"
|
||||
class="com.arsdigita.xml.formatters.DateFormatter"/>
|
||||
<xrd:associations rule="include">
|
||||
<xrd:property name="/object/thumbnail"/>
|
||||
<xrd:property name="/object/image"/>
|
||||
<xrd:property name="/object/textAsset"/>
|
||||
</xrd:associations>
|
||||
</xrd:adapter>
|
||||
</xrd:context>
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ package com.arsdigita.cms.contenttypes;
|
|||
|
||||
import com.arsdigita.cms.ContentPage;
|
||||
import com.arsdigita.cms.ImageAsset;
|
||||
import com.arsdigita.cms.TextAsset;
|
||||
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||
import com.arsdigita.domain.DomainObjectFactory;
|
||||
import com.arsdigita.persistence.DataObject;
|
||||
|
|
@ -36,11 +37,13 @@ import java.util.Date;
|
|||
public class Image extends ContentPage {
|
||||
|
||||
private final static org.apache.log4j.Logger s_log =
|
||||
org.apache.log4j.Logger.getLogger(GenericArticle.class);
|
||||
org.apache.log4j.Logger.getLogger(Image.class);
|
||||
/** PDL property name for lead */
|
||||
public static final String IMAGE = "image";
|
||||
// public static final String WIDTH = "width";
|
||||
// public static final String HEIGHT = "height";
|
||||
public static final String THUMBNAIL = "thumbnail";
|
||||
public static final String TEXT_ASSET = "textAsset";
|
||||
public static final String WIDTH = "width";
|
||||
public static final String HEIGHT = "height";
|
||||
public static final String CAPTION = "caption";
|
||||
public static final String DESCRIPTION = "description";
|
||||
public static final String ARTIST = "artist";
|
||||
|
|
@ -49,6 +52,8 @@ public class Image extends ContentPage {
|
|||
public static final String MEDIA = "media";
|
||||
public static final String COPYRIGHT = "copyright";
|
||||
public static final String SITE = "site";
|
||||
public static final String LICENSE = "license";
|
||||
protected static final int SUMMARY_SIZE = 1024;
|
||||
/** Data object type for this domain object */
|
||||
public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.cms.contenttypes.Image";
|
||||
private static final ImageConfig s_config = new ImageConfig();
|
||||
|
|
@ -59,11 +64,10 @@ public class Image extends ContentPage {
|
|||
s_log.debug("Static initalizer finished.");
|
||||
}
|
||||
|
||||
public static final ImageConfig getConfig() {
|
||||
public static ImageConfig getConfig() {
|
||||
return s_config;
|
||||
}
|
||||
|
||||
|
||||
public Image() {
|
||||
this(BASE_DATA_OBJECT_TYPE);
|
||||
}
|
||||
|
|
@ -97,6 +101,9 @@ public class Image extends ContentPage {
|
|||
|
||||
public void setImage(ImageAsset image) {
|
||||
set(IMAGE, image);
|
||||
setWidth(image.getWidth());
|
||||
setHeight(image.getHeight());
|
||||
setThumbnail();
|
||||
}
|
||||
|
||||
public String getCaption() {
|
||||
|
|
@ -107,6 +114,76 @@ public class Image extends ContentPage {
|
|||
set(CAPTION, caption);
|
||||
}
|
||||
|
||||
public ImageAsset getThumbnail() {
|
||||
DataObject dobj = (DataObject) get(THUMBNAIL);
|
||||
if (dobj != null) {
|
||||
return (ImageAsset) DomainObjectFactory.newInstance(dobj);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void setThumbnail() {
|
||||
try {
|
||||
set(THUMBNAIL, getImage().proportionalResizeToWidth(Image.getConfig().getMaxThumbnailWidth()));
|
||||
} catch (NullPointerException ex) {
|
||||
}
|
||||
}
|
||||
|
||||
public BigDecimal getWidth() {
|
||||
return (BigDecimal) get(WIDTH);
|
||||
}
|
||||
|
||||
private void setWidth(BigDecimal width) {
|
||||
set(WIDTH, width);
|
||||
}
|
||||
|
||||
public BigDecimal getHeight() {
|
||||
return (BigDecimal) get(HEIGHT);
|
||||
}
|
||||
|
||||
private void setHeight(BigDecimal height) {
|
||||
set(HEIGHT, height);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the text asset for this <code>Image</code>. Could return
|
||||
* null if there is no text body actually associated with the page
|
||||
*/
|
||||
public TextAsset getTextAsset() {
|
||||
DataObject text = (DataObject) get(TEXT_ASSET);
|
||||
if (text == null) {
|
||||
return null;
|
||||
} else {
|
||||
return new TextAsset(text);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Pass in a null value to remove the text of this item.
|
||||
* Explicitly call text.delete() to remove the text from the database
|
||||
*/
|
||||
public void setTextAsset(TextAsset text) {
|
||||
setAssociation(TEXT_ASSET, text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a short summary of the text body for search.
|
||||
* This method is WRONG, because the text body could actually
|
||||
* be extremely large, and doing substring on it is NOT safe
|
||||
*/
|
||||
@Override
|
||||
public String getSearchSummary() {
|
||||
TextAsset textAsset = getTextAsset();
|
||||
|
||||
if (textAsset == null) {
|
||||
return "";
|
||||
}
|
||||
return com.arsdigita.util.StringUtils.truncateString(textAsset.getText(),
|
||||
SUMMARY_SIZE,
|
||||
true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return (String) get(DESCRIPTION);
|
||||
|
|
@ -164,4 +241,12 @@ public class Image extends ContentPage {
|
|||
public void setSite(String site) {
|
||||
set(SITE, site);
|
||||
}
|
||||
|
||||
public String getLicense() {
|
||||
return (String) get(LICENSE);
|
||||
}
|
||||
|
||||
public void setLicense(String license) {
|
||||
set(LICENSE, license);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@ public class ImageConfig extends AbstractConfig {
|
|||
|
||||
private final Parameter m_startYear;
|
||||
private final Parameter m_endYearDelta;
|
||||
private final Parameter m_maxImageWidth;
|
||||
private final Parameter m_maxThumbnailWidth;
|
||||
|
||||
public ImageConfig() {
|
||||
m_startYear = new IntegerParameter(
|
||||
|
|
@ -40,8 +42,20 @@ public class ImageConfig extends AbstractConfig {
|
|||
Parameter.REQUIRED,
|
||||
new Integer(3));
|
||||
|
||||
m_maxImageWidth = new IntegerParameter(
|
||||
"com.arsdigita.cms.contenttypes.image.max_image_width",
|
||||
Parameter.REQUIRED,
|
||||
new Integer(600));
|
||||
|
||||
m_maxThumbnailWidth = new IntegerParameter(
|
||||
"com.arsdigita.cms.contenttypes.image.max_thumbnail_width",
|
||||
Parameter.REQUIRED,
|
||||
new Integer(150));
|
||||
|
||||
register(m_startYear);
|
||||
register(m_endYearDelta);
|
||||
register(m_maxImageWidth);
|
||||
register(m_maxThumbnailWidth);
|
||||
|
||||
loadInfo();
|
||||
}
|
||||
|
|
@ -53,4 +67,12 @@ public class ImageConfig extends AbstractConfig {
|
|||
public final int getEndYearDelta() {
|
||||
return ((Integer) get(m_endYearDelta)).intValue();
|
||||
}
|
||||
|
||||
public final int getMaxImageWidth() {
|
||||
return ((Integer) get(m_maxImageWidth)).intValue();
|
||||
}
|
||||
|
||||
public final int getMaxThumbnailWidth() {
|
||||
return ((Integer) get(m_maxThumbnailWidth)).intValue();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,3 +7,13 @@ com.arsdigita.cms.contenttypes.image.end_year_delta.title=End Year
|
|||
com.arsdigita.cms.contenttypes.image.end_year_delta.purpose=End year delta for the year select box
|
||||
com.arsdigita.cms.contenttypes.image.end_year_delta.example=3
|
||||
com.arsdigita.cms.contenttypes.image.end_year_delta.format=[integer]
|
||||
|
||||
com.arsdigita.cms.contenttypes.image.max_image_width.title=Max Image Width
|
||||
com.arsdigita.cms.contenttypes.image.max_image_width.purpose=max image display width for content center
|
||||
com.arsdigita.cms.contenttypes.image.max_image_width.example=600
|
||||
com.arsdigita.cms.contenttypes.image.max_image_width.format=[integer]
|
||||
|
||||
com.arsdigita.cms.contenttypes.image.max_image_width.title=Max thumbnail Width
|
||||
com.arsdigita.cms.contenttypes.image.max_image_width.purpose=max thumnail width
|
||||
com.arsdigita.cms.contenttypes.image.max_image_width.example=150
|
||||
com.arsdigita.cms.contenttypes.image.max_image_width.format=[integer]
|
||||
|
|
|
|||
|
|
@ -7,3 +7,6 @@ cms.contenttypes.ui.image.source=Source:
|
|||
cms.contenttypes.ui.image.media=Media:
|
||||
cms.contenttypes.ui.image.copyright=Copyright:
|
||||
cms.contenttypes.ui.image.site=Site:
|
||||
cms.contenttypes.ui.image.license=License:
|
||||
cms.contenttypes.ui.image.width=Width:
|
||||
cms.contenttypes.ui.image.height=Height:
|
||||
|
|
|
|||
|
|
@ -5,3 +5,6 @@ cms.contenttypes.ui.image.source=Quelle:
|
|||
cms.contenttypes.ui.image.media=Medium:
|
||||
cms.contenttypes.ui.image.copyright=Copyright:
|
||||
cms.contenttypes.ui.image.site=Standort:
|
||||
cms.contenttypes.ui.image.license=Lizenz:
|
||||
cms.contenttypes.ui.image.width=Breite:
|
||||
cms.contenttypes.ui.image.height=H\u00f6he:
|
||||
|
|
|
|||
|
|
@ -108,8 +108,12 @@ public class ImagePropertiesStep extends SimpleEditStep {
|
|||
|
||||
@Override
|
||||
protected ImageAsset getImageAsset(PageState state) {
|
||||
ImageAsset image = ((Image) itemModel.getSelectedItem(state)).getImage();
|
||||
return image;
|
||||
try {
|
||||
ImageAsset image = ((Image) itemModel.getSelectedItem(state)).getImage().proportionalResizeToWidth(Image.getConfig().getMaxImageWidth());
|
||||
return image;
|
||||
} catch (NullPointerException ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -122,6 +126,7 @@ public class ImagePropertiesStep extends SimpleEditStep {
|
|||
ContentPage.LAUNCH_DATE,
|
||||
new DomainObjectPropertySheet.AttributeFormatter() {
|
||||
|
||||
@Override
|
||||
public String format(DomainObject item,
|
||||
String attribute,
|
||||
PageState state) {
|
||||
|
|
@ -135,12 +140,15 @@ public class ImagePropertiesStep extends SimpleEditStep {
|
|||
});
|
||||
}
|
||||
|
||||
sheet.add(ImageGlobalizationUtil.globalize("cms.contenttypes.ui.image.width"), Image.WIDTH);
|
||||
sheet.add(ImageGlobalizationUtil.globalize("cms.contenttypes.ui.image.height"), Image.HEIGHT);
|
||||
sheet.add(ImageGlobalizationUtil.globalize("cms.contenttypes.ui.image.caption"), Image.CAPTION);
|
||||
sheet.add(ImageGlobalizationUtil.globalize("cms.contenttypes.ui.description"), Image.DESCRIPTION);
|
||||
sheet.add(ImageGlobalizationUtil.globalize("cms.contenttypes.ui.image.artist"), Image.ARTIST);
|
||||
sheet.add(ImageGlobalizationUtil.globalize("cms.contenttypes.ui.image.publishDate"), Image.PUBLISHDATE,
|
||||
new DomainObjectPropertySheet.AttributeFormatter() {
|
||||
|
||||
@Override
|
||||
public String format(DomainObject item, String attribute, PageState state) {
|
||||
Image image = (Image) item;
|
||||
if ((image.getPublishDate()) != null) {
|
||||
|
|
@ -154,6 +162,7 @@ public class ImagePropertiesStep extends SimpleEditStep {
|
|||
sheet.add(ImageGlobalizationUtil.globalize("cms.contenttypes.ui.image.media"), Image.MEDIA);
|
||||
sheet.add(ImageGlobalizationUtil.globalize("cms.contenttypes.ui.image.copyright"), Image.COPYRIGHT);
|
||||
sheet.add(ImageGlobalizationUtil.globalize("cms.contenttypes.ui.image.site"), Image.SITE);
|
||||
sheet.add(ImageGlobalizationUtil.globalize("cms.contenttypes.ui.image.license"), Image.LICENSE);
|
||||
|
||||
container.add(sheet);
|
||||
|
||||
|
|
@ -172,6 +181,7 @@ public class ImagePropertiesStep extends SimpleEditStep {
|
|||
|
||||
class ImageUploadListerner implements FormProcessListener {
|
||||
|
||||
@Override
|
||||
public void process(FormSectionEvent fse) {
|
||||
FormData data = fse.getFormData();
|
||||
PageState ps = fse.getPageState();
|
||||
|
|
@ -233,10 +243,12 @@ public class ImagePropertiesStep extends SimpleEditStep {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public SaveCancelSection getSaveCancelSection() {
|
||||
return m_saveCancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImageAsset getImage(FormSectionEvent event)
|
||||
throws FormProcessException {
|
||||
PageState ps = event.getPageState();
|
||||
|
|
@ -254,6 +266,7 @@ public class ImagePropertiesStep extends SimpleEditStep {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Form getForm() {
|
||||
return this;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ public class ImagePropertyForm
|
|||
|
||||
add(new Label(ImageGlobalizationUtil.globalize("cms.contenttypes.ui.description")));
|
||||
ParameterModel descriptionParam = new StringParameter(Image.DESCRIPTION);
|
||||
descriptionParam.addParameterListener(new StringInRangeValidationListener(0, 2000));
|
||||
descriptionParam.addParameterListener(new StringInRangeValidationListener(0, 500));
|
||||
TextArea description = new TextArea(descriptionParam);
|
||||
description.setRows(10);
|
||||
description.setCols(60);
|
||||
|
|
@ -133,9 +133,16 @@ public class ImagePropertyForm
|
|||
TextField site = new TextField(siteParam);
|
||||
add(site);
|
||||
|
||||
add(new Label(ImageGlobalizationUtil.globalize("cms.contenttypes.ui.image.license")));
|
||||
ParameterModel licenseParam = new StringParameter(Image.LICENSE);
|
||||
licenseParam.addParameterListener(new StringInRangeValidationListener(0, 300));
|
||||
TextField license = new TextField(licenseParam);
|
||||
add(license);
|
||||
|
||||
}
|
||||
|
||||
/** Form initialisation hook. Fills widgets with data. */
|
||||
@Override
|
||||
public void init(FormSectionEvent fse) {
|
||||
// Do some initialization hook stuff
|
||||
FormData data = fse.getFormData();
|
||||
|
|
@ -150,6 +157,7 @@ public class ImagePropertyForm
|
|||
data.put(Image.MEDIA, image.getMedia());
|
||||
data.put(Image.COPYRIGHT, image.getCopyright());
|
||||
data.put(Image.SITE, image.getSite());
|
||||
data.put(Image.LICENSE, image.getLicense());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -158,6 +166,7 @@ public class ImagePropertyForm
|
|||
}
|
||||
|
||||
/** Cancels streamlined editing. */
|
||||
@Override
|
||||
public void submitted(FormSectionEvent fse) {
|
||||
if (m_step != null
|
||||
&& getSaveCancelSection().getCancelButton().isSelected(fse.getPageState())) {
|
||||
|
|
@ -166,6 +175,7 @@ public class ImagePropertyForm
|
|||
}
|
||||
|
||||
/** Form processing hook. Saves Event object. */
|
||||
@Override
|
||||
public void process(FormSectionEvent fse) {
|
||||
FormData data = fse.getFormData();
|
||||
PageState ps = fse.getPageState();
|
||||
|
|
@ -182,6 +192,7 @@ public class ImagePropertyForm
|
|||
image.setMedia((String) data.get(Image.MEDIA));
|
||||
image.setCopyright((String) data.get(Image.COPYRIGHT));
|
||||
image.setSite((String) data.get(Image.SITE));
|
||||
image.setLicense((String) data.get(Image.LICENSE));
|
||||
|
||||
image.save();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@
|
|||
component="com.arsdigita.cms.contenttypes.ui.GenericArticlePropertiesStep"
|
||||
ordering="1"/>
|
||||
|
||||
<ctd:include href="/WEB-INF/content-types/edit-body-text-step.xml"/>
|
||||
|
||||
<ctd:include href="/WEB-INF/content-types/assign-categories-step.xml"/>
|
||||
</ctd:authoring-kit>
|
||||
</ctd:content-type>
|
||||
|
|
|
|||
|
|
@ -185,7 +185,7 @@ com.arsdigita.cms.search.score_title_and_keywords.format=[boolean]
|
|||
|
||||
com.arsdigita.cms.skip_asset_steps.title=Asset steps to skip
|
||||
com.arsdigita.cms.skip_asset_steps.purpose=Specify asset steps that are not relevant for specific content types
|
||||
com.arsdigita.cms.skip_asset_steps.example=com.arsdigita.cms.contenttypes.MultiPartArticle:com.arsdigita.cms.contenttypes.ui.ImageStep,com.arsdigita.cms.contenttypes.InlineSite:com.arsdigita.cms.contenttypes.ui.ImageStep,com.arsdigita.cms.InlineSite:om.arsdigita.cms.contentassets.ui.FileAttachmentsStep
|
||||
com.arsdigita.cms.skip_asset_steps.example=com.arsdigita.cms.contenttypes.MultiPartArticle:com.arsdigita.cms.contentassets.ui.ImageStep,com.arsdigita.cms.contenttypes.InlineSite:com.arsdigita.cms.contentassets.ui.ImageStep,com.arsdigita.cms.InlineSite:com.arsdigita.cms.contentassets.ui.FileAttachmentsStep,com.arsdigita.cms.contenttypes.Image:com.arsdigita.cms.contentassets.ui.ImageStep
|
||||
com.arsdigita.cms.skip_asset_steps.format=[string,string,string]
|
||||
|
||||
com.arsdigita.cms.mandatory_descriptions.title=Mandatory Descriptions
|
||||
|
|
|
|||
|
|
@ -30,11 +30,15 @@ import com.arsdigita.persistence.OID;
|
|||
import com.arsdigita.persistence.SessionManager;
|
||||
import com.arsdigita.versioning.VersionedACSObject;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import javax.imageio.ImageIO;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
|
|
@ -54,16 +58,14 @@ import org.apache.log4j.Logger;
|
|||
public class ImageAsset extends BinaryAsset {
|
||||
|
||||
public static final String BASE_DATA_OBJECT_TYPE =
|
||||
"com.arsdigita.cms.ImageAsset";
|
||||
|
||||
"com.arsdigita.cms.ImageAsset";
|
||||
public static final String CONTENT = "content";
|
||||
public static final String HEIGHT = "height";
|
||||
public static final String WIDTH = "width";
|
||||
|
||||
public static final String MIME_JPEG = "image/jpeg";
|
||||
public static final String MIME_GIF = "image/gif";
|
||||
private static final Logger s_log = Logger.getLogger(ImageAsset.class);
|
||||
|
||||
private static final Logger s_log = Logger.getLogger(ImageAsset.class);
|
||||
/**
|
||||
* Default constructor. This creates a new image asset.
|
||||
*/
|
||||
|
|
@ -133,6 +135,7 @@ public class ImageAsset extends BinaryAsset {
|
|||
*
|
||||
* @return the Blob content
|
||||
*/
|
||||
@Override
|
||||
protected byte[] getContent() {
|
||||
return (byte[]) get(CONTENT);
|
||||
}
|
||||
|
|
@ -140,6 +143,7 @@ public class ImageAsset extends BinaryAsset {
|
|||
/**
|
||||
* Sets the Blob content.
|
||||
*/
|
||||
@Override
|
||||
protected void setContent(byte[] content) {
|
||||
set(CONTENT, content);
|
||||
}
|
||||
|
|
@ -154,13 +158,13 @@ public class ImageAsset extends BinaryAsset {
|
|||
* @param defaultMimeType The default mime type for the file
|
||||
*/
|
||||
public void loadFromFile(String fileName, File file, String defaultMimeType)
|
||||
throws IOException {
|
||||
throws IOException {
|
||||
|
||||
// Guess mime type
|
||||
MimeType mime = MimeType.guessMimeTypeFromFile(fileName);
|
||||
|
||||
if(mime != null && mime instanceof ImageMimeType) {
|
||||
guessSize(file, (ImageMimeType)mime);
|
||||
if (mime != null && mime instanceof ImageMimeType) {
|
||||
guessSize(file, (ImageMimeType) mime);
|
||||
} else {
|
||||
// Set default mime type
|
||||
mime = MimeType.loadMimeType(defaultMimeType);
|
||||
|
|
@ -170,12 +174,12 @@ public class ImageAsset extends BinaryAsset {
|
|||
|
||||
// Extract the filename
|
||||
int i = fileName.lastIndexOf("/");
|
||||
if(i > 0) {
|
||||
fileName = fileName.substring(i+1);
|
||||
if (i > 0) {
|
||||
fileName = fileName.substring(i + 1);
|
||||
}
|
||||
i = fileName.lastIndexOf("\\"); // DOS-style
|
||||
if(i > 0) {
|
||||
fileName = fileName.substring(i+1);
|
||||
if (i > 0) {
|
||||
fileName = fileName.substring(i + 1);
|
||||
}
|
||||
|
||||
setName(fileName);
|
||||
|
|
@ -189,8 +193,9 @@ public class ImageAsset extends BinaryAsset {
|
|||
*
|
||||
* @param file The file on the server to write to.
|
||||
*/
|
||||
@Override
|
||||
public void writeToFile(File file)
|
||||
throws IOException {
|
||||
throws IOException {
|
||||
FileOutputStream fs = new FileOutputStream(file);
|
||||
try {
|
||||
fs.write(getContent());
|
||||
|
|
@ -202,7 +207,6 @@ public class ImageAsset extends BinaryAsset {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Guess image size by loading it from file. Set the WIDTH and HEIGHT
|
||||
* attributes, if possible
|
||||
|
|
@ -212,11 +216,11 @@ public class ImageAsset extends BinaryAsset {
|
|||
ImageSizer sizer = ImageSizerFactory.getImageSizer(mime.getMimeType());
|
||||
|
||||
try {
|
||||
if(sizer != null) {
|
||||
if (sizer != null) {
|
||||
Dimension d = sizer.computeImageSize(file);
|
||||
if(d != null) {
|
||||
width = new BigDecimal((int)d.getWidth());
|
||||
height = new BigDecimal((int)d.getHeight());
|
||||
if (d != null) {
|
||||
width = new BigDecimal((int) d.getWidth());
|
||||
height = new BigDecimal((int) d.getHeight());
|
||||
}
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
|
|
@ -234,9 +238,8 @@ public class ImageAsset extends BinaryAsset {
|
|||
* @return a collection of ImageAssets
|
||||
*/
|
||||
public static ImageAssetCollection getAllImages() {
|
||||
DataCollection da = SessionManager.getSession().retrieve
|
||||
(BASE_DATA_OBJECT_TYPE);
|
||||
da.addEqualsFilter(VersionedACSObject.IS_DELETED, new Integer(0));
|
||||
DataCollection da = SessionManager.getSession().retrieve(BASE_DATA_OBJECT_TYPE);
|
||||
da.addEqualsFilter(VersionedACSObject.IS_DELETED, new Integer(0));
|
||||
return new ImageAssetCollection(da);
|
||||
}
|
||||
|
||||
|
|
@ -249,8 +252,7 @@ public class ImageAsset extends BinaryAsset {
|
|||
* @return a collection of images whose name matches the keyword
|
||||
*/
|
||||
public static ImageAssetCollection getImagesByKeyword(
|
||||
String keyword, String context
|
||||
) {
|
||||
String keyword, String context) {
|
||||
ImageAssetCollection c = getAllImages();
|
||||
c.addOrder(Asset.NAME);
|
||||
Filter f;
|
||||
|
|
@ -271,4 +273,49 @@ public class ImageAsset extends BinaryAsset {
|
|||
return getImagesByKeyword(keyword, ContentItem.DRAFT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resize this ImageAsset proportional to maxThumbnailWidth, if this ImageAsset
|
||||
* is wider then maxThumbnailWidth. Else just return this ImageAsset.
|
||||
*
|
||||
* @param maxThumbnailWidth max image width
|
||||
* @return
|
||||
*/
|
||||
public ImageAsset proportionalResizeToWidth(int maxThumbnailWidth) {
|
||||
|
||||
if (this.getWidth().intValue() <= maxThumbnailWidth) {
|
||||
|
||||
return this;
|
||||
|
||||
} else {
|
||||
|
||||
ImageAsset imageAsset = new ImageAsset();
|
||||
imageAsset.setMimeType(this.getMimeType());
|
||||
imageAsset.setName("Scaled" + this.getName());
|
||||
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(this.getContent());
|
||||
try {
|
||||
BufferedImage origImage = ImageIO.read(in);
|
||||
|
||||
ByteArrayOutputStream scaledImageBuffer = new ByteArrayOutputStream();
|
||||
|
||||
java.awt.Image scaledImage = origImage.getScaledInstance(maxThumbnailWidth, -1, java.awt.Image.SCALE_SMOOTH);
|
||||
|
||||
BufferedImage scaledBufImage = new BufferedImage(scaledImage.getWidth(null), scaledImage.getHeight(null), origImage.getType());
|
||||
scaledBufImage.getGraphics().drawImage(scaledImage, 0, 0, null);
|
||||
|
||||
ImageIO.write(scaledBufImage, this.getMimeType().getFileExtension(), scaledImageBuffer);
|
||||
|
||||
imageAsset.setContent(scaledImageBuffer.toByteArray());
|
||||
imageAsset.setWidth(new BigDecimal(scaledImage.getWidth(null)));
|
||||
imageAsset.setHeight(new BigDecimal(scaledImage.getHeight(null)));
|
||||
|
||||
} catch (IOException e) {
|
||||
imageAsset.setContent(this.getContent());
|
||||
imageAsset.setWidth(this.getWidth());
|
||||
imageAsset.setHeight(this.getHeight());
|
||||
}
|
||||
|
||||
return imageAsset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,8 +48,8 @@ import com.arsdigita.util.Assert;
|
|||
*/
|
||||
public class GenericArticleBody extends TextAssetBody {
|
||||
|
||||
private AuthoringKitWizard m_parent;
|
||||
private ItemSelectionModel m_itemModel;
|
||||
protected AuthoringKitWizard m_parent;
|
||||
protected ItemSelectionModel m_itemModel;
|
||||
|
||||
/**
|
||||
* Construct a new GenericArticleBody component
|
||||
|
|
@ -68,6 +68,7 @@ public class GenericArticleBody extends TextAssetBody {
|
|||
|
||||
// Rest the component when it is hidden
|
||||
parent.getList().addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
PageState state = e.getPageState();
|
||||
reset(state);
|
||||
|
|
|
|||
Loading…
Reference in New Issue