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
parent
a4a9ae414a
commit
4425bfd8df
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,9 +10,21 @@
|
|||
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);
|
||||
}
|
||||
}
|
||||
</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>
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -30,8 +30,8 @@ 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 $
|
||||
|
|
@ -69,30 +69,39 @@ public class ExternalLinkPropertiesStep extends SimpleEditStep {
|
|||
* @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);
|
||||
sheet.add(ExternalLinkGlobalizationUtil.globalize(
|
||||
"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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
@ -84,7 +84,6 @@ public class ExternalLinkPropertyForm extends BasicPageForm
|
|||
"cms.contenttypes.externallink.description_hint"));
|
||||
add(description);
|
||||
|
||||
|
||||
url = new TextField(new TrimmedStringParameter(ExternalLink.URL));
|
||||
url.setLabel(ExternalLinkGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.externallink.location"));
|
||||
|
|
@ -93,7 +92,6 @@ public class ExternalLinkPropertyForm extends BasicPageForm
|
|||
url.setSize(40);
|
||||
add(url);
|
||||
|
||||
|
||||
comment = new TextArea(new TrimmedStringParameter(
|
||||
ExternalLink.COMMENT), 5, 40, TextArea.SOFT);
|
||||
comment.setLabel(ExternalLinkGlobalizationUtil.globalize(
|
||||
|
|
@ -102,17 +100,17 @@ public class ExternalLinkPropertyForm extends BasicPageForm
|
|||
"cms.contenttypes.externallink.comment_hint"));
|
||||
add(comment);
|
||||
|
||||
|
||||
Option showComment = new Option(ExternalLink.SHOW_COMMENT,
|
||||
new Label(ExternalLinkGlobalizationUtil.globalize(
|
||||
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(
|
||||
new Label(ExternalLinkGlobalizationUtil
|
||||
.globalize(
|
||||
"cms.contenttypes.externallink.target_window")));
|
||||
targetWindowCheckBox = new CheckboxGroup("targetWindowCheckBox");
|
||||
targetWindowCheckBox.addOption(targetWindow);
|
||||
|
|
@ -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;
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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"/>
|
||||
|
|
|
|||
|
|
@ -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) > 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) > 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>
|
||||
|
|
@ -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"/>
|
||||
|
|
|
|||
Loading…
Reference in New Issue