From 8ace1877213842faa8febb75b6b37eb3dbfad3bd Mon Sep 17 00:00:00 2001 From: garvinhicking Date: Tue, 23 Aug 2005 11:03:09 +0000 Subject: [PATCH] MAke image manager remember settings and return content at cursor position --- deployment/serendipity_editor.js | 2 +- docs/NEWS | 4 +++ serendipity_admin_image_selector.php | 50 ++++++++++++++++++++++------ serendipity_editor.js | 3 +- 4 files changed, 47 insertions(+), 12 deletions(-) diff --git a/deployment/serendipity_editor.js b/deployment/serendipity_editor.js index 5d246fe..d7dc031 100644 --- a/deployment/serendipity_editor.js +++ b/deployment/serendipity_editor.js @@ -143,7 +143,7 @@ function serendipity_imageSelector_addToElement (str, el) function serendipity_imageSelector_addToBody (str, textarea) { - document.forms['serendipityEntry']['serendipity['+ textarea +']'].value += str; + wrapSelection(document.forms['serendipityEntry']['serendipity['+ textarea +']'], str, ''); document.forms['serendipityEntry']['serendipity['+ textarea +']'].focus(); } diff --git a/docs/NEWS b/docs/NEWS index 9e8051b..22b92d5 100644 --- a/docs/NEWS +++ b/docs/NEWS @@ -3,6 +3,10 @@ Version 0.9 () ------------------------------------------------------------------------ + * Make media insertion dialog remember settings (via Cookies) and + insert return of the media database on cursor position. + (garvinhicking) + * Admin comment panels shows comments with their content and escaped HTML instead of stripping all HTML. Only summary, if longer than 200 characters will have stripped HTML because of otherwise invalid markup. (garvinhicking) diff --git a/serendipity_admin_image_selector.php b/serendipity_admin_image_selector.php index 4ba4337..2670406 100644 --- a/serendipity_admin_image_selector.php +++ b/serendipity_admin_image_selector.php @@ -22,6 +22,20 @@ if (!isset($serendipity['GET']['step'])) { $serendipity['GET']['step'] = (isset($serendipity['POST']['step']) ? $serendipity['POST']['step'] : ''); } +function ifRemember($name, $value, $isDefault = false, $att = 'checked') { + global $serendipity; + + if (!is_array($serendipity['COOKIE']) && !$isDefault) { + return false; + } + + if ((!is_array($serendipity['COOKIE']) && $isDefault) || + (!isset($serendipity['COOKIE']['serendipity_' . $name]) && $isDefault) || + (isset($serendipity['COOKIE']['serendipity_' . $name]) && $serendipity['COOKIE']['serendipity_' . $name] == $value)) { + + return " $att=\"$att\" "; + } +} ?> @@ -37,6 +51,23 @@ if (!isset($serendipity['GET']['step'])) { expire.setTime(today.getTime() + (60*60*24*30)); document.cookie = 'serendipity[' + name + ']='+escape(value) + ';expires=' + expire.toGMTString(); } + + function rememberOptions() { + el = document.getElementById('imageForm'); + for (i = 0; i < el.elements.length; i++) { + elname = new String(el.elements[i].name); + elname = elname.replace(/\[/g, '_'); + elname = elname.replace(/\]/g, ''); + + if (el.elements[i].type == 'radio') { + if (el.elements[i].checked) { + SetCookie(elname, el.elements[i].value); + } + } else if (typeof(el.elements[i].options) == 'object') { + SetCookie(elname, el.elements[i].options[el.elements[i].selectedIndex].value); + } + } + } @@ -123,7 +154,7 @@ switch ($serendipity['GET']['step']) {

-

+
@@ -142,24 +173,24 @@ switch ($serendipity['GET']['step']) { :
-
-
+ />
+ />

:
-
-
-
+ value="" />
+ value="left" />
+ value="right" />

:
-
- + />
+ />
@@ -178,7 +209,7 @@ switch ($serendipity['GET']['step']) { - +
@@ -244,4 +275,3 @@ switch ($serendipity['GET']['step']) { diff --git a/serendipity_editor.js b/serendipity_editor.js index 4918d30..c4ca8e6 100644 --- a/serendipity_editor.js +++ b/serendipity_editor.js @@ -144,7 +144,7 @@ function serendipity_imageSelector_addToElement (str, el) function serendipity_imageSelector_addToBody (str, textarea) { - document.forms['serendipityEntry']['serendipity['+ textarea +']'].value += str; + wrapSelection(document.forms['serendipityEntry']['serendipity['+ textarea +']'], str, ''); document.forms['serendipityEntry']['serendipity['+ textarea +']'].focus(); } @@ -219,6 +219,7 @@ function serendipity_imageSelector_done(textarea) if (self.opener.editorref) { self.opener.editorref.surroundHTML(block, ''); } else { + self.opener.serendipity_imageSelector_addToBody(block, textarea); } -- 2.39.5