incorporating APLAWS patch:

r1663 | chrisg23 | 2007-09-19 10:23:54 +0200 (Mi, 19 Sep 2007) 

Add association between image and link. Changes have no effect by themselves, but if the ccm-wsx-image-link-step module in contrib is loaded then the default image step is replaced with an asset step UI for associating the article image with one of the related links defined for the article. This change requires upgrade script to be run: ccm upgrade ccm-ldn-image-step --from-version 6.5.0 --to-version 6.5.1


git-svn-id: https://svn.libreccm.org/ccm/trunk@27 8810af33-2d31-482b-a856-94f89814c4df
master
pb 2008-02-15 18:53:06 +00:00
parent fcd00bdf1b
commit 00da3505ae
7 changed files with 73 additions and 1 deletions

View File

@ -2,7 +2,7 @@
<ccm:application xmlns:ccm="http://ccm.redhat.com/ccm-project"
name="ccm-ldn-image-step"
prettyName="Image step"
version="6.5.0"
version="6.5.1"
release="1"
webapp="ROOT">
<ccm:dependencies>

View File

@ -9,6 +9,7 @@ object type ItemImageAttachment extends ACSObject {
String[0..1] caption = cms_item_image_attachment.caption VARCHAR( 100 );
String[0..1] title = cms_item_image_attachment.title VARCHAR( 200 );
String[0..1] description = cms_item_image_attachment.description VARCHAR( 4000 );
component Link[0..1] imageLink = join cms_item_image_attachment.link_id to cms_links.link_id;
composite ReusableImageAsset[0..1] image
= join cms_item_image_attachment.image_id to cms_images.image_id;

View File

@ -0,0 +1,25 @@
--
-- Copyright (C) 2005 Chris Gilbert. 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
--
alter table cms_item_image_attachment add (link_id NUMBER);
alter table cms_item_image_attachment add
constraint cms_ite_ima_att_lin_id_f_eeymm foreign key (link_id)
references cms_links(link_id);

View File

@ -0,0 +1,4 @@
PROMPT ImageStep 6.5.0 -> 6.5.1 Upgrade Script (Oracle)
@@ ../default/upgrade/6.5.0-6.5.1/add_link_column.sql

View File

@ -0,0 +1,7 @@
\echo ImageStep 6.5.0 -> 6.5.1 Upgrade Script (PostgreSQL)
begin;
\i ../default/upgrade/6.5.0-6.5.1/add_link_column.sql
commit;

View File

@ -5,4 +5,7 @@
<version from="6.2.0" to="6.2.1">
<script sql="ccm-ldn-image-step/upgrade/::database::-6.2.0-6.2.1.sql"/>
</version>
<version from="6.5.0" to="6.5.1">
<script sql="ccm-ldn-image-step/upgrade/::database::-6.5.0-6.5.1.sql"/>
</version>
</upgrade>

View File

@ -23,8 +23,10 @@ import com.arsdigita.cms.CustomCopy;
import com.arsdigita.cms.ItemImageAttachmentConfig;
import com.arsdigita.cms.ItemCopier;
import com.arsdigita.cms.ReusableImageAsset;
import com.arsdigita.domain.DomainObject;
import com.arsdigita.domain.DomainObjectFactory;
import com.arsdigita.kernel.ACSObject;
import com.arsdigita.persistence.DataAssociation;
import com.arsdigita.persistence.DataCollection;
import com.arsdigita.persistence.DataObject;
import com.arsdigita.persistence.OID;
@ -47,6 +49,7 @@ public class ItemImageAttachment extends ACSObject implements CustomCopy {
public static final String TITLE = "title";
public static final String IMAGE_ATTACHMENTS = "imageAttachments";
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
@ -191,4 +194,33 @@ public class ItemImageAttachment extends ACSObject implements CustomCopy {
return false;
}
// chris gilbert - optional link
public Link getLink() {
Link link = null;
DataObject dobj = (DataObject) get( IMAGE_LINK );
if (dobj != null) {
link = (Link) DomainObjectFactory.newInstance( dobj );
}
return link;
}
public void setLink( Link link ) {
Assert.exists( link, Link.class );
set( IMAGE_LINK, link );
}
public void removeLink() {
// 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));
set (IMAGE_LINK, null);
save();
link.delete();
}
}