You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by ne...@apache.org on 2007/07/22 22:45:12 UTC

svn commit: r558544 - in /lenya/trunk/src/modules/editors: config/cocoon-xconf/usecase-insertLink.xconf config/module.xml resources/javascript/insertLink.js sitemap.xmap xslt/ xslt/insertLink.xsl

Author: nettings
Date: Sun Jul 22 13:45:10 2007
New Revision: 558544

URL: http://svn.apache.org/viewvc?view=rev&rev=558544
Log:
introduced generic editors.insertLink usecase implementation.
the view is created by a cocoon pipeline, not a jxtemplate, because the
necessary data is more readily available as input modules than via the
java api.
the next commit will migrate tinymce to use this implementation.

Added:
    lenya/trunk/src/modules/editors/config/cocoon-xconf/usecase-insertLink.xconf
      - copied, changed from r556063, lenya/trunk/src/modules/tinymce/config/cocoon-xconf/usecase-tinymce-edit.xconf
    lenya/trunk/src/modules/editors/resources/javascript/insertLink.js
    lenya/trunk/src/modules/editors/xslt/
    lenya/trunk/src/modules/editors/xslt/insertLink.xsl
      - copied, changed from r556063, lenya/trunk/src/modules/tinymce/xslt/link.xsl
Modified:
    lenya/trunk/src/modules/editors/config/module.xml
    lenya/trunk/src/modules/editors/sitemap.xmap

Copied: lenya/trunk/src/modules/editors/config/cocoon-xconf/usecase-insertLink.xconf (from r556063, lenya/trunk/src/modules/tinymce/config/cocoon-xconf/usecase-tinymce-edit.xconf)
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/editors/config/cocoon-xconf/usecase-insertLink.xconf?view=diff&rev=558544&p1=lenya/trunk/src/modules/tinymce/config/cocoon-xconf/usecase-tinymce-edit.xconf&r1=556063&p2=lenya/trunk/src/modules/editors/config/cocoon-xconf/usecase-insertLink.xconf&r2=558544
==============================================================================
--- lenya/trunk/src/modules/tinymce/config/cocoon-xconf/usecase-tinymce-edit.xconf (original)
+++ lenya/trunk/src/modules/editors/config/cocoon-xconf/usecase-insertLink.xconf Sun Jul 22 13:45:10 2007
@@ -16,12 +16,11 @@
   limitations under the License.
 -->
 
-<xconf xpath="/cocoon/usecases" unless="/cocoon/usecases/component-instance[@name = 'tinymce.edit']">
+<xconf xpath="/cocoon/usecases" unless="/cocoon/usecases/component-instance[@name = 'editors.insertLink']">
 
-  <component-instance name="tinymce.edit" logger="lenya.publication"
-                      class="org.apache.lenya.cms.editors.tinymce.TinyMce">
-    <transaction policy="pessimistic"/>
-    <view uri="cocoon://modules/tinymce/tinymce.edit" menu="false"/>
+  <component-instance name="editors.insertLink" logger="lenya.publication"
+                      class="org.apache.lenya.cms.usecase.DummyUsecase">
+    <view uri="cocoon://modules/editors/editors.insertLink" menu="false"/>
   </component-instance>
     
 </xconf>

Modified: lenya/trunk/src/modules/editors/config/module.xml
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/editors/config/module.xml?view=diff&rev=558544&r1=558543&r2=558544
==============================================================================
--- lenya/trunk/src/modules/editors/config/module.xml (original)
+++ lenya/trunk/src/modules/editors/config/module.xml Sun Jul 22 13:45:10 2007
@@ -25,8 +25,9 @@
   <depends module="org.apache.lenya.modules.sitemanagement"/>
   <depends module="org.apache.lenya.modules.linking"/>
   <package>org.apache.lenya.modules</package>
-  <version>0.1-dev</version>
+  <version>0.2-dev</version>
   <name>Editors</name>
   <lenya-version>@lenya.version@</lenya-version>
-  <description>Editor base and support classes</description>
+  <description>Editor base and support classes, Forms and Oneform editor
+  implementations, generic insertLink usecase implementation</description>
 </module>

Added: lenya/trunk/src/modules/editors/resources/javascript/insertLink.js
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/editors/resources/javascript/insertLink.js?view=auto&rev=558544
==============================================================================
--- lenya/trunk/src/modules/editors/resources/javascript/insertLink.js (added)
+++ lenya/trunk/src/modules/editors/resources/javascript/insertLink.js Sun Jul 22 13:45:10 2007
@@ -0,0 +1,75 @@
+/*
+  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.
+*/
+
+
+/* this file implements the generic part of an LenyaInsertLink usecase. for the editor-specific glue,
+   a callback function must be provided by the editor module. */
+
+function LenyaInvokeInsertLink() { 
+  // prepare linkData object (this is part of the callback API!):
+  var linkData = {
+    'href':  document.forms["LenyaInsertLink"].url.value,
+    'text':  document.forms["LenyaInsertLink"].text.value,
+    'title': document.forms["LenyaInsertLink"].title.value,
+    'name':  "",
+    'lang':  ""
+  };
+
+  // invoke callback:
+  LenyaInsertLink(linkData);
+}
+
+/**
+  * if the user selected some text in the editor, use it to fill the "text" field.
+  */
+function LenyaSetText() { 
+    var selectionContent = window.opener.getSelection().getEditableRange().toString(); 
+    if (selectionContent.length != 0) { 
+        document.forms["LenyaInsertLink"].text.value = selectionContent;
+    } 
+    focus(); 
+}
+
+function LenyaLinkTree(doc, treeElement) {
+    this.doc = doc;
+    this.treeElement = treeElement;
+    this.selected = null;
+}
+
+/**
+  * FIXME: CHOSEN_LANGUAGE should not be a global variable!
+  * a callback used by the LenyaLinkTree object.
+  */
+function LenyaSetLink(uuid) {
+    var language = CHOSEN_LANGUAGE;
+    document.forms["LenyaInsertLink"].url.value = "lenya-document:" + uuid + ",lang=" + language;
+}
+
+function LenyaBuildTree() {
+    var placeholder = document.getElementById('tree');
+    var tree = new LenyaLinkTree(document, placeholder);
+    tree.init(PUBLICATION_ID);
+    tree.render();
+    tree.loadInitialTree(AREA, DOCUMENT_ID);
+}
+
+window.onload = LenyaSetText;
+
+LenyaLinkTree.prototype = new NavTree;
+LenyaLinkTree.prototype.handleItemClick = function(item, event) {
+    LenyaSetLink(item.uuid);
+}

Modified: lenya/trunk/src/modules/editors/sitemap.xmap
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/editors/sitemap.xmap?view=diff&rev=558544&r1=558543&r2=558544
==============================================================================
--- lenya/trunk/src/modules/editors/sitemap.xmap (original)
+++ lenya/trunk/src/modules/editors/sitemap.xmap Sun Jul 22 13:45:10 2007
@@ -19,9 +19,22 @@
 <!-- $Id$ -->
 
 <map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
-  <!-- =========================== Components ================================ -->
-  <map:components/>
-  <!-- =========================== Pipelines ================================ -->  
+ 
+  <map:resources>
+ 
+   <map:resource name="style-cms-page">
+      <map:transform type="i18n">      
+        <map:parameter name="locale" value="{request:locale}"/>
+      </map:transform>    
+      <map:transform src="fallback://lenya/xslt/util/page2xhtml.xsl">
+        <map:parameter name="publicationid" value="{page-envelope:publication-id}"/>
+      </map:transform>
+      <map:transform src="context://lenya/xslt/util/strip_namespaces.xsl"/>
+      <map:transform type="proxy"/>
+    </map:resource>
+
+  </map:resources>
+
   <map:pipelines>
     
     <map:component-configurations>
@@ -72,7 +85,29 @@
         <map:transform type="url2uuid"/>
         <map:serialize type="xml"/>
       </map:match>
-      
+ 
+     <!-- this is a usecase view (see config/cocoon-xconf/usecase-insertLink.xconf) -->
+      <map:match pattern="editors.insertLink">
+        <map:generate src="context://lenya/content/util/empty.xml"/>
+        <map:transform src="fallback://lenya/modules/editors/xslt/insertLink.xsl">
+          <map:parameter name="publicationId" value="{page-envelope:publication-id}"/>
+          <map:parameter name="area" value="authoring"/>
+          <map:parameter name="areaBasePath"
+             value="{proxy:/{page-envelope:publication-id}/{page-envelope:area}}"/>
+          <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="documentId" value="{page-envelope:document-uuid}"/>
+          <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:parameter name="editorModule" value="{request-param:lenya.editorModule}"/>
+        </map:transform>
+        <map:call resource="style-cms-page"/>
+        <map:serialize />
+      </map:match>
+
+
       <map:match pattern="**">
         <map:read src="lenya-document:/{page-envelope:document-uuid}"/>
       </map:match>
@@ -81,4 +116,4 @@
     
   </map:pipelines>
 
-</map:sitemap>
+</map:sitemap>
\ No newline at end of file

Copied: lenya/trunk/src/modules/editors/xslt/insertLink.xsl (from r556063, lenya/trunk/src/modules/tinymce/xslt/link.xsl)
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/editors/xslt/insertLink.xsl?view=diff&rev=558544&p1=lenya/trunk/src/modules/tinymce/xslt/link.xsl&r1=556063&p2=lenya/trunk/src/modules/editors/xslt/insertLink.xsl&r2=558544
==============================================================================
--- lenya/trunk/src/modules/tinymce/xslt/link.xsl (original)
+++ lenya/trunk/src/modules/editors/xslt/insertLink.xsl Sun Jul 22 13:45:10 2007
@@ -17,7 +17,7 @@
 -->
 
 <!--
-  $Id: link.xsl 473861 2006-11-12 03:51:14Z gregor $
+  $Id: link.xsl 555656 2007-07-12 15:17:47Z nettings $
 -->
 
 <xsl:stylesheet version="1.0"
@@ -29,160 +29,142 @@
   xmlns:usecase="http://apache.org/cocoon/lenya/usecase/1.0"     
   >
   
-  <xsl:param name="contextprefix"/>
-  <xsl:param name="publicationid"/>
+  <xsl:param name="publicationId"/>
   <xsl:param name="area"/>
   <xsl:param name="tab"/>
-  <xsl:param name="documentid"/>
-  <xsl:param name="documentextension"/>
-  <xsl:param name="documenturl"/>
+  <xsl:param name="path"/>
+  <xsl:param name="documentExtension"/>
   <xsl:param name="languages"/>
-  <xsl:param name="chosenlanguage"/>
-  <xsl:param name="defaultlanguage"/>
-  
-  <xsl:variable name="extension"><xsl:if test="$documentextension != ''">.</xsl:if><xsl:value-of select="$documentextension"/></xsl:variable>
+  <xsl:param name="chosenLanguage"/>
+  <xsl:param name="defaultLanguage"/>
+  <xsl:param name="areaBasePath"/>
+  <xsl:param name="editorModule" select="editors"/>
+  
+  <xsl:variable name="extension">
+    <xsl:if test="$documentExtension != ''">
+      <xsl:text>.</xsl:text>
+    </xsl:if>
+    <xsl:value-of select="$documentExtension"/>
+  </xsl:variable>
   
   <xsl:template match="/">
     <page:page>
       <page:title>Insert Link</page:title>
       <page:body>
-        <script type="text/javascript" src="{$contextprefix}/modules/sitetree/javascript/tree.js">&#160;</script>
-        <script type="text/javascript" src="{$contextprefix}/modules/sitetree/javascript/lenyatree.js">&#160;</script>
-        <script type="text/javascript" src="{$contextprefix}/modules/sitetree/javascript/navtree.js">&#160;</script>
-        <script type="text/javascript" src="{$contextprefix}/modules/tinymce/javascript/insertLink.js">&#160;</script>
+        <script type="text/javascript" src="/modules/sitetree/javascript/tree.js">&#160;</script>
+        <script type="text/javascript" src="/modules/sitetree/javascript/lenyatree.js">&#160;</script>
+        <script type="text/javascript" src="/modules/sitetree/javascript/navtree.js">&#160;</script>
+        <script type="text/javascript" src="/modules/editors/javascript/insertLink.js">&#160;</script>
+        <script type="text/javascript" src="/modules/{$editorModule}/javascript/editorCallbacks.js">&#160;</script>
         <script type="text/javascript" >
           AREA = "<xsl:value-of select="$area"/>";
-          DOCUMENT_ID = "<xsl:value-of select="$documentid"/>";
-          CONTEXT_PREFIX = "<xsl:value-of select="$contextprefix"/>";
-          PUBLICATION_ID = "<xsl:value-of select="$publicationid"/>";
-          CHOSEN_LANGUAGE = "<xsl:value-of select="$chosenlanguage"/>";
-          DEFAULT_LANGUAGE = "<xsl:value-of select="$defaultlanguage"/>";
-          IMAGE_PATH = "<xsl:value-of select="$contextprefix"/>/lenya/images/tree/";
+          DOCUMENT_ID = "<xsl:value-of select="$path"/>";
+          PUBLICATION_ID = "<xsl:value-of select="$publicationId"/>";
+          CHOSEN_LANGUAGE = "<xsl:value-of select="$chosenLanguage"/>";
+          DEFAULT_LANGUAGE = "<xsl:value-of select="$defaultLanguage"/>";
+          IMAGE_PATH = "/lenya/images/tree/";
           CUT_DOCUMENT_ID = '';
-          ALL_AREAS = "authoring"
-          PIPELINE_PATH = '/authoring/sitetree-fragment.xml'
+          ALL_AREAS = "authoring";
+          PIPELINE_PATH = '/sitetree-fragment.xml';
+          AREA_BASE_PATH = "<xsl:value-of select="$areaBasePath"/>";
         </script>
-        <table border="0" cellpadding="0" cellspacing="0" width="100%">
-          <tr>
-            <td valign="top" width="20%">
-              <div id="lenya-info-treecanvas">
-                <!-- Build the tree. -->
-                <table border="0" cellpadding="0" cellspacing="0">
-                  <tr>
-                    <xsl:call-template name="languagetabs">
-                      <xsl:with-param name="tablanguages">
-                        <xsl:value-of select="$languages"/>
-                      </xsl:with-param>
-                    </xsl:call-template>
-                  </tr>
-                </table>
-                
-                <div id="lenya-info-tree">
-                  <div id="tree">
-                    <script type="text/javascript">
-                      buildTree();
-                    </script>
-                  </div>
-                </div>
-              </div>
-            </td>
-            <td>
-              <form action="" name="link" id="link" onsubmit="insertLink()">
-                <table class="lenya-table-noborder">
-                  <tr>
-                    <td colspan="2" class="lenya-form-caption">You can either click on a node in the tree for an internal link or enter a link in the URL field. </td>
-                  </tr>
-                  <tr>
-                    <td colspan="2">&#160;</td>
-                  </tr>
-                  <tr>
-                    <td class="lenya-form-caption"><i18n:text>URL</i18n:text>:</td>
-                    <td>
-                      <input class="lenya-form-element" type="text" name="url"/>
-                    </td>
-                  </tr>
-                  <tr>
-                    <td class="lenya-form-caption"><i18n:text>Title</i18n:text>:</td>
-                    <td>
-                      <input class="lenya-form-element" type="text" name="title"/>
-                    </td>
-                  </tr>
-                  <tr>
-                    <td class="lenya-form-caption">Link text:</td>
-                    <td>
-                      <input class="lenya-form-element" 
-                        type="text" 
-                        name="text"/>
-                    </td>
-                  </tr>
-                  <tr>
-                    <td colspan="2">&#160;</td>
-                  </tr>
-                  <tr>
-                    <td/>
-                    <td> <input type="submit" 
-                      value="Insert" name="input-insert"/>
-                    </td>
-                  </tr>
-                </table>
-              </form>   
-            </td>
-          </tr></table>
+        
+        <div id="lenya-info-treecanvas" style="width: 30%">
+          <div class="lenya-tabs">
+            <xsl:call-template name="languageTabs">
+              <xsl:with-param name="languages" select="$languages"/>
+            </xsl:call-template>
+          </div>
+          <div id="lenya-info-tree">
+            <div id="tree">
+              <script type="text/javascript">
+                LenyaBuildTree();
+              </script>
+            </div>
+          </div>
+        </div>
+        
+        <form action="" name="LenyaInsertLink" id="LenyaInsertLink" onsubmit="LenyaInvokeInsertLink()">
+          <table class="lenya-table-noborder">
+            <tr>
+              <td colspan="2" class="lenya-form-caption">You can either click on a node in the tree for an internal link or enter a link in the URL field. </td>
+            </tr>
+            <tr>
+              <td colspan="2">&#160;</td>
+            </tr>
+            <tr>
+              <td class="lenya-form-caption"><i18n:text>URL</i18n:text>:</td>
+              <td><input class="lenya-form-element" type="text" name="url"/></td>
+            </tr>
+            <tr>
+              <td class="lenya-form-caption"><i18n:text>Title</i18n:text>:</td>
+              <td><input class="lenya-form-element" type="text" name="title"/></td>
+            </tr>
+            <tr>
+              <td class="lenya-form-caption">Link text:</td>
+              <td><input class="lenya-form-element" type="text" name="text"/></td>
+            </tr>
+            <tr>
+              <td colspan="2">&#160;</td>
+            </tr>
+            <tr>
+              <td/>
+              <td><input type="submit" value="Insert" name="input-insert"/></td>
+            </tr>
+          </table>
+        </form>
+              
       </page:body>
     </page:page>
   </xsl:template>
   
-  
-  <xsl:template name="selecttab">
-    <xsl:text>?lenya.usecase=</xsl:text>
-    <xsl:choose>
-      <xsl:when test="$tab"><xsl:value-of select="$tab"/></xsl:when>
-      <xsl:otherwise>tinymce</xsl:otherwise>
-    </xsl:choose>
-    <xsl:text>&amp;lenya.step=link-show</xsl:text>
-  </xsl:template>
-  
-  
-  <xsl:template name="languagetabs">
-    <xsl:param name="tablanguages"/>
+  <xsl:template name="languageTabs">
+    <xsl:param name="languages"/>
     <xsl:choose>
-      <xsl:when test="not(contains($tablanguages,','))">
-        <xsl:call-template name="languagetab">
-          <xsl:with-param name="tablanguage">
-            <xsl:value-of select="$tablanguages"/>
+      <xsl:when test="not(contains($languages,','))">
+        <xsl:call-template name="languageTab">
+          <xsl:with-param name="language">
+            <xsl:value-of select="$languages"/>
           </xsl:with-param>
         </xsl:call-template>
       </xsl:when>
       <xsl:otherwise>
-        <xsl:variable name="head" select="substring-before($tablanguages,',')" />
-        <xsl:variable name="tail" select="substring-after($tablanguages,',')" />
-        <xsl:call-template name="languagetab">
-          <xsl:with-param name="tablanguage" select="$head"/>
+        <xsl:variable name="head" select="substring-before($languages,',')" />
+        <xsl:variable name="tail" select="substring-after($languages,',')" />
+        <xsl:call-template name="languageTab">
+          <xsl:with-param name="language" select="$head"/>
         </xsl:call-template>
-        <xsl:call-template name="languagetabs">
-          <xsl:with-param name="tablanguages" select="$tail"/>
+        <xsl:call-template name="languageTabs">
+          <xsl:with-param name="languages" select="$tail"/>
         </xsl:call-template>
       </xsl:otherwise>
     </xsl:choose>
   </xsl:template>
-  
-  
-  <xsl:template name="languagetab">
-    <xsl:param name="tablanguage"/>
-    <td>
-      <a id="{$tablanguage}">
-        <xsl:call-template name="activate">
-          <xsl:with-param name="tablanguage" select="$tablanguage"/>
-        </xsl:call-template>
-      </a>
-    </td>
-  </xsl:template>
-  
-  
-  <xsl:template name="activate">
-    <xsl:param name="tablanguage"/>
-    <xsl:attribute name="href"><xsl:value-of select="$contextprefix"/>/<xsl:value-of select="$publicationid"/>/<xsl:value-of select="$area"/><xsl:value-of select="$documentid"/>_<xsl:value-of select="$tablanguage"/><xsl:value-of select="$extension"/>?lenya.module=tinymce&amp;lenya.step=link-show</xsl:attribute>
-    <xsl:attribute name="class">lenya-tablink<xsl:choose><xsl:when test="$chosenlanguage = $tablanguage">-active</xsl:when><xsl:otherwise/></xsl:choose></xsl:attribute><xsl:value-of select="$tablanguage"/>
+
+  <xsl:template name="languageTab">
+    <xsl:param name="language"/>
+    <a id="{$language}">
+      <xsl:attribute name="href">
+        <xsl:text>/</xsl:text>
+        <xsl:value-of select="$publicationId"/>
+        <xsl:text>/</xsl:text>
+        <xsl:value-of select="$area"/>
+        <xsl:value-of select="$path"/>
+        <xsl:text>_</xsl:text>
+        <xsl:value-of select="$language"/>
+        <xsl:value-of select="$extension"/>
+        <xsl:text>?lenya.usecase=editors.insertLink</xsl:text>
+        <xsl:text>&amp;lenya.editorModule=</xsl:text>
+        <xsl:value-of select="$editorModule"/>
+      </xsl:attribute>
+      <xsl:attribute name="class">
+        <xsl:text>lenya-tablink</xsl:text>
+        <xsl:if test="$chosenLanguage = $language">
+          <xsl:text>-active</xsl:text>
+        </xsl:if>
+      </xsl:attribute>
+      <xsl:value-of select="$language"/>
+    </a>
   </xsl:template>
-  
+
 </xsl:stylesheet> 



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org


Re: JX templates vs. pipelines+XSLT

Posted by Andreas Hartmann <an...@apache.org>.
Hi Jörn,

Jörn Nettingsmeier schrieb:

[...]

>> <jx:set var="doc" value="${usecase.getParameter('document')}"/>
>>
>> (provided the handler belongs to a DocumentUsecase subclass)
> 
> ok, this was obstacle no. 1: i figured since i was not accessing
> documents at all, i should be subclassing AbstractUsecase, which does
> not provide all those neat functions. point taken.

OK, the docs aren't clear enough there. The DocumentUsecase is
meant to simplify accessing the currently managed document, it's
not about the concept of accessing documents.

[...]

>> AREA_BASE_PATH = '<proxy:url href="/${publicationId}/${area}"/>';
>>
>> (see modules/sitemanagement/usecases/tab/sitetree.jx, I'll add the
>> corresponding documentation to the usecase framework docs asap)
> 
> deep and utter magic. where did you pull this one from?
> i looked into sitetree.jx, but i still haven't figured what's going on.
> are those tags being replaced by a transformation before the
> jxtransformer kicks in?

Yes - this was the easiest way to implement this functionality, since
the ProxyTransformer already existed and can transform arbitrary
elements from arbitrary namespaces (see modules/usecase/usecase.xmap):

  <map:transformer name="usecase-proxy"
    logger="lenya.sitemap.transformer.proxy"
    src="org.apache.lenya.cms.cocoon.transformation.ProxyTransformer">

  <transform namespace="http://apache.org/lenya/proxy/1.0"
             element="url"
             attribute="href"/>

  </map:transformer>

IMO the approach is not that bad from an implementation point of view,
the major drawback is indeed that the existence of this functionality
not obvious. It should be easier to call the code within a JX template
without using specific XML elements.


>>> do you still think we had better use jxtemplate?
>>
>> IMO yes :)
> 
> point taken. i'll try and re-implement the stuff as a (shudder!)
> jxtemplate....

Great - good luck :)
Thanks for giving it a try!

-- Andreas


-- 
Andreas Hartmann, CTO
BeCompany GmbH
http://www.becompany.ch


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org


Re: JX templates vs. pipelines+XSLT

Posted by Jörn Nettingsmeier <ne...@apache.org>.
hi andreas!

Andreas Hartmann wrote:
> Hi Jörn,
> 
> Joern Nettingsmeier schrieb:
>> well, it's a matter of taste, actually. i like to implement usecase
>> views as cocoon pipelines, because i know how to get at stuff using
>> input modules, and i find jxtemplates nasty...
> 
> I understand that it's a matter of taste, but if we continue using
> both approaches we'll probably confuse our users. I prefer JX templates
> mainly because I can access Java objects directly, and I have to change
> just one place because the pipeline structures are already provided by
> the usecase module.
> 
> WDTOT?

>>> Would you mind giving a short description of what kind of information
>>> you were missing?
>> here is the information i needed to make the existing tree code work:
> 
> Some examples how to obtain this information in a JX template:
> 
>>>> +     <!-- this is a usecase view (see
>>>> config/cocoon-xconf/usecase-insertLink.xconf) -->
>>>> +      <map:match pattern="editors.insertLink">
>>>> +        <map:generate src="context://lenya/content/util/empty.xml"/>
>>>> +        <map:transform
>>>> src="fallback://lenya/modules/editors/xslt/insertLink.xsl">
> 
> <jx:set var="doc" value="${usecase.getParameter('document')}"/>
> 
> (provided the handler belongs to a DocumentUsecase subclass)

ok, this was obstacle no. 1: i figured since i was not accessing 
documents at all, i should be subclassing AbstractUsecase, which does 
not provide all those neat functions. point taken.

>>>> +          <map:parameter name="publicationId"
>>>> value="{page-envelope:publication-id}"/>
> 
> ${document.getPublication().getId()}
> 
>>>> +          <map:parameter name="area" value="authoring"/>
> 
> ${document.getArea()}
> 
>>>> +          <map:parameter name="areaBasePath"
>>>> +            
>>>> value="{proxy:/{page-envelope:publication-id}/{page-envelope:area}}"/>
> 
> AREA_BASE_PATH = '<proxy:url href="/${publicationId}/${area}"/>';
> 
> (see modules/sitemanagement/usecases/tab/sitetree.jx, I'll add the
> corresponding documentation to the usecase framework docs asap)

deep and utter magic. where did you pull this one from?
i looked into sitetree.jx, but i still haven't figured what's going on. 
are those tags being replaced by a transformation before the 
jxtransformer kicks in?

anyway, it's quite atrocious :-D

>>>> +          <map:parameter name="tab" value="en"/>
> 
> IMO this shouldn't be hard-coded, but rather set to the default
> language ...

sorry, yes. that's a leftover from the old code... will fix.

>>>> +          <map:parameter name="languages"
>>>> value="{page-envelope:publication-languages-csv}"/>
> 
> ${document.getPublication().getLanguages()}

ok, that's probably nicer than to dissect a csv. i'm assuming i can 
jx:forEach over the return value directly...

>>>> +          <map:parameter name="editorModule"
>>>> value="{request-param:lenya.editorModule}"/>
> 
> ${usecase.getParameter('lenya.editorModule')}
> 
>>>> +        </map:transform>
>>>> +        <map:call resource="style-cms-page"/>
>>>> +        <map:serialize />
>>>> +      </map:match>
>> i did not mean to imply it's not obtainable via java, just that i could
>> not figure out how in a reasonable timeframe.
> 
> I understand this for the areaBasePath, but for the other information -
> is it a matter of re-structuring the documentation? Or would a page on
> JX templates in Lenya help?

as i said, i started from AbstractUsecase... that was a very bad idea 
indeed.

>> plus in this case, we don't really cause server-side effects, hence it
>> seems overkill to implement a special usecase handler just to obtain
>> some view-related data. my approach uses the dummy handler instead.
> 
> You can just use the DocumentUsecase to get the information described
> above.

ah well :)

>> do you still think we had better use jxtemplate?
> 
> IMO yes :)

point taken. i'll try and re-implement the stuff as a (shudder!) 
jxtemplate....




-- 
Jörn Nettingsmeier

Kurt is up in heaven now.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org


JX templates vs. pipelines+XSLT (was: svn commit: r558544 - in /lenya/trunk/src/modules/editors: config/cocoon-xconf/usecase-insertLink.xconf config/module.xml resources/javascript/insertLink.js sitemap.xmap xslt/ xslt/insertLink.xsl)

Posted by Andreas Hartmann <an...@apache.org>.
Hi Jörn,

Joern Nettingsmeier schrieb:
> Andreas Hartmann wrote:

[...]

>>> introduced generic editors.insertLink usecase implementation.
>>> the view is created by a cocoon pipeline, not a jxtemplate, because the
>>> necessary data is more readily available as input modules than via the
>>> java api.
>>
>> that's an issue that should definitely be addressed immediately.
>> We can't declare JX templates the recommended way of implementing
>> usecase views if they don't provide access to information which
>> is necessary for rendering.
> 
> well, it's a matter of taste, actually. i like to implement usecase
> views as cocoon pipelines, because i know how to get at stuff using
> input modules, and i find jxtemplates nasty...

I understand that it's a matter of taste, but if we continue using
both approaches we'll probably confuse our users. I prefer JX templates
mainly because I can access Java objects directly, and I have to change
just one place because the pipeline structures are already provided by
the usecase module.

WDTOT?

>> Would you mind giving a short description of what kind of information
>> you were missing?
> 
> here is the information i needed to make the existing tree code work:

Some examples how to obtain this information in a JX template:

>>> +     <!-- this is a usecase view (see
>>> config/cocoon-xconf/usecase-insertLink.xconf) -->
>>> +      <map:match pattern="editors.insertLink">
>>> +        <map:generate src="context://lenya/content/util/empty.xml"/>
>>> +        <map:transform
>>> src="fallback://lenya/modules/editors/xslt/insertLink.xsl">

<jx:set var="doc" value="${usecase.getParameter('document')}"/>

(provided the handler belongs to a DocumentUsecase subclass)

>>> +          <map:parameter name="publicationId"
>>> value="{page-envelope:publication-id}"/>

${document.getPublication().getId()}

>>> +          <map:parameter name="area" value="authoring"/>

${document.getArea()}

>>> +          <map:parameter name="areaBasePath"
>>> +            
>>> value="{proxy:/{page-envelope:publication-id}/{page-envelope:area}}"/>

AREA_BASE_PATH = '<proxy:url href="/${publicationId}/${area}"/>';

(see modules/sitemanagement/usecases/tab/sitetree.jx, I'll add the
corresponding documentation to the usecase framework docs asap)


>>> +          <map:parameter name="tab" value="en"/>

IMO this shouldn't be hard-coded, but rather set to the default
language ...

>>> +          <map:parameter name="chosenLanguage"
>>> value="{page-envelope:document-language}"/>

${document.getLanguage()}

>>> +          <map:parameter name="path"
>>> value="{page-envelope:document-path}"/>

${document.getPath()}

>>> +          <map:parameter name="documentId"
>>> value="{page-envelope:document-uuid}"/>

${document.getUUID()}

>>> +          <map:parameter name="documentExtension"
>>> value="{page-envelope:document-extension}"/>

${document.getSourceExtension()}

>>> +          <map:parameter name="defaultLanguage"
>>> value="{page-envelope:default-language}"/>

${document.getPublication().getDefaultLanguage()}

>>> +          <map:parameter name="languages"
>>> value="{page-envelope:publication-languages-csv}"/>

${document.getPublication().getLanguages()}

>>> +          <map:parameter name="editorModule"
>>> value="{request-param:lenya.editorModule}"/>

${usecase.getParameter('lenya.editorModule')}

>>> +        </map:transform>
>>> +        <map:call resource="style-cms-page"/>
>>> +        <map:serialize />
>>> +      </map:match>
> 
> i did not mean to imply it's not obtainable via java, just that i could
> not figure out how in a reasonable timeframe.

I understand this for the areaBasePath, but for the other information -
is it a matter of re-structuring the documentation? Or would a page on
JX templates in Lenya help?


> plus in this case, we don't really cause server-side effects, hence it
> seems overkill to implement a special usecase handler just to obtain
> some view-related data. my approach uses the dummy handler instead.

You can just use the DocumentUsecase to get the information described
above.

> do you still think we had better use jxtemplate?

IMO yes :)

-- Andreas


> comments are appreciated.


-- 
Andreas Hartmann, CTO
BeCompany GmbH
http://www.becompany.ch


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org


Re: svn commit: r558544 - in /lenya/trunk/src/modules/editors: config/cocoon-xconf/usecase-insertLink.xconf config/module.xml resources/javascript/insertLink.js sitemap.xmap xslt/ xslt/insertLink.xsl

Posted by Joern Nettingsmeier <ne...@folkwang-hochschule.de>.
Andreas Hartmann wrote:
> Hi Jörn,
> 
> nettings@apache.org schrieb:
>> Author: nettings
>> Date: Sun Jul 22 13:45:10 2007
>> New Revision: 558544
>>
>> URL: http://svn.apache.org/viewvc?view=rev&rev=558544
>> Log:
>> introduced generic editors.insertLink usecase implementation.
>> the view is created by a cocoon pipeline, not a jxtemplate, because the
>> necessary data is more readily available as input modules than via the
>> java api.
> 
> that's an issue that should definitely be addressed immediately.
> We can't declare JX templates the recommended way of implementing
> usecase views if they don't provide access to information which
> is necessary for rendering.

well, it's a matter of taste, actually. i like to implement usecase 
views as cocoon pipelines, because i know how to get at stuff using 
input modules, and i find jxtemplates nasty...

> Would you mind giving a short description of what kind of information
> you were missing?

here is the information i needed to make the existing tree code work:

>> +     <!-- this is a usecase view (see config/cocoon-xconf/usecase-insertLink.xconf) -->
>> +      <map:match pattern="editors.insertLink">
>> +        <map:generate src="context://lenya/content/util/empty.xml"/>
>> +        <map:transform src="fallback://lenya/modules/editors/xslt/insertLink.xsl">
>> +          <map:parameter name="publicationId" value="{page-envelope:publication-id}"/>
>> +          <map:parameter name="area" value="authoring"/>
>> +          <map:parameter name="areaBasePath"
>> +             value="{proxy:/{page-envelope:publication-id}/{page-envelope:area}}"/>
>> +          <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="documentId" value="{page-envelope:document-uuid}"/>
>> +          <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:parameter name="editorModule" value="{request-param:lenya.editorModule}"/>
>> +        </map:transform>
>> +        <map:call resource="style-cms-page"/>
>> +        <map:serialize />
>> +      </map:match>

i did not mean to imply it's not obtainable via java, just that i could 
not figure out how in a reasonable timeframe.

plus in this case, we don't really cause server-side effects, hence it 
seems overkill to implement a special usecase handler just to obtain 
some view-related data. my approach uses the dummy handler instead.

do you still think we had better use jxtemplate? comments are appreciated.

jörn


-- 
jörn nettingsmeier

home://germany/45128 essen/lortzingstr. 11/
http://spunk.dnsalias.org
phone://+49/201/491621

Kurt is up in Heaven now.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org


Re: svn commit: r558544 - in /lenya/trunk/src/modules/editors: config/cocoon-xconf/usecase-insertLink.xconf config/module.xml resources/javascript/insertLink.js sitemap.xmap xslt/ xslt/insertLink.xsl

Posted by Andreas Hartmann <an...@apache.org>.
Hi Jörn,

nettings@apache.org schrieb:
> Author: nettings
> Date: Sun Jul 22 13:45:10 2007
> New Revision: 558544
> 
> URL: http://svn.apache.org/viewvc?view=rev&rev=558544
> Log:
> introduced generic editors.insertLink usecase implementation.
> the view is created by a cocoon pipeline, not a jxtemplate, because the
> necessary data is more readily available as input modules than via the
> java api.

that's an issue that should definitely be addressed immediately.
We can't declare JX templates the recommended way of implementing
usecase views if they don't provide access to information which
is necessary for rendering.

Would you mind giving a short description of what kind of information
you were missing?

TIA!

-- Andreas


> the next commit will migrate tinymce to use this implementation.
> 
> Added:
>     lenya/trunk/src/modules/editors/config/cocoon-xconf/usecase-insertLink.xconf
>       - copied, changed from r556063, lenya/trunk/src/modules/tinymce/config/cocoon-xconf/usecase-tinymce-edit.xconf
>     lenya/trunk/src/modules/editors/resources/javascript/insertLink.js
>     lenya/trunk/src/modules/editors/xslt/
>     lenya/trunk/src/modules/editors/xslt/insertLink.xsl
>       - copied, changed from r556063, lenya/trunk/src/modules/tinymce/xslt/link.xsl
> Modified:
>     lenya/trunk/src/modules/editors/config/module.xml
>     lenya/trunk/src/modules/editors/sitemap.xmap
> 
> Copied: lenya/trunk/src/modules/editors/config/cocoon-xconf/usecase-insertLink.xconf (from r556063, lenya/trunk/src/modules/tinymce/config/cocoon-xconf/usecase-tinymce-edit.xconf)
> URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/editors/config/cocoon-xconf/usecase-insertLink.xconf?view=diff&rev=558544&p1=lenya/trunk/src/modules/tinymce/config/cocoon-xconf/usecase-tinymce-edit.xconf&r1=556063&p2=lenya/trunk/src/modules/editors/config/cocoon-xconf/usecase-insertLink.xconf&r2=558544
> ==============================================================================
> --- lenya/trunk/src/modules/tinymce/config/cocoon-xconf/usecase-tinymce-edit.xconf (original)
> +++ lenya/trunk/src/modules/editors/config/cocoon-xconf/usecase-insertLink.xconf Sun Jul 22 13:45:10 2007
> @@ -16,12 +16,11 @@
>    limitations under the License.
>  -->
>  
> -<xconf xpath="/cocoon/usecases" unless="/cocoon/usecases/component-instance[@name = 'tinymce.edit']">
> +<xconf xpath="/cocoon/usecases" unless="/cocoon/usecases/component-instance[@name = 'editors.insertLink']">
>  
> -  <component-instance name="tinymce.edit" logger="lenya.publication"
> -                      class="org.apache.lenya.cms.editors.tinymce.TinyMce">
> -    <transaction policy="pessimistic"/>
> -    <view uri="cocoon://modules/tinymce/tinymce.edit" menu="false"/>
> +  <component-instance name="editors.insertLink" logger="lenya.publication"
> +                      class="org.apache.lenya.cms.usecase.DummyUsecase">
> +    <view uri="cocoon://modules/editors/editors.insertLink" menu="false"/>
>    </component-instance>
>      
>  </xconf>
> 
> Modified: lenya/trunk/src/modules/editors/config/module.xml
> URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/editors/config/module.xml?view=diff&rev=558544&r1=558543&r2=558544
> ==============================================================================
> --- lenya/trunk/src/modules/editors/config/module.xml (original)
> +++ lenya/trunk/src/modules/editors/config/module.xml Sun Jul 22 13:45:10 2007
> @@ -25,8 +25,9 @@
>    <depends module="org.apache.lenya.modules.sitemanagement"/>
>    <depends module="org.apache.lenya.modules.linking"/>
>    <package>org.apache.lenya.modules</package>
> -  <version>0.1-dev</version>
> +  <version>0.2-dev</version>
>    <name>Editors</name>
>    <lenya-version>@lenya.version@</lenya-version>
> -  <description>Editor base and support classes</description>
> +  <description>Editor base and support classes, Forms and Oneform editor
> +  implementations, generic insertLink usecase implementation</description>
>  </module>
> 
> Added: lenya/trunk/src/modules/editors/resources/javascript/insertLink.js
> URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/editors/resources/javascript/insertLink.js?view=auto&rev=558544
> ==============================================================================
> --- lenya/trunk/src/modules/editors/resources/javascript/insertLink.js (added)
> +++ lenya/trunk/src/modules/editors/resources/javascript/insertLink.js Sun Jul 22 13:45:10 2007
> @@ -0,0 +1,75 @@
> +/*
> +  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.
> +*/
> +
> +
> +/* this file implements the generic part of an LenyaInsertLink usecase. for the editor-specific glue,
> +   a callback function must be provided by the editor module. */
> +
> +function LenyaInvokeInsertLink() { 
> +  // prepare linkData object (this is part of the callback API!):
> +  var linkData = {
> +    'href':  document.forms["LenyaInsertLink"].url.value,
> +    'text':  document.forms["LenyaInsertLink"].text.value,
> +    'title': document.forms["LenyaInsertLink"].title.value,
> +    'name':  "",
> +    'lang':  ""
> +  };
> +
> +  // invoke callback:
> +  LenyaInsertLink(linkData);
> +}
> +
> +/**
> +  * if the user selected some text in the editor, use it to fill the "text" field.
> +  */
> +function LenyaSetText() { 
> +    var selectionContent = window.opener.getSelection().getEditableRange().toString(); 
> +    if (selectionContent.length != 0) { 
> +        document.forms["LenyaInsertLink"].text.value = selectionContent;
> +    } 
> +    focus(); 
> +}
> +
> +function LenyaLinkTree(doc, treeElement) {
> +    this.doc = doc;
> +    this.treeElement = treeElement;
> +    this.selected = null;
> +}
> +
> +/**
> +  * FIXME: CHOSEN_LANGUAGE should not be a global variable!
> +  * a callback used by the LenyaLinkTree object.
> +  */
> +function LenyaSetLink(uuid) {
> +    var language = CHOSEN_LANGUAGE;
> +    document.forms["LenyaInsertLink"].url.value = "lenya-document:" + uuid + ",lang=" + language;
> +}
> +
> +function LenyaBuildTree() {
> +    var placeholder = document.getElementById('tree');
> +    var tree = new LenyaLinkTree(document, placeholder);
> +    tree.init(PUBLICATION_ID);
> +    tree.render();
> +    tree.loadInitialTree(AREA, DOCUMENT_ID);
> +}
> +
> +window.onload = LenyaSetText;
> +
> +LenyaLinkTree.prototype = new NavTree;
> +LenyaLinkTree.prototype.handleItemClick = function(item, event) {
> +    LenyaSetLink(item.uuid);
> +}
> 
> Modified: lenya/trunk/src/modules/editors/sitemap.xmap
> URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/editors/sitemap.xmap?view=diff&rev=558544&r1=558543&r2=558544
> ==============================================================================
> --- lenya/trunk/src/modules/editors/sitemap.xmap (original)
> +++ lenya/trunk/src/modules/editors/sitemap.xmap Sun Jul 22 13:45:10 2007
> @@ -19,9 +19,22 @@
>  <!-- $Id$ -->
>  
>  <map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
> -  <!-- =========================== Components ================================ -->
> -  <map:components/>
> -  <!-- =========================== Pipelines ================================ -->  
> + 
> +  <map:resources>
> + 
> +   <map:resource name="style-cms-page">
> +      <map:transform type="i18n">      
> +        <map:parameter name="locale" value="{request:locale}"/>
> +      </map:transform>    
> +      <map:transform src="fallback://lenya/xslt/util/page2xhtml.xsl">
> +        <map:parameter name="publicationid" value="{page-envelope:publication-id}"/>
> +      </map:transform>
> +      <map:transform src="context://lenya/xslt/util/strip_namespaces.xsl"/>
> +      <map:transform type="proxy"/>
> +    </map:resource>
> +
> +  </map:resources>
> +
>    <map:pipelines>
>      
>      <map:component-configurations>
> @@ -72,7 +85,29 @@
>          <map:transform type="url2uuid"/>
>          <map:serialize type="xml"/>
>        </map:match>
> -      
> + 
> +     <!-- this is a usecase view (see config/cocoon-xconf/usecase-insertLink.xconf) -->
> +      <map:match pattern="editors.insertLink">
> +        <map:generate src="context://lenya/content/util/empty.xml"/>
> +        <map:transform src="fallback://lenya/modules/editors/xslt/insertLink.xsl">
> +          <map:parameter name="publicationId" value="{page-envelope:publication-id}"/>
> +          <map:parameter name="area" value="authoring"/>
> +          <map:parameter name="areaBasePath"
> +             value="{proxy:/{page-envelope:publication-id}/{page-envelope:area}}"/>
> +          <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="documentId" value="{page-envelope:document-uuid}"/>
> +          <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:parameter name="editorModule" value="{request-param:lenya.editorModule}"/>
> +        </map:transform>
> +        <map:call resource="style-cms-page"/>
> +        <map:serialize />
> +      </map:match>
> +
> +
>        <map:match pattern="**">
>          <map:read src="lenya-document:/{page-envelope:document-uuid}"/>
>        </map:match>
> @@ -81,4 +116,4 @@
>      
>    </map:pipelines>
>  
> -</map:sitemap>
> +</map:sitemap>
> \ No newline at end of file
> 
> Copied: lenya/trunk/src/modules/editors/xslt/insertLink.xsl (from r556063, lenya/trunk/src/modules/tinymce/xslt/link.xsl)
> URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/editors/xslt/insertLink.xsl?view=diff&rev=558544&p1=lenya/trunk/src/modules/tinymce/xslt/link.xsl&r1=556063&p2=lenya/trunk/src/modules/editors/xslt/insertLink.xsl&r2=558544
> ==============================================================================
> --- lenya/trunk/src/modules/tinymce/xslt/link.xsl (original)
> +++ lenya/trunk/src/modules/editors/xslt/insertLink.xsl Sun Jul 22 13:45:10 2007
> @@ -17,7 +17,7 @@
>  -->
>  
>  <!--
> -  $Id: link.xsl 473861 2006-11-12 03:51:14Z gregor $
> +  $Id: link.xsl 555656 2007-07-12 15:17:47Z nettings $
>  -->
>  
>  <xsl:stylesheet version="1.0"
> @@ -29,160 +29,142 @@
>    xmlns:usecase="http://apache.org/cocoon/lenya/usecase/1.0"     
>    >
>    
> -  <xsl:param name="contextprefix"/>
> -  <xsl:param name="publicationid"/>
> +  <xsl:param name="publicationId"/>
>    <xsl:param name="area"/>
>    <xsl:param name="tab"/>
> -  <xsl:param name="documentid"/>
> -  <xsl:param name="documentextension"/>
> -  <xsl:param name="documenturl"/>
> +  <xsl:param name="path"/>
> +  <xsl:param name="documentExtension"/>
>    <xsl:param name="languages"/>
> -  <xsl:param name="chosenlanguage"/>
> -  <xsl:param name="defaultlanguage"/>
> -  
> -  <xsl:variable name="extension"><xsl:if test="$documentextension != ''">.</xsl:if><xsl:value-of select="$documentextension"/></xsl:variable>
> +  <xsl:param name="chosenLanguage"/>
> +  <xsl:param name="defaultLanguage"/>
> +  <xsl:param name="areaBasePath"/>
> +  <xsl:param name="editorModule" select="editors"/>
> +  
> +  <xsl:variable name="extension">
> +    <xsl:if test="$documentExtension != ''">
> +      <xsl:text>.</xsl:text>
> +    </xsl:if>
> +    <xsl:value-of select="$documentExtension"/>
> +  </xsl:variable>
>    
>    <xsl:template match="/">
>      <page:page>
>        <page:title>Insert Link</page:title>
>        <page:body>
> -        <script type="text/javascript" src="{$contextprefix}/modules/sitetree/javascript/tree.js">&#160;</script>
> -        <script type="text/javascript" src="{$contextprefix}/modules/sitetree/javascript/lenyatree.js">&#160;</script>
> -        <script type="text/javascript" src="{$contextprefix}/modules/sitetree/javascript/navtree.js">&#160;</script>
> -        <script type="text/javascript" src="{$contextprefix}/modules/tinymce/javascript/insertLink.js">&#160;</script>
> +        <script type="text/javascript" src="/modules/sitetree/javascript/tree.js">&#160;</script>
> +        <script type="text/javascript" src="/modules/sitetree/javascript/lenyatree.js">&#160;</script>
> +        <script type="text/javascript" src="/modules/sitetree/javascript/navtree.js">&#160;</script>
> +        <script type="text/javascript" src="/modules/editors/javascript/insertLink.js">&#160;</script>
> +        <script type="text/javascript" src="/modules/{$editorModule}/javascript/editorCallbacks.js">&#160;</script>
>          <script type="text/javascript" >
>            AREA = "<xsl:value-of select="$area"/>";
> -          DOCUMENT_ID = "<xsl:value-of select="$documentid"/>";
> -          CONTEXT_PREFIX = "<xsl:value-of select="$contextprefix"/>";
> -          PUBLICATION_ID = "<xsl:value-of select="$publicationid"/>";
> -          CHOSEN_LANGUAGE = "<xsl:value-of select="$chosenlanguage"/>";
> -          DEFAULT_LANGUAGE = "<xsl:value-of select="$defaultlanguage"/>";
> -          IMAGE_PATH = "<xsl:value-of select="$contextprefix"/>/lenya/images/tree/";
> +          DOCUMENT_ID = "<xsl:value-of select="$path"/>";
> +          PUBLICATION_ID = "<xsl:value-of select="$publicationId"/>";
> +          CHOSEN_LANGUAGE = "<xsl:value-of select="$chosenLanguage"/>";
> +          DEFAULT_LANGUAGE = "<xsl:value-of select="$defaultLanguage"/>";
> +          IMAGE_PATH = "/lenya/images/tree/";
>            CUT_DOCUMENT_ID = '';
> -          ALL_AREAS = "authoring"
> -          PIPELINE_PATH = '/authoring/sitetree-fragment.xml'
> +          ALL_AREAS = "authoring";
> +          PIPELINE_PATH = '/sitetree-fragment.xml';
> +          AREA_BASE_PATH = "<xsl:value-of select="$areaBasePath"/>";
>          </script>
> -        <table border="0" cellpadding="0" cellspacing="0" width="100%">
> -          <tr>
> -            <td valign="top" width="20%">
> -              <div id="lenya-info-treecanvas">
> -                <!-- Build the tree. -->
> -                <table border="0" cellpadding="0" cellspacing="0">
> -                  <tr>
> -                    <xsl:call-template name="languagetabs">
> -                      <xsl:with-param name="tablanguages">
> -                        <xsl:value-of select="$languages"/>
> -                      </xsl:with-param>
> -                    </xsl:call-template>
> -                  </tr>
> -                </table>
> -                
> -                <div id="lenya-info-tree">
> -                  <div id="tree">
> -                    <script type="text/javascript">
> -                      buildTree();
> -                    </script>
> -                  </div>
> -                </div>
> -              </div>
> -            </td>
> -            <td>
> -              <form action="" name="link" id="link" onsubmit="insertLink()">
> -                <table class="lenya-table-noborder">
> -                  <tr>
> -                    <td colspan="2" class="lenya-form-caption">You can either click on a node in the tree for an internal link or enter a link in the URL field. </td>
> -                  </tr>
> -                  <tr>
> -                    <td colspan="2">&#160;</td>
> -                  </tr>
> -                  <tr>
> -                    <td class="lenya-form-caption"><i18n:text>URL</i18n:text>:</td>
> -                    <td>
> -                      <input class="lenya-form-element" type="text" name="url"/>
> -                    </td>
> -                  </tr>
> -                  <tr>
> -                    <td class="lenya-form-caption"><i18n:text>Title</i18n:text>:</td>
> -                    <td>
> -                      <input class="lenya-form-element" type="text" name="title"/>
> -                    </td>
> -                  </tr>
> -                  <tr>
> -                    <td class="lenya-form-caption">Link text:</td>
> -                    <td>
> -                      <input class="lenya-form-element" 
> -                        type="text" 
> -                        name="text"/>
> -                    </td>
> -                  </tr>
> -                  <tr>
> -                    <td colspan="2">&#160;</td>
> -                  </tr>
> -                  <tr>
> -                    <td/>
> -                    <td> <input type="submit" 
> -                      value="Insert" name="input-insert"/>
> -                    </td>
> -                  </tr>
> -                </table>
> -              </form>   
> -            </td>
> -          </tr></table>
> +        
> +        <div id="lenya-info-treecanvas" style="width: 30%">
> +          <div class="lenya-tabs">
> +            <xsl:call-template name="languageTabs">
> +              <xsl:with-param name="languages" select="$languages"/>
> +            </xsl:call-template>
> +          </div>
> +          <div id="lenya-info-tree">
> +            <div id="tree">
> +              <script type="text/javascript">
> +                LenyaBuildTree();
> +              </script>
> +            </div>
> +          </div>
> +        </div>
> +        
> +        <form action="" name="LenyaInsertLink" id="LenyaInsertLink" onsubmit="LenyaInvokeInsertLink()">
> +          <table class="lenya-table-noborder">
> +            <tr>
> +              <td colspan="2" class="lenya-form-caption">You can either click on a node in the tree for an internal link or enter a link in the URL field. </td>
> +            </tr>
> +            <tr>
> +              <td colspan="2">&#160;</td>
> +            </tr>
> +            <tr>
> +              <td class="lenya-form-caption"><i18n:text>URL</i18n:text>:</td>
> +              <td><input class="lenya-form-element" type="text" name="url"/></td>
> +            </tr>
> +            <tr>
> +              <td class="lenya-form-caption"><i18n:text>Title</i18n:text>:</td>
> +              <td><input class="lenya-form-element" type="text" name="title"/></td>
> +            </tr>
> +            <tr>
> +              <td class="lenya-form-caption">Link text:</td>
> +              <td><input class="lenya-form-element" type="text" name="text"/></td>
> +            </tr>
> +            <tr>
> +              <td colspan="2">&#160;</td>
> +            </tr>
> +            <tr>
> +              <td/>
> +              <td><input type="submit" value="Insert" name="input-insert"/></td>
> +            </tr>
> +          </table>
> +        </form>
> +              
>        </page:body>
>      </page:page>
>    </xsl:template>
>    
> -  
> -  <xsl:template name="selecttab">
> -    <xsl:text>?lenya.usecase=</xsl:text>
> -    <xsl:choose>
> -      <xsl:when test="$tab"><xsl:value-of select="$tab"/></xsl:when>
> -      <xsl:otherwise>tinymce</xsl:otherwise>
> -    </xsl:choose>
> -    <xsl:text>&amp;lenya.step=link-show</xsl:text>
> -  </xsl:template>
> -  
> -  
> -  <xsl:template name="languagetabs">
> -    <xsl:param name="tablanguages"/>
> +  <xsl:template name="languageTabs">
> +    <xsl:param name="languages"/>
>      <xsl:choose>
> -      <xsl:when test="not(contains($tablanguages,','))">
> -        <xsl:call-template name="languagetab">
> -          <xsl:with-param name="tablanguage">
> -            <xsl:value-of select="$tablanguages"/>
> +      <xsl:when test="not(contains($languages,','))">
> +        <xsl:call-template name="languageTab">
> +          <xsl:with-param name="language">
> +            <xsl:value-of select="$languages"/>
>            </xsl:with-param>
>          </xsl:call-template>
>        </xsl:when>
>        <xsl:otherwise>
> -        <xsl:variable name="head" select="substring-before($tablanguages,',')" />
> -        <xsl:variable name="tail" select="substring-after($tablanguages,',')" />
> -        <xsl:call-template name="languagetab">
> -          <xsl:with-param name="tablanguage" select="$head"/>
> +        <xsl:variable name="head" select="substring-before($languages,',')" />
> +        <xsl:variable name="tail" select="substring-after($languages,',')" />
> +        <xsl:call-template name="languageTab">
> +          <xsl:with-param name="language" select="$head"/>
>          </xsl:call-template>
> -        <xsl:call-template name="languagetabs">
> -          <xsl:with-param name="tablanguages" select="$tail"/>
> +        <xsl:call-template name="languageTabs">
> +          <xsl:with-param name="languages" select="$tail"/>
>          </xsl:call-template>
>        </xsl:otherwise>
>      </xsl:choose>
>    </xsl:template>
> -  
> -  
> -  <xsl:template name="languagetab">
> -    <xsl:param name="tablanguage"/>
> -    <td>
> -      <a id="{$tablanguage}">
> -        <xsl:call-template name="activate">
> -          <xsl:with-param name="tablanguage" select="$tablanguage"/>
> -        </xsl:call-template>
> -      </a>
> -    </td>
> -  </xsl:template>
> -  
> -  
> -  <xsl:template name="activate">
> -    <xsl:param name="tablanguage"/>
> -    <xsl:attribute name="href"><xsl:value-of select="$contextprefix"/>/<xsl:value-of select="$publicationid"/>/<xsl:value-of select="$area"/><xsl:value-of select="$documentid"/>_<xsl:value-of select="$tablanguage"/><xsl:value-of select="$extension"/>?lenya.module=tinymce&amp;lenya.step=link-show</xsl:attribute>
> -    <xsl:attribute name="class">lenya-tablink<xsl:choose><xsl:when test="$chosenlanguage = $tablanguage">-active</xsl:when><xsl:otherwise/></xsl:choose></xsl:attribute><xsl:value-of select="$tablanguage"/>
> +
> +  <xsl:template name="languageTab">
> +    <xsl:param name="language"/>
> +    <a id="{$language}">
> +      <xsl:attribute name="href">
> +        <xsl:text>/</xsl:text>
> +        <xsl:value-of select="$publicationId"/>
> +        <xsl:text>/</xsl:text>
> +        <xsl:value-of select="$area"/>
> +        <xsl:value-of select="$path"/>
> +        <xsl:text>_</xsl:text>
> +        <xsl:value-of select="$language"/>
> +        <xsl:value-of select="$extension"/>
> +        <xsl:text>?lenya.usecase=editors.insertLink</xsl:text>
> +        <xsl:text>&amp;lenya.editorModule=</xsl:text>
> +        <xsl:value-of select="$editorModule"/>
> +      </xsl:attribute>
> +      <xsl:attribute name="class">
> +        <xsl:text>lenya-tablink</xsl:text>
> +        <xsl:if test="$chosenLanguage = $language">
> +          <xsl:text>-active</xsl:text>
> +        </xsl:if>
> +      </xsl:attribute>
> +      <xsl:value-of select="$language"/>
> +    </a>
>    </xsl:template>
> -  
> +
>  </xsl:stylesheet> 


-- 
Andreas Hartmann, CTO
BeCompany GmbH
http://www.becompany.ch


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org