Fixed bug #16605: TCA tree: sorting is not working
authorSteffen Ritter <info@rs-websystems.de>
Mon, 29 Nov 2010 20:07:09 +0000 (20:07 +0000)
committerSteffen Ritter <info@rs-websystems.de>
Mon, 29 Nov 2010 20:07:09 +0000 (20:07 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@9675 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/tree/class.t3lib_tree_sortednodecollection.php
t3lib/tree/tca/class.t3lib_tree_tca_databasenode.php
t3lib/tree/tca/class.t3lib_tree_tca_databasetreedataprovider.php

index aaf449a..e2417cc 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,12 +5,13 @@
 
 2010-11-29  Steffen Ritter  <typo3@steffen-ritter.net>
 
-       * Fixed bug #16597: TCA tree: Adapt Signature of own select renderMode tree to match the signature other select-modes 
-       * Fixed bug #16600: TCA tree: Move the ACL-Checks out from Data-Provider and use the information from tceFroms 
+       * Fixed bug #16597: TCA tree: Adapt Signature of own select renderMode tree to match the signature other select-modes
+       * Fixed bug #16600: TCA tree: Move the ACL-Checks out from Data-Provider and use the information from tceFroms
        * Follow-up to bug #16600: TCA tree: Move the ACL-Checks out from Data-Provider and use the information from tceFroms (added missing class)
        * Fixed bug #16553: TCA tree does not work for relation-fields without TCA Definition.
-       * Cleanup #16553: TCA tree has redundant code passages 
+       * Cleanup #16553: TCA tree has redundant code passages
        * Fixed bug #16276: TCAtree should respect maxItems = 1
+       * Fixed bug #16605: TCA tree: sorting is not working
 
 2010-11-29  Jigal van Hemert <jigal@xs4all.nl>
 
index 9471f7b..bbc5f00 100644 (file)
@@ -105,25 +105,11 @@ class t3lib_tree_SortedNodeCollection extends t3lib_tree_NodeCollection {
         * @param t3lib_tree_Node $node
         * @return void
         */
-       public function addNode(t3lib_tree_Node $node) {
-               $this->append($node);
+       public function append(t3lib_tree_Node $node) {
+               parent::append($node);
                $this->asort();
                $this->normalize();
        }
 
-       /**
-        * Removes a specific node from the internal array
-        *
-        * @param t3lib_tree_Node $node
-        * @return void
-        */
-       public function removeNode(t3lib_tree_Node $node) {
-               $offset = $this->offsetOf($node);
-               if ($offset !== -1) {
-                       $this->offsetUnset($offset);
-                       $this->normalize();
-               }
-       }
 }
-
 ?>
\ No newline at end of file
index 90dc112..37de43f 100644 (file)
@@ -137,19 +137,22 @@ class t3lib_tree_Tca_DatabaseNode extends t3lib_tree_RepresentationNode {
        }
 
        /**
-        * Compares with another nide, used for sorting
+        * Compares a node to another one.
         *
-        * @param  $other node object
-        * @return int
+        * Returns:
+        * 1 if its greater than the other one
+        * -1 if its smaller than the other one
+        * 0 if its equal
+        *
+        * @param t3lib_tree_Node $other
+        * @return int see description above
         */
        public function compareTo($other) {
-               if ($this->sortValue > $other->sortValue) {
-                       return 1;
-               } elseif ($this->sortValue < $other->sortValue) {
-                       return -1;
-               } else {
+               if ($this->equals($other)) {
                        return 0;
                }
+
+               return ($this->sortValue > $other->getSortValue()) ? 1 : -1;
        }
 
        /**
index 83f142a..d911960 100644 (file)
@@ -258,10 +258,12 @@ class t3lib_tree_Tca_DatabaseTreeDataProvider extends t3lib_tree_Tca_AbstractTca
                        $node->setSelected(t3lib_div::inList($this->getSelectedList(), $basicNode->getId()));
                        $node->setExpanded($this->isExpanded($basicNode));
                }
+               $node->setId($basicNode->getId());
+
                $node->setSelectable(!t3lib_div::inList($this->getNonSelectableLevelList(), $level));
-               $node->setSortValue($this->nodeSortValues[$node->getId()]);
+               $node->setSortValue($this->nodeSortValues[$basicNode->getId()]);
+
                $node->setIcon(t3lib_iconWorks::mapRecordTypeToSpriteIconClass($this->tableName, $row));
-               $node->setId($basicNode->getId());
                $node->setParentNode($parent);
                if ($basicNode->hasChildNodes()) {
                        $node->setHasChildren(TRUE);
@@ -377,7 +379,6 @@ class t3lib_tree_Tca_DatabaseTreeDataProvider extends t3lib_tree_Tca_AbstractTca
         * @return array
         */
        protected function getChildrenUidsFromParentRelation(array $row) {
-               $relatedUids = array();
                $uid = $row['uid'];
 
                switch ((string) $this->columnConfiguration['type']) {