svn commit: r560257 - in /lenya/trunk/src/modules/fckeditor: ./ config/ config/cocoon-xconf/ resources/ resources/javascript/ resources/plugins/fck_lenya_glue/ resources/plugins/fck_lenya_glue/lang/ resources/plugins/lenyaSave/ usecases/ xslt/

[email protected]
Newsgroups gmane.comp.cms.lenya.cvs
Message-ID <[email protected]>
Author: nettings
Date: Fri Jul 27 07:54:53 2007
New Revision: 560257

URL: http://svn.apache.org/viewvc?view=rev&rev=560257
Log:
migrate fckeditor to new editor usecase api.
this is a little shaky atm...


Added:
    lenya/trunk/src/modules/fckeditor/resources/UNPACK_FCKEDITOR_ARCHIVE_HERE
    lenya/trunk/src/modules/fckeditor/resources/plugins/fck_lenya_glue/
    lenya/trunk/src/modules/fckeditor/resources/plugins/fck_lenya_glue/fckplugin.js
    lenya/trunk/src/modules/fckeditor/resources/plugins/fck_lenya_glue/insertImage.gif   (with props)
    lenya/trunk/src/modules/fckeditor/resources/plugins/fck_lenya_glue/insertLink.gif   (with props)
    lenya/trunk/src/modules/fckeditor/resources/plugins/fck_lenya_glue/lang/
    lenya/trunk/src/modules/fckeditor/resources/plugins/fck_lenya_glue/lang/de.js
    lenya/trunk/src/modules/fckeditor/resources/plugins/fck_lenya_glue/lang/en.js
Removed:
    lenya/trunk/src/modules/fckeditor/config/cocoon-xconf/usecase-insertAsset.xconf
    lenya/trunk/src/modules/fckeditor/config/cocoon-xconf/usecase-insertImage.xconf
    lenya/trunk/src/modules/fckeditor/resources/javascript/insertAsset.js
    lenya/trunk/src/modules/fckeditor/resources/javascript/insertLink.js
    lenya/trunk/src/modules/fckeditor/resources/plugins/lenyaSave/
    lenya/trunk/src/modules/fckeditor/xslt/link.xsl
Modified:
    lenya/trunk/src/modules/fckeditor/config/module.xml
    lenya/trunk/src/modules/fckeditor/resources/javascript/fckconfig.js
    lenya/trunk/src/modules/fckeditor/resources/javascript/fckloader.js
    lenya/trunk/src/modules/fckeditor/sitemap.xmap
    lenya/trunk/src/modules/fckeditor/usecases/fckeditor.jx

Modified: lenya/trunk/src/modules/fckeditor/config/module.xml
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/fckeditor/config/module.xml?view=diff&rev=560257&r1=560256&r2=560257
==============================================================================
--- lenya/trunk/src/modules/fckeditor/config/module.xml (original)
+++ lenya/trunk/src/modules/fckeditor/config/module.xml Fri Jul 27 07:54:53 2007
@@ -22,8 +22,9 @@
   <id>org.apache.lenya.modules.fckeditor</id>
   <depends module="org.apache.lenya.modules.usecase"/>
   <package>org.apache.lenya.modules</package>
-  <version>0.1-dev</version>
+  <version>0.2-dev</version>
   <name>FCK Editor</name>
   <lenya-version>@lenya.version@</lenya-version>
-  <description>FCK Editor</description>
+  <description>FCK Editor, now uses generic usecases to insert links, images and
+  assets</description>
 </module>

Added: lenya/trunk/src/modules/fckeditor/resources/UNPACK_FCKEDITOR_ARCHIVE_HERE
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/fckeditor/resources/UNPACK_FCKEDITOR_ARCHIVE_HERE?view=auto&rev=560257
==============================================================================
    (empty)

Modified: lenya/trunk/src/modules/fckeditor/resources/javascript/fckconfig.js
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/fckeditor/resources/javascript/fckconfig.js?view=diff&rev=560257&r1=560256&r2=560257
==============================================================================
--- lenya/trunk/src/modules/fckeditor/resources/javascript/fckconfig.js (original)
+++ lenya/trunk/src/modules/fckeditor/resources/javascript/fckconfig.js Fri Jul 27 07:54:53 2007
@@ -21,14 +21,14 @@
  */
 
 FCKConfig.ToolbarSets["Lenya"] = [
-	['Source','DocProps','-','lenyaSave','Preview','-','Templates'],
+	['Source','DocProps','-','Lenya_save','Preview','-','Templates'],
 	['Cut','Copy','Paste','PasteText','PasteWord','-','Print'],
 	['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
 	['Bold','Italic','Underline','StrikeThrough','-','Subscript','Superscript'],
 	['OrderedList','UnorderedList','-','Outdent','Indent'],
 	['JustifyLeft','JustifyCenter','JustifyRight','JustifyFull'],
-	['Link','Unlink','Anchor'],
-	['Image','Table','Rule','Smiley','SpecialChar','PageBreak'],
+	['Link', 'Lenya_insertLink','Unlink','Anchor'],
+	['Image', 'Lenya_insertImage','Table','Rule','Smiley','SpecialChar','PageBreak'],
 	['Form','Checkbox','Radio','TextField','Textarea','Select','Button','ImageButton','HiddenField'],
 	'/',
 	['Style','FontFormat','FontName','FontSize'],
@@ -39,7 +39,7 @@
  /*
  * plugin for save in lenya
  */  
-FCKConfig.Plugins.Add( 'lenyaSave', 'de,en', '../../plugins/' ) ;
+FCKConfig.Plugins.Add( 'fck_lenya_glue', 'de,en', '../../plugins/' ) ;
 
 /*
  * disable uploads since it needs to be done from withing Lenya

Modified: lenya/trunk/src/modules/fckeditor/resources/javascript/fckloader.js
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/fckeditor/resources/javascript/fckloader.js?view=diff&rev=560257&r1=560256&r2=560257
==============================================================================
--- lenya/trunk/src/modules/fckeditor/resources/javascript/fckloader.js (original)
+++ lenya/trunk/src/modules/fckeditor/resources/javascript/fckloader.js Fri Jul 27 07:54:53 2007
@@ -26,7 +26,10 @@
   oFCKeditor.Config[ "ProcessNumericEntities" ] = true ;
   oFCKeditor.Config["CustomConfigurationsPath"] = contextPath + "/modules/fckeditor/javascript/fckconfig.js"  ;
   oFCKeditor.ToolbarSet = 'Lenya' ;
-  oFCKeditor.Config[ "ImageBrowserURL" ] = requesturi +'?lenya.usecase=fckeditor.insertImage' ;
-  oFCKeditor.Config[ "LinkBrowserURL" ] = requesturi +'?lenya.module=fckeditor&lenya.step=link-show&language=en' ;
+// the current API does not support this anymore. there is a plugin for that job now.
+// with an extra html page, this function could probably be restored easily, which would be
+// nice because it plugs into the rather comfortable image and link dialogs of FCK...
+//  oFCKeditor.Config[ "ImageBrowserURL" ] = requesturi +'?lenya.usecase=editors.insertImage' ;
+//  oFCKeditor.Config[ "LinkBrowserURL" ] = requesturi +'?lenya.usecase=editors.insertLink' ;
   oFCKeditor.ReplaceTextarea() ;
 }

Added: lenya/trunk/src/modules/fckeditor/resources/plugins/fck_lenya_glue/fckplugin.js
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/fckeditor/resources/plugins/fck_lenya_glue/fckplugin.js?view=auto&rev=560257
==============================================================================
--- lenya/trunk/src/modules/fckeditor/resources/plugins/fck_lenya_glue/fckplugin.js (added)
+++ lenya/trunk/src/modules/fckeditor/resources/plugins/fck_lenya_glue/fckplugin.js Fri Jul 27 07:54:53 2007
@@ -0,0 +1,190 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License.  You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+
+/**
+  * implements a "save" button that works with Lenya
+  *
+  * All it does is trigger a submit event, and then the normal 
+  * usecase handler takes over, as if the user had clicked 
+  * the XHTML submit button.
+  */
+function LenyaSaveCommand() {  this.Name = 'Lenya_save'; }
+
+/**
+  * an FCKeditor callback that is run when the command is invoked
+  */
+LenyaSaveCommand.prototype.Execute = function() {
+  var oForm = FCK.LinkedField.form ;
+  oForm.submit.click()
+}
+/**
+  * an FCKeditor callback that takes care of button state
+  */ 
+LenyaSaveCommand.prototype.GetState = function() { 
+  return FCK_TRISTATE_OFF;
+}
+
+
+/**
+  * implements an "insert link" button that works with Lenya
+  *
+  * It will open the editors.insertLink usecase in a new window.
+  */
+function LenyaInsertLinkCommand() { this.Name = 'Lenya_insertLink'; }
+
+/**
+  * an FCKeditor callback that is run when the command is invoked
+  */
+LenyaInsertLinkCommand.prototype.Execute = function() {
+  //alert("Lenya_insertLink executed.");
+  var windowName = org.apache.lenya.editors.generateUniqueWindowName();
+  var selection = org.apache.lenya.editors.getSelectedText(FCK.EditorWindow);
+  usecaseMap[windowName] = org.apache.lenya.editors.USECASE_INSERTLINK;
+  objectData[windowName] = new org.apache.lenya.editors.ObjectData({
+    url   : "",
+    title : "",
+    text  : selection
+  });
+  org.apache.lenya.editors.openUsecaseWindow(
+    usecaseMap[windowName],
+    windowName
+  );
+}
+
+/**
+  * an FCKeditor callback that takes care of button state
+  */ 
+LenyaInsertLinkCommand.prototype.GetState = function() { 
+  return FCK_TRISTATE_OFF; 
+}
+
+
+/**
+  * implements an "insert image" button that works with Lenya
+  *
+  * It will open the editors.insertImage usecase in a new window.
+  */
+function LenyaInsertImageCommand() { this.Name = 'Lenya_insertLink'; }
+
+/**
+  * an FCKeditor callback that is run when the command is invoked
+  */
+LenyaInsertImageCommand.prototype.Execute = function() {
+  //alert("Lenya_insertImage executed.");
+  var windowName = org.apache.lenya.editors.generateUniqueWindowName();
+  var selection = org.apache.lenya.editors.getSelectedText(FCK.EditorWindow);
+  usecaseMap[windowName] = org.apache.lenya.editors.USECASE_INSERTIMAGE;
+  objectData[windowName] = new org.apache.lenya.editors.ObjectData({
+    url   : "",
+    title : "",
+    text  : selection,
+    height: "",
+    width : ""
+  });
+  org.apache.lenya.editors.openUsecaseWindow(
+    usecaseMap[windowName],
+    windowName
+  );
+}
+
+/**
+  * an FCKeditor callback that takes care of button state
+  */ 
+LenyaInsertImageCommand.prototype.GetState = function() { 
+  return FCK_TRISTATE_OFF;
+}
+
+
+/***************** main *******************************************************/  
+
+/**
+  * FCKeditor uses frames heavily, which means that our helper library
+  * will not be in the current scope. So we define it to point to the
+  * "top" window, which hopefully has the library included.
+  */
+var org;
+if (!org) {
+  org = window.top.org;
+} else if (!org.apache) {
+  org.apache = window.top.org.apache;
+} else if (!org.apache.lenya) {
+  org.apache.lenya = window.top.org.apache.lenya;
+} else if (!org.apache.lenya.editors) {
+  org.apache.lenya.editors = window.top.org.apache.lenya.editors;
+}
+
+/**
+  * to store usecase data per window
+  */
+var objectData = new Array();
+
+/**
+  * to map usecase names to window names
+  */
+var usecaseMap = new Array();
+
+
+/* FCKCommands.RegisterCommand(commandName, command)
+       commandName - Command name, referenced by the Toolbar, etc...
+       command - Command object (must provide an Execute() function).
+*/
+
+// Register Lenya-specific commands
+
+FCKCommands.RegisterCommand('Lenya_save', new LenyaSaveCommand());
+FCKCommands.RegisterCommand('Lenya_insertLink', new LenyaInsertLinkCommand());
+FCKCommands.RegisterCommand('Lenya_insertImage', new LenyaInsertImageCommand());
+
+
+
+// Create Lenya-specific toolbar buttons:
+ 
+var oLenya_saveItem = new FCKToolbarButton('Lenya_save', FCKLang['DlgLenya_saveTitle']);
+oLenya_saveItem.IconPath= [FCKConfig.SkinPath + 'fck_strip.gif', 16, 3]; // use FCKEditor's icons
+FCKToolbarItems.RegisterItem( 'Lenya_save', oLenya_saveItem ) ;
+
+var oLenya_insertLinkItem = new FCKToolbarButton('Lenya_insertLink', FCKLang['DlgLenya_insertLinkTitle']);
+oLenya_insertLinkItem.IconPath = FCKPlugins.Items['fck_lenya_glue'].Path + 'insertLink.gif' ;
+FCKToolbarItems.RegisterItem( 'Lenya_insertLink', oLenya_insertLinkItem ) ;
+
+var oLenya_insertImageItem = new FCKToolbarButton( 'Lenya_insertImage', FCKLang['DlgLenya_insertImageTitle']);
+oLenya_insertImageItem.IconPath = FCKPlugins.Items['fck_lenya_glue'].Path + 'insertImage.gif';
+FCKToolbarItems.RegisterItem('Lenya_insertImage', oLenya_insertImageItem);
+
+
+/******************** Lenya editor usecase callbacks **********************/
+
+
+org.apache.lenya.editors.setObjectData = function(objectData, windowName) {
+  var usecase = usecaseMap[windowName];
+  var snippet = org.apache.lenya.editors.generateContentSnippet(usecase, objectData);
+  var selection = org.apache.lenya.editors.getSelectedText(FCK.EditorWindow);
+  
+  FCK.InsertHtml(
+    snippet.beforeSelection 
+    + (snippet.replaceSelection ? snippet.replaceSelection : selection)
+    + snippet.afterSelection
+  );
+
+  usecaseMap[windowName] = undefined; // we're done!
+  objectData[windowName] = undefined; // we're done!
+}
+
+org.apache.lenya.editors.getObjectData = function(windowName, usecase) {
+  return objectData[windowName];
+}

Added: lenya/trunk/src/modules/fckeditor/resources/plugins/fck_lenya_glue/insertImage.gif
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/fckeditor/resources/plugins/fck_lenya_glue/insertImage.gif?view=auto&rev=560257
==============================================================================
Binary file - no diff available.

Propchange: lenya/trunk/src/modules/fckeditor/resources/plugins/fck_lenya_glue/insertImage.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: lenya/trunk/src/modules/fckeditor/resources/plugins/fck_lenya_glue/insertLink.gif
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/fckeditor/resources/plugins/fck_lenya_glue/insertLink.gif?view=auto&rev=560257
==============================================================================
Binary file - no diff available.

Propchange: lenya/trunk/src/modules/fckeditor/resources/plugins/fck_lenya_glue/insertLink.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: lenya/trunk/src/modules/fckeditor/resources/plugins/fck_lenya_glue/lang/de.js
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/fckeditor/resources/plugins/fck_lenya_glue/lang/de.js?view=auto&rev=560257
==============================================================================
--- lenya/trunk/src/modules/fckeditor/resources/plugins/fck_lenya_glue/lang/de.js (added)
+++ lenya/trunk/src/modules/fckeditor/resources/plugins/fck_lenya_glue/lang/de.js Fri Jul 27 07:54:53 2007
@@ -0,0 +1,20 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License.  You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+FCKLang['DlgLenya_saveTitle'] = 'Lenya-Dokument speichern'; 
+FCKLang['DlgLenya_insertLinkTitle'] = 'Lenya-Link einfügen'; 
+FCKLang['DlgLenya_insertImageTitle'] = 'Lenya-Bild einfügen'; 

Added: lenya/trunk/src/modules/fckeditor/resources/plugins/fck_lenya_glue/lang/en.js
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/fckeditor/resources/plugins/fck_lenya_glue/lang/en.js?view=auto&rev=560257
==============================================================================
--- lenya/trunk/src/modules/fckeditor/resources/plugins/fck_lenya_glue/lang/en.js (added)
+++ lenya/trunk/src/modules/fckeditor/resources/plugins/fck_lenya_glue/lang/en.js Fri Jul 27 07:54:53 2007
@@ -0,0 +1,20 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License.  You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+FCKLang['DlgLenya_saveTitle'] = 'Save Lenya Document'; 
+FCKLang['DlgLenya_insertLinkTitle'] = 'Insert Lenya link'; 
+FCKLang['DlgLenya_insertImageTitle'] = 'Insert Lenya image'; 

Modified: lenya/trunk/src/modules/fckeditor/sitemap.xmap
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/fckeditor/sitemap.xmap?view=diff&rev=560257&r1=560256&r2=560257
==============================================================================
--- lenya/trunk/src/modules/fckeditor/sitemap.xmap (original)
+++ lenya/trunk/src/modules/fckeditor/sitemap.xmap Fri Jul 27 07:54:53 2007
@@ -43,6 +43,7 @@
 
   <map:pipelines>
     <map:pipeline>
+
       <map:match pattern="fckeditor.open" >
         <map:generate type="jx" src="fallback://lenya/modules/fckeditor/usecases/fckeditor.jx"/>
         <map:transform type="i18n">
@@ -53,25 +54,6 @@
         <map:transform type="proxy"/>
         <map:transform src="fallback://lenya/xslt/util/strip_namespaces.xsl"/>
         <map:serialize type="xhtml"/>
-      </map:match>
-
-      <map:match pattern="link-show" type="step">
-        <map:generate src="context://lenya/content/util/empty.xml"/>
-        <map:transform src="fallback://lenya/modules/fckeditor/xslt/link.xsl" label="content">
-          <map:parameter name="infoarea" value="true"/>
-          <map:parameter name="contextprefix" value=""/>
-          <map:parameter name="publicationid" value="{page-envelope:publication-id}"/>
-          <map:parameter name="area" value="authoring"/>
-          <map:parameter name="tab" value="en"/>
-          <map:parameter name="chosenlanguage" value="{page-envelope:document-language}"/>
-          <map:parameter name="path" value="{page-envelope:document-path}"/>
-          <map:parameter name="documenturl" value="/{page-envelope:document-url}"/>
-          <map:parameter name="documentextension" value="{page-envelope:document-extension}"/>
-          <map:parameter name="defaultlanguage" value="{page-envelope:default-language}"/>
-          <map:parameter name="languages" value="{page-envelope:publication-languages-csv}"/>
-        </map:transform>
-        <map:call resource="style-cms-page"/>
-        <map:serialize />
       </map:match>
 
       <map:match pattern="content">

Modified: lenya/trunk/src/modules/fckeditor/usecases/fckeditor.jx
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/fckeditor/usecases/fckeditor.jx?view=diff&rev=560257&r1=560256&r2=560257
==============================================================================
--- lenya/trunk/src/modules/fckeditor/usecases/fckeditor.jx (original)
+++ lenya/trunk/src/modules/fckeditor/usecases/fckeditor.jx Fri Jul 27 07:54:53 2007
@@ -27,6 +27,8 @@
   <script type="text/javascript" src="/modules/fckeditor/fckeditor/fckeditor.js">&#160;</script>
   <script type="text/javascript" src="/modules/fckeditor/javascript/fckloader.js">&#160;</script>
   <script type="text/javascript" src="/modules/editors/javascript/disablebackspace.js">&#160;</script>
+  <script type="text/javascript" src="/modules/editors/javascript/org.apache.lenya.editors.js">&#160;</script> 
+  <script type="text/javascript" src="/modules/fckeditor/javascript/fck_lenya_glue.js">&#160;</script>
   <script type="text/javascript">
     window.onload = function()
     {
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.