------------------------------------------------------------------------

r1618 | chrisg23 | 2007-09-13 14:14:51 +0200 (Do, 13 Sep 2007) | 1 line

Sourceforge patch 1793743 changes for cms users to allow categories to be sorted by sortkey or alphabetically
------------------------------------------------------------------------


git-svn-id: https://svn.libreccm.org/ccm/trunk@3 8810af33-2d31-482b-a856-94f89814c4df
master
pb 2008-02-15 00:01:44 +00:00
parent 47a9f0a0dc
commit 30e0ace8ee
8 changed files with 54 additions and 7 deletions

View File

@ -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);
}
}

View File

@ -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]

View File

@ -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);

View File

@ -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);

View File

@ -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;
}

View File

@ -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;

View File

@ -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;

View File

@ -159,9 +159,19 @@
</span>
</div>
<div id="catCh{@node-id}" style="margin-left: 20px; display: {$expand}">
<xsl:choose>
<xsl:when test="@order='sortKey'">
<xsl:apply-templates select="cms:category" mode="cms:javascriptCat">
<xsl:sort data-type="number" select="@sortKey"/>
</xsl:apply-templates>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="cms:category" mode="cms:javascriptCat">
<xsl:sort data-type="text" select="@name"/>
</xsl:apply-templates>
</xsl:otherwise>
</xsl:choose>
</div>
</xsl:template>