Author: jeremy
Date: Tue Nov 23 06:00:43 2004
New Revision: 106299

Modified:
   cocoon/trunk/src/blocks/querybean/samples/flow/QuerySearcher.js
   cocoon/trunk/src/blocks/querybean/samples/i18n/messages_en.xml
   cocoon/trunk/src/blocks/querybean/samples/screens/results.xml
Log:
adding Query Tips to querybean block

Modified: cocoon/trunk/src/blocks/querybean/samples/flow/QuerySearcher.js
Url: 
http://svn.apache.org/viewcvs/cocoon/trunk/src/blocks/querybean/samples/flow/QuerySearcher.js?view=diff&rev=106299&p1=cocoon/trunk/src/blocks/querybean/samples/flow/QuerySearcher.js&r1=106298&p2=cocoon/trunk/src/blocks/querybean/samples/flow/QuerySearcher.js&r2=106299
==============================================================================
--- cocoon/trunk/src/blocks/querybean/samples/flow/QuerySearcher.js     
(original)
+++ cocoon/trunk/src/blocks/querybean/samples/flow/QuerySearcher.js     Tue Nov 
23 06:00:43 2004
@@ -114,11 +114,26 @@
        return new SimpleLuceneQueryBean(type, bool, match, field, "");
 }
 
-
-
-
 QuerySearcher.prototype.getTip = function(query) {
-       return null;
+       if (query.total > this._high) {
+               return ("query.tip.high");
+       } else if (query.total < this._low) {
+               var allProhibited = true;
+               var criteria = query.getCriteria();
+               for (var i = 0; i < criteria.size(); i++) {
+                       if (!criteria.get(i).isProhibited()) {
+                               allProhibited = false;
+                               break;
+                       }
+               }
+               if (allProhibited) {
+                       return ("query.tip.prohibited");
+               } else {
+                       return ("query.tip.low");
+               }
+       } else {
+               return null;
+       }
 }
 
 

Modified: cocoon/trunk/src/blocks/querybean/samples/i18n/messages_en.xml
Url: 
http://svn.apache.org/viewcvs/cocoon/trunk/src/blocks/querybean/samples/i18n/messages_en.xml?view=diff&rev=106299&p1=cocoon/trunk/src/blocks/querybean/samples/i18n/messages_en.xml&r1=106298&p2=cocoon/trunk/src/blocks/querybean/samples/i18n/messages_en.xml&r2=106299
==============================================================================
--- cocoon/trunk/src/blocks/querybean/samples/i18n/messages_en.xml      
(original)
+++ cocoon/trunk/src/blocks/querybean/samples/i18n/messages_en.xml      Tue Nov 
23 06:00:43 2004
@@ -147,6 +147,32 @@
   <message key="simple.page.title">A simple query</message>
        <message key="required.note">* required</message>
        <message key="cancel.note">you cancelled your edit</message>
+       <!-- tips -->
+       <message key="query.tip.title">Query Tips</message>
+       <message key="query.tip.high">
+               <p>You can reduce the number of hits like this:
+                       <ul>
+                               <li>Try adding one or more criteria that match 
using "does not contain", to remove unwanted hits.</li>
+                               <li>Try searching in specific fields instead of 
all fields.</li>
+                               <li>Try requiring that all of your search 
criteria are matched, instead of just some of them.</li>
+                               <li>Try increasing the number of required 
criteria.</li>
+                               <li>Try using the match "contains the phrase" 
or "contains all words in".</li>
+                       </ul>
+               </p>
+       </message>
+       <message key="query.tip.low">
+               <p>You can increase the number of hits like this:
+                       <ul>
+                               <li>Try searching in all fields rather than a 
specific field.</li>
+                               <li>Try matching your words using "is somthing 
like" or "contains any word in".</li>
+                               <li>Try allowing the query to only match some 
of your criteria, instead of all of them.</li>
+                               <li>Try increasing the number of non-required 
criteria.</li>
+                       </ul>
+               </p>
+       </message>
+       <message key="query.tip.prohibited">
+               <p>All of your criteria are matched using  "does not contain", 
this query will not work until you add at least one criterion that positively 
finds something, then the prohibiting criteria can filter hits from that 
one.</p>
+       </message>      
        <!-- errors -->
   <message key="search.error.noquery">There was no query</message>
   <message key="search.error.nohistory">You have no history at the 
moment</message>

Modified: cocoon/trunk/src/blocks/querybean/samples/screens/results.xml
Url: 
http://svn.apache.org/viewcvs/cocoon/trunk/src/blocks/querybean/samples/screens/results.xml?view=diff&rev=106299&p1=cocoon/trunk/src/blocks/querybean/samples/screens/results.xml&r1=106298&p2=cocoon/trunk/src/blocks/querybean/samples/screens/results.xml&r2=106299
==============================================================================
--- cocoon/trunk/src/blocks/querybean/samples/screens/results.xml       
(original)
+++ cocoon/trunk/src/blocks/querybean/samples/screens/results.xml       Tue Nov 
23 06:00:43 2004
@@ -52,9 +52,6 @@
                                </jx:forEach>
                        </ul>
                </p>
-               <jx:if test="${result.tip != null}">
-                       <i18n:text 
i18n:catalogue="local">${result.tip}</i18n:text>
-               </jx:if>
                <!-- links -->
                <p class="links">
                        <a href="${result.query.type}.html?hid=${result.id}" 
title="local:search.edit.hint" i18n:attr="title"><i18n:text 
i18n:catalogue="local">search.edit.title</i18n:text></a>
@@ -126,5 +123,9 @@
                                <p class="query.results-none"><i18n:text 
i18n:catalogue="local">search.norecords.note</i18n:text></p>
                        </jx:otherwise>
                </jx:choose>
+               <jx:if test="${result.tip != null}">
+                       <title><i18n:text 
i18n:catalogue="local">query.tip.title</i18n:text></title>
+                       <i18n:text 
i18n:catalogue="local">${result.tip}</i18n:text>
+               </jx:if>
        </content>
 </page>

Reply via email to