<%@ page contentType="text/html;charset=GBK" %>

<%
/**
 *	$RCSfile: searchSettings.jsp,v $
 *	$Revision: 1.1.1.1 $
 *	$Date: 2002/09/09 13:50:18 $
 */
%>

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

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

<%	// get parameters

    boolean searchEnabled = ParamUtils.getBooleanParameter(request,"searchEnabled");
    boolean setSearchEnabled = ParamUtils.getBooleanParameter(request,"setSearchEnabled");
	boolean setAutoIndexEnabled = ParamUtils.getBooleanParameter(request,"setAutoIndexEnabled");
	boolean autoIndexEnabled = ParamUtils.getBooleanParameter(request,"autoIndexEnabled");
    int updateInterval = ParamUtils.getIntParameter(request,"updateInterval",5);
	boolean doUpdateIndex = ParamUtils.getBooleanParameter(request,"doUpdateIndex");
	boolean doRebuildIndex = ParamUtils.getBooleanParameter(request,"doRebuildIndex");

    // Get the search manager
	SearchManager searchManager = forumFactory.getSearchManager();

    // enable or disable search
    if (setSearchEnabled) {
        searchManager.setSearchEnabled(searchEnabled);
        response.sendRedirect("searchSettings.jsp");
        return;
    }

    // enable or disable auto indexing
    if (setAutoIndexEnabled) {
        searchManager.setAutoIndexEnabled(autoIndexEnabled);
        searchManager.setAutoIndexInterval(updateInterval);
        response.sendRedirect("searchSettings.jsp");
        return;
    }

    // update index if requested
    if (doUpdateIndex) {
        searchManager.updateIndex();
        response.sendRedirect("searchSettings.jsp");
        return;
    }

    // rebuild index if requested
    if (doRebuildIndex) {
        searchManager.rebuildIndex();
        response.sendRedirect("searchSettings.jsp");
        return;
    }

	autoIndexEnabled = searchManager.isAutoIndexEnabled();
    searchEnabled = searchManager.isSearchEnabled();
%>

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

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

<font size="-1">
搜索引擎将定期的将新消息加入可搜索消息数据库。你可以通过调整刷新间隔控制这种更新。消息在被索引化前不会出现在搜索结果中，因此一个相对频繁的刷新间隔是推荐的值。
</font>

<p>

<%  // If we're doing any indexing operation, display a message
    if (searchManager.isBusy()) {
%>

<script language="JavaScript" type="text/javascript">
<!--
function reloadPage() {
    location.href='searchSettings.jsp';
}
setTimeout(reloadPage,4000);
//-->
</script>

<font size="-1"><b>索引化过程中...</b></font><p>
<ul>
    <font size="-1">
    <b>完成<%= searchManager.getPercentComplete() %>%</b>
    <br>
    Jive正在更新或者重建搜索索引。这可能需要几分钟。
    </font>
</ul>

<%  } else { %>

<font size="-1"><b>搜索状态</b></font><p>
<ul>
    <font size="-1">
    你可以用下面的表单激活或者关闭Jive的搜索功能。
    </font>
    <form action="searchSettings.jsp">
    <input type="hidden" name="setSearchEnabled" value="true">
    <table bgcolor="<%= tblBorderColor %>" cellpadding="0" cellspacing="0" border="0" width="300">
    <td>
    <table bgcolor="<%= tblBorderColor %>" cellpadding="3" cellspacing="1" border="0" width="100%">
    <tr bgcolor="#ffffff">
	<td align="center"<%= (searchEnabled)?" bgcolor=\"#99cc99\"":"" %>>
        <font size="-1">
		<input type="radio" name="searchEnabled" value="true" id="rb01"
		 <%= (searchEnabled)?"checked":"" %>>
		<label for="rb01"><%= (searchEnabled)?"<b>打开</b>":"打开" %></label>
        </font>
	</td>
	<td align="center"<%= (!searchEnabled)?" bgcolor=\"#cc6666\"":"" %>>
        <font size="-1">
		<input type="radio" name="searchEnabled" value="false" id="rb02"
		 <%= (!searchEnabled)?"checked":"" %>>
		<label for="rb02"><%= (!searchEnabled)?"<b>关闭</b>":"关闭" %></label>
        </font>
	</td>
	<td align="center">
		<input type="submit" value="更新">
	</td>
    </tr>
    </table>
    </td>
    </table>
    </form>
</ul>

<%  // only show the following section if the search feature is enabled
    if (searchEnabled) {
%>

<font size="-1"><b>索引化设置</b></font><p>
<ul>
    <font size="-1">
    你可以选择关闭自动索引。然而，在那种情况下必须由你手动启动索引化过程。
    </font>
    <p>
    <form action="searchSettings.jsp">
    <input type="hidden" name="setAutoIndexEnabled" value="true">

    <table cellpadding="2" cellspacing="0" border="0">
    <tr>
    	<td><input type="radio" name="autoIndexEnabled" value="true" id="rb03"<%= (autoIndexEnabled)?"checked":"" %>></td>
    	<td><font size="-1"><label for="rb03">自动索引化</label></font></td>
    </tr>
    <tr>
    	<td><input type="radio" name="autoIndexEnabled" value="false" id="rb04"<%= (!autoIndexEnabled)?"checked":"" %>></td>
    	<td><font size="-1"><label for="rb04">手动索引化</label></font></td>
    </tr>
    <%  if (!autoIndexEnabled) { %>
    <tr>
    	<td colspan="2"><input type="submit" value="保存设置"></td>
    </tr>
    <%  } %>
    </table>
    <%  if (autoIndexEnabled) { %>
    <p>
    <table>
    <tr>
    	<td>
        <font size="-1">
        你可以选择论坛内容索引化的频率。
        <br><br>
        </font>
        </td>
    </tr>
    <tr>
    	<td>
        <font size="-1">
        索引化最近更新时间：
        <%= JiveGlobals.formatDateTime(searchManager.getLastIndexedDate()) %>
        </font>
        </td>
    </tr>
    <tr>
    	<td>
        <font size="-1">
        每隔
		<select size="1" name="updateInterval">
<%      for (int i=0; i<=60;) {
            String selected = "";
            if (updateInterval == i) {
                selected = " selected";
            }
%>
        <option value="<%= i %>"<%= selected %>><%= i %>
<%          if (i >= 10) {
                i+=5;
            } else {
                i++;
            }
        }
%>
		</select>
		分钟更新一次。
        </font>
        </td>
    </tr>
    <tr>
    	<td><br><input type="submit" value="保存设置"></td>
    </tr>
    </table>
    <%  } %>
    </form>
</ul>

<font size="-1"><b>更新索引</b></font><p>
<ul>
    <form action="searchSettings.jsp">
    <font size="-1">
    这将将索引器上次运行以后添加的任何消息索引化。
    <br>
    </font>
    <input type="hidden" name="doUpdateIndex" value="true">
    <input type="submit" value="更新索引">
    </form>
</ul>

<font size="-1"><b>重建索引</b></font><p>
<ul>
    <form action="searchSettings.jsp">
    <font size="-1">
    这将重建所有消息的索引(如果有很多消息，这会花费一段时间)。
    <br>
    </font>
    <input type="hidden" name="doRebuildIndex" value="true">
    <input type="submit" value="重建索引">
    </form>
</ul>

<%  } // end if searchEnabled %>

<%  } // end if searchManager.isBusy() %>

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