/[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.4 - (show annotations)
Wed Apr 16 16:22:01 2003 UTC (21 years, 3 months ago) by joko
Branch: MAIN
Changes since 1.3: +16 -5 lines
+ introduced url::short

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

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