[BUGFIX] Saving Page Tree states issues in large environments
authorcybercraft <info@cybercraft.de>
Thu, 12 Apr 2012 15:26:07 +0000 (17:26 +0200)
committerStefan Galinski <stefan.galinski@gmail.com>
Fri, 13 Apr 2012 11:52:19 +0000 (13:52 +0200)
Change the way expanded nodes are saved for be_users back to a simple
key/boolean pair and adjust the size of the uc field to fit the needs of
larger page trees.

Change-Id: Ic926080b0dc0e6e24226ab00554091a5f0ffae66
Resolves: #24884
Releases: 4.5
Reviewed-on: http://review.typo3.org/10348
Reviewed-by: Markus Klein
Tested-by: Markus Klein
Reviewed-by: Stefan Galinski
Tested-by: Stefan Galinski
t3lib/js/extjs/ExtDirect.StateProvider.js
t3lib/js/extjs/components/pagetree/javascript/Ext.ux.state.TreePanel.js
t3lib/stddb/tables.sql
t3lib/tree/pagetree/class.t3lib_tree_pagetree_node.php

index 635d91d..fb88288 100644 (file)
@@ -118,11 +118,11 @@ Ext.extend(TYPO3.state.ExtDirectProvider, Ext.state.Provider, {
        initState: function(state) {
                if (Ext.isArray(state)) {
                        Ext.each(state, function(item) {
-                               this.state[item.name] = this.decodeValue(item[this.paramNames.value]);
+                               this.state[item.name] = item[this.paramNames.value];
                        }, this);
                } else if (Ext.isObject(state)) {
                        Ext.iterate(state, function(key, value){
-                               this.state[key] = this.decodeValue(value);
+                               this.state[key] = value;
                        }, this);
                } else {
                        this.state = {};
@@ -172,14 +172,14 @@ Ext.extend(TYPO3.state.ExtDirectProvider, Ext.state.Provider, {
                var lastValue = this.state[name];
                for (i = 0; i < this.queue.length; i++) {
                        if (this.queue[i].name === name) {
-                               lastValue = this.decodeValue(this.queue[i].value);
+                               lastValue = this.queue[i].value;
                        }
                }
                var changed = undefined === lastValue || lastValue !== value;
 
                if (changed) {
                        o[this.paramNames.name] = name;
-                       o[this.paramNames.value] = this.encodeValue(value);
+                       o[this.paramNames.value] = value;
                        for (i = 0; i < this.queue.length; i++) {
                                if (this.queue[i].name === o.name) {
                                        this.queue[i] = o;
@@ -260,7 +260,7 @@ Ext.extend(TYPO3.state.ExtDirectProvider, Ext.state.Provider, {
                                        return;
                                }
                                var name = item[this.paramNames.name];
-                               var value = this.decodeValue(item[this.paramNames.value]);
+                               var value = item[this.paramNames.value];
 
                                if (value === undefined  || value === null) {
                                        TYPO3.state.ExtDirectProvider.superclass.clear.call(this, name);
@@ -281,7 +281,7 @@ Ext.extend(TYPO3.state.ExtDirectProvider, Ext.state.Provider, {
                                                        break;
                                                }
                                        }
-                                       if (found && this.encodeValue(response.params.queue[i].value) === this.encodeValue(this.queue[j].value)) {
+                                       if (found && response.params.queue[i].value === this.queue[j].value) {
                                                this.queue.remove(this.queue[j]);
                                        }
                                }
@@ -330,7 +330,7 @@ Ext.extend(TYPO3.state.ExtDirectProvider, Ext.state.Provider, {
                } else {
                        data = o[this.paramNames.data];
                        Ext.iterate(data, function(key, value) {
-                               this.state[key] = this.decodeValue(value);
+                               this.state[key] = value;
                        }, this);
                        this.queue = [];
                        this.dirty = false;
index 5233467..469890f 100644 (file)
@@ -49,8 +49,8 @@ Ext.override(Ext.ux.state.TreePanel, {
                                if (this.isRestoringState) {
                                        return;
                                }
-
-                               this.stateHash[n.id] = n.getPath();
+                               var saveID = n.id;
+                               this.stateHash[saveID.substr(1)] = 1;
                        },
 
                        // delete path and all subpaths of collapsed node from stateHash
@@ -59,15 +59,8 @@ Ext.override(Ext.ux.state.TreePanel, {
                                        return;
                                }
 
-                               delete this.stateHash[n.id];
-                               var cPath = n.getPath();
-                               for(var p in this.stateHash) {
-                                       if(this.stateHash.hasOwnProperty(p)) {
-                                               if(this.stateHash[p].indexOf(cPath) !== -1) {
-                                                       delete this.stateHash[p];
-                                               }
-                                       }
-                               }
+                               var deleteID = n.id;
+                               delete this.stateHash[deleteID.substr(1)];
                        },
 
                        beforeclick: function(node) {
@@ -85,16 +78,26 @@ Ext.override(Ext.ux.state.TreePanel, {
                // add state related props to the tree
                Ext.apply(tree, {
                        // keeps expanded nodes paths keyed by node.ids
-                        stateHash:{},
+                       stateHash:{},
 
                        restoreState: function() {
                                this.isRestoringState = true;
-                               for(var p in this.stateHash) {
-                                       if(this.stateHash.hasOwnProperty(p)) {
-                                               this.expandPath(this.stateHash[p]);
+                                       // get last selected node
+                               for (var pageID in this.stateHash) {
+                                       var pageNode = this.getNodeById('p' + pageID);
+                                       if (pageNode) {
+                                               pageNode.on({
+                                                       expand: {
+                                                               single:true,
+                                                               scope:this,
+                                                               fn: this.restoreState
+                                                       }
+                                               });
+                                               if (pageNode.expanded === false) {
+                                                       pageNode.expand();
+                                               }
                                        }
                                }
-                                       // get last selected node
 
                                if (this.stateHash['lastSelectedNode']) {
                                        var node = this.getNodeById(this.stateHash['lastSelectedNode']);
index 621dac8..4119784 100644 (file)
@@ -74,7 +74,7 @@ CREATE TABLE be_users (
   realName varchar(80) DEFAULT '' NOT NULL,
   userMods varchar(255) DEFAULT '' NOT NULL,
   allowed_languages varchar(255) DEFAULT '' NOT NULL,
-  uc text,
+  uc mediumtext,
   file_mountpoints varchar(255) DEFAULT '' NOT NULL,
   fileoper_perms tinyint(4) DEFAULT '0' NOT NULL,
   workspace_perms tinyint(3) DEFAULT '1' NOT NULL,
index 80e1c5b..a6a6e8c 100644 (file)
@@ -306,7 +306,7 @@ class t3lib_tree_pagetree_Node extends t3lib_tree_extdirect_Node {
        public function toArray() {
                $arrayRepresentation = parent::toArray();
 
-               $arrayRepresentation['id'] = 'mp-' . $this->getMountPoint() . '-' . $this->getId();
+               $arrayRepresentation['id'] = 'p' . dechex($this->getId()) . ($this->getMountPoint() ? '-' . dechex($this->getMountPoint()) : '');
                $arrayRepresentation['realId'] = $this->getId();
                $arrayRepresentation['nodeData']['id'] = $this->getId();