You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2006/06/08 12:45:46 UTC

svn commit: r412718 - in /lenya/trunk/src: modules/cforms/config/menu.xsp modules/links/config/menu.xsp modules/opendocument/config/menus/opendocument.xsp modules/xhtml/config/menu.xsp pubs/default/modules/homepage/config/menus/homepage.xsp

Author: andreas
Date: Thu Jun  8 03:45:46 2006
New Revision: 412718

URL: http://svn.apache.org/viewvc?rev=412718&view=rev
Log:
Added check for document existence to module menus to avoid exception for non-existing documents in the site area.

Modified:
    lenya/trunk/src/modules/cforms/config/menu.xsp
    lenya/trunk/src/modules/links/config/menu.xsp
    lenya/trunk/src/modules/opendocument/config/menus/opendocument.xsp
    lenya/trunk/src/modules/xhtml/config/menu.xsp
    lenya/trunk/src/pubs/default/modules/homepage/config/menus/homepage.xsp

Modified: lenya/trunk/src/modules/cforms/config/menu.xsp
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/cforms/config/menu.xsp?rev=412718&r1=412717&r2=412718&view=diff
==============================================================================
--- lenya/trunk/src/modules/cforms/config/menu.xsp (original)
+++ lenya/trunk/src/modules/cforms/config/menu.xsp Thu Jun  8 03:45:46 2006
@@ -44,15 +44,23 @@
       
       <menu i18n:attr="name" name="Edit">
           <xsp:logic>
-            String doctype = <input:get-attribute module="page-envelope" as="string" name="document-type"/>;
-            if ("cforms".equals(doctype)) {
-                <block info="false">
-                  <item wf:event="edit" uc:usecase="edit.cforms" href="?"><i18n:text>With CForms</i18n:text></item>
-                  <!-- TODO: add RelaxNG schemas for cforms doctype.
-                  <item wf:event="edit" uc:usecase="edit.forms"><xsp:attribute name="href"><xsp:expr>"?form=" + doctype</xsp:expr></xsp:attribute><i18n:text>With Forms</i18n:text></item>
-                  <item wf:event="edit" uc:usecase="edit.oneform" href="?"><i18n:text>With one Form</i18n:text></item>
-                  -->
-                </block>
+            try {
+                Document doc = (Document) <input:get-attribute module="page-envelope" as="object" name="document"/>;
+                if (doc != null &amp;&amp; doc.exists()) {
+                    String doctype = <input:get-attribute module="page-envelope" as="string" name="document-type"/>;
+                    if ("cforms".equals(doctype)) {
+                        <block info="false">
+                          <item wf:event="edit" uc:usecase="edit.cforms" href="?"><i18n:text>With CForms</i18n:text></item>
+                          <!-- TODO: add RelaxNG schemas for cforms doctype.
+                          <item wf:event="edit" uc:usecase="edit.forms"><xsp:attribute name="href"><xsp:expr>"?form=" + doctype</xsp:expr></xsp:attribute><i18n:text>With Forms</i18n:text></item>
+                          <item wf:event="edit" uc:usecase="edit.oneform" href="?"><i18n:text>With one Form</i18n:text></item>
+                          -->
+                        </block>
+                    }
+                }
+            }
+            catch (Exception e) {
+                throw new ProcessingException("Error during menu generation: ", e);
             }
           </xsp:logic>
       </menu>

Modified: lenya/trunk/src/modules/links/config/menu.xsp
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/links/config/menu.xsp?rev=412718&r1=412717&r2=412718&view=diff
==============================================================================
--- lenya/trunk/src/modules/links/config/menu.xsp (original)
+++ lenya/trunk/src/modules/links/config/menu.xsp Thu Jun  8 03:45:46 2006
@@ -44,11 +44,19 @@
       
       <menu i18n:attr="name" name="Edit">
           <xsp:logic>
-            String doctype = <input:get-attribute module="page-envelope" as="string" name="document-type"/>;
-            if ("links".equals(doctype)) {
-                <block info="false">
-                  <item wf:event="edit" uc:usecase="edit.oneform" href="?"><i18n:text>With one Form</i18n:text></item>
-                </block>
+            try {
+                Document doc = (Document) <input:get-attribute module="page-envelope" as="object" name="document"/>;
+                if (doc != null &amp;&amp; doc.exists()) {
+                    String doctype = <input:get-attribute module="page-envelope" as="string" name="document-type"/>;
+                    if ("links".equals(doctype)) {
+                        <block info="false">
+                          <item wf:event="edit" uc:usecase="edit.oneform" href="?"><i18n:text>With one Form</i18n:text></item>
+                        </block>
+                    }
+                }
+            }
+            catch (Exception e) {
+                throw new ProcessingException("Error during menu generation: ", e);
             }
           </xsp:logic>
       </menu>

Modified: lenya/trunk/src/modules/opendocument/config/menus/opendocument.xsp
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/opendocument/config/menus/opendocument.xsp?rev=412718&r1=412717&r2=412718&view=diff
==============================================================================
--- lenya/trunk/src/modules/opendocument/config/menus/opendocument.xsp (original)
+++ lenya/trunk/src/modules/opendocument/config/menus/opendocument.xsp Thu Jun  8 03:45:46 2006
@@ -43,20 +43,28 @@
       </menu>
       <menu i18n:attr="name" name="Edit">
           <xsp:logic>
-            String doctype = <input:get-attribute module="page-envelope" as="string" name="document-type"/>;
-            String requestURI = <input:get-attribute module="request" as="string" name="requestURI"/>;
-            String moduleURI = requestURI.substring(0,requestURI.lastIndexOf(".html")).concat(".odt?lenya.module=opendocument");
-            if ("opendocument".equals(doctype)) {
-                <block info="false">
-                  <item>
-                    <xsp:attribute name="href">
-                      <xsp:expr>moduleURI</xsp:expr>
-                    </xsp:attribute>
-                    <i18n:text>Download ODT</i18n:text></item>
-                </block>
-                <block info="false">
-                  <item uc:usecase="module.odt.upload" href="?"><i18n:text>Upload ODT</i18n:text></item>
-                </block>
+            try {
+                Document doc = (Document) <input:get-attribute module="page-envelope" as="object" name="document"/>;
+                if (doc != null &amp;&amp; doc.exists()) {
+                    String doctype = <input:get-attribute module="page-envelope" as="string" name="document-type"/>;
+                    String requestURI = <input:get-attribute module="request" as="string" name="requestURI"/>;
+                    String moduleURI = requestURI.substring(0,requestURI.lastIndexOf(".html")).concat(".odt?lenya.module=opendocument");
+                    if ("opendocument".equals(doctype)) {
+                        <block info="false">
+                          <item>
+                            <xsp:attribute name="href">
+                              <xsp:expr>moduleURI</xsp:expr>
+                            </xsp:attribute>
+                            <i18n:text>Download ODT</i18n:text></item>
+                        </block>
+                        <block info="false">
+                          <item uc:usecase="module.odt.upload" href="?"><i18n:text>Upload ODT</i18n:text></item>
+                        </block>
+                    }
+                }
+            }
+            catch (Exception e) {
+                throw new ProcessingException("Error during menu generation: ", e);
             }
           </xsp:logic>
       </menu>

Modified: lenya/trunk/src/modules/xhtml/config/menu.xsp
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/xhtml/config/menu.xsp?rev=412718&r1=412717&r2=412718&view=diff
==============================================================================
--- lenya/trunk/src/modules/xhtml/config/menu.xsp (original)
+++ lenya/trunk/src/modules/xhtml/config/menu.xsp Thu Jun  8 03:45:46 2006
@@ -44,14 +44,22 @@
       
       <menu i18n:attr="name" name="Edit">
           <xsp:logic>
-            String doctype = <input:get-attribute module="page-envelope" as="string" name="document-type"/>;
-            if ("xhtml".equals(doctype)) {
-                <block info="false">
-                  <item wf:event="edit" uc:usecase="kupu" uc:step="open" href="?"><i18n:text>With Kupu</i18n:text></item>
-                  <item wf:event="edit" uc:usecase="edit.bxe" href="?"><i18n:text>With BXE</i18n:text></item>
-                  <item wf:event="edit" uc:usecase="edit.forms"><xsp:attribute name="href"><xsp:expr>"?form=" + doctype</xsp:expr></xsp:attribute><i18n:text>With Forms</i18n:text></item>
-                  <item wf:event="edit" uc:usecase="edit.oneform" href="?"><i18n:text>With one Form</i18n:text></item>
-                </block>
+            try {
+                Document doc = (Document) <input:get-attribute module="page-envelope" as="object" name="document"/>;
+                if (doc != null &amp;&amp; doc.exists()) {
+                    String doctype = <input:get-attribute module="page-envelope" as="string" name="document-type"/>;
+                    if ("xhtml".equals(doctype)) {
+                        <block info="false">
+                          <item wf:event="edit" uc:usecase="kupu" uc:step="open" href="?"><i18n:text>With Kupu</i18n:text></item>
+                          <item wf:event="edit" uc:usecase="edit.bxe" href="?"><i18n:text>With BXE</i18n:text></item>
+                          <item wf:event="edit" uc:usecase="edit.forms"><xsp:attribute name="href"><xsp:expr>"?form=" + doctype</xsp:expr></xsp:attribute><i18n:text>With Forms</i18n:text></item>
+                          <item wf:event="edit" uc:usecase="edit.oneform" href="?"><i18n:text>With one Form</i18n:text></item>
+                        </block>
+                    }
+                }
+            }
+            catch (Exception e) {
+                throw new ProcessingException("Error during menu generation: ", e);
             }
           </xsp:logic>
       </menu>

Modified: lenya/trunk/src/pubs/default/modules/homepage/config/menus/homepage.xsp
URL: http://svn.apache.org/viewvc/lenya/trunk/src/pubs/default/modules/homepage/config/menus/homepage.xsp?rev=412718&r1=412717&r2=412718&view=diff
==============================================================================
--- lenya/trunk/src/pubs/default/modules/homepage/config/menus/homepage.xsp (original)
+++ lenya/trunk/src/pubs/default/modules/homepage/config/menus/homepage.xsp Thu Jun  8 03:45:46 2006
@@ -38,14 +38,22 @@
     <menus>
       <menu i18n:attr="name" name="Edit">
           <xsp:logic>
-            String doctype = <input:get-attribute module="page-envelope" as="string" name="document-type"/>;
-            if ("homepage".equals(doctype)) {
-                <block info="false">
-                  <item wf:event="edit" uc:usecase="kupu" uc:step="open" href="?"><i18n:text>With Kupu</i18n:text></item>
-                  <item wf:event="edit" uc:usecase="edit.bxe" href="?"><i18n:text>With BXE</i18n:text></item>
-                  <item wf:event="edit" uc:usecase="edit.forms"><xsp:attribute name="href"><xsp:expr>"?form=" + doctype</xsp:expr></xsp:attribute><i18n:text>With Forms</i18n:text></item>
-                  <item wf:event="edit" uc:usecase="edit.oneform" href="?"><i18n:text>With one Form</i18n:text></item>
-                </block>
+            try {
+                Document doc = (Document) <input:get-attribute module="page-envelope" as="object" name="document"/>;
+                if (doc != null &amp;&amp; doc.exists()) {
+                    String doctype = <input:get-attribute module="page-envelope" as="string" name="document-type"/>;
+                    if ("homepage".equals(doctype)) {
+                        <block info="false">
+                          <item wf:event="edit" uc:usecase="kupu" uc:step="open" href="?"><i18n:text>With Kupu</i18n:text></item>
+                          <item wf:event="edit" uc:usecase="edit.bxe" href="?"><i18n:text>With BXE</i18n:text></item>
+                          <item wf:event="edit" uc:usecase="edit.forms"><xsp:attribute name="href"><xsp:expr>"?form=" + doctype</xsp:expr></xsp:attribute><i18n:text>With Forms</i18n:text></item>
+                          <item wf:event="edit" uc:usecase="edit.oneform" href="?"><i18n:text>With one Form</i18n:text></item>
+                        </block>
+                    }
+                }
+            }
+            catch (Exception e) {
+                throw new ProcessingException("Error during menu generation: ", e);
             }
           </xsp:logic>
       </menu>



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


Re: svn commit: r412718 - in /lenya/trunk/src: modules/cforms/config/menu.xsp modules/links/config/menu.xsp modules/opendocument/config/menus/opendocument.xsp modules/xhtml/config/menu.xsp pubs/default/modules/homepage/config/menus/homepage.xsp

Posted by Andreas Hartmann <an...@apache.org>.
Joern Nettingsmeier wrote:
> andreas@apache.org wrote:
>> Author: andreas
>> Date: Thu Jun  8 03:45:46 2006
>> New Revision: 412718
>>
>> URL: http://svn.apache.org/viewvc?rev=412718&view=rev
>> Log:
>> Added check for document existence to module menus to avoid exception for non-existing documents in the site area.
>>
>> Modified:
>>     lenya/trunk/src/modules/cforms/config/menu.xsp
>>     lenya/trunk/src/modules/links/config/menu.xsp
>>     lenya/trunk/src/modules/opendocument/config/menus/opendocument.xsp
>>     lenya/trunk/src/modules/xhtml/config/menu.xsp
>>     lenya/trunk/src/pubs/default/modules/homepage/config/menus/homepage.xsp
> 
> this is a lot of code duplication.

Yes, I don't like it either :(

> isn't there a way to move this
> snippet into an xsp "functions" file, maybe via cinclude and friends?

Hmmm, I wouldn't like to add any indirections / includes to XSP unless
this is absolutely necessary. Maybe we can optimize the input module(s)
to require less checking code in the menu XSP?

BTW, good to see that you're a critical commit list reader :)

-- Andreas


-- 
Andreas Hartmann
Wyona Inc.  -   Open Source Content Management   -   Apache Lenya
http://www.wyona.com                      http://lenya.apache.org
andreas.hartmann@wyona.com                     andreas@apache.org


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


Re: svn commit: r412718 - in /lenya/trunk/src: modules/cforms/config/menu.xsp modules/links/config/menu.xsp modules/opendocument/config/menus/opendocument.xsp modules/xhtml/config/menu.xsp pubs/default/modules/homepage/config/menus/homepage.xsp

Posted by Joern Nettingsmeier <po...@uni-due.de>.
andreas@apache.org wrote:
> Author: andreas
> Date: Thu Jun  8 03:45:46 2006
> New Revision: 412718
> 
> URL: http://svn.apache.org/viewvc?rev=412718&view=rev
> Log:
> Added check for document existence to module menus to avoid exception for non-existing documents in the site area.
> 
> Modified:
>     lenya/trunk/src/modules/cforms/config/menu.xsp
>     lenya/trunk/src/modules/links/config/menu.xsp
>     lenya/trunk/src/modules/opendocument/config/menus/opendocument.xsp
>     lenya/trunk/src/modules/xhtml/config/menu.xsp
>     lenya/trunk/src/pubs/default/modules/homepage/config/menus/homepage.xsp

this is a lot of code duplication. isn't there a way to move this
snippet into an xsp "functions" file, maybe via cinclude and friends?



-- 
"Án nýrra verka, án nútimans, hættir fortíðin að vekja áhuga."
"Without new works, without the present the past will cease to be of
interest."
        - Ásmundur Sveinsson (1893-1982)

--
Jörn Nettingsmeier, EDV-Administrator
Institut für Politikwissenschaft
Universität Duisburg-Essen, Standort Duisburg
Mail: pol-admin@uni-due.de, Telefon: 0203/379-2736


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