author | zecke <zecke> | 2003-08-22 18:47:14 (UTC) |
---|---|---|
committer | zecke <zecke> | 2003-08-22 18:47:14 (UTC) |
commit | a8859fac97c0b3255a261221d2b31ebedb56075c (patch) (unidiff) | |
tree | b878e6387d06399839cd5f9b7e1113349364878f /development/feature_plan/kde-features.inc | |
parent | f4ad258aff432a4b6aff84190d053bbd6e87c490 (diff) | |
download | opie-a8859fac97c0b3255a261221d2b31ebedb56075c.zip opie-a8859fac97c0b3255a261221d2b31ebedb56075c.tar.gz opie-a8859fac97c0b3255a261221d2b31ebedb56075c.tar.bz2 |
Add Feature Plan + little desktop add to change the .xml
if you're too lazy to edit it yourself
Diffstat (limited to 'development/feature_plan/kde-features.inc') (more/less context) (ignore whitespace changes)
-rw-r--r-- | development/feature_plan/kde-features.inc | 283 |
1 files changed, 283 insertions, 0 deletions
diff --git a/development/feature_plan/kde-features.inc b/development/feature_plan/kde-features.inc new file mode 100644 index 0000000..a1d9b51 --- a/dev/null +++ b/development/feature_plan/kde-features.inc | |||
@@ -0,0 +1,283 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | This file contains the code to generate the KDE feature list. | ||
5 | |||
6 | Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> | ||
7 | Copyright (c) 2003 Mario Andres Yepes C <marioy@upb.edu.co> | ||
8 | |||
9 | This program is free software; you can redistribute it and/or modify | ||
10 | it under the terms of the GNU General Public License as published by | ||
11 | the Free Software Foundation; either version 2 of the License, or | ||
12 | (at your option) any later version. | ||
13 | |||
14 | This program is distributed in the hope that it will be useful, | ||
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | GNU General Public License for more details. | ||
18 | |||
19 | You should have received a copy of the GNU General Public License | ||
20 | along with this program; if not, write to the Free Software | ||
21 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
22 | */ | ||
23 | |||
24 | class KFeatures | ||
25 | { | ||
26 | var $type = 'kdefeatures'; | ||
27 | var $parentID = null; | ||
28 | var $children = array(); | ||
29 | |||
30 | function setParentID($id) | ||
31 | { | ||
32 | $this->parentID = $id; | ||
33 | } | ||
34 | function getParentID() | ||
35 | { | ||
36 | return $this->parentID; | ||
37 | } | ||
38 | function addChild(&$child) | ||
39 | { | ||
40 | $this->children[] = &$child; | ||
41 | } | ||
42 | function getHtml($target, $status) | ||
43 | { | ||
44 | $out = ''; | ||
45 | foreach ($this->children as $child) { | ||
46 | $out .= $child->getHtml($target, $status); | ||
47 | } | ||
48 | return $out; | ||
49 | } | ||
50 | |||
51 | } | ||
52 | |||
53 | class KCategory extends KFeatures | ||
54 | { | ||
55 | |||
56 | var $type = 'category'; | ||
57 | var $name = ''; | ||
58 | var $children = array(); | ||
59 | |||
60 | function KCategory($name) | ||
61 | { | ||
62 | $this->name = $name; | ||
63 | } | ||
64 | function getHtml($target, $status) | ||
65 | { | ||
66 | $out = ''; | ||
67 | foreach ($this->children as $child) { | ||
68 | $temp = $child->getHtml( $target, $status); | ||
69 | # don't display empty categories | ||
70 | if ($child->type == "category" && strlen($temp)) | ||
71 | { | ||
72 | $out .= sprintf("\t<li>%s\t</li>\n", $temp); | ||
73 | } else { | ||
74 | $out .= $temp; | ||
75 | } | ||
76 | } | ||
77 | if (strlen($out)) { | ||
78 | return sprintf("<h2>%s</h2>\n\t<ul>\n%s\t</ul>\n\n",$this->name,$out); | ||
79 | } | ||
80 | return ''; | ||
81 | } | ||
82 | } | ||
83 | |||
84 | class KFeature extends KFeatures | ||
85 | { | ||
86 | |||
87 | var $resp_name = array(); | ||
88 | var $resp_email = array(); | ||
89 | var $summary = ''; | ||
90 | var $status = ''; | ||
91 | var $target = ''; | ||
92 | var $type = 'feature'; | ||
93 | |||
94 | function KFeature($status, $target) | ||
95 | { | ||
96 | $this->status = $status; | ||
97 | $this->target = $target; | ||
98 | } | ||
99 | function getStatus() | ||
100 | { | ||
101 | return $this->status; | ||
102 | } | ||
103 | function getTarget() | ||
104 | { | ||
105 | return $this->target; | ||
106 | } | ||
107 | function setResponsible($name = null, $email = null) | ||
108 | { | ||
109 | $this->resp_name[] = $name; | ||
110 | $this->resp_email[] = $email; | ||
111 | } | ||
112 | function getResponsible() | ||
113 | { | ||
114 | # Nobody responsible? | ||
115 | if (count($this->resp_name) == 0) return ''; | ||
116 | |||
117 | $out = '<em>'; | ||
118 | for ($i = 0; $i < count($this->resp_name); $i++) { | ||
119 | if ($i > 0) $out .= ', '; | ||
120 | if ($this->resp_name[$i]) { | ||
121 | $out .= $this->resp_name[$i]; | ||
122 | } | ||
123 | if ($this->resp_name[$i] && $this->resp_email[$i]) $out .= " "; | ||
124 | if ($this->resp_email[$i]) { | ||
125 | $out .= '<'.$this->resp_email[$i].'>'; | ||
126 | } | ||
127 | } | ||
128 | $out .= '</em>'; | ||
129 | return $out; | ||
130 | } | ||
131 | function setSummary($summary) | ||
132 | { | ||
133 | $this->summary .= $summary.' '; | ||
134 | } | ||
135 | function getHtml($target, $status){ | ||
136 | if ($this->target == $target && $this->status == $status) { | ||
137 | return sprintf("\t\t<li>%s%s</li>\n",$this->summary,$this->getResponsible()); | ||
138 | } | ||
139 | return ''; | ||
140 | } | ||
141 | |||
142 | } | ||
143 | |||
144 | function startElement($parser, $name, $attrs) { | ||
145 | global $tags; | ||
146 | global $parentID; | ||
147 | |||
148 | global $insummary; | ||
149 | global $pcdata; | ||
150 | global $curtag; | ||
151 | |||
152 | switch ($name) { | ||
153 | case 'FEATURES': | ||
154 | $parentID = 0; | ||
155 | $obj = new KFeatures(); | ||
156 | $tags = array($obj); | ||
157 | |||
158 | $insummary = false; | ||
159 | $pcdata = ''; | ||
160 | $curtag = ''; | ||
161 | break; | ||
162 | case 'CATEGORY': | ||
163 | $obj = new KCategory($attrs['NAME']); | ||
164 | $obj->setParentID($parentID); | ||
165 | $tags[] = $obj; | ||
166 | $currentID = count($tags) - 1; | ||
167 | $tags[$parentID]->addChild($tags[$currentID]); | ||
168 | $parentID = $currentID; | ||
169 | |||
170 | break; | ||
171 | case 'FEATURE': | ||
172 | $obj = new KFeature($attrs['STATUS'], $attrs['TARGET']); | ||
173 | $obj->setParentID($parentID); | ||
174 | $tags[] = $obj; | ||
175 | $currentID = count($tags) - 1; | ||
176 | $tags[$parentID]->addChild($tags[$currentID]); | ||
177 | $parentID = $currentID; | ||
178 | break; | ||
179 | case 'RESPONSIBLE': | ||
180 | $n = count($tags) - 1; | ||
181 | $tags[$n]->setResponsible(@$attrs['NAME'], @$attrs['EMAIL']); | ||
182 | break; | ||
183 | case 'SUMMARY': | ||
184 | $insummary = true; | ||
185 | $pcdata = ''; | ||
186 | break; | ||
187 | default: | ||
188 | if (!$insummary) { | ||
189 | break; | ||
190 | } | ||
191 | $curtag = strtolower($name); | ||
192 | $att = ''; | ||
193 | foreach ($attrs as $k => $v) { | ||
194 | $att .= ' '.strtolower($k).'="'.$v.'"'; | ||
195 | } | ||
196 | |||
197 | $pcdata .= '<'.$curtag.$att.'>'; | ||
198 | break; | ||
199 | } | ||
200 | } | ||
201 | |||
202 | function endElement($parser, $name) { | ||
203 | global $parentID; | ||
204 | global $tags; | ||
205 | |||
206 | global $curtag; | ||
207 | global $pcdata; | ||
208 | global $insummary; | ||
209 | |||
210 | switch ($name) { | ||
211 | case "FEATURE": | ||
212 | $n = count($tags) - 1; | ||
213 | $parentID = $tags[$n]->getParentID(); | ||
214 | break; | ||
215 | case "CATEGORY": | ||
216 | $parentID = $tags[$parentID]->getParentID(); | ||
217 | break; | ||
218 | case "SUMMARY": | ||
219 | $n = count($tags) - 1; | ||
220 | $tags[$n]->setSummary($pcdata); | ||
221 | |||
222 | $insummary = false; | ||
223 | $pcdata = ''; | ||
224 | break; | ||
225 | default: | ||
226 | if ($insummary) { | ||
227 | $pcdata .= '</'.$curtag.'>'; | ||
228 | } | ||
229 | break; | ||
230 | } | ||
231 | } | ||
232 | |||
233 | function characterData($parser, $data) { | ||
234 | global $htmltag; | ||
235 | global $tags; | ||
236 | |||
237 | global $pcdata; | ||
238 | global $curtag; | ||
239 | global $insummary; | ||
240 | |||
241 | if (!$insummary) { | ||
242 | return; | ||
243 | } | ||
244 | $pcdata .= htmlspecialchars($data); | ||
245 | } | ||
246 | |||
247 | function parse( $file ) { | ||
248 | |||
249 | $xml_parser = xml_parser_create(); | ||
250 | |||
251 | xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, true); | ||
252 | xml_set_element_handler($xml_parser, "startElement", "endElement"); | ||
253 | xml_set_character_data_handler($xml_parser, "characterData"); | ||
254 | |||
255 | if (!($fp = fopen($file, "r"))) { | ||
256 | die("could not open XML input"); | ||
257 | } | ||
258 | |||
259 | |||
260 | while ($data = fread($fp, 4096)) { | ||
261 | if (!xml_parse($xml_parser, $data, feof($fp))) { | ||
262 | die(sprintf("XML error: %s at line %d", | ||
263 | xml_error_string(xml_get_error_code($xml_parser)), | ||
264 | xml_get_current_line_number($xml_parser))); | ||
265 | } | ||
266 | } | ||
267 | |||
268 | xml_parser_free($xml_parser); | ||
269 | } | ||
270 | |||
271 | |||
272 | |||
273 | function printHtml($target, $status) | ||
274 | { | ||
275 | global $tags; | ||
276 | if (!is_array($tags)) { | ||
277 | die('You must parse the xml file first with parse("filename.xml");'); | ||
278 | } | ||
279 | print($tags[0]->getHtml($target,$status)); | ||
280 | } | ||
281 | |||
282 | |||
283 | ?> | ||