1 |
<? |
<? |
2 |
/* |
/* |
3 |
## ----------------------------------------------------------------------------- |
## ------------------------------------------------------------------------- |
4 |
## $Id$ |
## $Id$ |
5 |
## ----------------------------------------------------------------------------- |
## ------------------------------------------------------------------------- |
6 |
## $Log$ |
## $Log$ |
7 |
|
## Revision 1.9 2003/04/11 00:44:46 joko |
8 |
|
## minor update: shortened seperators |
9 |
|
## |
10 |
|
## Revision 1.8 2003/04/09 07:54:42 joko |
11 |
|
## cleaned up decoding part |
12 |
|
## |
13 |
|
## Revision 1.7 2003/04/09 00:37:53 jonen |
14 |
|
## + added actionbar |
15 |
|
## + some changes according to request vars |
16 |
|
## |
17 |
|
## Revision 1.6 2003/04/08 17:48:31 jonen |
18 |
|
## + bugfix again |
19 |
|
## |
20 |
|
## Revision 1.5 2003/04/08 17:33:22 jonen |
21 |
|
## + fixed problems with hidden form fields(current base URL) at the 'simple search form' |
22 |
|
## |
23 |
|
## Revision 1.4 2003/04/06 01:41:07 jonen |
24 |
|
## - removed duplicated decode functions |
25 |
|
## |
26 |
|
## Revision 1.3 2003/04/04 21:26:06 joko |
27 |
|
## added comments regarding possible (future) refactoring using the Data::Lift-infrastructure |
28 |
|
## |
29 |
|
## Revision 1.2 2003/04/04 00:45:40 jonen |
30 |
|
## + reworked decode functions |
31 |
|
## |
32 |
## Revision 1.1 2003/03/27 01:17:31 jonen |
## Revision 1.1 2003/03/27 01:17:31 jonen |
33 |
## + inital commit (was orginal 'ObjectList.inc) |
## + inital commit (was orginal 'ObjectList.inc) |
34 |
## |
## |
41 |
## Revision 1.1 2003/03/01 22:57:40 cvsmax |
## Revision 1.1 2003/03/01 22:57:40 cvsmax |
42 |
## + inital commit |
## + inital commit |
43 |
## |
## |
44 |
## |
## ------------------------------------------------------------------------- |
|
## ----------------------------------------------------------------------------- |
|
45 |
*/ |
*/ |
46 |
|
|
47 |
|
|
48 |
/** |
/** |
49 |
* Need to make sure we have the DefaultGUIDataList object |
* Need to make sure we have the DefaultGUIDataList object |
50 |
*/ |
*/ |
64 |
*/ |
*/ |
65 |
var $_options = NULL; |
var $_options = NULL; |
66 |
|
|
67 |
|
/** |
68 |
|
* Holds a list of hidden elements |
69 |
|
* |
70 |
|
*/ |
71 |
|
var $_hidden_elements = array(); |
72 |
|
|
73 |
|
|
74 |
/** |
/** |
75 |
* The constructor is used to pass in some additional |
* The constructor is used to pass in some additional |
76 |
* metadata informations as "options". |
* metadata informations as "options". |
93 |
*/ |
*/ |
94 |
function GenericGUIDataList($title, $width = "100%", $default_orderby='', $default_reverseorder=FALSE, $options = array()) { |
function GenericGUIDataList($title, $width = "100%", $default_orderby='', $default_reverseorder=FALSE, $options = array()) { |
95 |
if ($options) { $this->_options = $options; } |
if ($options) { $this->_options = $options; } |
96 |
|
|
97 |
|
// call parent constructor |
98 |
$parent = get_parent_class($this); |
$parent = get_parent_class($this); |
99 |
$this->$parent($title, $width = "100%", $default_orderby='', $default_reverseorder=FALSE); |
$this->$parent($title, $width = "100%", $default_orderby='', $default_reverseorder=FALSE); |
100 |
} |
} |
101 |
|
|
102 |
|
|
103 |
function get_data_source( ) { |
function get_data_source( ) { |
104 |
|
|
105 |
// finally: create phpHtmlLib source handle (XyzDataListSource) |
// finally: create phpHtmlLib source handle (XyzDataListSource) |
205 |
|
|
206 |
//make sure its set to something. |
//make sure its set to something. |
207 |
if ($obj == '') { |
if ($obj == '') { |
208 |
$obj = " "; |
$obj = " "; |
209 |
} |
} |
210 |
// if item is match by expression we will replace it with an link object |
|
211 |
elseif($this->_options['decode']) { |
// decode item / mungle item data? |
212 |
if($this->decode_item_expr($obj)) { |
// TODO: use Data::Lift here!!! (like already done in YAA::JobList and YAA::JobDetails) |
213 |
$obj = $this->decode_item_expr($obj); |
elseif ($this->_options['decode']) { |
214 |
} |
|
215 |
// if item is an Array we will replace it with an selection form object |
// Proposal using Data::Lift: (see YAA::JobList and YAA::JobDetails) |
216 |
elseif($this->decode_item_array($obj) ) { |
// This class will get shorter and better to maintain! |
217 |
$obj = $this->decode_item_array($obj); |
|
218 |
|
// Picture Data::Lift as a container component handling |
219 |
|
// *specific* en-/decoding stuff for your very core components. |
220 |
|
// This way we will have almost all "specific mungling code" at one place. nice thing! |
221 |
|
|
222 |
|
/* |
223 |
|
|
224 |
|
// 1. expr: string -> object (phpHtmlLib-object: 'html_a'-tag) |
225 |
|
// returns a phpHtmlLib object of class 'Xyz' containing a http-/html-link |
226 |
|
// pointing to a View of a different - linked/referenced - object (reference-interpolation) |
227 |
|
$this->lift1 = php::mkComponent('Data::Lift', $obj, array( metatype => 'expression' ) ); |
228 |
|
$obj = $this->lift1->to('phpHtmlLib::html_a'); |
229 |
|
|
230 |
|
// 2. data: hash -> object (phpHtmlLib-object: 'container'-object containing form) |
231 |
|
// returns a phpHtmlLib object of class 'Container' containing a html-form made up of |
232 |
|
// phpHtmlLib form-tags wrapping all attribute-value pairs of the data hash (object-edit) |
233 |
|
$this->lift2 = php::mkComponent('Data::Lift', $obj, array( metatype => 'item' ) ); |
234 |
|
$obj = $this->lift2->to('phpHtmlLib::form'); |
235 |
|
|
236 |
|
*/ |
237 |
|
|
238 |
|
$utils = php::mkComponent('WebExplorer::utils'); |
239 |
|
$hidden = $this->_hidden_elements; |
240 |
|
$options = $this->_options['decode_args']; |
241 |
|
|
242 |
|
// a) Iterate through the attributes of the item and replace each |
243 |
|
// value with an appropriate link object if it has a certain format. |
244 |
|
if ($utils->decode_item_expr($obj, $hidden, $options)) { |
245 |
|
|
246 |
|
// b) Otherwise: If item is an Array we will replace it with a selection form object. |
247 |
|
} else { |
248 |
|
$utils->decode_item_array($obj, $hidden, $options); |
249 |
} |
} |
250 |
|
|
251 |
} |
} |
252 |
|
|
253 |
//make sure we don't put a right border on the last |
//make sure we don't put a right border on the last |
254 |
//column we are working on. |
//column we are working on. |
255 |
//$style = "padding-left: 3px;padding-right:3px;border-top: 1px solid #dddddd;"; |
//$style = "padding-left: 3px;padding-right:3px;border-top: 1px solid #dddddd;"; |
274 |
return $td; |
return $td; |
275 |
} |
} |
276 |
|
|
277 |
function decode_item_array($item) { |
function add_hidden_element($label, $value) { |
278 |
$options = $this->_options['decode_args']; |
$this->_hidden_elements[$label] = $value; |
279 |
if( is_array($item) ) { |
} |
280 |
//$cur_row_index = $this->_datasource->get_cur_data_index(); |
|
281 |
//$parent_guid = $this->_datasource->_data[$cur_row_index]['guid']; |
|
282 |
// build list for selection form |
/** |
283 |
if($options['form']) { |
* This function builds the simple search TD |
284 |
foreach($item as $key => $value) { |
* |
285 |
$tmp = split($options['seperator'], $value); |
* @return ContainerWidget |
286 |
$ident = $tmp['1']; |
*/ |
287 |
$meta = $tmp['2']; |
function _build_simple_search_form() { |
288 |
$list[$key] = $ident; |
|
289 |
} |
//if there is only 1 item enabled for search |
290 |
if(is_array($list) ) { |
//then the search looks simple. |
291 |
$container = container( |
$fields = $this->_get_searchable_fields(); |
292 |
form_open( $item[0], $_SERVER["PHP_SELF"], "POST" ), |
$cnt = count($fields); |
293 |
form_open("ecdm", $meta), |
if ($cnt == 0) { |
294 |
form_select("ecdid", $list), |
return NULL; |
295 |
form_submit("submit","view" ) |
} |
296 |
); |
|
297 |
foreach($this->_hidden_items as $label => $value) { |
$container = new ContainerWidget; |
298 |
$container->add(form_hidden($label, $value)); |
|
299 |
} |
// get current request vars and add them ad hidden items |
300 |
$container->add(form_close() ); |
$url_vars = $this->_get_current_url_vars(); |
301 |
$item = $container; |
foreach($url_vars as $label => $value) { |
302 |
} |
$container->push(form_hidden($label, $value)); |
303 |
|
} |
304 |
|
|
305 |
|
if ($cnt == 1) { |
306 |
|
//user only has 1 field to show. |
307 |
|
list($name, $field) = each($fields); |
308 |
|
$container->push("Find ".$name." "); |
309 |
} else { |
} else { |
310 |
$container = container(); |
//user has many fields to show. |
311 |
foreach($item as $key => $value) { |
$container->push("Find ", |
312 |
$tmp = split($options['seperator'], $value); |
form_select($this->_vars["search_fieldVar"], $fields, $this->search_field())); |
313 |
$ident = $tmp['1']; |
} |
314 |
$meta = $tmp['2']; |
|
315 |
foreach($this->_hidden_items as $label => $value) { |
if ($this->get_simple_search_modifier()) { |
316 |
$tmp_array[] = $label . "=" . $value; |
//the user wants the search modifier turned on. |
317 |
} |
$container->push($this->_build_simple_search_modifier()); |
318 |
$str_hidden = join("&", $tmp_array); |
} |
319 |
$container->add("->", html_a($_SERVER["PHP_SELF"] . "?ecdid=" . $ident . "&ecdm=" . $meta . $str_hidden, $key . " view"), html_br()); |
|
320 |
|
$container->push(form_text($this->_vars["search_valueVar"], $this->search_value_filter($this->search_value()), "20", "100", array("style"=>"vertical-align:middle;")), |
321 |
|
form_submit($this->get_form_name(), "Search", array("style"=>"vertical-align:middle;"))); |
322 |
|
|
323 |
|
if ($this->is_advanced_search_enabled()) { |
324 |
|
$span = html_span(html_a("ass","Advanced Search", "title")); |
325 |
|
$container->push(" ", $span); |
326 |
|
} |
327 |
|
|
328 |
|
if ($cnt == 1) { |
329 |
|
$container->push(form_hidden($this->_vars["search_fieldVar"], $field)); |
330 |
|
} |
331 |
|
|
332 |
|
|
333 |
|
//$container->push(form_close() ); |
334 |
|
return $container; |
335 |
|
} |
336 |
|
|
337 |
|
|
338 |
|
/** |
339 |
|
* this is the method that builds |
340 |
|
* the contents for the middle actionbar |
341 |
|
* td cell. |
342 |
|
* |
343 |
|
* @return ContainerWidget object |
344 |
|
*/ |
345 |
|
function actionbar_cell() { |
346 |
|
$action_list = $this->_options['actionbar']['list']; |
347 |
|
$action_name = $this->_options['actionbar']['name']; |
348 |
|
|
349 |
|
if($action_name && is_array($action_list)) { |
350 |
|
$action_form = container("Select action", _HTML_SPACE, |
351 |
|
form_open("data_list_action", $_SERVER['PHP_SELF'], 'POST'), |
352 |
|
form_select($action_name, $action_list), |
353 |
|
form_submit("submit","OK" ) |
354 |
|
); |
355 |
|
$url_vars = $this->_get_current_url_vars(); |
356 |
|
foreach($url_vars as $label => $value) { |
357 |
|
$action_form->add(form_hidden($label, $value)); |
358 |
} |
} |
359 |
$item = $container; |
$action_form->add(form_close()); |
360 |
|
return $action_form; |
361 |
|
} else { |
362 |
|
return _HTML_SPACE; |
363 |
} |
} |
|
return $item; |
|
364 |
} |
} |
|
} |
|
365 |
|
|
366 |
function decode_item_expr($item) { |
|
367 |
$options = $this->_options['decode_args']; |
/* |
368 |
if(substr($item, 0, 2) == "o_") { |
* this method returns the current requested variables |
369 |
$tmp = split($options['seperator'], $item); |
* |
370 |
$ident = $tmp['1']; |
* @return array |
371 |
$meta = $tmp['2']; |
*/ |
372 |
foreach($this->_hidden_items as $label => $value) { |
function _get_current_url_vars() { |
373 |
$tmp_array[] = $label . "=" . $value; |
$cur_url_vars = array(); |
374 |
|
|
375 |
|
// get new LinkBuilder instance |
376 |
|
$linkbuilder = new LinkBuilder(); |
377 |
|
|
378 |
|
$url_vars = php::array_join_merge($_GET, $_POST); |
379 |
|
if(is_array($url_vars)) { |
380 |
|
foreach($url_vars as $key => $value) { |
381 |
|
// if there is an LinkBuilder guid instead of variables, encode it |
382 |
|
if($key == 'lbid') { |
383 |
|
$lb_vars = $linkbuilder->load($value); |
384 |
|
foreach($lb_vars as $lbkey => $lbval) { |
385 |
|
$cur_url_vars[$lbkey] = $lbval; |
386 |
|
} |
387 |
|
} else { |
388 |
|
$cur_url_vars[$key] = $value; |
389 |
|
} |
390 |
} |
} |
391 |
$str_hidden = join("&", $tmp_array); |
} |
392 |
$item = html_a($_SERVER["PHP_SELF"] . "?ecdid=" . $guid . "&ecdm=" . $meta . $str_hidden, "view"); |
return $cur_url_vars; |
|
return $item; |
|
393 |
} |
} |
|
} |
|
394 |
|
|
395 |
} |
} |
396 |
?> |
?> |