KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > meshcms > webui > Help


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.webui;
24
25 import java.util.*;
26 import org.meshcms.core.*;
27 import org.meshcms.util.*;
28
29 /**
30  *
31  */

32 public class Help {
33   public static final String JavaDoc CONFIGURE = "configure";
34   public static final String JavaDoc CONTROL_PANEL = "control_panel";
35   public static final String JavaDoc EDIT_PAGE = "edit_page";
36   public static final String JavaDoc EDIT_PROFILE = "edit_profile";
37   public static final String JavaDoc FILE_MANAGER = "file_manager";
38   public static final String JavaDoc PAGE_MANAGER = "page_manager";
39   public static final String JavaDoc NEW_PAGE = "create_new_page";
40   public static final String JavaDoc NEW_USER = "new_user";
41   public static final String JavaDoc SITE_MANAGER = "site_manager";
42   public static final String JavaDoc STATIC_EXPORT = "static_export";
43   public static final String JavaDoc UNZIP = "unzip";
44   public static final String JavaDoc UPLOAD = "upload";
45   public static final String JavaDoc MODULES = "modules";
46
47   private static Properties args;
48
49   static {
50     args = new Properties();
51     args.setProperty(EDIT_PAGE, "ch04s02.html");
52     args.setProperty(NEW_PAGE, "ch04s03.html");
53     args.setProperty(CONTROL_PANEL, "ch05.html");
54     args.setProperty(PAGE_MANAGER, "ch05s01.html");
55     args.setProperty(CONFIGURE, "ch05s02.html");
56     args.setProperty(EDIT_PROFILE, "ch05s03.html");
57     args.setProperty(NEW_USER, "ch05s04.html");
58     args.setProperty(FILE_MANAGER, "ch05s05.html");
59     args.setProperty(UPLOAD, "ch05s05.html#upload");
60     args.setProperty(UNZIP, "ch05s05.html#unzip");
61     args.setProperty(STATIC_EXPORT, "ch05s06.html");
62     args.setProperty(SITE_MANAGER, "ch05s07.html");
63     args.setProperty(MODULES, "ch06s01.html");
64   }
65
66   /**
67    * Creates the HTML used to display the help icon in the admin pages.
68    */

69   public static String JavaDoc icon(WebSite webSite, String JavaDoc contextPath,
70       String JavaDoc argument, UserInfo userInfo) {
71     return icon(webSite, contextPath, argument, userInfo, null, false);
72   }
73
74   public static String JavaDoc icon(WebSite webSite, String JavaDoc contextPath,
75       String JavaDoc argument, UserInfo userInfo, String JavaDoc anchor, boolean grayIcon) {
76     String JavaDoc lang = getHelpLang(webSite, userInfo);
77
78     return "<img SRC='" + contextPath + '/' + webSite.getAdminPath() +
79         "/images/" + (grayIcon ? "small_help_gray.gif" : "small_help.gif") +
80         "' title='Help: " + argument +
81         "' alt='Help Icon' onclick=\"javascript:window.open('" +
82         contextPath + '/' + webSite.getAdminPath() + "/help/" + lang +
83         '/' + args.getProperty(argument, "index.html") +
84         (Utils.isNullOrEmpty(anchor) ? "" : "#" + anchor) +
85         "', 'meshcmshelp', 'width=740,height=560,menubar=no,status=yes,toolbar=no,resizable=yes,scrollbars=yes').focus();\" />";
86   }
87
88   public static String JavaDoc getHelpLang(WebSite webSite, UserInfo userInfo) {
89     String JavaDoc lang = "en";
90
91     if (userInfo != null) {
92       String JavaDoc otherLang = userInfo.getPreferredLocaleCode();
93
94       if (webSite.getFile(webSite.getAdminPath().add("help", otherLang)).exists()) {
95         lang = otherLang;
96       }
97     }
98
99     return lang;
100   }
101 }
102
Popular Tags