4 |
## $Id$ |
## $Id$ |
5 |
## ----------------------------------------------------------------------------- |
## ----------------------------------------------------------------------------- |
6 |
## $Log$ |
## $Log$ |
7 |
|
## Revision 1.6 2003/05/13 16:24:30 joko |
8 |
|
## title addendum |
9 |
|
## MetaBox - header style |
10 |
|
## |
11 |
|
## Revision 1.5 2003/05/10 18:07:31 jonen |
12 |
|
## + added values needed for 'create/add new' links |
13 |
|
## - purged depreciated code |
14 |
|
## |
15 |
|
## Revision 1.4 2003/04/09 09:53:13 joko |
16 |
|
## fixes regarding modification of decode-function-behavior |
17 |
|
## |
18 |
|
## Revision 1.3 2003/04/06 01:40:35 jonen |
19 |
|
## + removed duplicated decode functions |
20 |
|
## |
21 |
|
## Revision 1.2 2003/04/04 23:58:33 jonen |
22 |
|
## + minor changes |
23 |
|
## |
24 |
## Revision 1.1 2003/04/04 00:32:57 jonen |
## Revision 1.1 2003/04/04 00:32:57 jonen |
25 |
## + initial commit |
## + initial commit |
26 |
## |
## |
49 |
function DataItem($title, $options = array()) { |
function DataItem($title, $options = array()) { |
50 |
$this->_options = $options; |
$this->_options = $options; |
51 |
|
|
52 |
|
//print "title: $title<br/>"; |
53 |
|
//print Dumper($options); |
54 |
|
|
55 |
|
$title .= $this->get_title_addendum(); |
56 |
|
|
57 |
$parent = get_parent_class($this); |
$parent = get_parent_class($this); |
58 |
$this->$parent($title, $width="100%", "center"); |
$this->$parent($title, $width="100%", "center"); |
59 |
|
|
128 |
$result = $this->_datasource->_result; |
$result = $this->_datasource->_result; |
129 |
if (is_array($result)) { |
if (is_array($result)) { |
130 |
foreach($result as $key => $value) { |
foreach($result as $key => $value) { |
131 |
if(!$value) { $value = " "; } |
// set empty values to 'html spacer' for render |
132 |
// 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!! |
133 |
|
if(!$value && !is_array($value)) { $value = _HTML_SPACE; } |
134 |
|
// if decode options are true, trie to decode values(e.g. for inhiterance) |
135 |
if($this->_options['decode']) { |
if($this->_options['decode']) { |
136 |
if($this->decode_item_expr($value)) { |
$utils = php::mkComponent('WebExplorer::utils'); |
137 |
$this->add_element($key, $this->decode_item_expr($value)); |
$hidden = $this->_hidden_elements; |
138 |
} |
$options = $this->_options['decode_args']; |
139 |
// if item is an Array we will replace it with an selection form object |
$options[label] = $key; |
140 |
elseif($this->decode_item_array($value) ) { |
$options[parent_guid] = $this->_options['parent']['guid']; |
141 |
$this->add_element($key, $this->decode_item_array($value)); |
$options[parent_class] = $this->_options['parent']['class']; |
142 |
} else { |
// if item is matched by a special expression we will replace it with an html-link object |
143 |
$this->add_element($key, $value); |
$utils->decode_item_expr($value, $hidden, $options); |
144 |
} |
// if item is an Array we will replace it with an html-link object |
145 |
|
$utils->decode_item_array($value, $hidden, $options); |
146 |
|
$this->add_element($key, $value); |
147 |
} else { |
} else { |
148 |
$this->add_element($key, $value); |
$this->add_element($key, $value); |
149 |
} |
} |
170 |
} |
} |
171 |
} |
} |
172 |
// submit button |
// submit button |
173 |
$container->add(form_submit('ecfedit', "edit")); |
$container->add(form_submit('ecdfe', "edit")); |
174 |
// close form |
// close form |
175 |
$container->add(form_close()); |
$container->add(form_close()); |
176 |
|
|
177 |
// add container to InfoTable |
// add container to InfoTable |
178 |
$this->add_row(" ", $container); |
$this->add_row(_HTML_SPACE, $container); |
179 |
} |
} |
180 |
|
|
|
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; |
|
|
} |
|
|
} |
|
181 |
|
|
182 |
|
// Please visit WebExplorer::Module::DataItem - there is a similar chooser at the top!!! |
183 |
|
// TODO: abstract this out into some reusable, generic component sometimes (SimpleChooser?) |
184 |
|
// (also take a look at WebExplorer::Module::DataTree) |
185 |
|
function get_title_addendum() { |
186 |
|
|
187 |
|
// MetaBox / Chooser - resolve / display some links which probably have been declared in some other layer |
188 |
|
//$this->header = html_span(); |
189 |
|
|
190 |
|
// Build a header-style MetaBox. |
191 |
|
// This will get injected into the header of the DataItem. |
192 |
|
$this->header_box = php::mkComponent('MetaBox', array( |
193 |
|
box_mode => 'header', |
194 |
|
caption => $this->_options['caption'], |
195 |
|
payload => $this->_options['links'], |
196 |
|
) ); |
197 |
|
|
198 |
function decode_item_expr($item, $options=array()) { |
return $this->header_box->render(); |
199 |
$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; |
|
|
} |
|
200 |
} |
} |
201 |
|
|
|
|
|
202 |
} |
} |
203 |
|
|
204 |
|
|