X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=src%2Fsearch.php;h=7e037d223a019898a7ca92f5ee249c599a410dc8;hb=65efa9821218829082c7e0c68705f782d10172bb;hp=427fb16e7ef63e0303aa0c1dfc7ffb8ac4de4f30;hpb=b4425d7ce91c080f3f801694880dc8e3d15de9d9;p=squirrelmail.git
diff --git a/src/search.php b/src/search.php
index 427fb16e..7e037d22 100644
--- a/src/search.php
+++ b/src/search.php
@@ -47,47 +47,6 @@ define('ASEARCH_MAX', 7);
*/
define('ASEARCH_CRITERIA', 'criteria');
-/** Builds a href with params
- * @param string $params optional parameters to GET
- * @since 1.5.1
- * @private
- */
-function asearch_get_href($params = '')
-{
- $href = 'search.php';
- if ($params != '')
- $href .= '?' . $params;
- return $href;
-}
-
-/** Builds a [link]
- * @param string $href (reference) URL
- * @param string $text link name
- * @param string $title link title attribute value
- * @since 1.5.1
- * @private
- */
-function asearch_get_link(&$href, $text, $title = '')
-{
- if ($title != '')
- $title = ' title="' . $title . '"';
- return '' . $text . '';
-}
-
-/** Builds a toggle [link]
- * @param integer $value
- * @param string $action
- * @param array $text_array
- * @param array $title_array
- * @since 1.5.1
- * @private
- */
-function asearch_get_toggle_link($value, $action, $text_array, $title_array = array())
-{
- $asearch_nz=asearch_nz($title_array[$value]);
- $asearch_get_href=asearch_get_href($action . '=' . (int)$value);
- return asearch_get_link($asearch_get_href, $text_array[$value], $asearch_nz);
-}
/**
* Array sort callback used to sort $imap_asearch_options
@@ -103,20 +62,6 @@ function asearch_unhtml_strcoll($a, $b)
return strcoll(asearch_unhtmlentities($a), asearch_unhtmlentities($b));
}
-
-/**
- * @param string $mailbox mailbox name utf7 encoded inc. special case INBOX
- * @return string mailbox name ready to display (utf7 decoded or localized INBOX)
- * @since 1.5.0
- * @private
- */
-function imap_get_mailbox_display($mailbox)
-{
- if (strtoupper($mailbox) == 'INBOX')
- return _("INBOX");
- return imap_utf7_decode_local($mailbox);
-}
-
/**
* @param string $mailbox mailbox name or special case 'All Folders'
* @return string mailbox name ready to display (utf7 decoded or localized 'All Folders')
@@ -125,32 +70,12 @@ function imap_get_mailbox_display($mailbox)
*/
function asearch_get_mailbox_display($mailbox)
{
- if ($mailbox == 'All Folders')
+ if ($mailbox == 'All Folders') {
return _("All Folders");
- return imap_get_mailbox_display($mailbox);
-}
-
-/**
- * @param array $color color array (unused)
- * @param string $txt text to display
- * @return string title ready to display
- * @since 1.5.0
- * @private
- */
-function asearch_get_title_display($color, $txt)
-{
- return '' . $txt . '';
-}
-/**
- * @param array $color color array
- * @param string $txt text to display
- * @return string error text ready to display
- * @since 1.5.0
- * @private
- */
-function asearch_get_error_display($color, $txt)
-{
- return '' . '' . $txt . '';
+ } elseif (strtoupper($mailbox) == 'INBOX') {
+ return _("INBOX");
+ }
+ return imap_utf7_decode_local($mailbox);
}
/**
@@ -651,7 +576,7 @@ function asearch_get_query_display(&$color, &$mailbox_array, &$biop_array, &$uno
$cur_mailbox = 'INBOX';
$biop = asearch_nz($biop_array[$crit_num]);
if (($query_display == '') || ($cur_mailbox != $last_mailbox)) {
- $mailbox_display = ' ' . htmlspecialchars(asearch_get_mailbox_display($cur_mailbox)) . '';
+ $mailbox_display = ' ' . htmlspecialchars(asearch_get_mailbox_display($cur_mailbox)) . '';
if ($query_display == '')
$biop_display = _("In");
else
@@ -672,25 +597,25 @@ function asearch_get_query_display(&$color, &$mailbox_array, &$biop_array, &$uno
$what = $what_array[$crit_num];
if ($what_type) { /* Check opcode parameter */
if ($what == '')
- $what_display = ' ' . asearch_get_error_display($color, _("(Missing argument)"));
+ $what_display = ' ' . _("(Missing argument)") .'';
else {
if ($what_type == 'adate')
$what_display = asearch_get_date_display($what);
else
$what_display = htmlspecialchars($what);
- $what_display = ' ' . $what_display . '';
+ $what_display = ' ' . $what_display . '';
}
}
else {
if ($what)
- $what_display = ' ' . asearch_get_error_display($color, _("(Spurious argument)"));
+ $what_display = ' ' . _("(Spurious argument)") .'';
else
$what_display = '';
}
if ($mailbox_display != '')
- $query_display .= ' ' . $biop_display . '' . $mailbox_display . ' ' . $where_display . '' . $what_display;
+ $query_display .= ' ' . $biop_display . '' . $mailbox_display . ' ' . $where_display . '' . $what_display;
else
- $query_display .= ' ' . $biop_display . ' ' . $where_display . '' . $what_display;
+ $query_display .= ' ' . $biop_display . ' ' . $where_display . '' . $what_display;
}
}
return $query_display;
@@ -716,28 +641,6 @@ function getButton($type, $name, $value, $js = '', $enabled = TRUE) {
'" style="padding: 0px; margin: 0px" />';
}
-
-/** Handle the alternate row colors
- * @param array $color color theme array
- * @param integer $row_num
- * @return string color value
- * @since 1.5.0
- * @private
- */
-function asearch_get_row_color(&$color, $row_num)
-{
-/*$color_string = ($row_num%2 ? $color[0] : $color[4]);*/
- $color_string = $color[4];
- if ($GLOBALS['alt_index_colors']) {
- if (($row_num % 2) == 0) {
- if (!isset($color[12]))
- $color[12] = '#EAEAEA';
- $color_string = $color[12];
- }
- }
- return $color_string;
-}
-
/**
* Print a whole query array, recent or saved
*
@@ -753,58 +656,49 @@ function asearch_get_row_color(&$color, $row_num)
*/
function asearch_print_query_array(&$boxes, &$query_array, &$query_keys, &$action_array, $title, $show_pref)
{
- global $color;
global $data_dir, $username;
- global $use_icons, $icon_theme;
+ global $icon_theme_path;
+ global $oTemplate;
$show_flag = getPref($data_dir, $username, $show_pref, 0) & 1;
- $use_icons_flag = ($use_icons) && ($icon_theme != 'none');
- if ($use_icons_flag)
- $text_array = array('',
- '');
- else
- $text_array = array('-', '+');
- $toggle_link = asearch_get_toggle_link(!$show_flag, $show_pref, $text_array, array(_("Fold"), _("Unfold")));
- if (!$use_icons_flag)
- $toggle_link = '[' . $toggle_link . ']';
-
- echo "
\n";
- echo html_tag('table', '', 'center', $color[9], 'width="95%" cellpadding="1" cellspacing="1" border="0"');
- echo html_tag('tr',
- html_tag('td', $toggle_link, 'center', $color[5], 'width="5%"')
- . html_tag('td', asearch_get_title_display($color, $title), 'center', $color[5], 'colspan=4'));
- if ($show_flag) {
- $main_key = $query_keys[ASEARCH_WHERE];
- $query_count = count($query_array[$main_key]);
- for ($query_num = 0, $row_num = 0; $query_num < $query_count; $query_num++) {
- if (!empty($query_array[$main_key][$query_num])) {
- echo html_tag('tr', '', '', asearch_get_row_color($color, $row_num));
-
- unset($search_array);
- foreach ($query_keys as $query_key) {
- $search_array[] = asearch_unserialize($query_array[$query_key][$query_num]);
- }
- $where_array = $search_array[ASEARCH_WHERE];
- $mailbox_array = $search_array[ASEARCH_MAILBOX];
- $what_array = $search_array[ASEARCH_WHAT];
- $unop_array = $search_array[ASEARCH_UNOP];
- $biop_array = asearch_nz($search_array[ASEARCH_BIOP], array());
- $exclude_array = asearch_nz($search_array[ASEARCH_EXCLUDE], array());
- $sub_array = asearch_nz($search_array[ASEARCH_SUB], array());
- $query_display = asearch_get_query_display($color, $mailbox_array, $biop_array, $unop_array, $where_array, $what_array, $exclude_array, $sub_array);
-
- echo html_tag('td', $query_num + 1, 'right');
- echo html_tag('td', $query_display, 'center', '', 'width="80%"');
- foreach ($action_array as $action => $action_display) {
- echo html_tag('td', '' . $action_display . '', 'center');
- }
-
- echo '' . "\n";
- $row_num++;
+ $a = array();
+ $main_key = $query_keys[ASEARCH_WHERE];
+ $query_count = count($query_array[$main_key]);
+ for ($query_num = 0, $row_num = 0; $query_num < $query_count; $query_num++) {
+ if (!empty($query_array[$main_key][$query_num])) {
+ unset($search_array);
+ foreach ($query_keys as $query_key) {
+ $search_array[] = asearch_unserialize($query_array[$query_key][$query_num]);
}
+
+ $where_array = $search_array[ASEARCH_WHERE];
+ $mailbox_array = $search_array[ASEARCH_MAILBOX];
+ $what_array = $search_array[ASEARCH_WHAT];
+ $unop_array = $search_array[ASEARCH_UNOP];
+ $biop_array = asearch_nz($search_array[ASEARCH_BIOP], array());
+ $exclude_array = asearch_nz($search_array[ASEARCH_EXCLUDE], array());
+ $sub_array = asearch_nz($search_array[ASEARCH_SUB], array());
+ $query_display = asearch_get_query_display($color, $mailbox_array, $biop_array, $unop_array, $where_array, $what_array, $exclude_array, $sub_array);
+
+ $a[$query_num] = $query_display;
}
}
- echo '' . "\n";
+
+ $oTemplate->assign('list_title', $title);
+ $oTemplate->assign('show_list', $show_flag==1);
+ $oTemplate->assign('is_recent_list', $title==_("Recent Searches"));
+ $oTemplate->assign('expand_collapse_toggle', '../src/search.php?'.$show_pref.'='.($show_flag==1 ? 0 : 1));
+ $oTemplate->assign('query_list', $a);
+
+ $oTemplate->assign('save_recent', '../src/search.php?submit=save_recent&rownum=');
+ $oTemplate->assign('do_recent', '../src/search.php?submit=search_recent&rownum=');
+ $oTemplate->assign('forget_recent', '../src/search.php?submit=forget_recent&rownum=');
+
+ $oTemplate->assign('edit_saved', '../src/search.php?submit=edit_saved&rownum=');
+ $oTemplate->assign('do_saved', '../src/search.php?submit=search_saved&rownum=');
+ $oTemplate->assign('delete_saved', '../src/search.php?submit=delete_saved&rownum=');
+
+ $oTemplate->display('search_list.tpl');
}
/** Print the saved array
@@ -850,39 +744,6 @@ function asearch_print_recent(&$boxes)
}
}
-/**
- * Build an ' . "\n";
-}
-
-/** Build a