From da75df6388e8a1dc3ea5de9f886cfe76276c6c04 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 30 Jun 2014 20:25:47 +0200 Subject: [PATCH] Improved autosave to use prefixed keys --- com.woltlab.wcf/templates/wysiwyg.tpl | 2 +- .../install/files/js/3rdParty/redactor/plugins/wutil.js | 1 - wcfsetup/install/files/lib/system/WCF.class.php | 9 +++++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/com.woltlab.wcf/templates/wysiwyg.tpl b/com.woltlab.wcf/templates/wysiwyg.tpl index d8951b3601..0b84dc4434 100644 --- a/com.woltlab.wcf/templates/wysiwyg.tpl +++ b/com.woltlab.wcf/templates/wysiwyg.tpl @@ -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} } }; diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js index 031289470c..db311e4fd0 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js @@ -203,7 +203,6 @@ RedactorPlugins.wutil = { } if (this._autosaveWorker === null) { - var self = this; this._autosaveWorker = new WCF.PeriodicalExecuter($.proxy(this._saveTextToStorage, this), 60 * 1000); } diff --git a/wcfsetup/install/files/lib/system/WCF.class.php b/wcfsetup/install/files/lib/system/WCF.class.php index 7c0008d30d..bc01e55fc0 100644 --- a/wcfsetup/install/files/lib/system/WCF.class.php +++ b/wcfsetup/install/files/lib/system/WCF.class.php @@ -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. */ -- 2.20.1