ccm-cms-types-externallink:

- Some enhancements
    - Foundry now supports ExternalLink


git-svn-id: https://svn.libreccm.org/ccm/trunk@3505 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2015-06-26 11:29:05 +00:00
parent a4a9ae414a
commit 4425bfd8df
8 changed files with 277 additions and 91 deletions

View File

@ -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);
}

View File

@ -2,17 +2,29 @@
xmlns:define="/WEB-INF/bebop-define.tld"
xmlns:show="/WEB-INF/bebop-show.tld"
version="1.2">
<jsp:directive.page import="com.arsdigita.cms.contenttypes.ExternalLink"/>
<jsp:directive.page import="com.arsdigita.cms.CMS"/>
<jsp:directive.page import="com.arsdigita.cms.CMSContext"/>
<jsp:scriptlet>
<jsp:directive.page import="com.arsdigita.cms.contenttypes.ExternalLink"/>
<jsp:directive.page import="com.arsdigita.cms.CMS"/>
<jsp:directive.page import="com.arsdigita.cms.CMSContext"/>
<jsp:scriptlet>
CMSContext ctx = CMS.getContext();
if (ctx.hasContentItem()) {
ExternalLink extLink = (ExternalLink) ctx.getContentItem();
String url = extLink.getURL();
if (url != null &amp;&amp; url.length() &gt; 0) {
if (url != null &amp;&amp; !(url.isEmpty())
&amp;&amp; !(extLink.getShowComment())) {
response.sendRedirect(url);
}
}
</jsp:scriptlet>
</jsp:scriptlet>
<define:page name="itemPage"
application="content"
title="CMS"
cache="true">
<define:component name="itemXML"
classname="com.arsdigita.cms.dispatcher.ContentPanel"/>
</define:page>
<show:all/>
</jsp:root>

View File

@ -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);
}
}

View File

@ -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 <tosmers@uni-bremen.de>
* @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;
}
}

View File

@ -40,17 +40,17 @@ import com.arsdigita.cms.ui.authoring.BasicPageForm;
* Used by <code>ExternalLinkPropertiesStep</code> authoring kit step.
* <br />
* This form can be extended to create forms for ExternalLink subclasses.
*
*
* @author Tobias Osmers <tosmers@uni-bremen.de>
* @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);
}
}
}

View File

@ -33,6 +33,7 @@
<xsl:import href="content-items/bookmark.xsl"/>
<xsl:import href="content-items/contact.xsl"/>
<xsl:import href="content-items/decisiontree.xsl"/>
<xsl:import href="content-items/external-link.xsl"/>
<xsl:import href="content-items/event.xsl"/>
<xsl:import href="content-items/generic-orgaunit.xsl"/>
<xsl:import href="content-items/formitem.xsl"/>

View File

@ -0,0 +1,159 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2014 Jens Pelzetter for the LibreCCM Foundation
This file is part of the Foundry Theme Engine for LibreCCM
Foundry is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
Foundry 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with Foundry If not, see <http://www.gnu.org/licenses/>.
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:bebop="http://www.arsdigita.com/bebop/1.0"
xmlns:cms="http://www.arsdigita.com/cms/1.0"
xmlns:foundry="http://foundry.libreccm.org"
xmlns:nav="http://ccm.redhat.com/navigation"
xmlns:ui="http://www.arsdigita.com/ui/1.0"
exclude-result-prefixes="xsl xs bebop cms foundry nav ui"
version="2.0">
<foundry:doc-file>
<foundry:doc-title>Tags for ccm-cms-types-externallink</foundry:doc-title>
<foundry:doc-file-desc>
<p>
Tags for displaying the special properties of a ExternalLink
</p>
</foundry:doc-file-desc>
</foundry:doc-file>
<foundry:doc section="user" type="template-tag">
<foundry:doc-desc>
<p>
Checks if the external link has a description and applies the
enclosed tags if there is one.
</p>
</foundry:doc-desc>
</foundry:doc>
<xsl:template match="/content-item-layout//if-extlink-description">
<xsl:param name="contentitem-tree" tunnel="yes"/>
<xsl:if test="string-length($contentitem-tree/pageDescription) &gt; 0">
<xsl:apply-templates/>
</xsl:if>
</xsl:template>
<foundry:doc section="user" type="template-tag">
<foundry:doc-desc>
<p>
Output the description of an ExternalLink.
</p>
</foundry:doc-desc>
</foundry:doc>
<xsl:template match="/content-item-layout//show-extlink-description">
<xsl:param name="contentitem-tree" tunnel="yes"/>
<xsl:value-of disable-output-escaping="yes"
select="$contentitem-tree/pageDescription"/>
</xsl:template>
<foundry:doc section="user" type="template-tag">
<foundry:doc-desc>
<p>
Checks if the <code>showComment</code> property of the
ExternalLink is <code>true</code> and if there is a comment
text. If both conditions are <code>true</code> the enclosed tags
are applied.
</p>
</foundry:doc-desc>
</foundry:doc>
<xsl:template match="/content-item-layout//if-extlink-comment">
<xsl:param name="contentitem-tree" tunnel="yes"/>
<xsl:if test="foundry:boolean($contentitem-tree/showComment)
and string-length($contentitem-tree/comment) &gt; 0">
<xsl:apply-templates/>
</xsl:if>
</xsl:template>
<foundry:doc section="user" type="template-tag">
<foundry:doc-desc>
<p>
Outputs the comment text.
</p>
</foundry:doc-desc>
</foundry:doc>
<xsl:template match="/content-item-layout//show-extlink-comment">
<xsl:param name="contentitem-tree" tunnel="yes"/>
<xsl:value-of disable-output-escaping="yes"
select="$contentitem-tree/comment"/>
</xsl:template>
<foundry:doc section="user" type="template-tag">
<foundry:doc-desc>
<p>
Checks if the <code>targetNewWindow</code> property of the
ExternalLink is set to <code>true</code> 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.
</p>
</foundry:doc-desc>
</foundry:doc>
<xsl:template match="/content-item-layout//if-extlink-new-window">
<xsl:param name="contentitem-tree" tunnel="yes"/>
<xsl:if test="foundry:boolean($contentitem-tree/targetNewWindow)">
<xsl:apply-templates/>
</xsl:if>
</xsl:template>
<xsl:template match="/content-item-layout//if-extlink-not-new-window">
<xsl:param name="contentitem-tree" tunnel="yes"/>
<xsl:if test="not(foundry:boolean($contentitem-tree/targetNewWindow))">
<xsl:apply-templates/>
</xsl:if>
</xsl:template>
<foundry:doc section="user" type="template-tag">
<foundry:doc-desc>
<p>
Puts the URL of the ExternalLink into the environment.
</p>
</foundry:doc-desc>
</foundry:doc>
<xsl:template match="/content-item-layout//extlink-target-url">
<xsl:param name="contentitem-tree" tunnel="yes"/>
<xsl:apply-templates>
<xsl:with-param name="href"
tunnel="yes"
select="$contentitem-tree/url"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="/content-item-layout//extlink-data">
<xsl:param name="contentitem-tree" tunnel="yes"/>
<div>
<xsl:attribute name="id" select="'extlink-data'"/>
<xsl:attribute name="data-new-window"
select="$contentitem-tree/targetNewWindow"/>
<xsl:attribute name="data-url"
select="$contentitem-tree/url"/>
</div>
</xsl:template>
</xsl:stylesheet>

View File

@ -90,6 +90,12 @@
<code>type</code>
</dt>
<dd>The media type of the link target.</dd>
<dt>
<code>target</code>
</dt>
<dd>
The target window/frame for the link.
</dd>
</dl>
</foundry:doc-desc>
<foundry:doc-attributes>
@ -184,6 +190,10 @@
select="foundry:get-static-text('', ./@title-static)"/>
</xsl:when>
</xsl:choose>
<xsl:if test="./@target">
<xsl:attribute name="target" select="./@target"/>
</xsl:if>
<xsl:call-template name="foundry:process-layouttree-attributes">
<xsl:with-param name="id" select="$id"/>
<xsl:with-param name="class" select="$class"/>