1 |
<? |
<? |
2 |
/* |
/* |
3 |
## ----------------------------------------------------------------------------- |
## ------------------------------------------------------------------------- |
4 |
## $Id$ |
## $Id$ |
5 |
## ----------------------------------------------------------------------------- |
## ------------------------------------------------------------------------- |
6 |
## $Log$ |
## $Log$ |
7 |
|
## Revision 1.14 2004/11/15 16:51:48 jonen |
8 |
|
## + added var 'numrows' to constructor args |
9 |
|
## |
10 |
|
## Revision 1.13 2004/10/07 14:17:50 jonen |
11 |
|
## + pass filter-values to backend now! (page-control!) |
12 |
|
## |
13 |
|
## Revision 1.12 2004/05/06 17:14:35 jonen |
14 |
|
## updated |
15 |
|
## |
16 |
|
## Revision 1.11 2003/05/10 17:58:45 jonen |
17 |
|
## + reworked to implement 'create/add new' item |
18 |
|
## |
19 |
|
## Revision 1.10 2003/04/18 18:40:02 jonen |
20 |
|
## + fixed bugs at 'actionbar_cell' relating to html-form and js |
21 |
|
## |
22 |
|
## Revision 1.9 2003/04/11 00:44:46 joko |
23 |
|
## minor update: shortened seperators |
24 |
|
## |
25 |
## Revision 1.8 2003/04/09 07:54:42 joko |
## Revision 1.8 2003/04/09 07:54:42 joko |
26 |
## cleaned up decoding part |
## cleaned up decoding part |
27 |
## |
## |
56 |
## Revision 1.1 2003/03/01 22:57:40 cvsmax |
## Revision 1.1 2003/03/01 22:57:40 cvsmax |
57 |
## + inital commit |
## + inital commit |
58 |
## |
## |
59 |
## |
## ------------------------------------------------------------------------- |
|
## ----------------------------------------------------------------------------- |
|
60 |
*/ |
*/ |
61 |
|
|
62 |
|
|
63 |
/** |
/** |
64 |
* Need to make sure we have the DefaultGUIDataList object |
* Need to make sure we have the DefaultGUIDataList object |
65 |
*/ |
*/ |
106 |
* |
* |
107 |
* |
* |
108 |
*/ |
*/ |
109 |
function GenericGUIDataList($title, $width = "100%", $default_orderby='', $default_reverseorder=FALSE, $options = array()) { |
function GenericGUIDataList($title, $width = "100%", $default_orderby='', $default_reverseorder=FALSE, $num_rows=10, $options = array()) { |
110 |
if ($options) { $this->_options = $options; } |
if ($options) { $this->_options = $options; } |
111 |
|
|
112 |
|
$this->set_numrows($num_rows); |
113 |
|
|
114 |
// call parent constructor |
// call parent constructor |
115 |
$parent = get_parent_class($this); |
$parent = get_parent_class($this); |
116 |
$this->$parent($title, $width = "100%", $default_orderby='', $default_reverseorder=FALSE); |
$this->$parent($title, $width = "100%", $default_orderby='', $default_reverseorder=FALSE); |
117 |
|
|
118 |
} |
} |
119 |
|
|
120 |
|
|
150 |
// V5: |
// V5: |
151 |
//print "options: " . Dumper($this->_options); |
//print "options: " . Dumper($this->_options); |
152 |
|
|
153 |
|
|
154 |
|
//HACK 2004-10-07: page-filter done by backend now, |
155 |
|
// filter-values are passed to backend |
156 |
|
$this->_options['data_locator_meta']['filter']['offset'] = $this->offset(); |
157 |
|
$this->_options['data_locator_meta']['filter']['numrows'] = $this->numrows(); |
158 |
|
$this->_options['data_locator_meta']['filter']['search_field'] = $this->search_field(); |
159 |
|
$this->_options['data_locator_meta']['filter']['search_value'] = $this->search_value(); |
160 |
|
$this->_options['data_locator_meta']['filter']['search_modifier'] = $this->simple_search_modifier_value(); |
161 |
|
|
162 |
|
//$this->_set("offsetVar", 0); |
163 |
|
|
164 |
$initial_locator = php::mkComponent( 'DataSource::Locator', array( adapter_type => 'phpHtmlLib' ) ); |
$initial_locator = php::mkComponent( 'DataSource::Locator', array( adapter_type => 'phpHtmlLib' ) ); |
165 |
//print "1st locator: " . Dumper($initial_locator); |
//print "1st locator: " . Dumper($initial_locator); |
166 |
|
|
184 |
$source = $proxy->get_adapter(); |
$source = $proxy->get_adapter(); |
185 |
|
|
186 |
// V4: |
// V4: |
187 |
//$source = $this->_datasource; |
//$source = $this->_datasource; |
188 |
|
|
189 |
//print "objectlist-source: " . Dumper($source); |
//print "objectlist-source: " . Dumper($source); |
190 |
//exit; |
//exit; |
191 |
|
|
202 |
|
|
203 |
//print Dumper($source); |
//print Dumper($source); |
204 |
$headers = $source->get_header(); |
$headers = $source->get_header(); |
205 |
//print Dumper($headers); |
//print "headers: " . Dumper($headers); |
206 |
|
|
207 |
$this->set_title( $this->get_title() . ' - ' . $source->get_total_rows() . ' Einträge' ); |
$this->set_title( $this->get_title() . ' - ' . $source->get_total_rows() . ' Einträge' ); |
208 |
|
|
209 |
foreach($headers as $val) { |
foreach($headers as $val) { |
210 |
$this->add_header_item($val, "150", $val, SORTABLE, SEARCHABLE); |
$this->add_header_item($val, "150", $val, SORTABLE, SEARCHABLE); |
211 |
} |
} |
212 |
|
|
213 |
|
|
214 |
/* |
/* |
215 |
$this->add_header_item("Uid", "200", "uid", SORTABLE, SEARCHABLE); |
$this->add_header_item("Uid", "200", "uid", SORTABLE, SEARCHABLE); |
216 |
$this->add_header_item("Name", "200", "lastName", SORTABLE, SEARCHABLE, "center"); |
$this->add_header_item("Name", "200", "lastName", SORTABLE, SEARCHABLE, "center"); |
217 |
*/ |
*/ |
218 |
|
|
219 |
} |
} |
220 |
|
|
221 |
|
|
232 |
* @param int - the column # we are working on. |
* @param int - the column # we are working on. |
233 |
* @return TDtag object |
* @return TDtag object |
234 |
*/ |
*/ |
235 |
function wrap_column_item($obj, $col_name) { |
function wrap_column_item($obj, $col_name, $row_data) { |
236 |
|
|
237 |
|
//print "item: " . Dumper($obj) . "<br>"; |
238 |
|
|
239 |
//make sure its set to something. |
//make sure its set to something. |
240 |
if ($obj == '') { |
if ($obj == '') { |
271 |
$utils = php::mkComponent('WebExplorer::utils'); |
$utils = php::mkComponent('WebExplorer::utils'); |
272 |
$hidden = $this->_hidden_elements; |
$hidden = $this->_hidden_elements; |
273 |
$options = $this->_options['decode_args']; |
$options = $this->_options['decode_args']; |
274 |
|
$options[label] = $col_name; |
275 |
|
$options[parent_guid] = $row_data[guid]; |
276 |
|
$options[parent_class] = $this->_options['parent']['class']; |
277 |
|
|
278 |
// a) Iterate through the attributes of the item and replace each |
// a) Iterate through the attributes of the item and replace each |
279 |
// value with an appropriate link object if it has a certain format. |
// value with an appropriate link object if it has a certain format. |
315 |
} |
} |
316 |
|
|
317 |
|
|
318 |
|
|
319 |
/** |
/** |
320 |
* This function builds the simple search TD |
* This function builds the simple search TD |
321 |
* |
* |
333 |
|
|
334 |
$container = new ContainerWidget; |
$container = new ContainerWidget; |
335 |
|
|
336 |
|
// OLD - needed hidden elements are now recognized at 'render()' |
337 |
|
/* |
338 |
// get current request vars and add them ad hidden items |
// get current request vars and add them ad hidden items |
339 |
$url_vars = $this->_get_current_url_vars(); |
$url_vars = $this->_get_current_url_vars(); |
340 |
foreach($url_vars as $label => $value) { |
foreach($url_vars as $label => $value) { |
341 |
$container->push(form_hidden($label, $value)); |
$container->push(form_hidden($label, $value)); |
342 |
} |
} |
343 |
|
*/ |
344 |
|
|
345 |
if ($cnt == 1) { |
if ($cnt == 1) { |
346 |
//user only has 1 field to show. |
//user only has 1 field to show. |
369 |
$container->push(form_hidden($this->_vars["search_fieldVar"], $field)); |
$container->push(form_hidden($this->_vars["search_fieldVar"], $field)); |
370 |
} |
} |
371 |
|
|
|
|
|
|
//$container->push(form_close() ); |
|
372 |
return $container; |
return $container; |
373 |
} |
} |
374 |
|
|
375 |
|
|
376 |
/** |
/** |
377 |
|
* This function builds the data cell action buttons or main actionbar |
378 |
|
* |
379 |
|
* @return TDtag; |
380 |
|
*/ |
381 |
|
function _build_actionbar_data_cell() { |
382 |
|
$td = new TDtag(array("class" => "datalist_title", |
383 |
|
"style" => "padding-left:5px;padding-right:5px;". |
384 |
|
"padding-top:5px;padding-bottom:5px") |
385 |
|
); |
386 |
|
|
387 |
|
$flag = FALSE; |
388 |
|
if ($this->_has_action_column("FIRST")) { |
389 |
|
$flag = TRUE; |
390 |
|
$td->set_tag_attribute("align", "left"); |
391 |
|
} |
392 |
|
elseif ($this->_has_action_column("LAST")) { |
393 |
|
$flag = TRUE; |
394 |
|
$td->set_tag_attribute("align", "right"); |
395 |
|
} |
396 |
|
|
397 |
|
if ($flag && $this->_datasource->get_total_rows()) { |
398 |
|
$td->push($this->actionbar_cell()); |
399 |
|
$td->push($this->actionbar_cell_new()); |
400 |
|
} |
401 |
|
else { |
402 |
|
$td->push(" "); |
403 |
|
$td->push($this->actionbar_cell_new()); |
404 |
|
} |
405 |
|
|
406 |
|
return $td; |
407 |
|
} |
408 |
|
|
409 |
|
|
410 |
|
/** |
411 |
* this is the method that builds |
* this is the method that builds |
412 |
* the contents for the middle actionbar |
* the contents for the middle actionbar |
413 |
* td cell. |
* td cell. |
420 |
|
|
421 |
if($action_name && is_array($action_list)) { |
if($action_name && is_array($action_list)) { |
422 |
$action_form = container("Select action", _HTML_SPACE, |
$action_form = container("Select action", _HTML_SPACE, |
423 |
form_open("data_list_action", $_SERVER['PHP_SELF'], 'POST'), |
form_select($action_name, $action_list, $this->_options['actionbar']['selected']), |
424 |
form_select($action_name, $action_list), |
form_submit("ok","OK" ) |
425 |
form_submit("submit","OK" ) |
); |
426 |
|
return $action_form; |
427 |
|
} else { |
428 |
|
return _HTML_SPACE; |
429 |
|
} |
430 |
|
} |
431 |
|
|
432 |
|
|
433 |
|
/** |
434 |
|
* this is the method that builds |
435 |
|
* the contents for the buttons of actionbar |
436 |
|
* td cell. |
437 |
|
* |
438 |
|
* @return ContainerWidget object |
439 |
|
*/ |
440 |
|
function actionbar_cell_new() { |
441 |
|
$action_buttons = $this->_options['actionbar']['buttons']; |
442 |
|
|
443 |
|
if(is_array($action_buttons)) { |
444 |
|
$action_form = container(); |
445 |
|
foreach($action_buttons as $type) { |
446 |
|
$action_form->add( |
447 |
|
_HTML_SPACE, |
448 |
|
form_submit($type['name'], $type['value']) |
449 |
); |
); |
|
$url_vars = $this->_get_current_url_vars(); |
|
|
foreach($url_vars as $label => $value) { |
|
|
$action_form->add(form_hidden($label, $value)); |
|
450 |
} |
} |
|
$action_form->add(form_close()); |
|
451 |
return $action_form; |
return $action_form; |
452 |
} else { |
} else { |
453 |
return _HTML_SPACE; |
return _HTML_SPACE; |
456 |
|
|
457 |
|
|
458 |
/* |
/* |
459 |
* this method returns the current requested variables |
* OLD (depreciated) - this method returns the current requested variables |
460 |
* |
* |
461 |
* @return array |
* @return array |
462 |
*/ |
*/ |
483 |
return $cur_url_vars; |
return $cur_url_vars; |
484 |
} |
} |
485 |
|
|
486 |
|
|
487 |
|
/** |
488 |
|
* This function renders the final |
489 |
|
* widget |
490 |
|
* |
491 |
|
*/ |
492 |
|
function render($indent_level, $output_debug) { |
493 |
|
|
494 |
|
//setup the columns in their sorts |
495 |
|
$this->setup_columns(); |
496 |
|
|
497 |
|
//do any data prefetch work |
498 |
|
//which may be child specific |
499 |
|
if ( $this->_show_results() ) { |
500 |
|
$this->data_prefetch(); |
501 |
|
} |
502 |
|
|
503 |
|
//This function gives the child class |
504 |
|
//a chance to build the tables/divs/containers |
505 |
|
//that will be responsible for the look/feel |
506 |
|
//of the DataList |
507 |
|
$this->gui_init(); |
508 |
|
|
509 |
|
//see if we need to build the search area. |
510 |
|
if ( $this->is_search_enabled() || $this->is_advanced_search_enabled() ) { |
511 |
|
$this->_search_table = $this->child_build_search_table(); |
512 |
|
if ( $this->_search_table ) { |
513 |
|
$this->set_form_render(TRUE); |
514 |
|
} |
515 |
|
} |
516 |
|
|
517 |
|
//see if form is needed by the actionbar |
518 |
|
if($this->_show_actionbar) { |
519 |
|
$this->set_form_render(TRUE); |
520 |
|
} |
521 |
|
|
522 |
|
if ( $this->get_form_render() ) { |
523 |
|
$form = new FORMtag( array("method" => $this->get_form_method(), |
524 |
|
"action" => $this->build_base_url(), |
525 |
|
"name" => $this->get_form_name(), |
526 |
|
"style" => "margin-top: 0px;margin-bottom:0px;") ); |
527 |
|
|
528 |
|
$target = $this->get_form_target(); |
529 |
|
if ( $target != NULL ) |
530 |
|
$form->set_tag_attribute("target",$target); |
531 |
|
|
532 |
|
$action = $this->get_form_action(); |
533 |
|
if ( $action != NULL ) |
534 |
|
$form->set_tag_attribute("action",$action); |
535 |
|
|
536 |
|
//now build the UI and return it |
537 |
|
$form->add( $this->build_gui() ); |
538 |
|
|
539 |
|
} else { |
540 |
|
$form = container(); |
541 |
|
|
542 |
|
//now build the UI and return it |
543 |
|
$form->add( $this->build_gui() ); |
544 |
|
} |
545 |
|
|
546 |
|
//add the hidden vars if we are a POST |
547 |
|
if ($this->get_form_method() == "POST") { |
548 |
|
$form->add( $this->_build_default_vars() ); |
549 |
|
|
550 |
|
//build hidden elements needed for data flow control |
551 |
|
$hidden = $this->_hidden_elements; |
552 |
|
//print "Hidden: " . Dumper($hidden); |
553 |
|
if($hidden) { |
554 |
|
foreach($hidden as $label => $value) { |
555 |
|
$form->add(form_hidden($label, $value)); |
556 |
|
} |
557 |
|
} |
558 |
|
|
559 |
|
} |
560 |
|
|
561 |
|
//add the save vars the user wants. |
562 |
|
$form->add( $this->_build_save_vars() ); |
563 |
|
|
564 |
|
//add any javascript required |
565 |
|
$container = container( $this->_javascript(), $form ); |
566 |
|
return $container->render( $indent_level, $output_debug ); |
567 |
|
} |
568 |
|
|
569 |
|
|
570 |
|
|
571 |
|
function child_add_row_cell($obj, $col_name, $last_in_row_flag, $row_data) { |
572 |
|
if (!$this->_cur_col_cntr) { |
573 |
|
//if (!isset($this->_cur_col_cntr)) { |
574 |
|
$this->_cur_col_cntr = 1; |
575 |
|
//lets see if we need to add an action column |
576 |
|
//as the first column. |
577 |
|
if ($this->_has_action_column("FIRST")) { |
578 |
|
//looks like we have a FIRST column actionbar |
579 |
|
//lets add it |
580 |
|
$this->_data_row->add($this->_build_action_column("FIRST", FALSE, $row_data)); |
581 |
|
} |
582 |
|
$td = $this->wrap_column_item($obj, $col_name, $row_data); |
583 |
|
$this->_data_row->add( $td ); |
584 |
|
} else { |
585 |
|
//show the normal data |
586 |
|
$td = $this->wrap_column_item($obj, $col_name, $row_data); |
587 |
|
$this->_data_row->add( $td ); |
588 |
|
} |
589 |
|
|
590 |
|
|
591 |
|
if ($last_in_row_flag) { |
592 |
|
//lets see if we need to add an action column |
593 |
|
//as the first column. |
594 |
|
if ($this->_has_action_column("LAST")) { |
595 |
|
//looks like we have a LAST column actionbar |
596 |
|
//lets add it |
597 |
|
$this->_data_row->add($this->_build_action_column("LAST", FALSE, $row_data)); |
598 |
|
} |
599 |
|
|
600 |
|
|
601 |
|
|
602 |
|
$this->_data_table->add_row( $this->_data_row ); |
603 |
|
$this->_data_row = new TRtag; |
604 |
|
unset( $this->_cur_col_cntr ); |
605 |
|
} else { |
606 |
|
$this->_cur_col_cntr++; |
607 |
|
} |
608 |
|
} |
609 |
|
|
610 |
} |
} |
611 |
?> |
?> |