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 2003/09/18 15:19:48 UTC

cvs commit: cocoon-lenya/src/webapp/lenya/content/info deactivate.xsp

andreas     2003/09/18 06:19:48

  Modified:    src/webapp/lenya/xslt/info deactivate.xsl
               src/webapp/lenya/content/info deactivate.xsp
  Log:
  showing error message if child documents are live
  
  Revision  Changes    Path
  1.9       +95 -58    cocoon-lenya/src/webapp/lenya/xslt/info/deactivate.xsl
  
  Index: deactivate.xsl
  ===================================================================
  RCS file: /home/cvs/cocoon-lenya/src/webapp/lenya/xslt/info/deactivate.xsl,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- deactivate.xsl	8 Sep 2003 20:48:58 -0000	1.8
  +++ deactivate.xsl	18 Sep 2003 13:19:48 -0000	1.9
  @@ -1,76 +1,113 @@
  -<?xml version="1.0"?>
  -
  +<?xml version="1.0" encoding="UTF-8"?>
   <!--
    $Id$
    -->
  -
  - <xsl:stylesheet version="1.0"
  -   xmlns="http://www.w3.org/1999/xhtml"
  -   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  -   xmlns:session="http://www.apache.org/xsp/session/2.0"
  -   xmlns:page="http://apache.org/cocoon/lenya/cms-page/1.0"
  -   xmlns:not="http://apache.org/cocoon/lenya/notification/1.0"
  -   >
  -   
  +<xsl:stylesheet version="1.0" xmlns="http://www.w3.org/1999/xhtml"
  +  xmlns:not="http://apache.org/cocoon/lenya/notification/1.0"
  +  xmlns:page="http://apache.org/cocoon/lenya/cms-page/1.0"
  +  xmlns:session="http://www.apache.org/xsp/session/2.0"
  +  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  +  
     <xsl:param name="lenya.event"/>
     
  -  <xsl:output version="1.0" indent="yes" encoding="ISO-8859-1"/>
  +  <xsl:output encoding="ISO-8859-1" indent="yes" version="1.0"/>
  +  
  +  <xsl:variable name="document-id">
  +    <xsl:value-of select="/page/info/document-id"/>
  +  </xsl:variable>
  +  
  +  <xsl:variable name="task-id">
  +    <xsl:value-of select="/page/info/task-id"/>
  +  </xsl:variable>
  +  
  +  <xsl:variable name="request-uri">
  +    <xsl:value-of select="/page/info/request-uri"/>
  +  </xsl:variable>
  +  
     
  -  <xsl:variable name="document-id"><xsl:value-of select="/page/info/document-id"/></xsl:variable>
  -  <xsl:variable name="task-id"><xsl:value-of select="/page/info/task-id"/></xsl:variable>
  -  <xsl:variable name="request-uri"><xsl:value-of select="/page/info/request-uri"/></xsl:variable>
  -
     <xsl:template match="/">
       <xsl:apply-templates/>
     </xsl:template>
     
  +  
     <xsl:template match="page">
       <page:page>
         <page:title>Deactivate Document</page:title>
         <page:body>
           <xsl:apply-templates select="body"/>
  -	    <xsl:apply-templates select="info"/>
  +        <xsl:apply-templates select="info"/>
         </page:body>
       </page:page>
     </xsl:template>
     
  -  <xsl:template match="info">
  -        <form method="get">
  -        	
  -	<div class="lenya-box">
  -		<div class="lenya-box-title">Deactivate Document</div>
  -		<div class="lenya-box-body">
  -			<input type="hidden" name="lenya.usecase" value="deactivate"/>
  -			<input type="hidden" name="lenya.step" value="deactivate"/>
  -			<input type="hidden" name="lenya.event" value="{$lenya.event}"/>
  -			<input type="hidden" name="task-id" value="{$task-id}"/>
  -			<xsl:call-template name="task-parameters">
  -				<xsl:with-param name="prefix" select="''"/>
  -			</xsl:call-template>
  -			<p>
  -				Do you really want to deactivate this document?
  -				<ul>
  -					<li><xsl:value-of select="$document-id"/></li>
  -				</ul>
  -			</p>
  -		</div>
  -	</div>
  -          
  -					<not:notification>
  -						<not:textarea/>
  -					</not:notification>
  -
  -          <input type="submit" value="Deactivate"/>
  -          &#160;
  -          <input type="button" onClick="location.href='{$request-uri}';" value="Cancel"/>
  -        </form>
  -  </xsl:template>
  -
  -<xsl:template name="task-parameters">
  -  <xsl:param name="prefix" select="'task.'"/>
  -  <input type="hidden" name="{$prefix}properties.node.firstdocumentid" value="{$document-id}"/>
  -</xsl:template>
  -
  -
  -
  -</xsl:stylesheet>
  \ No newline at end of file
  +  
  +  <xsl:template match="info[not(message)]">
  +    <form method="get">
  +      <div class="lenya-box">
  +        <div class="lenya-box-title">Deactivate Document</div>
  +        <div class="lenya-box-body">
  +          <input name="lenya.usecase" type="hidden" value="deactivate"/>
  +          <input name="lenya.step" type="hidden" value="deactivate"/>
  +          <input name="lenya.event" type="hidden" value="{$lenya.event}"/>
  +          <input name="task-id" type="hidden" value="{$task-id}"/>
  +          <xsl:call-template name="task-parameters">
  +            <xsl:with-param name="prefix" select="''"/>
  +          </xsl:call-template>
  +          <p> Do you really want to deactivate this document?</p>
  +          <table class="lenya-table-noborder">
  +            <tr>
  +              <td class="lenya-entry-caption">Document:</td>
  +              <td><xsl:value-of select="$document-id"/></td>
  +            </tr>
  +          </table>
  +        </div>
  +      </div>
  +      <not:notification>
  +        <not:textarea/>
  +      </not:notification>
  +      <input type="submit" value="Deactivate"/> &#160; <input
  +        onClick="location.href='{$request-uri}';" type="button" value="Cancel"/>
  +    </form>
  +  </xsl:template>
  +  
  +  
  +  <xsl:template match="info[message]">
  +    <form method="get">
  +      <div class="lenya-box">
  +        <div class="lenya-box-title">Deactivate Document</div>
  +        <div class="lenya-box-body">
  +          <table class="lenya-table-noborder">
  +            <tr>
  +              <td class="lenya-entry-caption">Document:</td>
  +              <td><xsl:value-of select="$document-id"/></td>
  +            </tr>
  +            <tr>
  +              <td valign="top" class="lenya-entry-caption">Problem:</td>
  +              <td>
  +                <span class="lenya-form-error">This document cannot be deactivated
  +                unless the following child documents are deactivated:</span>
  +                <ul>
  +                  <xsl:apply-templates select="live-child"/>
  +                </ul>
  +              </td>
  +            </tr>
  +          </table>
  +        </div>
  +      </div>
  +      <input onClick="location.href='{$request-uri}';" type="button" value="Cancel"/>
  +    </form>
  +  </xsl:template>
  +  
  +  
  +  <xsl:template match="live-child">
  +    <li><a href="{@href}"><xsl:value-of select="@id"/> [<xsl:value-of select="@language"/>]</a></li>
  +  </xsl:template>
  +  
  +  
  +  <xsl:template name="task-parameters">
  +    <xsl:param name="prefix" select="'task.'"/>
  +    <input name="{$prefix}properties.node.firstdocumentid" type="hidden" value="{$document-id}"/>
  +  </xsl:template>
  +  
  +  
  +</xsl:stylesheet>
  
  
  
  1.6       +42 -0     cocoon-lenya/src/webapp/lenya/content/info/deactivate.xsp
  
  Index: deactivate.xsp
  ===================================================================
  RCS file: /home/cvs/cocoon-lenya/src/webapp/lenya/content/info/deactivate.xsp,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- deactivate.xsp	5 Sep 2003 14:41:10 -0000	1.5
  +++ deactivate.xsp	18 Sep 2003 13:19:48 -0000	1.6
  @@ -6,12 +6,54 @@
     xmlns:xsp-request="http://apache.org/xsp/request/2.0"
     xmlns:input="http://apache.org/cocoon/xsp/input/1.0"
     >
  +  
  +<xsp:structure>
  +  <xsp:include>org.apache.lenya.cms.publication.DefaultDocumentBuilder</xsp:include>
  +  <xsp:include>org.apache.lenya.cms.publication.Document</xsp:include>
  +  <xsp:include>org.apache.lenya.cms.publication.Publication</xsp:include>
  +  <xsp:include>org.apache.lenya.cms.publication.SiteTree</xsp:include>
  +  <xsp:include>org.apache.lenya.cms.publication.SiteTreeNode</xsp:include>
  +</xsp:structure>
   
   <page>
     <info>
  +    
       <request-uri><xsp-request:get-uri/></request-uri>
       <document-id><input:get-attribute module="page-envelope" as="string" name="document-id"/></document-id>
       <task-id>deactivateDocument</task-id>
  +    
  +    <xsp:logic>
  +      try {
  +          Document document = (Document) <input:get-attribute module="page-envelope" as="object" name="document"/>;
  +          SiteTree liveTree = document.getPublication().getSiteTree(Publication.LIVE_AREA);
  +          SiteTreeNode liveNode = liveTree.getNode(document.getId());
  +          SiteTreeNode[] liveChildren = liveNode.getChildren(document.getLanguage());
  +          Publication publication = (Publication) <input:get-attribute module="page-envelope" as="object" name="publication"/>;
  +          
  +          if (liveChildren.length &gt; 0) {
  +              <message id="children-live"/>
  +          }
  +          
  +          DefaultDocumentBuilder builder = DefaultDocumentBuilder.getInstance();
  +          for (int i = 0; i &lt; liveChildren.length; i++) {
  +          
  +              String url = builder.buildCanonicalUrl(publication,
  +                  document.getArea(), document.getId() + "/" + liveChildren[i].getId(), document.getLanguage());
  +          
  +              <live-child>
  +                <xsp:attribute name="href"><xsp-request:get-context-path/><xsp:expr>url</xsp:expr></xsp:attribute>
  +                <xsp:attribute name="id"><xsp:expr>liveChildren[i].getId()</xsp:expr></xsp:attribute>
  +                <xsp:attribute name="language"><xsp:expr>document.getLanguage()</xsp:expr></xsp:attribute>
  +              </live-child>
  +          }
  +          
  +      }
  +      catch (Exception e) {
  +          throw new ProcessingException(e);
  +      }
  +    </xsp:logic>
  +    
  +    
     </info>
   </page>
   </xsp:page>
  
  
  

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