/[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.10 - (show annotations)
Thu Aug 11 14:12:24 2005 UTC (18 years, 11 months ago) by jonen
Branch: MAIN
CVS Tags: HEAD
Changes since 1.9: +23 -1 lines
+ bugfix
+ added function to get allowed writeable entries for a TerminalOwner

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

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