4 |
## $Id$ |
## $Id$ |
5 |
## ----------------------------------------------------------------------------- |
## ----------------------------------------------------------------------------- |
6 |
## $Log$ |
## $Log$ |
7 |
|
## Revision 1.5 2003/04/08 17:33:22 jonen |
8 |
|
## + fixed problems with hidden form fields(current base URL) at the 'simple search form' |
9 |
|
## |
10 |
|
## Revision 1.4 2003/04/06 01:41:07 jonen |
11 |
|
## - removed duplicated decode functions |
12 |
|
## |
13 |
|
## Revision 1.3 2003/04/04 21:26:06 joko |
14 |
|
## added comments regarding possible (future) refactoring using the Data::Lift-infrastructure |
15 |
|
## |
16 |
## Revision 1.2 2003/04/04 00:45:40 jonen |
## Revision 1.2 2003/04/04 00:45:40 jonen |
17 |
## + reworked decode functions |
## + reworked decode functions |
18 |
## |
## |
188 |
|
|
189 |
//make sure its set to something. |
//make sure its set to something. |
190 |
if ($obj == '') { |
if ($obj == '') { |
191 |
$obj = " "; |
$obj = " "; |
192 |
} |
} |
193 |
// if item is match by expression we will replace it with an link object |
|
194 |
elseif($this->_options['decode']) { |
// decode item / mungle item data? |
195 |
if($this->decode_item_expr($obj)) { |
// TODO: use Data::Lift here!!! (like already done in YAA::JobList and YAA::JobDetails) |
196 |
$obj = $this->decode_item_expr($obj); |
elseif ($this->_options['decode']) { |
197 |
} |
|
198 |
// if item is an Array we will replace it with an selection form object |
// Proposal using Data::Lift: (see YAA::JobList and YAA::JobDetails) |
199 |
elseif($this->decode_item_array($obj) ) { |
// This class will get shorter and better to maintain! |
200 |
$obj = $this->decode_item_array($obj); |
|
201 |
|
// Picture Data::Lift as a container component handling |
202 |
|
// *specific* en-/decoding stuff for your very core components. |
203 |
|
// This way we will have almost all "specific mungling code" at one place. nice thing! |
204 |
|
|
205 |
|
/* |
206 |
|
|
207 |
|
// 1. expr: string -> object (phpHtmlLib-object: 'html_a'-tag) |
208 |
|
// returns a phpHtmlLib object of class 'Xyz' containing a http-/html-link |
209 |
|
// pointing to a View of a different - linked/referenced - object (reference-interpolation) |
210 |
|
$this->lift1 = php::mkComponent('Data::Lift', $obj, array( metatype => 'expression' ) ); |
211 |
|
$obj = $this->lift1->to('phpHtmlLib::html_a'); |
212 |
|
|
213 |
|
// 2. data: hash -> object (phpHtmlLib-object: 'container'-object containing form) |
214 |
|
// returns a phpHtmlLib object of class 'Container' containing a html-form made up of |
215 |
|
// phpHtmlLib form-tags wrapping all attribute-value pairs of the data hash (object-edit) |
216 |
|
$this->lift2 = php::mkComponent('Data::Lift', $obj, array( metatype => 'item' ) ); |
217 |
|
$obj = $this->lift2->to('phpHtmlLib::form'); |
218 |
|
|
219 |
|
*/ |
220 |
|
|
221 |
|
$utils = php::mkComponent('WebExplorer::utils'); |
222 |
|
$hidden = $this->_hidden_elements; |
223 |
|
$options = $this->_options['decode_args']; |
224 |
|
|
225 |
|
// 1. if item is match by expression we will replace it with an link object |
226 |
|
if ($utils->decode_item_expr($obj, $hidden, $options)) { |
227 |
|
$obj = $utils->decode_item_expr($obj, $hidden, $options); |
228 |
} |
} |
229 |
|
|
230 |
|
// 2. if item is an Array we will replace it with an selection form object |
231 |
|
elseif ( $utils->decode_item_array($obj, $hidden, $options) ) { |
232 |
|
$obj = $utils->decode_item_array($obj, $hidden, $options); |
233 |
|
} |
234 |
|
|
235 |
} |
} |
236 |
|
|
237 |
//make sure we don't put a right border on the last |
//make sure we don't put a right border on the last |
238 |
//column we are working on. |
//column we are working on. |
239 |
//$style = "padding-left: 3px;padding-right:3px;border-top: 1px solid #dddddd;"; |
//$style = "padding-left: 3px;padding-right:3px;border-top: 1px solid #dddddd;"; |
263 |
} |
} |
264 |
|
|
265 |
|
|
266 |
function decode_item_array($item) { |
/** |
267 |
$options = $this->_options['decode_args']; |
* This function builds the simple search TD |
268 |
if( is_array($item) ) { |
* |
269 |
//$cur_row_index = $this->_datasource->get_cur_data_index(); |
* @return ContainerWidget |
270 |
//$parent_guid = $this->_datasource->_data[$cur_row_index]['guid']; |
*/ |
271 |
// build list for selection form |
function _build_simple_search_form() { |
272 |
if($options['form']) { |
|
273 |
foreach($item as $key => $value) { |
//if there is only 1 item enabled for search |
274 |
$tmp = split($options['seperator'], $value); |
//then the search looks simple. |
275 |
$ident = $tmp['1']; |
$fields = $this->_get_searchable_fields(); |
276 |
$meta = $tmp['2']; |
$cnt = count($fields); |
277 |
$list[$key] = $ident; |
if ($cnt == 0) { |
278 |
} |
return NULL; |
279 |
if(is_array($list) ) { |
} |
280 |
$container = container( |
|
281 |
form_open( $item[0], $_SERVER["PHP_SELF"], "POST" ), |
$container = new ContainerWidget; |
282 |
form_hidden("ecdm", $meta), |
|
283 |
form_select("ecdid", $list), |
if ($cnt == 1) { |
284 |
form_submit("submit","view" ) |
//user only has 1 field to show. |
285 |
); |
list($name, $field) = each($fields); |
286 |
foreach($this->_hidden_elements as $label => $value) { |
$container->push("Find ".$name." "); |
|
$container->add(form_hidden($label, $value)); |
|
|
} |
|
|
$container->add(form_close() ); |
|
|
$item = $container; |
|
|
} |
|
287 |
} else { |
} else { |
288 |
$container = container(); |
//user has many fields to show. |
289 |
foreach($item as $key => $value) { |
$container->push("Find ", |
290 |
$tmp = split($options['seperator'], $value); |
form_select($this->_vars["search_fieldVar"], $fields, $this->search_field())); |
291 |
$ident = $tmp['1']; |
} |
292 |
$meta = $tmp['2']; |
|
293 |
foreach($this->_hidden_elements as $label => $value) { |
if ($this->get_simple_search_modifier()) { |
294 |
$tmp_array[] = $label . "=" . $value; |
//the user wants the search modifier turned on. |
295 |
} |
$container->push($this->_build_simple_search_modifier()); |
296 |
$str_hidden = join("&", $tmp_array); |
} |
297 |
$container->add("->", html_a($_SERVER["PHP_SELF"] . "?ecdid=" . $ident . "&ecdm=" . $meta . "&" . $str_hidden, $key . " view"), html_br()); |
|
298 |
} |
$container->push(form_text($this->_vars["search_valueVar"], $this->search_value_filter($this->search_value()), "20", "100", array("style"=>"vertical-align:middle;")), |
299 |
$item = $container; |
form_submit($this->get_form_name(), "Search", array("style"=>"vertical-align:middle;"))); |
300 |
|
|
301 |
|
if ($this->is_advanced_search_enabled()) { |
302 |
|
$span = html_span(html_a("ass","Advanced Search", "title")); |
303 |
|
$container->push(" ", $span); |
304 |
|
} |
305 |
|
|
306 |
|
if ($cnt == 1) { |
307 |
|
$container->push(form_hidden($this->_vars["search_fieldVar"], $field)); |
308 |
} |
} |
|
return $item; |
|
|
} |
|
|
} |
|
309 |
|
|
310 |
function decode_item_expr($item) { |
// find variables attached at base URL and add them as hidden fields, |
311 |
$options = $this->_options['decode_args']; |
// so the search method will reach its starting point at deep frameworks |
312 |
if(substr($item, 0, 2) == "o_") { |
$base_url = $this->build_base_url(); |
313 |
$tmp = split($options['seperator'], $item); |
$url_vars = split("&", $base_url); |
314 |
$ident = $tmp['1']; |
$tmp = split("\?", $url_vars[0]); |
315 |
$meta = $tmp['2']; |
$url_vars[0] = $tmp[1]; |
316 |
foreach($this->_hidden_elements as $label => $value) { |
if(is_array($url_vars)) { |
317 |
$tmp_array[] = $label . "=" . $value; |
foreach($url_vars as $value) { |
318 |
|
$var = split("=", $value); |
319 |
|
$container->push(form_hidden($var[0], $var[1])); |
320 |
} |
} |
321 |
$str_hidden = join("&", $tmp_array); |
} |
322 |
$item = html_a($_SERVER["PHP_SELF"] . "?ecdid=" . $ident . "&ecdm=" . $meta . "&" . $str_hidden, "view"); |
|
323 |
return $item; |
$container->push(form_close() ); |
324 |
|
return $container; |
325 |
} |
} |
326 |
} |
|
327 |
|
|
328 |
} |
} |
329 |
?> |
?> |