source: trunk/tools/database/www/Odin32DBHelpers.php3@ 10366

Last change on this file since 10366 was 6678, checked in by bird, 24 years ago

reverse prev rev.

File size: 84.8 KB
Line 
1<?php
2
3/**
4 * Profiling function for mysql queries.
5 * @returns same as mysql_query
6 * @param $sSql SQL statement.
7 * @param $db Database connection.
8 * @sketch
9 * Get time.
10 * Execute query.
11 * Get time.
12 * Calc time ellapsed.
13 * Start a HTML comment.
14 * Log time and sql statement in the HTML comment.
15 * EXPLAIN sql statement and log it in the HTML comment.
16 * End the HTML comment.
17 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
18 */
19function _mysql_query($sSql, $db)
20{
21 $sMsStart = microtime();
22
23 $Result = mysql_query($sSql, $db);
24
25 $sMsEnd = microtime();
26
27 /*
28 * Format: 0.mmmmmmmm sssssssss
29 * 0.00322252 965056018
30 *
31 * 01234567890123456789
32 * 0 1
33 */
34 $sMsStart = substr($sMsStart,11) . substr($sMsStart,1,9);
35 $sMsEnd = substr($sMsEnd,11) . substr($sMsEnd,1,9);
36 $sMsTime = (double)$sMsEnd - (double)$sMsStart;
37
38 echo
39 "\n<!-- start: $sMsStart end: $sMsEnd time: $sMsTime".
40 "\nSQL:\n".
41 $sSql.
42 "\n".
43 "rows: ". mysql_num_rows($Result) ."\n";
44
45 $ResultExplain = mysql_query("EXPLAIN ".$sSql, $db);
46 if ($ResultExplain)
47 {
48 echo "Explain:\n";
49 printf("%-15s %-17 %-20s %-12s %-10s %-20s %-8s %s\n",
50 "Table",
51 "Type",
52 "Possible keys",
53 "Key",
54 "Key length",
55 "Ref",
56 "Rows",
57 "Extra");
58
59 while ($aExplain = mysql_fetch_array($ResultExplain))
60 {
61 printf("%-15s %-17 %-20s %-12s %-10s %-20s %-8s %s\n",
62 isset($aExplain["0"]) ? $aExplain["0"] : "NULL",
63 isset($aExplain["1"]) ? $aExplain["1"] : "NULL",
64 isset($aExplain["2"]) ? $aExplain["2"] : "NULL",
65 isset($aExplain["3"]) ? $aExplain["3"] : "NULL",
66 isset($aExplain["4"]) ? $aExplain["4"] : "NULL",
67 isset($aExplain["5"]) ? $aExplain["5"] : "NULL",
68 isset($aExplain["6"]) ? $aExplain["6"] : "NULL",
69 isset($aExplain["7"]) ? $aExplain["7"] : "NULL");
70 }
71 mysql_free_result($ResultExplain);
72 }
73 else
74 echo "\nexplain failed\n";
75
76 echo "-->\n";
77
78 return $Result;
79}
80
81
82/**
83 * Starts a timer. Writes a nag in the file.
84 * @returns
85 * @param $sText Log text.
86 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
87 */
88function Odin32DBTimerStart($sText)
89{
90 $sMsStart = microtime();
91 $sMsStart = substr($sMsStart,11) . substr($sMsStart,1,9);
92 echo "\n<!-- Timer started: $sMsStart $sText -->\n";
93 return $sMsStart.$sText;
94}
95
96
97/**
98 * Stops the timer $sMsStart. And writes the elapsed time.
99 * @returns Nothing.
100 * @param $sTimer The timer handle returned by Odin32DBTimerStart.
101 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
102 */
103function Odin32DBTimerStop($sTimer)
104{
105 $sMsEnd = microtime();
106 $sMsEnd = substr($sMsEnd,11) . substr($sMsEnd,1,9);
107 $sMsStart= substr($sTimer,0,18);
108 $sMsTime = (double)$sMsEnd - (double)$sMsStart;
109 $sText = substr($sTimer,18);
110 echo "\n<!-- Timer stopped: $sMsEnd ($sMsStart) Elapsed: $sMsTime $sText -->\n";
111}
112
113
114/**
115 * Compute completion percentage for a dll.
116 * @returns Completion percentage. Range 0-100.
117 * On error -1 or -2 is returned.
118 * @param $iDll Dll reference code.
119 * @param $db Database connection variable.
120 * @sketch Get total number of function in the dll.
121 * Get number of completed functions in the dll.
122 * return complete*100 / total
123 * @status Completely implemented
124 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
125 * @remark
126 */
127function Odin32DBComputeCompletion($iDll, $db)
128{
129 /*
130 * Count the total number of functions in the DLL.
131 */
132 $sql = sprintf("SELECT SUM(s.weight)/COUNT(f.state)
133 FROM
134 function f,
135 state s
136 WHERE
137 f.state = s.refcode
138 AND dll = %d",
139 $iDll);
140 if (($result = mysql_query($sql, $db)) && mysql_num_rows($result) < 1)
141 {
142 echo "<br>Odin32DBComputeCompletion: IPE no. 1 <br>";
143 return -1;
144 }
145 $row = mysql_fetch_row($result);
146 $iComplete = $row[0];
147 mysql_free_result($result);
148}
149
150
151/**
152 * Draws a completion bar for a Function.
153 * @param $iFunction Function reference code.
154 * @param $iFunctionName Function name.
155 * @param $db Database connection variable.
156 * @sketch Call Odin32DBCompletionBar2 with an appropriate condition.
157 * @status Completely implemented
158 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
159 */
160function Odin32DBCompletionBarFunction($iFunction, $sFunctionName, $db)
161{
162 return Odin32DBcompletionBar2("refcode = ".$iFunction, $sFunctionName, $db);
163}
164
165
166/**
167 * Draws a completion bar for a dll (or all dlls).
168 * @param $iDll Dll reference code.
169 * If < 0 then for the entire project.
170 * @param $iDllName Dll name.
171 * @param $db Database connection variable.
172 * @sketch Call Odin32DBCompletionBar2 with an appropriate condition.
173 * @status Completely implemented
174 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
175 */
176function Odin32DBCompletionBarDll($iDll, $sDllName, $db)
177{
178 if ($iDll < 0)
179 return Odin32DBcompletionBar2("", $sDllName, $db);
180 return Odin32DBcompletionBar2("dll = ".$iDll, $sDllName, $db);
181}
182
183/**
184 * Draws a completion bar for a File.
185 * @param $iFile File reference code.
186 * @param $iFileName File name.
187 * @param $db Database connection variable.
188 * @sketch Call Odin32DBCompletionBar2 with an appropriate condition.
189 * @status Completely implemented
190 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
191 */
192function Odin32DBCompletionBarFile($iFile, $sFileName, $db)
193{
194 return Odin32DBcompletionBar2("file = ".$iFile, $sFileName, $db);
195}
196
197/**
198 * Draws a completion bar for an API Group.
199 * @param $iAPIGroup API Group reference code.
200 * @param $iAPIGroupName API Group name.
201 * @param $db Database connection variable.
202 * @sketch Call Odin32DBCompletionBar2 with an appropriate condition.
203 * @status Completely implemented
204 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
205 */
206function Odin32DBCompletionBarAPIGroup($iAPIGroup, $sAPIGroupName, $db)
207{
208 return Odin32DBcompletionBar2("apigroup = ".$iAPIGroup, $sAPIGroupName, $db);
209}
210
211/**
212 * Draws a completion bar for an Author.
213 * @param $iAuthor Author reference code.
214 * @param $iAuthorName Author name.
215 * @param $db Database connection variable.
216 * @sketch Call Odin32DBCompletionBar2 with an appropriate condition.
217 * @status Completely implemented
218 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
219 */
220function Odin32DBCompletionBarAuthor($iAuthor, $sAuthorName, $db)
221{
222 /*
223 * Count the total number of functions in the DLL.
224 */
225 $sql = "SELECT COUNT(*) FROM fnauthor fa JOIN function f\n".
226 "WHERE fa.function = f.refcode AND fa.author = ".$iAuthor;
227 if (($result = mysql_query($sql, $db)) && mysql_num_rows($result) < 1)
228 {
229 printf("\n\n<br>Odin32DBCompletionBar2: IPE(1).<br>\n\n");
230 return -1;
231 }
232 $row = mysql_fetch_row($result);
233 $cFunctions = $row[0];
234 mysql_free_result($result);
235
236
237 /*
238 * Make
239 */
240 echo "\n<table width=100% border=0 cellspacing=0 cellpadding=0>";
241 if ($sAuthorName != '')
242 echo " <tr><td width=90%><font size=-1 color=#000099><tt>".$sAuthorName."</tt></font></td><td width=10%></td></tr>\n";
243 echo " <tr><td width=90%>\n".
244 " <table width=100% border=0 cellspacing=0 cellpadding=0>\n".
245 " <tr>\n";
246
247 /*
248 * Get states and make bar.
249 */
250 $sql = "SELECT\n".
251 " COUNT(f.refcode) AS count,\n".
252 " s.refcode AS state,\n".
253 " s.color AS color,\n".
254 " s.weight AS weight\n".
255 "FROM\n".
256 " fnauthor fa,\n".
257 " function f,\n".
258 " state s\n".
259 "WHERE\n".
260 " fa.author = ".$iAuthor." AND\n".
261 " fa.function = f.refcode AND\n".
262 " f.state = s.refcode\n".
263 "GROUP BY s.refcode\n".
264 "ORDER BY state\n";
265 $rdCompletePercent = 0.0;
266 if (!($result = mysql_query($sql, $db)))
267 Odin32DBSqlError($sql);
268 else if (mysql_num_rows($result) < 1)
269 echo " <td colspan=2 bgcolor=#dddddd><font size=-1>&nbsp;</font></td>\n";
270 else
271 {
272 while ($row = mysql_fetch_row($result))
273 {
274 $iPercent = (int)($row[0] * 90 /* 10% is reserved to % */ / $cFunctions);
275 if ($iPercent == 0)
276 $iPercent = 1;
277 echo " <td width=".$iPercent." bgcolor=".$row[2]."><font size=-1>&nbsp;</font></td>\n";
278
279 $rdCompletePercent += ((double)$row[3] * (double)$row[0]) / $cFunctions;
280 }
281
282 }
283 mysql_free_result($result);
284
285 /*
286 * Complete bar with a total completion percent.
287 */
288 echo " <td width=10% align=right><font size=-1 color=#000099>".(int)$rdCompletePercent."%</font></td>\n".
289 " </tr>\n".
290 " </table>\n".
291 "</td></tr>\n".
292 "</table>\n";
293}
294
295/**
296 * Draws a completion bar.
297 * @param $iDll Dll reference code.
298 * If < 0 then for the entire project.
299 * @param $db Database connection variable.
300 * @sketch Get total number of function in the dll.
301 * Get the number of function per status. (+state color)
302 * Draw bar.
303 * @status Completely implemented
304 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
305 */
306function Odin32DBCompletionBar2($sCondition, $sName, $db)
307{
308 /*
309 * Count the total number of functions in the DLL.
310 */
311 $sql = "SELECT COUNT(*) FROM function f";
312 if ($sCondition != "") $sql = $sql." WHERE f.".$sCondition;
313 if (($result = mysql_query($sql, $db)) && mysql_num_rows($result) < 1)
314 {
315 printf("\n\n<br>Odin32DBCompletionBar2: IPE(1).<br>\n\n");
316 Odin32DBSqlError($sql);
317 return -1;
318 }
319 $row = mysql_fetch_row($result);
320 $cFunctions = $row[0];
321 mysql_free_result($result);
322
323
324 /*
325 * Double table. Eventually write the name.
326 */
327 echo "\n<table width=100% border=0 cellspacing=0 cellpadding=0>\n";
328 if ($sName != "")
329 echo "<tr><td width=90%><font size=-1 color=#000099><tt>".$sName."</tt></font></td><td width=10%></td></tr>\n";
330 echo "<tr><td width=90%>\n".
331 " <table width=100% border=0 cellspacing=0 cellpadding=0>\n".
332 " <tr>\n";
333
334 /*
335 * Get states and make bar.
336 */
337 if ($sCondition != "") $sCondition = "f.".$sCondition." AND";
338 $sql = "SELECT\n".
339 " COUNT(f.refcode) AS count,\n".
340 " s.refcode AS state,\n".
341 " s.color AS color,\n".
342 " s.weight AS weight\n".
343 "FROM\n".
344 " function f,\n".
345 " state s\n".
346 "WHERE\n".
347 " ".$sCondition."\n".
348 " s.refcode = f.state\n".
349 "GROUP BY s.refcode\n".
350 "ORDER BY state\n";
351 $rdCompletePercent = 0.0;
352 if (!($result = mysql_query($sql, $db)))
353 Odin32DBSqlError($sql);
354 else if (mysql_num_rows($result) < 1)
355 echo " <td colspan=2 bgcolor=#dddddd><font size=-1>&nbsp;</font></td>\n";
356 else
357 {
358 while ($row = mysql_fetch_row($result))
359 {
360 $iPercent = (int)($row[0] * 90 /* 10% is reserved to % */ / $cFunctions);
361 if ($iPercent == 0)
362 $iPercent = 1;
363 echo " <td width=".$iPercent." bgcolor=".$row[2]."><font size=-1>&nbsp;</font></td>\n";
364 $rdCompletePercent += ((double)$row[3] * (double)$row[0]) / $cFunctions;
365 }
366
367 }
368 mysql_free_result($result);
369
370 /*
371 * Complete bar with a total completion percent.
372 */
373 echo " <td width=10% align=right><font size=-1 color=#000099>".(int)$rdCompletePercent."%</font></td>\n".
374 " </tr>\n".
375 " </table>\n".
376 "</td></tr>\n".
377 "</table>\n";
378}
379
380
381/**
382 * Draws a legend for status colors.
383 * @param $db Database connection variable.
384 * @sketch Get status codes; fetch name and color.
385 *
386 *
387 * @status Completely implemented
388 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
389 */
390function Odin32DBStateLegend($db)
391{
392 /*
393 * Count the total number of functions in the DLL.
394 */
395 $sql = "SELECT
396 name,
397 color
398 FROM
399 state
400 ORDER BY refcode";
401 if (($result = mysql_query($sql, $db)) && mysql_num_rows($result) < 1)
402 {
403 printf("\n\n<br>Odin32DBStateLegned: IPE(1).<br>\n\n");
404 return -1;
405 }
406 else
407 {
408 echo "\n".
409 "<tr><td></td></tr>\n".
410 "<tr><td><center><B><font face=\"WarpSans, Arial\" color=\"#990000\">Status Legend:</font></b></center></td></tr>\n".
411 "<tr><td>\n".
412 " <table width=100% border=0 cellspacing=2 cellpadding=0 align=right>\n";
413
414 while ($row = mysql_fetch_row($result))
415 echo " <tr><td width=85% align=right><font size=1 color=#000099>".$row[0]."</font></td>\n".
416 " <td width=15% bgcolor=".$row[1]."><font size=-1>&nbsp;<br>&nbsp;</font></td>\n".
417 " </tr>\n";
418
419 echo " </table>\n".
420 "</td></tr>\n";
421 }
422
423
424 mysql_free_result($result);
425}
426
427
428/**
429 * Dump an SQL statement in HTML.
430 *
431 * @returns nothing.
432 * @param $sql Sql to display.
433 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
434 */
435function Odin32DBSqlError($sql)
436{
437 echo "<p><font size=1 face=\"courier\">
438 SQL-Error:<br>
439 ".mysql_error()."
440 <br>
441 </font>
442 </p>
443 ";
444
445 echo "<p><font size=1 face=\"courier\">
446 SQL:<br>
447 ".str_replace(" ", "&nbsp;", str_replace("\n", "<br>\n", $sql))."
448 <br>
449 </font>
450 </p>
451 ";
452}
453
454
455/**
456 *
457 * @returns
458 * @param $sName
459 * @param $array Result array.
460 * @param $sValueName Name in the $array for the value.
461 * @param $sRefName Name in the $array for the reference.
462 * @param $sOdin32DBArg Odin32DB.phtml argument.
463 * @param $sNullText Null text (if the array element is NULL display this).
464 * @param $sPostText Text to insert after the value.
465 *
466 */
467function Odin32DBInfoRow1($sName, $array, $sValueName, $sRefName, $sOdin32DBArg, $sNullText, $sPostText)
468{
469 echo " <tr>\n".
470 " <td width=35%><tt>".$sName."</tt></td>\n".
471 " <td valign=top>";
472 if (isset($array[$sValueName]))
473 {
474 if ($sRefName != "" && isset($array[$sRefName]) && $sOdin32DBArg != "")
475 {
476 echo "<a href=\"Odin32DB.phtml?".$sOdin32DBArg."=".$array[$sRefName]."\">";
477 $sPostText = "</a>".$sPostText;
478 }
479 echo $array[$sValueName];
480 echo $sPostText;
481 }
482 else if ($sNullText != "")
483 echo "<i>".$sNullText."</i>";
484
485 echo "</td>\n".
486 " </tr>\n";
487}
488
489
490/**
491 *
492 * @returns
493 * @param $sName
494 * @param $sValue Value.
495 * @param $sRef Reference.
496 * @param $sOdin32DBArg Odin32DB.phtml argument.
497 * @param $sNullText Null text (if the array element is NULL display this).
498 * @param $sPostText Text to insert after the value.
499 *
500 */
501function Odin32DBInfoRow1NoArray($sName, $sValue, $sRef, $sOdin32DBArg, $sNullText, $sPostText)
502{
503 echo " <tr>\n".
504 " <td width=35%><tt>".$sName."</tt></td>\n".
505 " <td valign=top>";
506 if (isset($sValue) && $sValue != "")
507 {
508 if (isset($sRef) && $sRef != "" && $sOdin32DBArg != "")
509 {
510 echo "<a href=\"Odin32DB.phtml?".$sOdin32DBArg."=".$sRef."\">";
511 $sPostText = "</a>".$sPostText;
512 }
513 echo $sValue.$sPostText;
514 }
515 else if ($sNullText != "")
516 echo "<i>".$sNullText."</i>";
517
518 echo "</td>\n".
519 " </tr>\n";
520}
521
522
523
524/**
525 *
526 * @returns
527 * @param $sName
528 * @param $array Result array.
529 * @param $sValueName1 Name in the $array for the value.
530 * @param $sRefName1 Name in the $array for the reference.
531 * @param $sOdin32DBArg1 Odin32DB.phtml argument.
532 * @param $sNullText Null text (if the array element is NULL display this).
533 * @param $sPostText Text to insert after the value.
534 * @param $sValueName2 Name in the $array for the value.
535 * @param $sRefName2 Name in the $array for the reference.
536 * @param $sOdin32DBArg2 Odin32DB.phtml argument.
537 *
538 */
539function Odin32DBInfoRow2($sName, $array, $sValueName1, $sRefName1, $sOdin32DBArg1, $sNullText, $sPostText,
540 $sValueName2, $sRefName2, $sOdin32DBArg2)
541{
542 echo " <tr>\n".
543 " <td width=35%><tt>".$sName."</tt></td>\n".
544 " <td valign=top>";
545 if (isset($array[$sValueName1]))
546 {
547 if ($sRefName1 != "" && isset($array[$sRefName1]) && $sOdin32DBArg1 != "")
548 {
549 echo "<a href=\"Odin32DB.phtml?".$sOdin32DBArg1."=".$array[$sRefName1]."\">";
550 $sPostText = "</a>".$sPostText;
551 }
552 echo $array[$sValueName1];
553 echo $sPostText;
554
555 if (isset($array[$sValueName2]))
556 {
557 if ($sRefName2 != "" && isset($array[$sRefName2]) && $sOdin32DBArg2 != "")
558 {
559 echo "<a href=\"Odin32DB.phtml?".$sOdin32DBArg2."=".$array[$sRefName2]."\">";
560 echo $array[$sValueName2]."</a>";
561 }
562 else
563 echo $array[$sValueName2];
564 }
565 }
566 else if ($sNullText != "")
567 echo "<i>".$sNullText."</i>";
568
569 echo "</td>\n".
570 " </tr>\n";
571}
572
573
574
575/**
576 * Inserts a documentation row from database..
577 * @param $sName Name of the information.
578 * @param $array DB result array.
579 * @param $sValueName Name in the DB result array.
580 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
581 * @remark Displays <i>not available</i> if empty field.
582 */
583function Odin32DBDocRow1($sName, $array, $sValueName)
584{
585 PodNaslov($sName);
586 if (isset($array[$sValueName]))
587 {
588 echo $array[$sValueName];
589 }
590 else
591 echo "<i>not available</i>";
592}
593
594
595/**
596 * Using (Odin32DB)Naslov.
597 * Inserts a documentation row from database..
598 * @param $sName Name of the information.
599 * @param $sLabel Section label.
600 * @param $array DB result array.
601 * @param $sValueName Name in the DB result array.
602 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
603 * @remark Displays <i>not available</i> if empty field.
604 */
605function Odin32DBDocRow($sName, $sLabel, $array, $sValueName)
606{
607 Odin32DBNaslov($sName, $sLabel);
608 if (isset($array[$sValueName]))
609 {
610 echo $array[$sValueName];
611 }
612 else
613 echo "<i>not available</i>";
614}
615
616
617/**
618 * Writes a state section based on a sqlstatment returning the following values (ordered):
619 * 0. state
620 * 1. functions
621 *
622 * @returns nothing.
623 * @param $cFunctions Number of functions.
624 * @param $sql Sql statement.
625 * @param $db Database connection.
626 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
627 */
628function Odin32DBWriteStates($cFunctions, $sql, $db)
629{
630 Odin32DBNaslov("Status", "status");
631 if ($result2 = mysql_query($sql, $db))
632 {
633 $result = mysql_query("SELECT refcode, name, color FROM state ORDER BY refcode", $db);
634 if ($result)
635 {
636 echo "\n<table width=100% border=0 cellpadding=0>\n";
637
638 $aState2 = mysql_fetch_array($result2);
639 while ($aState = mysql_fetch_row($result))
640 {
641 if ($aState2 && $aState[0] == $aState2[0])
642 {
643 $cStateFunctions = (int)$aState2[1];
644 $aState2 = mysql_fetch_array($result2);
645 }
646 else
647 $cStateFunctions = 0;
648 printf("<tr>\n".
649 " <td width=75%%><font size=-1 color=%s>%s</font></td>\n".
650 " <td align=right><font size=-1 color=%s>%s</font></td>\n".
651 " <td align=right><font size=-1 color=%s>%d%%</font></td>\n".
652 "</tr>\n",
653 $aState[2], $aState[1],
654 $aState[2], $cStateFunctions,
655 $aState[2], @(int)($cStateFunctions * 100 / $cFunctions));
656 }
657
658 echo "</table>\n";
659 }
660 else
661 Odin32DBSqlError($sql);
662 }
663 else
664 Odin32DBSqlError($sql);
665}
666
667
668/**
669 * Writes the a function listing base sqlstatement with these columns (ordered):
670 * 0. dll refcode
671 * 1. dll name
672 * 2. number of functions
673 *
674 * @returns nothing
675 * @param $sql SQL statement.
676 * @param $db Database connection.
677 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
678 */
679function Odin32DBWriteDlls($sql, $db)
680{
681 if ($result2 = mysql_query($sql, $db))
682 {
683 if (mysql_num_rows($result2) > 0)
684 {
685 echo "\n<table width=100% border=0 cellpadding=0>\n".
686 "<tr>\n".
687 " <td width=75%><font size=-1><b>Dlls</b></font></td>\n".
688 " <td align=right><font size=-1><b>Functions</b></font></td>\n".
689 "</tr>\n";
690 while ($aFunction = mysql_fetch_array($result2))
691 printf("<tr>".
692 "<td><font size=-1><a href=\"Odin32DB.phtml?dllrefcode=%s\">%s</a></font></td>".
693 "<td align=right><font size=-1>%s</font></td>".
694 "</tr>\n",
695 $aFunction[0], $aFunction[1], $aFunction[2]);
696
697 echo "</table>\n";
698 }
699 else
700 echo "<i>No Files.</i><br>\n";
701 }
702 else
703 Odin32DBSqlError($sql);
704}
705
706
707/**
708 * Writes the a function listing base sqlstatement with these columns (ordered):
709 * 0. function refcode
710 * 1. function name
711 * 2. state color
712 * 3. state name
713 *
714 * @returns nothing
715 * @param $sql SQL statement.
716 * @param $db Database connection.
717 * @param $sURLArgs URL arguments.
718 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
719 */
720function Odin32DBWriteFunctions($sql, $db, $sURLArgs)
721{
722 if ($result2 = mysql_query($sql, $db))
723 {
724 if (mysql_num_rows($result2) > 0)
725 {
726 echo
727 "<table width=100% border=0 cellpadding=0>\n",
728 "<tr>\n",
729 " <td width=75%><font size=-1><b>Function Name</b></font></td>\n",
730 " <td><font size=-1><b>State</b></font></td>\n",
731 "</tr>\n";
732
733 while ($aFunction = mysql_fetch_row($result2))
734 printf("<tr>".
735 "<td><font size=-1><a href=\"Odin32DB.phtml?functionrefcode=%s\">%s</a></font></td>".
736 "<td><font size=-1 color=%s>%s</font></td></tr>\n",
737 $aFunction[0], $aFunction[1], $aFunction[2], $aFunction[3]);
738
739 echo "</table></font>\n";
740
741 /*
742 * Sort text.
743 */
744 $fSortByState = strstr($sURLArgs, "&fSortByState=1");
745 if ($fSortByState)
746 $sURLArgs = str_replace("&fSortByState=1", "", $sURLArgs);
747 else
748 $sURLArgs = $sURLArgs."&fSortByState=1";
749
750 echo "<p>Click <a href=\"Odin32DB.phtml#functions?".$sURLArgs."\">here</a> to view functions sorted ".
751 ($fSortByState ? "alphabetical" : "by state"). ".<br>";
752 }
753 else
754 echo "<i>No Functions.</i><br>\n";
755 mysql_free_result($result2);
756 }
757 else
758 Odin32DBSqlError($sql);
759}
760
761
762/**
763 * Writes the a function listing base sqlstatement with these columns (ordered):
764 * 0. dll refcode
765 * 1. dll name
766 * 2. function refcode
767 * 3. function name
768 * 4. state color
769 * 5. state name
770 *
771 * @returns nothing
772 * @param $sql SQL statement.
773 * @param $db Database connection.
774 * @param $sURLArgs URL arguments.
775 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
776 */
777function Odin32DBWriteFunctionsWithDlls($sql, $db, $sURLArgs)
778{
779 if ($result2 = mysql_query($sql, $db))
780 {
781 if (mysql_num_rows($result2) > 0)
782 {
783 echo "\n<table width=100% border=0 cellpadding=0>\n".
784 "<tr>\n".
785 " <td width=30%><font size=-1><b>Dll Name</b></font></td>\n".
786 " <td width=45%><font size=-1><b>Function Name</b></font></td>\n".
787 " <td><font size=-1><b>State</b></font></td>\n".
788 "</tr>\n";
789 while ($aFunction = mysql_fetch_row($result2))
790 printf("<tr>".
791 "<td><font size=-1><a href=\"Odin32DB.phtml?dllrefcode=%s\">%s</a></font></td>".
792 "<td><font size=-1><a href=\"Odin32DB.phtml?functionrefcode=%s\">%s</a></font></td>".
793 "<td><font size=-1 color=%s>%s</font></td>".
794 "</tr>\n",
795 $aFunction[2], $aFunction[3],
796 $aFunction[0], $aFunction[1],
797 $aFunction[4], $aFunction[5]);
798
799 echo "</table>\n";
800
801 /*
802 * Sort text.
803 */
804 $fSortByState = strstr($sURLArgs, "&fSortByState=1");
805 if ($fSortByState)
806 $sURLArgs = str_replace("&fSortByState=1", "", $sURLArgs);
807 else
808 $sURLArgs = $sURLArgs."&fSortByState=1";
809
810 echo "<p>Click <a href=\"Odin32DB.phtml#functions?".$sURLArgs."\">here</a> to view functions sorted ".
811 ($fSortByState ? "alphabetical by dll" : "by state"). ".<br>";
812 }
813 else
814 echo "<i>No functions found</i><br>\n";
815 }
816 else
817 Odin32DBSqlError($sql);
818}
819
820
821/**
822 * Writes the a file listing base sqlstatement with these columns (ordered):
823 * 0. file refcode
824 * 1. file name
825 * 2. number of functions
826 *
827 * @returns nothing
828 * @param $sql SQL statement.
829 * @param $db Database connection.
830 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
831 */
832function Odin32DBWriteFiles($sql, $db)
833{
834 if ($result2 = mysql_query($sql, $db))
835 {
836 if (mysql_num_rows($result2) > 0)
837 {
838 echo "\n<table width=100% border=0 cellpadding=0>\n".
839 "<tr>\n".
840 " <td><font size=-1><b>Filename</b></font></td>\n".
841 " <td align=right><font size=-1><b>Functions</b></font></td>\n".
842 "</tr>\n";
843 while ($aFile = mysql_fetch_row($result2))
844 printf("<tr>".
845 "<td width=75%%><font size=-1><a href=\"Odin32DB.phtml?filerefcode=%s\">%s</a></font></td>".
846 "<td align=right><font size=-1>%s</font></td>".
847 "</tr>\n",
848 $aFile[0], $aFile[1], $aFile[2]);
849
850 echo "</table>\n";
851 }
852 else
853 echo "<i>No Files.</i><br>\n";
854 }
855 else
856 Odin32DBSqlError($sql);
857}
858
859
860/**
861 * Writes the an API Group listing base sqlstatement with these columns (ordered):
862 * 0. apigroup refcode
863 * 1. apigroup name
864 * 2. number of functions
865 *
866 * @returns nothing
867 * @param $sql SQL statement.
868 * @param $db Database connection.
869 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
870 */
871function Odin32DBWriteAPIGroups($sql, $db)
872{
873 if ($result2 = mysql_query($sql, $db))
874 {
875 if (mysql_num_rows($result2) > 0)
876 {
877 echo "\n<table width=100% border=0 cellpadding=0>\n".
878 "<tr>\n".
879 " <td width=75%><font size=-1><b>Group Name</b></font></td>\n".
880 " <td align=right><font size=-1><b>Functions</b></font></td>\n".
881 "</tr>\n";
882 while ($aAPIGroup = mysql_fetch_row($result2))
883 printf("<tr>".
884 "<td><font size=-1><a href=\"Odin32DB.phtml?apigrouprefcode=%s\">%s</a></font></td>".
885 "<td align=right><font size=-1>%s</font></td>".
886 "</tr>\n",
887 $aAPIGroup[0], $aAPIGroup[1], $aAPIGroup[2]);
888 echo "</table>\n";
889 }
890 else
891 echo "<i>No API Groups.</i><br>\n";
892 mysql_free_result($result2);
893 }
894 else
895 Odin32DBSqlError($sql);
896}
897
898
899
900/**
901 * Writes the a author listing base sqlstatement with these columns (ordered):
902 * 0. author refcode
903 * 1. author name
904 * 2. number of functions
905 *
906 * @returns nothing
907 * @param $sql SQL statement.
908 * @param $db Database connection.
909 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
910 */
911function Odin32DBWriteAuthors($sql, $db)
912{
913 if ($result2 = mysql_query($sql, $db))
914 {
915 if (mysql_num_rows($result2) > 0)
916 {
917 echo "\n<table width=100% border=0 cellpadding=0>\n".
918 "<tr>\n".
919 " <td width=75%><font size=-1><b>Author</b></font></td>\n".
920 " <td align=right><font size=-1><b>Functions</b></font></td>\n".
921 "</tr>\n";
922 while ($aAuthor = mysql_fetch_row($result2))
923 printf("<tr>".
924 "<td><font size=-1><a href=\"Odin32DB.phtml?authorrefcode=%s\">%s</a></font></td>".
925 "<td align=right><font size=-1>%s</font></td>".
926 "</tr>\n",
927 $aAuthor[0], $aAuthor[1], $aAuthor[2]);
928
929 echo "</table>\n";
930 }
931 else
932 echo "<i>No Authors</i>.<br>\n";
933 mysql_free_result($result2);
934 }
935 else
936 Odin32DBSqlError($sql);
937}
938
939
940/* NAVIGATION */
941/* NAVIGATION */
942/* NAVIGATION */
943
944/**
945 * Make top of page navigation stuff for the Odin32 database pages.
946 * @param $sExpand Expand arguments.
947 * @param $sCollapse Collapse arguments.
948 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
949 */
950function Odin32DBNavigationTop($sExpand, $sCollapse)
951{
952 echo "\n<center><font size=1>\n";
953
954 echo "<a href=\"Odin32DB.phtml\">Root</a>\n".
955 " - <a href=\"Odin32DB.phtml?dlls=1\">Dlls</a>\n".
956 " - <a href=\"Odin32DB.phtml?authors=1\">Authors</a>\n".
957 " - <a href=\"Odin32DB.phtml?apigroups=1\">API Groups</a>\n";
958
959 if ($sExpand != "" && $sCollapse != "")
960 {
961 echo "<br><a href=\"Odin32DB.phtml?".$sExpand."\">Expand All</a> - \n".
962 "<a href=\"Odin32DB.phtml?".$sCollapse."\">Collapse All</a>\n";
963 }
964
965 echo "</font></center>\n";
966}
967
968
969/**
970 * Make bottom of page navigation stuff for the Odin32 database pages.
971 * @param $sExpand Expand arguments.
972 * @param $sCollapse Collapse arguments.
973 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
974 */
975function Odin32DBNavigationBottom($sExpand, $sCollapse)
976{
977 echo "\n<p><br><center>\n".
978 "<font size=1>\n";
979
980 if ($sExpand != "" && $sCollapse != "")
981 {
982 echo "<a href=\"Odin32DB.phtml?".$sExpand."\">Expand All</a> - \n".
983 "<a href=\"Odin32DB.phtml?".$sCollapse."\">Collapse All</a><br>\n";
984 }
985
986 echo
987 "<a href=\"Odin32DB.phtml\">Root</a>\n".
988 " - <a href=\"Odin32DB.phtml?dlls=1\">Dlls</a>\n".
989 " - <a href=\"Odin32DB.phtml?authors=1\">Authors</a>\n".
990 " - <a href=\"Odin32DB.phtml?apigroups=1\">API Groups</a>\n";
991 echo "</font></center>\n";
992}
993
994
995
996/* INFO OUTPUT */
997/* INFO OUTPUT */
998/* INFO OUTPUT */
999
1000
1001/**
1002 * Writes standard function info.
1003 *
1004 * @returns void
1005 * @param $db Database handle.
1006 * @param $iRefcode Function reference code.
1007 * @sketch
1008 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
1009 * @remark
1010 */
1011function Odin32DBFunctionInfo($db, $iRefcode)
1012{
1013 Odin32DBNavigationTop("","");
1014
1015 $sql = sprintf("SELECT\n".
1016 " f.name AS name,\n".
1017 " f.intname AS intname,\n".
1018 " f.ordinal AS ordinal,\n".
1019 " f.return AS return,\n".
1020 " f.description AS description,\n".
1021 " f.remark AS remark,\n".
1022 " f.returndesc AS returndesc,\n".
1023 " f.sketch AS sketch,\n".
1024 " f.equiv AS equiv,\n".
1025 " f.time AS time,\n".
1026 " f.line AS line,\n".
1027 " g.name AS apigroupname,\n".
1028 " g.refcode AS apigrouprefcode,\n".
1029 " a.name AS aliasname,\n".
1030 " a.refcode AS aliasrefcode,\n".
1031 " ad.name AS aliasdllname,\n".
1032 " ad.refcode AS aliasdllrefcode,\n".
1033 " d.name AS dllname,\n".
1034 " d.refcode AS dllrefcode,\n".
1035 " i.name AS filename,\n".
1036 " i.refcode AS filerefcode,\n".
1037 " s.name AS state,\n".
1038 " c.description AS type\n".
1039 "FROM\n".
1040 " function f\n".
1041 " LEFT OUTER JOIN function a ON f.aliasfn = a.refcode\n".
1042 " LEFT OUTER JOIN dll ad ON a.dll = ad.refcode\n".
1043 " LEFT OUTER JOIN apigroup g ON f.apigroup = g.refcode\n".
1044 " LEFT JOIN dll d ON f.dll = d.refcode\n".
1045 " LEFT JOIN state s ON f.state = s.refcode\n".
1046 " LEFT OUTER JOIN file i ON f.file = i.refcode\n".
1047 " LEFT JOIN code c ON f.type = c.code\n".
1048 "WHERE\n".
1049 " c.codegroup = 'FTYP' AND\n".
1050 " f.refcode = %d",
1051 $iRefcode);
1052 if (($result = mysql_query($sql, $db)) && @mysql_num_rows($result) > 0 && ($array = mysql_fetch_array($result)))
1053 {
1054 /*
1055 * General
1056 */
1057 Odin32DBNaslov("General", "general");
1058 echo "\n<table width=100% border=3 cellpadding=0>\n";
1059 Odin32DBInfoRow1("Name", $array, "name","","","","");
1060 if (isset($array["intname"]))
1061 Odin32DBInfoRow1("Internal Name", $array, "intname","","","","");
1062 else
1063 Odin32DBInfoRow1("Internal Name", $array, "name","","","","");
1064 Odin32DBInfoRow1("Type", $array, "type", "", "","invalid","");
1065 Odin32DBInfoRow1("State", $array, "state", "", "","invalid","");
1066 Odin32DBInfoRow1("Dll", $array, "dllname", "dllrefcode", "dllrefcode","","");
1067 Odin32DBInfoRow1("Ordinal", $array, "ordinal","","","not available","");
1068 if (isset($array["apigroupname"]))
1069 Odin32DBInfoRow1("API Group", $array, "apigroupname", "apigrouprefcode", "apigrouprefcode","","");
1070 Odin32DBInfoRow1("File", $array, "filename", "filerefcode", "filerefcode", "not available",
1071 " (<a href=\"cvs.phtml#".$array["line"]."?sFile=./src/".$array["dllname"]."/".$array["filename"].",v&sRevision=\">cvs</a>)");
1072 if ($array["line"] > 0)
1073 Odin32DBInfoRow1("Line", $array, "line", "", "","","");
1074 else
1075 Odin32DBInfoRow1("Line", $array, "unavailable", "", "","not available","");
1076 if (isset($array["aliasrefcode"]))
1077 Odin32DBInfoRow2("Forwards", $array, "aliasdllname", "aliasdllrefcode", "dllrefcode","",".",
1078 "aliasname", "aliasrefcode", "functionrefcode");
1079 else
1080 {
1081 $sql = sprintf("SELECT\n".
1082 " d.name AS dllname,\n".
1083 " d.refcode AS dllrefcode,\n".
1084 " f.name AS fnname,\n".
1085 " f.refcode AS fnrefcode\n".
1086 "FROM\n".
1087 " function f,\n".
1088 " dll d\n".
1089 "WHERE\n".
1090 " f.aliasfn = %d AND\n".
1091 " f.dll = d.refcode\n".
1092 "ORDER BY d.name, f.name\n",
1093 $iRefcode);
1094 if (($result2 = mysql_query($sql, $db)))
1095 {
1096 if (mysql_num_rows($result2) > 0)
1097 {
1098 $sValue = "";
1099 $f = 0;
1100 while ($aAlias = mysql_fetch_array($result2))
1101 {
1102 if ($f) $sValue = $sValue."<br>";
1103 else $f = 1;
1104 $sValue = $sValue."<a href=\"Odin32DB.phtml?dllrefcode=".
1105 $aAlias["dllrefcode"]."\">".$aAlias["dllname"]."</a>.".
1106 "<a href=\"Odin32DB.phtml?functionrefcode=".
1107 $aAlias["fnrefcode"]."\">".$aAlias["fnname"]."</a>";
1108 }
1109 Odin32DBInfoRow1NoArray("Forwarded as", $sValue, "","","","");
1110 }
1111 }
1112 else
1113 Odin32DBSqlError($sql);
1114 }
1115 echo "</table>\n";
1116
1117 /*
1118 * Completion
1119 */
1120 Odin32DBNaslov("Completion", "completion");
1121 Odin32DBCompletionBarFunction($iRefcode, "", $db);
1122
1123
1124 /*
1125 * Declaration
1126 */
1127 Odin32DBNaslov("Declaration", "declaration");
1128 echo "\n<pre>";
1129 if (isset($array["return"]))
1130 echo $array["return"]." ";
1131 echo $array["name"]."(";
1132 $sql = sprintf("SELECT\n".
1133 " name AS name,\n".
1134 " type AS type,\n".
1135 " description AS description\n".
1136 "FROM\n".
1137 " parameter\n".
1138 "WHERE\n".
1139 " function = %d\n".
1140 "ORDER BY sequencenbr",
1141 $iRefcode);
1142 if (($result2 = mysql_query($sql, $db)) && ($cParams = mysql_num_rows($result2)) > 0)
1143 {
1144 while ($param = mysql_fetch_array($result2))
1145 {
1146 if (--$cParams == 0)
1147 printf("\n %-20s %s", $param["type"], $param["name"]);
1148 else
1149 printf("\n %-20s %s,", $param["type"], $param["name"]);
1150 }
1151 }
1152 else
1153 echo "void";
1154
1155 echo ");\n";
1156 echo "</pre>\n";
1157
1158 /*
1159 * Description
1160 */
1161 Odin32DBDocRow("Description", "desc", $array, "description");
1162
1163
1164 /*
1165 * Parameters
1166 */
1167 Odin32DBNaslov("Parameters", "params");
1168 if ($result2 && mysql_num_rows($result2) > 0 && mysql_data_seek($result2, 0))
1169 {
1170 while ($param = mysql_fetch_array($result2))
1171 {
1172 echo "\n<dt><b>".$param["name"].":</b></dt>\n";
1173 if (isset($param["description"]))
1174 {
1175 if (1)
1176 {
1177 echo "\n <table width=100% border=0 cellpadding=0>\n";
1178 echo " <tr><td width=10%>&nbsp;</td>\n";
1179 $sDescription = str_replace("<BR>", "", str_replace("<BR><BR>\n","<br>",$param["description"]));
1180 echo " <td width=90%><font size=-1>".$sDescription."</font></td></tr>\n";
1181 echo "</table>\n";
1182 }
1183 else
1184 {
1185 $sDescription = str_replace("<BR>", "", str_replace("<BR><BR>\n","<br>",$param["description"]));
1186 echo "<dd><font size=-1>".$sDescription."</font></dd>\n\n";
1187 }
1188 }
1189 echo "<p>\n";
1190 }
1191 }
1192 else
1193 echo "void";
1194
1195
1196 /*
1197 * Returns
1198 */
1199 Odin32DBDocRow("Returns", "return", $array, "returndesc");
1200
1201 /*
1202 * Sketch/Algorithm
1203 */
1204 Odin32DBDocRow("Sketch/Algorithm", "sketch", $array, "sketch");
1205
1206 /*
1207 * Remark
1208 */
1209 Odin32DBDocRow("Remarks", "remark", $array, "remark");
1210
1211 /*
1212 * Authors
1213 */
1214 Odin32DBNaslov("Authors", "Authors");
1215 $sql = sprintf("SELECT\n".
1216 " a.name AS name,\n".
1217 " a.refcode AS refcode\n".
1218 "FROM\n".
1219 " fnauthor fa\n".
1220 " JOIN function f\n".
1221 " JOIN author a\n".
1222 "WHERE\n".
1223 " f.refcode = %d AND\n".
1224 " fa.function = f.refcode AND\n".
1225 " fa.author = a.refcode\n".
1226 "ORDER BY a.name",
1227 $iRefcode);
1228 if (($result2 = mysql_query($sql, $db)) && mysql_num_rows($result2) > 0)
1229 {
1230 while ($author = mysql_fetch_array($result2))
1231 echo "<a href=\"Odin32DB.phtml?authorrefcode=".$author["refcode"]."\">".$author["name"]."</a><br>\n";
1232 }
1233 else
1234 echo "<i>Hmm. Seems noone wrote this function...</i><br>\n";
1235 }
1236 else
1237 {
1238 echo "<p> No data! Invalid refcode? </p>";
1239 Odin32DBSqlError($sql);
1240 }
1241 Odin32DBNavigationBottom("","");
1242}
1243
1244
1245
1246/**
1247 * Writes standard dll info.
1248 *
1249 * @returns void
1250 * @param $db Database handle.
1251 * @param $iRefcode Dll reference code.
1252 * @param $fFunctions Flags which tells wether to list all functions or not.
1253 * @param $fFiles Flags which tells wether to list all files or not.
1254 * @param $fAPIGroups Flags which tells wether to list all apigroups or not.
1255 * @param $fAuthors Flags which tells wether to list all authors or not.
1256 * @param $fSortByState Flags which tells wether to sort functions by
1257 * state and function name or just by function name.
1258 * @sketch
1259 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
1260 * @remark
1261 */
1262function Odin32DBDllInfo($db, $iRefcode, $fFunctions, $fFiles, $fAPIGroups, $fAuthors, $fSortByState)
1263{
1264 $sURLArgs = "dllrefcode=".$iRefcode.
1265 ($fFunctions ? "&fFunctions=1" : "").
1266 ($fFiles ? "&fFiles=1" : "").
1267 ($fAPIGroups ? "&fAPIGroups=1" : "").
1268 ($fAuthors ? "&fAuthors=1" : "").
1269 ($fSortByState ? "&fSortByState=1" : "");
1270
1271 /*
1272 * Navigation - TOP
1273 */
1274 $sExpand = "dllrefcode=".$iRefcode."&fFiles=1&fFunctions=1&fAPIGroups=1&fAuthors=1";
1275 if ($fSortByState) $sExpand = $sExpand."&fSortByState=".$fSortByState;
1276 $sCollapse = "dllrefcode=".$iRefcode;
1277 Odin32DBNavigationTop($sExpand, $sCollapse);
1278
1279 /*
1280 * Fetch (vital) data.
1281 */
1282 $sql = sprintf("SELECT\n".
1283 " d.name AS name,\n".
1284 " d.description AS description,\n".
1285 " c.description AS type\n".
1286 "FROM\n".
1287 " dll d,\n".
1288 " code c\n".
1289 "WHERE\n".
1290 " c.codegroup = 'DTYP' AND\n".
1291 " d.type = c.code AND\n".
1292 " d.refcode = %d",
1293 $iRefcode);
1294 if (($result = mysql_query($sql, $db)) && mysql_num_rows($result) > 0 && ($array = mysql_fetch_array($result)))
1295 {
1296 /*
1297 * General
1298 */
1299 Odin32DBNaslov("General", "general");
1300 echo "\n<table width=100% border=3 cellpadding=0>\n";
1301 Odin32DBInfoRow1("Name", $array, "name","","","","");
1302 Odin32DBInfoRow1("Description", $array, "description","","","","");
1303 Odin32DBInfoRow1("Type", $array, "type","","","","");
1304 $sql = sprintf("SELECT\n".
1305 " COUNT(*) as functions\n".
1306 "FROM\n".
1307 " function\n".
1308 "WHERE\n".
1309 " dll = %d",
1310 $iRefcode);
1311 $cFunctions = 0;
1312 if (($result2 = mysql_query($sql, $db)) && mysql_num_rows($result2) > 0 && ($array2 = mysql_fetch_array($result2)))
1313 {
1314 Odin32DBInfoRow1("# Functions", $array2, "functions","","","","");
1315 $cFunctions = $array2["functions"];
1316 }
1317
1318 $sql = sprintf("SELECT\n".
1319 " COUNT(*) as files\n".
1320 "FROM\n".
1321 " file\n".
1322 "WHERE\n".
1323 " dll = %d",
1324 $iRefcode);
1325 $cFiles = 0;
1326 if (($result2 = mysql_query($sql, $db)) && mysql_num_rows($result2) > 0 && ($array2 = mysql_fetch_array($result2)))
1327 {
1328 Odin32DBInfoRow1("# Source files", $array2, "files","","","","");
1329 $cFiles = $array2["files"];
1330 }
1331
1332 $sql = sprintf("SELECT\n".
1333 " COUNT(*) as apigroups\n".
1334 "FROM\n".
1335 " apigroup\n".
1336 "WHERE\n".
1337 " dll = %d",
1338 $iRefcode);
1339 $cAPIGroups = 0;
1340 if (($result2 = mysql_query($sql, $db)) && mysql_num_rows($result2) > 0 && ($array2 = mysql_fetch_array($result2)))
1341 {
1342 Odin32DBInfoRow1("# API Groups", $array2, "apigroups","","","","");
1343 $cAPIGroups = $array2["apigroups"];
1344 }
1345
1346 echo "</table>\n";
1347
1348
1349 /*
1350 * Completion
1351 */
1352 Odin32DBNaslov("Completion", "completion");
1353 Odin32DBCompletionBarDll($iRefcode, "", $db);
1354
1355 /*
1356 * States
1357 */
1358 $sql = sprintf("SELECT\n".
1359 " state,\n".
1360 " COUNT(state)\n".
1361 "FROM\n".
1362 " function\n".
1363 "WHERE\n".
1364 " dll = %d\n".
1365 "GROUP BY state\n".
1366 "ORDER BY state",
1367 $iRefcode);
1368 Odin32DBWriteStates($cFunctions, $sql, $db);
1369
1370 /*
1371 * Functions
1372 */
1373 Odin32DBNaslov("Functions", "functions");
1374 if ($fFunctions)
1375 {
1376 $sql = sprintf("SELECT\n".
1377 " f.refcode,\n".
1378 " f.name,\n".
1379 " s.color,\n".
1380 " s.name\n".
1381 "FROM\n".
1382 " function f\n".
1383 " LEFT JOIN state s ON f.state = s.refcode\n".
1384 "WHERE\n".
1385 " f.dll = %d\n",
1386 $iRefcode);
1387 if ($fSortByState)
1388 $sql = $sql."ORDER BY s.refcode, f.name";
1389 else
1390 $sql = $sql."ORDER BY f.name";
1391 Odin32DBWriteFunctions($sql, $db, $sURLArgs);
1392 }
1393 else
1394 echo "Click <a href=\"Odin32DB.phtml#functions?".$sURLArgs."&fFunctions=1".
1395 "\">here</a> to see all functions.\n";
1396
1397
1398 /*
1399 * Files
1400 */
1401 Odin32DBNaslov("Files", "files");
1402 if ($fFiles)
1403 {
1404 $sql = sprintf("SELECT\n".
1405 " f.refcode,\n".
1406 " f.name,\n".
1407 " COUNT(fn.refcode)\n".
1408 "FROM\n".
1409 " file f\n".
1410 " LEFT OUTER JOIN function fn ON fn.file = f.refcode\n".
1411 "WHERE\n".
1412 " f.dll = %d\n".
1413 "GROUP BY f.refcode\n".
1414 "ORDER BY f.name\n",
1415 $iRefcode);
1416 Odin32DBWriteFiles($sql, $db);
1417 }
1418 else
1419 echo "Click <a href=\"Odin32DB.phtml#files?".$sURLArgs."&fFiles=1".
1420 "\">here</a> to see all files.\n";
1421
1422
1423 /*
1424 * API Groups
1425 */
1426 if ($cAPIGroups > 0)
1427 {
1428 Odin32DBNaslov("API Groups", "apigroups");
1429 if ($fAPIGroups)
1430 {
1431 $sql = sprintf("SELECT\n".
1432 " g.refcode,\n".
1433 " g.name,\n".
1434 " COUNT(f.refcode)\n".
1435 "FROM\n".
1436 " apigroup g\n".
1437 " JOIN function f\n".
1438 "WHERE\n".
1439 " g.dll = %d AND\n".
1440 " f.dll = %d AND\n".
1441 " f.apigroup = g.refcode\n".
1442 "GROUP BY f.apigroup\n".
1443 "ORDER BY g.name\n",
1444 $iRefcode,
1445 $iRefcode);
1446 Odin32DBWriteAPIGroups($sql, $db);
1447 }
1448 else
1449 echo "Click <a href=\"Odin32DB.phtml#apigroups?".$sURLArgs."&fAPIGroups=1".
1450 "\">here</a> to see all the API Groups.\n";
1451 }
1452
1453
1454 /*
1455 * Authors
1456 */
1457 Odin32DBNaslov("Authors", "authors");
1458 if ($fAuthors)
1459 {
1460 $sql = sprintf("SELECT\n".
1461 " a.refcode,\n".
1462 " a.name,\n".
1463 " COUNT(f.refcode)\n".
1464 "FROM\n".
1465 " fnauthor fa\n".
1466 " JOIN function f\n".
1467 " JOIN author a\n".
1468 "WHERE\n".
1469 " f.dll = %d AND\n".
1470 " fa.function = f.refcode AND\n".
1471 " fa.author = a.refcode\n".
1472 "GROUP BY a.refcode\n".
1473 "ORDER BY a.name\n",
1474 $iRefcode);
1475 Odin32DBWriteAuthors($sql, $db);
1476 }
1477 else
1478 echo "Click <a href=\"Odin32DB.phtml#authors?".$sURLArgs."&fAuthors=1".
1479 "\">here</a> to see all authors.\n";
1480 }
1481 else
1482 {
1483 echo "<p> No data! Invalid refcode? </p>";
1484 Odin32DBSqlError($sql);
1485 }
1486
1487 /*
1488 * Navigation - Bottom
1489 */
1490 Odin32DBNavigationBottom($sExpand, $sCollapse);
1491}
1492
1493
1494
1495/**
1496 * Writes standard file info.
1497 *
1498 * @returns void
1499 * @param $db Database handle.
1500 * @param $iRefcode File reference code.
1501 * @param $fFunctions Flags which tells wether to list all functions or not.
1502 * @param $fAPIGroups Flags which tells wether to list all apigroups or not.
1503 * @param $fAuthors Flags which tells wether to list all authors or not.
1504 * @param $fSortByState Flags which tells wether to sort functions by
1505 * state and function name or just by function name.
1506 * @sketch
1507 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
1508 * @remark
1509 */
1510function Odin32DBFileInfo($db, $iRefcode, $fFunctions, $fAPIGroups, $fAuthors, $fSortByState)
1511{
1512 $sURLArgs = "filerefcode=".$iRefcode.
1513 ($fFunctions ? "&fFunctions=1" : "").
1514 ($fAuthors ? "&fAuthors=1" : "").
1515 ($fAPIGroups ? "&fAPIGroups=1" : "").
1516 ($fSortByState ? "&fSortByState=1" : "");
1517
1518 /*
1519 * Navigation - TOP
1520 */
1521 $sExpand = "filerefcode=".$iRefcode."&fFiles=1&fFunctions=1&fAPIGroups=1&fAuthors=1";
1522 if ($fSortByState) $sExpand = $sExpand."&fSortByState=".$fSortByState;
1523 $sCollapse = "filerefcode=".$iRefcode;
1524 Odin32DBNavigationTop($sExpand, $sCollapse);
1525
1526 /*
1527 * Fetch (vital) data.
1528 */
1529 $sql = sprintf("SELECT\n".
1530 " f.name AS name,\n".
1531 " f.refcode AS refcode,\n".
1532 " f.lastdatetime AS lastdatetime,\n".
1533 " a.name AS lastauthorname,\n".
1534 " f.lastauthor AS lastauthorrefcode,\n".
1535 " f.revision AS revision,\n".
1536 " f.description AS description,\n".
1537 " f.dll AS dllrefcode,\n".
1538 " d.name AS dllname\n".
1539 "FROM\n".
1540 " file f,\n".
1541 " dll d,\n".
1542 " author a\n".
1543 "WHERE\n".
1544 " f.refcode = %d AND\n".
1545 " f.dll = d.refcode AND\n".
1546 " f.lastauthor= a.refcode",
1547 $iRefcode);
1548 if (($result = mysql_query($sql, $db)) && mysql_num_rows($result) > 0 && ($array = mysql_fetch_array($result)))
1549 {
1550 /*
1551 * General
1552 */
1553 Odin32DBNaslov("General", "general");
1554 echo "\n<table width=100% border=3 cellpadding=0>\n";
1555 Odin32DBInfoRow1("Name", $array, "name","","","",
1556 " (<a href=\"cvs.phtml?sFile=./src/".$array["dllname"]."/".$array["name"].",v&sRevision=\">cvs</a>)");
1557 Odin32DBInfoRow1("Revision", $array, "revision","","","","");
1558 Odin32DBInfoRow1("Changed", $array, "lastdatetime","","","","");
1559 Odin32DBInfoRow1("Last Author", $array, "lastauthorname","lastauthorrefcode","authorrefcode","","");
1560 Odin32DBInfoRow1("Dll", $array, "dllname","dllrefcode","dllrefcode","","");
1561 $sql = sprintf("SELECT\n".
1562 " COUNT(*) as functions\n".
1563 "FROM\n".
1564 " function\n".
1565 "WHERE\n".
1566 " file = %d",
1567 $iRefcode);
1568 $cFunctions = 0;
1569 if (($result2 = mysql_query($sql, $db)) && mysql_num_rows($result2) > 0 && ($aFunctions = mysql_fetch_array($result2)))
1570 {
1571 Odin32DBInfoRow1("# Functions", $aFunctions, "functions","","","","");
1572 $cFunctions = $aFunctions["functions"];
1573 }
1574
1575 $sql = sprintf("SELECT\n".
1576 " COUNT(*) as functions\n".
1577 "FROM\n".
1578 " function\n".
1579 "WHERE\n".
1580 " file = %d AND\n".
1581 " apigroup IS NOT NULL\n".
1582 "GROUP BY apigroup\n",
1583 $iRefcode);
1584 $cAPIGroups = 0;
1585 if (($result2 = mysql_query($sql, $db)) && ($cAPIGroups = mysql_num_rows($result2)) > 0)
1586 Odin32DBInfoRow1NoArray("# API Groups", $cAPIGroups, "","","","");
1587 if (!$result2)
1588 Odin32DBSqlError($sql);
1589
1590 echo "</table>\n";
1591
1592 /*
1593 * Description
1594 */
1595 Odin32DBDocRow("Description", "description", $array, "description");
1596
1597 /*
1598 * Completion
1599 */
1600 Odin32DBNaslov("Completion", "completion");
1601 Odin32DBCompletionBarFile($iRefcode, "", $db);
1602
1603 /*
1604 * States
1605 */
1606 $sql = sprintf("SELECT\n".
1607 " state,\n".
1608 " COUNT(state)\n".
1609 "FROM\n".
1610 " function\n".
1611 "WHERE\n".
1612 " file = %d\n".
1613 "GROUP BY state\n".
1614 "ORDER BY state",
1615 $iRefcode);
1616 Odin32DBWriteStates($cFunctions, $sql, $db);
1617
1618
1619 /*
1620 * Functions
1621 */
1622 Odin32DBNaslov("Functions", "functions");
1623 if ($fFunctions)
1624 {
1625 $sql = sprintf("SELECT\n".
1626 " f.refcode,\n".
1627 " f.name,\n".
1628 " s.color,\n".
1629 " s.name\n".
1630 "FROM\n".
1631 " function f\n".
1632 " LEFT JOIN state s ON f.state = s.refcode\n".
1633 "WHERE\n".
1634 " f.file = %d\n",
1635 $iRefcode);
1636 if ($fSortByState)
1637 $sql = $sql."ORDER BY s.refcode, f.name";
1638 else
1639 $sql = $sql."ORDER BY f.name";
1640 Odin32DBWriteFunctions($sql, $db, $sURLArgs);
1641 }
1642 else
1643 echo "Click <a href=\"Odin32DB.phtml#functions?".$sURLArgs."&fFunctions=1".
1644 "\">here</a> to see all functions.\n";
1645
1646
1647 /*
1648 * API Groups
1649 */
1650 if ($cAPIGroups > 0)
1651 {
1652 Odin32DBNaslov("API Groups", "apigroups");
1653 if ($fAPIGroups)
1654 {
1655 $sql = sprintf("SELECT\n".
1656 " g.refcode,\n".
1657 " g.name,\n".
1658 " COUNT(f.refcode)\n".
1659 "FROM\n".
1660 " apigroup g\n".
1661 " JOIN function f\n".
1662 "WHERE\n".
1663 " f.file = %d AND\n".
1664 " f.apigroup = g.refcode\n".
1665 "GROUP BY f.apigroup\n".
1666 "ORDER BY g.name\n",
1667 $iRefcode);
1668 Odin32DBWriteAPIGroups($sql, $db);
1669 }
1670 else
1671 echo "Click <a href=\"Odin32DB.phtml#apigroups?".$sURLArgs."&fAPIGroups=1".
1672 "\">here</a> to see all the API Groups.\n";
1673 }
1674
1675
1676 /*
1677 * Authors
1678 */
1679 Odin32DBNaslov("Authors", "authors");
1680 if ($fAuthors)
1681 {
1682 $sql = sprintf("SELECT\n".
1683 " a.refcode,\n".
1684 " a.name,\n".
1685 " COUNT(f.refcode)\n".
1686 "FROM\n".
1687 " fnauthor fa\n".
1688 " JOIN function f\n".
1689 " JOIN author a\n".
1690 "WHERE\n".
1691 " f.file = %d AND\n".
1692 " fa.function = f.refcode AND\n".
1693 " fa.author = a.refcode\n".
1694 "GROUP BY a.refcode\n".
1695 "ORDER BY a.name\n",
1696 $iRefcode
1697 );
1698 Odin32DBWriteAuthors($sql, $db);
1699 }
1700 else
1701 echo "Click <a href=\"Odin32DB.phtml#authors?".$sURLArgs."&fAuthors=1".
1702 "\">here</a> to see all authors.\n";
1703 }
1704 else
1705 {
1706 echo "<p> No data! Invalid refcode? </p>";
1707 Odin32DBSqlError($sql);
1708 }
1709
1710 /*
1711 * Navigation - Bottom
1712 */
1713 Odin32DBNavigationBottom($sExpand, $sCollapse);
1714}
1715
1716
1717
1718/**
1719 * Writes standard file info.
1720 *
1721 * @returns void
1722 * @param $db Database handle.
1723 * @param $iRefcode Author reference code.
1724 * @param $fDlls Flags which tells wether to list all dlls or not.
1725 * @param $fFunctions Flags which tells wether to list all functions or not.
1726 * @param $fFiles Flags which tells wether to list all files or not.
1727 * @param $fAPIGroups Flags which tells wether to list all apigroups or not.
1728 * @param $fSortByState Flags which tells wether to sort functions by
1729 * state and function name or just by function name.
1730 * @param $iDllRefcode Dll refcode. All Dll if < 0.
1731 * (not implemented yet)
1732 * @sketch
1733 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
1734 * @remark
1735 */
1736function Odin32DBAuthorInfo($db, $iRefcode, $fDlls, $fFunctions, $fFiles, $fAPIGroups, $fSortByState, $iDllRefcode)
1737{
1738 $sURLArgs = "authorrefcode=".$iRefcode.
1739 ($fDlls ? "&fDlls=1" : "").
1740 ($fFunctions ? "&fFunctions=1" : "").
1741 ($fFiles ? "&fFiles=1" : "").
1742 ($fAPIGroups ? "&fAPIGroups=1" : "").
1743 ($fSortByState ? "&fSortByState=1" : "");
1744
1745 /*
1746 * Navigation - TOP
1747 */
1748 $sExpand = "authorrefcode=".$iRefcode."&fDlls=1&fFiles=1&fFunctions=1&fAPIGroups=1&fAuthors=1&dll=".$iDllRefcode;
1749 if ($fSortByState) $sExpand = $sExpand."&fSortByState=".$fSortByState;
1750 $sCollapse = "authorrefcode=".$iRefcode;
1751 Odin32DBNavigationTop($sExpand, $sCollapse);
1752
1753 /*
1754 * Fetch (vital) data.
1755 */
1756 $sql = sprintf("SELECT\n".
1757 " a.name AS name,\n".
1758 " a.refcode AS refcode,\n".
1759 " a.initials AS initials,\n".
1760 " a.alias AS alias,\n".
1761 " a.email AS email,\n".
1762 " a.country AS country,\n".
1763 " a.location AS location,\n".
1764 " a.description AS description\n".
1765 "FROM\n".
1766 " author a\n".
1767 "WHERE\n".
1768 " a.refcode = %d",
1769 $iRefcode);
1770 if (($result = mysql_query($sql, $db)) && mysql_num_rows($result) > 0 && ($array = mysql_fetch_array($result)))
1771 {
1772 /*
1773 * General
1774 */
1775 Odin32DBNaslov("General", "general");
1776 echo "\n<table width=100% border=3 cellpadding=0>\n";
1777 Odin32DBInfoRow1("Name", $array, "name","","","","");
1778 Odin32DBInfoRow1("e-mail", $array, "email","","","",""); //???? should all authors have email address displayed?
1779 Odin32DBInfoRow1("CVS User", $array, "alias","","","","");
1780 Odin32DBInfoRow1("Country", $array, "country","","","","");
1781 Odin32DBInfoRow1("Location", $array, "location","","","","");
1782 if (isset($array["description"]))
1783 Odin32DBInfoRow1("Description", $array, "description","","","","");
1784 $sql = sprintf("SELECT\n".
1785 " COUNT(*) as functions\n".
1786 "FROM\n".
1787 " fnauthor\n".
1788 "WHERE\n".
1789 " author = %d",
1790 $iRefcode);
1791 $cFunctions = 0;
1792 if (($result2 = mysql_query($sql, $db)) && mysql_num_rows($result2) > 0 && ($aFunctions = mysql_fetch_array($result2)))
1793 {
1794 Odin32DBInfoRow1("# Functions", $aFunctions, "functions","","","","");
1795 $cFunctions = $aFunctions["functions"];
1796 }
1797 $sql = sprintf("SELECT\n".
1798 " COUNT(f.dll) as functions
1799 \n".
1800 "FROM\n".
1801 " fnauthor fa,\n".
1802 " function f\n".
1803 "WHERE\n".
1804 " fa.author = %d AND".
1805 " f.refcode = fa.function\n".
1806 "GROUP BY f.dll",
1807 $iRefcode);
1808 $cDlls = 0;
1809 if (($result2 = mysql_query($sql, $db)) && ($cDlls = mysql_num_rows($result2)) > 0)
1810 Odin32DBInfoRow1NoArray("# Dlls", $cDlls, "","","","");
1811 $sql = sprintf("SELECT\n".
1812 " COUNT(f.dll) as functions
1813 \n".
1814 "FROM\n".
1815 " fnauthor fa,\n".
1816 " function f\n".
1817 "WHERE\n".
1818 " fa.author = %d AND".
1819 " f.file >= 0 AND".
1820 " f.refcode = fa.function \n".
1821 "GROUP BY f.file",
1822 $iRefcode);
1823 $cFiles = 0;
1824 if (($result2 = mysql_query($sql, $db)) && ($cFiles = mysql_num_rows($result2)) > 0)
1825 Odin32DBInfoRow1NoArray("# Files", $cFiles, "","","","");
1826 $sql = sprintf("SELECT\n".
1827 " COUNT(f.dll) as functions
1828 \n".
1829 "FROM\n".
1830 " fnauthor fa,\n".
1831 " function f\n".
1832 "WHERE\n".
1833 " fa.author = %d AND".
1834 " f.apigroup IS NOT NULL AND".
1835 " f.refcode = fa.function\n".
1836 "GROUP BY f.apigroup",
1837 $iRefcode);
1838 $cAPIGroups = 0;
1839 if (($result2 = mysql_query($sql, $db)) && ($cAPIGroups = mysql_num_rows($result2)) > 0)
1840 Odin32DBInfoRow1NoArray("# API Groups", $cAPIGroups, "","","","");
1841
1842 echo "</table>\n";
1843
1844 /*
1845 * Completion
1846 */
1847 Odin32DBNaslov("Completion", "completion");
1848 Odin32DBCompletionBarAuthor($iRefcode, "", $db);
1849
1850 /*
1851 * States
1852 */
1853 //TODO: optimize this further.
1854 $sql = sprintf("SELECT\n".
1855 " f.state,\n".
1856 " COUNT(f.refcode)\n".
1857 "FROM\n".
1858 " function f,\n".
1859 " fnauthor fa\n".
1860 "WHERE\n".
1861 " fa.author = %d AND\n".
1862 " fa.function = f.refcode\n".
1863 "GROUP BY f.state\n".
1864 "ORDER BY f.state",
1865 $iRefcode);
1866 Odin32DBWriteStates($cFunctions, $sql, $db);
1867
1868 /*
1869 * Dlls
1870 */
1871 Odin32DBNaslov("Dlls", "dlls");
1872 if ($fDlls)
1873 {
1874 $sql = sprintf("SELECT\n".
1875 " d.refcode,\n".
1876 " d.name,\n".
1877 " COUNT(f.refcode)\n".
1878 "FROM\n".
1879 " fnauthor fa,\n".
1880 " dll d,\n".
1881 " function f\n".
1882 "WHERE\n".
1883 " fa.author = %d AND\n".
1884 " fa.function = f.refcode AND\n".
1885 " f.dll = d.refcode\n".
1886 "GROUP BY d.refcode\n".
1887 "ORDER BY d.name\n",
1888 $iRefcode);
1889 Odin32DBWriteDlls($sql, $db, $sURLArgs);
1890 }
1891 else
1892 echo "Click <a href=\"Odin32DB.phtml#dlls?".$sURLArgs."&fDlls=1".
1893 "\">here</a> to see all files.\n";
1894
1895
1896 /*
1897 * Functions
1898 */
1899 Odin32DBNaslov("Functions", "functions");
1900 if ($fFunctions)
1901 {
1902 $sql = sprintf("SELECT\n".
1903 " f.refcode,\n".
1904 " f.name,\n".
1905 " d.refcode,\n".
1906 " d.name,\n".
1907 " s.color,\n".
1908 " s.name\n".
1909 "FROM\n".
1910 " fnauthor fa\n".
1911 " JOIN function f\n".
1912 " JOIN dll d\n".
1913 " LEFT JOIN state s ON f.state = s.refcode\n".
1914 "WHERE\n".
1915 " fa.author = %d AND\n".
1916 " fa.function = f.refcode AND \n".
1917 " f.dll = d.refcode\n",
1918 $iRefcode);
1919 if ($fSortByState)
1920 $sql = $sql."ORDER BY s.refcode, f.name, d.name";
1921 else
1922 $sql = $sql."ORDER BY d.name, f.name";
1923 Odin32DBWriteFunctionsWithDlls($sql, $db, $sURLArgs);
1924 }
1925 else
1926 echo "Click <a href=\"Odin32DB.phtml#functions?".$sURLArgs."&fFunctions=1".
1927 "\">here</a> to see all functions.\n";
1928
1929
1930 /*
1931 * Files
1932 */
1933 Odin32DBNaslov("Files", "files");
1934 if ($fFiles)
1935 {
1936 $sql = sprintf("SELECT\n".
1937 " f.refcode,\n".
1938 " f.name,\n".
1939 " COUNT(fn.refcode)\n".
1940 "FROM\n".
1941 " fnauthor fa,\n".
1942 " file f,\n".
1943 " function fn\n".
1944 "WHERE\n".
1945 " fa.author = %d AND\n".
1946 " fa.function = fn.refcode AND\n".
1947 " fn.file = f.refcode\n".
1948 "GROUP BY f.refcode\n".
1949 "ORDER BY f.name\n",
1950 $iRefcode);
1951 Odin32DBWriteFiles($sql, $db);
1952 }
1953 else
1954 echo "Click <a href=\"Odin32DB.phtml#files?".$sURLArgs."&fFiles=1".
1955 "\">here</a> to see all files.\n";
1956
1957
1958 /*
1959 * API Groups
1960 */
1961 if ($cAPIGroups > 0)
1962 {
1963 Odin32DBNaslov("API Groups", "apigroups");
1964 if ($fAPIGroups)
1965 {
1966 $sql = sprintf("SELECT\n".
1967 " g.refcode,\n".
1968 " g.name,\n".
1969 " COUNT(f.refcode)\n".
1970 "FROM\n".
1971 " fnauthor fa\n".
1972 " JOIN apigroup g\n".
1973 " JOIN function f\n".
1974 "WHERE\n".
1975 " fa.author = %d AND\n".
1976 " fa.function = f.refcode AND\n".
1977 " f.apigroup = g.refcode\n".
1978 "GROUP BY f.apigroup\n".
1979 "ORDER BY g.name\n",
1980 $iRefcode);
1981 Odin32DBWriteAPIGroups($sql, $db);
1982 }
1983 else
1984 echo "Click <a href=\"Odin32DB.phtml#apigroups?".$sURLArgs."&fAPIGroups=1".
1985 "\">here</a> to see all the API Groups.\n";
1986 }
1987 }
1988 else
1989 {
1990 echo "<p> No data! Invalid refcode? </p>";
1991 Odin32DBSqlError($sql);
1992 }
1993
1994 /*
1995 * Navigation - Bottom
1996 */
1997 Odin32DBNavigationBottom($sExpand, $sCollapse);
1998}
1999
2000
2001
2002/**
2003 * Writes standard file info.
2004 *
2005 * @returns void
2006 * @param $db Database handle.
2007 * @param $iRefcode Author reference code.
2008 * @param $fFunctions Flags which tells wether to list all functions or not.
2009 * @param $fFiles Flags which tells wether to list all files or not.
2010 * @param $fAuthors Flags which tells wether to list all authors or not.
2011 * @param $fSortByState Flags which tells wether to sort functions by
2012 * state and function name or just by function name.
2013 * @sketch
2014 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
2015 * @remark
2016 */
2017function Odin32DBAPIGroupInfo($db, $iRefcode, $fFunctions, $fFiles, $fAuthors, $fSortByState)
2018{
2019 $sURLArgs = "apigrouprefcode=".$iRefcode.
2020 ($fFunctions ? "&fFunctions=1" : "").
2021 ($fFiles ? "&fFiles=1" : "").
2022 ($fAuthors ? "&fAuthors=1" : "").
2023 ($fSortByState ? "&fSortByState=1" : "");
2024
2025 /*
2026 * Navigation - TOP
2027 */
2028 $sExpand = "apigrouprefcode=".$iRefcode."&fFiles=1&fFunctions=1&fAuthors=1";
2029 if ($fSortByState) $sExpand = $sExpand."&fSortByState=".$fSortByState;
2030 $sCollapse = "apigrouprefcode=".$iRefcode;
2031 Odin32DBNavigationTop($sExpand, $sCollapse);
2032
2033 /*
2034 * Fetch (vital) data.
2035 */
2036 $sql = sprintf("SELECT\n".
2037 " g.name AS name,\n".
2038 " g.refcode AS refcode,\n".
2039 " g.description AS description,\n".
2040 " d.name AS dllname,\n".
2041 " d.refcode AS dllrefcode\n".
2042 "FROM\n".
2043 " apigroup g\n".
2044 " JOIN dll d\n".
2045 "WHERE\n".
2046 " g.refcode = %d AND".
2047 " g.dll = d.refcode\n",
2048 $iRefcode);
2049 if (($result = mysql_query($sql, $db)) && mysql_num_rows($result) > 0 && ($array = mysql_fetch_array($result)))
2050 {
2051 /*
2052 * General
2053 */
2054 Odin32DBNaslov("General", "general");
2055 echo "\n<table width=100% border=3 cellpadding=0>\n";
2056 Odin32DBInfoRow1("Name", $array, "name","","","","");
2057 Odin32DBInfoRow1("Dll", $array, "dllname","dllrefcode","dllrefcode","bad configuration","");
2058 if (isset($array["description"]))
2059 Odin32DBInfoRow1("Description", $array, "description","","","","");
2060 $sql = sprintf("SELECT\n".
2061 " COUNT(*) as functions\n".
2062 "FROM\n".
2063 " function\n".
2064 "WHERE\n".
2065 " apigroup = %d",
2066 $iRefcode);
2067 $cFunctions = 0;
2068 if (($result2 = mysql_query($sql, $db)) && mysql_num_rows($result2) > 0 && ($aFunctions = mysql_fetch_array($result2)))
2069 {
2070 Odin32DBInfoRow1("# Functions", $aFunctions, "functions","","","","");
2071 $cFunctions = $aFunctions["functions"];
2072 }
2073 $sql = sprintf("SELECT\n".
2074 " COUNT(*) as functions\n".
2075 "FROM\n".
2076 " function\n".
2077 "WHERE\n".
2078 " apigroup = %d AND".
2079 " file >= 0\n".
2080 "GROUP BY file",
2081 $iRefcode);
2082 $cFiles = 0;
2083 if (($result2 = mysql_query($sql, $db)) && ($cFiles = mysql_num_rows($result2)) > 0)
2084 Odin32DBInfoRow1NoArray("# Files", $cFiles, "","","","");
2085
2086 $sql = sprintf("SELECT\n".
2087 " COUNT(f.dll) as functions\n".
2088 "FROM\n".
2089 " fnauthor fa,\n".
2090 " function f\n".
2091 "WHERE\n".
2092 " f.apigroup = %d AND".
2093 " f.refcode = fa.function\n".
2094 "GROUP BY fa.author",
2095 $iRefcode);
2096 $cAuthors = 0;
2097 if (($result2 = mysql_query($sql, $db)) && ($cAuthors = mysql_num_rows($result2)) > 0)
2098 Odin32DBInfoRow1NoArray("# Authors", $cAuthors, "","","","");
2099
2100 echo "</table>\n";
2101
2102 /*
2103 * Completion
2104 */
2105 Odin32DBNaslov("Completion", "completion");
2106 Odin32DBCompletionBarAPIGroup($iRefcode, "", $db);
2107
2108 /*
2109 * States
2110 */
2111 $sql = sprintf("SELECT\n".
2112 " state,\n".
2113 " COUNT(state)\n".
2114 "FROM\n".
2115 " function\n".
2116 "WHERE\n".
2117 " apigroup = %d\n".
2118 "GROUP BY state\n".
2119 "ORDER BY state",
2120 $iRefcode);
2121 Odin32DBWriteStates($cFunctions, $sql, $db);
2122
2123 /*
2124 * Functions
2125 */
2126 Odin32DBNaslov("Functions", "functions");
2127 if ($fFunctions)
2128 {
2129 //TODO: optimize this...
2130 $sql = sprintf("SELECT\n".
2131 " f.refcode,\n".
2132 " f.name,\n".
2133 " s.color,\n".
2134 " s.name\n".
2135 "FROM\n".
2136 " function f\n".
2137 " LEFT JOIN state s ON f.state = s.refcode\n".
2138 "WHERE\n".
2139 " f.apigroup = %d\n",
2140 $iRefcode);
2141 if ($fSortByState)
2142 $sql = $sql."ORDER BY s.refcode, f.name";
2143 else
2144 $sql = $sql."ORDER BY f.name";
2145 Odin32DBWriteFunctions($sql, $db, $sURLArgs);
2146 }
2147 else
2148 echo "Click <a href=\"Odin32DB.phtml#functions?".$sURLArgs."&fFunctions=1".
2149 "\">here</a> to see all functions.\n";
2150
2151
2152 /*
2153 * Files
2154 */
2155 Odin32DBNaslov("Files", "files");
2156 if ($fFiles)
2157 {
2158 //TODO: optimize this...
2159 $sql = sprintf("SELECT\n".
2160 " f.refcode,\n".
2161 " f.name,\n".
2162 " COUNT(fn.refcode)\n".
2163 "FROM\n".
2164 " file f\n".
2165 " LEFT OUTER JOIN function fn ON fn.file = f.refcode\n".
2166 "WHERE\n".
2167 " fn.apigroup = %d\n".
2168 "GROUP BY f.refcode\n".
2169 "ORDER BY f.name\n",
2170 $iRefcode);
2171 Odin32DBWriteFiles($sql, $db);
2172 }
2173 else
2174 echo "Click <a href=\"Odin32DB.phtml#files?".$sURLArgs."&fFiles=1".
2175 "\">here</a> to see all files.\n";
2176
2177
2178 /*
2179 * Authors
2180 */
2181 Odin32DBNaslov("Authors", "authors");
2182 if ($fAuthors)
2183 {
2184 //TODO: optimize this...
2185 $sql = sprintf("SELECT\n".
2186 " a.refcode,\n".
2187 " a.name,\n".
2188 " COUNT(f.refcode)\n".
2189 "FROM\n".
2190 " fnauthor fa\n".
2191 " JOIN function f\n".
2192 " JOIN author a\n".
2193 "WHERE\n".
2194 " f.apigroup = %d AND\n".
2195 " fa.function = f.refcode AND\n".
2196 " fa.author = a.refcode\n".
2197 "GROUP BY a.refcode\n".
2198 "ORDER BY a.name\n",
2199 $iRefcode
2200 );
2201 Odin32DBWriteAuthors($sql, $db);
2202 }
2203 else
2204 echo "Click <a href=\"Odin32DB.phtml#authors?".$sURLArgs."&fAuthors=1".
2205 "\">here</a> to see all authors.\n";
2206 }
2207 else
2208 {
2209 echo "<p> No data! Invalid refcode? </p>";
2210 Odin32DBSqlError($sql);
2211 }
2212
2213 /*
2214 * Navigation - Bottom
2215 */
2216 Odin32DBNavigationBottom($sExpand, $sCollapse);
2217}
2218
2219
2220/**
2221 * Displays a design not.
2222 * @returns void
2223 * @param $db Database handle.
2224 * @param $iRefcode Author reference code.
2225 * @author knut st. osmundsen (kosmunds@csc.com)
2226 * @remark
2227 */
2228function Odin32DBDesignNote($db, $iRefcode)
2229{
2230 /*
2231 * Navigation - TOP
2232 */
2233 $sExpand = "authorrefcode=".$iRefcode."&fDlls=1&fFiles=1&fFunctions=1&fAPIGroups=1&fAuthors=1&dll=".$iDllRefcode;
2234 if ($fSortByState) $sExpand = $sExpand."&fSortByState=".$fSortByState;
2235 $sCollapse = "authorrefcode=".$iRefcode;
2236 Odin32DBNavigationTop($sExpand, $sCollapse);
2237
2238 /*
2239 * Fetch (vital) data.
2240 */
2241 $sql = sprintf("SELECT\n".
2242 " dn.name AS name,\n".
2243 " dn.note AS note,\n".
2244 " dn.refcode AS refcode,\n".
2245 " dn.dll AS dllrefcode,\n".
2246 " dn.file AS filerefcode,\n".
2247 " dn.seqnbrnote AS seqnbnote,\n".
2248 " dn.level AS level,\n".
2249 " dn.seqnbr AS seqnbr,\n".
2250 " dn.line AS line,\n".
2251 " d.name AS dll,\n".
2252 " f.name AS file\n".
2253 "FROM\n".
2254 " designnote dn,\n".
2255 " dll d,\n".
2256 " file f\n".
2257 "WHERE dn.refcode = %d\n".
2258 " AND dn.dll = d.refcode\n".
2259 " AND dn.file = f.refcode\n".
2260 "ORDER BY dn.seqnbrnote\n",
2261 $iRefcode);
2262 if (($result = mysql_query($sql, $db)) && mysql_num_rows($result) > 0 && ($array = mysql_fetch_array($result)))
2263 {
2264 /*
2265 * General
2266 */
2267 /*Odin32DBNaslov("General", "general");
2268 echo "\n<table width=100% border=3 cellpadding=0>\n";
2269 Odin32DBInfoRow1("Title", $array, "name","","","","");
2270 Odin32DBInfoRow1("Module", $array, "dll","","","","");
2271 Odin32DBInfoRow1("File", $array, "file","","","","");
2272 Odin32DBInfoRow1("Line", $array, "line","","","","");
2273 Odin32DBInfoRow1("Seq#", $array, "seqnbr","","","","");
2274 echo "</table>\n";
2275 */
2276
2277 /*
2278 * Sections.
2279 */
2280 $iLevel = 0;
2281 $sSectionNbr = "";
2282 do
2283 {
2284 /* make section number */
2285 if ($array["level"] <= 0)
2286 $sSection = $array["seqnbr"].".0";
2287 else
2288 {
2289 while ($iLevel > 0 && $iLevel < $array["level"])
2290 {
2291 $sSection .= '.0';
2292 $iLevel = $iLevel + 1;
2293 }
2294
2295 if ($iLevel == 0) $iLevel++;
2296 while ($iLevel >= $array["level"])
2297 {
2298 $sSection = substr($sSection, 0, strlen($sSection) - strlen(strrchr($sSection, '.')));
2299 $iLevel = $iLevel - 1;
2300 }
2301 $sSection = $sSection.".".$array["seqnbr"];
2302 }
2303 $iLevel = $array["level"];
2304
2305 /* print it */
2306 $sName = $sSection." ".$array["name"];
2307 Odin32DBNaslov($sName, $sName);
2308 echo $array["note"]."\n";
2309
2310 } while ($array = mysql_fetch_array($result));
2311
2312 }
2313 else
2314 {
2315 echo "<p> No data! Invalid refcode? </p>";
2316 Odin32DBSqlError($sql);
2317 }
2318
2319 /*
2320 * Navigation - Bottom
2321 */
2322 Odin32DBNavigationBottom($sExpand, $sCollapse);
2323}
2324
2325
2326
2327
2328
2329/* TEXT FORMATTING OVERLOADS */
2330/* TEXT FORMATTING OVERLOADS */
2331/* TEXT FORMATTING OVERLOADS */
2332$aContent = array();
2333$aaSubContent = array();
2334$fNumberSections = 0;
2335
2336/**
2337 * Call this to autogenerate section and subsection numbers.
2338 */
2339function ODin32DBNumberSections()
2340{
2341 global $fNumberSections;
2342 $fNumberSections = 1;
2343}
2344
2345
2346/**
2347 * Makes the contents for this page.
2348 * @sketch Writes the headers present in the contents array.
2349 */
2350function Odin32DBWriteContents()
2351{
2352 global $aContent;
2353 global $aaSubContent;
2354
2355 echo "\n",
2356 "<tr><td>\n";
2357
2358 for ($i = 0; $i < sizeof($aContent); $i += 2)
2359 {
2360 echo "<font size=-2 face=\"WarpSans, Helv, Helvetica, Arial\">".
2361 "<a href=\"#".$aContent[$i+1]."\"><font color=000099>".
2362 $aContent[$i]."</font></a><br>\n";
2363
2364 $aSubContent = $aaSubContent[$i/2];
2365 echo "\n";
2366 if (sizeof($aSubContent) > 0)
2367 {
2368 echo "<table>\n";
2369 for ($j = 0; $j < sizeof($aSubContent); $j += 2)
2370 {
2371 echo "<tr><td width=10%>&nbsp;</td>\n",
2372 " <td><font size=-2 face=\"WarpSans, Helv, Helvetica, Arial\">".
2373 "<font size=-2 face=\"WarpSans, Helv, Helvetica, Arial\">".
2374 "<a href=\"#".$aSubContent[$j+1]."\"><font color=000099>".
2375 $aSubContent[$j]."</font></a><br>\n";
2376 echo "</td></tr>\n";
2377 }
2378 echo "</table>\n";
2379 }
2380 else
2381 echo "<p>\n";
2382 }
2383
2384 echo "</td></tr>\n";
2385}
2386
2387/**
2388 * Forwarder which also maintains the contents array.
2389 */
2390function Odin32DBNaslov($sFull, $sShort)
2391{
2392 global $aContent;
2393 global $aaSubContent;
2394 global $fNumberSections;
2395
2396 if ($fNumberSections)
2397 $sFull = (sizeof($aContent)/2 + 1).". ".$sFull;
2398
2399 $aContent[] = $sFull;
2400 $aContent[] = $sShort;
2401 $aaSubContent[] = array();
2402 return Naslov($sFull, $sShort);
2403}
2404
2405
2406/**
2407 * Forwarder which also maintains the contents array.
2408 * Equal to Odin32DBNaslov, but have allows a different contents text.
2409 */
2410function Odin32DBNaslov2($sFull, $sFullContents, $sShort)
2411{
2412 global $aContent;
2413 global $aaSubContent;
2414 global $fNumberSections;
2415
2416 if ($fNumberSections)
2417 {
2418 $sFull = (sizeof($aContent)/2 + 1).". ".$sFull;
2419 $sFullContents = (sizeof($aContent)/2 + 1).". ".$sFullContents;
2420 }
2421
2422 $aContent[] = $sFullContents;
2423 $aContent[] = $sShort;
2424 $aaSubContent[] = array();
2425 return Naslov($sFull, $sShort);
2426}
2427
2428
2429/**
2430 * Sub title with contents entry.
2431 */
2432function Odin32DBPodNaslov($sFull, $sShort)
2433{
2434 global $aContent;
2435 global $aaSubContent;
2436 global $fNumberSections;
2437
2438 $j = (sizeof($aContent) / 2) - 1;
2439 $aSubContent = $aaSubContent[$j];
2440
2441 if ($fNumberSections)
2442 $sFull = (sizeof($aContent)/2).".".(sizeof($aSubContent)/2 + 1)." ".$sFull;
2443
2444 $aSubContent[] = $sFull;
2445 $aSubContent[] = $sShort;
2446 $aaSubContent[$j] = $aSubContent;
2447 echo "<p><b><a name=\"".$sShort."\"><font size=+0 face=\"Helv, Arial\"><br>".$sFull."</font></b></a><p>";
2448}
2449
2450?>
2451
Note: See TracBrowser for help on using the repository browser.