Problem der Objektsortierung in den Kategorien behoben (Ticket #1318)
git-svn-id: https://svn.libreccm.org/ccm/trunk@1839 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
1b69863fa6
commit
dd864b7ed4
|
|
@ -71,7 +71,7 @@ public class BaseImage extends ResourceHandlerImpl {
|
|||
CMS.getConfig().getImageCacheMaxSize());
|
||||
}
|
||||
}
|
||||
private final bool IMAGE_CACHE_PREFETCH = CMS.getConfig().getImageCachePrefetchEnabled();
|
||||
private final boolean IMAGE_CACHE_PREFETCH = CMS.getConfig().getImageCachePrefetchEnabled();
|
||||
private static final Logger s_log = Logger.getLogger(BaseImage.class);
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -60,21 +60,26 @@ public class CategorizedObjectsList extends SortableCategoryList {
|
|||
* This actually performs the sorting
|
||||
*/
|
||||
public void respond(PageState ps) throws ServletException {
|
||||
String event = ps.getControlEventName();
|
||||
final String event = ps.getControlEventName();
|
||||
|
||||
if (NEXT_EVENT.equals(event) || PREV_EVENT.equals(event)) {
|
||||
BigDecimal selectedID = new BigDecimal(ps.getControlEventValue());
|
||||
Category parent = getCategory(ps);
|
||||
final BigDecimal selectedID = new BigDecimal(ps.getControlEventValue());
|
||||
final Category parent = getCategory(ps);
|
||||
|
||||
final ContentItem selectedItem = new ContentItem(selectedID);
|
||||
final BigDecimal selectedDraftId = selectedItem.getDraftVersion().getID();
|
||||
|
||||
if (CMS.getContext().getSecurityManager().canAccess(SecurityManager.CATEGORY_ADMIN)) {
|
||||
BigDecimal swapId = getSwapID(parent, selectedID, event);
|
||||
final BigDecimal swapId = getSwapID(parent, selectedID, event);
|
||||
parent.swapSortKeys(selectedID, swapId);
|
||||
final ContentItem draftSwapItem = new ContentItem(swapId);
|
||||
final BigDecimal draftSwapId = selectedItem.getDraftVersion().getID();
|
||||
parent.swapSortKeys(selectedDraftId, draftSwapId);
|
||||
final ContentItem swapItem = new ContentItem(swapId);
|
||||
final BigDecimal swapDraftId = swapItem.getDraftVersion().getID();
|
||||
|
||||
final BigDecimal sortKey1 = parent.getSortKey(selectedItem);
|
||||
final BigDecimal sortKey2 = parent.getSortKey(swapItem);
|
||||
|
||||
parent.setSortKey(new ContentItem(selectedDraftId), sortKey1);
|
||||
parent.setSortKey(new ContentItem(swapDraftId), sortKey2);
|
||||
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -169,6 +169,7 @@ public class OrderedCategorizedObjectsList extends CategorizedObjectsList {
|
|||
}
|
||||
}
|
||||
parent.save();
|
||||
|
||||
} catch (DataObjectNotFoundException e) {
|
||||
s_log.error("Trying to create categories with state = " + ps, e);
|
||||
throw new ServletException(e);
|
||||
|
|
@ -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.ContentItem;
|
||||
import com.arsdigita.cms.ContentSection;
|
||||
import com.arsdigita.cms.SecurityManager;
|
||||
import com.arsdigita.cms.ui.SortableList;
|
||||
|
|
|
|||
|
|
@ -416,7 +416,8 @@ public class Category extends ACSObject {
|
|||
public String getName(String locale) {
|
||||
|
||||
// Test for localized version
|
||||
if (locale != null && !locale.isEmpty() && m_categoryLocalizationCollection != null && m_categoryLocalizationCollection.
|
||||
if (locale != null && !locale.isEmpty() && m_categoryLocalizationCollection != null
|
||||
&& m_categoryLocalizationCollection.
|
||||
localizationExists(locale)) {
|
||||
|
||||
// Return value of isEnabled from localized version, so categories could be disabled depending on locale
|
||||
|
|
@ -602,7 +603,8 @@ public class Category extends ACSObject {
|
|||
|
||||
// Test for localized version
|
||||
// HACK
|
||||
if (locale != null && !locale.isEmpty() && m_categoryLocalizationCollection != null && m_categoryLocalizationCollection.
|
||||
if (locale != null && !locale.isEmpty() && m_categoryLocalizationCollection != null
|
||||
&& m_categoryLocalizationCollection.
|
||||
localizationExists(locale)) {
|
||||
|
||||
// Return value of isEnabled from localized version, so categories could be disabled depending on locale
|
||||
|
|
@ -679,7 +681,8 @@ public class Category extends ACSObject {
|
|||
public String getURL(String locale) {
|
||||
|
||||
// Test for localized version
|
||||
if (locale != null && !locale.isEmpty() && m_categoryLocalizationCollection != null && m_categoryLocalizationCollection.
|
||||
if (locale != null && !locale.isEmpty() && m_categoryLocalizationCollection != null
|
||||
&& m_categoryLocalizationCollection.
|
||||
localizationExists(locale)) {
|
||||
|
||||
// Return value of isEnabled from localized version, so categories could be disabled depending on locale
|
||||
|
|
@ -751,7 +754,8 @@ public class Category extends ACSObject {
|
|||
}
|
||||
|
||||
// Test for localized version
|
||||
if (locale != null && !locale.isEmpty() && m_categoryLocalizationCollection != null && m_categoryLocalizationCollection.
|
||||
if (locale != null && !locale.isEmpty() && m_categoryLocalizationCollection != null
|
||||
&& m_categoryLocalizationCollection.
|
||||
localizationExists(locale)) {
|
||||
|
||||
// Return value of isEnabled from localized version, so categories could be disabled depending on locale
|
||||
|
|
@ -1640,6 +1644,24 @@ public class Category extends ACSObject {
|
|||
}
|
||||
}
|
||||
|
||||
public BigDecimal getSortKey(final ACSObject object) {
|
||||
return getSortKey(object.getID());
|
||||
}
|
||||
|
||||
public BigDecimal getSortKey(final BigDecimal objId) {
|
||||
final DataAssociationCursor cursor = ((DataAssociation) get(CHILD_OBJECTS)).cursor();
|
||||
cursor.addEqualsFilter(ID, objId);
|
||||
if (cursor.next()) {
|
||||
return (BigDecimal) cursor.getLink().get(SORT_KEY);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setSortKey(ACSObject object, int key) {
|
||||
setSortKey(object, new BigDecimal(key));
|
||||
}
|
||||
|
||||
/**
|
||||
* Explicitly sets the sort key for this child object (category or
|
||||
* otherwise).
|
||||
|
|
@ -1647,7 +1669,7 @@ public class Category extends ACSObject {
|
|||
* @param child The child object or category to set the sortKey for
|
||||
* @param key The integer to use for the sortKey
|
||||
*/
|
||||
public void setSortKey(ACSObject child, int key) {
|
||||
public void setSortKey(ACSObject child, BigDecimal key) {
|
||||
if (isCategory(child)) {
|
||||
setSortKey((Category) child, key);
|
||||
return;
|
||||
|
|
@ -1659,7 +1681,7 @@ public class Category extends ACSObject {
|
|||
cursor.addEqualsFilter(ID, child.getID());
|
||||
if (cursor.next()) {
|
||||
DataObject link = cursor.getLink();
|
||||
link.set(SORT_KEY, new BigDecimal(key));
|
||||
link.set(SORT_KEY, key);
|
||||
}
|
||||
cursor.close();
|
||||
}
|
||||
|
|
@ -2053,6 +2075,7 @@ public class Category extends ACSObject {
|
|||
public String getToken() {
|
||||
return m_token;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -2356,4 +2379,5 @@ public class Category extends ACSObject {
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue