[geeklog-hg] geeklog: Modified the code in order to enable the FCKEditor to b...

geeklog-cvs at lists.geeklog.net geeklog-cvs at lists.geeklog.net
Sat Aug 3 11:04:36 EDT 2013


changeset 9241:3bb5c8dfc471
url:  http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/3bb5c8dfc471
user: dengen <taharaxp at gmail.com>
date: Sat Aug 03 21:39:11 2013 +0900
description:
Modified the code in order to enable the FCKEditor to be replaced with another editor

diffstat:

 public_html/admin/plugins/staticpages/index.php   |  10 +-
 public_html/admin/story.php                       |   8 +-
 public_html/fckeditor/functions.js                |  31 +++++++
 public_html/javascript/staticpages_adveditor.js   |  71 +++++++++++++++++
 public_html/javascript/storyeditor_adveditor.js   |  95 +++++++++++++++++++++++
 public_html/javascript/submitcomment_adveditor.js |  60 ++++++++++++++
 public_html/javascript/submitstory_adveditor.js   |  60 ++++++++++++++
 public_html/lib-common.php                        |   5 +
 public_html/submit.php                            |   9 +-
 system/classes/scripts.class.php                  |   5 +-
 system/lib-comment.php                            |   8 +-
 11 files changed, 338 insertions(+), 24 deletions(-)

diffs (truncated from 442 to 300 lines):

diff -r 0f6822044e4c -r 3bb5c8dfc471 public_html/admin/plugins/staticpages/index.php
--- a/public_html/admin/plugins/staticpages/index.php	Tue Jul 30 21:41:55 2013 -0400
+++ b/public_html/admin/plugins/staticpages/index.php	Sat Aug 03 21:39:11 2013 +0900
@@ -103,12 +103,10 @@
         $sp_template->set_var('noscript', COM_getNoScript(false, '', $link_message));        
         
         // Add JavaScript
-        $_SCRIPTS->setJavaScriptFile('fckeditor','/fckeditor/fckeditor.js');
-        // Hide the Advanced Editor as Javascript is required. If JS is enabled then the JS below will un-hide it
-        $js = 'document.getElementById("advanced_editor").style.display="";';                 
-        $_SCRIPTS->setJavaScript($js, true);
-        $_SCRIPTS->setJavaScriptFile('staticpages_fckeditor', '/javascript/staticpages_fckeditor.js');
-
+        $_SCRIPTS->setJavaScriptFile('adveditor', $_CONF['advanced_editor_js']);
+        $_SCRIPTS->setJavaScriptFile('adveditor_functions', "/{$_CONF['advanced_editor_name']}/functions.js");
+        $_SCRIPTS->setJavaScriptFile('staticpages_adveditor', '/javascript/staticpages_adveditor.js');
+        
         $sp_template->set_var('lang_expandhelp', $LANG24[67]);
         $sp_template->set_var('lang_reducehelp', $LANG24[68]);
         $sp_template->set_var('lang_toolbar', $LANG24[70]);
diff -r 0f6822044e4c -r 3bb5c8dfc471 public_html/admin/story.php
--- a/public_html/admin/story.php	Tue Jul 30 21:41:55 2013 -0400
+++ b/public_html/admin/story.php	Sat Aug 03 21:39:11 2013 +0900
@@ -746,11 +746,9 @@
     );
 
     if ($advanced_editormode) {
-        $_SCRIPTS->setJavaScriptFile('fckeditor','/fckeditor/fckeditor.js');
-        // Hide the Advanced Editor as Javascript is required. If JS is enabled then the JS below will un-hide it
-        $js = 'document.getElementById("advanced_editor").style.display="";';
-        $_SCRIPTS->setJavaScript($js, true);
-        $_SCRIPTS->setJavaScriptFile('storyeditor_fckeditor', '/javascript/storyeditor_fckeditor.js');
+        $_SCRIPTS->setJavaScriptFile('adveditor', $_CONF['advanced_editor_js']);
+        $_SCRIPTS->setJavaScriptFile('adveditor_functions', "/{$_CONF['advanced_editor_name']}/functions.js");
+        $_SCRIPTS->setJavaScriptFile('storyeditor_adveditor', '/javascript/storyeditor_adveditor.js');
     }
     
     $story_templates->set_var('saved_images', $saved_images);
diff -r 0f6822044e4c -r 3bb5c8dfc471 public_html/fckeditor/functions.js
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/public_html/fckeditor/functions.js	Sat Aug 03 21:39:11 2013 +0900
@@ -0,0 +1,31 @@
+
+function adve_newEditor(instanceName, options) {
+    var oEditor = new FCKeditor(instanceName);
+    oEditor.BasePath = geeklogEditorBasePath;
+    oEditor.Config['CustomConfigurationsPath'] = geeklogEditorBaseUrl + '/fckeditor/myconfig.js';
+    oEditor.ToolbarSet = 'editor-toolbar' + (options['toolbar'] + 1);
+    oEditor.Height = 200;
+    oEditor.ReplaceTextarea();
+}
+
+function adve_getContent(instanceName) {
+    return FCKeditorAPI.GetInstance(instanceName).GetXHTML(true);
+}
+
+function adve_setContent(instanceName, content) {
+    FCKeditorAPI.GetInstance(instanceName).SetHTML(content);
+}
+
+function adve_changeToolbar(instanceName, toolbar) {
+    FCKeditorAPI.GetInstance(instanceName).ToolbarSet.Load(toolbar);
+}
+
+function adve_changeTextAreaSize(instanceName, option) {
+    var currentSize = parseInt(document.getElementById(instanceName + '___Frame').style.height);
+    if (option == 'larger') {
+        var newsize = currentSize + 50;
+    } else if (option == 'smaller') {
+        var newsize = currentSize - 50;
+    }
+    document.getElementById(instanceName + '___Frame').style.height = newsize + 'px';
+}
diff -r 0f6822044e4c -r 3bb5c8dfc471 public_html/javascript/staticpages_adveditor.js
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/public_html/javascript/staticpages_adveditor.js	Sat Aug 03 21:39:11 2013 +0900
@@ -0,0 +1,71 @@
+/* Reminder: always indent with 4 spaces (no tabs). */
+// +---------------------------------------------------------------------------+
+// | Geeklog 2.0                                                               |
+// +---------------------------------------------------------------------------+
+// | Javascript functions for WISIWIG HTML Editor Integration into Geeklog     |
+// |                                                                           |
+// +---------------------------------------------------------------------------+
+// | Copyright (C) 2003-2013 by the following authors:                         |
+// |                                                                           |
+// | Authors:   Blaine Lang - blaine at portalparts.com                           |
+// |                                                                           |
+// +---------------------------------------------------------------------------+
+// |                                                                           |
+// | This program is free software; you can redistribute it and/or             |
+// | modify it under the terms of the GNU General Public License               |
+// | as published by the Free Software Foundation; either version 2            |
+// | of the License, or (at your option) any later version.                    |
+// |                                                                           |
+// | This program is distributed in the hope that it will be useful,           |
+// | but WITHOUT ANY WARRANTY; without even the implied warranty of            |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             |
+// | GNU General Public License for more details.                              |
+// |                                                                           |
+// | You should have received a copy of the GNU General Public License         |
+// | along with this program; if not, write to the Free Software Foundation,   |
+// | Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.           |
+// |                                                                           |
+// +---------------------------------------------------------------------------+
+
+window.onload = function() {
+    var bar = 1;
+    if (navigator.userAgent.match(/iPhone|Android|IEMobile/i)) {
+        bar = 0;
+    }
+    document.getElementById('advanced_editor').style.display = '';
+    adve_newEditor('sp_content', {'toolbar':bar});
+    document.getElementById('fckeditor_toolbar_selector').options[bar].selected = true;
+}
+
+function changeToolbar(toolbar) {
+    adve_changeToolbar('sp_content', toolbar);
+}
+
+function change_editmode(obj) {
+    if (obj.value == 'adveditor') {
+        document.getElementById('advanced_editarea').style.display = '';
+        document.getElementById('sel_toolbar').style.display = '';
+        document.getElementById('html_editarea').style.display = 'none';
+        swapEditorContent('advanced');
+    } else {
+        document.getElementById('advanced_editarea').style.display = 'none';
+        document.getElementById('sel_toolbar').style.display = 'none';
+        document.getElementById('html_editarea').style.display = '';
+        swapEditorContent('html');
+    }
+}
+
+function swapEditorContent(curmode) {
+    if (curmode == 'advanced') {
+        var content = document.getElementById('html_content').value;
+        adve_setContent('sp_content', content);
+    } else {
+        document.getElementById('html_content').value = adve_getContent('sp_content');
+    }
+}
+
+function set_postcontent() {
+    if (document.getElementById('sel_editmode').value == 'adveditor') {
+        document.getElementById('html_content').value = adve_getContent('sp_content');
+    }
+}
diff -r 0f6822044e4c -r 3bb5c8dfc471 public_html/javascript/storyeditor_adveditor.js
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/public_html/javascript/storyeditor_adveditor.js	Sat Aug 03 21:39:11 2013 +0900
@@ -0,0 +1,95 @@
+/* Reminder: always indent with 4 spaces (no tabs). */
+// +---------------------------------------------------------------------------+
+// | Geeklog 2.0                                                               |
+// +---------------------------------------------------------------------------+
+// | Javascript functions for WISIWIG HTML Editor Integration into Geeklog     |
+// |                                                                           |
+// +---------------------------------------------------------------------------+
+// | Copyright (C) 2003-2013 by the following authors:                         |
+// |                                                                           |
+// | Authors:   Blaine Lang - blaine at portalparts.com                           |
+// |                                                                           |
+// +---------------------------------------------------------------------------+
+// |                                                                           |
+// | This program is free software; you can redistribute it and/or             |
+// | modify it under the terms of the GNU General Public License               |
+// | as published by the Free Software Foundation; either version 2            |
+// | of the License, or (at your option) any later version.                    |
+// |                                                                           |
+// | This program is distributed in the hope that it will be useful,           |
+// | but WITHOUT ANY WARRANTY; without even the implied warranty of            |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             |
+// | GNU General Public License for more details.                              |
+// |                                                                           |
+// | You should have received a copy of the GNU General Public License         |
+// | along with this program; if not, write to the Free Software Foundation,   |
+// | Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.           |
+// |                                                                           |
+// +---------------------------------------------------------------------------+
+
+window.onload = function() {
+    var bar = 1;
+    if (navigator.userAgent.match(/iPhone|Android|IEMobile/i)) {
+        bar = 0;
+    }
+    document.getElementById('advanced_editor').style.display = '';
+    adve_newEditor('introhtml', {'toolbar':bar});
+    adve_newEditor('bodyhtml',  {'toolbar':bar});
+    document.getElementById('fckeditor_toolbar_selector').options[bar].selected = true;
+}
+
+function change_editmode(obj) {
+    var navlistcount = document.getElementById('navlist').getElementsByTagName('li').length;
+    showhideEditorDiv('editor', navlistcount - 6);
+    if (obj.value == 'html') {
+        document.getElementById('html_editor').style.display = 'none';
+        document.getElementById('text_editor').style.display = '';
+        swapEditorContent('html', 'introhtml');
+        swapEditorContent('html', 'bodyhtml');
+    } else if (obj.value == 'adveditor') {
+        document.getElementById('text_editor').style.display = 'none';
+        document.getElementById('html_editor').style.display = '';
+        swapEditorContent('adveditor', 'introhtml');
+        swapEditorContent('adveditor', 'bodyhtml');
+    } else {
+        document.getElementById('html_editor').style.display = 'none';
+        document.getElementById('text_editor').style.display = '';
+        swapEditorContent('text', 'introhtml');
+        swapEditorContent('text', 'bodyhtml');
+    }
+}
+
+function changeHTMLTextAreaSize(element, option) {
+    adve_changeTextAreaSize(element, option);
+}
+
+function changeTextAreaSize(element, option) {
+    var size = document.getElementById(element).rows;
+    if (option == 'larger') {
+        document.getElementById(element).rows = +(size) + 3;
+    } else if (option == 'smaller') {
+        document.getElementById(element).rows = +(size) - 3;
+    }
+}
+
+function swapEditorContent(curmode,instanceName) {
+    var textelem = (instanceName == 'introhtml') ? 'introtext' : 'bodytext';
+    if (curmode == 'adveditor') {
+        var content = document.getElementById(textelem).value;
+        adve_setContent(instanceName, content)
+    } else {
+        document.getElementById(textelem).value = adve_getContent(instanceName);
+    }
+}
+
+function set_postcontent() {
+    if (document.getElementById('sel_editmode').value == 'adveditor') {
+        document.getElementById('introtext').value = adve_getContent('introhtml');
+        document.getElementById('bodytext').value = adve_getContent('bodyhtml');
+    }
+}
+
+function changeToolbar(toolbar) {
+    adve_changeToolbar('introhtml', toolbar);
+    adve_changeToolbar('bodyhtml', toolbar);
+}
diff -r 0f6822044e4c -r 3bb5c8dfc471 public_html/javascript/submitcomment_adveditor.js
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/public_html/javascript/submitcomment_adveditor.js	Sat Aug 03 21:39:11 2013 +0900
@@ -0,0 +1,60 @@
+/* Reminder: always indent with 4 spaces (no tabs). */
+// +---------------------------------------------------------------------------+
+// | Geeklog 2.0                                                               |
+// +---------------------------------------------------------------------------+
+// | Javascript functions for WISIWIG HTML Editor Integration into Geeklog     |
+// |                                                                           |
+// +---------------------------------------------------------------------------+
+// | Copyright (C) 2003-2013 by the following authors:                         |
+// |                                                                           |
+// | Authors:   Blaine Lang - blaine at portalparts.com                           |
+// |                                                                           |
+// +---------------------------------------------------------------------------+
+// |                                                                           |
+// | This program is free software; you can redistribute it and/or             |
+// | modify it under the terms of the GNU General Public License               |
+// | as published by the Free Software Foundation; either version 2            |
+// | of the License, or (at your option) any later version.                    |
+// |                                                                           |
+// | This program is distributed in the hope that it will be useful,           |
+// | but WITHOUT ANY WARRANTY; without even the implied warranty of            |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             |
+// | GNU General Public License for more details.                              |
+// |                                                                           |
+// | You should have received a copy of the GNU General Public License         |
+// | along with this program; if not, write to the Free Software Foundation,   |
+// | Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.           |
+// |                                                                           |
+// +---------------------------------------------------------------------------+
+
+window.onload = function() {
+    document.getElementById('advanced_editor').style.display = '';
+    adve_newEditor('comment_html', {'toolbar':0});
+}
+
+function change_editmode(obj) {
+    if (obj.value == 'html') {
+        document.getElementById('text_editor').style.display = 'none';
+        document.getElementById('html_editor').style.display = '';
+        swapEditorContent('html');
+    } else {
+        document.getElementById('text_editor').style.display = '';
+        document.getElementById('html_editor').style.display = 'none';
+        swapEditorContent('text');
+    }
+}
+
+function swapEditorContent(curmode) {
+    if (curmode == 'html') {
+        var content = document.getElementById('comment_text').value;



More information about the geeklog-cvs mailing list