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 |
## Revision 1.10 2003/04/18 18:40:02 jonen |
11 |
## + fixed bugs at 'actionbar_cell' relating to html-form and js |
## + fixed bugs at 'actionbar_cell' relating to html-form and js |
12 |
## |
## |
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 |
// a) Iterate through the attributes of the item and replace each |
// a) Iterate through the attributes of the item and replace each |
253 |
// value with an appropriate link object if it has a certain format. |
// value with an appropriate link object if it has a certain format. |
289 |
} |
} |
290 |
|
|
291 |
|
|
292 |
|
|
293 |
/** |
/** |
294 |
* This function builds the simple search TD |
* This function builds the simple search TD |
295 |
* |
* |
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 |
// get current request vars and add them ad hidden items |
313 |
$url_vars = $this->_get_current_url_vars(); |
$url_vars = $this->_get_current_url_vars(); |
314 |
foreach($url_vars as $label => $value) { |
foreach($url_vars as $label => $value) { |
315 |
$container->push(form_hidden($label, $value)); |
$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 |
|
|
|
|
|
|
//$container->push(form_close() ); |
|
346 |
return $container; |
return $container; |
347 |
} |
} |
348 |
|
|
349 |
|
|
350 |
/** |
/** |
351 |
|
* 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 |
* this is the method that builds |
386 |
* the contents for the middle actionbar |
* the contents for the middle actionbar |
387 |
* td cell. |
* td cell. |
394 |
|
|
395 |
if($action_name && is_array($action_list)) { |
if($action_name && is_array($action_list)) { |
396 |
$action_form = container("Select action", _HTML_SPACE, |
$action_form = container("Select action", _HTML_SPACE, |
397 |
form_select($action_name, $action_list), |
form_select($action_name, $action_list, $this->_options['actionbar']['selected']), |
398 |
form_submit("ok","OK" ) |
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; |
return $action_form; |
423 |
} else { |
} else { |
427 |
|
|
428 |
|
|
429 |
/* |
/* |
430 |
* this method returns the current requested variables |
* OLD (depreciated) - this method returns the current requested variables |
431 |
* |
* |
432 |
* @return array |
* @return array |
433 |
*/ |
*/ |
454 |
return $cur_url_vars; |
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 |
|
//This function gives the child class |
475 |
|
//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 |
?> |
?> |