qsos-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qsos-commits] qsos/apps/phpviewer collapse.png expand.png ind...


From: Raphaël Semeteys
Subject: [Qsos-commits] qsos/apps/phpviewer collapse.png expand.png ind...
Date: Tue, 31 Oct 2006 15:56:05 +0000

CVSROOT:        /sources/qsos
Module name:    qsos
Changes by:     Raphaël Semeteys <rsemeteys>   06/10/31 15:56:05

Added files:
        apps/phpviewer : collapse.png expand.png index.php phpviewer.css 
                         QSOSDocument.php radar.php radar_single.php 
                         show.php show_single.php 

Log message:
        First commit

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qsos/apps/phpviewer/collapse.png?cvsroot=qsos&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/qsos/apps/phpviewer/expand.png?cvsroot=qsos&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/qsos/apps/phpviewer/index.php?cvsroot=qsos&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/qsos/apps/phpviewer/phpviewer.css?cvsroot=qsos&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/qsos/apps/phpviewer/QSOSDocument.php?cvsroot=qsos&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/qsos/apps/phpviewer/radar.php?cvsroot=qsos&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/qsos/apps/phpviewer/radar_single.php?cvsroot=qsos&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/qsos/apps/phpviewer/show.php?cvsroot=qsos&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/qsos/apps/phpviewer/show_single.php?cvsroot=qsos&rev=1.1

Patches:
Index: collapse.png
===================================================================
RCS file: collapse.png
diff -N collapse.png
Binary files /dev/null and /tmp/cvs18ZBVg differ

Index: expand.png
===================================================================
RCS file: expand.png
diff -N expand.png
Binary files /dev/null and /tmp/cvsKFrIIh differ

Index: index.php
===================================================================
RCS file: index.php
diff -N index.php
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ index.php   31 Oct 2006 15:56:05 -0000      1.1
@@ -0,0 +1,79 @@
+<html>
+<head>
+<LINK REL=StyleSheet HREF="phpviewer.css" TYPE="text/css"/>
+</head>
+
+<body>
+<?php
+
+$family = $_GET['f'];
+$delim = "/";
+$sheet = "sheet";
+
+function getFamilies($dir) {
+       global $delim;
+       $families = array();
+       if (is_dir($dir)) {
+               if ($dh = opendir($dir)) {
+                       while (($file = readdir($dh)) !== false) {
+                               if (is_dir($dir.$delim.$file) && ($file != 
'CVS') && ($file != '.') && ($file != '..') && ($file != 'include')) {
+                                       array_push($families, $file);
+                               }
+                       }
+                       closedir($dh);
+               }
+       }
+       return (isset($families) ? $families : false);
+}
+
+function retrieveTree($path)  {
+       global $delim;
+       
+       if (address@hidden($path)) {
+       while (($element=readdir($dir))!== false) {
+               if (is_dir($path.$delim.$element) && $element!= "." && 
$element!= ".." && $element!= "CVS" && $element!= "template") {
+                       $array[$element] = retrieveTree($path.$delim.$element);
+               } elseif (substr($element, -5) == ".qsos") {
+                       $array[] = $element;
+               }
+       }
+       closedir($dir);
+       }
+       return (isset($array) ? $array : false);
+}
+
+if (!isset($family)) {
+       $families = getFamilies($sheet);
+       echo "<div>Select a software family:<br/>\n";
+       echo "<table style='border-collapse: collapse;'>\n";
+       echo "<tr class='title'><td>Software families</td></tr>\n";
+       for ($i=0; $i<count($families); $i++) {
+               echo "<tr class='level1'><td><a 
href='index.php?f=$families[$i]'>$families[$i]</a></td></tr>\n";
+       }
+       echo "</table></div>\n";
+} else {
+       $tree= retrieveTree($sheet.$delim.$family); 
+       $keys = array_keys($tree);
+       
+       echo "<div>Select a software:<br/>\n";
+       echo "<form action='show.php'>\n";
+       echo "<table style='border-collapse: collapse;'>\n";
+       echo "<tr class='title'><td colspan='2'>$family</td></tr>\n";
+       for ($i=0; $i<count($keys); $i++) {
+               if (!is_int($keys[$i])) {
+                       echo "<tr class='level0'><td 
colspan='2'>$keys[$i]</td></tr>\n";
+                       for ($j=0; $j<count($tree[$keys[$i]]); $j++) {
+                               $file = $tree[$keys[$i]][$j];
+                               $link = 
$sheet.$delim.$family.$delim.$keys[$i].$delim.$file;
+                               echo "<tr class='level1'><td><a 
href='show_single?f=$link'>$file</a></td>\n";
+                               echo "<td><input type='checkbox' name='files[]' 
value='$link'></td></tr>\n";
+                       }
+               }
+       }
+       echo "</table>";
+       echo "<input type='submit' value='Compare'></form></div>\n";
+}
+
+?>
+</body>
+</html>
\ No newline at end of file

Index: phpviewer.css
===================================================================
RCS file: phpviewer.css
diff -N phpviewer.css
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ phpviewer.css       31 Oct 2006 15:56:05 -0000      1.1
@@ -0,0 +1,50 @@
+span.collapsed {
+  cursor: pointer;
+  background-image: url("expand.png");
+  background-repeat: no-repeat;
+  background-position: center left;
+  padding-left: 12px;
+}
+
+span.expanded {
+  cursor: pointer;
+  background-image: url("collapse.png");
+  background-repeat: no-repeat;
+  background-position: center left;
+  padding-left: 12px;
+}
+
+tr.title {
+  background-color: black;
+  font-weight: bold;
+  color: white;
+}
+
+tr.level0 {
+  background-color: #0047ff;
+  font-weight: bold;
+}
+
+tr.level1 {
+  background-color: #0099ff;
+}
+
+tr.level2 {
+  background-color: #99ccff;
+}
+
+tr.level3 {
+  background-color: #bfdbf8;
+}
+
+tr.level4 {
+  background-color: #e7ecf2;
+}
+
+td.score {
+  text-align: center;
+}
+
+A:link    {  text-decoration: none; color: #0b1c51}
+A:visited {  text-decoration: none; color: #0b1c51}
+A:hover   {  text-decoration: underline; color: #0b1c51}
\ No newline at end of file

Index: QSOSDocument.php
===================================================================
RCS file: QSOSDocument.php
diff -N QSOSDocument.php
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ QSOSDocument.php    31 Oct 2006 15:56:05 -0000      1.1
@@ -0,0 +1,174 @@
+<?php
+/*
+**  Copyright (C) 2006 Atos Origin 
+**
+**  Author: Rapha� Semeteys <address@hidden>
+**
+**  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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  
USA
+**
+**
+** QSOSDocument.php: PHP classes to access and manipulate QSOS documents
+**
+*/
+
+//Class representing a QSOS criterion (<section/> or <element/>)
+class QSOSCriterion {
+       var $name;
+       var $title;
+       var $children;
+       var $score;
+}
+
+//Class representing a QSOS document
+class QSOSDocument {
+       var $doc;
+       var $xpath;
+
+    //$file: filename of the QSOS document to load
+       function __construct($file) {
+               if (file_exists($file)) {
+                       $this->doc = new DOMDocument();
+                       $this->doc->load($file);
+                       $this->xpath = new DOMXPath($this->doc);
+               } else {
+                       return 'Failed to open file '.$file;
+               }
+       }
+
+    //$name: name of the tested element
+    //Returns: true if element has children elements
+       public function hassubelements($name) {
+               $query = "//address@hidden'".$name."']/element";
+               $nb = $this->xpath->query($query);
+               return $nb->length;
+               /*if ($nb->length != 0) {
+                       return true;
+               } else {
+                       return false;
+               }*/
+       }
+
+    //$element: name of the XML header tag
+    //Returns: the value of a header tag (like appname, release, ...)
+       public function getkey($element) {
+               $nodes = $this->xpath->query("//".$element);
+               if ($nodes->length != 0) {
+                       return $nodes->item(0)->nodeValue;
+               } else {
+                       return "";
+               }
+       }
+       
+    //$element: name of the element
+    //$subelement: name of the XML tag
+    //Returns: value of the XML tag included in the element
+       public function getgeneric($element, $subelement) {
+               $nodes = 
$this->xpath->query("//address@hidden'".$element."']/".$subelement);
+               if ($nodes->length != 0) {
+                       return $nodes->item(0)->nodeValue;
+               } else {
+                       return "";
+               }
+       }
+
+    //$element: name of the element
+    //Returns: value of the <score/> tag included in the element
+       public function getkeyscore($element) {
+               $nodes = 
$this->xpath->query("//address@hidden'".$element."']/score");
+               if ($nodes->length != 0) {
+                       return $nodes->item(0)->nodeValue;
+               } else {
+                       return -1;
+               }
+       }
+
+    //$element: name of the element (<section/> or <element/>)
+    //Returns: value of the "title" attribute of the element
+       public function getkeytitle($element) {
+               $nodes = $this->xpath->query("//address@hidden'".$element."']");
+               if ($nodes->length != 0) {
+                       return $nodes->item(0)->getAttribute('title');
+               } else {
+                       return "";
+               }
+       }
+
+    //Returns: tree of QSOSCriterion objects representing the scored criteria 
of the QSOS document
+       public function getTree() {
+               $tree = array();
+               $sections = $this->xpath->query("//section");
+               foreach ($sections as $section) {
+                       $criterion = new QSOSCriterion();
+                       $criterion->name = $section->getAttribute('name');
+                       $criterion->title = $section->getAttribute('title');
+                       $criterion->children = 
$this->getSubTree($criterion->name);
+                       $criterion->score = 
$this->renderScore($criterion->children);
+                       array_push($tree, $criterion);
+               }
+               return $tree;
+       }
+
+    //Recursive function
+    //$name: name of the element
+    //Returns: tree of QSOSCriterion objects representing the scored criteria 
of the element
+       public function getSubTree($name) {
+               $tree = array();
+               $elements = 
$this->xpath->query("//address@hidden'".$name."']/element");
+               foreach ($elements as $element) {
+                       $criterion = new QSOSCriterion();
+                       $criterion->name = $element->getAttribute('name');
+                       $criterion->title = $element->getAttribute('title');
+
+                       if ($this->hassubelements($criterion->name)) {
+                               $criterion->children = 
$this->getSubTree($criterion->name);
+                               $criterion->score = 
$this->renderScore($criterion->children);
+                               array_push($tree, $criterion);
+                       } else {
+                               $criterion->children = null;
+                               $criterion->score = 
$this->getkeyscore($criterion->name);
+                               if ($criterion->score == "") $criterion->score 
= null;
+                               if ($criterion->score != -1) array_push($tree, 
$criterion);
+                       }
+               }
+               return $tree;
+       }
+
+    //$tree: tree of QSOSCriterion objects to render
+    //Returns: the rendered score of the single QSOScriterion in $tree
+    //Recursive function
+       public function renderScore($tree) {
+               $score = 0;
+               $sum = 0;
+               $totalWeight = 0;
+               $isRenderable = true;
+
+               for ($i=0; $i < count($tree); $i++) {
+                       $totalWeight++;
+                       if ($tree[$i]->score == null) $isRenderable = false;
+                       $sum += round($tree[$i]->score, 2);
+               }
+
+;
+               if ($isRenderable) {
+                       $score = round(($sum/$totalWeight), 2);
+               }
+               else {
+                       $score = null;
+               }
+               
+               return $score;
+       }
+}
+?>
\ No newline at end of file

Index: radar.php
===================================================================
RCS file: radar.php
diff -N radar.php
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ radar.php   31 Oct 2006 15:56:05 -0000      1.1
@@ -0,0 +1,126 @@
+<?php
+include ("jpgraph-2.1.3/src/jpgraph.php");
+include ("jpgraph-2.1.3/src/jpgraph_radar.php");
+include("QSOSDocument.php");
+
+$files = $_GET['f'];
+$name = $_GET['c'];
+
+$myDoc = array();
+$app = array();
+$trees = array();
+$scores = array();
+$titles = array();
+
+$i = 0;
+$num = count($files);
+
+//Initialization of data arrays
+for($i=0; $i<$num; $i++) {
+       $myDoc[$i] = new QSOSDocument($files[$i]);
+       $trees[$i] = array();
+       if (isset($name)) {
+               $trees[$i] = $myDoc[$i]->getSubTree($name);
+       } else {
+               $trees[$i] = $myDoc[$i]->getTree();
+       }
+
+       $scores[$i] = array();
+       foreach($trees[$i] as $element) {
+               array_push($scores[$i], $element->score);
+       }
+}
+
+//Graph's title
+if (isset($name)) {
+       $title = $myDoc[0]->getkeytitle($name);
+} else {
+       $title = $myDoc[0]->getkey("qsosappfamily");
+}
+
+//Axis titles
+foreach($trees[0] as $element) {
+       array_push($titles, $element->title);
+}
+
+// Create the basic radar graph
+$graph = new RadarGraph(700,500,"auto");
+
+// Set background color and shadow
+$graph->SetColor("white");
+$graph->SetFrame(false,'',0);
+
+// Position the graph
+$graph->SetCenter(0.4,0.55);
+$graph->SetPos(0.5,0.6);
+
+// Setup the axis formatting  
+$graph->SetScale('lin',0,2);
+$graph->axis->SetFont(FF_ARIAL,FS_BOLD);
+$graph->axis->title->SetFont(FF_ARIAL,FS_BOLD);
+$graph->axis->title->SetMargin(5);
+$graph->axis->SetWeight(1);
+$graph->axis->SetColor('darkgray'); 
+
+// Setup the grid lines
+$graph->grid->SetLineStyle("longdashed");
+$graph->grid->SetColor("darkgray");
+$graph->grid->Show();
+$graph->HideTickMarks();
+        
+// Setup graph titles
+$graph->title->Set($title);
+$graph->title->SetFont(FF_ARIAL,FS_BOLD,12);
+$graph->SetTitles($titles);
+
+// Setup graph legend
+$graph->legend->SetFont(FF_ARIAL,FS_BOLD);
+
+function getColor($b_safe = TRUE) {
+       //if a browser safe color is requested then set the array up
+       //so that only a browser safe color can be returned
+       if($b_safe) {
+               $ary_codes = array('00','33','66','99','CC','FF');
+               $max = 5; //the highest array offest
+               //if a browser safe color is not requested then set the array
+               //up so that any color can be returned.
+       } else {
+               $ary_codes = array();
+               for($i=0;$i<16;$i++) {
+                       $t_1 = dechex($i);
+                       for($j=0;$j<16;$j++) {
+                               $t_2 = dechex($j);
+                               $ary_codes[] = "$t_1$t_2";
+                       }
+               }
+               $max = 256; //the highest array offset
+       }
+       $retVal = '';
+       
+       //generate a random color code
+       for($i=0;$i<3;$i++) {
+               $offset = rand(0,$max);
+               $retVal .= $ary_codes[$offset];
+       } //end for i
+       
+       return "#".$retVal;
+}
+
+//Generate graph for each software
+function getPlot($scores, $myDoc) {
+       $plot = new RadarPlot($scores);
+       $plot->SetLegend($myDoc->getkey("appname")." 
".$myDoc->getkey("release"));
+       $plot->SetColor(getColor()."@0.2");
+       $plot->SetLineWeight(3);
+       return $plot;
+}
+
+//Add them to the global graph
+for($i=0; $i<$num; $i++) {
+       $graph->Add(getPlot($scores[$i], $myDoc[$i]));
+}
+
+//Output the graph
+$graph->Stroke();
+
+?> 
\ No newline at end of file

Index: radar_single.php
===================================================================
RCS file: radar_single.php
diff -N radar_single.php
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ radar_single.php    31 Oct 2006 15:56:05 -0000      1.1
@@ -0,0 +1,71 @@
+<?php
+include ("jpgraph-2.1.3/src/jpgraph.php");
+include ("jpgraph-2.1.3/src/jpgraph_radar.php");
+include("QSOSDocument.php");
+
+$file = $_GET['f'];
+$name = $_GET['c'];
+
+// Get QSOS data
+$myDoc = new QSOSDocument($file);
+if (isset($name)) {
+    $tree = $myDoc->getSubTree($name);
+    $title = $myDoc->getkeytitle($name);
+} else {
+    $tree = $myDoc->getTree();
+    $title = $myDoc->getkey("qsosappfamily");
+}
+$titles = array();
+$scores = array();
+foreach($tree as $element) {
+    array_push($titles, $element->title);
+    array_push($scores, $element->score);
+}
+
+// Create the basic radar graph
+$graph = new RadarGraph(700,500,"auto");
+
+// Set background color and shadow
+$graph->SetColor("white");
+$graph->SetFrame(false,'',0);
+
+// Position the graph
+$graph->SetCenter(0.4,0.55);
+$graph->SetPos(0.5,0.6);
+
+// Setup the axis formatting  
+$graph->SetScale('lin',0,2);
+$graph->axis->SetFont(FF_ARIAL,FS_BOLD);
+$graph->axis->title->SetFont(FF_ARIAL,FS_BOLD);
+$graph->axis->title->SetMargin(5);
+$graph->axis->SetWeight(1);
+$graph->axis->SetColor("darkgray"); 
+
+// Setup the grid lines
+$graph->grid->SetLineStyle("longdashed");
+$graph->grid->SetColor("darkgray");
+$graph->grid->Show();
+$graph->HideTickMarks();
+        
+// Setup graph titles
+$graph->title->Set($title);
+$graph->title->SetFont(FF_ARIAL,FS_BOLD,12);
+$graph->SetTitles($titles);
+
+// Setup graph legend
+$graph->legend->SetFont(FF_ARIAL,FS_BOLD);
+
+// Create the first radar plot        
+$plot = new RadarPlot($scores);
+$plot->SetLegend($myDoc->getkey("appname")." ".$myDoc->getkey("release"));
+$plot->SetColor("address@hidden");
+$plot->SetFillColor("address@hidden");
+$plot->SetLineWeight(3);
+
+// Add the plots to the graph
+$graph->Add($plot);
+
+// And output the graph
+$graph->Stroke();
+
+?> 
\ No newline at end of file

Index: show.php
===================================================================
RCS file: show.php
diff -N show.php
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ show.php    31 Oct 2006 15:56:05 -0000      1.1
@@ -0,0 +1,186 @@
+<html>
+<head>
+<LINK REL=StyleSheet HREF="phpviewer.css" TYPE="text/css"/>
+<script language="JavaScript" type="text/javascript">
+function matchStart(target, pattern) {
+       var pos = target.indexOf(pattern);
+       if (pos == 0) {
+               return true;
+       } else {
+               return false;
+       }
+}
+
+function expand(div) {
+       var rows = document.getElementsByTagName("tr");
+       var id = div.parentNode.parentNode.id + "-";
+       for (var i = 0; i < rows.length; i++) {
+               var r = rows[i];
+               if (matchStart(r.id, id)) {
+                       if (document.all) r.style.display = "block"; //IE4+ 
specific code
+                       else r.style.display = "table-row"; //Netscape and 
Mozilla
+               }
+       }
+       div.className = "expanded";
+       div.onclick = function () {
+               collapse(this);
+       }
+}
+
+function collapse(div) {
+       var rows = document.getElementsByTagName("tr");
+       var id = div.parentNode.parentNode.id + "-";
+       for (var i = 0; i < rows.length; i++) {
+               var r = rows[i];
+               if (matchStart(r.id, id)) {
+                       r.style.display = "none";
+               }
+       }
+       div.className = "collapsed";
+       div.onclick = function () {
+               expand(this);
+       }
+}
+
+function collapseAll() {
+       var rows = document.getElementsByTagName("TR");
+               for (var j = 0; j < rows.length; j++) {
+               var r = rows[j];
+               if (r.id.indexOf("-") >= 0) {
+                       r.style.display = "none";
+               }
+       }
+       document.getElementById("all_selector").href = 
"javascript:expandAll();";
+       document.getElementById("all_selector").firstChild.nodeValue = "Expand 
All";
+}
+
+function expandAll() {
+       var rows = document.getElementsByTagName("TR");
+               for (var j = 0; j < rows.length; j++) {
+               var r = rows[j];
+               if (r.id.indexOf("-") >= 0) {
+                       if (document.all) r.style.display = "block"; //IE4+ 
specific code
+                       else r.style.display = "table-row"; //Netscape and 
Mozilla
+               }
+       }
+       document.getElementById("all_selector").href = 
"javascript:collapseAll();";
+       document.getElementById("all_selector").firstChild.nodeValue = 
"Collapse All";
+}
+
+function showComments() {
+       var cells = document.getElementsByTagName("td");
+       for (var i = 0; i < cells.length; i++) {
+               var c = cells[i];
+               if (c.id == 'comment') {
+                       if (document.all) c.style.display = "block"; //IE4+ 
specific code
+                       else c.style.display = "table-row"; //Netscape and 
Mozilla
+               }
+       }
+       document.getElementById("comment_selector").href = 
"javascript:hideComments();";
+       document.getElementById("comment_selector").firstChild.nodeValue = 
"Hide comments";
+}
+
+function hideComments() {
+       var cells = document.getElementsByTagName("td");
+       for (var i = 0; i < cells.length; i++) {
+               var c = cells[i];
+               if (c.id == 'comment') {
+                       c.style.display = "none";
+               }
+       }
+       document.getElementById("comment_selector").href = 
"javascript:showComments();";
+       document.getElementById("comment_selector").firstChild.nodeValue = 
"Show comments";
+}
+</script>
+</head>
+<body>
+<?php
+include("QSOSDocument.php");
+
+$files = $_GET['files'];
+
+$num = count($files);
+$myDoc = array();
+$app = array();
+$trees = array();
+
+$i = 0;
+foreach($files as $file) {
+       $myDoc[$i] = new QSOSDocument($file);
+       $app[$i] = $myDoc[$i]->getkey("appname")." 
".$myDoc[$i]->getkey("release");
+       $trees[$i] = $myDoc[$i]->getTree();
+       $i++;
+}
+
+$family = $myDoc[0]->getkey("qsosappfamily");
+
+
+echo "[<a id='comment_selector' href='javascript:hideComments();'>Hide 
comments</a>]";
+echo "<table style='border-collapse: collapse; table-layout: fixed;'>\n";
+
+echo "<tr class='title'><td>$family</td>";
+for($i=0; $i<$num; $i++) {
+       echo "<td>$app[$i]</td><td id='comment'>Comments</td>";
+}
+echo "</tr>\n";
+
+showtree($myDoc, $trees, 0, '');
+echo "</table>\n";
+
+function showtree($myDoc, $trees, $depth, $idP) {
+       $new_depth = $depth + 1;
+       $offset = $new_depth*10;
+       $idF = 0;
+       $tree = $trees[0];
+
+       for($k=0; $k<count($tree); $k++) {
+       //foreach($trees[0] as $element) {
+               //$name = $element->name;
+               //$title = $element->title;
+               //$subtree = $element->children;
+               $name = $tree[$k]->name;
+               $title = $tree[$k]->title;
+               $subtree = $tree[$k]->children;
+               $subtrees = array();
+
+               $idF++;
+               if ($idP == '') {
+                       $id = $idF;
+               } else  {
+                       $id = $idP."-".$idF;
+               }
+
+               echo "<tr id='$id' name='$name' class='level$depth'>\n";
+               if ($subtree) {
+                       echo "<td><span style='position:relative; left:$offset' 
onclick=\"collapse(this);\" class='expanded'>$title";
+                       if ($myDoc[0]->hassubelements($name) > 2) {
+                               $files = $_GET['files'];
+                               $f = "";
+                               foreach($files as $file) {
+                                       $f .= "f[]=$file&";
+                               }
+                               echo " [<a 
href='radar.php?".$f."c=$name'>Schema</a>]";
+                       }
+                       echo "</span></td>\n";
+               } else {
+                       echo "<td><span style='position:relative; 
left:$offset'>$title</span></td>\n";
+               }
+
+               for($i=0; $i<count($trees); $i++) {
+                       echo "<td 
class='score'>".$trees[$i][$k]->score."</td>\n";
+                       echo "<td id='comment'>".$myDoc[$i]->getgeneric($name, 
"comment")."</td>\n";
+               }
+               echo "</tr>\n";
+;
+               if ($subtree) {
+                       for($i=0; $i<count($trees); $i++) {
+                               $subtrees[$i] = $trees[$i][$k]->children;
+                       }
+                       showtree($myDoc, $subtrees, $new_depth, $id);
+               }
+       }
+}
+
+?>
+</body>
+</html>
\ No newline at end of file

Index: show_single.php
===================================================================
RCS file: show_single.php
diff -N show_single.php
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ show_single.php     31 Oct 2006 15:56:05 -0000      1.1
@@ -0,0 +1,152 @@
+<html>
+<head>
+<LINK REL=StyleSheet HREF="phpviewer.css" TYPE="text/css"/>
+<script language="JavaScript" type="text/javascript">
+function matchStart(target, pattern) {
+       var pos = target.indexOf(pattern);
+       if (pos == 0) {
+               return true;
+       } else {
+               return false;
+       }
+}
+
+function expand(div) {
+       var rows = document.getElementsByTagName("tr");
+       var id = div.parentNode.parentNode.id + "-";
+       for (var i = 0; i < rows.length; i++) {
+               var r = rows[i];
+               if (matchStart(r.id, id)) {
+                       if (document.all) r.style.display = "block"; //IE4+ 
specific code
+                       else r.style.display = "table-row"; //Netscape and 
Mozilla
+               }
+       }
+       div.className = "expanded";
+       div.onclick = function () {
+               collapse(this);
+       }
+}
+
+function collapse(div) {
+       var rows = document.getElementsByTagName("tr");
+       var id = div.parentNode.parentNode.id + "-";
+       for (var i = 0; i < rows.length; i++) {
+               var r = rows[i];
+               if (matchStart(r.id, id)) {
+                       r.style.display = "none";
+               }
+       }
+       div.className = "collapsed";
+       div.onclick = function () {
+               expand(this);
+       }
+}
+
+function collapseAll() {
+       var rows = document.getElementsByTagName("TR");
+               for (var j = 0; j < rows.length; j++) {
+               var r = rows[j];
+               if (r.id.indexOf("-") >= 0) {
+                       r.style.display = "none";
+               }
+       }
+       document.getElementById("all_selector").href = 
"javascript:expandAll();";
+       document.getElementById("all_selector").firstChild.nodeValue = "Expand 
All";
+}
+
+function expandAll() {
+       var rows = document.getElementsByTagName("TR");
+               for (var j = 0; j < rows.length; j++) {
+               var r = rows[j];
+               if (r.id.indexOf("-") >= 0) {
+                       if (document.all) r.style.display = "block"; //IE4+ 
specific code
+                       else r.style.display = "table-row"; //Netscape and 
Mozilla
+               }
+       }
+       document.getElementById("all_selector").href = 
"javascript:collapseAll();";
+       document.getElementById("all_selector").firstChild.nodeValue = 
"Collapse All";
+}
+
+function showComments() {
+       var cells = document.getElementsByTagName("td");
+       for (var i = 0; i < cells.length; i++) {
+               var c = cells[i];
+               if (c.id == 'comment') {
+                       if (document.all) c.style.display = "block"; //IE4+ 
specific code
+                       else c.style.display = "table-row"; //Netscape and 
Mozilla
+               }
+       }
+       document.getElementById("comment_selector").href = 
"javascript:hideComments();";
+       document.getElementById("comment_selector").firstChild.nodeValue = 
"Hide comments";
+}
+
+function hideComments() {
+       var cells = document.getElementsByTagName("td");
+       for (var i = 0; i < cells.length; i++) {
+               var c = cells[i];
+               if (c.id == 'comment') {
+                       c.style.display = "none";
+               }
+       }
+       document.getElementById("comment_selector").href = 
"javascript:showComments();";
+       document.getElementById("comment_selector").firstChild.nodeValue = 
"Show comments";
+}
+</script>
+</head>
+<body>
+<?php
+include("QSOSDocument.php");
+
+$file = $_GET['f'];
+
+$myDoc = new QSOSDocument($file);
+$family = $myDoc->getkey("qsosappfamily");
+$app = $myDoc->getkey("appname")." ".$myDoc->getkey("release");
+
+
+echo "[<a id='comment_selector' href='javascript:hideComments();'>Hide 
comments</a>]";
+echo "<table style='border-collapse: collapse; table-layout: fixed;'>\n";
+echo "<tr class='title'><td>$family</td><td>$app</td><td 
id='comment'>Comments</td></tr>\n";
+showtree($myDoc, $file, $myDoc->getTree(), 0, '');
+echo "</table>\n";
+
+function showtree($myDoc, $file, $tree, $depth, $idP) {
+       $new_depth = $depth + 1;
+       $offset = $new_depth*10;
+       $idF = 0;
+
+       foreach($tree as $element) {
+               $name = $element->name;
+               $title = $element->title;
+               $subtree = $element->children;
+               $comment = $myDoc->getgeneric($name, "comment");
+
+               $idF++;
+               if ($idP == '') {
+                       $id = $idF;
+               } else  {
+                       $id = $idP."-".$idF;
+               }
+
+               echo "<tr id='$id' name='$name' class='level$depth'>\n";
+               if ($subtree) {
+                       echo "<td><span style='position:relative; left:$offset' 
onclick=\"collapse(this);\" class='expanded'>$title";
+                       if ($myDoc->hassubelements($name) > 2) {
+                               echo " [<a 
href='radar_single.php?f=$file&c=$name'>Schema</a>]";
+                       }
+                       echo "</span></td>\n";
+               } else {
+                       echo "<td><span style='position:relative; 
left:$offset'>$title</span></td>\n";
+               }
+               echo "<td class='score'>".$element->score."</td>\n";
+               echo "<td id='comment'>".$comment."</td></tr>\n";
+               if ($subtree) {
+                       showtree($myDoc, $file, $subtree, $new_depth, $id);
+               }
+       }
+}
+
+?>
+<script language="JavaScript" type="text/javascript" 
src="wz_tooltip.js"></script>
+</body>
+</html>
\ No newline at end of file




reply via email to

[Prev in Thread] Current Thread [Next in Thread]