Improved autosave to use prefixed keys
authorAlexander Ebert <ebert@woltlab.com>
Mon, 30 Jun 2014 18:25:47 +0000 (20:25 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 30 Jun 2014 18:25:47 +0000 (20:25 +0200)
com.woltlab.wcf/templates/wysiwyg.tpl
wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js
wcfsetup/install/files/lib/system/WCF.class.php

index d8951b3601954c1326e8455104cb12e129c33658..0b84dc443489456b648a5934cb1138e4c0140690 100644 (file)
@@ -41,7 +41,7 @@ $(function() {
                        plugins: [ 'wutil',  'wmonkeypatch', 'wbutton', 'wbbcode',  'wfontcolor', 'wfontfamily', 'wfontsize' ],
                        wautosave: {
                                active: ($autosave) ? true : false,
-                               key: ($autosave) ? $autosave : '',
+                               key: ($autosave) ? '{@$__wcf->getAutosavePrefix()}_' + $autosave : '',
                                saveOnInit: {if !$errorField|empty}true{else}false{/if}
                        }
                };
index 031289470ccb2022e15dfa20be3ec4e403a6df07..db311e4fd0d6044479d28882d7ed58c4ec07ec4b 100644 (file)
@@ -203,7 +203,6 @@ RedactorPlugins.wutil = {
                }
                
                if (this._autosaveWorker === null) {
-                       var self = this;
                        this._autosaveWorker = new WCF.PeriodicalExecuter($.proxy(this._saveTextToStorage, this), 60 * 1000);
                }
                
index 7c0008d30d00775df8d316f3b6bb0d0d0a57eb7d..bc01e55fc01943cdd6dd7cf3d9612546578c571a 100644 (file)
@@ -810,6 +810,15 @@ class WCF {
                return RouteHandler::secureConnection();
        }
        
+       /**
+        * Returns a 8 character prefix for editor autosave.
+        * 
+        * @return      string
+        */
+       public function getAutosavePrefix() {
+               return substr(sha1(preg_replace('~^https~', 'http', WCF::getPath())), 0, 8);
+       }
+       
        /**
         * Initialises the cronjobs.
         */