diff --git a/ccm-cms-types-externallink/pdl/com/arsdigita/cms/contenttypes/ExternalLink.pdl b/ccm-cms-types-externallink/pdl/com/arsdigita/cms/contenttypes/ExternalLink.pdl index 93cf2e351..569801913 100644 --- a/ccm-cms-types-externallink/pdl/com/arsdigita/cms/contenttypes/ExternalLink.pdl +++ b/ccm-cms-types-externallink/pdl/com/arsdigita/cms/contenttypes/ExternalLink.pdl @@ -23,8 +23,8 @@ import com.arsdigita.cms.ContentPage; object type ExternalLink extends ContentPage { String [0..1] url = ct_extLinks.url VARCHAR(2000); String [0..1] comment = ct_extLinks.comment VARCHAR(4000); - String [0..1] showComment = ct_extLinks.show_comment VARCHAR(50); - String [0..1] targetWindow = ct_extLinks.target_window VARCHAR(50); + Boolean [0..1] showComment = ct_extLinks.show_comment; + Boolean [0..1] targetNewWindow = ct_extLinks.target_new_window; reference key (ct_extLinks.extLink_id); } diff --git a/ccm-cms-types-externallink/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/externallink-item.jsp b/ccm-cms-types-externallink/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/externallink-item.jsp index ce56c0cf2..b6c32beca 100644 --- a/ccm-cms-types-externallink/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/externallink-item.jsp +++ b/ccm-cms-types-externallink/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/externallink-item.jsp @@ -2,17 +2,29 @@ xmlns:define="/WEB-INF/bebop-define.tld" xmlns:show="/WEB-INF/bebop-show.tld" version="1.2"> - - - - + + + + CMSContext ctx = CMS.getContext(); if (ctx.hasContentItem()) { ExternalLink extLink = (ExternalLink) ctx.getContentItem(); String url = extLink.getURL(); - if (url != null && url.length() > 0) { + if (url != null && !(url.isEmpty()) + && !(extLink.getShowComment())) { response.sendRedirect(url); } } - + + + + + + + + diff --git a/ccm-cms-types-externallink/src/com/arsdigita/cms/contenttypes/ExternalLink.java b/ccm-cms-types-externallink/src/com/arsdigita/cms/contenttypes/ExternalLink.java index 459deafef..ebe1f95ee 100644 --- a/ccm-cms-types-externallink/src/com/arsdigita/cms/contenttypes/ExternalLink.java +++ b/ccm-cms-types-externallink/src/com/arsdigita/cms/contenttypes/ExternalLink.java @@ -45,7 +45,7 @@ public class ExternalLink extends ContentPage { /** PDL property showComment */ public static final String SHOW_COMMENT = "showComment"; /** PDL property targetWindow */ - public static final String TARGET_WINDOW = "targetWindow"; + public static final String TARGET_WINDOW = "targetNewWindow"; /** * Data object type for this domain object @@ -152,8 +152,8 @@ public class ExternalLink extends ContentPage { * * @return the value weather the comment will be shown */ - public String getShowComment() { - return (String) get(SHOW_COMMENT); + public Boolean getShowComment() { + return (Boolean) get(SHOW_COMMENT); } /** @@ -161,7 +161,7 @@ public class ExternalLink extends ContentPage { * * @param show The value weather the comment should be shown. */ - public void setShowComment(final String show) { + public void setShowComment(final Boolean show) { set(SHOW_COMMENT, show); } @@ -170,8 +170,8 @@ public class ExternalLink extends ContentPage { * * @return The Target Window */ - public String getTargetWindow() { - return (String) get(TARGET_WINDOW); + public Boolean getTargetNewWindow() { + return (Boolean) get(TARGET_WINDOW); } /** @@ -179,7 +179,7 @@ public class ExternalLink extends ContentPage { * * @param window The Target Window */ - public void setTargetWindow(String window) { + public void setTargetNewWindow(Boolean window) { set(TARGET_WINDOW, window); } } \ No newline at end of file diff --git a/ccm-cms-types-externallink/src/com/arsdigita/cms/contenttypes/ui/ExternalLinkPropertiesStep.java b/ccm-cms-types-externallink/src/com/arsdigita/cms/contenttypes/ui/ExternalLinkPropertiesStep.java index f9a132e14..40975b78c 100644 --- a/ccm-cms-types-externallink/src/com/arsdigita/cms/contenttypes/ui/ExternalLinkPropertiesStep.java +++ b/ccm-cms-types-externallink/src/com/arsdigita/cms/contenttypes/ui/ExternalLinkPropertiesStep.java @@ -30,9 +30,9 @@ import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess; import com.arsdigita.toolbox.ui.DomainObjectPropertySheet; /** - * Authoring step to view/edit the simple attributes of the - * ExternalLink content type (and its subclasses). - * + * Authoring step to view/edit the simple attributes of the ExternalLink content + * type (and its subclasses). + * * @author Tobias Osmers * @version $Revision: #1 $ $Date: 2015/02/22 $ */ @@ -49,8 +49,8 @@ public class ExternalLinkPropertiesStep extends SimpleEditStep { * @param itemModel * @param parent */ - public ExternalLinkPropertiesStep(final ItemSelectionModel itemModel, - final AuthoringKitWizard parent) { + public ExternalLinkPropertiesStep(final ItemSelectionModel itemModel, + final AuthoringKitWizard parent) { super(itemModel, parent); final BasicPageForm editSheet = new ExternalLinkPropertyForm(itemModel); @@ -63,36 +63,45 @@ public class ExternalLinkPropertiesStep extends SimpleEditStep { } /** - * Returns a component that displays the properties of the ExternalLink + * Returns a component that displays the properties of the ExternalLink * content item specified by the ItemSelectionModel passed in. * * @param itemModel The ItemSelectionModel to use * * @pre itemModel != null - * @return A component to display the state of the basic properties of the release + * @return A component to display the state of the basic properties of the + * release * - * Method add deprecated, use add(GlobalizedMessage label, String attribute) instead (but - * probably Camden doesn't use globalized strings). + * Method add deprecated, use add(GlobalizedMessage label, String attribute) + * instead (but probably Camden doesn't use globalized strings). */ - public static Component getExternalLinkPropertySheet(final ItemSelectionModel itemModel) { + public static Component getExternalLinkPropertySheet( + final ItemSelectionModel itemModel) { - final DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(itemModel); + final DomainObjectPropertySheet sheet = new DomainObjectPropertySheet( + itemModel); sheet.add(ExternalLinkGlobalizationUtil.globalize( - "cms.contenttypes.externallink.name"), ExternalLink.NAME); + "cms.contenttypes.externallink.name"), ExternalLink.NAME); sheet.add(ExternalLinkGlobalizationUtil.globalize( - "cms.contenttypes.externallink.title"), ExternalLink.TITLE); + "cms.contenttypes.externallink.title"), ExternalLink.TITLE); sheet.add(ExternalLinkGlobalizationUtil.globalize( - "cms.contenttypes.externallink.description"), ExternalLink.DESCRIPTION); + "cms.contenttypes.externallink.description"), + ExternalLink.DESCRIPTION); sheet.add(ExternalLinkGlobalizationUtil.globalize( - "cms.contenttypes.externallink.location"), ExternalLink.URL); + "cms.contenttypes.externallink.location"), + ExternalLink.URL); sheet.add(ExternalLinkGlobalizationUtil.globalize( - "cms.contenttypes.externallink.comment"), ExternalLink.COMMENT); + "cms.contenttypes.externallink.comment"), + ExternalLink.COMMENT); sheet.add(ExternalLinkGlobalizationUtil.globalize( - "cms.contenttypes.externallink.show_comment"), ExternalLink.SHOW_COMMENT); + "cms.contenttypes.externallink.show_comment"), + ExternalLink.SHOW_COMMENT); sheet.add(ExternalLinkGlobalizationUtil.globalize( - "cms.contenttypes.externallink.target_window"), ExternalLink.TARGET_WINDOW); + "cms.contenttypes.externallink.target_window"), + ExternalLink.TARGET_WINDOW); return sheet; } + } diff --git a/ccm-cms-types-externallink/src/com/arsdigita/cms/contenttypes/ui/ExternalLinkPropertyForm.java b/ccm-cms-types-externallink/src/com/arsdigita/cms/contenttypes/ui/ExternalLinkPropertyForm.java index b804a41e8..b55cf8e28 100644 --- a/ccm-cms-types-externallink/src/com/arsdigita/cms/contenttypes/ui/ExternalLinkPropertyForm.java +++ b/ccm-cms-types-externallink/src/com/arsdigita/cms/contenttypes/ui/ExternalLinkPropertyForm.java @@ -40,17 +40,17 @@ import com.arsdigita.cms.ui.authoring.BasicPageForm; * Used by ExternalLinkPropertiesStep authoring kit step. *
* This form can be extended to create forms for ExternalLink subclasses. - * + * * @author Tobias Osmers * @version $Revision: #1 $ $Date: 2015/02/22 $ */ public class ExternalLinkPropertyForm extends BasicPageForm - implements FormProcessListener, FormInitListener { + implements FormProcessListener, FormInitListener { /** * Name of this form */ - public static final String ID = "externallinkform_edit"; + public static final String ID = "externallinkform_edit"; // formerly "externalLinkEdit" private TextArea description; @@ -59,11 +59,11 @@ public class ExternalLinkPropertyForm extends BasicPageForm private CheckboxGroup showCommentCheckBox, targetWindowCheckBox; /** - * Creates a new form to edit the ExternalLink object specified by the - * item selection model passed in. + * Creates a new form to edit the ExternalLink object specified by the item + * selection model passed in. * - * @param itemModel The ItemSelectionModel to use to obtain the - * ExternalLink to work on + * @param itemModel The ItemSelectionModel to use to obtain the ExternalLink + * to work on */ public ExternalLinkPropertyForm(final ItemSelectionModel itemModel) { super(ID, itemModel); @@ -77,43 +77,41 @@ public class ExternalLinkPropertyForm extends BasicPageForm super.addWidgets(); description = new TextArea(new TrimmedStringParameter( - ContentPage.DESCRIPTION), 5, 40, TextArea.SOFT); + ContentPage.DESCRIPTION), 5, 40, TextArea.SOFT); description.setLabel(ExternalLinkGlobalizationUtil.globalize( - "cms.contenttypes.externallink.description")); + "cms.contenttypes.externallink.description")); description.setHint(ExternalLinkGlobalizationUtil.globalize( - "cms.contenttypes.externallink.description_hint")); + "cms.contenttypes.externallink.description_hint")); add(description); - - + url = new TextField(new TrimmedStringParameter(ExternalLink.URL)); url.setLabel(ExternalLinkGlobalizationUtil.globalize( - "cms.contenttypes.externallink.location")); + "cms.contenttypes.externallink.location")); url.setHint(ExternalLinkGlobalizationUtil.globalize( - "cms.contenttypes.externallink.location_hint")); + "cms.contenttypes.externallink.location_hint")); url.setSize(40); add(url); - - + comment = new TextArea(new TrimmedStringParameter( - ExternalLink.COMMENT), 5, 40, TextArea.SOFT); + ExternalLink.COMMENT), 5, 40, TextArea.SOFT); comment.setLabel(ExternalLinkGlobalizationUtil.globalize( - "cms.contenttypes.externallink.comment")); + "cms.contenttypes.externallink.comment")); comment.setHint(ExternalLinkGlobalizationUtil.globalize( - "cms.contenttypes.externallink.comment_hint")); + "cms.contenttypes.externallink.comment_hint")); add(comment); - - - Option showComment = new Option(ExternalLink.SHOW_COMMENT, - new Label(ExternalLinkGlobalizationUtil.globalize( - "cms.contenttypes.externallink.show_comment"))); + + Option showComment = new Option(ExternalLink.SHOW_COMMENT, + new Label(ExternalLinkGlobalizationUtil + .globalize( + "cms.contenttypes.externallink.show_comment"))); showCommentCheckBox = new CheckboxGroup("showCommentCheckBox"); showCommentCheckBox.addOption(showComment); add(showCommentCheckBox); - - + Option targetWindow = new Option(ExternalLink.TARGET_WINDOW, - new Label(ExternalLinkGlobalizationUtil.globalize( - "cms.contenttypes.externallink.target_window"))); + new Label(ExternalLinkGlobalizationUtil + .globalize( + "cms.contenttypes.externallink.target_window"))); targetWindowCheckBox = new CheckboxGroup("targetWindowCheckBox"); targetWindowCheckBox.addOption(targetWindow); add(targetWindowCheckBox); @@ -132,16 +130,19 @@ public class ExternalLinkPropertyForm extends BasicPageForm description.setValue(state, extLink.getDescription()); url.setValue(state, extLink.getURL()); comment.setValue(state, extLink.getComment()); - String showComment = ExternalLinkGlobalizationUtil.globalize( - "cms.contenttypes.externallink.yes").localize().equals( - extLink.getShowComment()) ? - extLink.SHOW_COMMENT : null; - showCommentCheckBox.setValue(state, showComment); - String newWindow = ExternalLinkGlobalizationUtil.globalize( - "cms.contenttypes.externallink.yes").localize().equals( - extLink.getTargetWindow()) ? - extLink.TARGET_WINDOW : null; - targetWindowCheckBox.setValue(state, newWindow); + if (extLink.getShowComment()) { + showCommentCheckBox.setValue( + state, new String[]{ExternalLink.SHOW_COMMENT}); + } else { + showCommentCheckBox.setValue(state, null); + } + + if (extLink.getTargetNewWindow()) { + targetWindowCheckBox.setValue( + state, new String[]{ExternalLink.TARGET_WINDOW}); + } else { + targetWindowCheckBox.setValue(state, null); + } } /** @@ -151,12 +152,13 @@ public class ExternalLinkPropertyForm extends BasicPageForm */ @Override public void process(final FormSectionEvent fse) { - final ExternalLink extLink = (ExternalLink) super.processBasicWidgets(fse); + final ExternalLink extLink = (ExternalLink) super.processBasicWidgets( + fse); final PageState state = fse.getPageState(); // save only if save button was pressed - if (extLink != null && - getSaveCancelSection().getSaveButton().isSelected(state)) { + if (extLink != null && getSaveCancelSection().getSaveButton() + .isSelected(state)) { extLink.setDescription((String) description.getValue(state)); extLink.setURL((String) url.getValue(state)); extLink.setComment((String) comment.getValue(state)); @@ -164,29 +166,22 @@ public class ExternalLinkPropertyForm extends BasicPageForm boolean showComment = false; String[] value = (String[]) showCommentCheckBox.getValue(state); if (value != null) { - showComment = extLink.SHOW_COMMENT.equals(value[0]); - } - if (showComment) { - extLink.setShowComment((String) ExternalLinkGlobalizationUtil.globalize( - "cms.contenttypes.externallink.yes").localize()); - } else { - extLink.setShowComment((String) ExternalLinkGlobalizationUtil.globalize( - "cms.contenttypes.externallink.no").localize()); + showComment = ExternalLink.SHOW_COMMENT.equals(value[0]); } + + extLink.setShowComment(showComment); + // Process whether the external link will be opened in a new // window - boolean newWindow = false; + boolean newWindow = false; value = (String[]) targetWindowCheckBox.getValue(state); if (value != null) { - newWindow = extLink.TARGET_WINDOW.equals(value[0]); - } - if (newWindow) { - extLink.setTargetWindow((String) ExternalLinkGlobalizationUtil.globalize( - "cms.contenttypes.externallink.yes").localize()); - } else { - extLink.setTargetWindow((String) ExternalLinkGlobalizationUtil.globalize( - "cms.contenttypes.externallink.no").localize()); + newWindow = ExternalLink.TARGET_WINDOW.equals(value[0]); } + + extLink.setTargetNewWindow(newWindow); + } } + } diff --git a/ccm-core/web/themes/foundry/foundry/lib/template-tags/content-items.xsl b/ccm-core/web/themes/foundry/foundry/lib/template-tags/content-items.xsl index 3ec026974..648b42baa 100644 --- a/ccm-core/web/themes/foundry/foundry/lib/template-tags/content-items.xsl +++ b/ccm-core/web/themes/foundry/foundry/lib/template-tags/content-items.xsl @@ -33,6 +33,7 @@ + diff --git a/ccm-core/web/themes/foundry/foundry/lib/template-tags/content-items/external-link.xsl b/ccm-core/web/themes/foundry/foundry/lib/template-tags/content-items/external-link.xsl new file mode 100644 index 000000000..d91ced243 --- /dev/null +++ b/ccm-core/web/themes/foundry/foundry/lib/template-tags/content-items/external-link.xsl @@ -0,0 +1,159 @@ + + + + + + Tags for ccm-cms-types-externallink + +

+ Tags for displaying the special properties of a ExternalLink +

+
+
+ + + +

+ Checks if the external link has a description and applies the + enclosed tags if there is one. +

+
+
+ + + + + + + + + + +

+ Output the description of an ExternalLink. +

+
+
+ + + + + + + + +

+ Checks if the showComment property of the + ExternalLink is true and if there is a comment + text. If both conditions are true the enclosed tags + are applied. +

+
+
+ + + + + + + + + + +

+ Outputs the comment text. +

+
+
+ + + + + + + + +

+ Checks if the targetNewWindow property of the + ExternalLink is set to true indicating that the + link should be opened in a new windows. This can be used to + integrate an JavaScript into the HTML for opening the new + window. +

+
+
+ + + + + + + + + + + + + + + + + + +

+ Puts the URL of the ExternalLink into the environment. +

+
+
+ + + + + + + + + + + +
+ + + +
+
+ +
\ No newline at end of file diff --git a/ccm-core/web/themes/foundry/foundry/lib/template-tags/html-tags.xsl b/ccm-core/web/themes/foundry/foundry/lib/template-tags/html-tags.xsl index 5108f8685..314fe84ab 100644 --- a/ccm-core/web/themes/foundry/foundry/lib/template-tags/html-tags.xsl +++ b/ccm-core/web/themes/foundry/foundry/lib/template-tags/html-tags.xsl @@ -90,6 +90,12 @@ type
The media type of the link target.
+
+ target +
+
+ The target window/frame for the link. +
@@ -184,6 +190,10 @@ select="foundry:get-static-text('', ./@title-static)"/> + + + +