1 |
<? |
<? |
2 |
/* |
/* |
3 |
## ----------------------------------------------------------------------------- |
## ------------------------------------------------------------------------- |
4 |
## $Id$ |
## $Id$ |
5 |
## ----------------------------------------------------------------------------- |
## ------------------------------------------------------------------------- |
6 |
## $Log$ |
## $Log$ |
7 |
|
## Revision 1.11 2003/05/10 17:58:45 jonen |
8 |
|
## + reworked to implement 'create/add new' item |
9 |
|
## |
10 |
|
## Revision 1.10 2003/04/18 18:40:02 jonen |
11 |
|
## + fixed bugs at 'actionbar_cell' relating to html-form and js |
12 |
|
## |
13 |
|
## Revision 1.9 2003/04/11 00:44:46 joko |
14 |
|
## minor update: shortened seperators |
15 |
|
## |
16 |
|
## Revision 1.8 2003/04/09 07:54:42 joko |
17 |
|
## cleaned up decoding part |
18 |
|
## |
19 |
|
## Revision 1.7 2003/04/09 00:37:53 jonen |
20 |
|
## + added actionbar |
21 |
|
## + some changes according to request vars |
22 |
|
## |
23 |
## Revision 1.6 2003/04/08 17:48:31 jonen |
## Revision 1.6 2003/04/08 17:48:31 jonen |
24 |
## + bugfix again |
## + bugfix again |
25 |
## |
## |
47 |
## Revision 1.1 2003/03/01 22:57:40 cvsmax |
## Revision 1.1 2003/03/01 22:57:40 cvsmax |
48 |
## + inital commit |
## + inital commit |
49 |
## |
## |
50 |
## |
## ------------------------------------------------------------------------- |
|
## ----------------------------------------------------------------------------- |
|
51 |
*/ |
*/ |
52 |
|
|
53 |
|
|
54 |
/** |
/** |
55 |
* Need to make sure we have the DefaultGUIDataList object |
* Need to make sure we have the DefaultGUIDataList object |
56 |
*/ |
*/ |
76 |
*/ |
*/ |
77 |
var $_hidden_elements = array(); |
var $_hidden_elements = array(); |
78 |
|
|
79 |
|
|
80 |
/** |
/** |
81 |
* The constructor is used to pass in some additional |
* The constructor is used to pass in some additional |
82 |
* metadata informations as "options". |
* metadata informations as "options". |
99 |
*/ |
*/ |
100 |
function GenericGUIDataList($title, $width = "100%", $default_orderby='', $default_reverseorder=FALSE, $options = array()) { |
function GenericGUIDataList($title, $width = "100%", $default_orderby='', $default_reverseorder=FALSE, $options = array()) { |
101 |
if ($options) { $this->_options = $options; } |
if ($options) { $this->_options = $options; } |
102 |
|
|
103 |
|
// call parent constructor |
104 |
$parent = get_parent_class($this); |
$parent = get_parent_class($this); |
105 |
$this->$parent($title, $width = "100%", $default_orderby='', $default_reverseorder=FALSE); |
$this->$parent($title, $width = "100%", $default_orderby='', $default_reverseorder=FALSE); |
106 |
} |
} |
107 |
|
|
108 |
|
|
109 |
function get_data_source( ) { |
function get_data_source( ) { |
110 |
|
|
111 |
// finally: create phpHtmlLib source handle (XyzDataListSource) |
// finally: create phpHtmlLib source handle (XyzDataListSource) |
191 |
$this->add_header_item("Uid", "200", "uid", SORTABLE, SEARCHABLE); |
$this->add_header_item("Uid", "200", "uid", SORTABLE, SEARCHABLE); |
192 |
$this->add_header_item("Name", "200", "lastName", SORTABLE, SEARCHABLE, "center"); |
$this->add_header_item("Name", "200", "lastName", SORTABLE, SEARCHABLE, "center"); |
193 |
*/ |
*/ |
194 |
|
|
195 |
} |
} |
196 |
|
|
197 |
|
|
208 |
* @param int - the column # we are working on. |
* @param int - the column # we are working on. |
209 |
* @return TDtag object |
* @return TDtag object |
210 |
*/ |
*/ |
211 |
function wrap_column_item($obj, $col_name) { |
function wrap_column_item($obj, $col_name, $row_data) { |
212 |
|
|
213 |
//make sure its set to something. |
//make sure its set to something. |
214 |
if ($obj == '') { |
if ($obj == '') { |
245 |
$utils = php::mkComponent('WebExplorer::utils'); |
$utils = php::mkComponent('WebExplorer::utils'); |
246 |
$hidden = $this->_hidden_elements; |
$hidden = $this->_hidden_elements; |
247 |
$options = $this->_options['decode_args']; |
$options = $this->_options['decode_args']; |
248 |
|
$options[label] = $col_name; |
249 |
|
$options[parent_guid] = $row_data[guid]; |
250 |
|
$options[parent_class] = $this->_options['parent']['class']; |
251 |
|
|
252 |
// 1. if item is match by expression we will replace it with an link object |
// a) Iterate through the attributes of the item and replace each |
253 |
if ($utils->decode_item_expr($obj, $hidden, $options)) { |
// value with an appropriate link object if it has a certain format. |
254 |
$obj = $utils->decode_item_expr($obj, $hidden, $options); |
if ($utils->decode_item_expr($obj, $hidden, $options)) { |
255 |
} |
|
256 |
|
// b) Otherwise: If item is an Array we will replace it with a selection form object. |
257 |
// 2. if item is an Array we will replace it with an selection form object |
} else { |
258 |
elseif ( $utils->decode_item_array($obj, $hidden, $options) ) { |
$utils->decode_item_array($obj, $hidden, $options); |
|
$obj = $utils->decode_item_array($obj, $hidden, $options); |
|
259 |
} |
} |
260 |
|
|
261 |
} |
} |
289 |
} |
} |
290 |
|
|
291 |
|
|
292 |
|
|
293 |
/** |
/** |
294 |
* This function builds the simple search TD |
* This function builds the simple search TD |
295 |
* |
* |
306 |
} |
} |
307 |
|
|
308 |
$container = new ContainerWidget; |
$container = new ContainerWidget; |
309 |
|
|
310 |
|
// OLD - needed hidden elements are now recognized at 'render()' |
311 |
|
/* |
312 |
|
// get current request vars and add them ad hidden items |
313 |
|
$url_vars = $this->_get_current_url_vars(); |
314 |
|
foreach($url_vars as $label => $value) { |
315 |
|
$container->push(form_hidden($label, $value)); |
316 |
|
} |
317 |
|
*/ |
318 |
|
|
319 |
if ($cnt == 1) { |
if ($cnt == 1) { |
320 |
//user only has 1 field to show. |
//user only has 1 field to show. |
343 |
$container->push(form_hidden($this->_vars["search_fieldVar"], $field)); |
$container->push(form_hidden($this->_vars["search_fieldVar"], $field)); |
344 |
} |
} |
345 |
|
|
346 |
// find variables attached at base URL and add them as hidden fields, |
return $container; |
347 |
// so the search method will reach its starting point at deep frameworks |
} |
348 |
$base_url = $this->build_base_url(); |
|
349 |
$url_vars = split("&", $base_url); |
|
350 |
$tmp = split("\?", $url_vars[0]); |
/** |
351 |
$url_vars[0] = $tmp[1]; |
* This function builds the data cell action buttons or main actionbar |
352 |
|
* |
353 |
|
* @return TDtag; |
354 |
|
*/ |
355 |
|
function _build_actionbar_data_cell() { |
356 |
|
$td = new TDtag(array("class" => "datalist_title", |
357 |
|
"style" => "padding-left:5px;padding-right:5px;". |
358 |
|
"padding-top:5px;padding-bottom:5px") |
359 |
|
); |
360 |
|
|
361 |
|
$flag = FALSE; |
362 |
|
if ($this->_has_action_column("FIRST")) { |
363 |
|
$flag = TRUE; |
364 |
|
$td->set_tag_attribute("align", "left"); |
365 |
|
} |
366 |
|
elseif ($this->_has_action_column("LAST")) { |
367 |
|
$flag = TRUE; |
368 |
|
$td->set_tag_attribute("align", "right"); |
369 |
|
} |
370 |
|
|
371 |
|
if ($flag && $this->_datasource->get_total_rows()) { |
372 |
|
$td->push($this->actionbar_cell()); |
373 |
|
$td->push($this->actionbar_cell_new()); |
374 |
|
} |
375 |
|
else { |
376 |
|
$td->push(" "); |
377 |
|
$td->push($this->actionbar_cell_new()); |
378 |
|
} |
379 |
|
|
380 |
|
return $td; |
381 |
|
} |
382 |
|
|
383 |
|
|
384 |
|
/** |
385 |
|
* this is the method that builds |
386 |
|
* the contents for the middle actionbar |
387 |
|
* td cell. |
388 |
|
* |
389 |
|
* @return ContainerWidget object |
390 |
|
*/ |
391 |
|
function actionbar_cell() { |
392 |
|
$action_list = $this->_options['actionbar']['list']; |
393 |
|
$action_name = $this->_options['actionbar']['name']; |
394 |
|
|
395 |
|
if($action_name && is_array($action_list)) { |
396 |
|
$action_form = container("Select action", _HTML_SPACE, |
397 |
|
form_select($action_name, $action_list, $this->_options['actionbar']['selected']), |
398 |
|
form_submit("ok","OK" ) |
399 |
|
); |
400 |
|
return $action_form; |
401 |
|
} else { |
402 |
|
return _HTML_SPACE; |
403 |
|
} |
404 |
|
} |
405 |
|
|
406 |
|
|
407 |
|
/** |
408 |
|
* this is the method that builds |
409 |
|
* the contents for the 'create new' actionbar |
410 |
|
* td cell. |
411 |
|
* |
412 |
|
* @return ContainerWidget object |
413 |
|
*/ |
414 |
|
function actionbar_cell_new() { |
415 |
|
$action_create = $this->_options['actionbar']['create']; |
416 |
|
|
417 |
|
if(is_array($action_create)) { |
418 |
|
$action_form = container( |
419 |
|
_HTML_SPACE, |
420 |
|
form_submit($action_create['name'], $action_create['value']) |
421 |
|
); |
422 |
|
return $action_form; |
423 |
|
} else { |
424 |
|
return _HTML_SPACE; |
425 |
|
} |
426 |
|
} |
427 |
|
|
428 |
|
|
429 |
|
/* |
430 |
|
* OLD (depreciated) - this method returns the current requested variables |
431 |
|
* |
432 |
|
* @return array |
433 |
|
*/ |
434 |
|
function _get_current_url_vars() { |
435 |
|
$cur_url_vars = array(); |
436 |
|
|
437 |
|
// get new LinkBuilder instance |
438 |
|
$linkbuilder = new LinkBuilder(); |
439 |
|
|
440 |
|
$url_vars = php::array_join_merge($_GET, $_POST); |
441 |
if(is_array($url_vars)) { |
if(is_array($url_vars)) { |
442 |
foreach($url_vars as $value) { |
foreach($url_vars as $key => $value) { |
443 |
$var = split("=", $value); |
// if there is an LinkBuilder guid instead of variables, encode it |
444 |
if($var[0] && $var[1]) { |
if($key == 'lbid') { |
445 |
$container->push(form_hidden($var[0], $var[1])); |
$lb_vars = $linkbuilder->load($value); |
446 |
} |
foreach($lb_vars as $lbkey => $lbval) { |
447 |
|
$cur_url_vars[$lbkey] = $lbval; |
448 |
|
} |
449 |
|
} else { |
450 |
|
$cur_url_vars[$key] = $value; |
451 |
|
} |
452 |
} |
} |
453 |
} |
} |
454 |
|
return $cur_url_vars; |
455 |
|
} |
456 |
|
|
457 |
|
|
458 |
|
/** |
459 |
|
* This function renders the final |
460 |
|
* widget |
461 |
|
* |
462 |
|
*/ |
463 |
|
function render($indent_level, $output_debug) { |
464 |
|
|
465 |
|
//setup the columns in their sorts |
466 |
|
$this->setup_columns(); |
467 |
|
|
468 |
|
//do any data prefetch work |
469 |
|
//which may be child specific |
470 |
|
if ( $this->_show_results() ) { |
471 |
|
$this->data_prefetch(); |
472 |
|
} |
473 |
|
|
474 |
$container->push(form_close() ); |
//This function gives the child class |
475 |
return $container; |
//a chance to build the tables/divs/containers |
476 |
|
//that will be responsible for the look/feel |
477 |
|
//of the DataList |
478 |
|
$this->gui_init(); |
479 |
|
|
480 |
|
//see if we need to build the search area. |
481 |
|
if ( $this->is_search_enabled() || $this->is_advanced_search_enabled() ) { |
482 |
|
$this->_search_table = $this->child_build_search_table(); |
483 |
|
if ( $this->_search_table ) { |
484 |
|
$this->set_form_render(TRUE); |
485 |
|
} |
486 |
|
} |
487 |
|
|
488 |
|
//see if form is needed by the actionbar |
489 |
|
if($this->_show_actionbar) { |
490 |
|
$this->set_form_render(TRUE); |
491 |
|
} |
492 |
|
|
493 |
|
if ( $this->get_form_render() ) { |
494 |
|
$form = new FORMtag( array("method" => $this->get_form_method(), |
495 |
|
"action" => $this->build_base_url(), |
496 |
|
"name" => $this->get_form_name(), |
497 |
|
"style" => "margin-top: 0px;margin-bottom:0px;") ); |
498 |
|
|
499 |
|
$target = $this->get_form_target(); |
500 |
|
if ( $target != NULL ) |
501 |
|
$form->set_tag_attribute("target",$target); |
502 |
|
|
503 |
|
$action = $this->get_form_action(); |
504 |
|
if ( $action != NULL ) |
505 |
|
$form->set_tag_attribute("action",$action); |
506 |
|
|
507 |
|
//now build the UI and return it |
508 |
|
$form->add( $this->build_gui() ); |
509 |
|
|
510 |
|
} else { |
511 |
|
$form = container(); |
512 |
|
|
513 |
|
//now build the UI and return it |
514 |
|
$form->add( $this->build_gui() ); |
515 |
|
} |
516 |
|
|
517 |
|
//add the hidden vars if we are a POST |
518 |
|
if ($this->get_form_method() == "POST") { |
519 |
|
$form->add( $this->_build_default_vars() ); |
520 |
|
|
521 |
|
//build hidden elements needed for data flow control |
522 |
|
$hidden = $this->_hidden_elements; |
523 |
|
//print "Hidden: " . Dumper($hidden); |
524 |
|
if($hidden) { |
525 |
|
foreach($hidden as $label => $value) { |
526 |
|
$form->add(form_hidden($label, $value)); |
527 |
|
} |
528 |
|
} |
529 |
|
|
530 |
|
} |
531 |
|
|
532 |
|
//add the save vars the user wants. |
533 |
|
$form->add( $this->_build_save_vars() ); |
534 |
|
|
535 |
|
//add any javascript required |
536 |
|
$container = container( $this->_javascript(), $form ); |
537 |
|
return $container->render( $indent_level, $output_debug ); |
538 |
} |
} |
539 |
|
|
540 |
|
|
541 |
|
|
542 |
|
function child_add_row_cell($obj, $col_name, $last_in_row_flag, $row_data) { |
543 |
|
if (!$this->_cur_col_cntr) { |
544 |
|
$this->_cur_col_cntr = 1; |
545 |
|
//lets see if we need to add an action column |
546 |
|
//as the first column. |
547 |
|
if ($this->_has_action_column("FIRST")) { |
548 |
|
//looks like we have a FIRST column actionbar |
549 |
|
//lets add it |
550 |
|
$this->_data_row->add($this->_build_action_column("FIRST", FALSE, $row_data)); |
551 |
|
} |
552 |
|
$td = $this->wrap_column_item($obj, $col_name, $row_data); |
553 |
|
$this->_data_row->add( $td ); |
554 |
|
} else { |
555 |
|
//show the normal data |
556 |
|
$td = $this->wrap_column_item($obj, $col_name, $row_data); |
557 |
|
$this->_data_row->add( $td ); |
558 |
|
} |
559 |
|
|
560 |
|
|
561 |
|
if ($last_in_row_flag) { |
562 |
|
//lets see if we need to add an action column |
563 |
|
//as the first column. |
564 |
|
if ($this->_has_action_column("LAST")) { |
565 |
|
//looks like we have a LAST column actionbar |
566 |
|
//lets add it |
567 |
|
$this->_data_row->add($this->_build_action_column("LAST", FALSE, $row_data)); |
568 |
|
} |
569 |
|
|
570 |
|
|
571 |
|
|
572 |
|
$this->_data_table->add_row( $this->_data_row ); |
573 |
|
$this->_data_row = new TRtag; |
574 |
|
unset( $this->_cur_col_cntr ); |
575 |
|
} else { |
576 |
|
$this->_cur_col_cntr++; |
577 |
|
} |
578 |
|
} |
579 |
|
|
580 |
} |
} |
581 |
?> |
?> |