40 include_once (
'Class.QueryDb.php');
41 include_once (
'Class.TableLayout.php');
42 include_once (
'Class.SubForm.php');
63 <form name="fulltext" method="post"
64 action="javascript:set_form_par(\'query\',\'fulltext\',self.document.fulltext.text.value,0);set_form_par(\'query\',\'start\',0,0);set_form_par(\'query\',\'all\',\'\',1);"
65 onreset="javascript:set_form_par(\'query\',\'fulltext\',\'\',0);set_form_par(\'query\',\'start\',0,0);set_form_par(\'query\',\'all\',\'\',1);">
66 <input name="text" type="text" value="%s" size="10" placeholder="%s">
75 $this->log =
new Log(
"",
"QueryGen",
"$class");
82 $this->action_name = GetHttpVars(
"sact",
$action->name);
83 $this->app_name = GetHttpVars(
"sapp",
$action->parent->name);
85 if ($this->action_name !=
$action->name) {
89 $this->action->Set($this->action_name,
$app);
92 $this->
Init(
"order_by", $this->query->basic_elem->order_by);
93 $this->
Init(
"desc",
"down");
94 $this->
Init(
"start", 0);
95 $this->
Init(
"slice", 10);
96 $this->
Init(
"fulltext",
"");
97 $this->
Init(
"freedata",
"");
98 $this->fulltextfields = $this->query->basic_elem->fulltextfields;
101 while ($i < $this->
slice) {
102 $this->
Init(
"criteria",
"", $i);
103 if (($this->criteria ==
"") || ($this->criteria[$i] ==
""))
break;
106 $this->
Init(
"operator",
"", $i);
107 $this->
Init(
"value",
"", $i);
108 $this->
Init(
"connector",
"", $i);
109 $this->
Init(
"level",
"", $i);
113 $this->baseurl =
$action->GetParam(
"CORE_BASEURL");
114 $this->action->lay->set(
"QUERY_FORM", $this->
GenMainForm(
"query", 0, 0, $this->baseurl .
"app=CORE&action=SETACTPAR&sole=Y"));
116 $this->action->parent->AddJsRef(
$action->GetParam(
"CORE_JSURL") .
"/query_paging.js");
118 $this->table =
new TableLayout($this->action->lay);
125 $this->table->lay->set(
"FULLTEXTFORM", sprintf($this->fulltextform, $text, $this->placeHolder));
128 function GenMainForm($name, $height, $width, $mainurl, $suburl =
"")
130 $this->form =
new SubForm($name, $height, $width, $mainurl, $suburl);
132 $this->form->SetParam(
"key",
"");
133 $this->form->SetParam(
"start", $this->
start);
134 $this->form->SetParam(
"slice", $this->
slice);
135 $this->form->SetParam(
"order_by", $this->
order_by);
136 $this->form->SetParam(
"desc", $this->desc);
137 $this->form->SetParam(
"fulltext", $this->fulltext);
138 $this->form->SetParam(
"sapp", $this->action->parent->name);
139 $this->form->SetParam(
"sact", $this->action->name);
140 $this->form->SetParam(
"freedata", $this->freedata);
143 while ($i < $this->
slice) {
144 if (!isset($this->criteria[$i]) || $this->criteria[$i] ==
"")
break;
147 $this->form->SetParam(
"criteria_$i", $this->criteria[$i]);
148 $this->form->SetParam(
"operator_$i", $this->
operator[$i]);
149 $this->form->SetParam(
"value_$i", $this->value[$i]);
150 $this->form->SetParam(
"connector_$i", $this->connector[$i]);
151 $this->form->SetParam(
"level_$i", $this->level[$i]);
154 return ($this->form->GetMainForm());
163 $this->table->array = $this->query->Query($this->
start, $this->
slice,
$type);
164 $this->table->nb_tot = $this->query->count();
165 if ($this->table->nb_tot == 0) {
166 $this->table->array = array();
169 $this->table->page_link =
"javascript:set_form_par('query','start','%s',1);";
170 $this->table->sort_link =
"javascript:set_form_par('query','order_by','%s',0);set_form_par('query','desc','%s',0);set_form_par('query','start','%s',0);set_form_par('query','all','',1);";
174 $this->table->prev = $this->action->GetIcon(
"prev.png",
"prev", 16);
175 $this->table->next = $this->action->GetIcon(
"next.png",
"next", 16);
176 $this->table->first = $this->action->GetIcon(
"first.png",
"first", 16);
177 $this->table->last = $this->action->GetIcon(
"last.png",
"last", 16);
178 $this->up = $this->action->GetIcon(
"up.png",
"up");
179 $this->down = $this->action->GetIcon(
"down.png",
"down");
182 $this->table->fields[] =
"CLASS";
183 reset($this->table->array);
184 foreach ($this->table->array as $k => $v) {
185 $this->table->array[$k][
"CLASS"] = ($k % 2) ?
"TABOdd" :
"";
188 reset($this->table->array);
189 if (($this->
order_by !=
"") && ($this->desc !=
"")) {
191 if (is_array($this->table->headsortfields)) {
192 reset($this->table->headsortfields);
193 foreach ($this->table->headsortfields as $k => $v) {
195 $this->table->headcontent[$k].= $this->$desc;
204 if (($this->fulltext !=
"") && (
sizeof($this->fulltextfields) > 0)) {
205 reset($this->fulltextfields);
207 foreach ($this->fulltextfields as $k => $v) {
208 $sql.=
" upper($v) like '%" . strtoupper($this->fulltext) .
"%' OR";
215 function Init($key, $defval, $ind =
"")
219 $this->$key = GetHttpVars(
"$key", $this->action->ActRead($key, $defval));
220 $this->action->ActRegister(
"$key", $this->$key);
222 $this->$key[$ind] = GetHttpVars(
"$key_$ind", $this->action->ActRead(
"$key_$ind", $defval));
223 $this->action->ActRegister(
"$key_$ind", $this->$key[$ind]);
229 $this->query->AddQuery($contraint);
GenMainForm($name, $height, $width, $mainurl, $suburl="")
__construct($dbaccess, $class, &$action)
Init($key, $defval, $ind="")