/[cvs]/nfo/php/libs/org.netfrag.app/WebExplorer/utils.php
ViewVC logotype

Contents of /nfo/php/libs/org.netfrag.app/WebExplorer/utils.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.9 - (show annotations)
Tue Aug 31 14:22:03 2004 UTC (19 years, 11 months ago) by jonen
Branch: MAIN
Changes since 1.8: +9 -3 lines
 added removing of 'template' hash-value, needed to recognize empty hash-refs

1 <?php
2
3 /**
4 * $Id: utils.php,v 1.8 2003/12/14 01:52:26 jonen Exp $
5 *
6 * $Log: utils.php,v $
7 * Revision 1.8 2003/12/14 01:52:26 jonen
8 * implemented 'SELECT' mode for selecting existing object-refereneces as child-nodes
9 *
10 * Revision 1.7 2003/07/02 12:32:27 jonen
11 * fixed bugs
12 *
13 * Revision 1.6 2003/05/10 18:17:19 jonen
14 * + added 'create/add new' links
15 *
16 * Revision 1.5 2003/04/18 13:38:40 jonen
17 * + added use of url::short function at 'decode_item_expr'
18 *
19 * Revision 1.4 2003/04/16 16:22:01 joko
20 * + introduced url::short
21 *
22 * Revision 1.3 2003/04/09 07:57:15 joko
23 * revamped 'function decode_item_expr'
24 * introduced shortcut 'link::store'
25 *
26 * Revision 1.2 2003/04/09 00:32:42 jonen
27 * some tests according to form rendering at the decode functions
28 *
29 * Revision 1.1 2003/04/06 01:28:04 jonen
30 * + initial commit
31 * + moved decode functions here
32 * + reworked decode functions to use new LinkBuilder class
33 *
34 *
35 *
36 */
37
38 /**
39 * Container holds most helper functions are used at the WebExplorer itself
40 * or at its components, e.g. decode functions used at the GUI modules.
41 *
42 *
43 * @author Sebastian Utz <seut@tunemedia.de>
44 * @package org.netfrag.app
45 * @name WebExplorer::utils
46 *
47 */
48
49
50 class WebExplorer_utils {
51
52
53
54 // TODO: refactor to Data::Lift - subcomponent: handling will get way more easy!
55 function decode_item_array(&$item, $hidden_elements, $options) {
56 //$options = $this->_options['decode_args'];
57 //print "item: " . Dumper($item);
58 //print "options: " . Dumper($options);
59 if( is_array($item) ) {
60 //print "is_array($item)<br>";
61 //$cur_row_index = $this->_datasource->get_cur_data_index();
62 //$parent_guid = $this->_datasource->_data[$cur_row_index]['guid'];
63 // build list for selection form
64 if($options['form']) {
65 foreach($item as $key => $value) {
66 $link_meta = php::untwingle_reference($value, $options);
67 $link_vars = array(
68 'ecdid' => $link_meta[ident],
69 'ecdm' => $link_meta[type]
70 );
71
72 foreach($hidden_elements as $label => $value) {
73 $link_vars[$label] = $value;
74 }
75
76 // V1 - create new LinkBuilder instance and get link GUID by saving vars
77 $link_guid = link::store($link_vars);
78
79 // V2 - more flexible - adjustable link shrinking via some constant defined elsewhere
80 //$link_guid = url::short('', $link_vars);
81
82 $list[$key] = $link_guid;
83 }
84 if(is_array($list) ) {
85 $container = container(
86 //form_open( $item[0], $_SERVER['PHP_SELF'], "POST" ),
87 form_select("lbid", $list),
88 form_submit("submit","view" )
89 );
90 //$container->add(form_close() );
91 $item = $container;
92 }
93 } else {
94 //print "<b>2</b><br/>";
95 $container = container();
96
97 // add default 'add new' link
98 $link_vars_create = array(
99 'ecdid' => $options[label],
100 'ecdm' => $options[parent_guid],
101 'ecdmx' => $options[parent_class],
102 'ecmod' => "create",
103 'ecat' => 'item'
104 );
105 foreach($hidden_elements as $label => $value) {
106 if(!$link_vars_create[$label]) {
107 $link_vars_create[$label] = $value;
108 }
109 }
110 $url_short = url::short($_SERVER["PHP_SELF"], $link_vars_create);
111 $container->add(_HTML_SPACE, html_a( $url_short, $key . " add new"), html_br());
112
113 if($item[tmp]) { unset($item[tmp]); }
114
115 if(count($item) != 0) {
116 foreach($item as $key => $value) {
117 $link_meta = php::untwingle_reference($value, $options);
118 $link_vars = array(
119 'ecdid' => $link_meta[ident],
120 'ecdm' => $link_meta[type],
121 'ecat' => 'item'
122 );
123
124 foreach($hidden_elements as $label => $value) {
125 if(!$link_vars[$label]) {
126 $link_vars[$label] = $value;
127 }
128 //$tmp_array[] = $label . "=" . $value;
129 }
130
131 //$str_hidden = join("&", $tmp_array);
132 //$container->add("->", html_a($_SERVER["PHP_SELF"] . "?ecdid=" . $ident . "&ecdm=" . $meta . "&" . $str_hidden, $key . " view"), html_br());
133
134 // V1 - create new LinkBuilder instance and get link GUID by saving vars
135 //$link_guid = link::store($link_vars);
136 //$container->add("->", html_a($_SERVER["PHP_SELF"] . "?lbid=" . $link_guid, $key . " view"), html_br());
137
138 // V2 - more flexible - adjustable link shrinking via some constant defined elsewhere
139 $url_short = url::short($_SERVER["PHP_SELF"], $link_vars);
140 $container->add( _HTML_SPACE, html_a( $url_short, $key . " - " . " view"), html_br());
141
142 }
143 }
144 $item = $container;
145 }
146 //return $item;
147 return 1;
148 }
149 }
150
151 // decodes serialized string representations of object-references
152 // TODO: refactor to Data::Lift - subcomponent: handling will get way more easy!
153 function decode_item_expr(&$item, $hidden_elements, $options) {
154
155 //return;
156
157 // debug
158 //$options = $this->_options['decode_args'];
159 //print "item(expr): " . Dumper($item);
160 //print "options(expr): " . Dumper($options);
161
162 if($item == "_REF") {
163 $link_vars_create = array(
164 'ecdid' => $options[label],
165 'ecdm' => $options[parent_guid],
166 'ecdmx' => $options[parent_class],
167 'ecmod' => "create",
168 'ecat' => 'item'
169 );
170 foreach($hidden_elements as $label => $value) {
171 if(!$link_vars_create[$label]) {
172 $link_vars_create[$label] = $value;
173 }
174 }
175 $url_short = url::short($_SERVER["PHP_SELF"], $link_vars_create);
176 $item = html_a( $url_short, " create");
177 } elseif($item == "_REF_SELECT") {
178 $link_vars_create = array(
179 'ecdid' => $options[label],
180 'ecdm' => $options[parent_guid],
181 'ecdmx' => $options[parent_class],
182 'ecmod' => "select",
183 'ecat' => 'list'
184 );
185 foreach($hidden_elements as $label => $value) {
186 if(!$link_vars_create[$label]) {
187 $link_vars_create[$label] = $value;
188 }
189 }
190 $url_short = url::short($_SERVER["PHP_SELF"], $link_vars_create);
191 $item = html_a( $url_short, " select");
192 } else {
193 // resolve 'o_{guid}_{classname}' - encoded string
194 $link_meta = php::untwingle_reference($item);
195
196 if (!is_array($link_meta)) {
197 //return $item;
198 //print "NO<br/>";
199 return;
200 }
201
202 $link_vars = array(
203 'ecdid' => $link_meta[ident],
204 'ecdm' => $link_meta[type],
205 'ecat' => 'item'
206 );
207
208 foreach($hidden_elements as $label => $value) {
209 if(!$link_vars[$label]) {
210 $link_vars[$label] = $value;
211 }
212 }
213
214 // V1
215 //$str_hidden = join("&", $tmp_array);
216 //$item = html_a($_SERVER["PHP_SELF"] . "?ecdid=" . $ident . "&ecdm=" . $meta . "&" . $str_hidden, "view");
217
218 // V2
219 //$link_guid = link::store($link_vars);
220 //$item = html_a($_SERVER["PHP_SELF"] . "?lbid=" . $link_guid, "view");
221
222 // V3 - more flexible - adjustable link shrinking via some constant defined elsewhere
223 $url_short = url::short($_SERVER["PHP_SELF"], $link_vars);
224 $item = html_a( $url_short, " view");
225 }
226
227 return 1;
228 }
229
230
231
232 }
233
234
235 ?>

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed