/[health_html]/inc/search.php
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /inc/search.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by ravilov, Thu Aug 30 16:35:36 2001 UTC revision 1.5 by ravilov, Mon Sep 3 15:52:16 2001 UTC
# Line 1  Line 1 
1  <?php  <?php
2          $basic_logic = "AND";          $basic_logic = "AND";
3            function MySort($a, $b) {
4                    return MyCompare($a["caption"], $b["caption"]);
5            }
6          function Search($fields, $q1_fields, $q2_fields, $def_field = "") {          function Search($fields, $q1_fields, $q2_fields, $def_field = "") {
7                  global $go;                  global $go;
8                  $tp = new Smarty();                  $tp = new Smarty();
# Line 62  Line 65 
65                                  $i = 1;                                  $i = 1;
66                                  while (${"search_".$i}) {                                  while (${"search_".$i}) {
67                                          $field = ${"field_".$i};                                          $field = ${"field_".$i};
68                                          $not = ${"not_".$i} ? "NOT" : "";                                          $not = ${"not_".$i} ? " NOT" : "";
69                                          $qry1 = preg_split('/\s+/', ${"query_".$i});                                          $qry1 = preg_split('/\s+/', ${"query_".$i});
70                                          $qry2 = array();                                          $qry2 = array();
71                                          $qry3 = array();                                          $qry3 = array();
72                                          while (list($k, $v) = each($qry1)) {                                          while (list($k, $v) = each($qry1)) {
73                                                  if (!$qry1[$k]) continue;                                                  if (!$qry1[$k]) continue;
74                                                  if (${"case_".$i}) $qq = "(".$fields[$field]["dbname"]." $not LIKE '%".$qry1[$k]."%')";                                                  if (${"case_".$i}) $qq = "(".$fields[$field]["dbname"]."$not LIKE '%".$qry1[$k]."%')";
75                                                          else $qq = "(UPPER(".$fields[$field]["dbname"].") $not LIKE UPPER('%".$qry1[$k]."%'))";                                                          else $qq = "(UPPER(".$fields[$field]["dbname"].")$not LIKE '%".MyUpper($qry1[$k])."%')";
76                                                  $is_q1 = false;                                                  $is_q1 = false;
77                                                  for ($j = 0; $j < count($q1_fields); $j++)                                                  for ($j = 0; $j < count($q1_fields); $j++)
78                                                          if ($q1_fields[$j] == $field) $is_q1 = true;                                                          if ($q1_fields[$j] == $field) $is_q1 = true;
# Line 99  Line 102 
102                                  $q3 = array();                                  $q3 = array();
103                                  while (list($k, $v) = each($q)) {                                  while (list($k, $v) = each($q)) {
104                                          if (!$q[$k]) continue;                                          if (!$q[$k]) continue;
105                                          $qq = "(UPPER(".$fields[$field]["dbname"].") LIKE UPPER('%".$q[$k]."%'))";                                          $qq = "(UPPER(".$fields[$field]["dbname"].") LIKE '%".MyUpper($q[$k])."%')";
106                                          $is_q1 = false;                                          $is_q1 = false;
107                                          for ($i = 0; $i < count($q1_fields); $i++)                                          for ($i = 0; $i < count($q1_fields); $i++)
108                                                  if ($q1_fields[$i] == $field) $is_q1 = true;                                                  if ($q1_fields[$i] == $field) $is_q1 = true;
# Line 121  Line 124 
124                                  "caption" => MyEscape($v["caption"])                                  "caption" => MyEscape($v["caption"])
125                          ));                          ));
126                  }                  }
127                    usort($flds, "MySort");
128                  $tp->assign("fields", $flds);                  $tp->assign("fields", $flds);
129                  global $PHP_SELF, $section, $section_menu;                  global $PHP_SELF, $section, $section_menu;
130                  $tp->assign("section", $section);                  $tp->assign("section", $section);
131                  $tp->assign("section_menu", $section_menu);                  $tp->assign("section_menu", $section_menu);
132                  $tp->assign("FORM_ACTION", $PHP_SELF.HTMLSpecialChars("?section=$section&section_menu={$section_menu}&stype=$stype"));                  $tp->assign("FORM_ACTION", $PHP_SELF.HTMLSpecialChars("?section=$section&section_menu={$section_menu}&stype=$stype"));
133                  $form = $tp->fetch("search.tpl");                  $form = $tp->fetch("search.tpl");
134                    global $onload;
135                    $onload .= "document.forms[0].elements[".($stype?2:1)."].focus();";
136                  return array($form, $qry_1, $qry_2);                  return array($form, $qry_1, $qry_2);
137          }          }
138  ?>  ?>

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

  ViewVC Help
Powered by ViewVC 1.1.26