[prev in list] [next in list] [prev in thread] [next in thread] 

List:       turba
Subject:    [turba] advanced search
From:       Bo Daley <bo () tilda ! com ! au>
Date:       2003-12-22 3:49:28
[Download RAW message or body]

This message is in MIME format.


hi all,

I don't know if this is going to be useful to anyone else, but after talking to
a couple of users it seemed that they wanted a couple of changes to the
appearance of the advanced search in Turba. They requested:

- ability to specify that some fields should not appear on the advanced search
page. (eg. it doesn't make much sense for 'spacer' fields to be displayed, but
there might be others too).

- a preference to determine whether the search results should appear above or
below the advanced search form. This is because that search form can get very
long, and users were complaining about how far down the page they need to
scroll to see the results.

there are probably better ways to do this, but here's a quick patch that
implements these. does this look ok?

thanks,

bo.


["advsrch.diff" (text/x-diff)]

Index: advanced.php
===================================================================
RCS file: /repository/turba/advanced.php,v
retrieving revision 1.48
diff -u -r1.48 advanced.php
--- advanced.php	7 Nov 2003 21:31:40 -0000	1.48
+++ advanced.php	22 Dec 2003 02:05:40 -0000
@@ -94,16 +94,23 @@
 $width = floor(100 / (count($columns) + 1));
 
 Turba::menu();
-require TURBA_TEMPLATES . '/advanced/head.inc';
 
+ob_start();
+require TURBA_TEMPLATES . '/advanced/head.inc';
 foreach ($map as $name => $v) {
+    $searchable = isset($attributes[$name]['searchable']) ? \
$attributes[$name]['searchable'] : true;  if ($name != '__owner' &&
         $name != '__type' &&
-        $name != '__members') {
+        $name != '__members' &&
+        $searchable != false) {
         require TURBA_TEMPLATES . '/advanced/criteria.inc';
     }
 }
+require TURBA_TEMPLATES . '/advanced/criteria_foot.inc';
+$ob_criteria = ob_get_contents();
+ob_end_clean();
 
+ob_start();
 $addresses = Util::getFormData('addresses');
 if (is_object($_SESSION['turba_search_results']) &&
     ($_SESSION['turba_search_results']->count() > 0)) {
@@ -117,6 +124,16 @@
     $display = new Turba_ListView($_SESSION['turba_search_results'], TURBA_TEMPLATES \
. '/browse/contactrow.inc');  $numDisplayed = $display->display();
     $_SESSION['turba_search_results'] = \
$_SESSION['turba_search_results']->serialize(); +}
+$ob_results = ob_get_contents();
+ob_end_clean();
+
+// Display search form and results in the order specified in the user's pref
+$adv_results_placement = $prefs->getValue('adv_results_placement');
+if ($adv_results_placement == 'below') {
+    echo $ob_criteria . $ob_results;
+} else {
+    echo $ob_results . $ob_criteria;
 }
 
 require TURBA_TEMPLATES . '/advanced/foot.inc';
Index: config/attributes.php.dist
===================================================================
RCS file: /repository/turba/config/attributes.php.dist,v
retrieving revision 1.27
diff -u -r1.27 attributes.php.dist
--- config/attributes.php.dist	1 Sep 2003 00:31:14 -0000	1.27
+++ config/attributes.php.dist	22 Dec 2003 02:05:40 -0000
@@ -30,12 +30,14 @@
  *                      - colorpicker       - sorter
  *                      - creditcard        - invalid
  *                      - stringlist
- *      required - boolean, true or false whether this field is mandatory
- *      readonly - boolean, true or false whether this editable
- *      desc     - any help text attached to the field
- *      params   - any other parameters that need to be passed to the field
- *                 such as a list to be used in the enum field, the row and
- *                 column sizing for a longtext field, TODO (list more types)
+ *      required   - boolean, true or false whether this field is mandatory
+ *      readonly   - boolean, true or false whether this editable
+ *      desc       - any help text attached to the field
+ *      searchable - boolean, true or false whether this field should appear 
+ *                   on the advanced search page. defaults to true.
+ *      params     - any other parameters that need to be passed to the field
+ *                   such as a list to be used in the enum field, the row and
+ *                   column sizing for a longtext field, TODO (list more types)
  */
 
 $attributes['name'] = array(
Index: config/prefs.php.dist
===================================================================
RCS file: /repository/turba/config/prefs.php.dist,v
retrieving revision 1.19
diff -u -r1.19 prefs.php.dist
--- config/prefs.php.dist	5 Dec 2003 18:49:39 -0000	1.19
+++ config/prefs.php.dist	22 Dec 2003 02:05:40 -0000
@@ -33,7 +33,7 @@
     'column' => _("Display Options"),
     'label' => _("Searching Options"),
     'desc' => _("Choose a default directory for your personal addressbook, contact \
                lists, and searches."),
-    'members' => array('default_dir')
+    'members' => array('default_dir', 'adv_results_placement')
 );
 
 $prefGroups['application'] = array(
@@ -118,6 +118,17 @@
     'desc' => _("Default directory for your personal addressbook, contact lists, and \
searches.")  );
 
+// Advanced search results placement. Are results positioned above or below the \
search form? +$_prefs['adv_results_placement'] = array(
+    'value' => 'below',
+    'locked' => false,
+    'shared' => false,
+    'type' => 'enum',
+    'desc' => _("Specify where you want advanced search results to appear."),
+    'enum' => array('below' => _("Below search form"),
+                    'above'  => _("Above search form"))
+);
+
 // preference for holding any preferences-based addressbooks.
 $_prefs['prefbooks'] = array(
     'value' => '',
@@ -133,4 +144,4 @@
     'shared' => false,
     'type' => 'checkbox',
     'desc' => _("Should Turba prompt you before deleting objects?")
-);
\ No newline at end of file
+);
Index: templates/advanced/results_head.inc
===================================================================
RCS file: /repository/turba/templates/advanced/results_head.inc,v
retrieving revision 1.20
diff -u -r1.20 results_head.inc
--- templates/advanced/results_head.inc	13 Dec 2003 15:14:23 -0000	1.20
+++ templates/advanced/results_head.inc	22 Dec 2003 02:05:40 -0000
@@ -1,14 +1,3 @@
-<tr>
-  <td>&nbsp;</td>
-  <td>
-    <input type="submit" class="button" name="search" value="<?php echo _("Search") \
                ?>" />
-    <input type="reset" class="button" name="reset" value="<?php echo _("Reset") ?>" \
                />
-  </td>
-</tr>
-</table>
-</form>
-
-<br />
 
 <form method="post" name="contacts" action="<?php echo Horde::selfURL() ?>">
 <?php echo Util::formInput() ?>


["criteria_foot.inc" (application/octet-stream)]

-- 
Turba mailing list
Frequently Asked Questions: http://horde.org/faq/
To unsubscribe, mail: turba-unsubscribe@lists.horde.org


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic