- 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(
new GlobalizedMessage("com.arsdigita.cms.contentassets.related_link_resourceSize",
"com.arsdigita.cms.contentassets.RelatedLinkResources")));
TextField resSize = new TextField(new StringParameter(RelatedLink.RESOURCE_SIZE));
add(resSize);
add(new Label(
new GlobalizedMessage("com.arsdigita.cms.contentassets.related_link_resourceType",
"com.arsdigita.cms.contentassets.RelatedLinkResources")));
SingleSelect resType = new SingleSelect(new StringParameter(RelatedLink.RESOURCE_TYPE));
addMimeOptions(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.roles=Roles
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.roles=Rollen
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.ui.content_center=Content Centre
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.ui.delete=Remove
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.ui.delete=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;
import com.arsdigita.bebop.PageState;
import com.arsdigita.cms.ContentBundle;
import com.arsdigita.cms.ContentItem;
@ -37,10 +36,13 @@ import com.arsdigita.persistence.DataCollection;
import com.arsdigita.persistence.Session;
import com.arsdigita.persistence.SessionManager;
import com.arsdigita.util.Assert;
import com.arsdigita.web.ParameterMap;
import com.arsdigita.web.URL;
import java.math.BigDecimal;
import java.util.StringTokenizer;
import org.apache.log4j.Logger;
/**
* This content type represents a Link content type for linking
* ContentItems and external links.
@ -50,6 +52,7 @@ import org.apache.log4j.Logger;
* @author Sören Bernstein (Quasimodo)
*/
public class Link extends ACSObject {
private static final Logger s_log = Logger.getLogger(Link.class);
/** PDL properties
* cms_links.title */
@ -69,10 +72,9 @@ public class Link extends ACSObject {
public static final String DESCRIPTION = "linkDescription";
/** PDL property "order" */
public static final String ORDER = "linkOrder";
/** Data object type for this domain object */
public static final String BASE_DATA_OBJECT_TYPE
= "com.arsdigita.cms.contenttypes.Link";
public static final String BASE_DATA_OBJECT_TYPE =
"com.arsdigita.cms.contenttypes.Link";
/**
* Default constructor. This creates a new Link.
@ -129,8 +131,6 @@ public class Link extends ACSObject {
super(type);
}
/**
* Returns the title of this <code>Link</code>
*
@ -140,7 +140,6 @@ public class Link extends ACSObject {
return (String) get(TITLE);
}
/**
* Sets the title of this <code>Link</code>
*
@ -166,8 +165,8 @@ public class Link extends ACSObject {
* Link.INTERNAL_LINK
*/
public void setTargetType(String type) {
Assert.isTrue(type != null &&
(type.equals(EXTERNAL_LINK)||type.equals(INTERNAL_LINK)));
Assert.isTrue(type != null && (type.equals(EXTERNAL_LINK) || type.equals(
INTERNAL_LINK)));
set(TARGET_TYPE, type);
}
@ -196,7 +195,8 @@ public class Link extends ACSObject {
*/
public ContentItem getTargetItem() {
DataObject object = (DataObject) get(TARGET_ITEM);
ACSObject acsObject = (ACSObject) DomainObjectFactory.newInstance(object);
ACSObject acsObject =
(ACSObject) DomainObjectFactory.newInstance(object);
// Quasimodo: BEGIN
// This is part of the patch to make RelatedLink (and Link) multilanguage compatible
@ -207,7 +207,8 @@ public class Link extends ACSObject {
// If acsObject is instance of ContentBundle
if (acsObject instanceof 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 there are no language versions so just use the acsObject
ci = (ContentItem) acsObject;
@ -261,7 +262,6 @@ public class Link extends ACSObject {
set(DESCRIPTION, description);
}
/**
* Returns the link order for this <code>Link</code>
*
@ -306,18 +306,43 @@ public class Link extends ACSObject {
ContentItem item = getTargetItem();
if (item == null) {
s_log.error(getOID() + " is internal link, but has null target item" );
s_log.error(getOID()
+ " is internal link, but has null target item");
return "";
}
ContentSection section = item.getContentSection();
ItemResolver resolver = section.getItemResolver();
String url = resolver.generateItemURL(
state, item, section, item.getVersion()
);
state, item, section, item.getVersion());
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();
}
}
}
/**
* Returns a DataCollection of links which refer to the given
@ -331,7 +356,9 @@ public class Link extends ACSObject {
public static DataCollection getReferringLinks(ContentItem item) {
Session session = SessionManager.getSession();
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());
return links;
@ -345,8 +372,8 @@ public class Link extends ACSObject {
* @throws UnsupportedOperationException
*/
public void swapWithNext() {
throw new UnsupportedOperationException
("Not implemented on base Link class. Subclass Link to support this for a specific role");
throw new UnsupportedOperationException(
"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
*/
public void swapWithPrevious() {
throw new UnsupportedOperationException
("Not implemented on base Link class. Subclass Link to support this for a specific role");
throw new UnsupportedOperationException(
"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)
* DataQuery for use in swapKeys. This implementation does no
@ -413,9 +439,8 @@ public class Link extends ACSObject {
* @return the DataOperation
*/
protected DataOperation getSwapOperation(String operationName) {
DataOperation operation = SessionManager.getSession()
.retrieveDataOperation
(operationName);
DataOperation operation = SessionManager.getSession().
retrieveDataOperation(operationName);
return operation;
}
@ -425,7 +450,8 @@ public class Link extends ACSObject {
* or the previous
* @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;
if (swapNext) {
@ -434,8 +460,8 @@ public class Link extends ACSObject {
methodName = "swapWithPrevious";
}
Assert.isTrue(!isNew(), methodName + " cannot be called on an " +
"object that is new");
Assert.isTrue(!isNew(), methodName + " cannot be called on an "
+ "object that is new");
Integer currentKey = (Integer) get(ORDER);
// if the current item is not already ordered, alphabetize
@ -445,9 +471,9 @@ public class Link extends ACSObject {
alphabetize();
return;
}
Assert.isTrue(currentKey != null, methodName + " cannot be " +
"called on an object that is not currently in the " +
"list");
Assert.isTrue(currentKey != null, methodName + " cannot be "
+ "called on an object that is not currently in the "
+ "list");
int key = currentKey.intValue();
@ -458,13 +484,14 @@ public class Link extends ACSObject {
if (swapNext) {
otherKey = key + 1;
query.addOrder("linkOrder ASC");
query.addFilter(query.getFilterFactory()
.greaterThan("linkOrder", currentKey, true));
query.addFilter(query.getFilterFactory().greaterThan("linkOrder",
currentKey,
true));
} else {
otherKey = key - 1;
query.addOrder("linkOrder DESC");
query.addFilter(query.getFilterFactory()
.lessThan("linkOrder", currentKey, true));
query.addFilter(query.getFilterFactory().lessThan("linkOrder",
currentKey, true));
}
if (query.next()) {
@ -491,6 +518,4 @@ public class Link extends ACSObject {
protected void alphabetize() {
return;
}
}

View File

@ -64,7 +64,8 @@ import org.apache.log4j.Logger;
* @author Nobuko Asakai (nasakai@redhat.com)
*/
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);
/** Name of this form */
@ -80,6 +81,7 @@ public class LinkPropertyForm extends FormSection
private LinkSelectionModel m_linkModel;
private SaveCancelSection m_saveCancelSection;
private ItemSearchWidget m_itemSearch;
private TextField m_itemParams;
private ContentType m_contentType;
private final String ITEM_SEARCH = "contentItem";
@ -127,7 +129,8 @@ public class LinkPropertyForm extends FormSection
m_description = new TextArea("description");
m_description.setCols(40);
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);
@ -135,11 +138,28 @@ public class LinkPropertyForm extends FormSection
"<script language=\"javascript\">\n"
+ "<!-- \n"
+ "function toggle_link_fields(status) { \n"
+ " document.forms['linkEditForm'].targetURI.disabled = status; \n"
+ " document.forms['linkEditForm'].openOption.disabled = status; \n"
+ " document.forms['linkEditForm'].contentItem.disabled = !status; \n"
+ " document.forms['linkEditForm'].contentItem_search.disabled = !status; \n"
+ " document.forms['linkEditForm'].contentItem_clear.disabled = !status; \n"
+ "// document.forms['linkEditForm'].targetURI.disabled = status; \n"
+ "// document.forms['linkEditForm'].openOption.disabled = status; \n"
+ "// document.forms['linkEditForm'].contentItem.disabled = !status; \n"
+ "// document.forms['linkEditForm'].contentItem_search.disabled = !status; \n"
+ "// document.forms['linkEditForm'].contentItem_clear.disabled = !status; \n"
+ "// document.forms['linkEditForm'].itemParams.disabled = !status; \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"
+ "</script>\n",
@ -149,12 +169,15 @@ public class LinkPropertyForm extends FormSection
ColumnPanel.FULL_WIDTH);
m_linkType = new RadioGroup("linkType");
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");
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.addOption(m_selectWindow);
@ -168,7 +191,8 @@ public class LinkPropertyForm extends FormSection
m_targetURI = new TextField("targetURI");
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(m_targetURI);
@ -178,13 +202,22 @@ public class LinkPropertyForm extends FormSection
m_itemSearch.getClearButton().setOnFocus("toggle_link_fields(true)");
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(
"<script language=\"javascript\">\n"
+ "<!-- \n"
+ "if (document.forms['linkEditForm'].linkType[0].checked) { \n"
+ " toggle_link_fields(false); \n"
+ " //toggle_link_fields(false); \n"
+ " enableUrlFields(); \n"
+ "} else { \n"
+ " toggle_link_fields(true); \n"
+ " //toggle_link_fields(true); \n"
+ " enableItemFields(); \n"
+ "} \n"
+ "// -->\n"
+ "</script>\n",
@ -264,7 +297,8 @@ public class LinkPropertyForm extends FormSection
// The link is external, the URL must be valid and not null
String externalURI = (String) m_targetURI.getValue(state);
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);
@ -291,7 +325,8 @@ public class LinkPropertyForm extends FormSection
} else {
// 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 {
@ -320,13 +355,16 @@ public class LinkPropertyForm extends FormSection
// check that's what they intended
if (!localLink && !hasProtocol) {
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
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 {
m_title.setValue(state, link.getTitle());
m_description.setValue(state, link.getDescription());
if (link.getTargetURI().startsWith("&")) {
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())) {
}
if (com.arsdigita.bebop.Link.NEW_FRAME.equals(link.
getTargetWindow())) {
m_URIOption.setValue(state, Link.TARGET_WINDOW);
} else {
m_URIOption.setValue(state, null);
@ -453,7 +497,12 @@ public class LinkPropertyForm extends FormSection
link.setTargetItem(null);
} else {
// Internal
if (((String) m_itemParams.getValue(state)).isEmpty()) {
link.setTargetURI(null);
} else {
link.setTargetURI(String.format("&%s", m_itemParams.getValue(
state)));
}
// Quasimodo: BEGIN
// This is part of the patch to make RelatedLink (and Link) multilanguage compatible