RelatedLinks: title-column can be used for captions
git-svn-id: https://svn.libreccm.org/ccm/trunk@3454 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
88fb5966da
commit
9e7b5ad380
|
|
@ -7,3 +7,5 @@ cms.contentassets.ui.related_link.add_caption=Add a caption
|
|||
cms.contentassets.ui.related_link.add_link=Add a Link
|
||||
cms.contentassets.ui.related_link.caption=Caption:
|
||||
cms.contentassets.ui.related_link.Description=Description/Caption:
|
||||
cms.contentassets.ui.related_link.title=Title:
|
||||
cms.contentassets.ui.related_link.description=Description:
|
||||
|
|
|
|||
|
|
@ -7,3 +7,5 @@ cms.contentassets.ui.related_link.add_caption=Zwischentitel hinzuf\u00fcgen
|
|||
cms.contentassets.ui.related_link.add_link=Link hinzuf\u00fcgen
|
||||
cms.contentassets.ui.related_link.caption=Zwischentitel:
|
||||
cms.contentassets.ui.related_link.Description=Beschreibung/Zwischentitel:
|
||||
cms.contentassets.ui.related_link.title=Titel:
|
||||
cms.contentassets.ui.related_link.description=Beschreibung:
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import com.arsdigita.bebop.FormData;
|
|||
import com.arsdigita.bebop.FormProcessException;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||
import com.arsdigita.bebop.parameters.NotNullValidationListener;
|
||||
import com.arsdigita.cms.ItemSelectionModel;
|
||||
import com.arsdigita.cms.contentassets.RelatedLink;
|
||||
import com.arsdigita.cms.contenttypes.ui.LinkSelectionModel;
|
||||
|
|
@ -39,10 +40,11 @@ public class RelatedLinkCaptionEditForm extends RelatedLinkCaptionForm {
|
|||
RelatedLink link;
|
||||
if (m_linkModel.isSelected(state)) {
|
||||
link = (RelatedLink) m_linkModel.getSelectedLink(state);
|
||||
if (link.getTitle().equals("caption")) {
|
||||
if (link.getTargetURI().equals("caption")) {
|
||||
//make this form visible because we are editing and it is a caption not a link
|
||||
setVisible(state, true);
|
||||
}
|
||||
m_title.setValue(state, link.getTitle());
|
||||
m_description.setValue(state, link.getDescription());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,8 +32,10 @@ import com.arsdigita.bebop.event.FormProcessListener;
|
|||
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||
import com.arsdigita.bebop.event.FormValidationListener;
|
||||
import com.arsdigita.bebop.event.FormSubmissionListener;
|
||||
import com.arsdigita.bebop.form.DHTMLEditor;
|
||||
import com.arsdigita.bebop.form.Submit;
|
||||
import com.arsdigita.bebop.form.TextArea;
|
||||
import com.arsdigita.bebop.parameters.NotNullValidationListener;
|
||||
import com.arsdigita.bebop.parameters.StringLengthValidationListener;
|
||||
import com.arsdigita.cms.CMSConfig;
|
||||
import com.arsdigita.util.Assert;
|
||||
|
|
@ -73,6 +75,7 @@ public class RelatedLinkCaptionForm extends FormSection
|
|||
public static final String SSL_PROTOCOL = "https://";
|
||||
public static final String HTTP_PROTOCOL = "http://";
|
||||
protected TextArea m_description;
|
||||
protected TextArea m_title;
|
||||
protected ItemSelectionModel m_itemModel;
|
||||
protected LinkSelectionModel m_linkModel;
|
||||
private SaveCancelSection m_saveCancelSection;
|
||||
|
|
@ -128,14 +131,17 @@ public class RelatedLinkCaptionForm extends FormSection
|
|||
* Adds widgets to the form.
|
||||
*/
|
||||
protected void addWidgets() {
|
||||
|
||||
m_title = new DHTMLEditor("captiontitle");
|
||||
add(new Label(RelatedLinkGlobalizationUtil.globalize("cms.contentassets.ui.related_link.title")));
|
||||
add(m_title);
|
||||
|
||||
|
||||
/* Add the standard description field */
|
||||
m_description = new TextArea("description");
|
||||
m_description.setCols(40);
|
||||
m_description.setRows(5);
|
||||
m_description = new DHTMLEditor("description");
|
||||
m_description.addValidationListener(new NotNullValidationListener());
|
||||
m_description.addValidationListener(new StringLengthValidationListener(CMSConfig
|
||||
.getInstanceOf().getLinkDescMaxLength()));
|
||||
add(new Label(RelatedLinkGlobalizationUtil.globalize("cms.contentassets.ui.related_link.caption")));
|
||||
add(new Label(RelatedLinkGlobalizationUtil.globalize("cms.contentassets.ui.related_link.Description")));
|
||||
add(m_description);
|
||||
|
||||
}
|
||||
|
|
@ -230,7 +236,9 @@ public class RelatedLinkCaptionForm extends FormSection
|
|||
@Override
|
||||
public void validate(FormSectionEvent event)
|
||||
throws FormProcessException {
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -278,6 +286,7 @@ public class RelatedLinkCaptionForm extends FormSection
|
|||
s_log.debug("Init");
|
||||
s_log.debug("new link");
|
||||
m_description.setValue(state, null);
|
||||
m_title.setValue(state,null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -328,10 +337,17 @@ public class RelatedLinkCaptionForm extends FormSection
|
|||
protected void setLinkProperties(RelatedLink link, FormSectionEvent fse) {
|
||||
PageState state = fse.getPageState();
|
||||
FormData data = fse.getFormData();
|
||||
link.setTitle("caption");
|
||||
|
||||
String title = (String) m_title.getValue(state);
|
||||
if(!title.isEmpty()){
|
||||
link.setTitle(title);
|
||||
} else {
|
||||
//if user did not typed in a title
|
||||
link.setTitle(" ");
|
||||
}
|
||||
link.setDescription((String) m_description.getValue(state));
|
||||
link.setTargetType(RelatedLink.EXTERNAL_LINK);
|
||||
link.setTargetURI(null);
|
||||
link.setTargetURI("caption");
|
||||
link.setTargetWindow("");
|
||||
link.setResourceSize("");
|
||||
link.setResourceType(MimeType.loadMimeType("text/html"));
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ public class RelatedLinkEditForm extends RelatedLinkPropertyForm {
|
|||
if (getLinkSelectionModel().isSelected(ps)) {
|
||||
|
||||
rl = (RelatedLink) getLinkSelectionModel().getSelectedLink(ps);
|
||||
if (!rl.getTitle().equals("caption")) {
|
||||
if (!rl.getTargetURI().equals("caption")) {
|
||||
//make this form visible because we are editing and its not a caption
|
||||
setVisible(ps, true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,17 +62,17 @@ import java.net.URL;
|
|||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* Form to edit the basic properties of an Link. This form can be extended to create forms for Link
|
||||
* subclasses.
|
||||
* Form to edit the basic properties of an Link. This form can be extended to
|
||||
* create forms for Link subclasses.
|
||||
*
|
||||
* @version $Revision: #5 $ $Date: 2004/08/17 $
|
||||
* @author Nobuko Asakai (nasakai@redhat.com)
|
||||
* @author Sören Bernstein <quasi@quasiweb.de>
|
||||
*/
|
||||
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);
|
||||
|
||||
/**
|
||||
|
|
@ -95,44 +95,44 @@ public class LinkPropertyForm extends FormSection
|
|||
protected final String ITEM_SEARCH = "contentItem";
|
||||
|
||||
/**
|
||||
* Constructor creates a new form to edit the Link object specified by the item selection model
|
||||
* passed in.
|
||||
* Constructor creates a new form to edit the Link object specified by the
|
||||
* item selection model passed in.
|
||||
*
|
||||
* @param itemModel The ItemSelectionModel to use to obtain the ContentItem to which this link
|
||||
* is (or will be) attached
|
||||
* @param link The LinkSelectionModel to use to obtain the Link to work on
|
||||
* @param itemModel The ItemSelectionModel to use to obtain the ContentItem
|
||||
* to which this link is (or will be) attached
|
||||
* @param link The LinkSelectionModel to use to obtain the Link to work on
|
||||
*/
|
||||
public LinkPropertyForm(ItemSelectionModel itemModel,
|
||||
LinkSelectionModel link) {
|
||||
LinkSelectionModel link) {
|
||||
this(itemModel, link, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor creates a new form to edit the Link object specified by the item selection model
|
||||
* passed in.
|
||||
* Constructor creates a new form to edit the Link object specified by the
|
||||
* item selection model passed in.
|
||||
*
|
||||
* @param itemModel
|
||||
* @param link
|
||||
* @param contentType
|
||||
*/
|
||||
public LinkPropertyForm(ItemSelectionModel itemModel,
|
||||
LinkSelectionModel link,
|
||||
ContentType contentType) {
|
||||
|
||||
LinkSelectionModel link,
|
||||
ContentType contentType) {
|
||||
|
||||
super(new ColumnPanel(2));
|
||||
|
||||
|
||||
s_log.debug("property form constructor");
|
||||
m_linkModel = link;
|
||||
m_itemModel = itemModel;
|
||||
m_contentType = contentType;
|
||||
|
||||
|
||||
addWidgets();
|
||||
addSaveCancelSection();
|
||||
|
||||
|
||||
addInitListener(this);
|
||||
|
||||
|
||||
addValidationListener(this);
|
||||
|
||||
|
||||
addProcessListener(this);
|
||||
addSubmissionListener(this);
|
||||
}
|
||||
|
|
@ -153,14 +153,14 @@ public class LinkPropertyForm extends FormSection
|
|||
m_description.setCols(40);
|
||||
m_description.setRows(5);
|
||||
m_description.addValidationListener(new StringLengthValidationListener(CMSConfig
|
||||
.getInstanceOf().getLinkDescMaxLength()));
|
||||
.getInstanceOf().getLinkDescMaxLength()));
|
||||
add(new Label(GlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.description")));
|
||||
"cms.contenttypes.ui.description")));
|
||||
add(m_description);
|
||||
|
||||
|
||||
//add(new Label(
|
||||
add(new Embedded(
|
||||
"<script language=\"javascript\">\n"
|
||||
"<script language=\"javascript\">\n"
|
||||
+ "<!-- \n"
|
||||
+ "function toggle_link_fields(status) { \n"
|
||||
+ "// document.forms['linkEditForm'].targetURI.disabled = status; \n"
|
||||
|
|
@ -188,56 +188,56 @@ public class LinkPropertyForm extends FormSection
|
|||
+ "} \n"
|
||||
+ "// -->\n"
|
||||
+ "</script>\n",
|
||||
false));
|
||||
false));
|
||||
|
||||
/* Sub-title external URL / internal URL (content item) */
|
||||
add(new Label(GlobalizationUtil.globalize(
|
||||
"cms.contenttyes.link.ui.link_type_subtitle"),
|
||||
Label.BOLD),
|
||||
ColumnPanel.FULL_WIDTH);
|
||||
"cms.contenttyes.link.ui.link_type_subtitle"),
|
||||
Label.BOLD),
|
||||
ColumnPanel.FULL_WIDTH);
|
||||
|
||||
/* Option group to choose either external oder internal */
|
||||
m_linkType = new RadioGroup("linkType");
|
||||
|
||||
|
||||
Option m_external = new Option(
|
||||
Link.EXTERNAL_LINK,
|
||||
new Label(GlobalizationUtil.globalize(
|
||||
"cms.contenttyes.link.ui.option_group.link_type.external")));
|
||||
Link.EXTERNAL_LINK,
|
||||
new Label(GlobalizationUtil.globalize(
|
||||
"cms.contenttyes.link.ui.option_group.link_type.external")));
|
||||
m_external.setOnClick("enableUrlFields()");
|
||||
|
||||
|
||||
Option m_internal = new Option(
|
||||
Link.INTERNAL_LINK,
|
||||
new Label(GlobalizationUtil.globalize(
|
||||
"cms.contenttyes.link.ui.option_group.link_type.internal")));
|
||||
Link.INTERNAL_LINK,
|
||||
new Label(GlobalizationUtil.globalize(
|
||||
"cms.contenttyes.link.ui.option_group.link_type.internal")));
|
||||
m_internal.setOnClick("enableItemFields()");
|
||||
|
||||
|
||||
m_linkType.addOption(m_external);
|
||||
m_linkType.addOption(m_internal);
|
||||
m_linkType.setOptionSelected(m_internal);
|
||||
m_linkType.addValidationListener(new NotNullValidationListener());
|
||||
add(new Label(GlobalizationUtil.globalize(
|
||||
"cms.contenttyes.link.ui.option_group.link_type.label")));
|
||||
"cms.contenttyes.link.ui.option_group.link_type.label")));
|
||||
add(m_linkType);
|
||||
|
||||
/* External target */
|
||||
Fieldset externalFieldset = new Fieldset(GlobalizationUtil.globalize(
|
||||
"cms.contenttyes.link.ui.target_uri"));
|
||||
"cms.contenttyes.link.ui.target_uri"));
|
||||
externalFieldset.setClassAttr("externalLink autoHide");
|
||||
m_targetURI = new TextField("targetURI");
|
||||
m_targetURI.setOnFocus("toggle_link_fields(false)");
|
||||
m_targetURI.setHint(GlobalizationUtil.globalize(
|
||||
"cms.contenttyes.link.ui.target_uri_hint"));
|
||||
"cms.contenttyes.link.ui.target_uri_hint"));
|
||||
externalFieldset.add(new Label(GlobalizationUtil.globalize(
|
||||
"cms.contenttyes.link.ui.target_uri")));
|
||||
"cms.contenttyes.link.ui.target_uri")));
|
||||
externalFieldset.add(m_targetURI);
|
||||
add(externalFieldset);
|
||||
|
||||
/* Internal target */
|
||||
Fieldset internalFieldset = new Fieldset(GlobalizationUtil.globalize(
|
||||
"cms.contenttyes.link.ui.target_content_item"));
|
||||
"cms.contenttyes.link.ui.target_content_item"));
|
||||
internalFieldset.setClassAttr("internalLink autoHide");
|
||||
internalFieldset.add(new Label(GlobalizationUtil.globalize(
|
||||
"cms.contenttyes.link.ui.target_content_item")));
|
||||
"cms.contenttyes.link.ui.target_content_item")));
|
||||
m_itemSearch = new ItemSearchWidget(ITEM_SEARCH, m_contentType);
|
||||
m_itemSearch.getSearchButton().setOnFocus("toggle_link_fields(true)");
|
||||
m_itemSearch.getClearButton().setOnFocus("toggle_link_fields(true)");
|
||||
|
|
@ -245,11 +245,11 @@ public class LinkPropertyForm extends FormSection
|
|||
|
||||
/* Optional parameters for internal target */
|
||||
internalFieldset.add(new Label(GlobalizationUtil.globalize(
|
||||
"cms.contenttyes.link.ui.target_parameters")));
|
||||
"cms.contenttyes.link.ui.target_parameters")));
|
||||
m_itemParams = new TextField("itemParams");
|
||||
m_itemParams.setOnFocus("toggle_link_fields(true)");
|
||||
m_itemParams.setHint(GlobalizationUtil.globalize(
|
||||
"cms.contenttyes.link.ui.target_parameters_hint"));
|
||||
"cms.contenttyes.link.ui.target_parameters_hint"));
|
||||
internalFieldset.add(m_itemParams);
|
||||
add(internalFieldset);
|
||||
|
||||
|
|
@ -260,9 +260,9 @@ public class LinkPropertyForm extends FormSection
|
|||
// 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")));
|
||||
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);
|
||||
|
|
@ -270,7 +270,7 @@ public class LinkPropertyForm extends FormSection
|
|||
|
||||
//add(new Label(
|
||||
add(new Embedded(
|
||||
"<script language=\"javascript\">\n"
|
||||
"<script language=\"javascript\">\n"
|
||||
+ "<!-- \n"
|
||||
+ "if (document.forms['linkEditForm'].linkType[0].checked) { \n"
|
||||
+ " //toggle_link_fields(false); \n"
|
||||
|
|
@ -281,7 +281,7 @@ public class LinkPropertyForm extends FormSection
|
|||
+ "} \n"
|
||||
+ "// -->\n"
|
||||
+ "</script>\n",
|
||||
false), ColumnPanel.FULL_WIDTH);
|
||||
false), ColumnPanel.FULL_WIDTH);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -291,37 +291,37 @@ public class LinkPropertyForm extends FormSection
|
|||
m_saveCancelSection = new SaveCancelSection();
|
||||
try {
|
||||
m_saveCancelSection.getCancelButton().addPrintListener(
|
||||
new PrintListener() {
|
||||
|
||||
@Override
|
||||
public void prepare(PrintEvent e) {
|
||||
Submit target = (Submit) e.getTarget();
|
||||
if (m_linkModel.isSelected(e.getPageState())) {
|
||||
target.setButtonLabel(GlobalizationUtil.globalize(
|
||||
"cms.contenttyes.link.ui.button_cancel"));
|
||||
} else {
|
||||
target.setButtonLabel(GlobalizationUtil.globalize(
|
||||
"cms.contenttyes.link.ui.button_reset"));
|
||||
new PrintListener() {
|
||||
|
||||
@Override
|
||||
public void prepare(PrintEvent e) {
|
||||
Submit target = (Submit) e.getTarget();
|
||||
if (m_linkModel.isSelected(e.getPageState())) {
|
||||
target.setButtonLabel(GlobalizationUtil.globalize(
|
||||
"cms.contenttyes.link.ui.button_cancel"));
|
||||
} else {
|
||||
target.setButtonLabel(GlobalizationUtil.globalize(
|
||||
"cms.contenttyes.link.ui.button_reset"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
m_saveCancelSection.getSaveButton().addPrintListener(
|
||||
new PrintListener() {
|
||||
|
||||
@Override
|
||||
public void prepare(PrintEvent e) {
|
||||
Submit target = (Submit) e.getTarget();
|
||||
if (m_linkModel.isSelected(e.getPageState())) {
|
||||
target.setButtonLabel(GlobalizationUtil.globalize(
|
||||
"cms.contenttyes.link.ui.button_save"));
|
||||
} else {
|
||||
target.setButtonLabel(GlobalizationUtil.globalize(
|
||||
"cms.contenttyes.link.ui.button_create"));
|
||||
new PrintListener() {
|
||||
|
||||
@Override
|
||||
public void prepare(PrintEvent e) {
|
||||
Submit target = (Submit) e.getTarget();
|
||||
if (m_linkModel.isSelected(e.getPageState())) {
|
||||
target.setButtonLabel(GlobalizationUtil.globalize(
|
||||
"cms.contenttyes.link.ui.button_save"));
|
||||
} else {
|
||||
target.setButtonLabel(GlobalizationUtil.globalize(
|
||||
"cms.contenttyes.link.ui.button_create"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
} catch (TooManyListenersException e) {
|
||||
throw new UncheckedWrapperException("this cannot happen", e);
|
||||
}
|
||||
|
|
@ -353,7 +353,7 @@ public class LinkPropertyForm extends FormSection
|
|||
*/
|
||||
@Override
|
||||
public void submitted(FormSectionEvent e)
|
||||
throws FormProcessException {
|
||||
throws FormProcessException {
|
||||
if (m_saveCancelSection.getCancelButton().isSelected(e.getPageState())) {
|
||||
s_log.debug("cancel in submission listener");
|
||||
m_linkModel.clearSelection(e.getPageState());
|
||||
|
|
@ -364,7 +364,8 @@ public class LinkPropertyForm extends FormSection
|
|||
}
|
||||
|
||||
/**
|
||||
* Validation listener. Ensures consistency of internal vs. external link data
|
||||
* Validation listener. Ensures consistency of internal vs. external link
|
||||
* data
|
||||
*
|
||||
* @param event the FormSectionEvent
|
||||
*
|
||||
|
|
@ -372,34 +373,34 @@ public class LinkPropertyForm extends FormSection
|
|||
*/
|
||||
@Override
|
||||
public void validate(FormSectionEvent event)
|
||||
throws FormProcessException {
|
||||
throws FormProcessException {
|
||||
PageState state = event.getPageState();
|
||||
FormData data = event.getFormData();
|
||||
|
||||
|
||||
if (Link.EXTERNAL_LINK.equals((String) m_linkType.getValue(state))) {
|
||||
// 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(GlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.external_link_requires_uri_field"));
|
||||
"cms.contenttypes.ui.external_link_requires_uri_field"));
|
||||
}
|
||||
|
||||
|
||||
String url = (String) m_targetURI.getValue(state);
|
||||
|
||||
|
||||
try {
|
||||
// See if it's a valid URL
|
||||
URL test = new URL(url);
|
||||
} catch (MalformedURLException ex) {
|
||||
boolean localLink = url.startsWith("/");
|
||||
boolean hasProtocol = url.indexOf("://") != -1;
|
||||
|
||||
|
||||
String newURL;
|
||||
if (localLink) {
|
||||
// For a local link, see if it would be ok if we stuck
|
||||
// "http://servername" on the front
|
||||
|
||||
newURL = HTTP_PROTOCOL + Web.getConfig().getHost()
|
||||
+ url;
|
||||
+ url;
|
||||
} else if (!hasProtocol) {
|
||||
// There's no protocol. See if it would be ok if we
|
||||
// put one on the beginning
|
||||
|
|
@ -407,30 +408,30 @@ public class LinkPropertyForm extends FormSection
|
|||
newURL = HTTP_PROTOCOL + url;
|
||||
} else {
|
||||
// No idea, just throw the error
|
||||
|
||||
|
||||
// originally: "URL is not valid: " + ex.getMessage()
|
||||
throw new FormProcessException(GlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.url_not_valid"));
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
URL test = new URL(newURL);
|
||||
} catch (MalformedURLException ex2) {
|
||||
StringBuilder msg = new StringBuilder();
|
||||
|
||||
|
||||
/* excluded by Tobias Osmers to change the FormProcessException
|
||||
if (localLink) {
|
||||
// For local link, report the error after we put a
|
||||
// protocol and servername on it
|
||||
msg.append("Local URL is not valid: ");
|
||||
msg.append(ex2.getMessage());
|
||||
} else {
|
||||
// For external link, report the error before we tried
|
||||
// to munge it
|
||||
msg.append("External URL is not valid: ");
|
||||
msg.append(ex.getMessage());
|
||||
}
|
||||
*/
|
||||
if (localLink) {
|
||||
// For local link, report the error after we put a
|
||||
// protocol and servername on it
|
||||
msg.append("Local URL is not valid: ");
|
||||
msg.append(ex2.getMessage());
|
||||
} else {
|
||||
// For external link, report the error before we tried
|
||||
// to munge it
|
||||
msg.append("External URL is not valid: ");
|
||||
msg.append(ex.getMessage());
|
||||
}
|
||||
*/
|
||||
throw new FormProcessException(GlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.url_not_valid"));
|
||||
}
|
||||
|
|
@ -440,20 +441,20 @@ public class LinkPropertyForm extends FormSection
|
|||
if (!localLink && !hasProtocol) {
|
||||
m_targetURI.setValue(state, newURL);
|
||||
throw new FormProcessException(
|
||||
GlobalizationUtil.globalize("cms.contenttypes.ui.url_missing_protocol"));
|
||||
GlobalizationUtil.globalize("cms.contenttypes.ui.url_missing_protocol"));
|
||||
}
|
||||
}
|
||||
} else if (Link.INTERNAL_LINK.equals((String) m_linkType.getValue(
|
||||
state))) {
|
||||
state))) {
|
||||
// The link is internal, the item selected must be not null
|
||||
if (data.get(ITEM_SEARCH) == null) {
|
||||
throw new FormProcessException(
|
||||
GlobalizationUtil.globalize("cms.contenttypes.ui.internal_link_requires_item_selection"));
|
||||
GlobalizationUtil.globalize("cms.contenttypes.ui.internal_link_requires_item_selection"));
|
||||
}
|
||||
// Quasimodo
|
||||
// The target of the link must not be the same as the owner
|
||||
if (m_itemModel.getSelectedItem(state).getID().equals(
|
||||
((ContentItem) data.get(ITEM_SEARCH)).getID())) {
|
||||
((ContentItem) data.get(ITEM_SEARCH)).getID())) {
|
||||
throw new FormProcessException(GlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.false_link_target"));
|
||||
}
|
||||
|
|
@ -495,24 +496,26 @@ public class LinkPropertyForm extends FormSection
|
|||
@Override
|
||||
public void init(FormSectionEvent fse) throws FormProcessException {
|
||||
FormData data = fse.getFormData();
|
||||
PageState state = fse.getPageState();
|
||||
PageState state = fse.getPageState();
|
||||
s_log.debug("Init");
|
||||
setVisible(state, true);
|
||||
Link link;
|
||||
if (m_linkModel.isSelected(state)) {
|
||||
s_log.debug("Edit");
|
||||
link = m_linkModel.getSelectedLink(state);
|
||||
|
||||
if(link.getTitle().equals("caption")){
|
||||
setVisible(state,false);
|
||||
}
|
||||
|
||||
if (link.getTargetURI()!= null && link.getTargetURI().equals("caption")) {
|
||||
setVisible(state, false);
|
||||
}
|
||||
try {
|
||||
m_title.setValue(state, link.getTitle());
|
||||
if(link.getTitle()!=null){
|
||||
m_title.setValue(state, link.getTitle());}
|
||||
m_description.setValue(state, link.getDescription());
|
||||
if ((link.getTargetURI() != null)
|
||||
if ((link.getTargetURI() != null)
|
||||
&& (!link.getTargetURI().equals("caption"))
|
||||
&& link.getTargetURI().startsWith("&")) {
|
||||
m_itemParams.setValue(state,
|
||||
link.getTargetURI().substring(1));
|
||||
link.getTargetURI().substring(1));
|
||||
} else {
|
||||
m_targetURI.setValue(state, link.getTargetURI());
|
||||
}
|
||||
|
|
@ -525,7 +528,7 @@ public class LinkPropertyForm extends FormSection
|
|||
if (Link.INTERNAL_LINK.equals(link.getTargetType())) {
|
||||
data.put(ITEM_SEARCH, link.getTargetItem());
|
||||
}
|
||||
|
||||
|
||||
} catch (IllegalStateException e) {
|
||||
s_log.error(e.getMessage());
|
||||
throw e;
|
||||
|
|
@ -559,9 +562,9 @@ public class LinkPropertyForm extends FormSection
|
|||
// cancel button is selected
|
||||
m_linkModel.clearSelection(state);
|
||||
s_log.debug("link save canceled");
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
if (m_linkModel.isSelected(state)) {
|
||||
// Editing a link
|
||||
s_log.debug("processing link edit");
|
||||
|
|
@ -574,7 +577,7 @@ public class LinkPropertyForm extends FormSection
|
|||
//call to set various properties of Link.
|
||||
setLinkProperties(link, fse);
|
||||
s_log.debug("Created Link with ID: " + link.getOID().toString()
|
||||
+ "Title " + link.getTitle());
|
||||
+ "Title " + link.getTitle());
|
||||
}
|
||||
// XXX Initialize the form
|
||||
m_linkModel.clearSelection(state);
|
||||
|
|
@ -582,8 +585,8 @@ public class LinkPropertyForm extends FormSection
|
|||
}
|
||||
|
||||
/**
|
||||
* Set various properties of the Link.Child clases can over-ride this method to add additional
|
||||
* properties to Link.
|
||||
* Set various properties of the Link.Child clases can over-ride this method
|
||||
* to add additional properties to Link.
|
||||
*
|
||||
* @param link
|
||||
* @param fse
|
||||
|
|
@ -599,7 +602,7 @@ public class LinkPropertyForm extends FormSection
|
|||
// Process internal and external urls
|
||||
if (Link.EXTERNAL_LINK.equals(m_linkType.getValue(state))) {
|
||||
link.setTargetURI(
|
||||
(String) m_targetURI.getValue(state));
|
||||
(String) m_targetURI.getValue(state));
|
||||
link.setTargetItem(null);
|
||||
} else {
|
||||
// Internal
|
||||
|
|
@ -607,7 +610,7 @@ public class LinkPropertyForm extends FormSection
|
|||
link.setTargetURI(null);
|
||||
} else {
|
||||
link.setTargetURI(String.format("&%s", m_itemParams.getValue(
|
||||
state)));
|
||||
state)));
|
||||
}
|
||||
|
||||
// Quasimodo: BEGIN
|
||||
|
|
@ -624,7 +627,7 @@ public class LinkPropertyForm extends FormSection
|
|||
// negotiate the language depending on browser settings
|
||||
ci = (ContentItem) ci.getParent();
|
||||
}
|
||||
|
||||
|
||||
link.setTargetItem(ci);
|
||||
}
|
||||
// Process whether link is to be opened in new window
|
||||
|
|
@ -640,8 +643,8 @@ public class LinkPropertyForm extends FormSection
|
|||
} else {
|
||||
link.setTargetWindow("");
|
||||
}
|
||||
|
||||
|
||||
link.save();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -204,16 +204,16 @@ public class LinkTable extends Table {
|
|||
boolean isLast = (row == ((Long) m_size.get(state)).intValue() - 1);
|
||||
|
||||
if (column == m_titleCol.getModelIndex()) {
|
||||
String url = link.getInternalOrExternalURI(state);
|
||||
if (link.getTitle().equals("caption")) {
|
||||
ExternalLink extLink = new ExternalLink("", url);
|
||||
extLink.setTargetFrame("_blank");
|
||||
return extLink;
|
||||
} else {
|
||||
ExternalLink extLink = new ExternalLink(link.getTitle(), url);
|
||||
extLink.setTargetFrame("_blank");
|
||||
return extLink;
|
||||
|
||||
if (link.getTargetURI()!=null && link.getTargetURI().equals("caption")) {
|
||||
Label label = new Label(link.getTitle());
|
||||
return label;
|
||||
}
|
||||
String url = link.getInternalOrExternalURI(state);
|
||||
ExternalLink extLink = new ExternalLink(link.getTitle(), url);
|
||||
extLink.setTargetFrame("_blank");
|
||||
return extLink;
|
||||
|
||||
} else if (column == m_descCol.getModelIndex()) {
|
||||
if (isSelected) {
|
||||
return new Label(link.getDescription(), Label.BOLD);
|
||||
|
|
|
|||
Loading…
Reference in New Issue