KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > jsp > CmsJspNavBuilder


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src/org/opencms/jsp/CmsJspNavBuilder.java,v $
3  * Date : $Date: 2005/06/28 13:30:16 $
4  * Version: $Revision: 1.23 $
5  *
6  * This library is part of OpenCms -
7  * the Open Source Content Mananagement System
8  *
9  * Copyright (c) 2005 Alkacon Software GmbH (http://www.alkacon.com)
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2.1 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * Lesser General Public License for more details.
20  *
21  * For further information about Alkacon Software GmbH, please see the
22  * company website: http://www.alkacon.com
23  *
24  * For further information about OpenCms, please see the
25  * project website: http://www.opencms.org
26  *
27  * You should have received a copy of the GNU Lesser General Public
28  * License along with this library; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */

31
32 package org.opencms.jsp;
33
34 import org.opencms.file.CmsObject;
35 import org.opencms.file.CmsProperty;
36 import org.opencms.file.CmsPropertyDefinition;
37 import org.opencms.file.CmsResource;
38 import org.opencms.file.CmsResourceFilter;
39 import org.opencms.main.CmsException;
40 import org.opencms.main.CmsLog;
41 import org.opencms.main.OpenCms;
42
43 import java.util.ArrayList JavaDoc;
44 import java.util.Collections JavaDoc;
45 import java.util.Iterator JavaDoc;
46 import java.util.List JavaDoc;
47
48 import org.apache.commons.logging.Log;
49
50 /**
51  * Bean to provide a convenient way to build navigation structures based on the
52  * <code>{@link org.opencms.jsp.CmsJspNavElement}</code>.<p>
53  *
54  * Use this together with the <code>{@link org.opencms.jsp.CmsJspActionElement}</code>
55  * to obtain navigation information based on the current users permissions.
56  * For example, use <code>{@link #getNavigationForFolder(String)}</code> and pass the
57  * value of the current OpenCms user context uri obtained
58  * from <code>{@link org.opencms.file.CmsRequestContext#getUri()}</code> as argument to obtain a list
59  * of all items in the navigation of the current folder. Then use a simple scriptlet to
60  * iterate over these items and create a HTML navigation.<p>
61  *
62  * @author Alexander Kandzior
63  *
64  * @version $Revision: 1.23 $
65  *
66  * @since 6.0.0
67  *
68  * @see org.opencms.jsp.CmsJspNavElement
69  */

70 public class CmsJspNavBuilder {
71
72     /**
73      * Internal helper class to get a title - comparable CmsResource for channels.<p>
74      */

75     private static class ResourceTitleContainer implements Comparable JavaDoc {
76
77         /** The resource. */
78         protected CmsResource m_res;
79
80         /** The title of the resource. */
81         protected String JavaDoc m_title;
82
83         /**
84          * @param cms context provider for the current request
85          * @param res the resource to compare
86          */

87         ResourceTitleContainer(CmsObject cms, CmsResource res) {
88
89             m_res = res;
90             try {
91                 cms.getRequestContext().saveSiteRoot();
92                 cms.getRequestContext().setSiteRoot(CmsResource.VFS_FOLDER_CHANNELS);
93                 m_title = cms.readPropertyObject(
94                     res,
95                     org.opencms.file.CmsPropertyDefinition.PROPERTY_TITLE,
96                     false).getValue();
97                 cms.getRequestContext().restoreSiteRoot();
98             } catch (Exception JavaDoc e) {
99                 m_title = "";
100             }
101         }
102
103         /**
104          * @see java.lang.Comparable#compareTo(Object)
105          */

106         public int compareTo(Object JavaDoc obj) {
107
108             if (obj == this) {
109                 return 0;
110             }
111             if (obj instanceof ResourceTitleContainer) {
112                 if (m_title == null) {
113                     return 1;
114                 }
115                 return (m_title.toLowerCase().compareTo(((ResourceTitleContainer)obj).m_title.toLowerCase()));
116             }
117             return 0;
118         }
119     }
120
121     /** The log object for this class. */
122     private static final Log LOG = CmsLog.getLog(CmsJspNavBuilder.class);
123
124     // Member variables
125
private CmsObject m_cms;
126     private String JavaDoc m_requestUri;
127     private String JavaDoc m_requestUriFolder;
128
129     /**
130      * Empty constructor, so that this bean can be initialized from a JSP.<p>
131      *
132      * @see java.lang.Object#Object()
133      */

134     public CmsJspNavBuilder() {
135
136         // empty
137
}
138
139     /**
140      * Default constructor.<p>
141      *
142      * @param cms context provider for the current request
143      */

144     public CmsJspNavBuilder(CmsObject cms) {
145
146         init(cms);
147     }
148
149     /**
150      * Returns all subfolders of a channel, or an empty array if
151      * the folder does not exist or has no subfolders.<p>
152      *
153      * @param cms context provider for the current request
154      * @param channel the channel to look for subfolders in
155      * @return an unsorted list of CmsResources
156      */

157     public static List JavaDoc getChannelSubFolders(CmsObject cms, String JavaDoc channel) {
158
159         if (!channel.startsWith("/")) {
160             channel = "/" + channel;
161         }
162         if (!channel.endsWith("/")) {
163             channel += "/";
164         }
165
166         // Now read all subchannels of this channel
167
List JavaDoc subChannels = new ArrayList JavaDoc();
168         cms.getRequestContext().saveSiteRoot();
169         try {
170             cms.getRequestContext().setSiteRoot(CmsResource.VFS_FOLDER_CHANNELS);
171             subChannels = cms.getSubFolders(channel);
172         } catch (CmsException e) {
173             if (LOG.isErrorEnabled()) {
174                 // will be localized if the CmsException was constructoed localized.
175
LOG.error(e.getLocalizedMessage());
176             }
177         } finally {
178             cms.getRequestContext().restoreSiteRoot();
179         }
180
181         // Create an ArrayList out of the Vector
182
java.util.ArrayList JavaDoc list = new java.util.ArrayList JavaDoc(subChannels.size());
183         list.addAll(subChannels);
184         return list;
185     }
186
187     /**
188      * Returns all subfolders of a sub channel that has
189      * the given parent channel, or an empty array if
190      * that combination does not exist or has no subfolders.<p>
191      *
192      * @param cms context provider for the current request
193      * @param parentChannel the parent channel
194      * @param subChannel the sub channel
195      * @return an unsorted list of CmsResources
196      */

197     public static List JavaDoc getChannelSubFolders(CmsObject cms, String JavaDoc parentChannel, String JavaDoc subChannel) {
198
199         String JavaDoc channel = null;
200         if (subChannel == null) {
201             subChannel = "";
202         } else if (subChannel.startsWith("/")) {
203             subChannel = subChannel.substring(1);
204         }
205         if (parentChannel == null) {
206             parentChannel = "";
207         }
208         if (parentChannel.endsWith("/")) {
209             channel = parentChannel + subChannel;
210         } else {
211             channel = parentChannel + "/" + subChannel;
212         }
213         return getChannelSubFolders(cms, channel);
214     }
215
216     /**
217      * Returns all subfolders of a channel,
218      * sorted by "Title" property ascending, or an empty array if
219      * the folder does not exist or has no subfolders.
220      *
221      * @param cms context provider for the current request
222      * @param channel the parent channel
223      * @param subChannel the sub channel
224      * @return a sorted list of CmsResources
225      */

226     public static List JavaDoc getChannelSubFoldersSortTitleAsc(CmsObject cms, String JavaDoc channel, String JavaDoc subChannel) {
227
228         List JavaDoc subChannels = getChannelSubFolders(cms, channel, subChannel);
229         // Create an ArrayList out of the Vector
230
ArrayList JavaDoc tmpList = new java.util.ArrayList JavaDoc(subChannels.size());
231         for (int i = 0; i < subChannels.size(); i++) {
232             CmsResource res = (CmsResource)subChannels.get(i);
233             ResourceTitleContainer container = new ResourceTitleContainer(cms, res);
234             tmpList.add(container);
235         }
236         Collections.sort(tmpList);
237         java.util.ArrayList JavaDoc list = new java.util.ArrayList JavaDoc(subChannels.size());
238         for (int i = 0; i < tmpList.size(); i++) {
239             ResourceTitleContainer container = (ResourceTitleContainer)tmpList.get(i);
240             list.add(container.m_res);
241         }
242         return list;
243     }
244
245     /**
246      * Returns the full name (including vfs path) of the default file for this nav element
247      * or <code>null</code> if the nav element is not a folder.<p>
248      *
249      * The default file of a folder is determined by the value of the property
250      * <code>default-file</code> or the systemwide property setting.
251      *
252      * @param cms the cms object
253      * @param folder full name of the folder
254      *
255      * @return the name of the default file
256      */

257     public static String JavaDoc getDefaultFile(CmsObject cms, String JavaDoc folder) {
258
259         if (folder.endsWith("/")) {
260             List JavaDoc defaultFolders = new ArrayList JavaDoc();
261             try {
262                 CmsProperty p = cms.readPropertyObject(folder, CmsPropertyDefinition.PROPERTY_DEFAULT_FILE, false);
263                 defaultFolders.add(p.getValue());
264             } catch (CmsException exc) {
265                 // noop
266
}
267
268             defaultFolders.addAll(OpenCms.getDefaultFiles());
269
270             for (Iterator JavaDoc i = defaultFolders.iterator(); i.hasNext();) {
271                 String JavaDoc defaultName = (String JavaDoc)i.next();
272                 if (cms.existsResource(folder + defaultName)) {
273                     return folder + defaultName;
274                 }
275             }
276
277             return folder;
278         }
279
280         return null;
281     }
282
283     /**
284      * Collect all navigation elements from the files in the given folder,
285      * navigation elements are of class CmsJspNavElement.<p>
286      *
287      * @param cms context provider for the current request
288      * @param folder the selected folder
289      * @return a sorted (ascending to nav position) ArrayList of navigation elements
290      */

291     public static List JavaDoc getNavigationForFolder(CmsObject cms, String JavaDoc folder) {
292
293         folder = CmsResource.getFolderPath(folder);
294         List JavaDoc result = new ArrayList JavaDoc();
295
296         List JavaDoc resources;
297         try {
298             resources = cms.getResourcesInFolder(folder, CmsResourceFilter.DEFAULT);
299         } catch (Exception JavaDoc e) {
300             return Collections.EMPTY_LIST;
301         }
302
303         for (int i = 0; i < resources.size(); i++) {
304             CmsResource r = (CmsResource)resources.get(i);
305             CmsJspNavElement element = getNavigationForResource(cms, cms.getSitePath(r));
306             if ((element != null) && element.isInNavigation()) {
307                 result.add(element);
308             }
309         }
310         Collections.sort(result);
311         return result;
312     }
313
314     /**
315      * Build a navigation for the folder that is either minus levels up
316      * from the given folder, or that is plus levels down from the
317      * root folder towards the given folder.<p>
318      *
319      * If level is set to zero the root folder is used by convention.<p>
320      *
321      * @param cms context provider for the current request
322      * @param folder the selected folder
323      * @param level if negative, walk this many levels up, if positive, walk this many
324      * levels down from root folder
325      * @return a sorted (ascending to nav position) ArrayList of navigation elements
326      */

327     public static List JavaDoc getNavigationForFolder(CmsObject cms, String JavaDoc folder, int level) {
328
329         folder = CmsResource.getFolderPath(folder);
330         // If level is one just use root folder
331
if (level == 0) {
332             return getNavigationForFolder(cms, "/");
333         }
334         String JavaDoc navfolder = CmsResource.getPathPart(folder, level);
335         // If navfolder found use it to build navigation
336
if (navfolder != null) {
337             return getNavigationForFolder(cms, navfolder);
338         }
339         // Nothing found, return empty list
340
return Collections.EMPTY_LIST;
341     }
342
343     /**
344      * Returns a CmsJspNavElement for the named resource.<p>
345      *
346      * @param cms context provider for the current request
347      * @param resource the resource name to get the nav information for,
348      * must be a full path name, e.g. "/docs/index.html".
349      * @return a CmsJspNavElement for the given resource
350      */

351     public static CmsJspNavElement getNavigationForResource(CmsObject cms, String JavaDoc resource) {
352
353         List JavaDoc properties;
354         try {
355             properties = cms.readPropertyObjects(resource, false);
356         } catch (Exception JavaDoc e) {
357             return null;
358         }
359         int level = CmsResource.getPathLevel(resource);
360         if (resource.endsWith("/")) {
361             level--;
362         }
363         return new CmsJspNavElement(resource, CmsProperty.toMap(properties), level);
364     }
365
366     /**
367      * Builds a tree navigation for the folders between the provided start and end level.<p>
368      *
369      * A tree navigation includes all nav elements that are required to display a tree structure.
370      * However, the data structure is a simple list.
371      * Each of the nav elements in the list has the {@link CmsJspNavElement#getNavTreeLevel()} set
372      * to the level it belongs to. Use this information to distinguish between the nav levels.<p>
373      *
374      * @param cms context provider for the current request
375      * @param folder the selected folder
376      * @param startlevel the start level
377      * @param endlevel the end level
378      * @return a sorted list of nav elements with the nav tree level property set
379      */

380     public static List JavaDoc getNavigationTreeForFolder(CmsObject cms, String JavaDoc folder, int startlevel, int endlevel) {
381
382         folder = CmsResource.getFolderPath(folder);
383         // Make sure start and end level make sense
384
if (endlevel < startlevel) {
385             return Collections.EMPTY_LIST;
386         }
387         int currentlevel = CmsResource.getPathLevel(folder);
388         if (currentlevel < endlevel) {
389             endlevel = currentlevel;
390         }
391         if (startlevel == endlevel) {
392             return getNavigationForFolder(cms, CmsResource.getPathPart(folder, startlevel), startlevel);
393         }
394
395         ArrayList JavaDoc result = new ArrayList JavaDoc();
396         float parentcount = 0;
397
398         for (int i = startlevel; i <= endlevel; i++) {
399             String JavaDoc currentfolder = CmsResource.getPathPart(folder, i);
400             List JavaDoc entries = getNavigationForFolder(cms, currentfolder);
401             // Check for parent folder
402
if (parentcount > 0) {
403                 for (int it = 0; it < entries.size(); it++) {
404                     CmsJspNavElement e = (CmsJspNavElement)entries.get(it);
405                     e.setNavPosition(e.getNavPosition() + parentcount);
406                 }
407             }
408             // Add new entries to result
409
result.addAll(entries);
410             Collections.sort(result);
411             // Finally spread the values of the nav items so that there is enough room for further items.
412
float pos = 0;
413             int count = 0;
414             String JavaDoc nextfolder = CmsResource.getPathPart(folder, i + 1);
415             parentcount = 0;
416             for (int it = 0; it < result.size(); it++) {
417                 pos = 10000 * (++count);
418                 CmsJspNavElement e = (CmsJspNavElement)result.get(it);
419                 e.setNavPosition(pos);
420                 if (e.getResourceName().startsWith(nextfolder)) {
421                     parentcount = pos;
422                 }
423             }
424             if (parentcount == 0) {
425                 parentcount = pos;
426             }
427         }
428         return result;
429     }
430
431     /**
432      * This method builds a complete navigation tree with entries of all branches
433      * from the specified folder.<p>
434      *
435      * For an unlimited depth of the navigation (i.e. no endLevel), set the endLevel to
436      * a value &lt; 0.<p>
437      *
438      *
439      * @param cms the current CmsJspActionElement.
440      * @param folder the root folder of the navigation tree.
441      * @param endLevel the end level of the navigation.
442      * @return ArrayList of CmsJspNavElement, in depth first order.
443      */

444     public static List JavaDoc getSiteNavigation(CmsObject cms, String JavaDoc folder, int endLevel) {
445
446         // check if a specific end level was given, if not, build the complete navigation
447
boolean noLimit = false;
448         if (endLevel < 0) {
449             noLimit = true;
450         }
451         ArrayList JavaDoc list = new ArrayList JavaDoc();
452         // get the navigation for this folder
453
List JavaDoc curnav = getNavigationForFolder(cms, folder);
454         // loop through all nav entrys
455
for (int i = 0; i < curnav.size(); i++) {
456             CmsJspNavElement ne = (CmsJspNavElement)curnav.get(i);
457             // add the naventry to the result list
458
list.add(ne);
459             // check if naventry is a folder and below the max level -> if so, get the navigation from this folder as well
460
if (ne.isFolderLink() && (noLimit || (ne.getNavTreeLevel() < endLevel))) {
461                 List JavaDoc subnav = getSiteNavigation(cms, ne.getResourceName(), endLevel);
462                 // copy the result of the subfolder to the result list
463
list.addAll(subnav);
464             }
465         }
466         return list;
467     }
468
469     /**
470      * Returns all subfolders of a channel, or an empty array if
471      * the folder does not exist or has no subfolders.<p>
472      *
473      * @param channel the channel to look for subfolders in
474      * @return an unsorted list of CmsResources
475      */

476     public List JavaDoc getChannelSubFolders(String JavaDoc channel) {
477
478         return getChannelSubFolders(m_cms, channel);
479     }
480
481     /**
482      * Returns all subfolders of a sub channel that has
483      * the given parent channel, or an empty array if
484      * that combination does not exist or has no subfolders.<p>
485      *
486      * @param parentChannel the parent channel
487      * @param subChannel the sub channel
488      * @return an unsorted list of CmsResources
489      */

490     public List JavaDoc getChannelSubFolders(String JavaDoc parentChannel, String JavaDoc subChannel) {
491
492         return getChannelSubFolders(m_cms, parentChannel, subChannel);
493     }
494
495     /**
496      * Returns all subfolders of a channel,
497      * sorted by "Title" property ascending, or an empty array if
498      * the folder does not exist or has no subfolders.
499      *
500      * @param channel the parent channel
501      * @param subChannel the sub channel
502      * @return a sorted list of CmsResources
503      */

504     public List JavaDoc getChannelSubFoldersSortTitleAsc(String JavaDoc channel, String JavaDoc subChannel) {
505
506         return getChannelSubFoldersSortTitleAsc(m_cms, channel, subChannel);
507     }
508
509     /**
510      * Build a "bread crump" path navigation to the current folder.<p>
511      *
512      * @return ArrayList sorted list of navigation elements
513      * @see #getNavigationBreadCrumb(String, int, int, boolean)
514      */

515     public List JavaDoc getNavigationBreadCrumb() {
516
517         return getNavigationBreadCrumb(m_requestUriFolder, 0, -1, true);
518     }
519
520     /**
521      * Build a "bread crump" path navigation to the current folder.<p>
522      *
523      * @param startlevel the start level, if negative, go down |n| steps from selected folder
524      * @param currentFolder include the selected folder in navigation or not
525      * @return ArrayList sorted list of navigation elements
526      * @see #getNavigationBreadCrumb(String, int, int, boolean)
527      */

528     public List JavaDoc getNavigationBreadCrumb(int startlevel, boolean currentFolder) {
529
530         return getNavigationBreadCrumb(m_requestUriFolder, startlevel, -1, currentFolder);
531     }
532
533     /**
534      * Build a "bread crump" path navigation to the current folder.<p>
535      *
536      * @param startlevel the start level, if negative, go down |n| steps from selected folder
537      * @param endlevel the end level, if -1, build navigation to selected folder
538      * @return ArrayList sorted list of navigation elements
539      * @see #getNavigationBreadCrumb(String, int, int, boolean)
540      */

541     public List JavaDoc getNavigationBreadCrumb(int startlevel, int endlevel) {
542
543         return getNavigationBreadCrumb(m_requestUriFolder, startlevel, endlevel, true);
544     }
545
546     /**
547      * Build a "bread crump" path navigation to the given folder.<p>
548      *
549      * The startlevel marks the point where the navigation starts from, if negative,
550      * the count of steps to go down from the given folder.
551      * The endlevel is the maximum level of the navigation path, set it to -1 to build the
552      * complete navigation to the given folder.
553      * You can include the given folder in the navigation by setting currentFolder to true,
554      * otherwise false.<p>
555      *
556      * @param folder the selected folder
557      * @param startlevel the start level, if negative, go down |n| steps from selected folder
558      * @param endlevel the end level, if -1, build navigation to selected folder
559      * @param currentFolder include the selected folder in navigation or not
560      * @return ArrayList sorted list of navigation elements
561      */

562     public List JavaDoc getNavigationBreadCrumb(String JavaDoc folder, int startlevel, int endlevel, boolean currentFolder) {
563
564         ArrayList JavaDoc result = new ArrayList JavaDoc();
565
566         int level = CmsResource.getPathLevel(folder);
567         // decrease folder level if current folder is not displayed
568
if (!currentFolder) {
569             level -= 1;
570         }
571         // check current level and change endlevel if it is higher or -1
572
if (level < endlevel || endlevel == -1) {
573             endlevel = level;
574         }
575
576         // if startlevel is negative, display only |startlevel| links
577
if (startlevel < 0) {
578             startlevel = endlevel + startlevel + 1;
579             if (startlevel < 0) {
580                 startlevel = 0;
581             }
582         }
583
584         // create the list of navigation elements
585
for (int i = startlevel; i <= endlevel; i++) {
586             String JavaDoc navFolder = CmsResource.getPathPart(folder, i);
587             CmsJspNavElement e = getNavigationForResource(navFolder);
588             // add element to list
589
result.add(e);
590         }
591
592         return result;
593     }
594
595     /**
596      * Collect all navigation elements from the files of the folder of the current request URI,
597      * navigation elements are of class CmsJspNavElement.<p>
598      *
599      * @return a sorted (ascending to nav position) ArrayList of navigation elements.
600      */

601     public List JavaDoc getNavigationForFolder() {
602
603         return getNavigationForFolder(m_cms, m_requestUriFolder);
604     }
605
606     /**
607      * Build a navigation for the folder that is either minus levels up
608      * from of the folder of the current request URI, or that is plus levels down from the
609      * root folder towards the current request URI.<p>
610      *
611      * If level is set to zero the root folder is used by convention.<p>
612      *
613      * @param level if negative, walk this many levels up, if positive, walk this many
614      * levels down from root folder
615      * @return a sorted (ascending to nav position) ArrayList of navigation elements
616      */

617     public List JavaDoc getNavigationForFolder(int level) {
618
619         return getNavigationForFolder(m_cms, m_requestUriFolder, level);
620     }
621
622     /**
623      * Collect all navigation elements from the files in the given folder,
624      * navigation elements are of class CmsJspNavElement.<p>
625      *
626      * @param folder the selected folder
627      * @return A sorted (ascending to nav position) ArrayList of navigation elements.
628      */

629     public List JavaDoc getNavigationForFolder(String JavaDoc folder) {
630
631         return getNavigationForFolder(m_cms, folder);
632     }
633
634     /**
635      * Build a navigation for the folder that is either minus levels up
636      * from the given folder, or that is plus levels down from the
637      * root folder towards the given folder.<p>
638      *
639      * If level is set to zero the root folder is used by convention.<p>
640      *
641      * @param folder the selected folder
642      * @param level if negative, walk this many levels up, if positive, walk this many
643      * levels down from root folder
644      * @return a sorted (ascending to nav position) ArrayList of navigation elements
645      */

646     public List JavaDoc getNavigationForFolder(String JavaDoc folder, int level) {
647
648         return getNavigationForFolder(m_cms, folder, level);
649     }
650
651     /**
652      * Returns a CmsJspNavElement for the resource of the current request URI.<p>
653      *
654      * @return CmsJspNavElement a CmsJspNavElement for the resource of the current request URI
655      */

656     public CmsJspNavElement getNavigationForResource() {
657
658         return getNavigationForResource(m_cms, m_requestUri);
659     }
660
661     /**
662      * Returns a CmsJspNavElement for the named resource.<p>
663      *
664      * @param resource the resource name to get the nav information for,
665      * must be a full path name, e.g. "/docs/index.html".
666      * @return CmsJspNavElement a CmsJspNavElement for the given resource
667      */

668     public CmsJspNavElement getNavigationForResource(String JavaDoc resource) {
669
670         return getNavigationForResource(m_cms, resource);
671     }
672
673     /**
674      * Builds a tree navigation for the folders between the provided start and end level.<p>
675      *
676      * @param startlevel the start level
677      * @param endlevel the end level
678      * @return a sorted list of nav elements with the nav tree level property set
679      * @see #getNavigationTreeForFolder(CmsObject, String, int, int)
680      */

681     public List JavaDoc getNavigationTreeForFolder(int startlevel, int endlevel) {
682
683         return getNavigationTreeForFolder(m_cms, m_requestUriFolder, startlevel, endlevel);
684     }
685
686     /**
687      * Builds a tree navigation for the folders between the provided start and end level.<p>
688      *
689      * @param folder the selected folder
690      * @param startlevel the start level
691      * @param endlevel the end level
692      * @return a sorted list of nav elements with the nav tree level property set
693      * @see #getNavigationTreeForFolder(CmsObject, String, int, int)
694      */

695     public List JavaDoc getNavigationTreeForFolder(String JavaDoc folder, int startlevel, int endlevel) {
696
697         return getNavigationTreeForFolder(m_cms, folder, startlevel, endlevel);
698     }
699
700     /**
701      * This method builds a complete site navigation tree with entries of all branches.<p>
702      *
703      * @see #getSiteNavigation(CmsObject, String, int)
704      *
705      * @return ArrayList of CmsJspNavElement, in depth first order.
706      */

707     public List JavaDoc getSiteNavigation() {
708
709         return getSiteNavigation(m_cms, "/", -1);
710     }
711
712     /**
713      * This method builds a complete navigation tree with entries of all branches
714      * from the specified folder.<p>
715      *
716      * @see #getSiteNavigation(CmsObject, String, int)
717      *
718      * @param folder folder the root folder of the navigation tree.
719      * @param endLevel the end level of the navigation.
720      * @return ArrayList of CmsJspNavElement, in depth first order.
721      */

722     public List JavaDoc getSiteNavigation(String JavaDoc folder, int endLevel) {
723
724         return getSiteNavigation(m_cms, folder, endLevel);
725     }
726
727     /**
728      * Initiliazes this bean.<p>
729      *
730      * @param cms context provider for the current request
731      */

732     public void init(CmsObject cms) {
733
734         m_cms = cms;
735         m_requestUri = m_cms.getRequestContext().getUri();
736         m_requestUriFolder = CmsResource.getFolderPath(m_requestUri);
737     }
738 }
739
Popular Tags