File:  [mozdev] / chameleon / www / test.html
Revision 1.2: download - view: text, annotated - select for diffs - revision graph
Sun Feb 18 16:49:26 2001 UTC (16 years, 10 months ago) by petejc
Branches: MAIN
CVS tags: HEAD, CHAMELEON_0_02B_BRANCH
adding path to include

--pete

<?php

  require(PHP_INC.CONNECT);

  if (!isset($action)||$action=="form") {
    
    include SITE_TEM."form_template.php";
  
    $query="SELECT * FROM country ORDER BY name";
    $countries=mysql_query($query);
    
    $query="SELECT * FROM language ORDER BY name";
    $languages=mysql_query($query);
    
    $query="SELECT * FROM category ORDER BY name";
    $categories=mysql_query($query);
  
    $country_option_list="";
    while ($country=mysql_fetch_array($countries)) {
       $country_option_list.="<option value=\"$country[code]\">$country[name]</option>\n";
    }
    $language_option_list="";
    while ($language=mysql_fetch_array($languages)) {
       $language_option_list.="<option value=\"$language[code]\">$language[name]</option>\n";
    }
    $category_option_list="";
    while ($category=mysql_fetch_array($categories)) {
       $category_option_list.="<option value=\"$category[id]\">$category[name]</option>\n";
    }
    
    $html=str_replace("%countries%",$country_option_list,$html);
    $html=str_replace("%languages%",$language_option_list,$html);
    $html=str_replace("%categories%",$category_option_list,$html);
    
    echo($html);
  
  } else if ($action=="dosearch") {
    
    if ($country && $country!="all") {
      $andcountry=" AND country='$country'";
    }
    if ($language && $language!="all") {
      $andlanguage=" AND language='$language'"; 
    }
    if ($category && $category!="all") {
      $andcategory=" AND category='$category'"; 
    }
    //$query="SELECT * FROM sherlock WHERE name LIKE '%$name%'".$andcountry.$andlanguage.$andcategory." ORDER BY name";
                $query="SELECT *
                        FROM sherlock,category
                        WHERE sherlock.category=category.id AND sherlock.name
                          LIKE '%$name%'".$andcountry.$andlanguage .$andcategory."
                        ORDER BY category.name,sherlock.name";
    $res=mysql_query($query);
    $numrows=mysql_num_rows($res);
    if ($numrows>0) {
      while ($item=mysql_fetch_array($res)) {
                                if ($item[13] != $prevcat) {
                            if ($catfirsttime == "no") {
                                    echo("    </ul>\n  </li>\n");
                                  }
                                  else {
                                          $thelist = "<ol id=\"plugins\">\n";
                                    echo($thelist);
                                        $catfirsttime = "no";
                                  }
                                        $thiscat = "  <li class=\"category\">\n    $item[14]\n    <ul>\n";
                                  echo($thiscat);
                                  $prevcat = $item[13];
                                }
        displayitem($item);
      }
                        echo("    </ul>\n  </li>\n</ol>\n");
      echo("<p>$numrows plugins found.\n</p>");
      
    } else {
      $nothingfound="<p><b>Nothing found.</b></p>\n";
      echo($nothingfound); 
    }
    
  }
  function displayitem($item) {
        /*0 = id
          1 = plugin name
                2 = icon type
                3 = long url
                4 = short url
    5 = author
                6 = date
                7 = category number
                8 = country code
                9 = language code
                10 = beta
    11 = public
                12 = comment
                13 = category number
                14 = category name*/

          $startlist = "      <li style=\"list-style-image: url(http://sherlock.mozdev.org/$item[0].$item[2])\">\n";
                $address = "        (<a href=\"http://$item[3]\">$item[4]</a>)\n";
                if ($item[5]) {
                  $author = "        by $item[5]\n";
                }
                else {
                  $author = "";
                }
                $install = "        <a href=\"javascript:addEngine('$item[0]','$item[2]')\">$item[1]</a> [$item[9]-$item[8]]\n";
                $endlist = "      </li>\n";
                echo($startlist);
    echo($install);
    echo($address . $author);
    echo($endlist); 
  }

?>

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>