浏览代码

fix #1538 add filetype to advanced search page

Shinsuke Sugaya 7 年之前
父节点
当前提交
6284f2e6f7

+ 4 - 1
src/main/java/org/codelibs/fess/entity/SearchRequestParams.java

@@ -34,6 +34,8 @@ public interface SearchRequestParams {
 
 
     String AS_Q = "q";
     String AS_Q = "q";
 
 
+    String AS_FILETYPE = "filetype";
+
     String getQuery();
     String getQuery();
 
 
     Map<String, String[]> getFields();
     Map<String, String[]> getFields();
@@ -67,7 +69,8 @@ public interface SearchRequestParams {
         return !isEmptyArray(conditions.get(AS_Q))//
         return !isEmptyArray(conditions.get(AS_Q))//
                 || !isEmptyArray(conditions.get(AS_EPQ))//
                 || !isEmptyArray(conditions.get(AS_EPQ))//
                 || !isEmptyArray(conditions.get(AS_OQ))//
                 || !isEmptyArray(conditions.get(AS_OQ))//
-                || !isEmptyArray(conditions.get(AS_NQ));
+                || !isEmptyArray(conditions.get(AS_NQ))//
+                || !isEmptyArray(conditions.get(AS_FILETYPE));
     }
     }
 
 
     public default boolean isEmptyArray(String[] values) {
     public default boolean isEmptyArray(String[] values) {

+ 25 - 4
src/main/java/org/codelibs/fess/mylasta/action/FessLabels.java

@@ -2685,18 +2685,39 @@ public class FessLabels extends UserMessages {
     /** The key of the message: Advanced Search */
     /** The key of the message: Advanced Search */
     public static final String LABELS_advance_search_title = "{labels.advance_search_title}";
     public static final String LABELS_advance_search_title = "{labels.advance_search_title}";
 
 
-    /** The key of the message: All these words: */
+    /** The key of the message: All these words */
     public static final String LABELS_advance_search_must_queries = "{labels.advance_search_must_queries}";
     public static final String LABELS_advance_search_must_queries = "{labels.advance_search_must_queries}";
 
 
-    /** The key of the message: This exact word or phrase: */
+    /** The key of the message: This exact word or phrase */
     public static final String LABELS_advance_search_phrase_query = "{labels.advance_search_phrase_query}";
     public static final String LABELS_advance_search_phrase_query = "{labels.advance_search_phrase_query}";
 
 
-    /** The key of the message: Any of these words: */
+    /** The key of the message: Any of these words */
     public static final String LABELS_advance_search_should_queries = "{labels.advance_search_should_queries}";
     public static final String LABELS_advance_search_should_queries = "{labels.advance_search_should_queries}";
 
 
-    /** The key of the message: None of these words: */
+    /** The key of the message: None of these words */
     public static final String LABELS_advance_search_not_queries = "{labels.advance_search_not_queries}";
     public static final String LABELS_advance_search_not_queries = "{labels.advance_search_not_queries}";
 
 
+    /** The key of the message: File Type */
+    public static final String LABELS_advance_search_filetype = "{labels.advance_search_filetype}";
+
+    /** The key of the message: All Type */
+    public static final String LABELS_advance_search_filetype_default = "{labels.advance_search_filetype_default}";
+
+    /** The key of the message: HTML */
+    public static final String LABELS_advance_search_filetype_html = "{labels.advance_search_filetype_html}";
+
+    /** The key of the message: PDF */
+    public static final String LABELS_advance_search_filetype_pdf = "{labels.advance_search_filetype_pdf}";
+
+    /** The key of the message: MS Word */
+    public static final String LABELS_advance_search_filetype_word = "{labels.advance_search_filetype_word}";
+
+    /** The key of the message: MS Excel */
+    public static final String LABELS_advance_search_filetype_excel = "{labels.advance_search_filetype_excel}";
+
+    /** The key of the message: MS PowerPoint */
+    public static final String LABELS_advance_search_filetype_powerpoint = "{labels.advance_search_filetype_powerpoint}";
+
     /**
     /**
      * Assert the property is not null.
      * Assert the property is not null.
      * @param property The value of the property. (NotNull)
      * @param property The value of the property. (NotNull)

+ 3 - 0
src/main/java/org/codelibs/fess/util/QueryStringBuilder.java

@@ -124,6 +124,9 @@ public class QueryStringBuilder {
                                             s -> s.filter(StringUtil::isNotBlank).map(q -> "NOT " + q).collect(Collectors.joining(" ")));
                                             s -> s.filter(StringUtil::isNotBlank).map(q -> "NOT " + q).collect(Collectors.joining(" ")));
                             queryBuf.append(' ').append(nq);
                             queryBuf.append(' ').append(nq);
                         }));
                         }));
+        stream(conditions.get(SearchRequestParams.AS_FILETYPE)).of(
+                stream -> stream.filter(q -> StringUtil.isNotBlank(q) && q.length() <= maxQueryLength).forEach(
+                        q -> queryBuf.append(" filetype:\"").append(q.trim()).append('"')));
 
 
     }
     }
 
 

+ 7 - 0
src/main/resources/fess_label.properties

@@ -889,3 +889,10 @@ labels.advance_search_must_queries=All these words
 labels.advance_search_phrase_query=This exact word or phrase
 labels.advance_search_phrase_query=This exact word or phrase
 labels.advance_search_should_queries=Any of these words
 labels.advance_search_should_queries=Any of these words
 labels.advance_search_not_queries=None of these words
 labels.advance_search_not_queries=None of these words
+labels.advance_search_filetype=File Type
+labels.advance_search_filetype_default=All Type
+labels.advance_search_filetype_html=HTML
+labels.advance_search_filetype_pdf=PDF
+labels.advance_search_filetype_word=MS Word
+labels.advance_search_filetype_excel=MS Excel
+labels.advance_search_filetype_powerpoint=MS PowerPoint

+ 7 - 0
src/main/resources/fess_label_en.properties

@@ -889,3 +889,10 @@ labels.advance_search_must_queries=All these words
 labels.advance_search_phrase_query=This exact word or phrase
 labels.advance_search_phrase_query=This exact word or phrase
 labels.advance_search_should_queries=Any of these words
 labels.advance_search_should_queries=Any of these words
 labels.advance_search_not_queries=None of these words
 labels.advance_search_not_queries=None of these words
+labels.advance_search_filetype=File Type
+labels.advance_search_filetype_default=All Type
+labels.advance_search_filetype_html=HTML
+labels.advance_search_filetype_pdf=PDF
+labels.advance_search_filetype_word=MS Word
+labels.advance_search_filetype_excel=MS Excel
+labels.advance_search_filetype_powerpoint=MS PowerPoint

+ 7 - 0
src/main/resources/fess_label_ja.properties

@@ -891,3 +891,10 @@ labels.advance_search_must_queries=\u3059\u3079\u3066\u306e\u5358\u8a9e\u3092\u5
 labels.advance_search_phrase_query=\u8a9e\u9806\u3082\u542b\u3081\u305f\u5b8c\u5168\u4e00\u81f4
 labels.advance_search_phrase_query=\u8a9e\u9806\u3082\u542b\u3081\u305f\u5b8c\u5168\u4e00\u81f4
 labels.advance_search_should_queries=\u3044\u305a\u308c\u304b\u306e\u5358\u8a9e\u3092\u542b\u3080
 labels.advance_search_should_queries=\u3044\u305a\u308c\u304b\u306e\u5358\u8a9e\u3092\u542b\u3080
 labels.advance_search_not_queries=\u542b\u3081\u306a\u3044\u5358\u8a9e
 labels.advance_search_not_queries=\u542b\u3081\u306a\u3044\u5358\u8a9e
+labels.advance_search_filetype=\u30d5\u30a1\u30a4\u30eb\u5f62\u5f0f
+labels.advance_search_filetype_default=\u3059\u3079\u3066\u306e\u5f62\u5f0f
+labels.advance_search_filetype_html=HTML
+labels.advance_search_filetype_pdf=PDF
+labels.advance_search_filetype_word=MS Word
+labels.advance_search_filetype_excel=MS Excel
+labels.advance_search_filetype_powerpoint=MS PowerPoint

+ 28 - 0
src/main/webapp/WEB-INF/view/advance.jsp

@@ -233,6 +233,34 @@
 							</div>
 							</div>
 						</div>
 						</div>
 					</c:if>
 					</c:if>
+					<div class="form-group row">
+						<label for="as_filetype" class="col-lg-3 col-md-4 col-sm-5 col-xs-6 col-form-label"><la:message
+								key="labels.advance_search_filetype"
+							/></label>
+						<div class="col-lg-5 col-md-8 col-sm-7 col-xs-6">
+							<select id="as_filetype" name="as.filetype" class="form-control">
+								<option><la:message key="labels.advance_search_filetype_default" /></option>
+								<option value="html" <c:if test="${as.filetype.contains('html')}">selected</c:if>><la:message
+										key="labels.advance_search_filetype_html"
+									/></option>
+								<option value="pdf" <c:if test="${as.filetype.contains('pdf')}">selected</c:if>><la:message
+										key="labels.advance_search_filetype_pdf"
+									/></option>
+								<option value="word" <c:if test="${as.filetype.contains('word')}">selected</c:if>><la:message
+										key="labels.advance_search_filetype_word"
+									/></option>
+								<option value="excel" <c:if test="${as.filetype.contains('excel')}">selected</c:if>><la:message
+										key="labels.advance_search_filetype_excel"
+									/></option>
+								<option value="powerpoint" <c:if test="${as.filetype.contains('powerpoint')}">selected</c:if>><la:message
+										key="labels.advance_search_filetype_powerpoint"
+									/></option>
+							</select>
+						</div>
+						<div class="col-lg-4 hidden-md-down">
+							<!-- TODO -->
+						</div>
+					</div>
 
 
 					<div class="center">
 					<div class="center">
 						<button type="submit" name="search" id="searchButton" class="btn btn-primary">
 						<button type="submit" name="search" id="searchButton" class="btn btn-primary">