summaryrefslogtreecommitdiff
path: root/development/documents/opie-todo.inc
Unidiff
Diffstat (limited to 'development/documents/opie-todo.inc') (more/less context) (ignore whitespace changes)
-rw-r--r--development/documents/opie-todo.inc262
1 files changed, 262 insertions, 0 deletions
diff --git a/development/documents/opie-todo.inc b/development/documents/opie-todo.inc
new file mode 100644
index 0000000..69b4baa
--- a/dev/null
+++ b/development/documents/opie-todo.inc
@@ -0,0 +1,262 @@
1<?php
2
3class KFeatures
4{
5 var $type = 'kdefeatures';
6 var $parentID = null;
7 var $children = array();
8
9 function setParentID($id)
10 {
11 $this->parentID = $id;
12 }
13 function getParentID()
14 {
15 return $this->parentID;
16 }
17 function addChild(&$child)
18 {
19 $this->children[] = &$child;
20 }
21 function getHtml($target, $status)
22 {
23 $out = '';
24 foreach ($this->children as $child) {
25 $out .= $child->getHtml($target, $status);
26 }
27 return $out;
28 }
29
30}
31
32class KCategory extends KFeatures
33{
34
35 var $type = 'category';
36 var $name = '';
37 var $children = array();
38
39 function KCategory($name)
40 {
41 $this->name = $name;
42 }
43 function getHtml($target, $status)
44 {
45 $out = '';
46 foreach ($this->children as $child) {
47 $temp = $child->getHtml( $target, $status);
48 # don't display empty categories
49 if ($child->type == "category" && strlen($temp))
50 {
51 $out .= sprintf("\t<li>%s\t</li>\n", $temp);
52 } else {
53 $out .= $temp;
54 }
55 }
56 if (strlen($out)) {
57 return sprintf("<h2>%s</h2>\n\t<ul>\n%s\t</ul>\n\n",$this->name,$out);
58 }
59 return '';
60 }
61}
62
63class KFeature extends KFeatures
64{
65
66 var $resp_name = array();
67 var $resp_email = array();
68 var $summary = '';
69 var $status = '';
70 var $target = '';
71 var $type = 'feature';
72
73 function KFeature($status, $target)
74 {
75 $this->status = $status;
76 $this->target = $target;
77 }
78 function getStatus()
79 {
80 return $this->status;
81 }
82 function getTarget()
83 {
84 return $this->target;
85 }
86 function setResponsible($name = null, $email = null)
87 {
88 $this->resp_name[] = $name;
89 $this->resp_email[] = $email;
90 }
91 function getResponsible()
92 {
93 # Nobody responsible?
94 if (count($this->resp_name) == 0) return '';
95
96 $out = '<em>';
97 for ($i = 0; $i < count($this->resp_name); $i++) {
98 if ($i > 0) $out .= ', ';
99 if ($this->resp_name[$i]) {
100 $out .= $this->resp_name[$i];
101 }
102 if ($this->resp_name[$i] && $this->resp_email[$i]) $out .= " ";
103 if ($this->resp_email[$i]) {
104 $out .= '&lt;'.$this->resp_email[$i].'&gt;';
105 }
106 }
107 $out .= '</em>';
108 return $out;
109 }
110 function setSummary($summary)
111 {
112 $this->summary .= $summary.' ';
113 }
114 function getHtml($target, $status){
115 if ($this->target == $target && $this->status == $status) {
116 return sprintf("\t\t<li>%s%s</li>\n",$this->summary,$this->getResponsible());
117 }
118 return '';
119 }
120
121}
122
123function startElement($parser, $name, $attrs) {
124 global $tags;
125 global $parentID;
126
127 global $insummary;
128 global $pcdata;
129 global $curtag;
130
131 switch ($name) {
132 case 'FEATURES':
133 $parentID = 0;
134 $obj = new KFeatures();
135 $tags = array($obj);
136
137 $insummary = false;
138 $pcdata = '';
139 $curtag = '';
140 break;
141 case 'CATEGORY':
142 $obj = new KCategory($attrs['NAME']);
143 $obj->setParentID($parentID);
144 $tags[] = $obj;
145 $currentID = count($tags) - 1;
146 $tags[$parentID]->addChild($tags[$currentID]);
147 $parentID = $currentID;
148
149 break;
150 case 'FEATURE':
151 $obj = new KFeature($attrs['STATUS'], $attrs['TARGET']);
152 $obj->setParentID($parentID);
153 $tags[] = $obj;
154 $currentID = count($tags) - 1;
155 $tags[$parentID]->addChild($tags[$currentID]);
156 $parentID = $currentID;
157 break;
158 case 'RESPONSIBLE':
159 $n = count($tags) - 1;
160 $tags[$n]->setResponsible(@$attrs['NAME'], @$attrs['EMAIL']);
161 break;
162 case 'SUMMARY':
163 $insummary = true;
164 $pcdata = '';
165 break;
166 default:
167 if (!$insummary) {
168 break;
169 }
170 $curtag = strtolower($name);
171 $att = '';
172 foreach ($attrs as $k => $v) {
173 $att .= ' '.strtolower($k).'="'.$v.'"';
174 }
175
176 $pcdata .= '<'.$curtag.$att.'>';
177 break;
178 }
179}
180
181function endElement($parser, $name) {
182 global $parentID;
183 global $tags;
184
185 global $curtag;
186 global $pcdata;
187 global $insummary;
188
189 switch ($name) {
190 case "FEATURE":
191 $n = count($tags) - 1;
192 $parentID = $tags[$n]->getParentID();
193 break;
194 case "CATEGORY":
195 $parentID = $tags[$parentID]->getParentID();
196 break;
197 case "SUMMARY":
198 $n = count($tags) - 1;
199 $tags[$n]->setSummary($pcdata);
200
201 $insummary = false;
202 $pcdata = '';
203 break;
204 default:
205 if ($insummary) {
206 $pcdata .= '</'.$curtag.'>';
207 }
208 break;
209 }
210}
211
212function characterData($parser, $data) {
213 global $htmltag;
214 global $tags;
215
216 global $pcdata;
217 global $curtag;
218 global $insummary;
219
220 if (!$insummary) {
221 return;
222 }
223 $pcdata .= htmlspecialchars($data);
224}
225
226function parse( $file ) {
227
228 $xml_parser = xml_parser_create();
229
230 xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, true);
231 xml_set_element_handler($xml_parser, "startElement", "endElement");
232 xml_set_character_data_handler($xml_parser, "characterData");
233
234 if (!($fp = fopen($file, "r"))) {
235 die("could not open XML input");
236 }
237
238
239 while ($data = fread($fp, 4096)) {
240 if (!xml_parse($xml_parser, $data, feof($fp))) {
241 die(sprintf("XML error: %s at line %d",
242 xml_error_string(xml_get_error_code($xml_parser)),
243 xml_get_current_line_number($xml_parser)));
244 }
245 }
246
247 xml_parser_free($xml_parser);
248}
249
250
251
252function printHtml($target, $status)
253{
254 global $tags;
255 if (!is_array($tags)) {
256 die('You must parse the xml file first with parse("filename.xml");');
257 }
258 print($tags[0]->getHtml($target,$status));
259}
260
261
262?>