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