/[cvs]/nfo/php/libs/com.newsblob.phphtmllib/widgets/data_list/GenericGUIDataList.inc
ViewVC logotype

Contents of /nfo/php/libs/com.newsblob.phphtmllib/widgets/data_list/GenericGUIDataList.inc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations)
Thu Mar 27 00:59:27 2003 UTC (21 years, 5 months ago) by jonen
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +4 -1 lines
FILE REMOVED
removed, moved to org.netfrag.patches/phphtmllib

1 <?
2 /*
3 ## -----------------------------------------------------------------------------
4 ## $Id: GenericGUIDataList.inc,v 1.1 2003/03/20 04:17:28 jonen Exp $
5 ## -----------------------------------------------------------------------------
6 ## $Log: GenericGUIDataList.inc,v $
7 ## Revision 1.1 2003/03/20 04:17:28 jonen
8 ## + initial commit
9 ##
10 ## Revision 1.2 2003/03/02 04:32:22 cvsmax
11 ## + add decode_item functions
12 ##
13 ## Revision 1.1 2003/03/01 22:57:40 cvsmax
14 ## + inital commit
15 ##
16 ##
17 ## -----------------------------------------------------------------------------
18 */
19
20 /**
21 * Need to make sure we have the DefaultGUIDataList object
22 */
23 require_once($phphtmllib."/widgets/data_list/DefaultGUIDataList.inc");
24
25
26 class GenericGUIDataList extends DefaultGUIDataList {
27
28 /**
29 * Args needed for object list.
30 * Current use:
31 * - use some bits to create locator metadata (see below)
32 * - use all options to propagate to an AdapterProxy (here: GenericDataSource)
33 * as a query to receive a list of objects as response to a rpc-call.
34 * Todo: glossary: ban "*list* of objects" - it's an object *set* !!! (see CPAN's Set::Object)
35 *
36 */
37 var $_options = NULL;
38
39 /**
40 * The constructor is used to pass in some additional
41 * metadata informations as "options".
42 * The "locator metadata hash" isn't passed in here
43 * any more. Handling this one occours one level deeper
44 * inside the "GenericDataSource" Proxy.
45 *
46 * It's still possible to set locator metadata directly by
47 * using the optional key 'locator' inside your options hash.
48 * This can be either a DataSource::Locator instance or a plain
49 * hash. However - it gets merged to the master locator
50 * created by GenericDataSource using 'array_join_merge'.
51 *
52 * @param old: LocatorMetadataHash array - layout: array( type => '', metadata => '', dsn => '' )
53 * @param old: Query array - layout: array( type => '', metadata => '', dsn => '' )
54 *
55 * @param new: options array - layout: array( datasource_type => '', [locator => array()] )
56 *
57 *
58 */
59 function GenericGUIDataList($title, $width = "100%", $default_orderby='', $default_reverseorder=FALSE, $options = array()) {
60 if ($options) { $this->_options = $options; }
61 $parent = get_parent_class($this);
62 $this->$parent($title, $width = "100%", $default_orderby='', $default_reverseorder=FALSE);
63 }
64
65 function get_data_source( ) {
66
67 // finally: create phpHtmlLib source handle (XyzDataListSource)
68
69 // V1:
70 //$source = new GenericDataSource($this->_locator, $this->_options);
71 //$this->set_data_source( &$source );
72
73 /*
74 // V2:
75 loadModule("DataSource::GenericDataSource");
76 $source = new DataSource_GenericDataSource($this->_locator, $this->_options);
77 $this->set_data_source( &$source );
78 */
79
80 // V3:
81 /*
82 $proxy = php::mkComponent('DataSource::GenericDataSource', $this->_locator, $this->_options);
83 $source = &$proxy;
84 $this->set_data_source( &$source );
85 */
86
87 // V4:
88 /*
89 $proxy = php::mkComponent('DataSource::GenericDataSource', array( proxy => '', adapter => ''), $this->_options);
90 $source = &$proxy;
91 $this->set_data_source( &$source );
92 */
93
94 // V5:
95 //print "options: " . Dumper($this->_options);
96
97 $initial_locator = php::mkComponent( 'DataSource::Locator', array( adapter_type => 'phpHtmlLib' ) );
98 //print "1st locator: " . Dumper($initial_locator);
99
100 // OLD
101 //$proxy = php::mkComponent('DataSource::Generic', $initial_locator, $this->_options);
102
103 //print "Test Query:";
104 //print Dumper($this->_options['query']);
105 $proxy = php::mkComponent('DataSource::Generic', $initial_locator, $this->_options['data_locator_meta']);
106
107 // debug
108 //print "Proxy: " . Dumper($proxy);
109
110 // V1:
111 //$source = &$proxy;
112
113 // V2:
114 //$source->make_adapter_transparent();
115
116 // V3:
117 $source = $proxy->get_adapter();
118
119 // V4:
120 //$source = $this->_datasource;
121
122 //print "objectlist-source: " . Dumper($source);
123 //exit;
124
125 $this->set_data_source( &$source );
126
127 }
128
129 function user_setup() {
130
131 //return;
132
133 $source = $this->_datasource;
134 //if (!$source) { return; }
135
136 //print Dumper($source);
137 $headers = $source->get_header();
138 //print Dumper($headers);
139
140 $this->set_title( $this->get_title() . ' - ' . $source->get_total_rows() . ' Eintrรคge' );
141
142 foreach($headers as $val) {
143 $this->add_header_item($val, "150", $val, SORTABLE, SEARCHABLE);
144 }
145
146 /*
147 $this->add_header_item("Uid", "200", "uid", SORTABLE, SEARCHABLE);
148 $this->add_header_item("Name", "200", "lastName", SORTABLE, SEARCHABLE, "center");
149 */
150 }
151
152
153 /**
154 * This function ensures that the data we place
155 * in a column is aligned according to what the
156 * user wants.
157 *
158 * @param mixed - $obj - the data for the td.
159 * @param string - $col_name - the name of the column header
160 * for this row to render.
161 * @param int - $odd_row - tells us if this cell lives in
162 * an odd # row (for alternating row colors)
163 * @param int - the column # we are working on.
164 * @return TDtag object
165 */
166 function wrap_column_item($obj, $col_name) {
167
168 //make sure its set to something.
169 if ($obj == '') {
170 $obj = "&nbsp;";
171 }
172 // if item is match by expression we will replace it with an link object
173 elseif($this->_options['decode']) {
174 if($this->decode_item_expr($obj)) {
175 $obj = $this->decode_item_expr($obj);
176 }
177 // if item is an Array we will replace it with an selection form object
178 elseif($this->decode_item_array($obj) ) {
179 $obj = $this->decode_item_array($obj);
180 }
181 }
182
183 //make sure we don't put a right border on the last
184 //column we are working on.
185 //$style = "padding-left: 3px;padding-right:3px;border-top: 1px solid #dddddd;";
186
187
188 if ($this->_columns[$col_name]["data_name"] == $this->orderby()) {
189 $style = "background-color: #f4f4f4;";
190 } else {
191 $style = "background-color: #ffffff;";
192 }
193
194 $align = $this->_columns[$col_name]["align"];
195 $td = new TDtag(array("align" => $align,
196 "style" => $style,
197 "class" => "datalist_data_cell"));
198
199 if (is_object($obj) && $obj->_tag == "td") {
200 return $obj;
201 } else {
202 $td->add( $obj );
203 }
204 return $td;
205 }
206
207 function decode_item_array($item) {
208 $options = $this->_options['decode_args'];
209 if( is_array($item) ) {
210 //$cur_row_index = $this->_datasource->get_cur_data_index();
211 //$parent_guid = $this->_datasource->_data[$cur_row_index]['guid'];
212 // build list for selection form
213 if($options['form']) {
214 foreach($item as $key => $value) {
215 $tmp = split($options['seperator'], $value);
216 $ident = $tmp['1'];
217 $meta = $tmp['2'];
218 $list[$key] = $ident;
219 }
220 if(is_array($list) ) {
221 $container = container(
222 form_open( $item[0], $_SERVER["PHP_SELF"], "POST" ),
223 form_open("ecdm", $meta),
224 form_select("ecdid", $list),
225 form_submit("submit","view" ),
226 form_close()
227 );
228 foreach($this->_hidden_items as $label => $value) {
229 $container->add(form_hidden($label, $value));
230 }
231 $item = $container;
232 }
233 } else {
234 $container = container();
235 foreach($item as $key => $value) {
236 $tmp = split($options['seperator'], $value);
237 $ident = $tmp['1'];
238 $meta = $tmp['2'];
239 foreach($this->_hidden_items as $label => $value) {
240 $tmp_array[] = $label . "=" . $value;
241 }
242 $str_hidden = join("&", $tmp_array);
243 $container->add("->", html_a($_SERVER["PHP_SELF"] . "?ecdid=" . $ident . "&ecdm=" . $meta . $str_hidden, $key . " view"), html_br());
244 }
245 $item = $container;
246 }
247 return $item;
248 }
249 }
250
251 function decode_item_expr($item) {
252 $options = $this->_options['decode_args'];
253 if(substr($item, 0, 2) == "o_") {
254 $tmp = split($options['seperator'], $item);
255 $ident = $tmp['1'];
256 $meta = $tmp['2'];
257 foreach($this->_hidden_items as $label => $value) {
258 $tmp_array[] = $label . "=" . $value;
259 }
260 $str_hidden = join("&", $tmp_array);
261 $item = html_a($_SERVER["PHP_SELF"] . "?ecdid=" . $guid . "&ecdm=" . $meta . $str_hidden, "view");
262 return $item;
263 }
264 }
265
266 }
267 ?>

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