svn commit: r558896 - in /lenya/trunk/src/modules/tinymce: ./ resources/javascript/ xslt/

[email protected]
Newsgroups gmane.comp.cms.lenya.cvs
Message-ID <[email protected]>
Author: nettings
Date: Mon Jul 23 16:17:05 2007
New Revision: 558896

URL: http://svn.apache.org/viewvc?view=rev&rev=558896
Log:
added tinymce localisation according to {request:locale}. quite awkward,
since it requires an extra pipeline and transformation, but there is no
way to determine the browser language settings via javascript :(
removed "lenya.editorModule" parameter, callbacks are now provided by
the parent window and accessed via window.opener, i.e. the generic
usecase no longer needs to know which module is calling.

this is work in progress.

Added:
    lenya/trunk/src/modules/tinymce/resources/javascript/tiny_config.xml
      - copied, changed from r558684, lenya/trunk/src/modules/tinymce/resources/javascript/tiny_config.js
    lenya/trunk/src/modules/tinymce/xslt/tiny_config.xsl
Removed:
    lenya/trunk/src/modules/tinymce/resources/javascript/editorCallbacks.js
    lenya/trunk/src/modules/tinymce/resources/javascript/tiny_config.js
Modified:
    lenya/trunk/src/modules/tinymce/resources/javascript/tiny_lenya_glue.js
    lenya/trunk/src/modules/tinymce/sitemap.xmap
    lenya/trunk/src/modules/tinymce/xslt/page2edit.xsl

Copied: lenya/trunk/src/modules/tinymce/resources/javascript/tiny_config.xml (from r558684, lenya/trunk/src/modules/tinymce/resources/javascript/tiny_config.js)
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/tinymce/resources/javascript/tiny_config.xml?view=diff&rev=558896&p1=lenya/trunk/src/modules/tinymce/resources/javascript/tiny_config.js&r1=558684&p2=lenya/trunk/src/modules/tinymce/resources/javascript/tiny_config.xml&r2=558896
==============================================================================
--- lenya/trunk/src/modules/tinymce/resources/javascript/tiny_config.js (original)
+++ lenya/trunk/src/modules/tinymce/resources/javascript/tiny_config.xml Mon Jul 23 16:17:05 2007
@@ -1,4 +1,5 @@
-/*
+<javascript>
+  /*
   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.
@@ -20,9 +21,11 @@
 of options can be found in the excellent manual at
 http://tinymce.moxiecode.com/tinymce/docs/reference_configuration.html
 */
-  
+
+
     currentURL = location.href.replace(/\?.*$/,"");
-    //alert(currentURL);
+    locale = "<locale/>";
+
     config = {
 
     /* enable customizable theme */
@@ -33,13 +36,13 @@
     elements : "tinymce.content",
 
     /* FIXME: how do I get the user's language preference for authoring? */
-    language : "en",
+    language : locale,
 
     /* enable plugins for custom save function, fullscreen editing
       and search-and-replace. */
     plugins  : "save,fullscreen,searchreplace,table,contextmenu,simplebrowser",
     
-       plugin_simplebrowser_browselinkurl : currentURL + '?lenya.usecase=editors.insertLink&lenya.editorModule=tinymce',
+       plugin_simplebrowser_browselinkurl : currentURL + '?lenya.usecase=editors.insertLink',
        plugin_simplebrowser_browseimageurl : currentURL + '?lenya.usecase=tinymce.insertImage',
        plugin_simplebrowser_browseflashurl : '',
      
@@ -124,3 +127,4 @@
     save_callback : "LenyaSaveContent"
     };
 
+</javascript>
\ No newline at end of file

Modified: lenya/trunk/src/modules/tinymce/resources/javascript/tiny_lenya_glue.js
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/tinymce/resources/javascript/tiny_lenya_glue.js?view=diff&rev=558896&r1=558895&r2=558896
==============================================================================
--- lenya/trunk/src/modules/tinymce/resources/javascript/tiny_lenya_glue.js (original)
+++ lenya/trunk/src/modules/tinymce/resources/javascript/tiny_lenya_glue.js Mon Jul 23 16:17:05 2007
@@ -33,16 +33,6 @@
 }
 
 
-// this function will be called by the generic insertAsset
-// usecase.
-function insertCallback(content, editor_id) {
-  // FIXME: this is not tested and not finished. How are internal links handled atm?
-  alert("insertCallback called.\n" 
-         + "content   : " + content + "\n"
-         + "editor_id : " + editor_id
-  );
-  tinyMCE.execCommand('mceInsertContent', decodeURI(editor_id), content);
-}
 
 function LenyaSaveContent(element_id, html, body) {
   // Do some custom HTML cleanup
@@ -53,4 +43,24 @@
   return html;
 }
 
+/**
+  * This function is called by the editors.insertLink view to
+  * get default values and to determine which fields will be enabled.
+  * @returns a linkData hash map.
+  */
+function LenyaGetLinkData() {
+  var currentURL = TinyMCE_SimpleBrowserPlugin.options['curl'];
+  return {
+    'href' : currentURL ? currentURL : ""
+  };
+}
+
+/**
+  * This function is called by the editors.insertLink view to
+  * update the editor with the new user-supplied values.
+  */
+function LenyaSetLinkData(linkData) { 
+  TinyMCE_SimpleBrowserPlugin.browserCallback(linkData);
+}
 
+var lenyaLinkData;

Modified: lenya/trunk/src/modules/tinymce/sitemap.xmap
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/tinymce/sitemap.xmap?view=diff&rev=558896&r1=558895&r2=558896
==============================================================================
--- lenya/trunk/src/modules/tinymce/sitemap.xmap (original)
+++ lenya/trunk/src/modules/tinymce/sitemap.xmap Mon Jul 23 16:17:05 2007
@@ -88,6 +88,25 @@
         <map:serialize type="xhtml"/>
       </map:match>
 
+      <!-- check requested locale and set appropriate tinymce language, if available. if not, fall back to english -->
+      <map:match pattern="tiny_config.xml">
+        <map:generate src="fallback://lenya/modules/tinymce/resources/javascript/tiny_config.xml"/>
+        <map:select type="resource-exists">
+          <!-- fixme: is this an appropriate test for language packs? -->
+          <map:when test="fallback://lenya/modules/tinymce/resources/tinymce/jscripts/tiny_mce/langs/{request:locale}.js">
+            <map:transform src="fallback://lenya/modules/tinymce/xslt/tiny_config.xsl">  
+              <map:parameter name="locale" value="{request:locale}"/>
+            </map:transform>
+          </map:when>
+          <map:otherwise>
+            <map:transform src="fallback://lenya/modules/tinymce/xslt/tiny_config.xsl">  
+              <map:parameter name="locale" value="en"/>
+            </map:transform>
+          </map:otherwise>
+        </map:select>
+        <map:serialize type="text"/>
+      </map:match>
+
     </map:pipeline>
 
   </map:pipelines>

Modified: lenya/trunk/src/modules/tinymce/xslt/page2edit.xsl
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/tinymce/xslt/page2edit.xsl?view=diff&rev=558896&r1=558895&r2=558896
==============================================================================
--- lenya/trunk/src/modules/tinymce/xslt/page2edit.xsl (original)
+++ lenya/trunk/src/modules/tinymce/xslt/page2edit.xsl Mon Jul 23 16:17:05 2007
@@ -75,7 +75,7 @@
   </xsl:text>
   <script language="javascript" 
           type="text/javascript"
-          src="/{$publicationid}/modules/tinymce/javascript/tiny_config.js"
+          src="/{$publicationid}/modules/tinymce/tiny_config.xml"
   >&#160;</script>
   <xsl:text>
   </xsl:text>

Added: lenya/trunk/src/modules/tinymce/xslt/tiny_config.xsl
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/tinymce/xslt/tiny_config.xsl?view=auto&rev=558896
==============================================================================
--- lenya/trunk/src/modules/tinymce/xslt/tiny_config.xsl (added)
+++ lenya/trunk/src/modules/tinymce/xslt/tiny_config.xsl Mon Jul 23 16:17:05 2007
@@ -0,0 +1,15 @@
+<xsl:stylesheet version="1.0"
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+>
+
+<xsl:param name="locale"/>
+
+<xsl:template match="/*">
+  <xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="locale">
+  <xsl:value-of select="$locale"/>
+</xsl:template>
+
+</xsl:stylesheet>
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.