01: /**********************************************************************************
02: * $URL: https://source.sakaiproject.org/svn/help/tags/sakai_2-4-1/help-tool/src/java/org/sakaiproject/tool/help/TableOfContentsTool.java $
03: * $Id: TableOfContentsTool.java 7653 2006-04-12 12:10:02Z marquard@ched.uct.ac.za $
04: ***********************************************************************************
05: *
06: * Copyright (c) 2003, 2004 The Sakai Foundation.
07: *
08: * Licensed under the Educational Community License, Version 1.0 (the "License");
09: * you may not use this file except in compliance with the License.
10: * You may obtain a copy of the License at
11: *
12: * http://www.opensource.org/licenses/ecl1.php
13: *
14: * Unless required by applicable law or agreed to in writing, software
15: * distributed under the License is distributed on an "AS IS" BASIS,
16: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: * See the License for the specific language governing permissions and
18: * limitations under the License.
19: *
20: **********************************************************************************/package org.sakaiproject.tool.help;
21:
22: import javax.faces.context.FacesContext;
23: import javax.servlet.http.HttpServletRequest;
24:
25: import org.apache.commons.logging.Log;
26: import org.apache.commons.logging.LogFactory;
27: import org.sakaiproject.api.app.help.HelpManager;
28: import org.sakaiproject.api.app.help.TableOfContents;
29:
30: /**
31: * table of contents tool
32: * @version $Id: TableOfContentsTool.java 7653 2006-04-12 12:10:02Z marquard@ched.uct.ac.za $
33: *
34: */
35: public class TableOfContentsTool {
36:
37: private TableOfContents tableOfContents;
38: private HelpManager helpManager;
39: private String baseUrl = null;
40:
41: private static final Log LOG = LogFactory
42: .getLog(TableOfContentsTool.class);
43:
44: /**
45: * get table of contents
46: * @return Returns the tableOfContents.
47: */
48: public TableOfContents getTableOfContents() {
49: return helpManager.getTableOfContents();
50: }
51:
52: /**
53: * set table of contents
54: * @param tableOfContents The tableOfContents to set.
55: */
56: public void setTableOfContents(TableOfContents toc) {
57: helpManager.setTableOfContents(toc);
58: }
59:
60: /**
61: * get help manager
62: * @return Returns the helpManager.
63: */
64: public HelpManager getHelpManager() {
65: return helpManager;
66: }
67:
68: /**
69: * set help manager
70: * @param helpManager The helpManager to set.
71: */
72: public void setHelpManager(HelpManager helpManager) {
73: this .helpManager = helpManager;
74: }
75:
76: /**
77: * get base url
78: * @return base url
79: */
80: private String getBaseUrl() {
81: if (baseUrl == null) {
82: HttpServletRequest request = (HttpServletRequest) FacesContext
83: .getCurrentInstance().getExternalContext()
84: .getRequest();
85: StringBuffer base = request.getRequestURL();
86: String servletPath = request.getServletPath();
87: String contextPath = request.getContextPath();
88:
89: int pos = base.indexOf(contextPath);
90: if (pos != -1) {
91: base.setLength(pos);
92: }
93: baseUrl = base.toString();
94: }
95: return baseUrl;
96: }
97:
98: }
|