📄 filters.jsp
字号:
url.append("&edit=true&pos=").append(filterIndex); response.sendRedirect(url.toString()); return; } } } } // Remove one of the String[] prop entries: if (deletePropEntry) { if (deletePropertyName != null) { // The filter we're working with: Filter filter = filterManager.getFilter(filterIndex); PropertyDescriptor[] descriptors = (Introspector.getBeanInfo(filter.getClass())).getPropertyDescriptors(); PropertyDescriptor propDescriptor = null; // Look for the property specified for (int i=0; i<descriptors.length; i++) { if (descriptors[i].getName().equals(deletePropertyName)) { propDescriptor = descriptors[i]; break; } } if (propDescriptor != null) { // Get both the read and write methods: Method readMethod = propDescriptor.getReadMethod(); Method writeMethod = propDescriptor.getWriteMethod(); // Get the String[] via the read method: String[] entries = (String[])readMethod.invoke(filter, null); // Make a new entry array of entries.length+1 because we're // adding one more entry to the property String[] newEntries = new String[entries.length-1]; int offset = 0; for (int i=0; i<newEntries.length; i++) { // Skip the index of the item we want to delete if (i == deleteIndex) { offset++; } newEntries[i] = entries[i+offset]; } // Use the write method to save the new entries: writeMethod.invoke(filter, new Object[]{newEntries}); // Save filters filterManager.saveFilters(); // Done, so redirect StringBuffer url = new StringBuffer(); url.append("filters.jsp?forum=").append(forumID); url.append("&edit=true&pos=").append(filterIndex); response.sendRedirect(url.toString()); return; } } } // Save filter properties if (saveProperties) { if (filterIndex >= 0) { // The filter we're working with Filter filter = filterManager.getFilter(filterIndex); // A map of name/value pairs. The names are the names of the bean // properties and the values come as parameters to this page Map properties = getFilterPropertyValues(request, filter); // Set the properties BeanUtils.setProperties(filter, properties); // Save the filters filterManager.saveFilters(); // Determine the filter types: if (applyToSubj == (int)ForumFilterType.FORUM_MESSAGE_SUBJECT) { filterManager.addFilterTypes(filterIndex, ForumFilterType.FORUM_MESSAGE_SUBJECT); } else { filterManager.removeFilterTypes(filterIndex, ForumFilterType.FORUM_MESSAGE_SUBJECT); } if (applyToBody == (int)ForumFilterType.FORUM_MESSAGE_BODY) { filterManager.addFilterTypes(filterIndex, ForumFilterType.FORUM_MESSAGE_BODY); } else { filterManager.removeFilterTypes(filterIndex, ForumFilterType.FORUM_MESSAGE_BODY); } if (applyToProp == (int)ForumFilterType.FORUM_MESSAGE_PROPERTY) { filterManager.addFilterTypes(filterIndex, ForumFilterType.FORUM_MESSAGE_PROPERTY); } else { filterManager.removeFilterTypes(filterIndex, ForumFilterType.FORUM_MESSAGE_PROPERTY); } filterManager.saveFilters(); // Done, so redirect to this page response.sendRedirect("filters.jsp?forum=" + forumID); return; } } // Add a new filter to the list of installable filters if (addFilter) { try { if (newClassname == null) { throw new ClassNotFoundException("No classname specified."); } filterManager.addFilterClass(newClassname.trim()); } catch (ClassNotFoundException cnfe) { setOneTimeMessage(session, "message", "\"" + newClassname + "\" is not a valid classname."); } response.sendRedirect("filters.jsp?forum=" + forumID); return; } // Change the position of a filter if (changePosition) { if (filterIndex >= 0) { // Get the filter at the specified filter position Filter filter = filterManager.getFilter(filterIndex); // Re-add it based on the "direction" we're doing long filterTypes = filterManager.getFilterTypes(filterIndex); // Remove it filterManager.removeFilter(filterIndex); if (up) { filterManager.addFilter(filterIndex-1, filter); filterManager.addFilterTypes(filterIndex-1, filterTypes); } if (down) { filterManager.addFilter(filterIndex+1, filter); filterManager.addFilterTypes(filterIndex+1, filterTypes); } // done, so redirect response.sendRedirect("filters.jsp?forum=" + forumID); return; } } // Number of installed filters int filterCount = filterManager.getFilterCount(); // All filter classes Filter[] filters = filterManager.getAvailableFilters(); if (install && classname != null) { try { Filter newFilter = (Filter)(ClassUtils.forName(classname)).newInstance(); filterManager.addFilter(newFilter); int index = filterManager.getFilterCount()-1; if (applyToSubj == (int)ForumFilterType.FORUM_MESSAGE_SUBJECT) { filterManager.addFilterTypes(index, ForumFilterType.FORUM_MESSAGE_SUBJECT); } if (applyToBody == (int)ForumFilterType.FORUM_MESSAGE_BODY) { filterManager.addFilterTypes(index, ForumFilterType.FORUM_MESSAGE_BODY); } if (applyToProp == (int)ForumFilterType.FORUM_MESSAGE_PROPERTY) { filterManager.addFilterTypes(index, ForumFilterType.FORUM_MESSAGE_PROPERTY); } String redirect = "filters.jsp"; if (forumID > -1L) { redirect += "?forum=" + forumID; } response.sendRedirect(redirect); return; } catch (Exception e) { e.printStackTrace(); } } if (remove && position > -1) { filterManager.removeFilter(position); String redirect = "filters.jsp"; if (forumID > -1L) { redirect += "?forum=" + forumID; } response.sendRedirect(redirect); return; }%><%@ include file="header.jsp" %><% // Title of this page and breadcrumbs String title = ""; if (isGlobal) { title = "Global Message Filters"; } else { title = "Message Filters"; } String[][] breadcrumbs = null; if (isGlobal) { breadcrumbs = new String[][] { {"Main", "main.jsp"}, {"Global Message Filters", "filters.jsp"} }; } else { breadcrumbs = new String[][] { {"Main", "main.jsp"}, {"Forums", "forums.jsp"}, {"Edit Forum", "editForum.jsp?forum="+forumID}, {"Message Filters", "filters.jsp?forum="+forumID} }; }%><%@ include file="title.jsp" %><span><font size="-1"><% if (isGlobal) { %> Filters dynamically reformat the contents of messages. Use the forms below to install and customize global filters.<% } else { %> Filters dynamically reformat the contents of messages. Use the forms below to install and customize filters for this forum. Please note that global message filters are always applied before any forum message filters.<% } %></font></span><p><script language="JavaScript" type="text/javascript">var filterInfo = new Array(<% for (int i=0; i<filters.length; i++) { try { BeanDescriptor descriptor = (Introspector.getBeanInfo(filters[i].getClass())).getBeanDescriptor();%> new Array( "<%= descriptor.getBeanClass().getName() %>", "<%= descriptor.getValue("version") %>", "<%= descriptor.getValue("author") %>", "<%= StringUtils.replace(descriptor.getShortDescription(), "\"", "\\\"") %>" )<% if ((filters.length-i) > 1) { %> ,<% } } catch (Exception e) {} }%>);function properties(theForm) { var className = theForm.filters.options[theForm.filters.selectedIndex].value; var selected = 0; for (selected=0; selected<filterInfo.length; selected++) { if (filterInfo[selected][0] == className) { var version = filterInfo[selected][1]; var author = filterInfo[selected][2]; var description = filterInfo[selected][3]; theForm.version.value = ((version=="null")?"":version); theForm.author.value = ((author=="null")?"":author); theForm.description.value = ((description=="null")?"":description); break; } }}</script><% // Print out a message if one exists String oneTimeMessage = getOneTimeMessage(session, "message"); if (oneTimeMessage != null) {%> <font size="-1" color="#ff0000"> <i><%= oneTimeMessage %></i> </font> <p><% }%><% // Colors if (filterCount > 0) {%><table cellpadding="0" cellspacing="0" border="0"><tr><td> <font size="-1"><b>Current Filters</b></font> </td> <td> <a href="#" onclick="helpwin('filters','current_filters');return false;" title="Click for help" ><img src="images/help-16x16.gif" width="16" height="16" border="0" hspace="8"></a> </td></tr></table><br><ul> <table bgcolor="<%= tblBorderColor %>" cellpadding="0" cellspacing="0" border="0"> <tr><td> <table cellpadding="4" cellspacing="1" border="0" width="100%"> <tr bgcolor="#eeeeee"> <td align="center"><font size="-2" face="verdana"><b>ORDER</b></font></td> <td align="center"><font size="-2" face="verdana"><b>NAME</b></font></td> <td align="center"><font size="-2" face="verdana"><b>DESCRIPTION</b></font></td> <% if (filterCount > 1) { %> <td align="center"><font size="-2" face="verdana"><b>MOVE</b></font></td> <% } %> <td align="center"><font size="-2" face="verdana"><b>EDIT</b></font></td> <td align="center"><font size="-2" face="verdana"><b>DELETE</b></font></td> </tr><% // Loop through all filters
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -