CT HTMLForm
Wird jetzt von GenericArticle statt von CT Article abgeleitet. Dadurch läßt er sich unabhängig von CT Article installieren. git-svn-id: https://svn.libreccm.org/ccm/trunk@671 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
9a4a3caef0
commit
a76bf6287f
|
|
@ -8,7 +8,6 @@
|
||||||
<ccm:dependencies>
|
<ccm:dependencies>
|
||||||
<ccm:requires name="ccm-core" version="6.6.0" relation="ge"/>
|
<ccm:requires name="ccm-core" version="6.6.0" relation="ge"/>
|
||||||
<ccm:requires name="ccm-cms" version="6.6.0" relation="ge"/>
|
<ccm:requires name="ccm-cms" version="6.6.0" relation="ge"/>
|
||||||
<ccm:requires name="ccm-cms-types-article" version="6.6.0" relation="ge"/>
|
|
||||||
</ccm:dependencies>
|
</ccm:dependencies>
|
||||||
<ccm:directories>
|
<ccm:directories>
|
||||||
<ccm:directory name="pdl"/>
|
<ccm:directory name="pdl"/>
|
||||||
|
|
|
||||||
|
|
@ -17,5 +17,8 @@
|
||||||
model com.arsdigita.cms.contenttypes;
|
model com.arsdigita.cms.contenttypes;
|
||||||
|
|
||||||
|
|
||||||
object type HTMLForm extends Article {
|
object type HTMLForm extends GenericArticle {
|
||||||
|
String [0..1] lead = ct_htmlform.lead VARCHAR(1000);
|
||||||
|
|
||||||
|
reference key (ct_htmlform.item_id);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
labelBundle="com.arsdigita.cms.CMSResources"
|
labelBundle="com.arsdigita.cms.CMSResources"
|
||||||
descriptionKey="cms.contenttypes.shared.basic_properties.description"
|
descriptionKey="cms.contenttypes.shared.basic_properties.description"
|
||||||
descriptionBundle="com.arsdigita.cms.CMSResources"
|
descriptionBundle="com.arsdigita.cms.CMSResources"
|
||||||
component="com.arsdigita.cms.contenttypes.ui.ArticlePropertiesStep"/>
|
component="com.arsdigita.cms.contenttypes.ui.HTMLFormPropertiesStep"/>
|
||||||
|
|
||||||
<ctd:include href="/WEB-INF/content-types/edit-body-text-step.xml"/>
|
<ctd:include href="/WEB-INF/content-types/edit-body-text-step.xml"/>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,6 @@
|
||||||
<table name="acs_objects"/>
|
<table name="acs_objects"/>
|
||||||
<table name="cms_items"/>
|
<table name="cms_items"/>
|
||||||
<initializer class="com.arsdigita.cms.Initializer"/>
|
<initializer class="com.arsdigita.cms.Initializer"/>
|
||||||
<table name="ct_articles"/>
|
|
||||||
<initializer class="com.arsdigita.cms.contenttypes.ArticleInitializer"/>
|
|
||||||
</requires>
|
</requires>
|
||||||
<provides>
|
<provides>
|
||||||
<initializer class="com.arsdigita.cms.contenttypes.HTMLFormInitializer"/>
|
<initializer class="com.arsdigita.cms.contenttypes.HTMLFormInitializer"/>
|
||||||
|
|
|
||||||
|
|
@ -28,11 +28,14 @@ import java.math.BigDecimal;
|
||||||
*
|
*
|
||||||
* @version $Revision: #1 $ $Date: 2004/03/05 $
|
* @version $Revision: #1 $ $Date: 2004/03/05 $
|
||||||
*/
|
*/
|
||||||
public class HTMLForm extends Article {
|
public class HTMLForm extends GenericArticle {
|
||||||
|
|
||||||
private final static org.apache.log4j.Logger s_log =
|
private final static org.apache.log4j.Logger s_log =
|
||||||
org.apache.log4j.Logger.getLogger(HTMLForm.class);
|
org.apache.log4j.Logger.getLogger(HTMLForm.class);
|
||||||
|
|
||||||
|
/** PDL property name for lead */
|
||||||
|
public static final String LEAD = "lead";
|
||||||
|
|
||||||
/** 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.HTMLForm";
|
= "com.arsdigita.cms.contenttypes.HTMLForm";
|
||||||
|
|
@ -68,4 +71,20 @@ public class HTMLForm extends Article {
|
||||||
|
|
||||||
Assert.exists(getContentType(), ContentType.class);
|
Assert.exists(getContentType(), ContentType.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getLead() {
|
||||||
|
return (String) get( LEAD );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLead( String lead ) {
|
||||||
|
set( LEAD, lead );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final int SUMMARY_LENGTH = 200;
|
||||||
|
public String getSearchSummary() {
|
||||||
|
return com.arsdigita.util.StringUtils.truncateString(getLead(),
|
||||||
|
SUMMARY_LENGTH,
|
||||||
|
true);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,6 @@
|
||||||
|
|
||||||
package com.arsdigita.cms.contenttypes;
|
package com.arsdigita.cms.contenttypes;
|
||||||
|
|
||||||
import com.arsdigita.cms.contenttypes.AbstractContentTypeLoader;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loader.
|
* Loader.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,95 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2002-2004 Red Hat Inc. 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.contenttypes.ui;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.Component;
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.cms.ContentPage;
|
||||||
|
import com.arsdigita.cms.ContentSection;
|
||||||
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
|
import com.arsdigita.cms.contenttypes.HTMLForm;
|
||||||
|
import com.arsdigita.domain.DomainObject;
|
||||||
|
import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
|
||||||
|
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
||||||
|
import com.arsdigita.cms.ui.authoring.BasicPageForm;
|
||||||
|
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
||||||
|
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
|
||||||
|
import com.arsdigita.cms.util.GlobalizationUtil;
|
||||||
|
import java.text.DateFormat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Authoring step to edit the simple attributes of the HTMLForm content
|
||||||
|
* type (and its subclasses). The attributes edited are 'name', 'title'
|
||||||
|
* and 'lead'. This authoring step replaces
|
||||||
|
* the <code>com.arsdigita.ui.authoring.PageEdit</code> step for this type.
|
||||||
|
*/
|
||||||
|
public class HTMLFormPropertiesStep extends SimpleEditStep {
|
||||||
|
|
||||||
|
/** The name of the editing sheet added to this step */
|
||||||
|
public static String EDIT_SHEET_NAME = "edit";
|
||||||
|
|
||||||
|
public HTMLFormPropertiesStep(ItemSelectionModel itemModel, AuthoringKitWizard parent) {
|
||||||
|
super(itemModel, parent);
|
||||||
|
|
||||||
|
setDefaultEditKey(EDIT_SHEET_NAME);
|
||||||
|
|
||||||
|
BasicPageForm editSheet;
|
||||||
|
|
||||||
|
editSheet = new HTMLFormPropertyForm(itemModel, this);
|
||||||
|
add(EDIT_SHEET_NAME, "Edit", new WorkflowLockedComponentAccess(editSheet, itemModel),
|
||||||
|
editSheet.getSaveCancelSection().getCancelButton());
|
||||||
|
|
||||||
|
setDisplayComponent(getHTMLFormPropertySheet(itemModel));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a component that displays the properties of the
|
||||||
|
* HTMLForm specified by the ItemSelectionModel passed in.
|
||||||
|
* @param itemModel The ItemSelectionModel to use
|
||||||
|
* @pre itemModel != null
|
||||||
|
* @return A component to display the state of the basic properties
|
||||||
|
* of the release
|
||||||
|
*/
|
||||||
|
public static Component getHTMLFormPropertySheet(ItemSelectionModel itemModel) {
|
||||||
|
DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(itemModel);
|
||||||
|
|
||||||
|
sheet.add(GlobalizationUtil.globalize("cms.contenttypes.ui.name"), HTMLForm.NAME);
|
||||||
|
sheet.add(GlobalizationUtil.globalize("cms.contenttypes.ui.title"), HTMLForm.TITLE);
|
||||||
|
if (!ContentSection.getConfig().getHideLaunchDate()) {
|
||||||
|
sheet.add(GlobalizationUtil.globalize("cms.contenttypes.ui.launch_date"),
|
||||||
|
ContentPage.LAUNCH_DATE,
|
||||||
|
new DomainObjectPropertySheet.AttributeFormatter() {
|
||||||
|
|
||||||
|
public String format(DomainObject item,
|
||||||
|
String attribute,
|
||||||
|
PageState state) {
|
||||||
|
ContentPage page = (ContentPage) item;
|
||||||
|
if (page.getLaunchDate() != null) {
|
||||||
|
return DateFormat.getDateInstance(DateFormat.LONG).format(page.getLaunchDate());
|
||||||
|
} else {
|
||||||
|
return (String) GlobalizationUtil.globalize("cms.ui.unknown").localize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
sheet.add(GlobalizationUtil.globalize("cms.contenttypes.ui.lead"), HTMLForm.LEAD);
|
||||||
|
|
||||||
|
return sheet;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,134 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2002-2004 Red Hat Inc. 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.contenttypes.ui;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.FormData;
|
||||||
|
import com.arsdigita.bebop.FormProcessException;
|
||||||
|
import com.arsdigita.bebop.Label;
|
||||||
|
import com.arsdigita.bebop.event.FormInitListener;
|
||||||
|
import com.arsdigita.bebop.event.FormProcessListener;
|
||||||
|
import com.arsdigita.bebop.event.FormSubmissionListener;
|
||||||
|
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||||
|
import com.arsdigita.bebop.form.TextArea;
|
||||||
|
import com.arsdigita.bebop.parameters.NotEmptyValidationListener;
|
||||||
|
import com.arsdigita.bebop.parameters.ParameterModel;
|
||||||
|
import com.arsdigita.bebop.parameters.StringInRangeValidationListener;
|
||||||
|
import com.arsdigita.bebop.parameters.StringParameter;
|
||||||
|
import com.arsdigita.cms.ContentSection;
|
||||||
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
|
import com.arsdigita.cms.contenttypes.HTMLForm;
|
||||||
|
import com.arsdigita.cms.ui.authoring.BasicPageForm;
|
||||||
|
import com.arsdigita.cms.util.GlobalizationUtil;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Form to edit the basic properties of an HTMLForm. This form can be
|
||||||
|
* extended to create forms for HTMLForm subclasses.
|
||||||
|
*/
|
||||||
|
public class HTMLFormPropertyForm extends BasicPageForm implements FormProcessListener, FormInitListener, FormSubmissionListener {
|
||||||
|
|
||||||
|
private final static org.apache.log4j.Logger s_log =
|
||||||
|
org.apache.log4j.Logger.getLogger(HTMLFormPropertyForm.class);
|
||||||
|
private HTMLFormPropertiesStep m_step;
|
||||||
|
public static final String LEAD = "lead";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new form to edit the HTMLForm object specified
|
||||||
|
* by the item selection model passed in.
|
||||||
|
* @param itemModel The ItemSelectionModel to use to obtain the
|
||||||
|
* HTMLForm to work on
|
||||||
|
*/
|
||||||
|
public HTMLFormPropertyForm(ItemSelectionModel itemModel) {
|
||||||
|
this(itemModel, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new form to edit the HTMLForm object specified
|
||||||
|
* by the item selection model passed in.
|
||||||
|
* @param itemModel The ItemSelectionModel to use to obtain the
|
||||||
|
* HTMLForm to work on
|
||||||
|
* @param step The HTMLFormPropertiesStep which controls this form.
|
||||||
|
*/
|
||||||
|
public HTMLFormPropertyForm(ItemSelectionModel itemModel, HTMLFormPropertiesStep step) {
|
||||||
|
super(ID, itemModel);
|
||||||
|
m_step = step;
|
||||||
|
addSubmissionListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds widgets to the form.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void addWidgets() {
|
||||||
|
super.addWidgets();
|
||||||
|
|
||||||
|
add(new Label(GlobalizationUtil.globalize("cms.contenttypes.ui.lead")));
|
||||||
|
ParameterModel leadParam = new StringParameter(LEAD);
|
||||||
|
|
||||||
|
if (ContentSection.getConfig().mandatoryDescriptions()) {
|
||||||
|
leadParam.addParameterListener(new NotEmptyValidationListener(GlobalizationUtil.globalize("cms.contenttypes.ui.description_missing")));
|
||||||
|
}
|
||||||
|
//leadParam
|
||||||
|
// .addParameterListener( new NotNullValidationListener() );
|
||||||
|
leadParam.addParameterListener(new StringInRangeValidationListener(0, 1000));
|
||||||
|
TextArea lead = new TextArea(leadParam);
|
||||||
|
lead.setCols(40);
|
||||||
|
lead.setRows(5);
|
||||||
|
add(lead);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void validate(FormSectionEvent e) throws FormProcessException {
|
||||||
|
FormData d = e.getFormData();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Form initialisation hook. Fills widgets with data. */
|
||||||
|
public void init(FormSectionEvent fse) {
|
||||||
|
// Do some initialization hook stuff
|
||||||
|
FormData data = fse.getFormData();
|
||||||
|
HTMLForm htmlform = (HTMLForm) super.initBasicWidgets(fse);
|
||||||
|
|
||||||
|
data.put(LEAD, htmlform.getLead());
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Cancels streamlined editing. */
|
||||||
|
public void submitted(FormSectionEvent fse) {
|
||||||
|
if (m_step != null
|
||||||
|
&& getSaveCancelSection().getCancelButton().isSelected(fse.getPageState())) {
|
||||||
|
m_step.cancelStreamlinedCreation(fse.getPageState());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Form processing hook. Saves Event object. */
|
||||||
|
public void process(FormSectionEvent fse) {
|
||||||
|
FormData data = fse.getFormData();
|
||||||
|
|
||||||
|
HTMLForm htmlform = (HTMLForm) super.processBasicWidgets(fse);
|
||||||
|
|
||||||
|
// save only if save button was pressed
|
||||||
|
if (htmlform != null
|
||||||
|
&& getSaveCancelSection().getSaveButton().isSelected(fse.getPageState())) {
|
||||||
|
|
||||||
|
htmlform.setLead((String) data.get(LEAD));
|
||||||
|
htmlform.save();
|
||||||
|
}
|
||||||
|
if (m_step != null) {
|
||||||
|
m_step.maybeForwardToNextStep(fse.getPageState());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue