diff --git a/ccm-cms-publicpersonalprofile/application.xml b/ccm-cms-publicpersonalprofile/application.xml index b9eb19387..afea353f3 100644 --- a/ccm-cms-publicpersonalprofile/application.xml +++ b/ccm-cms-publicpersonalprofile/application.xml @@ -5,21 +5,22 @@ version="6.6.1" release="1" webapp="ROOT"> - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + Aggreates informations about a SciMember item. - + diff --git a/ccm-cms-publicpersonalprofile/src/ccm-cms-publicpersonalprofile.config b/ccm-cms-publicpersonalprofile/src/ccm-cms-publicpersonalprofile.config index 6c7222f2a..e94e0634f 100644 --- a/ccm-cms-publicpersonalprofile/src/ccm-cms-publicpersonalprofile.config +++ b/ccm-cms-publicpersonalprofile/src/ccm-cms-publicpersonalprofile.config @@ -1,7 +1,5 @@ - + storage="ccm-cms-publicpersonalprofile/profiles.properties"/> diff --git a/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/PublicPersonalProfile.java b/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/PublicPersonalProfile.java index ad9ed98e3..d6feb5c44 100644 --- a/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/PublicPersonalProfile.java +++ b/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/PublicPersonalProfile.java @@ -18,9 +18,11 @@ */ package com.arsdigita.cms.contenttypes; +import com.arsdigita.bebop.PageState; import com.arsdigita.cms.ContentPage; import com.arsdigita.cms.ExtraXMLGenerator; import com.arsdigita.cms.publicpersonalprofile.ContentGenerator; +import com.arsdigita.cms.publicpersonalprofile.PublicPersonalProfileConfig; import com.arsdigita.domain.DataObjectNotFoundException; import java.math.BigDecimal; import com.arsdigita.persistence.OID; @@ -44,13 +46,16 @@ import java.util.List; * @author Jens Pelzetter * @version $Id$ */ -public class PublicPersonalProfile extends ContentPage { +public class PublicPersonalProfile + extends ContentPage + implements CustomizedPreviewLink { + private static final PublicPersonalProfileConfig config = PublicPersonalProfileConfig.getConfig(); public static final String OWNER = "owner"; - public static final String PROFILE_URL = "profileUrl"; + public static final String PROFILE_URL = "profileUrl"; public static final String LINK_LIST_NAME = "publicPersonalProfileNavItems"; public static final String BASE_DATA_OBJECT_TYPE = - "com.arsdigita.cms.contenttypes.PublicPersonalProfile"; + "com.arsdigita.cms.contenttypes.PublicPersonalProfile"; public PublicPersonalProfile() { this(BASE_DATA_OBJECT_TYPE); @@ -117,7 +122,7 @@ public class PublicPersonalProfile extends ContentPage { * * @return The URL fragment of the profile used to build the URL of the * profile. - + */ public String getProfileUrl() { return (String) get(PROFILE_URL); @@ -126,7 +131,7 @@ public class PublicPersonalProfile extends ContentPage { public void setProfileUrl(String profileUrl) { set(PROFILE_URL, profileUrl); } - + /** * The profile has an extra XML Generator, which is primarily to render * the items and the navigation of the profile for the embedded view. @@ -136,9 +141,17 @@ public class PublicPersonalProfile extends ContentPage { @Override public List getExtraXMLGenerators() { final List generators = super.getExtraXMLGenerators(); - + generators.add(new PublicPersonalProfileExtraXmlGenerator()); - + return generators; } + + public String getPreviewUrl(final PageState state) { + if(config.getEmbedded()) { + return null; + } else { + return String.format("/profiles/preview/%s/", getProfileUrl()); + } + } } diff --git a/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/PublicPersonalProfileConfig.java b/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/PublicPersonalProfileConfig.java deleted file mode 100644 index 24025b34d..000000000 --- a/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/PublicPersonalProfileConfig.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2011 Jens Pelzetter - * - * 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.cms.contenttypes; - -import com.arsdigita.runtime.AbstractConfig; -import com.arsdigita.util.parameter.BooleanParameter; -import com.arsdigita.util.parameter.StringParameter; -import com.arsdigita.util.parameter.Parameter; - -/** - * - * @author Jens Pelzetter - * @version $Id$ - */ -public class PublicPersonalProfileConfig extends AbstractConfig { - - private final Parameter showUnfinishedParts; - private final Parameter personType; - - public PublicPersonalProfileConfig() { - showUnfinishedParts = - new BooleanParameter( - "com.arsdigita.cms.contenttypes.PublicPersonalProfile.show_unfinished_parts", - Parameter.REQUIRED, - Boolean.FALSE); - personType = - new StringParameter( - "com.arsdigita.cms.contenttypes.PublicPersonalProfile.person_type", - Parameter.REQUIRED, - "com.arsdigita.cms.contenttypes.GenericPerson"); - - register(showUnfinishedParts); - register(personType); - - loadInfo(); - } - - public final boolean getShowUnFinishedParts() { - return (Boolean) get(showUnfinishedParts); - } - - public final String getPersonType() { - return (String) get(personType); - } -} diff --git a/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/PublicPersonalProfileConfig_parameter.properties b/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/PublicPersonalProfileConfig_parameter.properties deleted file mode 100644 index 616d6c6f1..000000000 --- a/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/PublicPersonalProfileConfig_parameter.properties +++ /dev/null @@ -1,9 +0,0 @@ -com.arsdigita.cms.contenttypes.PublicPersonalProfile.show_unfinished_parts.title = Show parts of the PublicPersonalProfile which do not work yet. -com.arsdigita.cms.contenttypes.PublicPersonalProfile.show_unfinished_parts.purpose = Show parts of the PublicPersonalProfile which do not work yet. -com.arsdigita.cms.contenttypes.PublicPersonalProfile.show_unfinished_parts.example = false -com.arsdigita.cms.contenttypes.PublicPersonalProfile.show_unfinished_parts.format = [boolean] - -com.arsdigita.cms.contenttypes.PublicPersonalProfile.person_type.title = Class to restrict the selectable persons to. -com.arsdigita.cms.contenttypes.PublicPersonalProfile.person_type.purpose = Class to restrict the selectable persons to. -com.arsdigita.cms.contenttypes.PublicPersonalProfile.person_type.example = com.arsdigita.cms.contenttypes.GenericPerson -com.arsdigita.cms.contenttypes.PublicPersonalProfile.person_type.format = [string] \ No newline at end of file diff --git a/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/PublicPersonalProfileExtraXmlGenerator.java b/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/PublicPersonalProfileExtraXmlGenerator.java index a4d9c5a8a..ef5aac036 100644 --- a/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/PublicPersonalProfileExtraXmlGenerator.java +++ b/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/PublicPersonalProfileExtraXmlGenerator.java @@ -6,6 +6,7 @@ import com.arsdigita.cms.ContentItem; import com.arsdigita.cms.ExtraXMLGenerator; import com.arsdigita.cms.contentassets.RelatedLink; import com.arsdigita.cms.publicpersonalprofile.ContentGenerator; +import com.arsdigita.cms.publicpersonalprofile.PublicPersonalProfileConfig; import com.arsdigita.cms.publicpersonalprofile.PublicPersonalProfileXmlGenerator; import com.arsdigita.dispatcher.DispatcherHelper; import com.arsdigita.domain.DomainObjectFactory; @@ -22,6 +23,9 @@ import java.lang.reflect.InvocationTargetException; */ public class PublicPersonalProfileExtraXmlGenerator implements ExtraXMLGenerator { + private static final PublicPersonalProfileConfig config = + PublicPersonalProfileConfig. + getConfig(); public static final String SHOW_ITEM_PARAM = "showItem"; public void generateXML(final ContentItem item, @@ -35,14 +39,19 @@ public class PublicPersonalProfileExtraXmlGenerator implements ExtraXMLGenerator final PublicPersonalProfile profile = (PublicPersonalProfile) item; final String showItem = state.getRequest().getParameter(SHOW_ITEM_PARAM); - final Element navigation = element.newChildElement("profileNavigation"); - final PublicPersonalProfileXmlUtil util = - new PublicPersonalProfileXmlUtil(); - String prefix = DispatcherHelper.getDispatcherPrefix(state.getRequest()); - if (prefix == null) { - prefix = ""; + if (config.getEmbedded()) { + final Element navigation = element.newChildElement( + "profileNavigation"); + final PublicPersonalProfileXmlUtil util = + new PublicPersonalProfileXmlUtil(); + String prefix = DispatcherHelper.getDispatcherPrefix(state. + getRequest()); + if (prefix == null) { + prefix = ""; + } + util.createNavigation(profile, navigation, showItem, prefix, "", + false); } - util.createNavigation(profile, navigation, showItem, prefix, "", false); if ((showItem != null) && !showItem.trim().isEmpty()) { final Element profileContent = element.newChildElement( diff --git a/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/PublicPersonalProfileXmlUtil.java b/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/PublicPersonalProfileXmlUtil.java index 9f73d5376..dd0de681d 100644 --- a/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/PublicPersonalProfileXmlUtil.java +++ b/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/PublicPersonalProfileXmlUtil.java @@ -1,7 +1,7 @@ package com.arsdigita.cms.contenttypes; import com.arsdigita.cms.contentassets.RelatedLink; -import com.arsdigita.cms.publicpersonalprofile.PublicPersonalProfiles; +import com.arsdigita.cms.publicpersonalprofile.PublicPersonalProfileConfig; import com.arsdigita.dispatcher.DispatcherHelper; import com.arsdigita.domain.DomainObjectFactory; import com.arsdigita.persistence.DataCollection; @@ -17,8 +17,7 @@ import java.util.Map; public class PublicPersonalProfileXmlUtil { private final com.arsdigita.cms.publicpersonalprofile.PublicPersonalProfileConfig config = - PublicPersonalProfiles. - getConfig(); + PublicPersonalProfileConfig.getConfig(); public void createNavigation(final PublicPersonalProfile profile, final Element root, diff --git a/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/ui/PublicPersonalProfileCreate.java b/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/ui/PublicPersonalProfileCreate.java index 6dce49521..56c6f8344 100644 --- a/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/ui/PublicPersonalProfileCreate.java +++ b/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/ui/PublicPersonalProfileCreate.java @@ -24,7 +24,7 @@ import com.arsdigita.cms.Folder; import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.contenttypes.GenericPerson; import com.arsdigita.cms.contenttypes.PublicPersonalProfile; -import com.arsdigita.cms.contenttypes.PublicPersonalProfileConfig; +import com.arsdigita.cms.publicpersonalprofile.PublicPersonalProfileConfig; import com.arsdigita.cms.ui.authoring.ApplyWorkflowFormSection; import com.arsdigita.cms.ui.authoring.CreationSelector; import com.arsdigita.cms.ui.authoring.LanguageWidget; @@ -48,12 +48,8 @@ public class PublicPersonalProfileCreate extends PageCreate { private static final String SELECTED_PERSON = "selectedPerson"; private static final PublicPersonalProfileConfig config = - new PublicPersonalProfileConfig(); - - static { - config.load(); - } - + PublicPersonalProfileConfig.getConfig(); + public PublicPersonalProfileCreate(final ItemSelectionModel itemModel, final CreationSelector parent) { super(itemModel, parent); diff --git a/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/publicpersonalprofile/PublicPersonalProfileConfig.java b/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/publicpersonalprofile/PublicPersonalProfileConfig.java index dfba6cc21..6547d366f 100644 --- a/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/publicpersonalprofile/PublicPersonalProfileConfig.java +++ b/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/publicpersonalprofile/PublicPersonalProfileConfig.java @@ -12,11 +12,29 @@ import com.arsdigita.util.parameter.StringParameter; */ public class PublicPersonalProfileConfig extends AbstractConfig { + private final static PublicPersonalProfileConfig config = new PublicPersonalProfileConfig(); + private final Parameter personType; + private final Parameter embedded; private final Parameter homeNavItemLabels; private final Parameter showPersonInfoEverywhere; // private final Parameter contactType; + + static { + config.load(); + } public PublicPersonalProfileConfig() { + personType = + new StringParameter( + "com.arsdigita.cms.publicPersonalProfile.person_type", + Parameter.REQUIRED, + "com.arsdigita.cms.contenttypes.GenericPerson"); + + embedded = new BooleanParameter( + "com.arsdigita.cms.publicpersonalprofile.embedded", + Parameter.REQUIRED, + false); + homeNavItemLabels = new StringParameter( "com.arsdigita.cms.publicpersonalprofile.navitem.home.labels", Parameter.REQUIRED, @@ -33,6 +51,8 @@ public class PublicPersonalProfileConfig extends AbstractConfig { Parameter.REQUIRED, "commonContact");*/ + register(personType); + register(embedded); register(homeNavItemLabels); register(showPersonInfoEverywhere); // register(contactType); @@ -40,6 +60,14 @@ public class PublicPersonalProfileConfig extends AbstractConfig { loadInfo(); } + public final String getPersonType() { + return (String) get(personType); + } + + public final Boolean getEmbedded() { + return (Boolean) get(embedded); + } + public final String getHomeNavItemLabels() { return (String) get(homeNavItemLabels); } @@ -50,4 +78,8 @@ public class PublicPersonalProfileConfig extends AbstractConfig { /* public final String getContactType() { return (String) get(contactType); }*/ + + public static PublicPersonalProfileConfig getConfig() { + return config; + } } diff --git a/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/publicpersonalprofile/PublicPersonalProfileConfig_parameter.properties b/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/publicpersonalprofile/PublicPersonalProfileConfig_parameter.properties index 4c4717615..c8c4fc27d 100644 --- a/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/publicpersonalprofile/PublicPersonalProfileConfig_parameter.properties +++ b/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/publicpersonalprofile/PublicPersonalProfileConfig_parameter.properties @@ -1,3 +1,13 @@ +com.arsdigita.cms.contenttypes.PublicPersonalProfile.person_type.title = Class to restrict the selectable persons to. +com.arsdigita.cms.contenttypes.PublicPersonalProfile.person_type.purpose = Class to restrict the selectable persons to. +com.arsdigita.cms.contenttypes.PublicPersonalProfile.person_type.example = com.arsdigita.cms.contenttypes.GenericPerson +com.arsdigita.cms.contenttypes.PublicPersonalProfile.person_type.format = [string] + +com.arsdigita.cms.publicpersonalprofile.embedded.title = Embedded Mode +com.arsdigita.cms.publicpersonalprofile.embedded.purpose = If set the true the personal profiles are shown embedded into the normal web page. +com.arsdigita.cms.publicpersonalprofile.embedded.example = false +com.arsdigita.cms.publicpersonalprofile.embedded.format = [Boolean] + com.arsdigita.cms.publicpersonalprofile.navitem.home.labels.title = The labels for the home link of a profile com.arsdigita.cms.publicpersonalprofile.navitem.home.labels.purpose = The labels for the home link of a profile com.arsdigita.cms.publicpersonalprofile.navitem.home.labels.example = en:Home,de:Start diff --git a/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/publicpersonalprofile/PublicPersonalProfiles.java b/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/publicpersonalprofile/PublicPersonalProfiles.java index 16e6cacd0..1e414c37e 100644 --- a/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/publicpersonalprofile/PublicPersonalProfiles.java +++ b/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/publicpersonalprofile/PublicPersonalProfiles.java @@ -15,13 +15,8 @@ public class PublicPersonalProfiles extends Application { public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.cms.publicpersonalprofile.PublicPersonalProfile"; - private final static PublicPersonalProfileConfig config = - new PublicPersonalProfileConfig(); - - static { - config.load(); - } - + private final static PublicPersonalProfileConfig config = PublicPersonalProfileConfig.getConfig(); + public PublicPersonalProfiles(final DataObject dobj) { super(dobj); } @@ -36,10 +31,6 @@ public class PublicPersonalProfiles extends Application { this(new OID(BASE_DATA_OBJECT_TYPE, id)); } - public static PublicPersonalProfileConfig getConfig() { - return config; - } - @Override public String getServletPath() { return "/profiles/"; diff --git a/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/publicpersonalprofile/PublicPersonalProfilesServlet.java b/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/publicpersonalprofile/PublicPersonalProfilesServlet.java index 6a70285f5..0b72e072e 100644 --- a/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/publicpersonalprofile/PublicPersonalProfilesServlet.java +++ b/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/publicpersonalprofile/PublicPersonalProfilesServlet.java @@ -10,6 +10,8 @@ import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.ParameterSingleSelectionModel; import com.arsdigita.bebop.parameters.StringParameter; import com.arsdigita.cms.ContentItem; +import com.arsdigita.cms.ContentSection; +import com.arsdigita.cms.contentassets.ItemImageAttachment; import com.arsdigita.cms.contentassets.RelatedLink; import com.arsdigita.cms.contenttypes.GenericAddress; import com.arsdigita.cms.contenttypes.GenericContact; @@ -20,6 +22,8 @@ import com.arsdigita.cms.contenttypes.GenericPersonContactCollection; import com.arsdigita.cms.contenttypes.PublicPersonalProfile; import com.arsdigita.cms.contenttypes.PublicPersonalProfileNavItemCollection; import com.arsdigita.cms.contenttypes.PublicPersonalProfileXmlUtil; +import com.arsdigita.cms.dispatcher.CMSDispatcher; +import com.arsdigita.cms.dispatcher.ItemResolver; import com.arsdigita.cms.publicpersonalprofile.ui.PublicPersonalProfileNavItemsAddForm; import com.arsdigita.dispatcher.DispatcherHelper; import com.arsdigita.domain.DomainObjectFactory; @@ -32,6 +36,7 @@ import com.arsdigita.templating.Templating; import com.arsdigita.toolbox.ui.ApplicationAuthenticationListener; import com.arsdigita.web.Application; import com.arsdigita.web.BaseApplicationServlet; +import com.arsdigita.web.RedirectSignal; import com.arsdigita.xml.Document; import com.arsdigita.xml.Element; import java.io.IOException; @@ -58,7 +63,8 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet { private static final String PPP_NS = "http://www.arsdigita.com/PublicPersonalProfile/1.0"; public static final String SELECTED_NAV_ITEM = "selectedNavItem"; - private final PublicPersonalProfileConfig config = PublicPersonalProfiles. + private final PublicPersonalProfileConfig config = + PublicPersonalProfileConfig. getConfig(); @Override @@ -168,6 +174,28 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet { PublicPersonalProfile profile = (PublicPersonalProfile) DomainObjectFactory. newInstance(profiles.getDataObject()); + + if (config.getEmbedded()) { + final ContentSection section = + profile.getContentSection(); + final ItemResolver resolver = section.getItemResolver(); + + String context; + if (preview) { + context = CMSDispatcher.PREVIEW; + } else { + context = ContentItem.LIVE; + } + + final String url = String.format("/ccm%s", resolver. + generateItemURL(state, + profile, + section, + context)); + + throw new RedirectSignal(url, false); + } + Element profileElem = root.newChildElement("ppp:profile", PPP_NS); GenericPerson owner = profile.getOwner(); @@ -178,7 +206,17 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet { Element profileOwnerName = profileElem.newChildElement( "ppp:ownerName", PPP_NS); profileOwnerName.setText(owner.getFullName()); - + + final DataCollection images = ItemImageAttachment.getImageAttachments(profile); + if (!images.isEmpty()) { + images.next(); + final Element imageElem = profileElem.newChildElement("profileImage"); + ItemImageAttachment attachment = new ItemImageAttachment(images.getDataObject()); + //imageElem.addAttribute("oid", attachment.getImage().getOID().toString()); + + images.close(); + } + final PublicPersonalProfileXmlUtil util = new PublicPersonalProfileXmlUtil(); String prefix = diff --git a/ccm-cms/src/com/arsdigita/cms/ui/ContentItemPage.java b/ccm-cms/src/com/arsdigita/cms/ui/ContentItemPage.java index 783f98cc2..48dc95231 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/ContentItemPage.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/ContentItemPage.java @@ -43,6 +43,7 @@ import com.arsdigita.cms.ContentType; import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.PageLocations; import com.arsdigita.cms.Template; +import com.arsdigita.cms.contenttypes.CustomizedPreviewLink; import com.arsdigita.cms.dispatcher.CMSDispatcher; import com.arsdigita.cms.dispatcher.CMSPage; import com.arsdigita.cms.dispatcher.ItemResolver; @@ -76,9 +77,7 @@ import org.apache.log4j.Logger; */ public class ContentItemPage extends CMSPage implements ActionListener { - private static final Logger s_log = Logger.getLogger - (ContentItemPage.class); - + private static final Logger s_log = Logger.getLogger(ContentItemPage.class); /** * The URL parameter that must be passed in in order to set * the current tab. This is a KLUDGE right now because the @@ -86,19 +85,16 @@ public class ContentItemPage extends CMSPage implements ActionListener { * state parameter */ public static final String SET_TAB = "set_tab"; - /** * The name of the global state parameter that holds * the item id */ public static final String ITEM_ID = "item_id"; - /** * The name of the global state parameter which holds the * return URL */ public static final String RETURN_URL = "return_url"; - /** * The name of the global state parameter that determines whether * or not to use the streamlined authoring process (assuming the @@ -109,12 +105,10 @@ public class ContentItemPage extends CMSPage implements ActionListener { public static final String STREAMLINED_CREATION_ACTIVE = "active"; public static final String STREAMLINED_CREATION_INACTIVE = "active"; private static int s_tabOrder = 0; - /** * Index of the summary tab */ public static final int SUMMARY_TAB = s_tabOrder++; - /** *

The name of the state parameter which indicates the content * type of the item the user wishes to create. or edit.

@@ -123,20 +117,17 @@ public class ContentItemPage extends CMSPage implements ActionListener { * the id of the content type.

*/ public static final String CONTENT_TYPE = "content_type"; - public static final int AUTHORING_TAB = s_tabOrder++; public static final int LANGUAGE_TAB = s_tabOrder++; public static final int WORKFLOW_TAB = s_tabOrder++; public static final int PUBLISHING_TAB = s_tabOrder++; public static final int HISTORY_TAB = s_tabOrder++; public static final int TEMPLATES_TAB = s_tabOrder++; - private final TabbedPane m_tabbedPane; private StringParameter m_returnURL; private ItemSelectionModel m_itemModel; private ACSObjectSelectionModel m_typeModel; private ContentItemRequestLocal m_item; - private Summary m_summaryPane; private ItemWorkflowAdminPane m_workflowPane; private ItemLifecycleAdminPane m_lifecyclePane; @@ -144,16 +135,17 @@ public class ContentItemPage extends CMSPage implements ActionListener { private ItemLanguages m_languagesPane; private ItemRevisionAdminPane m_revisionsPane; private ItemTemplates m_templatesPane; - private Link m_previewLink; private class ItemRequestLocal extends ContentItemRequestLocal { + protected final Object initialValue(final PageState state) { return CMS.getContext().getContentItem(); } } private class TitlePrinter implements PrintListener { + public final void prepare(final PrintEvent e) { final Label label = (Label) e.getTarget(); final ContentItem item = m_item.getContentItem(e.getPageState()); @@ -180,25 +172,26 @@ public class ContentItemPage extends CMSPage implements ActionListener { m_itemModel = new ItemSelectionModel(itemId); // Add the content type global state parameter - BigDecimalParameter contentType = new BigDecimalParameter - (CONTENT_TYPE); + BigDecimalParameter contentType = new BigDecimalParameter(CONTENT_TYPE); addGlobalStateParam(contentType); // Add the streamlined creation global state parameter - StringParameter streamlinedCreation = new StringParameter - (STREAMLINED_CREATION); + StringParameter streamlinedCreation = new StringParameter( + STREAMLINED_CREATION); addGlobalStateParam(streamlinedCreation); - m_typeModel = new ACSObjectSelectionModel - (ContentType.class.getName(), ContentType.BASE_DATA_OBJECT_TYPE, contentType); + m_typeModel = new ACSObjectSelectionModel(ContentType.class.getName(), + ContentType.BASE_DATA_OBJECT_TYPE, + contentType); // Validate the item ID parameter (caches the validation). getStateModel().addValidationListener(new FormValidationListener() { - public void validate(FormSectionEvent event) - throws FormProcessException { - validateItemID(event.getPageState()); - } - }); + + public void validate(FormSectionEvent event) + throws FormProcessException { + validateItemID(event.getPageState()); + } + }); // Add the return url global state parameter m_returnURL = new StringParameter(RETURN_URL); @@ -222,40 +215,41 @@ public class ContentItemPage extends CMSPage implements ActionListener { m_tabbedPane.setIdAttr("page-body"); - m_tabbedPane.addTab - (new Label(gz("cms.ui.item.summary")), m_summaryPane); - m_tabbedPane.addTab - (new Label(gz("cms.ui.item.authoring")), m_wizardPane); - m_tabbedPane.addTab - (new Label(gz("cms.ui.item.languages")), m_languagesPane); - m_tabbedPane.addTab - (new Label(gz("cms.ui.item.workflow")), m_workflowPane); - m_tabbedPane.addTab - (new Label(gz("cms.ui.item.lifecycles")), m_lifecyclePane); - m_tabbedPane.addTab - (new Label(gz("cms.ui.item.history")), m_revisionsPane); - m_tabbedPane.addTab - (new Label(gz("cms.ui.item.templates")), m_templatesPane); + m_tabbedPane.addTab(new Label(gz("cms.ui.item.summary")), m_summaryPane); + m_tabbedPane.addTab(new Label(gz("cms.ui.item.authoring")), m_wizardPane); + m_tabbedPane.addTab(new Label(gz("cms.ui.item.languages")), + m_languagesPane); + m_tabbedPane.addTab(new Label(gz("cms.ui.item.workflow")), + m_workflowPane); + m_tabbedPane.addTab(new Label(gz("cms.ui.item.lifecycles")), + m_lifecyclePane); + m_tabbedPane.addTab(new Label(gz("cms.ui.item.history")), + m_revisionsPane); + m_tabbedPane.addTab(new Label(gz("cms.ui.item.templates")), + m_templatesPane); m_tabbedPane.addActionListener(new ActionListener() { - public final void actionPerformed(final ActionEvent e) { - final PageState state = e.getPageState(); - final Component pane = m_tabbedPane.getCurrentPane(state); - if (pane instanceof Resettable) { - ((Resettable) pane).reset(state); - } + public final void actionPerformed(final ActionEvent e) { + final PageState state = e.getPageState(); + final Component pane = m_tabbedPane.getCurrentPane(state); + + if (pane instanceof Resettable) { + ((Resettable) pane).reset(state); } - }); + } + }); // Build the preview link. - m_previewLink = new Link(new Label(gz("cms.ui.preview")), new PrintListener() { - public final void prepare(final PrintEvent e) { - final Link link = (Link) e.getTarget(); - link.setTarget(getPreviewURL(e.getPageState())); - link.setTargetFrame(Link.NEW_FRAME); - } - }); + m_previewLink = new Link(new Label(gz("cms.ui.preview")), + new PrintListener() { + + public final void prepare(final PrintEvent e) { + final Link link = (Link) e.getTarget(); + link.setTarget(getPreviewURL(e.getPageState())); + link.setTargetFrame(Link.NEW_FRAME); + } + }); m_previewLink.setIdAttr("preview_link"); add(m_previewLink); @@ -263,18 +257,19 @@ public class ContentItemPage extends CMSPage implements ActionListener { // Add validation to make sure we are not attempting to edit a live item getStateModel().addValidationListener(new FormValidationListener() { - public void validate(FormSectionEvent e) throws FormProcessException { - PageState s = e.getPageState(); - FormData data = e.getFormData(); - final ContentItem item = m_item.getContentItem(s); - if(item != null && ContentItem.LIVE.equals(item.getVersion())) { - String err = "The item " + item.getID() + - " is live and cannot be edited."; - // data.addError(err); - throw new FormProcessException(err); - } + + public void validate(FormSectionEvent e) throws FormProcessException { + PageState s = e.getPageState(); + FormData data = e.getFormData(); + final ContentItem item = m_item.getContentItem(s); + if (item != null && ContentItem.LIVE.equals(item.getVersion())) { + String err = "The item " + item.getID() + + " is live and cannot be edited."; + // data.addError(err); + throw new FormProcessException(err); } - }); + } + }); add(new DebugPanel()); } @@ -291,9 +286,8 @@ public class ContentItemPage extends CMSPage implements ActionListener { final ContentItem item = m_item.getContentItem(state); if (item == null) { - throw new FormProcessException - ("The item_id supplied does not reference a valid " + - "ContentItem."); + throw new FormProcessException("The item_id supplied does not reference a valid " + + "ContentItem."); } } @@ -340,8 +334,9 @@ public class ContentItemPage extends CMSPage implements ActionListener { m_tabbedPane.setTabVisible(state, m_languagesPane, false); m_previewLink.setVisible(state, false); } else { - m_tabbedPane.setTabVisible(state, m_templatesPane, !ContentSection.getConfig().getHideTemplatesTab()); - } + m_tabbedPane.setTabVisible(state, m_templatesPane, !ContentSection. + getConfig().getHideTemplatesTab()); + } // Set the current tab based on parameters if (setTab != null) { @@ -372,6 +367,7 @@ public class ContentItemPage extends CMSPage implements ActionListener { int tab) { return getItemURL(nodeURL, itemId, tab, false); } + /** * Construct a URL for displaying a certain item * @@ -386,14 +382,14 @@ public class ContentItemPage extends CMSPage implements ActionListener { boolean streamlinedCreation) { StringBuffer url = new StringBuffer(); - url.append(nodeURL) - .append(PageLocations.ITEM_PAGE) - .append("?").append(ITEM_ID).append("=").append(itemId.toString()) - .append("&").append(SET_TAB).append("=").append(tab); + url.append(nodeURL).append(PageLocations.ITEM_PAGE).append("?").append( + ITEM_ID).append("=").append(itemId.toString()).append("&"). + append(SET_TAB).append("=").append(tab); - if (streamlinedCreation && - ContentSection.getConfig().getUseStreamlinedCreation()) { - url.append("&").append(STREAMLINED_CREATION).append("=").append(STREAMLINED_CREATION_ACTIVE); + if (streamlinedCreation && ContentSection.getConfig(). + getUseStreamlinedCreation()) { + url.append("&").append(STREAMLINED_CREATION).append("=").append( + STREAMLINED_CREATION_ACTIVE); } return url.toString(); @@ -401,9 +397,8 @@ public class ContentItemPage extends CMSPage implements ActionListener { public static String getRelativeItemURL(BigDecimal itemId, int tab) { StringBuffer url = new StringBuffer(); - url.append("item.jsp") - .append("?").append(ITEM_ID).append("=").append(itemId.toString()) - .append("&").append(SET_TAB).append("=").append(tab); + url.append("item.jsp").append("?").append(ITEM_ID).append("=").append(itemId. + toString()).append("&").append(SET_TAB).append("=").append(tab); return url.toString(); } @@ -432,8 +427,9 @@ public class ContentItemPage extends CMSPage implements ActionListener { * @param tab The index of the tab to display */ public static String getItemURL(BigDecimal itemId, int tab) { - final ContentItem item = (ContentItem) DomainObjectFactory.newInstance - (new OID(ContentItem.BASE_DATA_OBJECT_TYPE, itemId)); + final ContentItem item = + (ContentItem) DomainObjectFactory.newInstance(new OID( + ContentItem.BASE_DATA_OBJECT_TYPE, itemId)); if (item == null) { return null; @@ -452,7 +448,7 @@ public class ContentItemPage extends CMSPage implements ActionListener { try { String returnURL = (String) state.getValue(m_returnURL); state.getResponse().sendRedirect(returnURL); - } catch(IOException e) { + } catch (IOException e) { s_log.error("IO Error redirecting back", e); // do nothing } @@ -462,9 +458,27 @@ public class ContentItemPage extends CMSPage implements ActionListener { * Fetch the preview URL. */ private String getPreviewURL(PageState state) { - ContentItem item = m_item.getContentItem(state); - ContentSection section = getContentSection(state); - ItemResolver itemResolver = section.getItemResolver(); + final ContentItem item = m_item.getContentItem(state); + + if (item instanceof CustomizedPreviewLink) { + final String previewLink = ((CustomizedPreviewLink) item). + getPreviewUrl( + state); + if ((previewLink == null) || previewLink.isEmpty()) { + return getDefaultPreviewLink(state, item); + } else { + return previewLink; + } + } else { + return getDefaultPreviewLink(state, item); + } + } + + private String getDefaultPreviewLink(final PageState state, + final ContentItem item) { + final ContentSection section = CMS.getContext().getContentSection(); + //ContentSection section = getContentSection(state); + final ItemResolver itemResolver = section.getItemResolver(); // Pass in the "Live" context since we need it for the preview return itemResolver.generateItemURL(state, item, section, @@ -480,8 +494,8 @@ public class ContentItemPage extends CMSPage implements ActionListener { } public static boolean isStreamlinedCreationActive(PageState state) { - return ContentSection.getConfig().getUseStreamlinedCreation() && - STREAMLINED_CREATION_ACTIVE.equals - (state.getRequest().getParameter(STREAMLINED_CREATION)); + return ContentSection.getConfig().getUseStreamlinedCreation() + && STREAMLINED_CREATION_ACTIVE.equals(state.getRequest(). + getParameter(STREAMLINED_CREATION)); } }