/[cvs]/nfo/php/libs/org.netfrag.elib/xml/wddx/wddx_datastructure2recordset.library
ViewVC logotype

Contents of /nfo/php/libs/org.netfrag.elib/xml/wddx/wddx_datastructure2recordset.library

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (show annotations) (vendor branch)
Wed Jan 23 17:40:37 2002 UTC (22 years, 6 months ago) by cvsjoko
Branch: nfo, MAIN
CVS Tags: v003, HEAD
Changes since 1.1: +0 -0 lines
initial

1 <?
2
3 // -------------------------------------------------------------------------------------------
4 // build a "TreeRecordset"
5 function getWddxTreeRecordsetFromDataStructure($datastructure_name, $datastructure_displaytype) {
6
7 global $site;
8
9 // include extended wddx-library for php ( (c) pm, amo. )
10 $path_component = $site->getAttribute('path_elib') . 'progressive/common/hidden/inc/pm-dwdfl_wddx.php.inc';
11 //include($path_component);
12
13 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
14 // create a new wddx-recordset-object ...
15
16 // ... (from "pm-dwdfl_wddx.php.inc")
17 $rsTree = new WddxRecordset;
18
19 // ... and add columns to it (these are exactly the values joust uses for building its outliner (treeview))
20 $rsTree->addColumn("itemid");
21 $rsTree->addColumn("parent");
22 $rsTree->addColumn("type");
23 $rsTree->addColumn("label");
24 $rsTree->addColumn("helptext");
25 $rsTree->addColumn("url");
26
27
28 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
29 // fill wddx-recordset
30
31 // 1. fill with actual data
32 // start fetching data from db starting with "parent-id = -1" (this means the first nodelist below root),
33 // this function will continue retrieving all child-nodes recursively.
34 // we pass "$rsTree" by ref here, so - when finished - we'll end up with a wddx-recordset-object filled with our data
35 getWddxTreeRecordset_appendNodeList($datastructure_name, $datastructure_displaytype, &$rsTree, -1);
36
37 // 2. fill with dummy data (for testing purposes)
38 /*
39 // Add some rows of actual data
40 $rsTree->addRows(2);
41
42 $rsTree->setField(0, "itemid", 91829);
43 $rsTree->setField(0, "parent", -1);
44 $rsTree->setField(0, "type", "Folder");
45 $rsTree->setField(0, "label", "myFirstLabel");
46 $rsTree->setField(0, "helptext", "some help");
47
48 $rsTree->setField(1, "itemid", 18298);
49 $rsTree->setField(1, "parent", 91829);
50 $rsTree->setField(1, "type", "Document");
51 $rsTree->setField(1, "label", "mySecondLabel");
52 $rsTree->setField(1, "url",
53 // s4ycfg_get_sidlink(s4ycfg_getPageURL_ByKey('prodlist'), 'S4Ymethod=4&S4Ypgid=18298')
54 '?vp=document.list'
55 );
56 */
57
58
59 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
60 // serialize wddx-recordset and create wddx-packet
61
62 // create a new wddx-serializer-object
63 $wddxSerializer = new WddxSerializer();
64
65 // misunderstanding, be careful! (imho i think, that this is wrong!?)
66 // $wddxPacket = $wddxSerializer->serialize($rsTree);
67
68 // that should be correct:
69 // serialize Recordset
70 $bool_ok = $rsTree->wddxSerialize($wddxSerializer);
71
72 // add WDDX-Envelope
73 $wddxPacket = $wddxSerializer->packEnvelope();
74
75 // print $wddxPacket;
76
77
78 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
79 // return serialized packet
80 return $wddxPacket;
81
82 }
83
84
85 // -------------------------------------------------------------------------------------------
86 function getWddxTreeRecordset_appendNodeList($datastructure_name, $datastructure_displaytype, &$rsTree, $parentid) {
87
88 global $tracking, $rowcount;
89
90 //print "dsname: $datastructure_name<br>";
91
92 $objecttype = getObjectTypeByDataStructureName($datastructure_name);
93 $datastructure_Collection =& $tracking->ds->getDataCollection($objecttype);
94
95 if ($datastructure_displaytype == 'tree') {
96 $filter =& $datastructure_Collection->addFilter('ParentId = :vParentId');
97 $filter->set('vParentId', $parentid);
98 }
99
100 //$DataStructure_ExternalCategory_List->addSortOrder('Id', 'asc');
101 //$DataStructure_ExternalCategory_List->addSortOrder('ParentId', 'asc');
102 $datastructure_Collection->load();
103 $resultcount = $datastructure_Collection->getResultCount();
104
105 if ($resultcount > 0) {
106
107 // if we shall render the first nodelist below root ("$parentid = -1"), we first create a root-node at "row = 0"
108 if ($parentid == -1) {
109
110 $rowcount = 0;
111
112 $rsTree->addRows(1);
113
114 $rsTree->setField($rowcount, "itemid", "999");
115 $rsTree->setField($rowcount, "parent", "-1");
116 $rsTree->setField($rowcount, "type", "Folder");
117 //$rsTree->setField($rowcount, "label", "&nbsp;&nbsp;<font size=1><- hier &ouml;ffnen</font>");
118 $rsTree->setField($rowcount, "label", "");
119 $rsTree->setField($rowcount, "helptext", "");
120 $rsTree->setField($rowcount, "url", "");
121
122 $rowcount++;
123 }
124
125 // iterate through list of nodes and store them into wddx-recordset
126 // TODO: handle this abstract!
127 while ( $item_aec =& $datastructure_Collection->next() ) {
128
129 // add one row
130 $rsTree->addRows(1);
131
132 // set (field-)values
133
134 $itemid = $item_aec->get('Id');
135 $rsTree->setField($rowcount, "itemid", $itemid);
136
137 $parentid = $item_aec->get('ParentId');
138 if ($parentid == -1) { $parentid = "999"; }
139 $rsTree->setField($rowcount, "parent", $parentid);
140
141 // $rsTree->setField($rowcount, "type", "Folder");
142 // $rsTree->setField($rowcount, "type", "Document");
143
144 $label = $item_aec->get('Name');
145 $label = str_replace ('"', '&quot;', $label);
146 $rsTree->setField($rowcount, "label", $label);
147
148 $tmp_key = $item_aec->get('Description');
149 if ($tmp_key) {
150 $rsTree->setField($rowcount, "helptext", $tmp_key);
151 }
152
153 //$vp = $tracking->getStatusAttribute('virtualpage');
154 $rsTree->setField($rowcount, "url", "?ni=$itemid");
155
156 // increase row-counter
157 $rowcount++;
158
159 // call us recursively to retrieve all child-nodes
160 if ($datastructure_displaytype == 'tree') {
161 getWddxTreeRecordset_appendNodeList($datastructure_name, $datastructure_displaytype, &$rsTree, $itemid);
162 }
163
164 }
165
166 }
167
168
169 }
170
171 ?>

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