Very small cleanup
authorphilippe_mingo <philippe_mingo@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sun, 25 Nov 2001 18:12:03 +0000 (18:12 +0000)
committerphilippe_mingo <philippe_mingo@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sun, 25 Nov 2001 18:12:03 +0000 (18:12 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@1803 7612ce4b-ef26-0410-bec9-ea0150e637f0

src/search.php

index 2dda97c..90131e7 100644 (file)
    require_once('../functions/imap_search.php');
    require_once('../functions/array.php');
 
+    function s_opt( $val, $sel, $tit ) {
+        echo "            <option value=\"$val\"";
+        if ( $sel )
+            echo 'selected';
+        echo  ">$tit</option>\n";
+    }
+
    displayPageHeader($color, $mailbox);
    $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
 
    do_hook('search_before_form');
-   echo "<br>\n";
-   echo "      <table width=95% align=center cellpadding=2 cellspacing=0 border=0>\n";
-   echo "      <tr><td bgcolor=\"$color[0]\">\n";
-   echo "          <center><b>"._("Search")."</b></center>\n";
-   echo "      </td></tr>\n";
-   echo '      <tr><td align=center>';
+   echo "<br>\n".
+        "      <table width=95% align=center cellpadding=2 cellspacing=0 border=0>\n".
+        "      <tr><td bgcolor=\"$color[0]\">\n".
+        "          <center><b>"._("Search")."</b></center>\n".
+        "      </td></tr>\n".
+        '      <tr><td align=center>'.
 
-   echo "<FORM ACTION=\"search.php\" NAME=s>\n";
-   echo "   <TABLE WIDTH=\"75%\">\n";
-   echo "     <TR>\n";
-   echo "       <TD WIDTH=\"33%\">\n";
-   echo '         <TT><SMALL><SELECT NAME="mailbox">';
+        "<FORM ACTION=\"search.php\" NAME=s>\n".
+        "   <TABLE WIDTH=\"75%\">\n".
+        "     <TR>\n".
+        "       <TD WIDTH=\"33%\">\n".
+        '         <TT><SMALL><SELECT NAME="mailbox">';
 
    $boxes = sqimap_mailbox_list($imapConnection);
    for ($i = 0; $i < count($boxes); $i++) {
             echo "         <OPTION VALUE=\"$box\">$box2</OPTION>\n";
       }
    }
-   echo '         </SELECT></SMALL></TT>';
-   echo "       </TD>\n";
-   echo "        <TD ALIGN=\"CENTER\" WIDTH=\"33%\">\n";
+   echo '         </SELECT></SMALL></TT>'.
+        "       </TD>\n".
+        "        <TD ALIGN=\"CENTER\" WIDTH=\"33%\">\n";
    if (!isset($what))
        $what = '';
    $what_disp = ereg_replace(',', ' ', $what);
    $what_disp = str_replace('\\\\', '\\', $what_disp);
    $what_disp = str_replace('\\"', '"', $what_disp);
    $what_disp = str_replace('"', '&quot;', $what_disp);
-   echo "          <INPUT TYPE=\"TEXT\" SIZE=\"20\" NAME=\"what\" VALUE=\"$what_disp\">\n";
-   echo '        </TD>';
-   echo "       <TD ALIGN=\"RIGHT\" WIDTH=\"33%\">\n";
-   echo '         <SELECT NAME="where">';
-   
-   if (isset($where) && $where == 'BODY') echo '           <OPTION VALUE="BODY" SELECTED>'._("Body")."\n";
-   else echo '           <OPTION VALUE="BODY">'._("Body")."\n";
-   
-   if (isset($where) && $where == 'TEXT') echo '           <OPTION VALUE="TEXT" SELECTED>'._("Everywhere")."\n";
-   else echo '           <OPTION VALUE="TEXT">'._("Everywhere")."\n";
-   
-   if (isset($where) && $where == 'SUBJECT') echo '           <OPTION VALUE="SUBJECT" SELECTED>'._("Subject")."\n";
-   else echo '           <OPTION VALUE="SUBJECT">'._("Subject")."\n";
-   
-   if (isset($where) && $where == 'FROM') echo '           <OPTION VALUE="FROM" SELECTED>'._("From")."\n";
-   else echo '           <OPTION VALUE="FROM">'._("From")."\n";
-   
-   if (isset($where) && $where == 'CC') echo '           <OPTION VALUE="Cc" SELECTED>'._("Cc")."\n";
-   else echo '           <OPTION VALUE="CC">'._("Cc")."\n";
-   
-   if (isset($where) && $where == 'TO') echo '           <OPTION VALUE="TO" SELECTED>'._("To")."\n";
-   else echo '           <OPTION VALUE="TO">'._("To")."\n";
-   
-   echo "         </SELECT>\n";
-   echo "        </TD>\n";
-   echo "       <TD COLSPAN=\"3\" ALIGN=\"CENTER\">\n";
-   echo "         <INPUT TYPE=\"submit\" VALUE=\""._("Search")."\">\n";
-   echo "       </TD>\n";
-   echo "     </TR>\n";
-   echo "   </TABLE>\n"; 
-   echo "</FORM>";
-   echo "</td></tr></table>";
+   echo "          <INPUT TYPE=\"TEXT\" SIZE=\"20\" NAME=\"what\" VALUE=\"$what_disp\">\n".
+                '</TD>'.
+               "<TD ALIGN=\"RIGHT\" WIDTH=\"33%\">\n".
+                 '<SELECT NAME="where">';
+
+   s_opt( 'BODY', ($where == 'BODY'), _("Body") );
+   s_opt( 'TEXT', ($where == 'TEXT'), _("Everywhere") );
+   s_opt( 'SUBJECT', ($where == 'SUBJECT'), _("Subject") );
+   s_opt( 'FROM', ($where == 'FROM'), _("From") );
+   s_opt( 'CC', ($where == 'CC'), _("Cc") );
+   s_opt( 'TO', ($where == 'TO'), _("To") );
+
+   echo "         </SELECT>\n" .
+        "        </TD>\n".
+        "       <TD COLSPAN=\"3\" ALIGN=\"CENTER\">\n".
+        "         <INPUT TYPE=\"submit\" VALUE=\""._("Search")."\">\n".
+        "       </TD>\n".
+        "     </TR>\n".
+        "   </TABLE>\n".
+        "</FORM>".
+        "</td></tr></table>";
    do_hook("search_after_form");
    if (isset($where) && $where && isset($what) && $what) {   
       sqimap_mailbox_select($imapConnection, $mailbox);