xlawrence    2005/10/28 10:24:19 CEST

  Modified files:
    core/src/java/org/jahia/gui HTMLToolBox.java 
    core/src/java/org/jahia/taglibs/html/actions 
                                                 ActionMenuTag.java 
    core/src/webapp/WEB-INF/var/shared_templates 
                                                 corporate_portal_templates.jar 
  Added files:
    core/src/webapp/jsp/jahia/components tree.inc 
  Log:
  Fixed problem regarding linked page and closing fieldset tags
  
  Revision  Changes      Path
  1.30      +51 -8       jahia/core/src/java/org/jahia/gui/HTMLToolBox.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/gui/HTMLToolBox.java.diff?r1=1.29&r2=1.30&f=h
  1.6       +20 -34      
jahia/core/src/java/org/jahia/taglibs/html/actions/ActionMenuTag.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/taglibs/html/actions/ActionMenuTag.java.diff?r1=1.5&r2=1.6&f=h
  1.68      +1409 -1474  
jahia/core/src/webapp/WEB-INF/var/shared_templates/corporate_portal_templates.jar
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/webapp/WEB-INF/var/shared_templates/corporate_portal_templates.jar.diff?r1=1.67&r2=1.68&f=h
  1.1       +166 -0      jahia/core/src/webapp/jsp/jahia/components/tree.inc 
(new)
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/webapp/jsp/jahia/components/tree.inc?rev=1.1&content-type=text/plain
  
  
  
  Index: HTMLToolBox.java
  ===================================================================
  RCS file: 
/home/cvs/repository/jahia/core/src/java/org/jahia/gui/HTMLToolBox.java,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- HTMLToolBox.java  3 Oct 2005 12:49:38 -0000       1.29
  +++ HTMLToolBox.java  28 Oct 2005 08:24:10 -0000      1.30
  @@ -1067,11 +1067,11 @@
                   return;
               }
   
  -            if (contentObject.getParent()!=null && 
contentObject.getParent().isPicker()) {
  +            if (contentObject.getParent() != null && 
contentObject.getParent().isPicker()) {
                   return;
               }
           } catch (JahiaException e) {
  -            logger.error("Error checking ACL when drawing Action Menu", e);
  +            logger.error(e.getMessage(), e);
               return;
           }
           
  @@ -1112,7 +1112,7 @@
        * @deprecated use drawEndActionMenu(final boolean useFieldSet,
               final JspWriter out) instead
        */
  -    public void drawEndActionMenu(final Object contentObject,
  +    public void drawEndActionMenu(final ContentBean contentObject,
               final String lockIcon,
               final String actionIcon,
               final boolean useFieldSet,
  @@ -1121,18 +1121,40 @@
               final String labelKey,
               final JspWriter out)
               throws IOException {
  -        
  +
           if (!ProcessingContext.EDIT.equals(jParams.getOperationMode())) {
               // if we are not in edit mode we don't display the GUI
               return;
           }
  -        
  +
  +        if (contentObject == null) {
  +            // No object -> No menu...
  +            return;
  +        }
  +
  +        try {
  +            if (contentObject.getID() > 0 &&
  +                    ! contentObject.getACL().getPermission(jParams.getUser(),
  +                            JahiaBaseACL.WRITE_RIGHTS)) {
  +                // if the user doesn't have Write access on the object, 
don't display the GUI
  +                return;
  +            }
  +        } catch (Throwable t) {
  +            logger.error(t.getMessage(), t);
  +        }
  +
  +        if (contentObject.getParent() != null && 
contentObject.getParent().isPicker()) {
  +            return;
  +        }
  +
           endAjaxMenu(useFieldSet, out);
       }
       
       /**
        * Generates the HTML for the end of the action menu, closing the
        * box around the content object if we started one.
  +     * @param contentObject the content object for which to generate the
  +     * action menu
        * @param useFieldSet use to specify when an HTML field set box should
        *                    be generated around the content object
        * @param out the output JspWriter in which the HTML output will be
  @@ -1141,15 +1163,36 @@
        * the output (such as a socket that's been disconnected).
        */
       public void drawEndActionMenu(
  +            final ContentBean contentObject,
               final boolean useFieldSet,
  -            final JspWriter out)  
  +            final JspWriter out)
               throws IOException {
  -        
  +
           if (!ProcessingContext.EDIT.equals(jParams.getOperationMode())) {
               // if we are not in edit mode we don't display the GUI
               return;
           }
  -        
  +
  +        if (contentObject == null) {
  +            // No object -> No menu...
  +            return;
  +        }
  +
  +        try {
  +            if (contentObject.getID() > 0 &&
  +                    ! contentObject.getACL().getPermission(jParams.getUser(),
  +                            JahiaBaseACL.WRITE_RIGHTS)) {
  +                // if the user doesn't have Write access on the object, 
don't display the GUI
  +                return;
  +            }
  +        } catch (Throwable t) {
  +            logger.error(t.getMessage(), t);
  +        }
  +
  +        if (contentObject.getParent() != null && 
contentObject.getParent().isPicker()) {
  +            return;
  +        }
  +
           endAjaxMenu(useFieldSet, out);
       }
       
  
  
  
  Index: ActionMenuTag.java
  ===================================================================
  RCS file: 
/home/cvs/repository/jahia/core/src/java/org/jahia/taglibs/html/actions/ActionMenuTag.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ActionMenuTag.java        5 Aug 2005 13:49:52 -0000       1.5
  +++ ActionMenuTag.java        28 Oct 2005 08:24:11 -0000      1.6
  @@ -1,16 +1,15 @@
   package org.jahia.taglibs.html.actions;
   
  -import java.io.IOException;
  -import java.util.Map;
  -import javax.servlet.ServletRequest;
  -import javax.servlet.jsp.JspException;
  -import javax.servlet.jsp.JspWriter;
  -import javax.servlet.jsp.tagext.BodyTagSupport;
   import org.jahia.data.beans.ContentBean;
   import org.jahia.data.beans.RequestBean;
  -import org.jahia.params.ProcessingContext;
   import org.jahia.gui.GuiBean;
   import org.jahia.gui.HTMLToolBox;
  +import org.jahia.params.ProcessingContext;
  +
  +import javax.servlet.jsp.JspException;
  +import javax.servlet.jsp.JspWriter;
  +import javax.servlet.jsp.tagext.BodyTagSupport;
  +import java.io.IOException;
   
   /**
    * <p>Title: Tag that generates the HTML for the action menu GUI 
interface</p>
  @@ -26,7 +25,7 @@
    * @author Serge Huber
    * @version 1.0
    *
  - * @jsp:tag name="actionMenu" body-content="tagdependent"
  + * jsp:tag name="actionMenu" body-content="tagdependent"
    * description="Displays the GUI interface for actions on the selected Jahia 
content object.
    *
    * <p><attriInfo>This tag is for the moment not very generic but it is
  @@ -88,10 +87,6 @@
       private boolean useFieldSet = true;
       private String namePostFix = null;
       private String name = null;
  -    private Map actionURIBeans = null;
  -    private RequestBean requestBean = null;
  -    private ProcessingContext processingContext = null;
  -    private GuiBean guiBean = null;
       private HTMLToolBox htmlToolBox = null;
       private String resourceBundle = null;
       private String lockIcon = null;
  @@ -102,7 +97,7 @@
       }
   
       /**
  -     * @jsp:attribute name="name" required="true" rtexprvalue="true"
  +     * jsp:attribute name="name" required="true" rtexprvalue="true"
        * description="the name of the bean object issued by the content object 
whose actions buttons we want to display.
        * <p><attriInfo>This can be the bean object of either a Jahia Field, a 
Page Field, a Container or a ContainerList.
        * </attriInfo>"
  @@ -116,7 +111,7 @@
       }
   
       /**
  -     * @jsp:attribute name="resourceBundle" required="true" 
rtexprvalue="true"
  +     * jsp:attribute name="resourceBundle" required="true" rtexprvalue="true"
        * description="the identifier of the resource bundle  in which to 
retrieve the resources.
        * <p><attriInfo>
        * Resource bundles contain key/value pairs for specific locales and are 
used for internalization.
  @@ -145,12 +140,12 @@
       }
   
       /**
  -     * @jsp:attribute name="namePostFix" required="true" rtexprvalue="true"
  +     * jsp:attribute name="namePostFix" required="true" rtexprvalue="true"
        * description="a name to append to the resource names to be able
        * to generate access to varied resource for creating different menus for
        * the same type of objects.
  -     * <p><attriInfo>For example given namePostFix=\”Text\”, then the keys 
\“updateText\”, \“deleteText\” and \“addText\”
  -     * will be accessed in the resource bundle in place of the default 
\“update\”, \“delete\” and \“add\” keys.
  +     * <p><attriInfo>For example given namePostFix=\�Text\�, then the 
keys \�updateText\�, \�deleteText\� and \�addText\�
  +     * will be accessed in the resource bundle in place of the default 
\�update\�, \�delete\� and \�add\� keys.
        * </attriInfo>"
        */
       public String getNamePostFix () {
  @@ -166,7 +161,7 @@
       }
   
       /**
  -     * @jsp:attribute name="useFieldSet" required="false" rtexprvalue="true" 
type"boolean"
  +     * jsp:attribute name="useFieldSet" required="false" rtexprvalue="true" 
type"boolean"
        * description="specifies if an HTML &lt;fieldset&gt; box should be 
generated around the content object.
        * <p><attriInfo>For fields you will want this to be false most of the 
time, but for containers and container lists you will
        * want to be active.
  @@ -178,7 +173,7 @@
       }
   
       /**
  -     * @jsp:attribute name="lockIcon" required="false" rtexprvalue="true"
  +     * jsp:attribute name="lockIcon" required="false" rtexprvalue="true"
        * description="the name of the lock icon to display.
        * <p><attriInfo>If null, the default name of \"lock.gif\" is used.
        * </attriInfo>"
  @@ -192,7 +187,7 @@
       }
   
       /**
  -     * @jsp:attribute name="actionIcon" required="false" rtexprvalue="true"
  +     * jsp:attribute name="actionIcon" required="false" rtexprvalue="true"
        * description="the name of the action icon to display.
        * <p><attriInfo> If null, the default name of \"action.gif\" is used.
        * </attriInfo>"
  @@ -207,7 +202,7 @@
   
       /**
        *
  -     * @jsp:attribute name="labelKey" required="false" rtexprvalue="true"
  +     * jsp:attribute name="labelKey" required="false" rtexprvalue="true"
        * description="the key in the resource bundle for the internationalized 
version of the label text.
        * <p><attriInfo>This key uniquely identifies the locale-specific label 
text in the associated 'resourceBundle' bundle appropriate
        * for the current user's locale.
  @@ -224,12 +219,9 @@
       }
   
       public int doStartTag () {
  -
  -        ServletRequest request = pageContext.getRequest();
  -
  -        requestBean = (RequestBean) 
pageContext.findAttribute("currentRequest");
  -        processingContext = requestBean.getParamBean();
  -        guiBean = new GuiBean(processingContext);
  +        RequestBean requestBean = (RequestBean) 
pageContext.findAttribute("currentRequest");
  +        ProcessingContext processingContext = requestBean.getParamBean();
  +        GuiBean guiBean = new GuiBean(processingContext);
           htmlToolBox = new HTMLToolBox(guiBean, processingContext);
           ContentBean contentObject = 
(ContentBean)pageContext.findAttribute(name);
           if (contentObject == null) {
  @@ -271,9 +263,7 @@
   
           try {
   
  -            htmlToolBox.drawEndActionMenu(contentObject, lockIcon, 
actionIcon,
  -                                          useFieldSet, namePostFix,
  -                                          resourceBundle, labelKey, out);
  +            htmlToolBox.drawEndActionMenu((ContentBean)contentObject, 
useFieldSet, out);
   
           } catch (IOException ioe) {
               logger.error(
  @@ -291,10 +281,6 @@
           useFieldSet = true;
           namePostFix = null;
           name = null;
  -        actionURIBeans = null;
  -        processingContext = null;
  -        requestBean = null;
  -        guiBean = null;
           htmlToolBox = null;
           resourceBundle = null;
           lockIcon = null;
  
  
  
  Index: corporate_portal_templates.jar
  ===================================================================
        <<Binary file>>
  
  
  
  Index: tree.inc
  ====================================================================
  <%@ page import="org.jahia.services.sitemap.JahiaSiteMapService" %>
  <%@ page import="org.jahia.registries.ServicesRegistry" %>
  <%@ page import="org.jahia.data.viewhelper.sitemap.TreeSiteMapViewHelper" %>
  <%@ page import="org.jahia.data.JahiaData" %>
  <%@ page import="org.jahia.params.ProcessingContext" %>
  <%@ page import="org.jahia.services.pages.ContentPage" %>
  <%@ page import="org.jahia.exceptions.JahiaException" %>
  <%@ page import="org.jahia.params.ParamBean" %>
  <%@ page import="org.jahia.engines.shared.BigText_Field" %>
  <%@ page import="org.jahia.data.fields.JahiaField" %>
  <%@ page import="java.util.HashMap" %>
  <%@ page language="java" contentType="text/html;charset=UTF-8" %>
  
  <%!
      /*
      * This is a model for a generic tree that can be used for several 
purposes.
      * For example, it may be used to display the tree representing the sitemap
      *
      * This JSP generates the necessary paramters to feed in the javascript 
tree definition
      * contained in dtree.js
      */
  
      private static final org.apache.log4j.Logger treeLogger =
              org.apache.log4j.Logger.getLogger("jsp.jahia.components.tree");
  
      private final static ServicesRegistry servicesRegistry = 
ServicesRegistry.getInstance();
      private final static JahiaSiteMapService siteMapService =
              servicesRegistry.getJahiaSiteMapService();
  
      public static final int PAGES = 0;
      public static final int FILES = 1;
  
      /**
       * Returns a String containing the parameters to initialize the dtree 
javascript object.
       *
       * @param jData JahiaData instance
       * @param currentLanguageCode Language of the node name
       * @param displayLevel The starting depth of the tree
       * @param checkboxes TRUE will display checkboxes in front of the nodes
       * @param pageState TRUE will generate extra parameters showing the page 
states (used by FCK editor)
       * @param nodeType What are the node showing ?  (PAGES or FILES)
       * @param canExpandAll TRUE will add an expandAll and a collapseAll button
       *
       * @throws JahiaException If something goes wrong while getting the tree 
information
       */
      public String getTree(final JahiaData jData,
                            final String currentLanguageCode,
                            final int displayLevel,
                            final boolean checkboxes,
                            final boolean pageState,
                            final int nodeType,
                            final boolean canExpandAll) throws JahiaException {
          treeLogger.debug("Getting tree with params: displayLevel = " + 
displayLevel + ", checkboxes = " +
                  checkboxes + ", pageState = " + pageState);
  
          final StringBuffer result = new StringBuffer(128);
          result.append("[[0,0,\'root\','/'],");
          final ProcessingContext processingContext = 
jData.getProcessingContext();
  
          final int pageInfosFlag;
          if (jData.gui().isNormalMode()) {
              pageInfosFlag = ContentPage.ACTIVE_PAGE_INFOS;
          } else {
              pageInfosFlag = ContentPage.ACTIVE_PAGE_INFOS | 
ContentPage.STAGING_PAGE_INFOS;
          }
  
          try {
              final ContentPage theContentPage = 
servicesRegistry.getJahiaPageService().
                      
lookupContentPage(processingContext.getSite().getHomePageID(), false);
  
              final TreeSiteMapViewHelper treeJahiaSiteMap = 
(TreeSiteMapViewHelper) siteMapService.
                      getTreeSiteMapViewHelper(processingContext.getUser(), 
theContentPage,
                              processingContext.getSessionID(), pageInfosFlag,
                              currentLanguageCode, displayLevel - 1 );
  
              for (int i = 0; i < treeJahiaSiteMap.size(); i++) {
                  final ContentPage contentPage = 
treeJahiaSiteMap.getContentPage(i);
                  if (contentPage == null) {
                      continue;
                  }
  
                  final int pid = contentPage.getID();
                  String pageTitle = treeJahiaSiteMap.getPageTitle(i, 
currentLanguageCode);
  
                  if (pageTitle == null || pageTitle.length() == 0) {
                      pageTitle = new StringBuffer().append("[pid = 
").append(pid).append("]").toString();
                  }
  
                  final StringBuffer pageUrl = new StringBuffer();
                  pageUrl.append(((ParamBean) 
processingContext).getRequest().getContextPath()).
                          
append("/lang/").append(currentLanguageCode).append("/pid/").append(pid);
  
                  addParamsAsString(result, treeJahiaSiteMap, i, pageTitle, 
pageUrl.toString(),
                          pid, currentLanguageCode, null, processingContext, 
null, pageState);
  
              }
              result.deleteCharAt(result.length() - 1);
              result.append("]");
  
          } catch (JahiaException je) {
              throw je;
          }
  
          treeLogger.debug("Result: " + result);
          return result.toString();
      }
  
      /**
       * calls getTree with the given parameters + pageState = false & nodeType 
= PAGES
       */
      public String getSiteMap(final JahiaData jData,
                               final String currentLanguageCode,
                               final int displayLevel,
                               final boolean checkboxes,
                               final boolean canExpandAll) throws 
JahiaException {
  
          return getTree(jData, currentLanguageCode, displayLevel, checkboxes, 
false, PAGES, canExpandAll);
      }
  
      /**
       * calls getTree with the given parameters + nodeType = PAGES
       */
      public String getSiteMap(final JahiaData jData,
                               final String currentLanguageCode,
                               final int displayLevel,
                               final boolean checkboxes,
                               final boolean pageState,
                               final boolean canExpandAll) throws 
JahiaException {
  
          return getTree (jData, currentLanguageCode, displayLevel, checkboxes, 
pageState, PAGES, canExpandAll);
      }
  
      /**
       * Adds a String containing the javascript parameters to the Result 
StringBuffer
       */
      private void addParamsAsString(final StringBuffer buff,
                                     final TreeSiteMapViewHelper 
treeJahiaSiteMap,
                                     final int i,
                                     final String pageTitle,
                                     final String pageUrl,
                                     final int pageId,
                                     final String currentLanguageCode,
                                     final JahiaField theField,
                                     final ProcessingContext jParams,
                                     final HashMap engineMap,
                                     final boolean showPageState) throws 
JahiaException {
  
          buff.append("[").append((treeJahiaSiteMap.getPageLevel(i) + 1)).
                  append(",").append((i + 1)).append(",\'").
                  append(pageTitle.replaceAll("'", "\\\\'")).
                  append("\','").append(pageUrl.toString().replaceAll("'", 
"\\\\'")).append("\',");
  
          if (showPageState) {
              buff.append("\'").
                      append(BigText_Field.getInstance().getPageState(pageId, 
currentLanguageCode)).
                      append("\',");
          }
          if (theField != null && engineMap != null) {
              buff.append("\'").
                      
append(BigText_Field.getInstance().getFieldGroupsNotHavingAccessOnPageAsString(
                              pageId, theField, jParams, 
engineMap)).append("\'");
          }
          buff.append("],");
      }
  
  %>

Reply via email to