1 |
<?php |
2 |
|
3 |
/** |
4 |
* $Id: utils.php,v 1.2 2003/04/09 00:32:42 jonen Exp $ |
5 |
* |
6 |
* $Log: utils.php,v $ |
7 |
* Revision 1.2 2003/04/09 00:32:42 jonen |
8 |
* some tests according to form rendering at the decode functions |
9 |
* |
10 |
* Revision 1.1 2003/04/06 01:28:04 jonen |
11 |
* + initial commit |
12 |
* + moved decode functions here |
13 |
* + reworked decode functions to use new LinkBuilder class |
14 |
* |
15 |
* |
16 |
* |
17 |
*/ |
18 |
|
19 |
/** |
20 |
* Container holds most helper functions are used at the WebExplorer itself |
21 |
* or at its components, e.g. decode functions used at the GUI modules. |
22 |
* |
23 |
* |
24 |
* @author Sebastian Utz <seut@tunemedia.de> |
25 |
* @package org.netfrag.app |
26 |
* @name WebExplorer::utils |
27 |
* |
28 |
*/ |
29 |
|
30 |
|
31 |
class WebExplorer_utils { |
32 |
|
33 |
|
34 |
|
35 |
// TODO: refactor to Data::Lift - subcomponent: handling will get way more easy! |
36 |
function decode_item_array(&$item, $hidden_elements, $options) { |
37 |
//$options = $this->_options['decode_args']; |
38 |
//print "item: " . Dumper($item); |
39 |
//print "options: " . Dumper($options); |
40 |
if( is_array($item) ) { |
41 |
//$cur_row_index = $this->_datasource->get_cur_data_index(); |
42 |
//$parent_guid = $this->_datasource->_data[$cur_row_index]['guid']; |
43 |
// build list for selection form |
44 |
if($options['form']) { |
45 |
foreach($item as $key => $value) { |
46 |
$tmp = split($options['seperator'], $value); |
47 |
$ident = $tmp['1']; |
48 |
$meta = $tmp['2']; |
49 |
|
50 |
$link_vars = array( |
51 |
'ecdid' => $ident, |
52 |
'ecdm' => $meta |
53 |
); |
54 |
|
55 |
foreach($hidden_elements as $label => $value) { |
56 |
$link_vars[$label] = $value; |
57 |
} |
58 |
|
59 |
// create new LinkBuilder instance and get link GUID by saving vars |
60 |
$link_guid = link::store($link_vars); |
61 |
|
62 |
$list[$key] = $link_guid; |
63 |
} |
64 |
if(is_array($list) ) { |
65 |
$container = container( |
66 |
//form_open( $item[0], $_SERVER['PHP_SELF'], "POST" ), |
67 |
form_select("lbid", $list), |
68 |
form_submit("submit","view" ) |
69 |
); |
70 |
//$container->add(form_close() ); |
71 |
$item = $container; |
72 |
} |
73 |
} else { |
74 |
//print "<b>2</b><br/>"; |
75 |
$container = container(); |
76 |
foreach($item as $key => $value) { |
77 |
$tmp = split($options['seperator'], $value); |
78 |
$ident = $tmp['1']; |
79 |
$meta = $tmp['2']; |
80 |
|
81 |
$link_vars = array( |
82 |
'ecdid' => $ident, |
83 |
'ecdm' => $meta, |
84 |
); |
85 |
|
86 |
foreach($hidden_elements as $label => $value) { |
87 |
$link_vars[$label] = $value; |
88 |
//$tmp_array[] = $label . "=" . $value; |
89 |
} |
90 |
|
91 |
//$str_hidden = join("&", $tmp_array); |
92 |
//$container->add("->", html_a($_SERVER["PHP_SELF"] . "?ecdid=" . $ident . "&ecdm=" . $meta . "&" . $str_hidden, $key . " view"), html_br()); |
93 |
|
94 |
// create new LinkBuilder instance and get link GUID by saving vars |
95 |
$link_guid = link::store($link_vars); |
96 |
|
97 |
$container->add("->", html_a($_SERVER["PHP_SELF"] . "?lbid=" . $link_guid, $key . " view"), html_br()); |
98 |
} |
99 |
$item = $container; |
100 |
} |
101 |
//return $item; |
102 |
return 1; |
103 |
} |
104 |
} |
105 |
|
106 |
// decodes serialized string representations of object-references |
107 |
// TODO: refactor to Data::Lift - subcomponent: handling will get way more easy! |
108 |
function decode_item_expr(&$item, $hidden_elements, $options) { |
109 |
|
110 |
//return; |
111 |
|
112 |
// debug |
113 |
//$options = $this->_options['decode_args']; |
114 |
//print "item: $item<br/>"; |
115 |
|
116 |
// resolve 'o_{guid}_{classname}' - encoded string |
117 |
$link_meta = php::untwingle_reference($item); |
118 |
//print Dumper($link_meta); |
119 |
|
120 |
if (!is_array($link_meta)) { |
121 |
//return $item; |
122 |
//print "NO<br/>"; |
123 |
return; |
124 |
} |
125 |
|
126 |
$link_vars = array( |
127 |
'ecdid' => $link_meta[ident], |
128 |
'ecdm' => $link_meta[type], |
129 |
); |
130 |
|
131 |
foreach($hidden_elements as $label => $value) { |
132 |
$link_vars[$label] = $value; |
133 |
} |
134 |
|
135 |
//$str_hidden = join("&", $tmp_array); |
136 |
//$item = html_a($_SERVER["PHP_SELF"] . "?ecdid=" . $ident . "&ecdm=" . $meta . "&" . $str_hidden, "view"); |
137 |
|
138 |
$link_guid = link::store($link_vars); |
139 |
$item = html_a($_SERVER["PHP_SELF"] . "?lbid=" . $link_guid, "view"); |
140 |
|
141 |
return 1; |
142 |
} |
143 |
|
144 |
|
145 |
|
146 |
} |
147 |
|
148 |
|
149 |
?> |