savannah-hackers-public
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Savannah-hackers-public] exact search code proposal


From: nick alvaro
Subject: [Savannah-hackers-public] exact search code proposal
Date: Mon, 28 Apr 2008 10:27:30 -0700 (PDT)

function search_send_header was causing me some issues so I had to change it. I 
called for the search_exact function in the search_send_header function's "if 
($type_of_search == "soft")" expression and moved each "<h3>" to each 
$type_of_search expression as well. This is because the exact search result has 
to come after the header is called and after the Search Criteria box is called 
but before the heading 3 is printed out. 

Here are my proposed changes:

function search_send_header ()
----CUT A LOT OF CODE OUT FOR EMAIL-----
  if ($words && $type_of_search)
    {
      # Print real words describing the type of search
      if ($type_of_search == "soft")
        { $type_of_search_real = _("Project/Group"); 
         search_exact($words);
         print '<h3>';
        }
      else if ($type_of_search == "support")
        { $type_of_search_real = _("Support");
         print '<h3>';
         }
      else if ($type_of_search == "bugs")
        { $type_of_search_real = _("Bugs"); 
         print '<h3>';    
        }
      else if ($type_of_search == "task")
        { $type_of_search_real = _("Task"); 
          print '<h3>';
        }
      else if ($type_of_search == "patch")
        { $type_of_search_real = _("Patch"); 
          print '<h3>';
        }
      else if ($type_of_search == "cookbook")
        { $type_of_search_real = _("Cookbook"); 
          print '<h3>';
        }
      else if ($type_of_search == "people")
        { $type_of_search_real = _("People"); 
          print '<h3>';

----CUT A LOT OF CODE OUT FOR EMAIL-----

function search_exact()

function search_exact ($keywords, $return_error_messages=1)
{

        // Find the characters that maybe for a non-precise search. No need to 
continue if it they are present.
        $non_precise_key1 = strpos($keywords, '*' );
        $non_precise_key2 = strpos($keywords, '%' );

        if ($non_precise_key1 === false && $non_precise_key2 === false)
           {    
        
           $sql_exact = "SELECT 
group_name,short_description,type,unix_group_name FROM groups WHERE group_name 
IN('$keywords') AND status='A' AND is_public='1'";
        
           $result_exact = mysql_query($sql_exact);
           $num_rows_result_exact = db_numrows($result_exact);

             if ($num_rows_result_exact == 1)
                  {
                  $title_arr = array();
                  $title_arr[] = _("Project");
                  $title_arr[] = _("Description");
                  $title_arr[] = _("Type");                        
        
                  print "<h3>Exact project search result for $keywords:</h3>";
                    
                  print html_build_list_table_top($title_arr);
                    
                  print "\n";
                    
                  $row_exact = mysql_fetch_array($result_exact);

                  $sql_exact_type = "SELECT name from group_type WHERE 
type_id=${row_exact['type']}";
                  $result_exact_type = db_query($sql_exact_type);
           
                  $row_exact_name = mysql_fetch_array($result_exact_type);

                  print "<tr><td><a 
href=\"../projects/${row_exact['unix_group_name']}\">${row_exact['group_name']}</a></td>
 \n
                  <td>${row_exact['short_description']}</td> \n
                  <td>${row_exact_name['name']}</td></tr> \n
                  
                  </table>";
                  }
           }
}


      
____________________________________________________________________________________
Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ




reply via email to

[Prev in Thread] Current Thread [Next in Thread]