Integrated r1948,r1949,r1950,r1951 (ccm-cms)

- Display of information about index items is now more informative and accurate 
- Upload option can now be turned off for text assets 
  using com.arsdigita.cms.hide_text_asset_upload_file configuration property
- Can hide the action for creating a content item from the content sections list 
- Users were adding brackets () to the Name field of a content item in basic 
  properties resulting in "page not found" error when you try to open the 
  published item


git-svn-id: https://svn.libreccm.org/ccm/trunk@254 8810af33-2d31-482b-a856-94f89814c4df
master
pb 2009-08-28 19:17:42 +00:00
parent d79d3985f1
commit dec240bf3b
12 changed files with 149 additions and 71 deletions

View File

@ -151,6 +151,8 @@ public final class ContentSectionConfig extends AbstractConfig {
private final Parameter m_deleteWorkflowNotificationsWhenSent; private final Parameter m_deleteWorkflowNotificationsWhenSent;
private final Parameter m_hasContactsAuthoringStep; private final Parameter m_hasContactsAuthoringStep;
private final Parameter m_categoryTreeOrdering; private final Parameter m_categoryTreeOrdering;
private final Parameter m_hideTextAssetUploadFile;
private final Parameter m_allowContentCreateInSectionListing;
/** /**
* Do not instantiate this class directly. * Do not instantiate this class directly.
@ -397,6 +399,15 @@ public final class ContentSectionConfig extends AbstractConfig {
("com.arsdigita.cms.has_contacts_authoring_step", ("com.arsdigita.cms.has_contacts_authoring_step",
Parameter.REQUIRED, new Boolean(false)); Parameter.REQUIRED, new Boolean(false));
m_hideTextAssetUploadFile = new BooleanParameter(
"com.arsdigita.cms.hide_text_asset_upload_file",
Parameter.REQUIRED,
new Boolean(false));
m_allowContentCreateInSectionListing = new BooleanParameter(
"com.arsdigita.cms.allow_content_create_in_section_listing",
Parameter.REQUIRED,
new Boolean(true));
register(m_templateRootPath); register(m_templateRootPath);
register(m_defaultItemTemplatePath); register(m_defaultItemTemplatePath);
@ -445,6 +456,8 @@ public final class ContentSectionConfig extends AbstractConfig {
register(m_deleteWorkflowNotificationsWhenSent); register(m_deleteWorkflowNotificationsWhenSent);
register(m_categoryTreeOrdering); register(m_categoryTreeOrdering);
register(m_hasContactsAuthoringStep); register(m_hasContactsAuthoringStep);
register(m_hideTextAssetUploadFile);
register(m_allowContentCreateInSectionListing);
loadInfo(); loadInfo();
} }
@ -807,4 +820,11 @@ public final class ContentSectionConfig extends AbstractConfig {
return ((Boolean) get(m_hasContactsAuthoringStep)).booleanValue(); return ((Boolean) get(m_hasContactsAuthoringStep)).booleanValue();
} }
public final boolean getHideTextAssetUploadFile() {
return ((Boolean) get(m_hideTextAssetUploadFile)).booleanValue();
}
public final boolean getAllowContentCreateInSectionListing() {
return ((Boolean) get(m_allowContentCreateInSectionListing)).booleanValue();
}
} }

View File

@ -232,3 +232,13 @@ com.arsdigita.cms.has_contacts_authoring_step.title=Contacts for content items
com.arsdigita.cms.has_contacts_authoring_step.purpose=Allows you to add a Contact authoring step to all items com.arsdigita.cms.has_contacts_authoring_step.purpose=Allows you to add a Contact authoring step to all items
com.arsdigita.cms.has_contacts_authoring_step.example=false com.arsdigita.cms.has_contacts_authoring_step.example=false
com.arsdigita.cms.has_contacts_authoring_step.format=[boolean] com.arsdigita.cms.has_contacts_authoring_step.format=[boolean]
com.arsdigita.cms.hide_text_asset_upload_file.title=Hide upload file link for text assets
com.arsdigita.cms.hide_text_asset_upload_file.purpose=Hide the upload file link in the editing of a text asset
com.arsdigita.cms.hide_text_asset_upload_file.example=false
com.arsdigita.cms.hide_text_asset_upload_file.format=[boolean]
com.arsdigita.cms.allow_content_create_in_section_listing.title=Allow content creation in section listing
com.arsdigita.cms.allow_content_create_in_section_listing.purpose=Allows you to turn off the ability to create content in the section listing
com.arsdigita.cms.allow_content_create_in_section_listing.example=true
com.arsdigita.cms.allow_content_create_in_section_listing.format=[boolean]

View File

@ -19,6 +19,8 @@
package com.arsdigita.cms.ui; package com.arsdigita.cms.ui;
import java.math.BigDecimal;
import com.arsdigita.bebop.Component; import com.arsdigita.bebop.Component;
import com.arsdigita.bebop.FormProcessException; import com.arsdigita.bebop.FormProcessException;
import com.arsdigita.bebop.Label; import com.arsdigita.bebop.Label;
@ -55,8 +57,6 @@ import com.arsdigita.util.Assert;
import com.arsdigita.util.LockableImpl; import com.arsdigita.util.LockableImpl;
import com.arsdigita.web.Web; import com.arsdigita.web.Web;
import java.math.BigDecimal;
/** /**
* Displays all the content sections in table, with links to the admin * Displays all the content sections in table, with links to the admin
* and public pages. Also displays a form for each content section to * and public pages. Also displays a form for each content section to
@ -107,15 +107,15 @@ public class ContentSectionContainer extends CMSContainer {
m_typeSel = typeSel; m_typeSel = typeSel;
m_sectionSel = sectionSel; m_sectionSel = sectionSel;
m_formContainer = new FormContainer(); m_formContainer = new FormContainer();
add(m_formContainer); add(m_formContainer);
m_table = new ContentSectionTable(); m_table = new ContentSectionTable();
add(m_table); add(m_table);
} }
public void register(Page p) { public void register(Page p) {
super.register(p); super.register(p);
p.setVisibleDefault(m_formContainer, false); p.setVisibleDefault(m_formContainer, false);
} }
private class FormContainer extends CMSContainer { private class FormContainer extends CMSContainer {
@ -208,7 +208,7 @@ public class ContentSectionContainer extends CMSContainer {
* @pre ( state != null && id != null ) * @pre ( state != null && id != null )
**/ **/
public void setSectionId(PageState state, BigDecimal id) { public void setSectionId(PageState state, BigDecimal id) {
Assert.assertNotNull(id); Assert.exists(id);
m_sectionIDParamWidget.setValue(state, id); m_sectionIDParamWidget.setValue(state, id);
} }
@ -226,7 +226,7 @@ public class ContentSectionContainer extends CMSContainer {
**/ **/
public ContentSection getContentSection(PageState state) { public ContentSection getContentSection(PageState state) {
BigDecimal id = getContentSectionID(state); BigDecimal id = getContentSectionID(state);
Assert.assertNotNull(id); Assert.exists(id);
ContentSection section; ContentSection section;
try { try {
section = new ContentSection(id); section = new ContentSection(id);
@ -435,7 +435,8 @@ public class ContentSectionContainer extends CMSContainer {
// If the user has no access, return an empty Label // If the user has no access, return an empty Label
SecurityManager sm = new SecurityManager(section); SecurityManager sm = new SecurityManager(section);
if (! sm.canAccess(state.getRequest(), SecurityManager.NEW_ITEM, folder)) { if (! sm.canAccess(state.getRequest(), SecurityManager.NEW_ITEM, folder)
|| !ContentSection.getConfig().getAllowContentCreateInSectionListing()) {
return new Label(" ", false); return new Label(" ", false);
} else { } else {
// set the value of the sectionIdParameter in the form // set the value of the sectionIdParameter in the form

View File

@ -168,7 +168,8 @@ public abstract class BasicItemForm extends FormSection
nameWidget.setOnBlur( nameWidget.setOnBlur(
"if (this.value == '') " + "if (this.value == '') " +
"{ defaulting = true; this.value = urlize(this.form." + TITLE + "{ defaulting = true; this.value = urlize(this.form." + TITLE +
".value) }" ".value) } " +
" else { this.value = urlize(this.value); }"
); );
add(nameWidget); add(nameWidget);

View File

@ -50,6 +50,7 @@ import com.arsdigita.bebop.parameters.NotNullValidationListener;
import com.arsdigita.bebop.parameters.StringParameter; import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.cms.Asset; import com.arsdigita.cms.Asset;
import com.arsdigita.cms.ContentSection; import com.arsdigita.cms.ContentSection;
import com.arsdigita.cms.ContentSectionConfig;
import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.TextAsset; import com.arsdigita.cms.TextAsset;
import com.arsdigita.cms.ui.CMSDHTMLEditor; import com.arsdigita.cms.ui.CMSDHTMLEditor;
@ -102,6 +103,11 @@ public abstract class TextAssetBody extends SecurityPropertyEditor
private static final String STREAMLINED = "_streamlined"; private static final String STREAMLINED = "_streamlined";
private static final String STREAMLINED_DONE = "1"; private static final String STREAMLINED_DONE = "1";
private static final ContentSectionConfig s_config = new ContentSectionConfig();
static {
s_config.load();
}
/** /**
* Construct a new TextPageBody component * Construct a new TextPageBody component
* *
@ -128,10 +134,12 @@ public abstract class TextAssetBody extends SecurityPropertyEditor
new StringParameter(parent == null ? "item" : new StringParameter(parent == null ? "item" :
parent.getContentType().getAssociatedObjectType() + "_body_done"); parent.getContentType().getAssociatedObjectType() + "_body_done");
PageFileForm f = getPageFileForm(); if (!s_config.getHideTextAssetUploadFile()) {
addFileWidgets(f); PageFileForm f = getPageFileForm();
add(FILE_UPLOAD, "Upload a file", f, addFileWidgets(f);
f.getSaveCancelSection().getCancelButton()); add(FILE_UPLOAD, "Upload a file", f,
f.getSaveCancelSection().getCancelButton());
}
PageTextForm t = new PageTextForm(); PageTextForm t = new PageTextForm();
addTextWidgets(t); addTextWidgets(t);

View File

@ -78,8 +78,10 @@ public class TextPageBody extends TextAssetBody {
// Set the right component access on the forms // Set the right component access on the forms
Component f = getComponent(FILE_UPLOAD); Component f = getComponent(FILE_UPLOAD);
setComponentAccess(FILE_UPLOAD, if (f != null) {
new WorkflowLockedComponentAccess(f, itemModel)); setComponentAccess(FILE_UPLOAD,
new WorkflowLockedComponentAccess(f, itemModel));
}
Component t = getComponent(TEXT_ENTRY); Component t = getComponent(TEXT_ENTRY);
setComponentAccess(TEXT_ENTRY, setComponentAccess(TEXT_ENTRY,
new WorkflowLockedComponentAccess(t, itemModel)); new WorkflowLockedComponentAccess(t, itemModel));

View File

@ -130,7 +130,8 @@ class BaseCategoryForm extends BaseForm {
m_url.setOnFocus("defaulting = false"); m_url.setOnFocus("defaulting = false");
m_url.setOnBlur("if (this.value == '') " + m_url.setOnBlur("if (this.value == '') " +
"{ defaulting = true; this.value = urlize(this.form." + NAME + "{ defaulting = true; this.value = urlize(this.form." + NAME +
".value) }"); ".value) } " +
"else { this.value = urlize(this.value); }");
addField(gz("cms.ui.category.url"),m_url); addField(gz("cms.ui.category.url"),m_url);
addAction(new Finish()); addAction(new Finish());

View File

@ -35,6 +35,7 @@ import com.arsdigita.bebop.form.Submit;
import com.arsdigita.categorization.CategorizationConfig; import com.arsdigita.categorization.CategorizationConfig;
import com.arsdigita.categorization.CategorizedCollection; import com.arsdigita.categorization.CategorizedCollection;
import com.arsdigita.categorization.Category; import com.arsdigita.categorization.Category;
import com.arsdigita.categorization.CategoryCollection;
import com.arsdigita.categorization.CategoryNotFoundException; import com.arsdigita.categorization.CategoryNotFoundException;
import com.arsdigita.cms.ContentBundle; import com.arsdigita.cms.ContentBundle;
import com.arsdigita.cms.ContentItem; import com.arsdigita.cms.ContentItem;
@ -55,7 +56,6 @@ import com.arsdigita.persistence.DataObject;
import com.arsdigita.persistence.OID; import com.arsdigita.persistence.OID;
import com.arsdigita.toolbox.ui.ActionGroup; import com.arsdigita.toolbox.ui.ActionGroup;
import com.arsdigita.toolbox.ui.PropertyList; import com.arsdigita.toolbox.ui.PropertyList;
import com.arsdigita.toolbox.ui.PropertyList.Property;
import com.arsdigita.toolbox.ui.Section; import com.arsdigita.toolbox.ui.Section;
import com.arsdigita.util.Assert; import com.arsdigita.util.Assert;
import com.arsdigita.web.Web; import com.arsdigita.web.Web;
@ -267,10 +267,23 @@ class CategoryItemPane extends BaseItemPane {
final Category category = m_category.getCategory(state); final Category category = m_category.getCategory(state);
final ACSObject item = category.getDirectIndexObject(); final ACSObject item = category.getDirectIndexObject();
String itemTitle = ""; String itemTitle = "None";
if (item != null) { if (item != null) {
itemTitle = item.getDisplayName(); itemTitle = item.getDisplayName();
} else if (!category.ignoreParentIndexItem()
&& category.getParentCategoryCount() > 0)
{
Category ancestor = findParentCategoryWithNonInheritedIndexItem(category);
if (ancestor != null) {
if (ancestor.getIndexObject() != null) {
itemTitle = ancestor.getIndexObject().getDisplayName();
}
itemTitle += " (Inherited from "
+ ancestor.getDisplayName() + ")";
} else {
// The complete hierarchy is set to inherit.
// Just leave the itemTitle as None.
} }
props.add(new Property(gz("cms.ui.name"), props.add(new Property(gz("cms.ui.name"),
@ -295,6 +308,27 @@ class CategoryItemPane extends BaseItemPane {
} }
} }
// Loop over the parents and recurse up the hierarchy the find the first
// parent with an explicit index item ignoreParentIndexItem is true.
private Category findParentCategoryWithNonInheritedIndexItem(Category c) {
if (c.getParentCategoryCount() == 0) {
return null;
}
CategoryCollection parents = c.getParents();
while (parents.next()) {
Category p = parents.getCategory();
if (p.getDirectIndexObject() != null || p.ignoreParentIndexItem()) {
return p;
}
// Try the parents of this parent.
Category gp = findParentCategoryWithNonInheritedIndexItem(p);
if (gp != null) {
return gp;
}
}
return null;
}
// Quasimodo: BEGIN // Quasimodo: BEGIN
// CategoryLocalizationSection // CategoryLocalizationSection
private class CategoryLocalizationSection extends Section { private class CategoryLocalizationSection extends Section {

View File

@ -147,7 +147,8 @@ public class CategoryLocalizationForm extends BaseForm {
m_url.setOnFocus("defaulting = false"); m_url.setOnFocus("defaulting = false");
m_url.setOnBlur("if (this.value == '') " + m_url.setOnBlur("if (this.value == '') " +
"{ defaulting = true; this.value = urlize(this.form." + NAME + "{ defaulting = true; this.value = urlize(this.form." + NAME +
".value) }"); ".value) } " +
"else { this.value = urlize(this.value); }");
addField(gz("cms.ui.category.url"),m_url); addField(gz("cms.ui.category.url"),m_url);
addAction(new Finish()); addAction(new Finish());

View File

@ -88,57 +88,53 @@ public class IndexItemSelectionForm extends CMSForm {
m_options = new RadioGroup(new StringParameter("items")); m_options = new RadioGroup(new StringParameter("items"));
try { try {
m_options.addPrintListener(new PrintListener() { m_options.addPrintListener(new PrintListener() {
public void prepare(PrintEvent event) { public void prepare(PrintEvent event) {
RadioGroup group = (RadioGroup)event.getTarget(); RadioGroup group = (RadioGroup)event.getTarget();
PageState state = event.getPageState(); PageState state = event.getPageState();
Category category = getCategory(event.getPageState()); Category category = getCategory(event.getPageState());
CategorizedCollection children = category.getObjects CategorizedCollection children = category.getObjects
(ContentItem.BASE_DATA_OBJECT_TYPE); (ContentItem.BASE_DATA_OBJECT_TYPE);
boolean valueSet = false; // option for NO index Object
group.addOption(new Option(NONE_OPTION_VALUE,
new Label(NONE_OPTION_VALUE)));
// option for NO index Object // option for inheriting from the parent category
group.addOption(new Option(NONE_OPTION_VALUE, if (category.getParentCategoryCount() > 0) {
new Label(NONE_OPTION_VALUE))); group.addOption
(new Option(NULL_OPTION_VALUE,
new Label("Inherit Index from Parent Category")));
}
while (children.next()) { while (children.next()) {
ACSObject item = ACSObject item =
(ACSObject) children.getDomainObject(); (ACSObject) children.getDomainObject();
if ((item instanceof ContentItem) && if ((item instanceof ContentItem) &&
((ContentItem) item).getVersion().equals(ContentItem.DRAFT)) { ((ContentItem) item).getVersion().equals(ContentItem.DRAFT))
{
group.addOption group.addOption
(new Option(item.getID().toString(), (new Option(item.getID().toString(),
((ContentItem)item).getName())); ((ContentItem)item).getName()));
} }
} }
// get currently selected item // get currently selected item
ACSObject indexItem = ACSObject indexItem = category.getDirectIndexObject();
category.getDirectIndexObject(); if (indexItem != null && indexItem instanceof ContentItem) {
if (indexItem != null && indexItem instanceof ContentItem) { group.setValue(state, ((ContentItem) indexItem)
group.setValue .getWorkingVersion()
(state, .getID().toString());
((ContentItem)indexItem) } else {
.getWorkingVersion() String value = NONE_OPTION_VALUE;
.getID().toString()); if (!category.ignoreParentIndexItem()
valueSet = true; && category.getParentCategoryCount() > 0)
} {
else{ value = NULL_OPTION_VALUE;
group.setValue(state, NONE_OPTION_VALUE); }
valueSet = true; group.setValue(state, value);
} }
}
if (category.getParentCategoryCount() > 0) { });
group.addOption
(new Option(NULL_OPTION_VALUE, new Label
("Inherit Index from Parent Categoy")));
if (!valueSet) {
group.setValue(state, NULL_OPTION_VALUE);
}
}
}
});
} catch (java.util.TooManyListenersException e) { } catch (java.util.TooManyListenersException e) {
s_log.error("Error adding init listener to Radio Group", e); s_log.error("Error adding init listener to Radio Group", e);
throw new UncheckedWrapperException(e); throw new UncheckedWrapperException(e);

View File

@ -67,6 +67,8 @@ abstract class FolderBaseForm extends CMSForm {
"if (this.value == '') {" + "if (this.value == '') {" +
" defaulting = true;" + " defaulting = true;" +
" this.value = urlize(this.form." + TITLE + ".value)" + " this.value = urlize(this.form." + TITLE + ".value)" +
"} else {" +
" this.value = urlize(this.value);" +
"}"; "}";
private Label m_script = new Label("<script language=\"javascript\" src=\"/javascript/manipulate-input.js\"></script>", false); private Label m_script = new Label("<script language=\"javascript\" src=\"/javascript/manipulate-input.js\"></script>", false);

View File

@ -91,8 +91,10 @@ public class TemplateBody extends TextAssetBody {
// Set the right component access on the forms - // Set the right component access on the forms -
// FIXME: Update this for templating permissions ! // FIXME: Update this for templating permissions !
Component f = getComponent(FILE_UPLOAD); Component f = getComponent(FILE_UPLOAD);
setComponentAccess(FILE_UPLOAD, if (f != null) {
new WorkflowLockedComponentAccess(f, itemModel)); setComponentAccess(FILE_UPLOAD,
new WorkflowLockedComponentAccess(f, itemModel));
}
Component t = getComponent(TEXT_ENTRY); Component t = getComponent(TEXT_ENTRY);
setComponentAccess(TEXT_ENTRY, setComponentAccess(TEXT_ENTRY,
new WorkflowLockedComponentAccess(t, itemModel)); new WorkflowLockedComponentAccess(t, itemModel));