Author: rfelden
Date: Fri Nov 16 14:43:37 2007
New Revision: 19188
URL: https://svndev.jahia.net/websvn/listing.php?sc=3D1&rev=3D19188&repname=
=3Djahia
Log:
Navigation menu updated
New "current page path" tag
Tag library "jahia-components.tld" updated
Added:
branches/JAHIA-INCLUDE-TAG-BRANCH/core/src/java/org/jahia/taglibs/html/=
links/CurrentPagePathTag.java
Modified:
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
Added: branches/JAHIA-INCLUDE-TAG-BRANCH/core/src/java/org/jahia/taglibs/ht=
ml/links/CurrentPagePathTag.java
URL: https://svndev.jahia.net/websvn/filedetails.php?path=3D/branches/JAHIA=
-INCLUDE-TAG-BRANCH/core/src/java/org/jahia/taglibs/html/links/CurrentPageP=
athTag.java&rev=3D19188&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 (added)
+++ branches/JAHIA-INCLUDE-TAG-BRANCH/core/src/java/org/jahia/taglibs/html/=
links/CurrentPagePathTag.java Fri Nov 16 14:43:37 2007
@@ -0,0 +1,167 @@
+/*
+ * Copyright 2002-2006 Jahia Ltd
+ *
+ * Licensed under the JAHIA COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (J=
CDDL), =
+ * Version 1.0 (the "License"), or (at your option) any later version; you=
may =
+ * not use this file except in compliance with the License. You should hav=
e =
+ * received a copy of the License along with this program; if not, you may=
obtain =
+ * a copy of the License at =
+ *
+ * http://www.jahia.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software =
+ * distributed under the License is distributed on an "AS IS" BASIS, =
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied=
. =
+ * See the License for the specific language governing permissions and =
+ * limitations under the License.
+ */package org.jahia.taglibs.html.links;
+
+import org.jahia.data.JahiaData;
+import org.jahia.exceptions.JahiaException;
+import org.jahia.gui.GuiBean;
+import org.jahia.params.ProcessingContext;
+import org.jahia.services.pages.ContentPage;
+import org.jahia.taglibs.AbstractJahiaTag;
+import org.jahia.utils.JahiaConsole;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.JspWriter;
+import java.io.IOException;
+import java.util.Enumeration;
+
+/**
+ * Class CurrentPagePathTag : returns the formated path of the current page
+ *
+ * @author rfelden
+ *
+ *
+ * jsp:tag name=3D"currentPagePath" body-content=3D"empty"
+ * description=3D"Returns the formatted path of the current page.
+ *
+ * <p><attriInfo>Basically, the output is a list of hyperlinked page title=
s.
+ *
+ * </attriInfo>"
+ */
+public class CurrentPagePathTag extends AbstractJahiaTag {
+
+ private String style =3D "pagePath";
+ private int maxchar =3D 0;
+ private String unreadablePages =3D "ellipsis" ;
+
+ /**
+ * jsp:attribute name=3D"style" required=3D"false" rtexprvalue=3D"true"
+ * description=3D"the CSS style name to use.
+ * <p><attriInfo>Defaulted to no CSS style at all.
+ * </attriInfo>"
+ */
+ public void setStyle (String aStyle) {
+ this.style =3D aStyle;
+ }
+
+ /**
+ * jsp:attribute name=3D"maxchar" required=3D"false" rtexprvalue=3D"tr=
ue"
+ * description=3D"maximum length of each displayed page title.
+ * <p><attriInfo>Cuts and prepares the page title string for display t=
o a specified length, by
+ * appending "..." characters at the end and encoding the string for
+ * HTML output (by replacing all non ISO-8859-1 characters with \&#XX;
+ * encoding).
+ * </attriInfo>"
+ */
+ public void setMaxchar (int maxChar) {
+ this.maxchar =3D maxChar;
+ }
+
+ /**
+ * jsp:attribute name=3D"unreadablePages" required=3D"false" rtexprva=
lue=3D"true"
+ * description=3D"what to display when a page is unreachable
+ * <p><attriInfo>e"llipsis" (default) means that a sequel of unreacha=
ble pages will be replaced
+ * by a single "...", "display means that everything will be displaye=
d and if the title is not
+ * available there will be "n.d." instead. Any other value will resul=
t in no display at all.
+ * </attriInfo>"
+ */
+ public void setUnreadablePages(String unreadableDisplay) {
+ this.unreadablePages =3D unreadableDisplay;
+ }
+
+ public int doStartTag () {
+
+ HttpServletRequest request =3D (HttpServletRequest) pageContext.
+ getRequest();
+ JahiaData jData =3D (JahiaData) request.getAttribute(
+ "org.jahia.data.JahiaData");
+ try {
+ ProcessingContext jParams =3D jData.getProcessingContext();
+ Enumeration thePath =3D jData.page().getContentPagePath(jParam=
s.
+ getOperationMode(), jParams.getUser());
+ 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(=
);
+ if (thePage !=3D null) {
+ if (!thePage.isAclSameAsParent()) {
+ isAccessible =3D thePage.checkReadAccess(jParams.g=
etUser()) ;
+ unreachablePageDisplayed =3D false ;
+ }
+ Integer currentPageState =3D (Integer)thePage.getLangu=
agesStates().get(jParams.getLocale().toString()) ;
+ if (pageState =3D=3D null || !pageState.equals(current=
PageState)) {
+ pageState =3D currentPageState ;
+ unreachablePageDisplayed =3D false ;
+ }
+
+
+ final String title =3D thePage.getTitle(jParams);
+ if (title !=3D null && isAccessible) {
+ path.append("<li><a");
+ path.append(" href=3D'");
+ path.append(thePage.getURL(jData.getProcessingCont=
ext()));
+ path.append("'>");
+ if (this.maxchar =3D=3D 0) {
+ path.append(title) ;
+ } else {
+ path.append(GuiBean.glueTitle(title, this.maxc=
har));
+ }
+ path.append("</a></li>\n");
+ } else {
+ if (unreadablePages.equals("display")) {
+ path.append("<li><a>") ;
+ path.append(title !=3D null ? title : "n.d.") ;
+ path.append("</a></li>") ;
+ } else if (unreadablePages.equals("ellipsis") && !=
unreachablePageDisplayed) {
+ path.append("<li><a>...</a></li>") ;
+ unreachablePageDisplayed =3D true ;
+ } else {
+ // don't display anything
+ }
+ }
+
+ }
+ }
+ JspWriter out =3D pageContext.getOut();
+ path.append("</ul>\n") ;
+ out.print(path.toString());
+
+ } catch (IOException ioe) {
+ JahiaConsole.println("CurrentPagePathTag: doStartTag ",
+ ioe.toString());
+ } catch (JahiaException je) {
+ JahiaConsole.println("CurrentPagePathTag: doStartTag ", je.toS=
tring());
+ }
+ return SKIP_BODY;
+ }
+
+ public int doEndTag ()
+ throws JspException {
+ // let's reinitialize the tag variables to allow tag object reuse =
in
+ // pooling.
+ style =3D "pagePath";
+ maxchar =3D 0;
+ unreadablePages =3D "ellipsis" ;
+ return EVAL_PAGE;
+ }
+
+
+}
\ No newline at end of file
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=
=3D19188&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 Nov 16 14:43:37 2007
@@ -28,84 +28,15 @@
import org.jahia.gui.GuiBean;
import org.jahia.params.ProcessingContext;
import org.jahia.services.pages.JahiaPage;
+import org.jahia.taglibs.AbstractJahiaTag;
=
import javax.servlet.ServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
-import javax.servlet.jsp.tagext.BodyTagSupport;
import java.io.IOException;
import java.util.Enumeration;
=
-/**
- * <p>Title: Tag that generates the HTML for the action menu GUI interface=
</p>
- * <p>Description: this tag is for the moment not very generic but it is
- * here to help template developers to include easily all the actions for
- * a given content object without having to know all the possible actions =
for
- * a specific content object. It also generates the GUI for the locking
- * information.</p>
- * <p>Warning: this tag supposses the use of some Javascript functions that
- * must be declared in the page for this menu to work !</p>
- * <p>Copyright: Copyright (c) 2002</p>
- * <p>Company: Jahia Ltd</p>
- *
- * @author Serge Huber
- * @version 1.0
- * <p/>
- * jsp:tag name=3D"actionMenu" body-content=3D"tagdependent"
- * description=3D"Displays the GUI interface for actions on the s=
elected Jahia content object.
- * <p/>
- * <p><attriInfo>This tag is for the moment not very generic but =
it is
- * here to help template developers to easily include all the act=
ions for
- * a given content object without having to know all the possible=
actions for
- * a specific content object.
- * <p>It also generates the GUI for the workflow information.
- * Content objects may go through intermediate stages of workflow=
before being published live. Usually a
- * new content object will first go to a \"staging\" state, then =
a \"waiting for validation\" state, and finally
- * to a \"live\" state if it was accepted, or back to \"staging\"=
state if it was refused.
- * <p>It also generates the GUI for the locking information.
- * Content objects are locked to prevent editing either if anothe=
r user is
- * currently already modifying the same object, or if the object =
or one of it's ancestors is in the \"waiting for validation\"
- * workflow state.
- * <p>If the user is not in Edit mode, the GUI interface isn't di=
splay.</p>
- * <p>Warning: this tag assumes the use of some Javascript functi=
ons pre-declared
- * in the page for this menu to work !</p>
- * <p/>
- * <p><b>Example :</b>
- * <p/>
- * <p/>
- * <p/>
- * <content:containerList name=3D\"myContainer\" id=3D\"myCont=
ainerList\"> <br>
- * <content:container id=3D\"myContainer\"=
> <br>
- * <b> <jahiaHtml:actionMenu=
name=3D\"myContainer\" namePostFix=3D\"\" resourceBundle=3D\"jahiatemplate=
s.Phal_litemplates\"> </b> <br>
- * <content=
:textField name=3D\"myAuthor\" defaultValue=3D\"\" diffActive=3D\"true\"/&g=
t; | <br>
- * <content=
:textField name=3D\"myTel\" defaultValue=3D\"\" diffActive=3D\"true\"/>&=
lt;br/> <br>
- * <br>
- * </jahiaHtml:actionMenu>=
; <br>
- * </content:container> <br>
- * <logic:equal name=3D\"myContainerList\" p=
roperty=3D\"size\" value=3D\"0\"> <br>
- * <content:addContainerURL =
id=3D\"addmyContainerURL\" display=3D\"false\"/> <br>
- * <logic:present name=3D\"a=
ddmyContainerURL\"> <br>
- * <br/>&=
lt;a href=3D\"<bean:write name=3D'addmyContainerURL'/>\">add</a=
> <br>
- * </logic:present> <br>
- * </logic:equal> <br>
- * </content:containerList> <br>
- * <br> ... <br>
- * <content:applicationField name=3D\"applicationTest\" id=3D\=
"applicationBean\" /> <br>
- * <logic:present name=3D\"applicationBean\"> <br>
- * <logic:present name=3D\"applicationBean\" p=
roperty=3D\"object\"> <br>
- * <bean:define name=3D\"appli=
cationBean\" property=3D\"object\" id=3D\"portletWindowBean\" /> <br>
- * <jahiaHtmlportletModes name=
=3D\"portletWindowBean\" /> <br>
- * <jahiaHtml:windowStates nam=
e=3D\"portletWindowBean\" /> <br>
- * </logic:present> <br>
- * </logic:present> <br>
- * <br /> <br>
- * <b><jahiaHtml:actionMenu name=3D\"applicationBean\" namePos=
tFix=3D\"\"
- * resourceBundle=3D\"jahiatemplates.Corporate_portal_templates\"=
useFieldSet=3D\"false\"/></b> <br>
- * <p/>
- * </attriInfo>"
- */
-
-public class NavMenuTag extends BodyTagSupport {
+public class NavMenuTag extends AbstractJahiaTag {
=
private static final Logger logger =3D Logger.getLogger(NavMenuTag.cla=
ss);
=
@@ -121,100 +52,60 @@
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;
=
- public NavMenuTag() {
- }
=
- public String getContainerListName() {
- return containerListName;
- }
=
public void setContainerListName(String containerListName) {
this.containerListName =3D containerListName;
}
-
- public String getPageFieldName() {
- return pageFieldName;
- }
-
+ =
public void setPageFieldName(String pageFieldName) {
this.pageFieldName =3D pageFieldName;
}
=
- public int getStartLevel() {
- return startLevel;
- }
-
public void setStartLevel(int startLevel) {
this.startLevel =3D startLevel;
}
=
- public int getMaxDepth() {
- return maxDepth;
- }
-
public void setMaxDepth(int maxDepth) {
this.maxDepth =3D maxDepth;
}
=
- public int getDispNumber() {
- return dispNumber;
- }
-
public void setDispNumber(int dispNumber) {
this.dispNumber =3D dispNumber;
}
=
- public boolean isExpandOnlyPageInPath() {
- return expandOnlyPageInPath;
- }
-
public void setExpandOnlyPageInPath(boolean expandOnlyPageInPath) {
this.expandOnlyPageInPath =3D expandOnlyPageInPath;
}
=
- public boolean isOnlyTop() {
- return onlyTop;
- }
-
public void setOnlyTop(boolean onlyTop) {
this.onlyTop =3D onlyTop;
}
=
- public String getBundleKey() {
- return bundleKey;
- }
-
public void setBundleKey(String bundleKey) {
this.bundleKey =3D bundleKey;
}
=
- public String getContainerListNamePostFix() {
- return containerListNamePostFix;
- }
-
public void setContainerListNamePostFix(String containerListNamePostFi=
x) {
this.containerListNamePostFix =3D containerListNamePostFix;
}
=
- public String getContainerNamePostFix() {
- return containerNamePostFix;
- }
-
public void setContainerNamePostFix(String containerNamePostFix) {
this.containerNamePostFix =3D containerNamePostFix;
}
=
- public String getContainerListLabel() {
- return containerListLabel;
- }
-
public void setContainerListLabel(String containerListLabel) {
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();
@@ -224,14 +115,16 @@
defaultSettings(jData.gui());
getPageSubTree(jData, jData.gui().getLevelID(startLevel), star=
tLevel);
} catch (JahiaException e) {
- logger.error("Exception rendering the menu", e);
+ logger.error("JahiaException rendering the menu", e);
} catch (IOException e) {
logger.error("IOException rendering the menu", e);
}
- return EVAL_BODY_BUFFERED;
+ return SKIP_BODY;
}
=
private void defaultSettings(GuiBean gui) throws JahiaException {
+
+ // set the level of the page where the request is coming from
reqLevel =3D gui.getLevel();
logger.debug("reqLevel =3D " + reqLevel);
// if the startLevel parameter is not specified, try to find a sim=
ilar
@@ -251,7 +144,10 @@
}
=
private void getPageSubTree(JahiaData jData, int pageId, int level) th=
rows JahiaException, IOException {
- if (pageId =3D=3D -1) return; // TODO handle this case better
+ if (pageId < 1) {
+ logger.error("Incorrect page ID: " + pageId);
+ throw new IllegalArgumentException("attribute pageID cannot be=
< 1 (is " + pageId + ")");
+ }
=
JspWriter out =3D pageContext.getOut();
=
@@ -275,7 +171,11 @@
if (link !=3D null) {
if (!hide) {
if (begin) {
- out.println("<ul>");
+ if (menuStyle =3D=3D null) {
+ out.print("<ul>");
+ } else {
+ out.print(new StringBuffer().append("<ul c=
lass=3D'").append(menuStyle).append("'>").toString());
+ }
begin =3D false;
}
String cssClass =3D " class=3D'navmenu_standard'";
@@ -302,7 +202,7 @@
}
if (!hide) out.println("</li>");
=
- } else { // TODO OOOOOO
+ } else {
// no navlink
if (editMode) {
if (begin) {
@@ -310,7 +210,7 @@
begin =3D false;
}
out.println("<li>");
- out.print("<a href=3D'' class=3D'link" + level + "=
'>n.d.</a>");
+ out.print("<a href=3D''>n.d.</a>");
jData.gui().html().drawBeginActionMenu(new Contain=
erBean(linkContainer, jParams),
null, null, false, containerNamePostFix, b=
undleKey, "add.navigationLinks", out);
out.println("</li>");
@@ -321,12 +221,17 @@
=
if (editMode) {
if (begin) {
- out.print(new StringBuffer().append("<ul class=3D'nav").ap=
pend((level =3D=3D 1) ? "2edit" : "3").append("'>").toString());
+ if (menuStyle =3D=3D null) {
+ out.print("<ul>");
+ } else {
+ out.print(new StringBuffer().append("<ul class=3D'").a=
ppend(menuStyle).append("'>").toString());
+ }
+ begin =3D false ;
}
out.print("<li>");
- jData.gui().html().drawBeginActionMenu(new ContainerListBean(l=
inkContainerList, jData.params()),
+ jData.gui().html().drawBeginActionMenu(new ContainerListBean(l=
inkContainerList, jParams),
null, null, false, containerListNamePostFix, bundleKey=
, containerListLabel, out);
- out.println(new StringBuffer("</li>").append((begin ? "</ul>" =
: "")).toString());
+ out.println("</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=
=3D19188&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 Nov 16 14:43:37 2007
@@ -18,7 +18,28 @@
</info>
=
<tag>
- <name>navmenu</name>
+ <name>currentPagePath</name>
+ <tagclass>org.jahia.taglibs.html.links.CurrentPagePathTag</tagclas=
s>
+ <info>Returns the formatted path of the current page</info>
+ <attribute>
+ <name>style</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
+ <attribute>
+ <name>maxchar</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
+ <attribute>
+ <name>unreadablePages</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
+ </tag>
+
+ <tag>
+ <name>navMenu</name>
<tagclass>org.jahia.taglibs.html.menus.NavMenuTag</tagclass>
<info>display a navigation menu</info>
=
_______________________________________________
cvs_list mailing list
[email protected]
http://lists.jahia.org/cgi-bin/mailman/listinfo/cvs_list