PageRenderTime 57ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/apps/o3s/show.php

#
PHP | 318 lines | 251 code | 35 blank | 32 comment | 34 complexity | 176b019b5c48a965377038e8ba67e815 MD5 | raw file
Possible License(s): GPL-2.0, CC-BY-SA-3.0
  1. <?php
  2. /*
  3. ** Copyright (C) 2007-2009 Atos Origin
  4. **
  5. ** Author: Raphael Semeteys <raphael.semeteys@atosorigin.com>
  6. **
  7. ** This program is free software; you can redistribute it and/or modify
  8. ** it under the terms of the GNU General Public License as published by
  9. ** the Free Software Foundation; either version 2 of the License, or
  10. ** (at your option) any later version.
  11. **
  12. ** This program is distributed in the hope that it will be useful,
  13. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. ** GNU General Public License for more details.
  16. **
  17. ** You should have received a copy of the GNU General Public License
  18. ** along with this program; if not, write to the Free Software
  19. ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. **
  21. **
  22. ** O3S
  23. ** show.php: show QSOS evaluation(s)
  24. **
  25. */
  26. session_start();
  27. $weights = $_SESSION;
  28. $is_weighted = $_SESSION["nbWeights"];
  29. //Search pattern
  30. $s = $_REQUEST['s'];
  31. include("config.php");
  32. include("lang.php");
  33. echo "<html>\n";
  34. echo "<head>\n";
  35. echo "<LINK REL=StyleSheet HREF='skins/$skin/o3s.css' TYPE='text/css'/>\n";
  36. ?>
  37. <script src="commons.js" language="JavaScript" type="text/javascript"></script>
  38. <script src="search.js" language="JavaScript" type="text/javascript"></script>
  39. <script>
  40. var size = 12;
  41. function showComments() {
  42. var cells = document.getElementsByTagName("td");
  43. for (var i = 0; i < cells.length; i++) {
  44. var c = cells[i];
  45. if (c.id == 'comment') {
  46. if (document.all) c.style.display = "block"; //IE4+ specific code
  47. else c.style.display = "table-row"; //Netscape and Mozilla
  48. }
  49. }
  50. document.getElementById("comment_selector").href = "javascript:hideComments();";
  51. document.getElementById("column").src = "<?php echo "skins/$skin/hide-comments.png"; ?>";
  52. }
  53. function hideComments() {
  54. var cells = document.getElementsByTagName("td");
  55. for (var i = 0; i < cells.length; i++) {
  56. var c = cells[i];
  57. if (c.id == 'comment') {
  58. c.style.display = "none";
  59. }
  60. }
  61. document.getElementById("comment_selector").href = "javascript:showComments();";
  62. document.getElementById("column").src = "<?php echo "skins/$skin/show-comments.png"; ?>";
  63. }
  64. function decreaseFontSize() {
  65. size--;
  66. document.getElementById("table").style.fontSize = size + "pt";
  67. }
  68. function increaseFontSize() {
  69. size++;
  70. document.getElementById("table").style.fontSize = size + "pt";
  71. }
  72. function submitForm(c) {
  73. document.getElementById("c").value = c;
  74. myForm.submit();
  75. }
  76. </script>
  77. <?php
  78. echo "</head>\n";
  79. include("libs/QSOSDocument.php");
  80. //Ids of QSOS XML files to be displayed
  81. $ids = $_REQUEST['id'];
  82. //Are graphs to be generated in SVG?
  83. $svg = $_REQUEST['svg'];
  84. function janitize($text) {
  85. return str_replace("\n",'',$text);
  86. }
  87. if (isset($s)) {
  88. echo "<body onload=\"highlightSearchTerms('$s');\">\n";
  89. } else {
  90. echo "<body>\n";
  91. }
  92. echo "<center>\n";
  93. echo "<img src='skins/$skin/o3s.png'/>\n";
  94. echo "<br/><br/>\n";
  95. echo "<div style='font-weight: bold'>".$msg['s4_title']."<br/><br/>\n";
  96. $IdDB = mysql_connect($db_host ,$db_user, $db_pwd);
  97. mysql_select_db($db_db);
  98. $query = "SELECT id FROM evaluations WHERE appname <> '' AND language = '$lang'";
  99. $IdReq = mysql_query($query, $IdDB);
  100. $allIds = array();
  101. while($row = mysql_fetch_row($IdReq)) {
  102. array_push($allIds, $row[0]);
  103. }
  104. $files = array();
  105. foreach($ids as $id) {
  106. if (!(in_array($id,$allIds))) die($id.$msg['s4_err_no_id']);
  107. $query = "SELECT file FROM evaluations WHERE id = \"$id\"";
  108. $IdReq = mysql_query($query, $IdDB);
  109. $result = mysql_fetch_row($IdReq);
  110. array_push($files, $result[0]);
  111. }
  112. //echo "<form id='myForm' method='POST' action='radar.php'>\n";
  113. //echo "<input type='hidden' name='svg' value='$svg'/>\n";
  114. //echo "<input type='hidden' name='c' id='c' value=''/>\n";
  115. //echo "<input type='hidden' name='s' value='$s'/>\n";
  116. $num = count($files);
  117. $myDoc = array();
  118. $app = array();
  119. $trees = array();
  120. $i = 0;
  121. foreach($files as $file) {
  122. $myDoc[$i] = new QSOSDocument($file);
  123. $app[$i] = $myDoc[$i]->getkey("appname")." ".$myDoc[$i]->getkey("release");
  124. if ($is_weighted) {
  125. $trees[$i] = $myDoc[$i]->getWeightedTree($weights);
  126. } else {
  127. $trees[$i] = $myDoc[$i]->getTree();
  128. }
  129. $i++;
  130. }
  131. $family = $myDoc[0]->getkey("qsosappfamily");
  132. $qsosspecificformat = $myDoc[0]->getkey("qsosspecificformat");
  133. $f = "";
  134. foreach($ids as $id) {
  135. $f .= "id[]=$id&";
  136. }
  137. echo "<table>\n";
  138. echo "<tr width='100%' align='center'><td>\n";
  139. echo "<a id='comment_selector' href='javascript:hideComments();'>";
  140. echo "<img id='column'
  141. src='skins/$skin/hide-comments.png'
  142. border=0
  143. onmouseover=\"return escape('Hide/Show comments')\"/>";
  144. echo "</a>\n";
  145. echo " <a href='javascript:decreaseFontSize();'>";
  146. echo "<img src='skins/$skin/decrease-font.png'
  147. border=0
  148. onmouseover=\"return escape('Decrease font size')\"/>";
  149. echo "</a>\n";
  150. echo " <a href='javascript:increaseFontSize();'>";
  151. echo "<img src='skins/$skin/increase-font.png'
  152. border=0
  153. onmouseover=\"return escape('Increase font size')\"/>";
  154. echo "</a>\n";
  155. if (!isset($s)) {
  156. echo " <a href='radar.php?lang=$lang&".$f."svg=$svg'>";
  157. echo "<img src='skins/$skin/graph.png'
  158. border=0 onmouseover=\"return escape('Show graph')\"/>";
  159. echo "</a>\n";
  160. }
  161. echo "</td></tr>\n";
  162. echo "<tr><td align='center'>\n";
  163. if (isset($s)) {
  164. echo "<input type='button'
  165. value='".$msg['s4_button_back_alt']
  166. ."' onclick='location.href=\"search.php?s=$s\"'><br/><br/>";
  167. } else {
  168. echo "<input type='button'
  169. value='".$msg['s4_button_back']
  170. ."' onclick='location.href=\"list.php?lang=$lang&family=".$family."&qsosspecificformat=$qsosspecificformat&svg=$svg\"'><br/><br/>";
  171. }
  172. echo "</td></tr>\n";
  173. echo "</table>\n";
  174. echo "<table id='table' style='font-size: 12pt; table-layout: fixed'>\n";
  175. echo "<tr class='title' style='width: 250px'>\n";
  176. echo "<td rowspan='2'><div style='text-align: center'>$family</div></td>\n";
  177. echo "<td style='width: 30px' rowspan='2'>";
  178. if ($is_weighted) {
  179. echo "<img src='skins/$skin/graph.png' border='' style='cursor: pointer' onclick='submitForm(\"\")'/>";
  180. }
  181. echo "</td>\n";
  182. for($i=0; $i<$num; $i++) {
  183. echo "<td colspan='2'><div style='width: 120px; text-align: center'>$app[$i]</div></td>\n";
  184. echo "<td id='comment' style='width: 300px'>".$msg['s4_comments']."</td>\n";
  185. }
  186. echo "</tr>\n";
  187. echo "<tr class='title'>\n";
  188. for($i=0; $i<$num; $i++) {
  189. echo "<td><div style='width: 60px; text-align: center'>".$msg['s4_score']."</div></td>\n";
  190. echo "<td><div style='width: 60px; text-align: center'>".$msg['s4_weight']."</div></td>\n";
  191. echo "<td id='comment' style='width: 300px'></td>\n";
  192. }
  193. echo "</tr>\n";
  194. showtree($myDoc, $trees, 0, '', $weights);
  195. echo "</table>\n";
  196. function showtree($myDoc, $trees, $depth, $idP, $weights) {
  197. global $id, $f;
  198. global $files;
  199. global $svg;
  200. global $is_weighted;
  201. global $skin;
  202. global $lang;
  203. $new_depth = $depth + 1;
  204. $offset = $new_depth*10;
  205. $idF = 0;
  206. $tree = $trees[0];
  207. for($k=0; $k<count($tree); $k++) {
  208. $name = $tree[$k]->name;
  209. $title = $tree[$k]->title;
  210. $subtree = $tree[$k]->children;
  211. $subtrees = array();
  212. $idF++;
  213. if ($idP == '') {
  214. $idDOM = $idF;
  215. } else {
  216. $idDOM = $idP."-".$idF;
  217. }
  218. echo "<tr id='$idDOM'
  219. name='$name'
  220. class='level$depth'
  221. onmouseover=\"this.setAttribute('class','highlight')\"
  222. onmouseout=\"this.setAttribute('class','level$depth')\">\n";
  223. if ($subtree) {
  224. echo "<td style='width: 250px; text-indent: $offset'>
  225. <span onclick=\"collapse(this);\" class='expanded'>$title</span>
  226. </td>\n";
  227. echo "<td style='width: 30px'>";
  228. if ($myDoc[0]->hassubelements($name) > 2) {
  229. if (!isset($s)) {
  230. echo "<a href='radar.php?lang=$lang&".$f."c=$name&svg=$svg'><img src='skins/$skin/graph.png' border='' style='cursor: pointer'/></a>\n";
  231. }
  232. }
  233. } else {
  234. echo "<td style='width: 250px; text-indent: $offset'>
  235. <span>$title</span>
  236. </td>\n";
  237. echo "<td style='width: 30px'></td>\n";;
  238. }
  239. for($i=0; $i<count($trees); $i++) {
  240. $desc = addslashes($myDoc[$i]->getgeneric($name, "desc".$trees[$i][$k]->score));
  241. if ($desc != "") {
  242. echo "<td class='score'
  243. style='width: 60px; cursor:help' onmouseover=\"return escape('".janitize($desc)."')\">
  244. <div style='text-align: center'>"
  245. .$trees[$i][$k]->score
  246. ."</div></td>\n";
  247. } else {
  248. echo "<td class='score'
  249. style='width: 60px; text-align: center'>
  250. <div style='text-align: center'>"
  251. .$trees[$i][$k]->score
  252. ."</div></td>\n";
  253. }
  254. if (!$is_weighted) {
  255. $weights[$name] = 1;
  256. $_SESSION[$name] = $weights[$name];
  257. }
  258. echo "<td>
  259. <div style='text-align: center'>"
  260. .$weights[$name]
  261. ."</div></td>\n";
  262. echo "<td id='comment'>
  263. <div style='width: 300px'>"
  264. .$myDoc[$i]->getgeneric($name, "comment")
  265. ."</div></td>\n";
  266. }
  267. echo "</tr>\n";
  268. if ($subtree) {
  269. for($i=0; $i<count($trees); $i++) {
  270. $subtrees[$i] = $trees[$i][$k]->children;
  271. }
  272. showtree($myDoc, $subtrees, $new_depth, $idDOM, $weights);
  273. }
  274. }
  275. }
  276. //echo "</form>";
  277. echo "<br/>";
  278. echo $msg['g_license_notice'];
  279. echo "</center>\n";
  280. echo "<script language='JavaScript' type='text/javascript' src='libs/wz_tooltip.js'></script>";
  281. echo "</body>\n";
  282. echo "</html>\n";
  283. ?>