| 1 | <?php
|
|---|
| 2 |
|
|---|
| 3 | /**
|
|---|
| 4 | * Compute completion percentage for a dll.
|
|---|
| 5 | * @returns Completion percentage. Range 0-100.
|
|---|
| 6 | * On error -1 or -2 is returned.
|
|---|
| 7 | * @param $iDll Dll reference code.
|
|---|
| 8 | * @param $db Database connection variable.
|
|---|
| 9 | * @sketch Get total number of function in the dll.
|
|---|
| 10 | * Get number of completed functions in the dll.
|
|---|
| 11 | * return complete*100 / total
|
|---|
| 12 | * @status Completely implemented
|
|---|
| 13 | * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
|
|---|
| 14 | * @remark
|
|---|
| 15 | */
|
|---|
| 16 | function Odin32DBComputeCompletion($iDll, $db)
|
|---|
| 17 | {
|
|---|
| 18 | /*
|
|---|
| 19 | * Count the total number of functions in the DLL.
|
|---|
| 20 | */
|
|---|
| 21 | $sql = sprintf("SELECT SUM(s.weight)/COUNT(f.state)
|
|---|
| 22 | FROM
|
|---|
| 23 | function f,
|
|---|
| 24 | state s
|
|---|
| 25 | WHERE
|
|---|
| 26 | f.state = s.refcode
|
|---|
| 27 | AND dll = %d",
|
|---|
| 28 | $iDll);
|
|---|
| 29 | $result = mysql_query($sql, $db);
|
|---|
| 30 | if (mysql_num_rows($result) < 1)
|
|---|
| 31 | {
|
|---|
| 32 | echo "<br>Odin32DBComputeCompletion: IPE no. 1 <br>";
|
|---|
| 33 | return -1;
|
|---|
| 34 | }
|
|---|
| 35 | $row = mysql_fetch_row($result);
|
|---|
| 36 | $iComplete = $row[0];
|
|---|
| 37 | mysql_free_result($result);
|
|---|
| 38 | }
|
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 | /**
|
|---|
| 43 | * Draws a completion bar.
|
|---|
| 44 | * @param $iDll Dll reference code.
|
|---|
| 45 | * If < 0 then for the entire project.
|
|---|
| 46 | * @param $db Database connection variable.
|
|---|
| 47 | * @sketch Get total number of function in the dll.
|
|---|
| 48 | * Get the number of function per status. (+state color)
|
|---|
| 49 | * Draw bar.
|
|---|
| 50 | * @status Completely implemented
|
|---|
| 51 | * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
|
|---|
| 52 | */
|
|---|
| 53 | function Odin32DBCompletionBar($iDll, $sDllName, $db)
|
|---|
| 54 | {
|
|---|
| 55 | /*
|
|---|
| 56 | * Count the total number of functions in the DLL.
|
|---|
| 57 | */
|
|---|
| 58 | if ($iDll < 0)
|
|---|
| 59 | $sql = "SELECT COUNT(*) FROM function f";
|
|---|
| 60 | else
|
|---|
| 61 | $sql = sprintf("SELECT COUNT(*) FROM function f WHERE dll = %d", $iDll);
|
|---|
| 62 | $result = mysql_query($sql, $db);
|
|---|
| 63 | if (mysql_num_rows($result) < 1)
|
|---|
| 64 | {
|
|---|
| 65 | printf("\n\n<br>Odin32DBCompletionBar: IPE(1).<br>\n\n");
|
|---|
| 66 | return -1;
|
|---|
| 67 | }
|
|---|
| 68 | $row = mysql_fetch_row($result);
|
|---|
| 69 | $cFunctions = $row[0];
|
|---|
| 70 | mysql_free_result($result);
|
|---|
| 71 |
|
|---|
| 72 |
|
|---|
| 73 | /*
|
|---|
| 74 | * Make
|
|---|
| 75 | */
|
|---|
| 76 | echo "
|
|---|
| 77 | <table width=100% border=0 cellspacing=0 cellpadding=0>
|
|---|
| 78 | <tr>
|
|---|
| 79 | <td width=90%>
|
|---|
| 80 | <font size=-1 color=000099>
|
|---|
| 81 | <tt>".$sDllName."</tt>
|
|---|
| 82 | </font>
|
|---|
| 83 | </td>
|
|---|
| 84 | <td width=10%></td>
|
|---|
| 85 | </tr>
|
|---|
| 86 | <tr>
|
|---|
| 87 | <td width=90%>
|
|---|
| 88 | <table width=100% border=0 cellspacing=0 cellpadding=0>
|
|---|
| 89 | <tr>
|
|---|
| 90 | ";
|
|---|
| 91 |
|
|---|
| 92 |
|
|---|
| 93 | /*
|
|---|
| 94 | * Get states and make bar.
|
|---|
| 95 | */
|
|---|
| 96 | if ($iDll < 0)
|
|---|
| 97 | $sDllCond = "";
|
|---|
| 98 | else
|
|---|
| 99 | $sDllCond = "dll = %d AND ";
|
|---|
| 100 | $sql = sprintf("SELECT COUNT(f.refcode) AS count,
|
|---|
| 101 | f.state AS state,
|
|---|
| 102 | s.color AS color,
|
|---|
| 103 | s.weight AS weight
|
|---|
| 104 | FROM
|
|---|
| 105 | function f,
|
|---|
| 106 | state s
|
|---|
| 107 | WHERE
|
|---|
| 108 | ".$sDllCond."
|
|---|
| 109 | s.refcode = f.state
|
|---|
| 110 | GROUP BY f.state
|
|---|
| 111 | ORDER BY state",
|
|---|
| 112 | $iDll);
|
|---|
| 113 | $result = mysql_query($sql, $db);
|
|---|
| 114 | $rdCompletePercent = 0.0;
|
|---|
| 115 | if (@mysql_num_rows($result) < 1)
|
|---|
| 116 | {
|
|---|
| 117 | echo "
|
|---|
| 118 | <td colspan=2 bgcolor=dddddd>
|
|---|
| 119 | <font size=-1>
|
|---|
| 120 |
|
|---|
| 121 | </font>
|
|---|
| 122 | </td>
|
|---|
| 123 | ";
|
|---|
| 124 |
|
|---|
| 125 | }
|
|---|
| 126 | else
|
|---|
| 127 | {
|
|---|
| 128 | while ($row = mysql_fetch_row($result))
|
|---|
| 129 | {
|
|---|
| 130 | $iPercent = (int)($row[0] * 90 /* 10% is reserved to % */ / $cFunctions);
|
|---|
| 131 | if ($iPercent == 0)
|
|---|
| 132 | $iPercent = 1;
|
|---|
| 133 | echo "
|
|---|
| 134 | <td width=".$iPercent." bgcolor=".$row[2].">
|
|---|
| 135 | <font size=-1>
|
|---|
| 136 |
|
|---|
| 137 | </font>
|
|---|
| 138 | </td>
|
|---|
| 139 | ";
|
|---|
| 140 |
|
|---|
| 141 | $rdCompletePercent += ((double)$row[3] * (double)$row[0]) / $cFunctions;
|
|---|
| 142 | }
|
|---|
| 143 |
|
|---|
| 144 | }
|
|---|
| 145 | mysql_free_result($result);
|
|---|
| 146 |
|
|---|
| 147 | /*
|
|---|
| 148 | * Complete bar with a total completion percent.
|
|---|
| 149 | */
|
|---|
| 150 | echo "
|
|---|
| 151 | <td width=10% align=right>
|
|---|
| 152 | <font size=-1 color=000099>
|
|---|
| 153 | ".(int)$rdCompletePercent."%
|
|---|
| 154 | </font>
|
|---|
| 155 | </td>
|
|---|
| 156 | </tr>
|
|---|
| 157 | </table>
|
|---|
| 158 | </td>
|
|---|
| 159 | </tr>
|
|---|
| 160 | </table>
|
|---|
| 161 | ";
|
|---|
| 162 | }
|
|---|
| 163 |
|
|---|
| 164 |
|
|---|
| 165 | /**
|
|---|
| 166 | * Draws a legend for status colors.
|
|---|
| 167 | * @param $db Database connection variable.
|
|---|
| 168 | * @sketch Get status codes; fetch name and color.
|
|---|
| 169 | *
|
|---|
| 170 | *
|
|---|
| 171 | * @status Completely implemented
|
|---|
| 172 | * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
|
|---|
| 173 | */
|
|---|
| 174 | function Odin32DBStateLegend($db)
|
|---|
| 175 | {
|
|---|
| 176 | /*
|
|---|
| 177 | * Count the total number of functions in the DLL.
|
|---|
| 178 | */
|
|---|
| 179 | $sql = "SELECT
|
|---|
| 180 | name,
|
|---|
| 181 | color
|
|---|
| 182 | FROM
|
|---|
| 183 | state
|
|---|
| 184 | ORDER BY refcode";
|
|---|
| 185 |
|
|---|
| 186 | $result = mysql_query($sql, $db);
|
|---|
| 187 | if (mysql_num_rows($result) < 1)
|
|---|
| 188 | {
|
|---|
| 189 | printf("\n\n<br>Odin32DBStateLegned: IPE(1).<br>\n\n");
|
|---|
| 190 | return -1;
|
|---|
| 191 | }
|
|---|
| 192 | else
|
|---|
| 193 | {
|
|---|
| 194 | echo "
|
|---|
| 195 | <tr><td></td></tr>
|
|---|
| 196 | <tr>
|
|---|
| 197 | <td>
|
|---|
| 198 | <center><B><font face=\"WarpSans, Arial\" color=\"#990000\">
|
|---|
| 199 | Status Legend:
|
|---|
| 200 | </font></b></center>
|
|---|
| 201 | </td>
|
|---|
| 202 | </tr>
|
|---|
| 203 | <tr>
|
|---|
| 204 | <td>
|
|---|
| 205 | <table width=100% border=0 cellspacing=2 cellpadding=0 align=right>
|
|---|
| 206 | ";
|
|---|
| 207 | while ($row = mysql_fetch_row($result))
|
|---|
| 208 | {
|
|---|
| 209 | if (1)
|
|---|
| 210 | {
|
|---|
| 211 | echo "
|
|---|
| 212 | <tr>
|
|---|
| 213 | <td width=85% align=right>
|
|---|
| 214 | <font size=1 color=000099>
|
|---|
| 215 | ".$row[0]."
|
|---|
| 216 | </font>
|
|---|
| 217 | </td>
|
|---|
| 218 | <td width=15% bgcolor=".$row[1].">
|
|---|
| 219 | <font size=-1>
|
|---|
| 220 | <br>
|
|---|
| 221 |
|
|---|
| 222 | </font>
|
|---|
| 223 | </td>
|
|---|
| 224 | </tr>
|
|---|
| 225 | ";
|
|---|
| 226 | }
|
|---|
| 227 | else
|
|---|
| 228 | {
|
|---|
| 229 | echo "
|
|---|
| 230 | <tr>
|
|---|
| 231 | <td align=left bgcolor=".$row[1].">
|
|---|
| 232 | <font size=1 color=000000>
|
|---|
| 233 | ".$row[0]."
|
|---|
| 234 | </font>
|
|---|
| 235 | </td>
|
|---|
| 236 | </tr>
|
|---|
| 237 | ";
|
|---|
| 238 | }
|
|---|
| 239 | }
|
|---|
| 240 |
|
|---|
| 241 | echo "
|
|---|
| 242 | </table>
|
|---|
| 243 | </p>
|
|---|
| 244 | </td>
|
|---|
| 245 | </tr>
|
|---|
| 246 | ";
|
|---|
| 247 | }
|
|---|
| 248 |
|
|---|
| 249 |
|
|---|
| 250 | mysql_free_result($result);
|
|---|
| 251 | }
|
|---|
| 252 |
|
|---|
| 253 |
|
|---|
| 254 | /**
|
|---|
| 255 | * Dump an SQL statement in HTML.
|
|---|
| 256 | *
|
|---|
| 257 | * @returns nothing.
|
|---|
| 258 | * @param $sql Sql to display.
|
|---|
| 259 | * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
|
|---|
| 260 | */
|
|---|
| 261 | function Odin32DBDumpSql($sql)
|
|---|
| 262 | {
|
|---|
| 263 | echo "<p><font size=1 face=\"courier\">
|
|---|
| 264 | SQL:<br>
|
|---|
| 265 | ".str_replace(" ", " ", str_replace("\n", "<br>\n", $sql))."
|
|---|
| 266 | <br>
|
|---|
| 267 | </font>
|
|---|
| 268 | </p>
|
|---|
| 269 | ";
|
|---|
| 270 | }
|
|---|
| 271 |
|
|---|
| 272 |
|
|---|
| 273 | /**
|
|---|
| 274 | *
|
|---|
| 275 | * @returns
|
|---|
| 276 | * @param $sName
|
|---|
| 277 | * @param $array Result array.
|
|---|
| 278 | * @param $sValueName Name in the $array for the value.
|
|---|
| 279 | * @param $sRefName Name in the $array for the reference.
|
|---|
| 280 | * @param $sOdin32DBArg Odin32DB.phtml argument.
|
|---|
| 281 | * @param $sNullText Null text (if the array element is NULL display this).
|
|---|
| 282 | * @param $sPostText Text to insert after the value.
|
|---|
| 283 | *
|
|---|
| 284 | */
|
|---|
| 285 | function Odin32DBInfoRow1($sName, $array, $sValueName, $sRefName, $sOdin32DBArg, $sNullText, $sPostText)
|
|---|
| 286 | {
|
|---|
| 287 | echo "
|
|---|
| 288 | <tr>
|
|---|
| 289 | <td width=35%><tt>".$sName."</tt></td>
|
|---|
| 290 | <td valign=top>";
|
|---|
| 291 | if (isset($array[$sValueName]))
|
|---|
| 292 | {
|
|---|
| 293 | if ($sRefName != "" && isset($array[$sRefName]) && $sOdin32DBArg != "")
|
|---|
| 294 | {
|
|---|
| 295 | echo "<a href=\"Odin32DB.phtml?".$sOdin32DBArg."=".$array[$sRefName]."\">";
|
|---|
| 296 | $sPostText = "</a>".$sPostText;
|
|---|
| 297 | }
|
|---|
| 298 | echo $array[$sValueName];
|
|---|
| 299 | echo $sPostText;
|
|---|
| 300 | }
|
|---|
| 301 | else if ($sNullText != "")
|
|---|
| 302 | echo "<i>".$sNullText."</i>";
|
|---|
| 303 |
|
|---|
| 304 | echo "
|
|---|
| 305 | </td>
|
|---|
| 306 | <tr>\n";
|
|---|
| 307 | }
|
|---|
| 308 |
|
|---|
| 309 |
|
|---|
| 310 | /**
|
|---|
| 311 | *
|
|---|
| 312 | * @returns
|
|---|
| 313 | * @param $sName
|
|---|
| 314 | * @param $array Result array.
|
|---|
| 315 | * @param $sValueName1 Name in the $array for the value.
|
|---|
| 316 | * @param $sRefName1 Name in the $array for the reference.
|
|---|
| 317 | * @param $sOdin32DBArg1 Odin32DB.phtml argument.
|
|---|
| 318 | * @param $sNullText Null text (if the array element is NULL display this).
|
|---|
| 319 | * @param $sPostText Text to insert after the value.
|
|---|
| 320 | * @param $sValueName2 Name in the $array for the value.
|
|---|
| 321 | * @param $sRefName2 Name in the $array for the reference.
|
|---|
| 322 | * @param $sOdin32DBArg2 Odin32DB.phtml argument.
|
|---|
| 323 | *
|
|---|
| 324 | */
|
|---|
| 325 | function Odin32DBInfoRow2($sName, $array, $sValueName1, $sRefName1, $sOdin32DBArg1, $sNullText, $sPostText,
|
|---|
| 326 | $sValueName2, $sRefName2, $sOdin32DBArg2)
|
|---|
| 327 | {
|
|---|
| 328 | echo "
|
|---|
| 329 | <tr>
|
|---|
| 330 | <td width=35%><tt>".$sName."</tt></td>
|
|---|
| 331 | <td valign=top>";
|
|---|
| 332 | if (isset($array[$sValueName1]))
|
|---|
| 333 | {
|
|---|
| 334 | if ($sRefName1 != "" && isset($array[$sRefName1]) && $sOdin32DBArg1 != "")
|
|---|
| 335 | {
|
|---|
| 336 | echo "<a href=\"Odin32DB.phtml?".$sOdin32DBArg1."=".$array[$sRefName1]."\">";
|
|---|
| 337 | $sPostText = "</a>".$sPostText;
|
|---|
| 338 | }
|
|---|
| 339 | echo $array[$sValueName1];
|
|---|
| 340 | echo $sPostText;
|
|---|
| 341 |
|
|---|
| 342 | if (isset($array[$sValueName2]))
|
|---|
| 343 | {
|
|---|
| 344 | if ($sRefName2 != "" && isset($array[$sRefName2]) && $sOdin32DBArg2 != "")
|
|---|
| 345 | {
|
|---|
| 346 | echo "<a href=\"Odin32DB.phtml?".$sOdin32DBArg2."=".$array[$sRefName2]."\">";
|
|---|
| 347 | echo $array[$sValueName2]."</a>";
|
|---|
| 348 | }
|
|---|
| 349 | else
|
|---|
| 350 | echo $array[$sValueName2];
|
|---|
| 351 | }
|
|---|
| 352 | }
|
|---|
| 353 | else if ($sNullText != "")
|
|---|
| 354 | echo "<i>".$sNullText."</i>";
|
|---|
| 355 |
|
|---|
| 356 | echo "</td>
|
|---|
| 357 | <tr>\n";
|
|---|
| 358 | }
|
|---|
| 359 |
|
|---|
| 360 |
|
|---|
| 361 |
|
|---|
| 362 | /**
|
|---|
| 363 | * Inserts a documentation row from database..
|
|---|
| 364 | * @param $sName Name of the information.
|
|---|
| 365 | * @param $array DB result array.
|
|---|
| 366 | * @param $sValueName Name in the DB result array.
|
|---|
| 367 | * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
|
|---|
| 368 | * @remark Displays <i>not available</i> if empty field.
|
|---|
| 369 | */
|
|---|
| 370 | function Odin32DBDocRow1($sName, $array, $sValueName)
|
|---|
| 371 | {
|
|---|
| 372 | PodNaslov($sName);
|
|---|
| 373 | if (isset($array[$sValueName]))
|
|---|
| 374 | {
|
|---|
| 375 | echo $array[$sValueName];
|
|---|
| 376 | }
|
|---|
| 377 | else
|
|---|
| 378 | echo "<i>not available</i>";
|
|---|
| 379 | }
|
|---|
| 380 |
|
|---|
| 381 | ?>
|
|---|
| 382 |
|
|---|