1 |
<? |
<? |
2 |
/* |
/* |
3 |
## ----------------------------------------------------------------------------- |
## ------------------------------------------------------------------------- |
4 |
## $Id$ |
## $Id$ |
5 |
## ----------------------------------------------------------------------------- |
## ------------------------------------------------------------------------- |
6 |
## $Log$ |
## $Log$ |
7 |
|
## Revision 1.12 2004/05/06 17:14:35 jonen |
8 |
|
## updated |
9 |
|
## |
10 |
|
## Revision 1.11 2003/05/10 17:58:45 jonen |
11 |
|
## + reworked to implement 'create/add new' item |
12 |
|
## |
13 |
|
## Revision 1.10 2003/04/18 18:40:02 jonen |
14 |
|
## + fixed bugs at 'actionbar_cell' relating to html-form and js |
15 |
|
## |
16 |
|
## Revision 1.9 2003/04/11 00:44:46 joko |
17 |
|
## minor update: shortened seperators |
18 |
|
## |
19 |
## Revision 1.8 2003/04/09 07:54:42 joko |
## Revision 1.8 2003/04/09 07:54:42 joko |
20 |
## cleaned up decoding part |
## cleaned up decoding part |
21 |
## |
## |
50 |
## Revision 1.1 2003/03/01 22:57:40 cvsmax |
## Revision 1.1 2003/03/01 22:57:40 cvsmax |
51 |
## + inital commit |
## + inital commit |
52 |
## |
## |
53 |
## |
## ------------------------------------------------------------------------- |
|
## ----------------------------------------------------------------------------- |
|
54 |
*/ |
*/ |
55 |
|
|
56 |
|
|
57 |
/** |
/** |
58 |
* Need to make sure we have the DefaultGUIDataList object |
* Need to make sure we have the DefaultGUIDataList object |
59 |
*/ |
*/ |
164 |
$source = $proxy->get_adapter(); |
$source = $proxy->get_adapter(); |
165 |
|
|
166 |
// V4: |
// V4: |
167 |
//$source = $this->_datasource; |
//$source = $this->_datasource; |
168 |
|
|
169 |
//print "objectlist-source: " . Dumper($source); |
//print "objectlist-source: " . Dumper($source); |
170 |
//exit; |
//exit; |
171 |
|
|
194 |
$this->add_header_item("Uid", "200", "uid", SORTABLE, SEARCHABLE); |
$this->add_header_item("Uid", "200", "uid", SORTABLE, SEARCHABLE); |
195 |
$this->add_header_item("Name", "200", "lastName", SORTABLE, SEARCHABLE, "center"); |
$this->add_header_item("Name", "200", "lastName", SORTABLE, SEARCHABLE, "center"); |
196 |
*/ |
*/ |
197 |
|
|
198 |
} |
} |
199 |
|
|
200 |
|
|
211 |
* @param int - the column # we are working on. |
* @param int - the column # we are working on. |
212 |
* @return TDtag object |
* @return TDtag object |
213 |
*/ |
*/ |
214 |
function wrap_column_item($obj, $col_name) { |
function wrap_column_item($obj, $col_name, $row_data) { |
215 |
|
|
216 |
//make sure its set to something. |
//make sure its set to something. |
217 |
if ($obj == '') { |
if ($obj == '') { |
248 |
$utils = php::mkComponent('WebExplorer::utils'); |
$utils = php::mkComponent('WebExplorer::utils'); |
249 |
$hidden = $this->_hidden_elements; |
$hidden = $this->_hidden_elements; |
250 |
$options = $this->_options['decode_args']; |
$options = $this->_options['decode_args']; |
251 |
|
$options[label] = $col_name; |
252 |
|
$options[parent_guid] = $row_data[guid]; |
253 |
|
$options[parent_class] = $this->_options['parent']['class']; |
254 |
|
|
255 |
// a) Iterate through the attributes of the item and replace each |
// a) Iterate through the attributes of the item and replace each |
256 |
// value with an appropriate link object if it has a certain format. |
// value with an appropriate link object if it has a certain format. |
292 |
} |
} |
293 |
|
|
294 |
|
|
295 |
|
|
296 |
/** |
/** |
297 |
* This function builds the simple search TD |
* This function builds the simple search TD |
298 |
* |
* |
310 |
|
|
311 |
$container = new ContainerWidget; |
$container = new ContainerWidget; |
312 |
|
|
313 |
|
// OLD - needed hidden elements are now recognized at 'render()' |
314 |
|
/* |
315 |
// get current request vars and add them ad hidden items |
// get current request vars and add them ad hidden items |
316 |
$url_vars = $this->_get_current_url_vars(); |
$url_vars = $this->_get_current_url_vars(); |
317 |
foreach($url_vars as $label => $value) { |
foreach($url_vars as $label => $value) { |
318 |
$container->push(form_hidden($label, $value)); |
$container->push(form_hidden($label, $value)); |
319 |
} |
} |
320 |
|
*/ |
321 |
|
|
322 |
if ($cnt == 1) { |
if ($cnt == 1) { |
323 |
//user only has 1 field to show. |
//user only has 1 field to show. |
346 |
$container->push(form_hidden($this->_vars["search_fieldVar"], $field)); |
$container->push(form_hidden($this->_vars["search_fieldVar"], $field)); |
347 |
} |
} |
348 |
|
|
|
|
|
|
//$container->push(form_close() ); |
|
349 |
return $container; |
return $container; |
350 |
} |
} |
351 |
|
|
352 |
|
|
353 |
/** |
/** |
354 |
|
* This function builds the data cell action buttons or main actionbar |
355 |
|
* |
356 |
|
* @return TDtag; |
357 |
|
*/ |
358 |
|
function _build_actionbar_data_cell() { |
359 |
|
$td = new TDtag(array("class" => "datalist_title", |
360 |
|
"style" => "padding-left:5px;padding-right:5px;". |
361 |
|
"padding-top:5px;padding-bottom:5px") |
362 |
|
); |
363 |
|
|
364 |
|
$flag = FALSE; |
365 |
|
if ($this->_has_action_column("FIRST")) { |
366 |
|
$flag = TRUE; |
367 |
|
$td->set_tag_attribute("align", "left"); |
368 |
|
} |
369 |
|
elseif ($this->_has_action_column("LAST")) { |
370 |
|
$flag = TRUE; |
371 |
|
$td->set_tag_attribute("align", "right"); |
372 |
|
} |
373 |
|
|
374 |
|
if ($flag && $this->_datasource->get_total_rows()) { |
375 |
|
$td->push($this->actionbar_cell()); |
376 |
|
$td->push($this->actionbar_cell_new()); |
377 |
|
} |
378 |
|
else { |
379 |
|
$td->push(" "); |
380 |
|
$td->push($this->actionbar_cell_new()); |
381 |
|
} |
382 |
|
|
383 |
|
return $td; |
384 |
|
} |
385 |
|
|
386 |
|
|
387 |
|
/** |
388 |
* this is the method that builds |
* this is the method that builds |
389 |
* the contents for the middle actionbar |
* the contents for the middle actionbar |
390 |
* td cell. |
* td cell. |
397 |
|
|
398 |
if($action_name && is_array($action_list)) { |
if($action_name && is_array($action_list)) { |
399 |
$action_form = container("Select action", _HTML_SPACE, |
$action_form = container("Select action", _HTML_SPACE, |
400 |
form_open("data_list_action", $_SERVER['PHP_SELF'], 'POST'), |
form_select($action_name, $action_list, $this->_options['actionbar']['selected']), |
401 |
form_select($action_name, $action_list), |
form_submit("ok","OK" ) |
402 |
form_submit("submit","OK" ) |
); |
403 |
|
return $action_form; |
404 |
|
} else { |
405 |
|
return _HTML_SPACE; |
406 |
|
} |
407 |
|
} |
408 |
|
|
409 |
|
|
410 |
|
/** |
411 |
|
* this is the method that builds |
412 |
|
* the contents for the buttons of actionbar |
413 |
|
* td cell. |
414 |
|
* |
415 |
|
* @return ContainerWidget object |
416 |
|
*/ |
417 |
|
function actionbar_cell_new() { |
418 |
|
$action_buttons = $this->_options['actionbar']['buttons']; |
419 |
|
|
420 |
|
if(is_array($action_buttons)) { |
421 |
|
$action_form = container(); |
422 |
|
foreach($action_buttons as $type) { |
423 |
|
$action_form->add( |
424 |
|
_HTML_SPACE, |
425 |
|
form_submit($type['name'], $type['value']) |
426 |
); |
); |
|
$url_vars = $this->_get_current_url_vars(); |
|
|
foreach($url_vars as $label => $value) { |
|
|
$action_form->add(form_hidden($label, $value)); |
|
427 |
} |
} |
|
$action_form->add(form_close()); |
|
428 |
return $action_form; |
return $action_form; |
429 |
} else { |
} else { |
430 |
return _HTML_SPACE; |
return _HTML_SPACE; |
433 |
|
|
434 |
|
|
435 |
/* |
/* |
436 |
* this method returns the current requested variables |
* OLD (depreciated) - this method returns the current requested variables |
437 |
* |
* |
438 |
* @return array |
* @return array |
439 |
*/ |
*/ |
460 |
return $cur_url_vars; |
return $cur_url_vars; |
461 |
} |
} |
462 |
|
|
463 |
|
|
464 |
|
/** |
465 |
|
* This function renders the final |
466 |
|
* widget |
467 |
|
* |
468 |
|
*/ |
469 |
|
function render($indent_level, $output_debug) { |
470 |
|
|
471 |
|
//setup the columns in their sorts |
472 |
|
$this->setup_columns(); |
473 |
|
|
474 |
|
//do any data prefetch work |
475 |
|
//which may be child specific |
476 |
|
if ( $this->_show_results() ) { |
477 |
|
$this->data_prefetch(); |
478 |
|
} |
479 |
|
|
480 |
|
//This function gives the child class |
481 |
|
//a chance to build the tables/divs/containers |
482 |
|
//that will be responsible for the look/feel |
483 |
|
//of the DataList |
484 |
|
$this->gui_init(); |
485 |
|
|
486 |
|
//see if we need to build the search area. |
487 |
|
if ( $this->is_search_enabled() || $this->is_advanced_search_enabled() ) { |
488 |
|
$this->_search_table = $this->child_build_search_table(); |
489 |
|
if ( $this->_search_table ) { |
490 |
|
$this->set_form_render(TRUE); |
491 |
|
} |
492 |
|
} |
493 |
|
|
494 |
|
//see if form is needed by the actionbar |
495 |
|
if($this->_show_actionbar) { |
496 |
|
$this->set_form_render(TRUE); |
497 |
|
} |
498 |
|
|
499 |
|
if ( $this->get_form_render() ) { |
500 |
|
$form = new FORMtag( array("method" => $this->get_form_method(), |
501 |
|
"action" => $this->build_base_url(), |
502 |
|
"name" => $this->get_form_name(), |
503 |
|
"style" => "margin-top: 0px;margin-bottom:0px;") ); |
504 |
|
|
505 |
|
$target = $this->get_form_target(); |
506 |
|
if ( $target != NULL ) |
507 |
|
$form->set_tag_attribute("target",$target); |
508 |
|
|
509 |
|
$action = $this->get_form_action(); |
510 |
|
if ( $action != NULL ) |
511 |
|
$form->set_tag_attribute("action",$action); |
512 |
|
|
513 |
|
//now build the UI and return it |
514 |
|
$form->add( $this->build_gui() ); |
515 |
|
|
516 |
|
} else { |
517 |
|
$form = container(); |
518 |
|
|
519 |
|
//now build the UI and return it |
520 |
|
$form->add( $this->build_gui() ); |
521 |
|
} |
522 |
|
|
523 |
|
//add the hidden vars if we are a POST |
524 |
|
if ($this->get_form_method() == "POST") { |
525 |
|
$form->add( $this->_build_default_vars() ); |
526 |
|
|
527 |
|
//build hidden elements needed for data flow control |
528 |
|
$hidden = $this->_hidden_elements; |
529 |
|
//print "Hidden: " . Dumper($hidden); |
530 |
|
if($hidden) { |
531 |
|
foreach($hidden as $label => $value) { |
532 |
|
$form->add(form_hidden($label, $value)); |
533 |
|
} |
534 |
|
} |
535 |
|
|
536 |
|
} |
537 |
|
|
538 |
|
//add the save vars the user wants. |
539 |
|
$form->add( $this->_build_save_vars() ); |
540 |
|
|
541 |
|
//add any javascript required |
542 |
|
$container = container( $this->_javascript(), $form ); |
543 |
|
return $container->render( $indent_level, $output_debug ); |
544 |
|
} |
545 |
|
|
546 |
|
|
547 |
|
|
548 |
|
function child_add_row_cell($obj, $col_name, $last_in_row_flag, $row_data) { |
549 |
|
if (!$this->_cur_col_cntr) { |
550 |
|
//if (!isset($this->_cur_col_cntr)) { |
551 |
|
$this->_cur_col_cntr = 1; |
552 |
|
//lets see if we need to add an action column |
553 |
|
//as the first column. |
554 |
|
if ($this->_has_action_column("FIRST")) { |
555 |
|
//looks like we have a FIRST column actionbar |
556 |
|
//lets add it |
557 |
|
$this->_data_row->add($this->_build_action_column("FIRST", FALSE, $row_data)); |
558 |
|
} |
559 |
|
$td = $this->wrap_column_item($obj, $col_name, $row_data); |
560 |
|
$this->_data_row->add( $td ); |
561 |
|
} else { |
562 |
|
//show the normal data |
563 |
|
$td = $this->wrap_column_item($obj, $col_name, $row_data); |
564 |
|
$this->_data_row->add( $td ); |
565 |
|
} |
566 |
|
|
567 |
|
|
568 |
|
if ($last_in_row_flag) { |
569 |
|
//lets see if we need to add an action column |
570 |
|
//as the first column. |
571 |
|
if ($this->_has_action_column("LAST")) { |
572 |
|
//looks like we have a LAST column actionbar |
573 |
|
//lets add it |
574 |
|
$this->_data_row->add($this->_build_action_column("LAST", FALSE, $row_data)); |
575 |
|
} |
576 |
|
|
577 |
|
|
578 |
|
|
579 |
|
$this->_data_table->add_row( $this->_data_row ); |
580 |
|
$this->_data_row = new TRtag; |
581 |
|
unset( $this->_cur_col_cntr ); |
582 |
|
} else { |
583 |
|
$this->_cur_col_cntr++; |
584 |
|
} |
585 |
|
} |
586 |
|
|
587 |
} |
} |
588 |
?> |
?> |