Abschliessender Teil zur Korrektur Lokalisation Content Asset Related Link.

git-svn-id: https://svn.libreccm.org/ccm/trunk@2242 8810af33-2d31-482b-a856-94f89814c4df
master
pb 2013-07-03 12:05:38 +00:00
parent 26ced22594
commit c9dbcddbd9
18 changed files with 269 additions and 67 deletions

View File

@ -1,8 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<xrd:adapters xmlns:xrd="http://xmlns.redhat.com/schemas/waf/xml-renderer-rules" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://rhea.redhat.com/schemas/waf/xml-renderer-rules xml-renderer-rules.xsd">
<xrd:adapters xmlns:xrd="http://xmlns.redhat.com/schemas/waf/xml-renderer-rules"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://rhea.redhat.com/schemas/waf/xml-renderer-rules xml-renderer-rules.xsd">
<!-- First off the adapters for ContentItemPanel -->
<xrd:context name="com.arsdigita.cms.dispatcher.SimpleXMLGenerator">
<xrd:adapter objectType="com.arsdigita.cms.contentassets.RelatedLink"
extends="com.arsdigita.cms.contenttypes.Link"
traversalClass="com.arsdigita.cms.contentassets.RelatedLinkTraversalAdapter">

View File

@ -1,10 +1,17 @@
package com.arsdigita.cms.contentassets;
import com.arsdigita.runtime.AbstractConfig;
import com.arsdigita.util.parameter.BooleanParameter;
import com.arsdigita.util.parameter.IntegerParameter;
import com.arsdigita.util.parameter.Parameter;
/**
* A record containing server-session scoped configuration properties.
*
* Accessors of this class may return null. Developers should take care to trap
* null return values in their code.
*
* Don't instantiate using constructor!
*
* @author Jens Pelzetter <jens@jp-digital.de>
* @version $Id$
@ -13,18 +20,56 @@ public class RelatedLinkConfig extends AbstractConfig {
private static RelatedLinkConfig INSTANCE;
// /////////////////////////////////////////////////////////
// Parameter Section
// /////////////////////////////////////////////////////////
/**
*
*/
private final Parameter assetStepSortKey = new IntegerParameter(
"com.arsdigita.cms.relatedlink.contentassets.asset_step_sortkey",
"com.arsdigita.cms.contentassets.relatedlink.asset_step_sortkey",
Parameter.REQUIRED,
1);
/**
* Hide Additional Resource Fields on RelatedLinkPropertyForm anf
* RelatedLink table
*/
private final Parameter hideAdditionalResourceFields =
new BooleanParameter(
"com.arsdigita.cms.contentassets.relatedlink.hide_additional_resource_fields",
Parameter.REQUIRED,
Boolean.FALSE);
/**
* Hide Additional Resource Fields on RelatedLinkPropertyForm anf
* RelatedLink table
*/
private final Parameter hideNewTargetWindow =
new BooleanParameter(
"com.arsdigita.cms.contentassets.relatedlink.hide_new_target_window",
Parameter.REQUIRED,
Boolean.FALSE);
/**
* Constructor, don't use to instantiate.
* Use getInstance() instead!
*/
public RelatedLinkConfig() {
register(assetStepSortKey);
register(hideAdditionalResourceFields);
register(hideNewTargetWindow);
loadInfo();
}
/**
* Returns the singleton configuration record for the content section
* environment.
*
* @return The <code>RelatedLinkConfig</code> record; it cannot be null
*/
public static final RelatedLinkConfig getInstance() {
if (INSTANCE == null) {
INSTANCE = new RelatedLinkConfig();
@ -33,8 +78,20 @@ public class RelatedLinkConfig extends AbstractConfig {
return INSTANCE;
}
// /////////////////////////////////////////////////////////
// Getter Section
// /////////////////////////////////////////////////////////
public Integer getAssetStepSortKey() {
return (Integer) get(assetStepSortKey);
}
public final boolean isHideAdditionalResourceFields() {
return ((Boolean) get(hideAdditionalResourceFields)).booleanValue();
}
public final boolean isHideNewTargetWindow() {
return ((Boolean) get(hideNewTargetWindow)).booleanValue();
}
}

View File

@ -16,6 +16,7 @@ package com.arsdigita.cms.contentassets;
import com.arsdigita.cms.contenttypes.ContentAssetInitializer;
import com.arsdigita.cms.contentassets.ui.RelatedLinkPropertiesStep;
import com.arsdigita.cms.contentassets.util.RelatedLinkGlobalizationUtil;
import com.arsdigita.cms.ContentPage;
import com.arsdigita.globalization.GlobalizedMessage;
@ -79,16 +80,16 @@ public class RelatedLinkInitializer extends ContentAssetInitializer {
* The label for the authoring step
*/
public GlobalizedMessage getAuthoringStepLabel() {
return new GlobalizedMessage("com.arsdigita.cms.contentassets.related_link_label",
"com.arsdigita.cms.contentassets.RelatedLinkResources");
return RelatedLinkGlobalizationUtil
.globalize("cms.contentassets.related_link.label");
}
/**
* The description for the authoring step
*/
public GlobalizedMessage getAuthoringStepDescription() {
return new GlobalizedMessage("com.arsdigita.cms.contentassets.related_link_description",
"com.arsdigita.cms.contentassets.RelatedLinkResources");
return RelatedLinkGlobalizationUtil
.globalize("cms.contentassets.related_link.description");
}
/**

View File

@ -1,4 +1,5 @@
com.arsdigita.cms.contentassets.related_link_label=Related Links
com.arsdigita.cms.contentassets.related_link_description=Related Links
com.arsdigita.cms.contentassets.related_link_resourceSize=Resource Size
com.arsdigita.cms.contentassets.related_link_resourceType=Resource Type
cms.contentassets.related_link.label=Add Related Links
cms.contentassets.related_link.description=Related Links
cms.contentassets.ui.related_link.resource_size=Resource Size
cms.contentassets.ui.related_link.resource_type=Resource Type
cms.contentassets.ui.related_link.resource_type_unknown=Unknown

View File

@ -1,4 +1,5 @@
com.arsdigita.cms.contentassets.related_link_label=Weiterf\u00FChrende Links
com.arsdigita.cms.contentassets.related_link_description=Weiterf\u00FChrende Links
com.arsdigita.cms.contentassets.related_link_resourceSize=Gr\u00F6\u00DFe
com.arsdigita.cms.contentassets.related_link_resourceType=Typ
cms.contentassets.related_link.label=Weiterf\u00fchrende Links hinzuf\u00fcgen
cms.contentassets.related_link.description=Weiterf\u00fchrende Links
cms.contentassets.ui.related_link.resource_size=Gr\u00f6\u00dfe
cms.contentassets.ui.related_link.resource_type=Ressourcen Typ
cms.contentassets.ui.related_link.resource_type_unknown=Unbekannt

View File

@ -0,0 +1,18 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<title>Content Management System API</title>
</head>
<body>
<p>
The content asset related links provides facilities to make
the CMS Link class available as configurable asset authoring step.
</p>
<p>
Most of its logic is delegatged to the CMS Link classes, including
ui
</p>
</body>
</html>

View File

@ -19,6 +19,7 @@ import com.arsdigita.bebop.FormSection;
import com.arsdigita.bebop.SimpleContainer;
import com.arsdigita.cms.ContentSection;
import com.arsdigita.cms.ContentType;
import com.arsdigita.cms.contentassets.RelatedLinkConfig;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
import com.arsdigita.cms.contenttypes.ui.LinkPropertiesStep;
@ -26,6 +27,9 @@ import com.arsdigita.cms.contenttypes.ui.LinkTable;
/**
* Authoring step to create a RelatedLink and change ordering.
*
* It is just a front end to the cms Link asset and makes RelatedLink accessible
* as installable add related link authoring step
*/
public class RelatedLinkPropertiesStep extends LinkPropertiesStep {
@ -58,20 +62,31 @@ public class RelatedLinkPropertiesStep extends LinkPropertiesStep {
}
/**
* Returns a RelatedLinkTable as the
* display component for this authoring step.
* Returns a RelatedLinkTable as the display component for this authoring
* step.
*
* Uses CMS LinkTable and its display facilities.
*
* @return The display component to use for the authoring step
*/
@Override
public Component getDisplayComponent() {
SimpleContainer container = new SimpleContainer();
LinkTable table;
if (ContentSection.getConfig().isHideAdditionalResourceFields()) {
table = new LinkTable(getItemSelectionModel(), getLinkSelectionModel());
table.setModelBuilder(new RelatedLinkTableModelBuilder(getItemSelectionModel(), linkListName));
if (RelatedLinkConfig.getInstance().isHideAdditionalResourceFields()) {
// CMS LinkTable it it's standard form
table = new LinkTable(getItemSelectionModel(),
getLinkSelectionModel());
table.setModelBuilder(new
RelatedLinkTableModelBuilder(getItemSelectionModel(),
linkListName));
} else {
table = new RelatedLinkTable(getItemSelectionModel(), getLinkSelectionModel(), linkListName);
// Add columns to standard CMS LinkTable
table = new RelatedLinkTable(getItemSelectionModel(),
getLinkSelectionModel(),
linkListName);
}
container.add(table);

View File

@ -28,10 +28,12 @@ import com.arsdigita.cms.ContentItem;
import com.arsdigita.cms.ContentSection;
import com.arsdigita.cms.ContentType;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.contentassets.RelatedLink;
import com.arsdigita.cms.contentassets.RelatedLinkConfig;
import com.arsdigita.cms.contentassets.util.RelatedLinkGlobalizationUtil;
import com.arsdigita.cms.contenttypes.Link;
import com.arsdigita.cms.contenttypes.ui.LinkPropertyForm;
import com.arsdigita.cms.contenttypes.ui.LinkSelectionModel;
import com.arsdigita.cms.contentassets.RelatedLink;
import com.arsdigita.globalization.GlobalizedMessage;
import com.arsdigita.mimetypes.MimeType;
import com.arsdigita.mimetypes.MimeTypeCollection;
@ -51,8 +53,11 @@ import org.apache.log4j.Logger;
*/
public class RelatedLinkPropertyForm extends LinkPropertyForm {
private static final Logger logger = Logger.getLogger(RelatedLinkPropertyForm.class);
private static boolean isHideAdditionalResourceFields = ContentSection.getConfig().isHideAdditionalResourceFields();
private static final Logger logger = Logger.getLogger(
RelatedLinkPropertyForm.class);
private static boolean isHideAdditionalResourceFields =
RelatedLinkConfig.getInstance()
.isHideAdditionalResourceFields();
private String m_linkListName;
/**
@ -80,28 +85,43 @@ public class RelatedLinkPropertyForm extends LinkPropertyForm {
@Override
protected void addWidgets() {
// Add default widgets from CMS Link class
super.addWidgets();
// NewTargetWindow option should be moved from CMS Link class to this
// asset and made optional. Current HTML doesn't allow this option
// anymore.
if (isHideAdditionalResourceFields) {
// /* Single option whether to open in new window, strongly discouraged!*/
// Option m_selectWindow = new Option(
// Link.TARGET_WINDOW,
// new Label(GlobalizationUtil.globalize(
// "cms.contenttyes.link.ui.option.new_window")));
// // "Open URL in new window");
// m_URIOption = new CheckboxGroup("openOption");
// m_URIOption.addOption(m_selectWindow);
// add(m_URIOption, ColumnPanel.FULL_WIDTH);
}
if (isHideAdditionalResourceFields) {
// Do nothing except protect the poor users from themselves.
} else {
//Hack to get the form layout right.
add(new Label(""));
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(new Label(RelatedLinkGlobalizationUtil.globalize(
"cms.contentassets.ui.related_link.resource_size")));
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));
add(new Label(RelatedLinkGlobalizationUtil.globalize(
"cms.contentassets.ui.related_link.resource_type")));
SingleSelect resType = new SingleSelect(new
StringParameter(RelatedLink.RESOURCE_TYPE));
addMimeOptions(resType);
add(resType);
}
Hidden linkListName = new Hidden(new StringParameter(RelatedLink.LINK_LIST_NAME));
Hidden linkListName = new Hidden(new StringParameter(
RelatedLink.LINK_LIST_NAME));
add(linkListName);
}
@ -160,7 +180,8 @@ public class RelatedLinkPropertyForm extends LinkPropertyForm {
rl = (RelatedLink) getLinkSelectionModel().getSelectedLink(ps);
data.put(RelatedLink.RESOURCE_SIZE, rl.getResourceSize());
if (rl.getResourceType() != null) {
data.put(RelatedLink.RESOURCE_TYPE, rl.getResourceType().getMimeType());
data.put(RelatedLink.RESOURCE_TYPE,
rl.getResourceType().getMimeType());
}
data.put(RelatedLink.LINK_LIST_NAME, rl.getLinkListName());
} else {
@ -192,7 +213,9 @@ public class RelatedLinkPropertyForm extends LinkPropertyForm {
}
rl.setLinkListName((String) data.get(RelatedLink.LINK_LIST_NAME));
DataCollection links = RelatedLink.getRelatedLinks(getContentItem(fse.getPageState()), m_linkListName);
DataCollection links = RelatedLink.getRelatedLinks(
getContentItem(fse.getPageState()),
m_linkListName);
rl.setOrder((int) links.size() + 1);
super.setLinkProperties(link, fse);

View File

@ -22,12 +22,15 @@ import com.arsdigita.bebop.table.TableCellRenderer;
import com.arsdigita.bebop.table.TableColumn;
import com.arsdigita.bebop.table.TableColumnModel;
import com.arsdigita.cms.contentassets.RelatedLink;
import com.arsdigita.cms.contentassets.util.RelatedLinkGlobalizationUtil;
import com.arsdigita.cms.contenttypes.ui.LinkTable;
import com.arsdigita.cms.contenttypes.ui.LinkSelectionModel;
import com.arsdigita.cms.ItemSelectionModel;
/**
* Bebop table to display a list of RelatedLinks associated with a ContentItem
* Bebop table to display a list of RelatedLinks associated with a ContentItem.
*
* It uses parent's class facilities but adds 2 additional columns.
*
* @version $Revision: #3 $ $Date: 2004/03/30 $
* @author Scott Seago (sseago@redhat.com)
@ -70,9 +73,13 @@ public class RelatedLinkTable extends LinkTable {
super.addColumns();
TableColumnModel model = getColumnModel();
m_typeCol = new TableColumn(model.size() , "Resource Type");
m_typeCol = new TableColumn(model.size() ,
new Label(RelatedLinkGlobalizationUtil.globalize(
"cms.contentassets.ui.related_link.resource_type")));
model.add(m_typeCol);
m_sizeCol = new TableColumn(model.size() , "Size");
m_sizeCol = new TableColumn(model.size() ,
new Label(RelatedLinkGlobalizationUtil.globalize(
"cms.contentassets.ui.related_link.resource_size")));
model.add(m_sizeCol);
}
@ -108,7 +115,8 @@ public class RelatedLinkTable extends LinkTable {
if(link.getResourceType() != null){
l = new Label(link.getResourceType().getMimeType());
} else{
l = new Label("Unknown");
l = new Label(RelatedLinkGlobalizationUtil.globalize(
"cms.contentassets.ui.related_link.resource_type_unknown"));
}
return l;
} else {

View File

@ -0,0 +1,71 @@
/*
* Copyright (C) 2013 Peter Boy, University of Bremen. All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.contentassets.util;
import com.arsdigita.globalization.Globalized;
import com.arsdigita.globalization.GlobalizedMessage;
/**
* Compilation of methods to simplify the handling of globalizing keys.
* Basically it adds the name of package's resource bundle files to the
* globalize methods and forwards to GlobalizedMessage, shortening the
* method invocation in the various application classes.
*
* @author pb
*/
public class RelatedLinkGlobalizationUtil implements Globalized {
/** Name of Java resource files to handle RelatedLink's globalisation. */
final public static String BUNDLE_NAME =
"com.arsdigita.cms.contentassets.RelatedLinkResources";
/** Name of Java resource files to handle CMS globalisation. */
final public static String ALTERNATE_BUNDLE_NAME =
"com.arsdigita.cms.CMSResources";
/**
* Returns a globalized message using the appropriate bundle.
* If the key string contains the modules name agenda the package specific
* bundle is used, otherwise the CMS ResourceBundle.
*/
public static GlobalizedMessage globalize(String key) {
if (key.indexOf(".related_link.") > 0) {
return new GlobalizedMessage(key, BUNDLE_NAME);
} else {
return new GlobalizedMessage(key, ALTERNATE_BUNDLE_NAME);
}
}
/**
* Returns a globalized message object, using the approprate bundle,
* takeing in an Object[] of arguments to interpolate into the retrieved
* message using the MessageFormat class.
* If the key string contains the modules name agenda the package specific
* bundle is used, otherwise the CMS ResourceBundle.
*/
public static GlobalizedMessage globalize(String key, Object[] args) {
if (key.indexOf(".related_link.") > 0) {
return new GlobalizedMessage(key, BUNDLE_NAME, args);
} else {
return new GlobalizedMessage(key, ALTERNATE_BUNDLE_NAME, args);
}
}
}

View File

@ -269,15 +269,6 @@ public final class CMSConfig extends AbstractConfig {
"com.arsdigita.cms.save_text_cleans_word_tags",
Parameter.OPTIONAL,
Boolean.FALSE);
/**
* Hide Additional Resource Fields on RelatedLinkPropertyForm
*/
private final Parameter m_hideAdditionalResourceFields =
new BooleanParameter(
"com.arsdigita.cms.contentassets.ui."
+ "RelatedLinkPropertyForm.hideAdditionalResourceFields",
Parameter.REQUIRED,
Boolean.FALSE);
/**
* Get the search indexing not to process FileAssets, eg to avoid PDF
* slowdowns
@ -703,7 +694,6 @@ public final class CMSConfig extends AbstractConfig {
register(m_publishLifecycleListenerClass);
register(m_notifyAuthorOnLifecycle);
register(m_saveTextCleansWordTags);
register(m_hideAdditionalResourceFields);
register(m_disableFileAssetExtraction);
register(m_deleteWorkflowAfterPublication);
register(m_soonExpiredTimespanMonths);
@ -886,10 +876,6 @@ public final class CMSConfig extends AbstractConfig {
return ((Boolean) get(m_saveTextCleansWordTags)).booleanValue();
}
public final boolean isHideAdditionalResourceFields() {
return ((Boolean) get(m_hideAdditionalResourceFields)).booleanValue();
}
public final boolean getDisableFileAssetExtraction() {
return ((Boolean) get(m_disableFileAssetExtraction)).booleanValue();
}

View File

@ -1035,3 +1035,4 @@ cms.contenttyes.link.ui.button_create=Create
cms.contenttyes.link.ui.button_save=Save
cms.contenttyes.link.ui.button_reset=Reset
cms.contenttyes.link.ui.button_cancel=Cancel
cms.contenttyes.link.ui.table_no_entries=There are no links for this content item

View File

@ -1030,3 +1030,4 @@ cms.contenttyes.link.ui.button_create=Erstellen
cms.contenttyes.link.ui.button_save=Sichern
cms.contenttyes.link.ui.button_reset=Zur\u00fccksetzen
cms.contenttyes.link.ui.button_cancel=Abbruch
cms.contenttyes.link.ui.table_no_entries=Es sind noch keine Links zugeordnet.

View File

@ -83,3 +83,4 @@ cms.contenttyes.link.ui.button_create=Create
cms.contenttyes.link.ui.button_save=Save
cms.contenttyes.link.ui.button_reset=Reset
cms.contenttyes.link.ui.button_cancel=Cancel
cms.contenttyes.link.ui.table_no_entries=There are no links for this content item

View File

@ -557,3 +557,4 @@ cms.contenttyes.link.ui.button_create=Create
cms.contenttyes.link.ui.button_save=Save
cms.contenttyes.link.ui.button_reset=Reset
cms.contenttyes.link.ui.button_cancel=Cancel
cms.contenttyes.link.ui.table_no_entries=There are no links for this content item

View File

@ -34,11 +34,19 @@ import com.arsdigita.dispatcher.DispatcherHelper;
import com.arsdigita.domain.DataObjectNotFoundException;
import com.arsdigita.util.UncheckedWrapperException;
import com.arsdigita.util.Assert;
import java.math.BigDecimal;
import java.io.IOException;
import org.apache.log4j.Logger;
/** Displays target url that redirects and description */
// NOTE: as of 2013-07-13 this class is not used by any other class of the system.
// Should be removed.
/**
* Displays target url that redirects and description
*/
public class LinkDisplayTable extends LinkTable {
private static final Logger s_log = Logger.getLogger(LinkDisplayTable.class);

View File

@ -203,15 +203,6 @@ public class LinkPropertyForm extends FormSection
"cms.contenttyes.link.ui.option_group.link_type.internal")));
m_internal.setOnClick("enableItemFields()");
/* Single option whether to open in new window, strongly discouraged!*/
Option m_selectWindow = new Option(
Link.TARGET_WINDOW,
new Label(GlobalizationUtil.globalize(
"cms.contenttyes.link.ui.option.new_window")));
// "Open URL in new window");
m_URIOption = new CheckboxGroup("openOption");
m_URIOption.addOption(m_selectWindow);
m_linkType.addOption(m_external);
m_linkType.addOption(m_internal);
m_linkType.setOptionSelected(m_external);
@ -219,7 +210,6 @@ public class LinkPropertyForm extends FormSection
add(new Label(GlobalizationUtil.globalize(
"cms.contenttyes.link.ui.option_group.link_type.label")));
add(m_linkType);
add(m_URIOption, ColumnPanel.FULL_WIDTH);
/* External target */
m_targetURI = new TextField("targetURI");
@ -247,6 +237,21 @@ public class LinkPropertyForm extends FormSection
"cms.contenttyes.link.ui.target_parameters_hint") );
add(m_itemParams);
// TODO:
// Move this option to contentasset related link for bacvkwards compatibility
// because this option is no longer compatible with current HTML
// Requires database modification (move field target_window from
// cms_links to cms_related_links which shoud become ca_related_links
/* Single option whether to open in new window, strongly discouraged!*/
Option m_selectWindow = new Option(
Link.TARGET_WINDOW,
new Label(GlobalizationUtil.globalize(
"cms.contenttyes.link.ui.option.new_window")));
// "Open URL in new window");
m_URIOption = new CheckboxGroup("openOption");
m_URIOption.addOption(m_selectWindow);
add(m_URIOption, ColumnPanel.FULL_WIDTH);
add(new Label(
"<script language=\"javascript\">\n"
+ "<!-- \n"

View File

@ -117,7 +117,8 @@ public class LinkTable extends Table {
}
};
Label empty = new Label("There are no links for this content item");
Label empty = new Label(GlobalizationUtil.globalize(
"cms.contenttyes.link.ui.table_no_entries"));
setEmptyView(empty);
addTableActionListener(new LinkTableActionListener());
setRowSelectionModel(m_linkModel);