"asc", "desc"=>"desc", ""=>"none"); ## HTML Widget dictionary var $dict = array( "de" => array( "searchfor" => "Suchen nach:", "and" => "und", "or" => "oder", "like" => "enth\344lt", "reset" => "Neu", "submit" => "Ausf\374hren", "less" => "Weniger", "more" => "Mehr" ), "en" => array( "searchfor" => "Search for:", "and" => "and", "and not" => "and not", "or" => "or", "or not" => "or not", "like" => "contains", "reset" => "Reset", "submit" => "Submit Query", "less" => "Fewer", "more" => "More", "sort" => "Sort Order:", "asc" => "Asc", "desc" => "Desc", "none" => "None" ), "rus" => array( "searchfor" => "Искать:", "and" => "и", "or" => "или", "like" => "содержит", "reset" => "Новый Поиск", "submit" => "Начать Поиск", "less" => "Меньше", "more" => "Больше", "sort" => "Порядок Сортировки:", "asc" => "Восходящий", "desc" => "Нисходящий", "none" => "Не сортировать" ) ); ## form: ## ## Draw SQL Query selection form. ## function form($base, $option, $class = "", $target = "") { if($this->debug) printf("form()
\n"); global $sess; ## ## load the HTML results of this function into $res. ## $res = ""; ## Scale the HTML table according to the number of active options $colnum = 4; // at least 4 columns if ($this->sort) $colnum += 1; ## A hack. We cannot do language dependent initialisation of ## static values. if (isset($this->compare["like"])) { $this->compare["like"] = $this->dict[$this->lang]["like"]; } if ($this->sort) { $this->sort["asc"] = $this->dict[$this->lang]["asc"]; $this->sort["desc"] = $this->dict[$this->lang]["desc"]; $this->sort[""] = $this->dict[$this->lang]["none"]; } ## Prepare a self-directed container form if ($this->container) { $res .= sprintf("

", ($class)?" class=$class":"", $colnum-1); $res .= sprintf("Sort Order", ($class)?" class=$class":""); } ## Build $this->conditions many selection elements for ($i=1; $i<= $this->conditions; $i++) { $res .= sprintf(" \n", ($class)?" class=$class":""); ## Build conjunction (first row does not have a conjunction) if ($i == 1) { $res .= sprintf(" %s\n", ($class)?" class=$class":"", $this->dict[$this->lang]["searchfor"]); } else { $res .= sprintf(" %s\n", ($class)?" class=$class":"", $this->selection($this->makename($base, "conj", $i), array( "and" => $this->dict[$this->lang]["and"], "or" => $this->dict[$this->lang]["or"], "and not" => $this->dict[$this->lang]["and not"], "or not" => $this->dict[$this->lang]["or not"], ), $GLOBALS[$base]["conj_".$i], "on", $class)); } ## Build field selection $res .= sprintf(" %s\n", ($class)?" class=$class":"", $this->selection( $this->makename($base, "sel", $i), $option, $GLOBALS[$base]["sel_".$i], $this->translate, $class)); ## Build comparison selection $res .= sprintf(" %s\n", ($class)?" class=$class":"", $this->selection( $this->makename($base, "comp", $i), $this->compare, $GLOBALS[$base]["comp_".$i], "on", $class)); ## Create text input field. $res .= sprintf("\n", ($class)?" class=$class":"", $this->makename($base, "input", $i), $GLOBALS[$base]["input_".$i], $this->input_size, $this->input_max, ($class)?" class=$class":""); ## Selector for "sort order" if ($this->sort) { $res .= sprintf(" %s\n", ($class)?" class=$class":"", $this->selection( $this->makename($base, "order", $i), $this->sort, $GLOBALS[$base]["order_".$i], "on", $class)); } } ## Create variable size buttons $res .= sprintf(" \n", ($class)?" class=$class":""); $res .= sprintf("  \n", ($class)?" class=$class":""); if ($this->variable) { $res .= sprintf("\n", ($class)?" class=$class":"", $this->makename($base, "more", 0), $this->dict[$this->lang]["more"]); $res .= sprintf("\n", $this->makename($base, "less", 0), $this->dict[$this->lang]["less"]); } else { $res .= sprintf("  \n", ($class)?" class=$class":""); } ## Create submit/reset buttons $res .= sprintf("  ", ($class)?" class=$class":"", $colnum-2, $this->dict[$this->lang]["reset"]); $res .= sprintf("\n", $this->makename($base, "submit", 0), $this->dict[$this->lang]["submit"]); $res .= sprintf(" \n"); $res .= sprintf("\n"); $res .= sprintf("
\n", ($class)?" class=$class":"", ($class)?" class=$class":"", ($class)?" class=$class":""); } $res .= sprintf("
\n", $this->method, ($target)?$target:$sess->self_url()); ## Prepare the inner table, laying out the selection elements $res .= sprintf("\n", ($class)?" class=$class":""); ## Lay out the header for the sort conditions if ($this->sort) { $res .= sprintf(" \n", ($class)?" class=$class":""); $res .= sprintf("
\n"); $res .= sprintf("\n"); if ($this->container) { $res .= sprintf("\n"); } $res .= sprintf("\n", $this->classname); return $res; } function plain_where($base) { if($this->debug) printf("plain_where()
\n"); ## get dictionary data for the queried tables if (!$this->ddata) $this->ddata= get_table_ddata(trim($GLOBALS[docprops][dtable])); for($i=1; $i<=$this->conditions; $i++) { ## Only create conditions for used input fields if ($GLOBALS[$base]["input_".$i] == "") continue; ## If necessary, add conjunction if ($q != "") $q .= sprintf(" %s ", $GLOBALS[$base]["conj_".$i]); ## Handle "like" if ($GLOBALS[$base]["comp_".$i] == "like") $v = "%".$GLOBALS[$base]["input_".$i]."%"; else $v = $GLOBALS[$base]["input_".$i]; ## Create subcondition, case-insensitive if $this->caseins is set and we are not searching on a date if ($this->caseins && ($this->ddata[$GLOBALS[$base]["sel_".$i]][datatype] != "DATE")) { $q .= sprintf("upper(%s) %s upper('%s')", $GLOBALS[$base]["sel_".$i], $GLOBALS[$base]["comp_".$i], addslashes($v)); } else { $q .= sprintf("%s %s '%s'", $GLOBALS[$base]["sel_".$i], $GLOBALS[$base]["comp_".$i], addslashes($v)); } } ## Create the "order by" string (MA, 8/18/2000) if ($this->sort) { for($i=1; $i<=$this->conditions; $i++) { if ($GLOBALS[$base]["order_".$i] == "") continue; if ($o != "") $o .= ", "; $o .= sprintf(" %s %s", $GLOBALS[$base]["sel_".$i], $GLOBALS[$base]["order_".$i]); } if (($q) && ($o)) $o = " order by " . $o; else $o = ""; // zero out the "order by" string if there is no query string } if (!$q) $q = "1=0"; return "( $q ) $o"; } } // end class ext_sql_query ?>