- Weitere Ergänzungen an den Übersetzungen

- Parameterisierbarer (Related)Link


git-svn-id: https://svn.libreccm.org/ccm/trunk@632 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2010-11-24 20:41:51 +00:00
parent 7bcd95ef54
commit 9d4315b042
8 changed files with 191 additions and 95 deletions

View File

@ -90,14 +90,12 @@ public class RelatedLinkPropertyForm extends LinkPropertyForm {
add(new Label( add(new Label(
new GlobalizedMessage("com.arsdigita.cms.contentassets.related_link_resourceSize", new GlobalizedMessage("com.arsdigita.cms.contentassets.related_link_resourceSize",
"com.arsdigita.cms.contentassets.RelatedLinkResources"))); "com.arsdigita.cms.contentassets.RelatedLinkResources")));
TextField resSize = new TextField(new StringParameter(RelatedLink.RESOURCE_SIZE)); TextField resSize = new TextField(new StringParameter(RelatedLink.RESOURCE_SIZE));
add(resSize); add(resSize);
add(new Label( add(new Label(
new GlobalizedMessage("com.arsdigita.cms.contentassets.related_link_resourceType", new GlobalizedMessage("com.arsdigita.cms.contentassets.related_link_resourceType",
"com.arsdigita.cms.contentassets.RelatedLinkResources"))); "com.arsdigita.cms.contentassets.RelatedLinkResources")));
SingleSelect resType = new SingleSelect(new StringParameter(RelatedLink.RESOURCE_TYPE)); SingleSelect resType = new SingleSelect(new StringParameter(RelatedLink.RESOURCE_TYPE));
addMimeOptions(resType); addMimeOptions(resType);
add(resType); add(resType);

View File

@ -1058,3 +1058,6 @@ cms.ui.workflow.task=Task
cms.ui.workflow.you_are_assigned_to_this_item=Assigned to you cms.ui.workflow.you_are_assigned_to_this_item=Assigned to you
cms.ui.workflow.roles=Roles cms.ui.workflow.roles=Roles
cms.ui.workflow.approve_this_content=Approve cms.ui.workflow.approve_this_content=Approve
cms.ui.unknownRole=Unknown role
cms.ui.unknownStatus=Unknown status
cms.contenttypes.ui.genericorgaunit.persons.status=Status

View File

@ -1051,3 +1051,6 @@ cms.ui.workflow.your_active_tasks=Ihre aktiven Aufgaben
cms.ui.workflow.you_are_assigned_to_this_item=Zugewiesen an Sie cms.ui.workflow.you_are_assigned_to_this_item=Zugewiesen an Sie
cms.ui.workflow.roles=Rollen cms.ui.workflow.roles=Rollen
cms.ui.workflow.approve_this_content=Aktzeptieren cms.ui.workflow.approve_this_content=Aktzeptieren
cms.ui.unknownRole=Unbekannte Rolle
cms.ui.unknownStatus=Unbekannter status
cms.contenttypes.ui.genericorgaunit.persons.status=Status

View File

@ -1,3 +1,6 @@
cms.tasks.ui.content_center=Content Centre cms.tasks.ui.content_center=Content Centre
cms.ui.content_center=Content Centre cms.ui.content_center=Content Centre
cms.ui.lifecycles=Lifecycles cms.ui.lifecycles=Lifecycles
cms.ui.unknownRole=
cms.ui.unknownStatus=Unknown status
cms.contenttypes.ui.genericorgaunit.persons.status=Status

View File

@ -114,3 +114,6 @@ cms.contenttypes.ui.contact.contactEntry.none=No contact information yet
cms.contenttypes.ui.genericorgaunit.person.role=Role cms.contenttypes.ui.genericorgaunit.person.role=Role
cms.ui.delete=Remove cms.ui.delete=Remove
sciorganization.ui.department.project.confirm_remove=Are you sure to remove this project? sciorganization.ui.department.project.confirm_remove=Are you sure to remove this project?
cms.ui.unknownRole=Unknown role
cms.ui.unknownStatus=Unknown status
Status=Status

View File

@ -116,3 +116,15 @@ cms.contenttypes.ui.genericorgaunit.select_person=Person ausw\u00e4hlen
cms.contenttypes.ui.genericorgaunit.person.role=Rolle cms.contenttypes.ui.genericorgaunit.person.role=Rolle
cms.ui.delete=Entfernen cms.ui.delete=Entfernen
sciorganization.ui.department.project.confirm_remove=Wollen Sie dieses Projekt wirklich entfernen? sciorganization.ui.department.project.confirm_remove=Wollen Sie dieses Projekt wirklich entfernen?
cms.ui.unknownRole=Unbekannte Rolle
cms.contenttypes.ui.contact.contactEntry.key.contact_type=Kontakttyp
cms.contenttypes.ui.contact.contactEntry.key.office_hours=Sprechzeiten
cms.contenttypes.ui.contact.contactEntry.key.phone_office=Telefon (B\u00fcro)
cms.contenttypes.ui.contact.contactEntry.key.phone_private=Telefon (Privat)
cms.contenttypes.ui.contact.contactEntry.key.phone_mobile=Telefon (mobil)
cms.contenttypes.ui.contact.contactEntry.key.email=E-Mail
cms.contenttypes.ui.contact.contactEntry.key.fax=sFax
cms.contenttypes.ui.contact.contactEntry.key.im=Instant Messanger
cms.contenttypes.ui.contact.contactEntry.key.www=Homepage
cms.ui.unknownStatus=Unkannter Status
Status=Status

View File

@ -18,7 +18,6 @@
*/ */
package com.arsdigita.cms.contenttypes; package com.arsdigita.cms.contenttypes;
import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PageState;
import com.arsdigita.cms.ContentBundle; import com.arsdigita.cms.ContentBundle;
import com.arsdigita.cms.ContentItem; import com.arsdigita.cms.ContentItem;
@ -37,10 +36,13 @@ import com.arsdigita.persistence.DataCollection;
import com.arsdigita.persistence.Session; import com.arsdigita.persistence.Session;
import com.arsdigita.persistence.SessionManager; import com.arsdigita.persistence.SessionManager;
import com.arsdigita.util.Assert; import com.arsdigita.util.Assert;
import com.arsdigita.web.ParameterMap;
import com.arsdigita.web.URL; import com.arsdigita.web.URL;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.StringTokenizer;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
/** /**
* This content type represents a Link content type for linking * This content type represents a Link content type for linking
* ContentItems and external links. * ContentItems and external links.
@ -49,7 +51,8 @@ import org.apache.log4j.Logger;
* @author Nobuko Asakai (nasakai@redhat.com) * @author Nobuko Asakai (nasakai@redhat.com)
* @author Sören Bernstein (Quasimodo) * @author Sören Bernstein (Quasimodo)
*/ */
public class Link extends ACSObject { public class Link extends ACSObject {
private static final Logger s_log = Logger.getLogger(Link.class); private static final Logger s_log = Logger.getLogger(Link.class);
/** PDL properties /** PDL properties
* cms_links.title */ * cms_links.title */
@ -60,7 +63,7 @@ public class Link extends ACSObject {
public static final String EXTERNAL_LINK = "externalLink"; public static final String EXTERNAL_LINK = "externalLink";
public static final String INTERNAL_LINK = "internalLink"; public static final String INTERNAL_LINK = "internalLink";
/** PDL property "targetURI" */ /** PDL property "targetURI" */
public static final String TARGET_URI ="targetURI"; public static final String TARGET_URI = "targetURI";
/** PDL property "targetItem" */ /** PDL property "targetItem" */
public static final String TARGET_ITEM = "targetItem"; public static final String TARGET_ITEM = "targetItem";
/** PDL property "targetWindow" */ /** PDL property "targetWindow" */
@ -69,16 +72,15 @@ public class Link extends ACSObject {
public static final String DESCRIPTION = "linkDescription"; public static final String DESCRIPTION = "linkDescription";
/** PDL property "order" */ /** PDL property "order" */
public static final String ORDER = "linkOrder"; public static final String ORDER = "linkOrder";
/** Data object type for this domain object */ /** Data object type for this domain object */
public static final String BASE_DATA_OBJECT_TYPE public static final String BASE_DATA_OBJECT_TYPE =
= "com.arsdigita.cms.contenttypes.Link"; "com.arsdigita.cms.contenttypes.Link";
/** /**
* Default constructor. This creates a new Link. * Default constructor. This creates a new Link.
*/ */
public Link() { public Link() {
this( BASE_DATA_OBJECT_TYPE ); this(BASE_DATA_OBJECT_TYPE);
} }
/** /**
@ -89,9 +91,9 @@ public class Link extends ACSObject {
* @param id The <code>id</code> for the retrieved * @param id The <code>id</code> for the retrieved
* <code>DataObject</code> * <code>DataObject</code>
*/ */
public Link( BigDecimal id ) public Link(BigDecimal id)
throws DataObjectNotFoundException { throws DataObjectNotFoundException {
this( new OID( BASE_DATA_OBJECT_TYPE, id ) ); this(new OID(BASE_DATA_OBJECT_TYPE, id));
} }
/** /**
@ -102,9 +104,9 @@ public class Link extends ACSObject {
* @param oid The <code>OID</code> for the retrieved * @param oid The <code>OID</code> for the retrieved
* <code>DataObject</code> * <code>DataObject</code>
*/ */
public Link( OID id ) public Link(OID id)
throws DataObjectNotFoundException { throws DataObjectNotFoundException {
super( id ); super(id);
} }
/** /**
@ -114,8 +116,8 @@ public class Link extends ACSObject {
* @param obj The <code>DataObject</code> with which to create or * @param obj The <code>DataObject</code> with which to create or
* load a content item * load a content item
*/ */
public Link( DataObject obj ) { public Link(DataObject obj) {
super( obj ); super(obj);
} }
/** /**
@ -125,29 +127,26 @@ public class Link extends ACSObject {
* @param type The <code>String</code> data object type of the * @param type The <code>String</code> data object type of the
* item to create * item to create
*/ */
public Link( String type ) { public Link(String type) {
super( type ); super(type);
} }
/** /**
* Returns the title of this <code>Link</code> * Returns the title of this <code>Link</code>
* *
* @return The Link title * @return The Link title
*/ */
public String getTitle() { public String getTitle() {
return (String) get( TITLE ); return (String) get(TITLE);
} }
/** /**
* Sets the title of this <code>Link</code> * Sets the title of this <code>Link</code>
* *
* @param title The Link title * @param title The Link title
*/ */
public void setTitle( String title ) { public void setTitle(String title) {
set( TITLE, title ); set(TITLE, title);
} }
/** /**
@ -166,8 +165,8 @@ public class Link extends ACSObject {
* Link.INTERNAL_LINK * Link.INTERNAL_LINK
*/ */
public void setTargetType(String type) { public void setTargetType(String type) {
Assert.isTrue(type != null && Assert.isTrue(type != null && (type.equals(EXTERNAL_LINK) || type.equals(
(type.equals(EXTERNAL_LINK)||type.equals(INTERNAL_LINK))); INTERNAL_LINK)));
set(TARGET_TYPE, type); set(TARGET_TYPE, type);
} }
@ -177,7 +176,7 @@ public class Link extends ACSObject {
* @return The Target Type * @return The Target Type
*/ */
public String getTargetURI() { public String getTargetURI() {
return (String) get( TARGET_URI ); return (String) get(TARGET_URI);
} }
/** /**
@ -185,8 +184,8 @@ public class Link extends ACSObject {
* *
* @param uri The Target URI * @param uri The Target URI
*/ */
public void setTargetURI( String uri ) { public void setTargetURI(String uri) {
set( TARGET_URI, uri ); set(TARGET_URI, uri);
} }
/** /**
@ -195,8 +194,9 @@ public class Link extends ACSObject {
* @return The Target Type * @return The Target Type
*/ */
public ContentItem getTargetItem() { public ContentItem getTargetItem() {
DataObject object = (DataObject)get(TARGET_ITEM); DataObject object = (DataObject) get(TARGET_ITEM);
ACSObject acsObject = (ACSObject) DomainObjectFactory.newInstance(object); ACSObject acsObject =
(ACSObject) DomainObjectFactory.newInstance(object);
// Quasimodo: BEGIN // Quasimodo: BEGIN
// This is part of the patch to make RelatedLink (and Link) multilanguage compatible // This is part of the patch to make RelatedLink (and Link) multilanguage compatible
@ -205,12 +205,13 @@ public class Link extends ACSObject {
// content type // content type
ContentItem ci; ContentItem ci;
// If acsObject is instance of ContentBundle // If acsObject is instance of ContentBundle
if(acsObject instanceof ContentBundle) { if (acsObject instanceof ContentBundle) {
// get the negotiated language version of this ContentBundle // get the negotiated language version of this ContentBundle
ci = ((ContentBundle) acsObject).negotiate(DispatcherHelper.getRequest().getLocales()); ci = ((ContentBundle) acsObject).negotiate(DispatcherHelper.
getRequest().getLocales());
} else { } else {
// else there are no language versions so just use the acsObject // else there are no language versions so just use the acsObject
ci = (ContentItem) acsObject; ci = (ContentItem) acsObject;
} }
// Quasimodo: END // Quasimodo: END
return ci; return ci;
@ -257,11 +258,10 @@ public class Link extends ACSObject {
* *
* @param description the description * @param description the description
*/ */
public void setDescription(String description ) { public void setDescription(String description) {
set(DESCRIPTION, description); set(DESCRIPTION, description);
} }
/** /**
* Returns the link order for this <code>Link</code> * Returns the link order for this <code>Link</code>
* *
@ -300,22 +300,47 @@ public class Link extends ACSObject {
* @return the Link URI * @return the Link URI
*/ */
public String getInternalOrExternalURI(PageState state) { public String getInternalOrExternalURI(PageState state) {
if (EXTERNAL_LINK.equals(getTargetType()) ) { if (EXTERNAL_LINK.equals(getTargetType())) {
return getTargetURI(); return getTargetURI();
} else { } else {
ContentItem item = getTargetItem(); ContentItem item = getTargetItem();
if ( item == null ) { if (item == null) {
s_log.error(getOID() + " is internal link, but has null target item" ); s_log.error(getOID()
return ""; + " is internal link, but has null target item");
return "";
} }
ContentSection section = item.getContentSection(); ContentSection section = item.getContentSection();
ItemResolver resolver = section.getItemResolver(); ItemResolver resolver = section.getItemResolver();
String url = resolver.generateItemURL( String url = resolver.generateItemURL(
state, item, section, item.getVersion() state, item, section, item.getVersion());
);
return URL.there(state.getRequest(), url).toString(); if (getTargetURI().startsWith("&")) {
ParameterMap parameters;
StringTokenizer tokenizer;
parameters = new ParameterMap();
tokenizer = new StringTokenizer(getTargetURI().substring(
1), "&");
while (tokenizer.hasMoreTokens()) {
String param[] = tokenizer.nextToken().split("=");
if (param.length >= 2) {
parameters.setParameter(param[0], param[1]);
}
}
s_log.debug(
String.format(
"Internal link with parameters found. Generated URL is: %s",
URL.there(state.getRequest(), url,
parameters).
toString()));
return URL.there(state.getRequest(), url, parameters).
toString();
} else {
return URL.there(state.getRequest(), url).toString();
}
} }
} }
@ -331,7 +356,9 @@ public class Link extends ACSObject {
public static DataCollection getReferringLinks(ContentItem item) { public static DataCollection getReferringLinks(ContentItem item) {
Session session = SessionManager.getSession(); Session session = SessionManager.getSession();
DataCollection links = session.retrieve(BASE_DATA_OBJECT_TYPE); DataCollection links = session.retrieve(BASE_DATA_OBJECT_TYPE);
Filter filter = links.addInSubqueryFilter("id", "com.arsdigita.cms.contenttypes.getReferringLinks"); Filter filter =
links.addInSubqueryFilter("id",
"com.arsdigita.cms.contenttypes.getReferringLinks");
filter.set("itemID", item.getID()); filter.set("itemID", item.getID());
return links; return links;
@ -345,8 +372,8 @@ public class Link extends ACSObject {
* @throws UnsupportedOperationException * @throws UnsupportedOperationException
*/ */
public void swapWithNext() { public void swapWithNext() {
throw new UnsupportedOperationException throw new UnsupportedOperationException(
("Not implemented on base Link class. Subclass Link to support this for a specific role"); "Not implemented on base Link class. Subclass Link to support this for a specific role");
} }
/** /**
@ -357,8 +384,8 @@ public class Link extends ACSObject {
* @throws UnsupportedOperationException * @throws UnsupportedOperationException
*/ */
public void swapWithPrevious() { public void swapWithPrevious() {
throw new UnsupportedOperationException throw new UnsupportedOperationException(
("Not implemented on base Link class. Subclass Link to support this for a specific role"); "Not implemented on base Link class. Subclass Link to support this for a specific role");
} }
/** /**
@ -388,7 +415,6 @@ public class Link extends ACSObject {
} }
/** /**
* Given a dataquery name, returns the (possibly filtered) * Given a dataquery name, returns the (possibly filtered)
* DataQuery for use in swapKeys. This implementation does no * DataQuery for use in swapKeys. This implementation does no
@ -413,9 +439,8 @@ public class Link extends ACSObject {
* @return the DataOperation * @return the DataOperation
*/ */
protected DataOperation getSwapOperation(String operationName) { protected DataOperation getSwapOperation(String operationName) {
DataOperation operation = SessionManager.getSession() DataOperation operation = SessionManager.getSession().
.retrieveDataOperation retrieveDataOperation(operationName);
(operationName);
return operation; return operation;
} }
@ -425,7 +450,8 @@ public class Link extends ACSObject {
* or the previous * or the previous
* @param queryName This is used to find the key with which to swap * @param queryName This is used to find the key with which to swap
*/ */
protected void swapKeys(boolean swapNext, String queryName, String operationName) { protected void swapKeys(boolean swapNext, String queryName,
String operationName) {
String methodName = null; String methodName = null;
if (swapNext) { if (swapNext) {
@ -434,10 +460,10 @@ public class Link extends ACSObject {
methodName = "swapWithPrevious"; methodName = "swapWithPrevious";
} }
Assert.isTrue(!isNew(), methodName + " cannot be called on an " + Assert.isTrue(!isNew(), methodName + " cannot be called on an "
"object that is new"); + "object that is new");
Integer currentKey = (Integer)get(ORDER); Integer currentKey = (Integer) get(ORDER);
// if the current item is not already ordered, alphabetize // if the current item is not already ordered, alphabetize
// instead the first time. This is instead of having to deal // instead the first time. This is instead of having to deal
// with an upgrade script. // with an upgrade script.
@ -445,9 +471,9 @@ public class Link extends ACSObject {
alphabetize(); alphabetize();
return; return;
} }
Assert.isTrue(currentKey != null, methodName + " cannot be " + Assert.isTrue(currentKey != null, methodName + " cannot be "
"called on an object that is not currently in the " + + "called on an object that is not currently in the "
"list"); + "list");
int key = currentKey.intValue(); int key = currentKey.intValue();
@ -458,17 +484,18 @@ public class Link extends ACSObject {
if (swapNext) { if (swapNext) {
otherKey = key + 1; otherKey = key + 1;
query.addOrder("linkOrder ASC"); query.addOrder("linkOrder ASC");
query.addFilter(query.getFilterFactory() query.addFilter(query.getFilterFactory().greaterThan("linkOrder",
.greaterThan("linkOrder", currentKey, true)); currentKey,
true));
} else { } else {
otherKey = key - 1; otherKey = key - 1;
query.addOrder("linkOrder DESC"); query.addOrder("linkOrder DESC");
query.addFilter(query.getFilterFactory() query.addFilter(query.getFilterFactory().lessThan("linkOrder",
.lessThan("linkOrder", currentKey, true)); currentKey, true));
} }
if (query.next()) { if (query.next()) {
otherKey = ((Integer)query.get("linkOrder")).intValue(); otherKey = ((Integer) query.get("linkOrder")).intValue();
query.close(); query.close();
} }
@ -489,8 +516,6 @@ public class Link extends ACSObject {
* without doing anything useful. * without doing anything useful.
*/ */
protected void alphabetize() { protected void alphabetize() {
return; return;
} }
} }

View File

@ -64,7 +64,8 @@ import org.apache.log4j.Logger;
* @author Nobuko Asakai (nasakai@redhat.com) * @author Nobuko Asakai (nasakai@redhat.com)
*/ */
public class LinkPropertyForm extends FormSection public class LinkPropertyForm extends FormSection
implements FormInitListener, FormProcessListener, FormValidationListener, FormSubmissionListener { implements FormInitListener, FormProcessListener, FormValidationListener,
FormSubmissionListener {
private static final Logger s_log = Logger.getLogger(LinkPropertyForm.class); private static final Logger s_log = Logger.getLogger(LinkPropertyForm.class);
/** Name of this form */ /** Name of this form */
@ -80,6 +81,7 @@ public class LinkPropertyForm extends FormSection
private LinkSelectionModel m_linkModel; private LinkSelectionModel m_linkModel;
private SaveCancelSection m_saveCancelSection; private SaveCancelSection m_saveCancelSection;
private ItemSearchWidget m_itemSearch; private ItemSearchWidget m_itemSearch;
private TextField m_itemParams;
private ContentType m_contentType; private ContentType m_contentType;
private final String ITEM_SEARCH = "contentItem"; private final String ITEM_SEARCH = "contentItem";
@ -92,12 +94,12 @@ public class LinkPropertyForm extends FormSection
* Link to work on * Link to work on
*/ */
public LinkPropertyForm(ItemSelectionModel itemModel, public LinkPropertyForm(ItemSelectionModel itemModel,
LinkSelectionModel link) { LinkSelectionModel link) {
this(itemModel, link, null); this(itemModel, link, null);
} }
public LinkPropertyForm(ItemSelectionModel itemModel, public LinkPropertyForm(ItemSelectionModel itemModel,
LinkSelectionModel link, ContentType contentType) { LinkSelectionModel link, ContentType contentType) {
super(new ColumnPanel(2)); super(new ColumnPanel(2));
s_log.debug("property form constructor"); s_log.debug("property form constructor");
m_linkModel = link; m_linkModel = link;
@ -127,7 +129,8 @@ public class LinkPropertyForm extends FormSection
m_description = new TextArea("description"); m_description = new TextArea("description");
m_description.setCols(40); m_description.setCols(40);
m_description.setRows(5); m_description.setRows(5);
add(new Label(GlobalizationUtil.globalize("cms.contenttypes.ui.description"))); add(new Label(GlobalizationUtil.globalize(
"cms.contenttypes.ui.description")));
add(m_description); add(m_description);
@ -135,26 +138,46 @@ public class LinkPropertyForm extends FormSection
"<script language=\"javascript\">\n" "<script language=\"javascript\">\n"
+ "<!-- \n" + "<!-- \n"
+ "function toggle_link_fields(status) { \n" + "function toggle_link_fields(status) { \n"
+ " document.forms['linkEditForm'].targetURI.disabled = status; \n" + "// document.forms['linkEditForm'].targetURI.disabled = status; \n"
+ " document.forms['linkEditForm'].openOption.disabled = status; \n" + "// document.forms['linkEditForm'].openOption.disabled = status; \n"
+ " document.forms['linkEditForm'].contentItem.disabled = !status; \n" + "// document.forms['linkEditForm'].contentItem.disabled = !status; \n"
+ " document.forms['linkEditForm'].contentItem_search.disabled = !status; \n" + "// document.forms['linkEditForm'].contentItem_search.disabled = !status; \n"
+ " document.forms['linkEditForm'].contentItem_clear.disabled = !status; \n" + "// document.forms['linkEditForm'].contentItem_clear.disabled = !status; \n"
+ "// document.forms['linkEditForm'].itemParams.disabled = !status; \n"
+ "}\n" + "}\n"
+ "function enableUrlFields() { \n"
+ " document.forms['linkEditForm'].targetURI.disabled = false; \n"
+ " document.forms['linkEditForm'].openOption.disabled = false; \n"
+ " document.forms['linkEditForm'].contentItem.disabled = true; \n"
+ " document.forms['linkEditForm'].contentItem_search.disabled = true; \n"
+ " //document.forms['linkEditForm'].contentItem_clear.disabled = true; \n"
+ " document.forms['linkEditForm'].itemParams.disabled = true; \n"
+ "} \n"
+ "function enableItemFields() { \n"
+ " document.forms['linkEditForm'].targetURI.disabled = true; \n"
+ " document.forms['linkEditForm'].openOption.disabled = true; \n"
+ " document.forms['linkEditForm'].contentItem.disabled = false; \n"
+ " document.forms['linkEditForm'].contentItem_search.disabled = false; \n"
+ " //document.forms['linkEditForm'].contentItem_clear.disabled = false; \n"
+ " document.forms['linkEditForm'].itemParams.disabled = false; \n"
+ "} \n"
+ "// -->\n" + "// -->\n"
+ "</script>\n", + "</script>\n",
false)); false));
add(new Label("Choose either a URL or a Content Item", Label.BOLD), add(new Label("Choose either a URL or a Content Item", Label.BOLD),
ColumnPanel.FULL_WIDTH); ColumnPanel.FULL_WIDTH);
m_linkType = new RadioGroup("linkType"); m_linkType = new RadioGroup("linkType");
Option m_external = new Option(Link.EXTERNAL_LINK, "URL"); Option m_external = new Option(Link.EXTERNAL_LINK, "URL");
m_external.setOnClick("toggle_link_fields(false)"); //m_external.setOnClick("toggle_link_fields(false)");
m_external.setOnClick("enableUrlFields()");
Option m_internal = new Option(Link.INTERNAL_LINK, "Content Item"); Option m_internal = new Option(Link.INTERNAL_LINK, "Content Item");
m_internal.setOnClick("toggle_link_fields(true)"); //m_internal.setOnClick("toggle_link_fields(true)");
m_internal.setOnClick("enableItemFields()");
Option m_selectWindow = new Option(Link.TARGET_WINDOW, "Open URL in new window"); Option m_selectWindow = new Option(Link.TARGET_WINDOW,
"Open URL in new window");
m_URIOption = new CheckboxGroup("openOption"); m_URIOption = new CheckboxGroup("openOption");
m_URIOption.addOption(m_selectWindow); m_URIOption.addOption(m_selectWindow);
@ -168,7 +191,8 @@ public class LinkPropertyForm extends FormSection
m_targetURI = new TextField("targetURI"); m_targetURI = new TextField("targetURI");
m_targetURI.setOnFocus("toggle_link_fields(false)"); m_targetURI.setOnFocus("toggle_link_fields(false)");
m_targetURI.setHint("Enter a URL such as http://www.example.com/ or /ccm/forum/"); m_targetURI.setHint(
"Enter a URL such as http://www.example.com/ or /ccm/forum/");
add(new Label("URL: ")); add(new Label("URL: "));
add(m_targetURI); add(m_targetURI);
@ -178,13 +202,22 @@ public class LinkPropertyForm extends FormSection
m_itemSearch.getClearButton().setOnFocus("toggle_link_fields(true)"); m_itemSearch.getClearButton().setOnFocus("toggle_link_fields(true)");
add(m_itemSearch); add(m_itemSearch);
add(new Label("Parameters"));
m_itemParams = new TextField("itemParams");
m_itemParams.setOnFocus("toggle_link_fields(true)");
m_itemParams.setHint(
"Enter parameters for the item URL. Separate items with '&'.");
add(m_itemParams);
add(new Label( add(new Label(
"<script language=\"javascript\">\n" "<script language=\"javascript\">\n"
+ "<!-- \n" + "<!-- \n"
+ "if (document.forms['linkEditForm'].linkType[0].checked) { \n" + "if (document.forms['linkEditForm'].linkType[0].checked) { \n"
+ " toggle_link_fields(false); \n" + " //toggle_link_fields(false); \n"
+ " enableUrlFields(); \n"
+ "} else { \n" + "} else { \n"
+ " toggle_link_fields(true); \n" + " //toggle_link_fields(true); \n"
+ " enableItemFields(); \n"
+ "} \n" + "} \n"
+ "// -->\n" + "// -->\n"
+ "</script>\n", + "</script>\n",
@ -264,7 +297,8 @@ public class LinkPropertyForm extends FormSection
// The link is external, the URL must be valid and not null // The link is external, the URL must be valid and not null
String externalURI = (String) m_targetURI.getValue(state); String externalURI = (String) m_targetURI.getValue(state);
if (externalURI == null || externalURI.length() == 0) { if (externalURI == null || externalURI.length() == 0) {
throw new FormProcessException("The URI field is required for an external link."); throw new FormProcessException(
"The URI field is required for an external link.");
} }
String url = (String) m_targetURI.getValue(state); String url = (String) m_targetURI.getValue(state);
@ -282,7 +316,7 @@ public class LinkPropertyForm extends FormSection
// "http://servername" on the front // "http://servername" on the front
newURL = HTTP_PROTOCOL + Web.getConfig().getHost() newURL = HTTP_PROTOCOL + Web.getConfig().getHost()
+ url; + url;
} else if (!hasProtocol) { } else if (!hasProtocol) {
// There's no protocol. See if it would be ok if we // There's no protocol. See if it would be ok if we
// put one on the beginning // put one on the beginning
@ -291,7 +325,8 @@ public class LinkPropertyForm extends FormSection
} else { } else {
// No idea, just throw the error // No idea, just throw the error
throw new FormProcessException("URL is not valid: " + ex.getMessage()); throw new FormProcessException("URL is not valid: " + ex.
getMessage());
} }
try { try {
@ -320,13 +355,16 @@ public class LinkPropertyForm extends FormSection
// check that's what they intended // check that's what they intended
if (!localLink && !hasProtocol) { if (!localLink && !hasProtocol) {
m_targetURI.setValue(state, newURL); m_targetURI.setValue(state, newURL);
throw new FormProcessException("A valid URL starts with a protocol, eg http://"); throw new FormProcessException(
"A valid URL starts with a protocol, eg http://");
} }
} }
} else if (Link.INTERNAL_LINK.equals((String) m_linkType.getValue(state))) { } else if (Link.INTERNAL_LINK.equals((String) m_linkType.getValue(
state))) {
// The link is internal, the item selected must be not null // The link is internal, the item selected must be not null
if (data.get(ITEM_SEARCH) == null) { if (data.get(ITEM_SEARCH) == null) {
throw new FormProcessException("Item selection is required for internal link."); throw new FormProcessException(
"Item selection is required for internal link.");
} }
} }
} }
@ -371,8 +409,14 @@ public class LinkPropertyForm extends FormSection
try { try {
m_title.setValue(state, link.getTitle()); m_title.setValue(state, link.getTitle());
m_description.setValue(state, link.getDescription()); m_description.setValue(state, link.getDescription());
m_targetURI.setValue(state, link.getTargetURI()); if (link.getTargetURI().startsWith("&")) {
if (com.arsdigita.bebop.Link.NEW_FRAME.equals(link.getTargetWindow())) { m_itemParams.setValue(state,
link.getTargetURI().substring(1));
} else {
m_targetURI.setValue(state, link.getTargetURI());
}
if (com.arsdigita.bebop.Link.NEW_FRAME.equals(link.
getTargetWindow())) {
m_URIOption.setValue(state, Link.TARGET_WINDOW); m_URIOption.setValue(state, Link.TARGET_WINDOW);
} else { } else {
m_URIOption.setValue(state, null); m_URIOption.setValue(state, null);
@ -427,7 +471,7 @@ public class LinkPropertyForm extends FormSection
//call to set various properties of Link. //call to set various properties of Link.
setLinkProperties(link, fse); setLinkProperties(link, fse);
s_log.debug("Created Link with ID: " + link.getOID().toString() s_log.debug("Created Link with ID: " + link.getOID().toString()
+ "Title " + link.getTitle()); + "Title " + link.getTitle());
} }
// XXX Initialize the form // XXX Initialize the form
m_linkModel.clearSelection(state); m_linkModel.clearSelection(state);
@ -453,7 +497,12 @@ public class LinkPropertyForm extends FormSection
link.setTargetItem(null); link.setTargetItem(null);
} else { } else {
// Internal // Internal
link.setTargetURI(null); if (((String) m_itemParams.getValue(state)).isEmpty()) {
link.setTargetURI(null);
} else {
link.setTargetURI(String.format("&%s", m_itemParams.getValue(
state)));
}
// Quasimodo: BEGIN // Quasimodo: BEGIN
// This is part of the patch to make RelatedLink (and Link) multilanguage compatible // This is part of the patch to make RelatedLink (and Link) multilanguage compatible