[dev] Turba patch for "unified" basic and advanced search
Joel Vandal
jvandal at infoteck.qc.ca
Wed Jan 14 07:51:53 PST 2004
Hi,
Turba.diff : This patch "unify" the search mode (basic/advanced) in Turba so some functionality only available in basic search will now be available in advanced (like the : Move or Copy to "directory")
.
search_criteria.inc : Save this file in turba/templates/browse
After apply these change, you can remove all files in turba/templates/advanced/ and turba/advanced.php
I've made a lot of test and all work perfectly.
--
Joel Vandal Infoteck Internet
http://www.infoteck.qc.ca Tel. 819-370-3232
jvandal at infoteck.qc.ca Fax. 819-370-3624
-------------- next part --------------
===================================================================
RCS file: /repository/turba/browse.php,v
retrieving revision 1.47
diff -r1.47 browse.php
241a242,247
>
> if ($_SESSION['turba_search_mode'] == 'advanced') {
> $map = $driver->getCriteria();
> $templates[] = '/browse/search_criteria.inc';
> }
>
248c254,259
< $js_onLoad = 'document.directory_search.val.focus();';
---
>
> if ($_SESSION['turba_search_mode'] == 'basic') {
> $js_onLoad = 'document.directory_search.val.focus();';
> } else {
> $js_onLoad = 'document.directory_search.name.focus();';
> }
Index: search.php
===================================================================
RCS file: /repository/turba/search.php,v
retrieving revision 1.84
diff -r1.84 search.php
17a18,26
> /* Verify if the search mode variable is passed in form or is registered in
> the session. Always use basic search by default */
> if (Util::getFormData('search_mode')) {
> $_SESSION['turba_search_mode'] = Util::getFormData('search_mode');
> }
> if (!isset($_SESSION['turba_search_mode'])) {
> $_SESSION['turba_search_mode'] = 'basic';
> }
>
20c29
< if (!isset($_SESSION['turba_search_results'])) {
---
> if (!$conf['search']['search_result'] || !isset($_SESSION['turba_search_results'])) {
44,49c53,76
< if (isset($criteria) && isset($val)) {
< $driver = &Turba_Source::singleton($source, $cfgSources[$source]);
< if (is_a($driver, 'PEAR_Error')) {
< $notification->push(_("Failed to connect to the specified directory."), 'horde.error');
< } else {
< if (is_object($results = $driver->search(array($criteria => $val)))) {
---
> $driver = &Turba_Source::singleton($source, $cfgSources[$source]);
> if (is_a($driver, 'PEAR_Error')) {
> $notification->push(_("Failed to connect to the specified directory."), 'horde.error');
> $map = array();
> } else {
> $map = $driver->getCriteria();
>
> if ($_SESSION['turba_search_mode'] == 'advanced') {
> $criteria = array();
> foreach ($map as $key => $value) {
> if ($key != '__key') {
> $val = Util::getFormData($key);
> if (!empty($val)) {
> $criteria[$key] = $val;
> }
> }
> }
> }
>
> if (isset($criteria) && isset($val)) {
> if (($_SESSION['turba_search_mode'] == 'basic' && is_object($results = $driver->search(array($criteria => $val))))
> or
> ($_SESSION['turba_search_mode'] == 'advanced' && is_object($results = $driver->search($criteria)))) {
>
68,69c95,102
< $title = _("Search");
< $js_onLoad = 'document.directory_search.val.focus();';
---
> if ($_SESSION['turba_search_mode'] == 'basic') {
> $title = _("Basic Search");
> $js_onLoad = 'document.directory_search.val.focus();';
> } else {
> $title = _("Advanced Search");
> $js_onLoad = 'document.directory_search.name.focus();';
> }
>
71a105
>
72a107,111
>
> if ($_SESSION['turba_search_mode'] == 'advanced') {
> require TURBA_TEMPLATES . '/browse/search_criteria.inc';
> }
>
Index: config/conf.xml
===================================================================
RCS file: /repository/turba/config/conf.xml,v
retrieving revision 1.4
diff -r1.4 conf.xml
21a22,27
> <configsection name="search">
> <configheader>
> Settings for Search
> </configheader>
> <configboolean name="search_result" desc="Should we keep old search result in session?">true</configboolean>
> </configsection>
Index: lib/api.php
===================================================================
RCS file: /repository/turba/lib/api.php,v
retrieving revision 1.74
diff -r1.74 api.php
272c272
< $results[$name][] = array_merge($att,
---
> $results[$name][] = array_merge($att,
378d377
<
Index: templates/browse/actions.inc
===================================================================
RCS file: /repository/turba/templates/browse/actions.inc,v
retrieving revision 1.11
diff -r1.11 actions.inc
65,66c65,70
< $search_link = Util::addParameter(Horde::applicationUrl('search.php'), 'source', $source);
< echo Horde::widget(Util::addParameter($search_link, 'clear', '1'), _("Clear Search"), 'widget', '', '', _("Clear Search"));
---
> if ($conf['search']['search_result']) {
> $search_link = Util::addParameter(Horde::applicationUrl('search.php'), 'source', $source);
> echo Horde::widget(Util::addParameter($search_link, 'clear', '1'), _("Clear Search"), 'widget', '', '', _("Clear Search"));
> } else {
> echo ' ';
> }
Index: templates/browse/search.inc
===================================================================
RCS file: /repository/turba/templates/browse/search.inc,v
retrieving revision 1.3
diff -r1.3 search.inc
28a29,30
>
> <?php if ($_SESSION['turba_search_mode'] == 'basic'): ?>
56a59,78
> <table border="0" cellpadding="1" cellspacing="0" width="100%">
> <tr class="header">
> <?php if ($_SESSION['turba_search_mode'] == 'basic'): ?>
> <td class="header">
> <b><?php echo _("Basic Search") ?></b>
> </td>
> <td align="right" class="header">
> <a class="menuitem" href="<?php echo Horde::url('search.php?search_mode=advanced') ?>"><?php echo _("Advanced Search") ?></a>
> </td>
> <?php else: ?>
> <td class="header">
> <b><?php echo _("Advanced Search") ?></b>
> </td>
> <td align="right" class="header">
> <a class="menuitem" href="<?php echo Horde::url('search.php?search_mode=basic') ?>"><?php echo _("Basic Search") ?></a>
> </td>
> <?php endif; ?>
> </tr>
>
> </table>
59d80
< <td class="header" align="left"><b><?php echo _("Search") ?></b></td>
96a118,150
>
>
> <?php else: ?>
>
> <form name="directory_search" action="<?php echo Horde::applicationUrl('search.php') ?>" method="get">
> <?php echo Util::formInput() ?>
>
> <table border="0" cellpadding="1" cellspacing="0" width="100%">
> <tr class="header">
> <td class="header">
> <b><?php echo _("Advanced Search") ?></b>
> </td>
> <td align="right" class="header">
> <a class="menuitem" href="<?php echo Horde::url('search.php?search_mode=basic') ?>"><?php echo _("Basic Search") ?></a>
> </td>
> </tr>
> </table>
>
> <table border="0" cellpadding="0" cellspacing="5" width="100%">
> <tr>
> <td> </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>
>
> <tr><td class="light" align="right"><b><?php echo _("Directory") ?></b></td>
> <td align="left"><select name="source" onchange="directory_search.submit()">
> <?php echo $source_options ?>
> </select></td></tr>
>
> <?php endif; ?>
Index: templates/menu/menu.inc
===================================================================
RCS file: /repository/turba/templates/menu/menu.inc,v
retrieving revision 1.28
diff -r1.28 menu.inc
9d8
< Menu::printItem(Horde::applicationUrl('advanced.php'), _("Advanced Search"), 'search.gif');
-------------- next part --------------
<?php
foreach ($map as $name => $v) {
if ($name != '__owner' &&
$name != '__type' &&
$name != '__members') {
?>
<tr>
<td width="1%" nowrap="nowrap" class="light" align="right"><b><?php echo $attributes[$name]['label'] ?></b></td>
<td align="left"><input type="text" size="30" name="<?php echo $name ?>" /></td>
</tr>
<?php
}
}
?>
</table>
</form>
More information about the dev
mailing list