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