/[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.8 - (show annotations)
Sun Dec 14 01:52:26 2003 UTC (20 years, 8 months ago) by jonen
Branch: MAIN
Changes since 1.7: +19 -1 lines
implemented 'SELECT' mode for selecting existing object-refereneces as child-nodes

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

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