lenya/src/java/org/apache/lenya/cms/cocoon/logicsheets util.xsl,1.14,1.15

Christian Egli <[email protected]> Wed, 14 May 2003 19:25:59 +0200
Newsgroups gmane.comp.cms.wyona.cvs
Message-ID <[email protected]>
Update of /repository/lenya/src/java/org/apache/lenya/cms/cocoon/logicsheets
In directory erbium:/tmp/cvs-serv31391/src/java/org/apache/lenya/cms/cocoon/logicsheets

Modified Files:
	util.xsl 
Log Message:
Major code cleanup and bugfix with regards to xsp_lenya_prefix.


Index: util.xsl
===================================================================
RCS file: /repository/lenya/src/java/org/apache/lenya/cms/cocoon/logicsheets/util.xsl,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** util.xsl	8 May 2003 07:54:08 -0000	1.14
--- util.xsl	14 May 2003 17:25:57 -0000	1.15
***************
*** 31,107 ****
  <xsl:template match="xsp-lenya:util">
    <xsp:logic>
!     Date xsp_lenya_server_time=new Date();
!     <xsp:content><server_time><xsp:expr>xsp_lenya_server_time</xsp:expr></server_time></xsp:content>
!     String xsp_lenya_context=request.getContextPath();
!     <xsp:content><context><xsp:expr>xsp_lenya_context</xsp:expr></context></xsp:content>
!     String xsp_lenya_request_uri=request.getRequestURI();
!     <xsp:content><request_uri><xsp:expr>xsp_lenya_request_uri</xsp:expr></request_uri></xsp:content>
! 
      String xsp_lenya_context_prefix = null;
      String xsp_lenya_pub_url = null;
!     if(xsp_lenya_request_uri.indexOf("/authoring") >= 0) {
          xsp_lenya_context_prefix = xsp_lenya_request_uri.substring(0,xsp_lenya_request_uri.indexOf("/authoring"));
          xsp_lenya_pub_url = xsp_lenya_request_uri.substring(xsp_lenya_request_uri.indexOf("/authoring")+10);
      }
!     <xsp:content><context_prefix><xsp:expr>xsp_lenya_context_prefix</xsp:expr></context_prefix></xsp:content>
  
!     String xsp_lenya_sitemap_uri=request.getSitemapURI();
!     <xsp:content><sitemap_uri><xsp:expr>xsp_lenya_sitemap_uri</xsp:expr></sitemap_uri></xsp:content>
!     String xsp_lenya_prefix=xsp_lenya_request_uri.substring(0,xsp_lenya_request_uri.length()-xsp_lenya_sitemap_uri.length()-1);
!     <xsp:content><prefix><xsp:expr>xsp_lenya_prefix</xsp:expr></prefix></xsp:content>
  
!     Session xsp_lenya_session=request.getSession(false);
!     Identity xsp_lenya_id=null;
!     if(xsp_lenya_session != null){
!       xsp_lenya_id=(Identity)xsp_lenya_session.getAttribute("org.apache.lenya.cms.ac.Identity");
!       if(xsp_lenya_id != null){
          <xsp:content><current_username><xsp:expr>xsp_lenya_id.getUsername()</xsp:expr></current_username></xsp:content>
!       }
!       else{
          <xsp:content><no_username_yet/></xsp:content>
        }
!     }
!     else{
        <xsp:content><no_session_yet/></xsp:content>
      }
!     String xsp_lenya_referer=request.getHeader("Referer");
!     if(xsp_lenya_referer == null){
        <xsp:content><no_referer/></xsp:content>
!     }    
!     else {
         String xsp_lenya_status=request.getParameter("status");
         if(xsp_lenya_status == null){
            xsp_lenya_session.setAttribute("org.apache.lenya.cms.cocoon.acting.TaskAction.parent_uri",xsp_lenya_referer);
            <xsp:content><referer><xsp:expr>xsp_lenya_referer</xsp:expr></referer></xsp:content>
!        }
!        else{
           <xsp:content><referer><xsp:expr>xsp_lenya_session.getAttribute("org.apache.lenya.cms.cocoon.acting.TaskAction.parent_uri")</xsp:expr></referer></xsp:content>
         }
      }
- 	PageEnvelope xspPageEnvelope = null;
- 	try {
- 		xspPageEnvelope = new PageEnvelope(resolver, request);
- 	} catch (Exception e) {}
-         Publication xspUtilPublication = null;
-         String xspUtilServletContextPath = null;
-         String xspUtilPublicationPath = null;
-         {
-             Source inputSource = resolver.resolve("");
-             String publicationPath = inputSource.getSystemId();
-             String directories[] = publicationPath.split("/");
-             String publicationId = directories[directories.length - 1];
-             String path = publicationPath.substring(0, publicationPath.indexOf("/lenya/pubs/" + publicationId));
-             // FIXME:
-             path = path.replaceAll("file:", "");
-             //path = path.replaceAll("file:/", "");
-             path = path.replace('/', File.separatorChar);
-             publicationPath = publicationPath.replaceAll("file:", "");
-             publicationPath = publicationPath.replace('/', File.separatorChar);
-             
-             xspUtilServletContextPath = path;
-             xspUtilPublicationPath = publicationPath;
-             xspUtilPublication = new Publication(publicationId, path);
-         }
-     
    </xsp:logic>
  </xsl:template>
--- 31,111 ----
  <xsl:template match="xsp-lenya:util">
    <xsp:logic>
!     PageEnvelope xspPageEnvelope = null;
!     try {
!         xspPageEnvelope = new PageEnvelope(resolver, request);
!     } catch (Exception e) {}
!     
!     Publication xspUtilPublication = null;
!     String xspUtilServletContextPath = null;
!     String xspUtilPublicationPath = null;
!     {
!         Source inputSource = resolver.resolve("");
!         String publicationPath = inputSource.getSystemId();
!         String directories[] = publicationPath.split("/");
!         String publicationId = directories[directories.length - 1];
!         String path = publicationPath.substring(0, publicationPath.indexOf("/lenya/pubs/" + publicationId));
!         // FIXME:
!         path = path.replaceAll("file:", "");
!         //path = path.replaceAll("file:/", "");
!         path = path.replace('/', File.separatorChar);
!         publicationPath = publicationPath.replaceAll("file:", "");
!         publicationPath = publicationPath.replace('/', File.separatorChar);
!         
!         xspUtilServletContextPath = path;
!         xspUtilPublicationPath = publicationPath;
!         xspUtilPublication = new Publication(publicationId, path);
!     }
!     
!     Date xsp_lenya_server_time = new Date();
!     String xsp_lenya_context = request.getContextPath();
!     String xsp_lenya_request_uri = request.getRequestURI();
      String xsp_lenya_context_prefix = null;
      String xsp_lenya_pub_url = null;
! 
!     if (xsp_lenya_request_uri.indexOf("/authoring") >= 0) {
          xsp_lenya_context_prefix = xsp_lenya_request_uri.substring(0,xsp_lenya_request_uri.indexOf("/authoring"));
          xsp_lenya_pub_url = xsp_lenya_request_uri.substring(xsp_lenya_request_uri.indexOf("/authoring")+10);
      }
!     String xsp_lenya_sitemap_uri = request.getSitemapURI();
!     // FIXME: This is highly dubious. What is the idea behind this?
!     int xsp_lenya_tmp = xsp_lenya_request_uri.length() - xsp_lenya_sitemap_uri.length() - 1;
!     String xsp_lenya_prefix = null;
!     if (xsp_lenya_tmp &gt; 0) {
!         xsp_lenya_prefix = xsp_lenya_request_uri.substring(0, xsp_lenya_tmp);
!     }
  
!       <xsp:content>
! 	<server_time><xsp:expr>xsp_lenya_server_time</xsp:expr></server_time>
! 	<context><xsp:expr>xsp_lenya_context</xsp:expr></context>
! 	<request_uri><xsp:expr>xsp_lenya_request_uri</xsp:expr></request_uri>
! 	<context_prefix><xsp:expr>xsp_lenya_context_prefix</xsp:expr></context_prefix>
! 	<sitemap_uri><xsp:expr>xsp_lenya_sitemap_uri</xsp:expr></sitemap_uri>
! 	<prefix><xsp:expr>xsp_lenya_prefix</xsp:expr></prefix>
!       </xsp:content>
  
!     Session xsp_lenya_session = request.getSession(false);
!     Identity xsp_lenya_id = null;
!     if (xsp_lenya_session != null) {
!       xsp_lenya_id = (Identity)xsp_lenya_session.getAttribute("org.apache.lenya.cms.ac.Identity");
!       if (xsp_lenya_id != null) {
          <xsp:content><current_username><xsp:expr>xsp_lenya_id.getUsername()</xsp:expr></current_username></xsp:content>
!       } else {
          <xsp:content><no_username_yet/></xsp:content>
        }
!     } else {
        <xsp:content><no_session_yet/></xsp:content>
      }
!     String xsp_lenya_referer = request.getHeader("Referer");
!     if (xsp_lenya_referer == null) {
        <xsp:content><no_referer/></xsp:content>
!     } else {
         String xsp_lenya_status=request.getParameter("status");
         if(xsp_lenya_status == null){
            xsp_lenya_session.setAttribute("org.apache.lenya.cms.cocoon.acting.TaskAction.parent_uri",xsp_lenya_referer);
            <xsp:content><referer><xsp:expr>xsp_lenya_referer</xsp:expr></referer></xsp:content>
!        } else {
           <xsp:content><referer><xsp:expr>xsp_lenya_session.getAttribute("org.apache.lenya.cms.cocoon.acting.TaskAction.parent_uri")</xsp:expr></referer></xsp:content>
         }
      }
    </xsp:logic>
  </xsl:template>
***************
*** 129,135 ****
  </xsl:template>
  
- 
  <xsl:template match="xsp-lenya:publication">
!   xspUtilPublication
  </xsl:template>
  
--- 133,138 ----
  </xsl:template>
  
  <xsl:template match="xsp-lenya:publication">
!   <xsp:expr>xspPageEnvelope.getPublication()</xsp:expr>
  </xsl:template>
  
***************
*** 140,157 ****
   </xsl:copy>
  </xsl:template>
- 
- <!-- Standard Templates -->
- <!--
-   <xsl:template name="get-nested-content">
-     <xsl:param name="content"/>
-     <xsl:choose>
-       <xsl:when test="$content/xsp:text">"<xsl:value-of select="$content"/>"</xsl:when>
-       <xsl:when test="$content/*">
-         <xsl:apply-templates select="$content/*"/>
-       </xsl:when>
-       <xsl:otherwise>"<xsl:value-of select="$content"/>"</xsl:otherwise>
-     </xsl:choose>
-   </xsl:template>
- -->
  
    <xsl:template match="@*|*|text()|processing-instruction()">
--- 143,146 ----