[dev] Turba patch for "unified" basic and advanced search

Joel Vandal jvandal at infoteck.qc.ca
Thu Jan 15 16:25:35 PST 2004


Hi Chuck,

> Looks nice - I've comitted it. Thanks! Here's a request, if you get to it
and
> feel like it - if search results are cached in the session, it'd be great
to be
> able to see them when you're in the UI for either a basic or advanced
search
> (at the bottom of the page).

Now all search results that are cached are displayed at the bottom of the
page, immediatly after the last search results. When you change the sorting,
cached results are still at the bottom. If it's what you want, so check the
patch.

Also, I have receive a request from by boss for display the total # of
result at the bottom of the page. I've notice that browse.php have a
variable $numDisplayed but it's not used anywhere, so I have patch the
templates/browse/footer.inc to display this variable.

Index: templates/browse/footer.inc
===================================================================
RCS file: /repository/turba/templates/browse/footer.inc,v
retrieving revision 1.2
diff -r1.2 footer.inc
1a2,4
> <table border="0" cellpadding="0" cellspacing="4">
> <tr><td class="legend"><b>Search result :</b> <?php echo $numDisplayed;
?></td></tr>
> </table>


-- 
Joel Vandal                                    Infoteck Internet
http://www.infoteck.qc.ca            Tel.  819-370-3232
jvandal at infoteck.qc.ca                 Fax. 819-370-3624
-------------- next part --------------
Index: browse.php
===================================================================
RCS file: /repository/turba/browse.php,v
retrieving revision 1.48
diff -r1.48 browse.php
239d238
<         $results->sort($sortcolumn, $prefs->getValue('sortdir'));
240a240,256
>         $old = &new Turba_List();
>         $new = &new Turba_List();
>         $combinedResults = &new Turba_List();
> 
> $new->merge($results->split(TRUE));
> $old->merge($results->split(FALSE));
> 
>         $old->sort($sortcolumn, $prefs->getValue('sortdir')); 
>         $new->sort($sortcolumn, $prefs->getValue('sortdir'));
> 
> $combinedResults->merge($new);
> $combinedResults->merge($old);
> 
> $results = $combinedResults;
> 
> $results->fresh = $new->fresh;
> 
262c278,279
<         $display = &new Turba_ListView($results, TURBA_TEMPLATES . '/browse/contactrow.inc');
---
> 
>       $display = &new Turba_ListView($results, TURBA_TEMPLATES . '/browse/contactrow.inc');
Index: lib/List.php
===================================================================
RCS file: /repository/turba/lib/List.php,v
retrieving revision 1.38
diff -r1.38 List.php
87a88,114
>      * Split an existing Turba_List and extract only fresh or old info.
>      *
>      * @param          boolean $new   Extract fresh or old from Turba_List object.
>      */
>     function split($new)
>     {
>         $fresh = &new Turba_List();
>         $old = &new Turba_List();
> 
>         foreach ($this->objects as $object) {
>            if (is_a($object, 'Turba_AbstractObject')) {
>               $source = $object->source->name;
>               $key = $source . ':' . $object->getValue('__key');
> 
>               if (isset($GLOBALS['cfgSources'][$source])) {
>                  if (isset($this->fresh[$key])) {
>                     $fresh->insert($object, TRUE);
>                  } else {
>                     $old->insert($object, FALSE);
>                  }
>               }
>            }
>         }
>         return ($new) ? $fresh : $old;
>     }
>     
>     /**


More information about the dev mailing list