author | zecke <zecke> | 2003-08-22 18:47:14 (UTC) |
---|---|---|
committer | zecke <zecke> | 2003-08-22 18:47:14 (UTC) |
commit | a8859fac97c0b3255a261221d2b31ebedb56075c (patch) (side-by-side diff) | |
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 @@ +<?php + +/* + This file contains the code to generate the KDE feature list. + + Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> + Copyright (c) 2003 Mario Andres Yepes C <marioy@upb.edu.co> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +class KFeatures +{ + var $type = 'kdefeatures'; + var $parentID = null; + var $children = array(); + + function setParentID($id) + { + $this->parentID = $id; + } + function getParentID() + { + return $this->parentID; + } + function addChild(&$child) + { + $this->children[] = &$child; + } + function getHtml($target, $status) + { + $out = ''; + foreach ($this->children as $child) { + $out .= $child->getHtml($target, $status); + } + return $out; + } + +} + +class KCategory extends KFeatures +{ + + var $type = 'category'; + var $name = ''; + var $children = array(); + + function KCategory($name) + { + $this->name = $name; + } + function getHtml($target, $status) + { + $out = ''; + foreach ($this->children as $child) { + $temp = $child->getHtml( $target, $status); + # don't display empty categories + if ($child->type == "category" && strlen($temp)) + { + $out .= sprintf("\t<li>%s\t</li>\n", $temp); + } else { + $out .= $temp; + } + } + if (strlen($out)) { + return sprintf("<h2>%s</h2>\n\t<ul>\n%s\t</ul>\n\n",$this->name,$out); + } + return ''; + } +} + +class KFeature extends KFeatures +{ + + var $resp_name = array(); + var $resp_email = array(); + var $summary = ''; + var $status = ''; + var $target = ''; + var $type = 'feature'; + + function KFeature($status, $target) + { + $this->status = $status; + $this->target = $target; + } + function getStatus() + { + return $this->status; + } + function getTarget() + { + return $this->target; + } + function setResponsible($name = null, $email = null) + { + $this->resp_name[] = $name; + $this->resp_email[] = $email; + } + function getResponsible() + { + # Nobody responsible? + if (count($this->resp_name) == 0) return ''; + + $out = '<em>'; + for ($i = 0; $i < count($this->resp_name); $i++) { + if ($i > 0) $out .= ', '; + if ($this->resp_name[$i]) { + $out .= $this->resp_name[$i]; + } + if ($this->resp_name[$i] && $this->resp_email[$i]) $out .= " "; + if ($this->resp_email[$i]) { + $out .= '<'.$this->resp_email[$i].'>'; + } + } + $out .= '</em>'; + return $out; + } + function setSummary($summary) + { + $this->summary .= $summary.' '; + } + function getHtml($target, $status){ + if ($this->target == $target && $this->status == $status) { + return sprintf("\t\t<li>%s%s</li>\n",$this->summary,$this->getResponsible()); + } + return ''; + } + +} + +function startElement($parser, $name, $attrs) { + global $tags; + global $parentID; + + global $insummary; + global $pcdata; + global $curtag; + + switch ($name) { + case 'FEATURES': + $parentID = 0; + $obj = new KFeatures(); + $tags = array($obj); + + $insummary = false; + $pcdata = ''; + $curtag = ''; + break; + case 'CATEGORY': + $obj = new KCategory($attrs['NAME']); + $obj->setParentID($parentID); + $tags[] = $obj; + $currentID = count($tags) - 1; + $tags[$parentID]->addChild($tags[$currentID]); + $parentID = $currentID; + + break; + case 'FEATURE': + $obj = new KFeature($attrs['STATUS'], $attrs['TARGET']); + $obj->setParentID($parentID); + $tags[] = $obj; + $currentID = count($tags) - 1; + $tags[$parentID]->addChild($tags[$currentID]); + $parentID = $currentID; + break; + case 'RESPONSIBLE': + $n = count($tags) - 1; + $tags[$n]->setResponsible(@$attrs['NAME'], @$attrs['EMAIL']); + break; + case 'SUMMARY': + $insummary = true; + $pcdata = ''; + break; + default: + if (!$insummary) { + break; + } + $curtag = strtolower($name); + $att = ''; + foreach ($attrs as $k => $v) { + $att .= ' '.strtolower($k).'="'.$v.'"'; + } + + $pcdata .= '<'.$curtag.$att.'>'; + break; + } +} + +function endElement($parser, $name) { + global $parentID; + global $tags; + + global $curtag; + global $pcdata; + global $insummary; + + switch ($name) { + case "FEATURE": + $n = count($tags) - 1; + $parentID = $tags[$n]->getParentID(); + break; + case "CATEGORY": + $parentID = $tags[$parentID]->getParentID(); + break; + case "SUMMARY": + $n = count($tags) - 1; + $tags[$n]->setSummary($pcdata); + + $insummary = false; + $pcdata = ''; + break; + default: + if ($insummary) { + $pcdata .= '</'.$curtag.'>'; + } + break; + } +} + +function characterData($parser, $data) { + global $htmltag; + global $tags; + + global $pcdata; + global $curtag; + global $insummary; + + if (!$insummary) { + return; + } + $pcdata .= htmlspecialchars($data); +} + +function parse( $file ) { + + $xml_parser = xml_parser_create(); + + xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, true); + xml_set_element_handler($xml_parser, "startElement", "endElement"); + xml_set_character_data_handler($xml_parser, "characterData"); + + if (!($fp = fopen($file, "r"))) { + die("could not open XML input"); + } + + + while ($data = fread($fp, 4096)) { + if (!xml_parse($xml_parser, $data, feof($fp))) { + die(sprintf("XML error: %s at line %d", + xml_error_string(xml_get_error_code($xml_parser)), + xml_get_current_line_number($xml_parser))); + } + } + + xml_parser_free($xml_parser); +} + + + +function printHtml($target, $status) +{ + global $tags; + if (!is_array($tags)) { + die('You must parse the xml file first with parse("filename.xml");'); + } + print($tags[0]->getHtml($target,$status)); +} + + +?> |