diff --git a/ccm-cms/src/com/arsdigita/cms/ContentSectionConfig.java b/ccm-cms/src/com/arsdigita/cms/ContentSectionConfig.java index 17d5cfdda..180812582 100755 --- a/ccm-cms/src/com/arsdigita/cms/ContentSectionConfig.java +++ b/ccm-cms/src/com/arsdigita/cms/ContentSectionConfig.java @@ -34,6 +34,7 @@ import org.apache.log4j.Logger; import com.arsdigita.bebop.SimpleComponent; import com.arsdigita.bebop.form.DHTMLEditor; +import com.arsdigita.categorization.Category; import com.arsdigita.cms.dispatcher.DefaultTemplateResolver; import com.arsdigita.cms.dispatcher.ItemResolver; import com.arsdigita.cms.dispatcher.MultilingualItemResolver; @@ -47,6 +48,7 @@ import com.arsdigita.runtime.AbstractConfig; import com.arsdigita.util.UncheckedWrapperException; import com.arsdigita.util.parameter.BooleanParameter; import com.arsdigita.util.parameter.ClassParameter; +import com.arsdigita.util.parameter.EnumerationParameter; import com.arsdigita.util.parameter.ErrorList; import com.arsdigita.util.parameter.IntegerParameter; import com.arsdigita.util.parameter.Parameter; @@ -121,6 +123,7 @@ public final class ContentSectionConfig extends AbstractConfig { private final Parameter m_deleteLifecycleWhenComplete; private final Parameter m_deleteExpiryNotificationsWhenSent; private final Parameter m_deleteWorkflowNotificationsWhenSent; + private final Parameter m_categoryTreeOrdering; /** * Do not instantiate this class directly. @@ -341,6 +344,15 @@ public final class ContentSectionConfig extends AbstractConfig { ("com.arsdigita.cms.delete_workflow_notification_when_sent", Parameter.OPTIONAL, new Boolean(false)); + m_categoryTreeOrdering = new EnumerationParameter + ("com.arsdigita.cms.category_tree_order", + Parameter.OPTIONAL, Category.SORT_KEY ); + + // 2 valid values at the moment - enumeration used rather than boolean in case other + // possible orders are deemed valid + ((EnumerationParameter)m_categoryTreeOrdering).put("SortKey", Category.SORT_KEY ); + ((EnumerationParameter)m_categoryTreeOrdering).put("Alphabetical", Category.NAME); + register(m_templateRootPath); register(m_defaultItemTemplatePath); register(m_defaultFolderTemplatePath); @@ -386,6 +398,7 @@ public final class ContentSectionConfig extends AbstractConfig { register(m_deleteLifecycleWhenComplete); register(m_deleteExpiryNotificationsWhenSent); register(m_deleteWorkflowNotificationsWhenSent); + register(m_categoryTreeOrdering); loadInfo(); } @@ -724,4 +737,7 @@ public final class ContentSectionConfig extends AbstractConfig { return ((Boolean)get(m_deleteWorkflowNotificationsWhenSent)).booleanValue(); } + public String getCategoryTreeOrder () { + return (String)get(m_categoryTreeOrdering); + } } diff --git a/ccm-cms/src/com/arsdigita/cms/ContentSectionConfig_parameter.properties b/ccm-cms/src/com/arsdigita/cms/ContentSectionConfig_parameter.properties index 0d49e2652..09ac3de76 100755 --- a/ccm-cms/src/com/arsdigita/cms/ContentSectionConfig_parameter.properties +++ b/ccm-cms/src/com/arsdigita/cms/ContentSectionConfig_parameter.properties @@ -222,3 +222,8 @@ com.arsdigita.cms.delete_workflow_notification_when_sent.title=Delete Sent Workf com.arsdigita.cms.delete_workflow_notification_when_sent.purpose=Decide whether successfully sent notifications and messages should be deleted from the system com.arsdigita.cms.delete_workflow_notification_when_sent.example=true|false com.arsdigita.cms.delete_workflow_notification_when_sent.format=[boolean] + +com.arsdigita.cms.category_tree_order.title=Ordering for nodes in assign category tree +com.arsdigita.cms.category_tree_order.purpose=Decide whether entries should be ordered alphabetically or according to sort key (maintained in category admin tab in content centre) +com.arsdigita.cms.category_tree_order.example=SortKey|Alphabetical +com.arsdigita.cms.category_tree_order.format=[string] diff --git a/ccm-cms/src/com/arsdigita/cms/ui/SortableList.java b/ccm-cms/src/com/arsdigita/cms/ui/SortableList.java index 5d4d5fb86..f1e2261e4 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/SortableList.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/SortableList.java @@ -59,16 +59,20 @@ public abstract class SortableList extends List { private static final String SELECT_EVENT = "s"; protected static final String PREV_EVENT = "prev"; protected static final String NEXT_EVENT = "next"; - //private boolean m_sortItems; + private boolean m_sortItems; /** * This just makes a standard * {@link SortableList} */ public SortableList(ParameterSingleSelectionModel model) { - super(model); + this(model, false); } + public SortableList(ParameterSingleSelectionModel model, boolean suppressSort) { + super(model); + m_sortItems = !suppressSort; + } /** * This geneates the XML as specified by the arguments pass in to * the constructor. @@ -99,8 +103,10 @@ public abstract class SortableList extends List { do { Element item = list.newChildElement (BebopConstants.BEBOP_CELL, BEBOP_XML_NS); - item.addAttribute("configure", "true"); + if (m_sortItems) { + item.addAttribute("configure", "true"); + } String key = m.getKey(); Assert.assertNotNull(key); diff --git a/ccm-cms/src/com/arsdigita/cms/ui/authoring/CategoryWidget.java b/ccm-cms/src/com/arsdigita/cms/ui/authoring/CategoryWidget.java index b067869ea..effb9d636 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/authoring/CategoryWidget.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/authoring/CategoryWidget.java @@ -30,6 +30,7 @@ import com.arsdigita.domain.DomainObjectFactory; import com.arsdigita.categorization.Category; import com.arsdigita.categorization.CategoryCollection; import com.arsdigita.cms.CMS; +import com.arsdigita.cms.ContentSection; import java.util.Set; import java.util.HashSet; import java.util.Map; @@ -124,6 +125,10 @@ public class CategoryWidget extends Widget { if (sortKey != null) { el.addAttribute("sortKey", sortKey.toString()); } + // sort order attribute added to every node in order that same xsl may + // be used to transform xml fragments returned by ajax in the Aplaws + // extension + el.addAttribute("order", ContentSection.getConfig().getCategoryTreeOrder()); String fullname = path == null ? "/" : path + " > " + cat.getName(); el.addAttribute("fullname", fullname); diff --git a/ccm-cms/src/com/arsdigita/cms/ui/category/CategoryTreeModelBuilder.java b/ccm-cms/src/com/arsdigita/cms/ui/category/CategoryTreeModelBuilder.java index bbf7078dd..b1cc2db95 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/category/CategoryTreeModelBuilder.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/category/CategoryTreeModelBuilder.java @@ -58,8 +58,8 @@ class CategoryTreeModelBuilder extends LockableImpl final ContentSection section = CMS.getContext().getContentSection(); final Category root = Category.getRootForObject(section, getUseContext(state)); - - final CategoryTreeModelLite model = new CategoryTreeModelLite(root, "sortKey"); + String order = ContentSection.getConfig().getCategoryTreeOrder(); + final CategoryTreeModelLite model = new CategoryTreeModelLite(root, order); return model; } diff --git a/ccm-cms/src/com/arsdigita/cms/ui/category/SortableCategoryList.java b/ccm-cms/src/com/arsdigita/cms/ui/category/SortableCategoryList.java index a3140005a..be711c435 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/category/SortableCategoryList.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/category/SortableCategoryList.java @@ -23,6 +23,7 @@ import com.arsdigita.bebop.ParameterSingleSelectionModel; import com.arsdigita.bebop.parameters.BigDecimalParameter; import com.arsdigita.categorization.Category; import com.arsdigita.cms.CMS; +import com.arsdigita.cms.ContentSection; import com.arsdigita.cms.SecurityManager; import com.arsdigita.cms.ui.SortableList; import com.arsdigita.domain.DataObjectNotFoundException; @@ -69,7 +70,7 @@ abstract class SortableCategoryList extends SortableList { */ public SortableCategoryList(final CategoryRequestLocal parent) { super(new ParameterSingleSelectionModel - (new BigDecimalParameter(CHILDREN))); + (new BigDecimalParameter(CHILDREN)), !Category.SORT_KEY.equals(ContentSection.getConfig().getCategoryTreeOrder())); m_parent = parent; diff --git a/ccm-cms/src/com/arsdigita/cms/ui/category/SubcategoryList.java b/ccm-cms/src/com/arsdigita/cms/ui/category/SubcategoryList.java index bf3f21ad6..3fdc8eb23 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/category/SubcategoryList.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/category/SubcategoryList.java @@ -28,6 +28,7 @@ import com.arsdigita.bebop.list.ListModel; import com.arsdigita.bebop.list.ListModelBuilder; import com.arsdigita.categorization.Category; import com.arsdigita.categorization.CategoryCollection; +import com.arsdigita.cms.ContentSection; import com.arsdigita.cms.util.GlobalizationUtil; import com.arsdigita.util.LockableImpl; @@ -79,7 +80,10 @@ public class SubcategoryList extends SortableCategoryList { if (category != null && category.hasChildCategories()) { CategoryCollection children = category.getChildren(); - children.addOrder("link." + Category.SORT_KEY); + String order = ContentSection.getConfig().getCategoryTreeOrder(); + order = order = Category.SORT_KEY.equals(order) ? "link." + order : order; + children.addOrder(order); + // children.addOrder("link." + Category.SORT_KEY); return new CategoryCollectionListModel(children); } else { return List.EMPTY_MODEL; diff --git a/ccm-cms/web/__ccm__/static/cms/admin/category-step/category-step.xsl b/ccm-cms/web/__ccm__/static/cms/admin/category-step/category-step.xsl index 57248a625..583e15e51 100755 --- a/ccm-cms/web/__ccm__/static/cms/admin/category-step/category-step.xsl +++ b/ccm-cms/web/__ccm__/static/cms/admin/category-step/category-step.xsl @@ -159,9 +159,19 @@
+ + + + + + + + + +