⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 locale.jsp

📁 一个jive论坛管理的源码 学习Jive源程序
💻 JSP
字号:
<%@ page contentType="text/html;charset=GB2312" %>
<%
/**
 *	$RCSfile: locale.jsp,v $
 *	$Revision: 1.1.1.1 $
 *	$Date: 2002/09/09 13:50:16 $
 */
%>

<%@ page import="java.util.*,
				 java.text.*,
				 com.jivesoftware.util.*,
                 com.jivesoftware.forum.*,

				 com.jivesoftware.forum.util.*"
%>

<%@ include file="global.jsp" %>

<%! // Global vars, methods, etc

    // All locales
    static Locale[] LOCALES = Locale.getAvailableLocales();
    static {
        Arrays.sort(LOCALES, new Comparator() {
            public int compare(Object o1, Object o2) {
                Locale loc1 = (Locale)o1;
                Locale loc2 = (Locale)o2;
                return loc1.getDisplayName().compareTo(loc2.getDisplayName());
            }
        });
    }
    static final String[][] timeZones = SkinUtils.getTimeZoneList();
%>

<%	// get parameters
    String localeCode = ParamUtils.getParameter(request,"localeCode");
    boolean saveLocale = ParamUtils.getBooleanParameter(request,"saveLocale");
    String timeZoneID = ParamUtils.getParameter(request,"timeZoneID");
    boolean saveTimeZone = ParamUtils.getBooleanParameter(request,"saveTimeZone");

    // save the locale if requested
    if (saveLocale) {
        // parse the incoming locale code
        String language = null;
        String country = null;
        String variant = null;
        if (localeCode != null) {
            StringTokenizer tokenizer = new StringTokenizer(localeCode, "_");
            if (tokenizer.hasMoreTokens()) {
                language = tokenizer.nextToken();
                if (tokenizer.hasMoreTokens()) {
                    country = tokenizer.nextToken();
                    if (tokenizer.hasMoreTokens()) {
                        variant = tokenizer.nextToken();
                    }
                }
            }
        }
        Locale newLocale = new Locale(
            language,
            ((country!=null)?country:""),
            ((variant!=null)?variant:"")
        );
        // finally, set the new jive locale
        JiveGlobals.setLocale(newLocale);
        // we're done so redirect back to this page
        response.sendRedirect("locale.jsp");
        return;
    }

    if (saveTimeZone) {
        try {
            TimeZone tz = TimeZone.getTimeZone(timeZoneID);
            JiveGlobals.setTimeZone(tz);
        }
        catch (Exception e) {}
    }

    // Get Jive's global locale
    Locale locale = JiveGlobals.getLocale();

    // Get Jive's global time zone
    TimeZone timeZone = JiveGlobals.getTimeZone();

    // Current date
    Date date = new Date();

    // Set the locale in the response object
    response.setLocale(locale);
%>

<%@ include file="header.jsp" %>

<p>

<%  // Title of this page and breadcrumbs
    String title = "区域设置";
    String[][] breadcrumbs = {
        {"主页面", "main.jsp"},
        {title, "locale.jsp"}
    };
%>
<%@ include file="title.jsp" %>

<font size="-1">
在下面编辑全局区域设置,它可以控制日期和时间的显示格式。
</font>

<p>

<font size="-1"><b>当前区域</b></font>
<ul>
    <font size="-1">
    当前区域为:<b><%= locale.getDisplayName() %></b>
    <p>
    <table cellpadding="2" cellspacing="0" border="0">
    <tr>
    	<td><font size="-1">日期范例:</font></td>
    	<td><font size="-1"><b><%= JiveGlobals.formatDate(date) %></b></font></td>
    </tr>
    <tr>
    	<td><font size="-1">日期和时间范例:</font></td>
    	<td><font size="-1"><b><%= JiveGlobals.formatDateTime(date) %></b></font></td>
    </tr>
    </table>
    <p>
    </font>
</ul>

<p>

<font size="-1"><b>区域设置</b></font>
<ul>
    <form action="locale.jsp">
    <input type="hidden" name="saveLocale" value="true">
    <table cellpadding="3" cellspacing="0" border="0">
    <tr>
    	<td><font size="-1">地区:</font></td>
        <td>
            <select size="1" name="localeCode">
        <%  for (int i=0; i<LOCALES.length; i++) {
                String selected = "";
                if (locale.equals(LOCALES[i])) {
                    selected = " selected";
                }
        %>
            <option value="<%= LOCALES[i].toString() %>"<%= selected %>><%= LOCALES[i].getDisplayName() %>
        <%  } %>
            </select>
        </td>
    </tr>
    <tr>
    	<td>&nbsp;</td>
        <td>
            <input type="submit" value="保存区域设置">
        </td>
    </tr>
    </table>
    </form>
</ul>

<font size="-1"><b>时区设置</b></font>
<ul>
    <form action="locale.jsp">
    <input type="hidden" name="saveTimeZone" value="true">
    <table cellpadding="3" cellspacing="0" border="0">
    <tr>
    	<td><font size="-1">时区:</font></td>
        <td>
            <select size="1" name="timeZoneID">
        <%  for (int i=0; i<timeZones.length; i++) {
                String selected = "";
                if (timeZone.getID().equals(timeZones[i][0])) {
                    selected = " selected";
                }
        %>
            <option value="<%= timeZones[i][0] %>"<%= selected %>><%= timeZones[i][1] %>
        <%  } %>
            </select>
        </td>
    </tr>
    <tr>
    	<td>&nbsp;</td>
        <td>
            <input type="submit" value="保存时区设置">
        </td>
    </tr>
    </table>
    </form>
</ul>

<p>

<%@ include file="footer.jsp" %>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -