Author: rfelden
Date: Fri Dec 14 16:00:29 2007
New Revision: 19372

URL: https://svndev.jahia.net/websvn/listing.php?sc=3D1&rev=3D19372&repname=
=3Djahia
Log:
current page path & navigation menu updates
pagepath:hide start and end pages
navmenu:topmenu refactored (used with corpV3)

Modified:
    branches/JAHIA-INCLUDE-TAG-BRANCH/core/src/java/org/jahia/taglibs/html/=
links/CurrentPagePathTag.java
    branches/JAHIA-INCLUDE-TAG-BRANCH/core/src/java/org/jahia/taglibs/html/=
menus/NavMenuTag.java
    branches/JAHIA-INCLUDE-TAG-BRANCH/core/src/webapp/WEB-INF/etc/taglibs/j=
ahia-components.tld

Modified: branches/JAHIA-INCLUDE-TAG-BRANCH/core/src/java/org/jahia/taglibs=
/html/links/CurrentPagePathTag.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-INCLUD=
E-TAG-BRANCH/core/src/java/org/jahia/taglibs/html/links/CurrentPagePathTag.=
java&rev=3D19372&repname=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/JAHIA-INCLUDE-TAG-BRANCH/core/src/java/org/jahia/taglibs/html/=
links/CurrentPagePathTag.java (original)
+++ branches/JAHIA-INCLUDE-TAG-BRANCH/core/src/java/org/jahia/taglibs/html/=
links/CurrentPagePathTag.java Fri Dec 14 16:00:29 2007
@@ -16,10 +16,12 @@
  * limitations under the License.
  */package org.jahia.taglibs.html.links;
 =

+import org.apache.log4j.Logger;
 import org.jahia.data.JahiaData;
 import org.jahia.exceptions.JahiaException;
 import org.jahia.gui.GuiBean;
 import org.jahia.params.ProcessingContext;
+import org.jahia.registries.ServicesRegistry;
 import org.jahia.services.pages.ContentPage;
 import org.jahia.taglibs.AbstractJahiaTag;
 import org.jahia.utils.JahiaConsole;
@@ -28,7 +30,8 @@
 import javax.servlet.jsp.JspException;
 import javax.servlet.jsp.JspWriter;
 import java.io.IOException;
-import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.Vector;
 =

 /**
  * Class CurrentPagePathTag : returns the formated path of the current page
@@ -45,9 +48,13 @@
  */
 public class CurrentPagePathTag extends AbstractJahiaTag {
 =

+    private static final Logger logger =3D Logger.getLogger(CurrentPagePat=
hTag.class);
+
     private String style =3D "pagePath";
     private int maxchar =3D 0;
     private String unreadablePages =3D "ellipsis" ;
+    private int hideBeginPages =3D 0 ;
+    private int hideEndPages =3D 0 ;
 =

     /**
      * jsp:attribute name=3D"style" required=3D"false" rtexprvalue=3D"true"
@@ -84,6 +91,14 @@
         this.unreadablePages =3D unreadableDisplay;
     }
 =

+    public void setHideBeginPages(int hideBeginPages) {
+        this.hideBeginPages =3D hideBeginPages;
+    }
+
+    public void setHideEndPages(int hideEndPages) {
+        this.hideEndPages =3D hideEndPages;
+    }
+
     public int doStartTag () {
 =

         HttpServletRequest request =3D (HttpServletRequest) pageContext.
@@ -92,15 +107,34 @@
             "org.jahia.data.JahiaData");
         try {
             ProcessingContext jParams =3D jData.getProcessingContext();
-            Enumeration thePath =3D jData.page().getContentPagePath(jParam=
s.
-                getOperationMode(), jParams.getUser());
+
+            Vector<ContentPage> vPath =3D ServicesRegistry.getInstance().g=
etJahiaPageService().getContentPagePath (jData.page().getID(), jParams.getE=
ntryLoadRequest(), jParams.getOperationMode(), jParams.getUser());
+
+            // remove unwanted entries
+            for (int i=3D0; i<hideBeginPages; i++) {
+                try {
+                    vPath.removeElementAt(0);
+                } catch (Exception e) {
+                    break ; // vector is empty
+                }
+            }
+            for (int i=3D0; i<hideEndPages; i++) {
+                try {
+                    vPath.removeElementAt(vPath.size()-1);
+                } catch (Exception e) {
+                    break ; // vector is empty
+                }
+            }
+
             StringBuffer path =3D new StringBuffer("<ul style=3D'").append=
(style).append("'>");
             boolean isAccessible =3D true ;
             boolean unreachablePageDisplayed =3D false ;
             // check page status
             Integer pageState =3D null ;
-            while (thePath.hasMoreElements()) {
-                ContentPage thePage =3D (ContentPage) thePath.nextElement(=
);
+
+            Iterator<ContentPage> thePath =3D vPath.iterator() ;
+            while (thePath.hasNext()) {
+                ContentPage thePage =3D thePath.next();
                 if (thePage !=3D null) {
                     if (!thePage.isAclSameAsParent()) {
                         isAccessible =3D thePage.checkReadAccess(jParams.g=
etUser()) ;

Modified: branches/JAHIA-INCLUDE-TAG-BRANCH/core/src/java/org/jahia/taglibs=
/html/menus/NavMenuTag.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-INCLUD=
E-TAG-BRANCH/core/src/java/org/jahia/taglibs/html/menus/NavMenuTag.java&rev=
=3D19372&repname=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/JAHIA-INCLUDE-TAG-BRANCH/core/src/java/org/jahia/taglibs/html/=
menus/NavMenuTag.java (original)
+++ branches/JAHIA-INCLUDE-TAG-BRANCH/core/src/java/org/jahia/taglibs/html/=
menus/NavMenuTag.java Fri Dec 14 16:00:29 2007
@@ -54,7 +54,6 @@
     private String containerListNamePostFix =3D null;
     private String containerNamePostFix =3D null;
     private String containerListLabel =3D null;
-    private String menuStyle =3D null ;
     private int reqLevel =3D -1;
     private boolean editMode;
 =

@@ -104,10 +103,6 @@
         this.containerListLabel =3D containerListLabel;
     }
 =

-    public void setMenuStyle(String menuStyle) {
-        this.menuStyle =3D menuStyle;
-    }
-
     public int doStartTag() {
         final RequestBean requestBean =3D (RequestBean) pageContext.findAt=
tribute("currentRequest");
         ServletRequest request =3D pageContext.getRequest();
@@ -131,13 +126,20 @@
             containerListName =3D "default_navLinkList" ;
             pageFieldName =3D "default_navLink" ;
 =

-            // declare the container list and the page field
-            jData.containers().declareField(containerListName, pageFieldNa=
me, pageFieldName, FieldTypes.PAGE, "");
-            Vector linkField =3D new Vector() ;
-            linkField.add(pageFieldName) ;
-            jData.containers().declareContainer(containerListName, contain=
erListName, linkField);
+            // declare the container list and the page field if it has not=
 already been
+            try {
+                jData.containers().declareField(containerListName, pageFie=
ldName, pageFieldName, FieldTypes.PAGE, "");
+                Vector<String> linkField =3D new Vector<String>() ;
+                linkField.add(pageFieldName) ;
+                jData.containers().declareContainer(containerListName, con=
tainerListName, linkField);
+            } catch (JahiaException e) {
+                logger.debug("Container List " + containerListName + " alr=
eady declared, no need to worry") ;
+            }
+
         } else if (containerListName !=3D null ^ pageFieldName !=3D null) {
-            throw new JahiaException("You must either declare both contain=
er list and page field or none", "Unable to create the navmenu container li=
st", JahiaException.TEMPLATE_SERVICE_ERROR, JahiaException.ERROR_SEVERITY) ;
+            throw new JahiaException("You must either declare both contain=
er list and page field or none",
+                    "Unable to create the navmenu container list", JahiaEx=
ception.TEMPLATE_SERVICE_ERROR,
+                    JahiaException.ERROR_SEVERITY) ;
         }
     }
 =

@@ -190,29 +192,31 @@
                 if (link !=3D null) {
                     if (!hide) {
                         if (begin) {
-                            if (menuStyle =3D=3D null) {
+                            if (cssClassName =3D=3D null) {
                                 out.print("<ul>");
                             } else {
-                                out.print(new StringBuffer().append("<ul c=
lass=3D'").append(menuStyle).append("'>").toString());
+                                out.print(new StringBuffer().append("<ul c=
lass=3D\"").append(cssClassName).append("\">").toString());
                             }
                             begin =3D false;
                         }
-                        String cssClass =3D " class=3D'navmenu_standard'";
+                        String cssClass =3D " class=3D\"item standard\"";
                         if (jData.gui().isPageInPath(link.getID()))
                             if (level =3D=3D reqLevel - 1) {
-                                cssClass =3D " class=3D'navmenu_selected'";
+                                cssClass =3D " class=3D\"item selected\"";
                             } else {
-                                cssClass =3D " class=3D'navmenu_inpath'";
+                                cssClass =3D " class=3D\"item inpath\"";
                             }
                         StringBuffer sbf =3D new StringBuffer();
-                        sbf.append("<li").append(cssClass).append("><a hre=
f=3D'").append(link.getURL(jParams)).append("'");
-                        sbf.append(" title=3D'").append(link.getTitle()).a=
ppend("' >");
-                        sbf.append("<span>").append(link.getHighLightDiffT=
itle(jParams)).append("</span></a>");
+                        sbf.append("<li").append(cssClass).append("><div><=
div>\n") ;
+                        sbf.append("<a href=3D\"").append(link.getURL(jPar=
ams)).append("\"");
+                        sbf.append(" title=3D\"").append(link.getTitle()).=
append("\">");
+                        sbf.append(link.getHighLightDiffTitle(jParams)).ap=
pend("</a>");
                         out.println(sbf.toString());
                         if (editMode) {
                             jData.gui().html().drawBeginActionMenu(new Con=
tainerBean(linkContainer, jParams),
                                     null, null, false, "", bundleKey, null=
, out);
                         }
+                        out.println("</div></div>") ;
                     }
 =

                     // displays sub links
@@ -229,7 +233,7 @@
                             begin =3D false;
                         }
                         out.println("<li>");
-                        out.print("<a href=3D''>n.d.</a>");
+                        out.print("<a>n.d.</a>");
                         jData.gui().html().drawBeginActionMenu(new Contain=
erBean(linkContainer, jParams),
                                 null, null, false, containerNamePostFix, b=
undleKey, "add.navigationLinks", out);
                         out.println("</li>");
@@ -238,19 +242,19 @@
             }
         }
 =

-        if (editMode && level >=3D reqLevel-1) { // new page can only be c=
reated as a sibling or a child
-            if (begin) {                       // to the current page (vis=
ual coherence limitation)
-                if (menuStyle =3D=3D null) {
+        if (editMode && (level >=3D reqLevel-1 || onlyTop)) { // new page =
can only be created as a sibling or a child
+            if (begin) {                                   // to the curre=
nt or the top page (visual coherence limitation)
+                if (cssClassName =3D=3D null) {
                     out.print("<ul>");
                 } else {
-                    out.print(new StringBuffer().append("<ul class=3D'").a=
ppend(menuStyle).append("'>").toString());
+                    out.print(new StringBuffer().append("<ul class=3D\"").=
append(cssClassName).append("\">").toString());
                 }
                 begin =3D false ;
             }
-            out.print("<li>");
+            out.print("<li><div>div>");
             jData.gui().html().drawBeginActionMenu(new ContainerListBean(l=
inkContainerList, jParams),
                     null, null, false, containerListNamePostFix, bundleKey=
, containerListLabel, out);
-            out.println("</li>");
+            out.println("</div></div></li>");
         }
 =

         if (!begin && !hide) {

Modified: branches/JAHIA-INCLUDE-TAG-BRANCH/core/src/webapp/WEB-INF/etc/tag=
libs/jahia-components.tld
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-INCLUD=
E-TAG-BRANCH/core/src/webapp/WEB-INF/etc/taglibs/jahia-components.tld&rev=
=3D19372&repname=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/JAHIA-INCLUDE-TAG-BRANCH/core/src/webapp/WEB-INF/etc/taglibs/j=
ahia-components.tld (original)
+++ branches/JAHIA-INCLUDE-TAG-BRANCH/core/src/webapp/WEB-INF/etc/taglibs/j=
ahia-components.tld Fri Dec 14 16:00:29 2007
@@ -26,6 +26,16 @@
             <rtexprvalue>true</rtexprvalue>
         </attribute>
         <attribute>
+            <name>hideBeginPages</name>
+            <required>false</required>
+            <rtexprvalue>true</rtexprvalue>
+        </attribute>
+        <attribute>
+            <name>hideEndPages</name>
+            <required>false</required>
+            <rtexprvalue>true</rtexprvalue>
+        </attribute>
+        <attribute>
             <name>maxchar</name>
             <required>false</required>
             <rtexprvalue>true</rtexprvalue>
@@ -41,7 +51,6 @@
         <name>navMenu</name>
         <tagclass>org.jahia.taglibs.html.menus.NavMenuTag</tagclass>
         <info>display a navigation menu</info>
-
         <attribute>
             <name>containerListName</name>
             <required>false</required>

_______________________________________________
cvs_list mailing list
[email protected]
http://lists.jahia.org/cgi-bin/mailman/listinfo/cvs_list

Reply via email to