| 4 |
## $Id$ |
## $Id$ |
| 5 |
## ----------------------------------------------------------------------------- |
## ----------------------------------------------------------------------------- |
| 6 |
## $Log$ |
## $Log$ |
| 7 |
|
## Revision 1.7 2003/11/22 18:40:58 udo |
| 8 |
|
## bug fix |
| 9 |
|
## |
| 10 |
|
## Revision 1.6 2003/05/13 16:24:30 joko |
| 11 |
|
## title addendum |
| 12 |
|
## MetaBox - header style |
| 13 |
|
## |
| 14 |
|
## Revision 1.5 2003/05/10 18:07:31 jonen |
| 15 |
|
## + added values needed for 'create/add new' links |
| 16 |
|
## - purged depreciated code |
| 17 |
|
## |
| 18 |
|
## Revision 1.4 2003/04/09 09:53:13 joko |
| 19 |
|
## fixes regarding modification of decode-function-behavior |
| 20 |
|
## |
| 21 |
|
## Revision 1.3 2003/04/06 01:40:35 jonen |
| 22 |
|
## + removed duplicated decode functions |
| 23 |
|
## |
| 24 |
|
## Revision 1.2 2003/04/04 23:58:33 jonen |
| 25 |
|
## + minor changes |
| 26 |
|
## |
| 27 |
## Revision 1.1 2003/04/04 00:32:57 jonen |
## Revision 1.1 2003/04/04 00:32:57 jonen |
| 28 |
## + initial commit |
## + initial commit |
| 29 |
## |
## |
| 52 |
function DataItem($title, $options = array()) { |
function DataItem($title, $options = array()) { |
| 53 |
$this->_options = $options; |
$this->_options = $options; |
| 54 |
|
|
| 55 |
$parent = get_parent_class($this); |
//print "title: $title<br/>"; |
| 56 |
|
//print "options:" . Dumper($options) . "<br>"; |
| 57 |
|
|
| 58 |
|
$title .= $this->get_title_addendum(); |
| 59 |
|
|
| 60 |
|
$parent = get_parent_class($this); |
| 61 |
|
// debug (WARNNING!!! Sometime an recursive loop happens here |
| 62 |
|
// if class $parent is eq current class!!) |
| 63 |
|
//print "parent: " . Dumper($parent) . "<br>"; |
| 64 |
|
|
| 65 |
$this->$parent($title, $width="100%", "center"); |
$this->$parent($title, $width="100%", "center"); |
| 66 |
|
|
| 67 |
// fetch data |
// fetch data |
| 111 |
} |
} |
| 112 |
|
|
| 113 |
function get_data_source() { |
function get_data_source() { |
| 114 |
|
|
| 115 |
$initial_locator = php::mkComponent( 'DataSource::Locator', array( adapter_type => 'phpHtmlLib' ) ); |
$initial_locator = php::mkComponent( 'DataSource::Locator', array( adapter_type => 'phpHtmlLib' ) ); |
| 116 |
$proxy = php::mkComponent('DataSource::Generic', $initial_locator, $this->_options['data_locator_meta']); |
$proxy = php::mkComponent('DataSource::Generic', $initial_locator, $this->_options['data_locator_meta']); |
| 117 |
$source = $proxy->get_adapter(); |
$source = $proxy->get_adapter(); |
| 136 |
$result = $this->_datasource->_result; |
$result = $this->_datasource->_result; |
| 137 |
if (is_array($result)) { |
if (is_array($result)) { |
| 138 |
foreach($result as $key => $value) { |
foreach($result as $key => $value) { |
| 139 |
if(!$value) { $value = " "; } |
// set empty values to 'html spacer' for render |
| 140 |
// if item is match by expression we will replace it with an link object |
// TODO: integer value '0' is interpretted as non-existing value! Hack this!! |
| 141 |
|
if(!$value && !is_array($value)) { $value = _HTML_SPACE; } |
| 142 |
|
// if decode options are true, trie to decode values(e.g. for inhiterance) |
| 143 |
if($this->_options['decode']) { |
if($this->_options['decode']) { |
| 144 |
if($this->decode_item_expr($value)) { |
$utils = php::mkComponent('WebExplorer::utils'); |
| 145 |
$this->add_element($key, $this->decode_item_expr($value)); |
$hidden = $this->_hidden_elements; |
| 146 |
} |
$options = $this->_options['decode_args']; |
| 147 |
// if item is an Array we will replace it with an selection form object |
$options[label] = $key; |
| 148 |
elseif($this->decode_item_array($value) ) { |
$options[parent_guid] = $this->_options['parent']['guid']; |
| 149 |
$this->add_element($key, $this->decode_item_array($value)); |
$options[parent_class] = $this->_options['parent']['class']; |
| 150 |
} else { |
// if item is matched by a special expression we will replace it with an html-link object |
| 151 |
$this->add_element($key, $value); |
$utils->decode_item_expr($value, $hidden, $options); |
| 152 |
} |
// if item is an Array we will replace it with an html-link object |
| 153 |
|
$utils->decode_item_array($value, $hidden, $options); |
| 154 |
|
|
| 155 |
|
$this->add_element($key, $value); |
| 156 |
} else { |
} else { |
| 157 |
$this->add_element($key, $value); |
$this->add_element($key, $value); |
| 158 |
} |
} |
| 179 |
} |
} |
| 180 |
} |
} |
| 181 |
// submit button |
// submit button |
| 182 |
$container->add(form_submit('ecfedit', "edit")); |
$container->add(form_submit('ecdfe', "edit")); |
| 183 |
// close form |
// close form |
| 184 |
$container->add(form_close()); |
$container->add(form_close()); |
| 185 |
|
|
| 186 |
// add container to InfoTable |
// add container to InfoTable |
| 187 |
$this->add_row(" ", $container); |
$this->add_row(_HTML_SPACE, $container); |
| 188 |
} |
} |
| 189 |
|
|
|
function decode_item_array($item) { |
|
|
$options = $this->_options['decode_args']; |
|
|
if( is_array($item) ) { |
|
|
//$cur_row_index = $this->_datasource->get_cur_data_index(); |
|
|
//$parent_guid = $this->_datasource->_data[$cur_row_index]['guid']; |
|
|
// build list for selection form |
|
|
if($options['form']) { |
|
|
foreach($item as $key => $value) { |
|
|
$tmp = split($options['seperator'], $value); |
|
|
$ident = $tmp['1']; |
|
|
$meta = $tmp['2']; |
|
|
$list[$key] = $ident; |
|
|
} |
|
|
if(is_array($list) ) { |
|
|
$container = container( |
|
|
form_open( $item[0], $_SERVER["PHP_SELF"], "POST" ), |
|
|
form_hidden("ecdm", $meta), |
|
|
form_select("ecdid", $list), |
|
|
form_submit("submit","view" ) |
|
|
); |
|
|
foreach($this->_hidden_elements as $label => $value) { |
|
|
$container->add(form_hidden($label, $value)); |
|
|
} |
|
|
$container->add(form_close() ); |
|
|
$item = $container; |
|
|
} |
|
|
} else { |
|
|
$container = container(); |
|
|
foreach($item as $key => $value) { |
|
|
$tmp = split($options['seperator'], $value); |
|
|
$ident = $tmp['1']; |
|
|
$meta = $tmp['2']; |
|
|
foreach($this->_hidden_elements as $label => $value) { |
|
|
$tmp_array[] = $label . "=" . $value; |
|
|
} |
|
|
$str_hidden = join("&", $tmp_array); |
|
|
$container->add("->", html_a($_SERVER["PHP_SELF"] . "?ecdid=" . $ident . "&ecdm=" . $meta . "&" . $str_hidden, $key . " view"), html_br()); |
|
|
} |
|
|
$item = $container; |
|
|
} |
|
|
return $item; |
|
|
} |
|
|
} |
|
| 190 |
|
|
| 191 |
|
// Please visit WebExplorer::Module::DataItem - there is a similar chooser at the top!!! |
| 192 |
|
// TODO: abstract this out into some reusable, generic component sometimes (SimpleChooser?) |
| 193 |
|
// (also take a look at WebExplorer::Module::DataTree) |
| 194 |
|
function get_title_addendum() { |
| 195 |
|
|
| 196 |
|
// MetaBox / Chooser - resolve / display some links which probably have been declared in some other layer |
| 197 |
|
//$this->header = html_span(); |
| 198 |
|
|
| 199 |
|
// Build a header-style MetaBox. |
| 200 |
|
// This will get injected into the header of the DataItem. |
| 201 |
|
$this->header_box = php::mkComponent('MetaBox', array( |
| 202 |
|
box_mode => 'header', |
| 203 |
|
caption => $this->_options['caption'], |
| 204 |
|
payload => $this->_options['links'], |
| 205 |
|
) ); |
| 206 |
|
|
| 207 |
function decode_item_expr($item, $options=array()) { |
return $this->header_box->render(); |
| 208 |
$options = $this->_options['decode_args']; |
|
|
if(substr($item, 0, 2) == "o_") { |
|
|
$tmp = split($options['seperator'], $item); |
|
|
$ident = $tmp['1']; |
|
|
$meta = $tmp['2']; |
|
|
foreach($this->_hidden_elements as $label => $value) { |
|
|
$tmp_array[] = $label . "=" . $value; |
|
|
} |
|
|
$str_hidden = join("&", $tmp_array); |
|
|
$item = html_a($_SERVER["PHP_SELF"] . "?ecdid=" . $ident . "&ecdm=" . $meta . "&" . $str_hidden, "view"); |
|
|
return $item; |
|
|
} |
|
| 209 |
} |
} |
| 210 |
|
|
|
|
|
| 211 |
} |
} |
| 212 |
|
|
| 213 |
|
|