KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > meshcms > taglib > TigraMenu


1 /*
2  * MeshCMS - A simple CMS based on SiteMesh
3  * Copyright (C) 2004-2007 Luciano Vernaschi
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  *
19  * You can contact the author at http://www.cromoteca.com
20  * and at info@cromoteca.com
21  */

22
23 package org.meshcms.taglib;
24
25 import java.io.*;
26 import org.meshcms.core.*;
27 import org.meshcms.util.*;
28
29 /**
30  * Creates a navigation menu based on the TigraMenu script
31  * created by <a HREF="http://www.softcomplex.com/">SoftComplex</a>.
32  */

33 public final class TigraMenu extends AbstractTag {
34   public static final String JavaDoc PART_HEAD = "head";
35   public static final String JavaDoc PART_BODY = "body";
36
37   private String JavaDoc part;
38   private String JavaDoc path;
39   private String JavaDoc placeholder;
40   private boolean allowHiding = false;
41
42   public void writeTag() throws IOException {
43     Path rootPath = (path == null) ?
44         webSite.getSiteInfo().getThemeRoot(pagePath) : new Path(path);
45     String JavaDoc script = WebUtils.getFullThemeFolder(request);
46     Writer outWriter = getOut();
47
48     if (part.equals(PART_BODY)) {
49       outWriter.write("<!-- Tigra Menu 2.0 -->\n");
50       outWriter.write("<script language=\"JavaScript\">\n");
51
52       if (Utils.isTrue(placeholder)) {
53         outWriter.write("document.write('<img SRC=\"" + afp + '/' +
54                         WebSite.ADMIN_THEME + "/tx1x1.gif\" width=\"'+MENU_POS[0]" +
55                         "['width']+'\" height=\"'+(MENU_ITEMS.length*" +
56                         "MENU_POS[0]['top'])+'\">');\n");
57       }
58
59       outWriter.write("new menu(MENU_ITEMS, MENU_POS);\n");
60       outWriter.write("</script>\n");
61       outWriter.write("<!-- End Tigra Menu -->\n");
62     } else if (part.equals(PART_HEAD)) {
63       outWriter.write("<!-- Tigra Menu 2.0 -->\n");
64       outWriter.write("<link rel=\"stylesheet\" HREF=\"" + script +
65                       "/menu.css\">\n");
66       outWriter.write("<script language=\"JavaScript\" SRC=\"" + script +
67                       "/menu.js\"></script>\n");
68       outWriter.write("<script language=\"JavaScript\">\n");
69       outWriter.write(webSite.getSiteMap().getTigraItems(cp, rootPath, false, allowHiding));
70       outWriter.write("\n</script>\n");
71       outWriter.write("<script language=\"JavaScript\" SRC=\"" + script +
72                       "/menu_tpl.js\"></script>\n");
73       outWriter.write("<!-- End Tigra Menu -->\n");
74     }
75   }
76
77   public String JavaDoc getPart() {
78     return part;
79   }
80
81   public void setPart(String JavaDoc part) {
82     this.part = part;
83   }
84
85   public String JavaDoc getPath() {
86     return path;
87   }
88
89   public void setPath(String JavaDoc path) {
90     this.path = path;
91   }
92
93   public String JavaDoc getPlaceholder() {
94     return placeholder;
95   }
96
97   public void setPlaceholder(String JavaDoc placeholder) {
98     this.placeholder = placeholder;
99   }
100
101   public boolean getAllowHiding() {
102     return allowHiding;
103   }
104
105   public void setAllowHiding(boolean allowHiding) {
106     this.allowHiding = allowHiding;
107   }
108 }
109
Popular Tags