001: /*
002: * MeshCMS - A simple CMS based on SiteMesh
003: * Copyright (C) 2004-2007 Luciano Vernaschi
004: *
005: * This program is free software; you can redistribute it and/or
006: * modify it under the terms of the GNU General Public License
007: * as published by the Free Software Foundation; either version 2
008: * of the License, or (at your option) any later version.
009: *
010: * This program is distributed in the hope that it will be useful,
011: * but WITHOUT ANY WARRANTY; without even the implied warranty of
012: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
013: * GNU General Public License for more details.
014: *
015: * You should have received a copy of the GNU General Public License
016: * along with this program; if not, write to the Free Software
017: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
018: *
019: * You can contact the author at http://www.cromoteca.com
020: * and at info@cromoteca.com
021: */
022:
023: package org.meshcms.webui;
024:
025: import java.util.*;
026: import org.meshcms.core.*;
027: import org.meshcms.util.*;
028:
029: /**
030: *
031: */
032: public class Help {
033: public static final String CONFIGURE = "configure";
034: public static final String CONTROL_PANEL = "control_panel";
035: public static final String EDIT_PAGE = "edit_page";
036: public static final String EDIT_PROFILE = "edit_profile";
037: public static final String FILE_MANAGER = "file_manager";
038: public static final String PAGE_MANAGER = "page_manager";
039: public static final String NEW_PAGE = "create_new_page";
040: public static final String NEW_USER = "new_user";
041: public static final String SITE_MANAGER = "site_manager";
042: public static final String STATIC_EXPORT = "static_export";
043: public static final String UNZIP = "unzip";
044: public static final String UPLOAD = "upload";
045: public static final String MODULES = "modules";
046:
047: private static Properties args;
048:
049: static {
050: args = new Properties();
051: args.setProperty(EDIT_PAGE, "ch04s02.html");
052: args.setProperty(NEW_PAGE, "ch04s03.html");
053: args.setProperty(CONTROL_PANEL, "ch05.html");
054: args.setProperty(PAGE_MANAGER, "ch05s01.html");
055: args.setProperty(CONFIGURE, "ch05s02.html");
056: args.setProperty(EDIT_PROFILE, "ch05s03.html");
057: args.setProperty(NEW_USER, "ch05s04.html");
058: args.setProperty(FILE_MANAGER, "ch05s05.html");
059: args.setProperty(UPLOAD, "ch05s05.html#upload");
060: args.setProperty(UNZIP, "ch05s05.html#unzip");
061: args.setProperty(STATIC_EXPORT, "ch05s06.html");
062: args.setProperty(SITE_MANAGER, "ch05s07.html");
063: args.setProperty(MODULES, "ch06s01.html");
064: }
065:
066: /**
067: * Creates the HTML used to display the help icon in the admin pages.
068: */
069: public static String icon(WebSite webSite, String contextPath,
070: String argument, UserInfo userInfo) {
071: return icon(webSite, contextPath, argument, userInfo, null,
072: false);
073: }
074:
075: public static String icon(WebSite webSite, String contextPath,
076: String argument, UserInfo userInfo, String anchor,
077: boolean grayIcon) {
078: String lang = getHelpLang(webSite, userInfo);
079:
080: // grayIcon currently ignored
081: return "<img src='"
082: + contextPath
083: + '/'
084: + webSite.getAdminPath()
085: + "/filemanager/images/"
086: + (grayIcon ? "help.png" : "help.png")
087: + "' title='Help: "
088: + argument
089: + "' alt='Help Icon' onclick=\"javascript:window.open('"
090: + contextPath
091: + '/'
092: + webSite.getAdminPath()
093: + "/help/"
094: + lang
095: + '/'
096: + args.getProperty(argument, "index.html")
097: + (Utils.isNullOrEmpty(anchor) ? "" : "#" + anchor)
098: + "', 'meshcmshelp', 'width=740,height=560,menubar=no,status=yes,toolbar=no,resizable=yes,scrollbars=yes').focus();\" />";
099: }
100:
101: public static String getHelpLang(WebSite webSite, UserInfo userInfo) {
102: String lang = "en";
103:
104: if (userInfo != null) {
105: String otherLang = userInfo.getPreferredLocaleCode();
106:
107: if (webSite.getFile(
108: webSite.getAdminPath().add("help", otherLang))
109: .exists()) {
110: lang = otherLang;
111: }
112: }
113:
114: return lang;
115: }
116: }
|