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

Last change on this file since 3914 was 3914, checked in by bird, 25 years ago

Rewrote ProjectTeams.phtml. Misc.

File size: 80.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 " g.name AS apigroupname,\n".
1027 " g.refcode AS apigrouprefcode,\n".
1028 " a.name AS aliasname,\n".
1029 " a.refcode AS aliasrefcode,\n".
1030 " ad.name AS aliasdllname,\n".
1031 " ad.refcode AS aliasdllrefcode,\n".
1032 " d.name AS dllname,\n".
1033 " d.refcode AS dllrefcode,\n".
1034 " i.name AS filename,\n".
1035 " i.refcode AS filerefcode,\n".
1036 " s.name AS state,\n".
1037 " c.description AS type\n".
1038 "FROM\n".
1039 " function f\n".
1040 " LEFT OUTER JOIN function a ON f.aliasfn = a.refcode\n".
1041 " LEFT OUTER JOIN dll ad ON a.dll = ad.refcode\n".
1042 " LEFT OUTER JOIN apigroup g ON f.apigroup = g.refcode\n".
1043 " LEFT JOIN dll d ON f.dll = d.refcode\n".
1044 " LEFT JOIN state s ON f.state = s.refcode\n".
1045 " LEFT OUTER JOIN file i ON f.file = i.refcode\n".
1046 " LEFT JOIN code c ON f.type = c.code\n".
1047 "WHERE\n".
1048 " c.codegroup = 'FTYP' AND\n".
1049 " f.refcode = %d",
1050 $iRefcode);
1051 if (($result = mysql_query($sql, $db)) && @mysql_num_rows($result) > 0 && ($array = mysql_fetch_array($result)))
1052 {
1053 /*
1054 * General
1055 */
1056 Odin32DBNaslov("General", "general");
1057 echo "\n<table width=100% border=3 cellpadding=0>\n";
1058 Odin32DBInfoRow1("Name", $array, "name","","","","");
1059 if (isset($array["intname"]))
1060 Odin32DBInfoRow1("Internal Name", $array, "intname","","","","");
1061 else
1062 Odin32DBInfoRow1("Internal Name", $array, "name","","","","");
1063 Odin32DBInfoRow1("Type", $array, "type", "", "","invalid","");
1064 Odin32DBInfoRow1("State", $array, "state", "", "","invalid","");
1065 Odin32DBInfoRow1("Dll", $array, "dllname", "dllrefcode", "dllrefcode","","");
1066 Odin32DBInfoRow1("Ordinal", $array, "ordinal","","","not available","");
1067 if (isset($array["apigroupname"]))
1068 Odin32DBInfoRow1("API Group", $array, "apigroupname", "apigrouprefcode", "apigrouprefcode","","");
1069 Odin32DBInfoRow1("File", $array, "filename", "filerefcode", "filerefcode","not available","");
1070 if (isset($array["aliasrefcode"]))
1071 Odin32DBInfoRow2("Forwards", $array, "aliasdllname", "aliasdllrefcode", "dllrefcode","",".",
1072 "aliasname", "aliasrefcode", "functionrefcode");
1073 else
1074 {
1075 $sql = sprintf("SELECT\n".
1076 " d.name AS dllname,\n".
1077 " d.refcode AS dllrefcode,\n".
1078 " f.name AS fnname,\n".
1079 " f.refcode AS fnrefcode\n".
1080 "FROM\n".
1081 " function f,\n".
1082 " dll d\n".
1083 "WHERE\n".
1084 " f.aliasfn = %d AND\n".
1085 " f.dll = d.refcode\n".
1086 "ORDER BY d.name, f.name\n",
1087 $iRefcode);
1088 if (($result2 = mysql_query($sql, $db)))
1089 {
1090 if (mysql_num_rows($result2) > 0)
1091 {
1092 $sValue = "";
1093 $f = 0;
1094 while ($aAlias = mysql_fetch_array($result2))
1095 {
1096 if ($f) $sValue = $sValue."<br>";
1097 else $f = 1;
1098 $sValue = $sValue."<a href=\"Odin32DB.phtml?dllrefcode=".
1099 $aAlias["dllrefcode"]."\">".$aAlias["dllname"]."</a>.".
1100 "<a href=\"Odin32DB.phtml?functionrefcode=".
1101 $aAlias["fnrefcode"]."\">".$aAlias["fnname"]."</a>";
1102 }
1103 Odin32DBInfoRow1NoArray("Forwarded as", $sValue, "","","","");
1104 }
1105 }
1106 else
1107 Odin32DBSqlError($sql);
1108 }
1109 echo "</table>\n";
1110
1111 /*
1112 * Completion
1113 */
1114 Odin32DBNaslov("Completion", "completion");
1115 Odin32DBCompletionBarFunction($iRefcode, "", $db);
1116
1117
1118 /*
1119 * Declaration
1120 */
1121 Odin32DBNaslov("Declaration", "declaration");
1122 echo "\n<pre>";
1123 if (isset($array["return"]))
1124 echo $array["return"]." ";
1125 echo $array["name"]."(";
1126 $sql = sprintf("SELECT\n".
1127 " name AS name,\n".
1128 " type AS type,\n".
1129 " description AS description\n".
1130 "FROM\n".
1131 " parameter\n".
1132 "WHERE\n".
1133 " function = %d\n".
1134 "ORDER BY sequencenbr",
1135 $iRefcode);
1136 if (($result2 = mysql_query($sql, $db)) && ($cParams = mysql_num_rows($result2)) > 0)
1137 {
1138 while ($param = mysql_fetch_array($result2))
1139 {
1140 if (--$cParams == 0)
1141 printf("\n %-20s %s", $param["type"], $param["name"]);
1142 else
1143 printf("\n %-20s %s,", $param["type"], $param["name"]);
1144 }
1145 }
1146 else
1147 echo "void";
1148
1149 echo ");\n";
1150 echo "</pre>\n";
1151
1152 /*
1153 * Description
1154 */
1155 Odin32DBDocRow("Description", "desc", $array, "description");
1156
1157
1158 /*
1159 * Parameters
1160 */
1161 Odin32DBNaslov("Parameters", "params");
1162 if ($result2 && mysql_num_rows($result2) > 0 && mysql_data_seek($result2, 0))
1163 {
1164 while ($param = mysql_fetch_array($result2))
1165 {
1166 echo "\n<dt><b>".$param["name"].":</b></dt>\n";
1167 if (isset($param["description"]))
1168 {
1169 if (1)
1170 {
1171 echo "\n <table width=100% border=0 cellpadding=0>\n";
1172 echo " <tr><td width=10%>&nbsp;</td>\n";
1173 $sDescription = str_replace("<BR>", "", str_replace("<BR><BR>\n","<br>",$param["description"]));
1174 echo " <td width=90%><font size=-1>".$sDescription."</font></td></tr>\n";
1175 echo "</table>\n";
1176 }
1177 else
1178 {
1179 $sDescription = str_replace("<BR>", "", str_replace("<BR><BR>\n","<br>",$param["description"]));
1180 echo "<dd><font size=-1>".$sDescription."</font></dd>\n\n";
1181 }
1182 }
1183 echo "<p>\n";
1184 }
1185 }
1186 else
1187 echo "void";
1188
1189
1190 /*
1191 * Returns
1192 */
1193 Odin32DBDocRow("Returns", "return", $array, "returndesc");
1194
1195 /*
1196 * Sketch/Algorithm
1197 */
1198 Odin32DBDocRow("Sketch/Algorithm", "sketch", $array, "sketch");
1199
1200 /*
1201 * Remark
1202 */
1203 Odin32DBDocRow("Remarks", "remark", $array, "remark");
1204
1205 /*
1206 * Authors
1207 */
1208 Odin32DBNaslov("Authors", "Authors");
1209 $sql = sprintf("SELECT\n".
1210 " a.name AS name,\n".
1211 " a.refcode AS refcode\n".
1212 "FROM\n".
1213 " fnauthor fa\n".
1214 " JOIN function f\n".
1215 " JOIN author a\n".
1216 "WHERE\n".
1217 " f.refcode = %d AND\n".
1218 " fa.function = f.refcode AND\n".
1219 " fa.author = a.refcode\n".
1220 "ORDER BY a.name",
1221 $iRefcode);
1222 if (($result2 = mysql_query($sql, $db)) && mysql_num_rows($result2) > 0)
1223 {
1224 while ($author = mysql_fetch_array($result2))
1225 echo "<a href=\"Odin32DB.phtml?authorrefcode=".$author["refcode"]."\">".$author["name"]."</a><br>\n";
1226 }
1227 else
1228 echo "<i>Hmm. Seems noone wrote this function...</i><br>\n";
1229 }
1230 else
1231 {
1232 echo "<p> No data! Invalid refcode? </p>";
1233 Odin32DBSqlError($sql);
1234 }
1235 Odin32DBNavigationBottom("","");
1236}
1237
1238
1239
1240/**
1241 * Writes standard dll info.
1242 *
1243 * @returns void
1244 * @param $db Database handle.
1245 * @param $iRefcode Dll reference code.
1246 * @param $fFunctions Flags which tells wether to list all functions or not.
1247 * @param $fFiles Flags which tells wether to list all files or not.
1248 * @param $fAPIGroups Flags which tells wether to list all apigroups or not.
1249 * @param $fAuthors Flags which tells wether to list all authors or not.
1250 * @param $fSortByState Flags which tells wether to sort functions by
1251 * state and function name or just by function name.
1252 * @sketch
1253 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
1254 * @remark
1255 */
1256function Odin32DBDllInfo($db, $iRefcode, $fFunctions, $fFiles, $fAPIGroups, $fAuthors, $fSortByState)
1257{
1258 $sURLArgs = "dllrefcode=".$iRefcode.
1259 ($fFunctions ? "&fFunctions=1" : "").
1260 ($fFiles ? "&fFiles=1" : "").
1261 ($fAPIGroups ? "&fAPIGroups=1" : "").
1262 ($fAuthors ? "&fAuthors=1" : "").
1263 ($fSortByState ? "&fSortByState=1" : "");
1264
1265 /*
1266 * Navigation - TOP
1267 */
1268 $sExpand = "dllrefcode=".$iRefcode."&fFiles=1&fFunctions=1&fAPIGroups=1&fAuthors=1";
1269 if ($fSortByState) $sExpand = $sExpand."&fSortByState=".$fSortByState;
1270 $sCollapse = "dllrefcode=".$iRefcode;
1271 Odin32DBNavigationTop($sExpand, $sCollapse);
1272
1273 /*
1274 * Fetch (vital) data.
1275 */
1276 $sql = sprintf("SELECT\n".
1277 " d.name AS name,\n".
1278 " d.description AS description,\n".
1279 " c.description AS type\n".
1280 "FROM\n".
1281 " dll d,\n".
1282 " code c\n".
1283 "WHERE\n".
1284 " c.codegroup = 'DTYP' AND\n".
1285 " d.type = c.code AND\n".
1286 " d.refcode = %d",
1287 $iRefcode);
1288 if (($result = mysql_query($sql, $db)) && mysql_num_rows($result) > 0 && ($array = mysql_fetch_array($result)))
1289 {
1290 /*
1291 * General
1292 */
1293 Odin32DBNaslov("General", "general");
1294 echo "\n<table width=100% border=3 cellpadding=0>\n";
1295 Odin32DBInfoRow1("Name", $array, "name","","","","");
1296 Odin32DBInfoRow1("Description", $array, "description","","","","");
1297 Odin32DBInfoRow1("Type", $array, "type","","","","");
1298 $sql = sprintf("SELECT\n".
1299 " COUNT(*) as functions\n".
1300 "FROM\n".
1301 " function\n".
1302 "WHERE\n".
1303 " dll = %d",
1304 $iRefcode);
1305 $cFunctions = 0;
1306 if (($result2 = mysql_query($sql, $db)) && mysql_num_rows($result2) > 0 && ($array2 = mysql_fetch_array($result2)))
1307 {
1308 Odin32DBInfoRow1("# Functions", $array2, "functions","","","","");
1309 $cFunctions = $array2["functions"];
1310 }
1311
1312 $sql = sprintf("SELECT\n".
1313 " COUNT(*) as files\n".
1314 "FROM\n".
1315 " file\n".
1316 "WHERE\n".
1317 " dll = %d",
1318 $iRefcode);
1319 $cFiles = 0;
1320 if (($result2 = mysql_query($sql, $db)) && mysql_num_rows($result2) > 0 && ($array2 = mysql_fetch_array($result2)))
1321 {
1322 Odin32DBInfoRow1("# Source files", $array2, "files","","","","");
1323 $cFiles = $array2["files"];
1324 }
1325
1326 $sql = sprintf("SELECT\n".
1327 " COUNT(*) as apigroups\n".
1328 "FROM\n".
1329 " apigroup\n".
1330 "WHERE\n".
1331 " dll = %d",
1332 $iRefcode);
1333 $cAPIGroups = 0;
1334 if (($result2 = mysql_query($sql, $db)) && mysql_num_rows($result2) > 0 && ($array2 = mysql_fetch_array($result2)))
1335 {
1336 Odin32DBInfoRow1("# API Groups", $array2, "apigroups","","","","");
1337 $cAPIGroups = $array2["apigroups"];
1338 }
1339
1340 echo "</table>\n";
1341
1342
1343 /*
1344 * Completion
1345 */
1346 Odin32DBNaslov("Completion", "completion");
1347 Odin32DBCompletionBarDll($iRefcode, "", $db);
1348
1349 /*
1350 * States
1351 */
1352 $sql = sprintf("SELECT\n".
1353 " state,\n".
1354 " COUNT(state)\n".
1355 "FROM\n".
1356 " function\n".
1357 "WHERE\n".
1358 " dll = %d\n".
1359 "GROUP BY state\n".
1360 "ORDER BY state",
1361 $iRefcode);
1362 Odin32DBWriteStates($cFunctions, $sql, $db);
1363
1364 /*
1365 * Functions
1366 */
1367 Odin32DBNaslov("Functions", "functions");
1368 if ($fFunctions)
1369 {
1370 $sql = sprintf("SELECT\n".
1371 " f.refcode,\n".
1372 " f.name,\n".
1373 " s.color,\n".
1374 " s.name\n".
1375 "FROM\n".
1376 " function f\n".
1377 " LEFT JOIN state s ON f.state = s.refcode\n".
1378 "WHERE\n".
1379 " f.dll = %d\n",
1380 $iRefcode);
1381 if ($fSortByState)
1382 $sql = $sql."ORDER BY s.refcode, f.name";
1383 else
1384 $sql = $sql."ORDER BY f.name";
1385 Odin32DBWriteFunctions($sql, $db, $sURLArgs);
1386 }
1387 else
1388 echo "Click <a href=\"Odin32DB.phtml#functions?".$sURLArgs."&fFunctions=1".
1389 "\">here</a> to see all functions.\n";
1390
1391
1392 /*
1393 * Files
1394 */
1395 Odin32DBNaslov("Files", "files");
1396 if ($fFiles)
1397 {
1398 $sql = sprintf("SELECT\n".
1399 " f.refcode,\n".
1400 " f.name,\n".
1401 " COUNT(fn.refcode)\n".
1402 "FROM\n".
1403 " file f\n".
1404 " LEFT OUTER JOIN function fn ON fn.file = f.refcode\n".
1405 "WHERE\n".
1406 " f.dll = %d\n".
1407 "GROUP BY f.refcode\n".
1408 "ORDER BY f.name\n",
1409 $iRefcode);
1410 Odin32DBWriteFiles($sql, $db);
1411 }
1412 else
1413 echo "Click <a href=\"Odin32DB.phtml#files?".$sURLArgs."&fFiles=1".
1414 "\">here</a> to see all files.\n";
1415
1416
1417 /*
1418 * API Groups
1419 */
1420 if ($cAPIGroups > 0)
1421 {
1422 Odin32DBNaslov("API Groups", "apigroups");
1423 if ($fAPIGroups)
1424 {
1425 $sql = sprintf("SELECT\n".
1426 " g.refcode,\n".
1427 " g.name,\n".
1428 " COUNT(f.refcode)\n".
1429 "FROM\n".
1430 " apigroup g\n".
1431 " JOIN function f\n".
1432 "WHERE\n".
1433 " g.dll = %d AND\n".
1434 " f.dll = %d AND\n".
1435 " f.apigroup = g.refcode\n".
1436 "GROUP BY f.apigroup\n".
1437 "ORDER BY g.name\n",
1438 $iRefcode,
1439 $iRefcode);
1440 Odin32DBWriteAPIGroups($sql, $db);
1441 }
1442 else
1443 echo "Click <a href=\"Odin32DB.phtml#apigroups?".$sURLArgs."&fAPIGroups=1".
1444 "\">here</a> to see all the API Groups.\n";
1445 }
1446
1447
1448 /*
1449 * Authors
1450 */
1451 Odin32DBNaslov("Authors", "authors");
1452 if ($fAuthors)
1453 {
1454 $sql = sprintf("SELECT\n".
1455 " a.refcode,\n".
1456 " a.name,\n".
1457 " COUNT(f.refcode)\n".
1458 "FROM\n".
1459 " fnauthor fa\n".
1460 " JOIN function f\n".
1461 " JOIN author a\n".
1462 "WHERE\n".
1463 " f.dll = %d AND\n".
1464 " fa.function = f.refcode AND\n".
1465 " fa.author = a.refcode\n".
1466 "GROUP BY a.refcode\n".
1467 "ORDER BY a.name\n",
1468 $iRefcode);
1469 Odin32DBWriteAuthors($sql, $db);
1470 }
1471 else
1472 echo "Click <a href=\"Odin32DB.phtml#authors?".$sURLArgs."&fAuthors=1".
1473 "\">here</a> to see all authors.\n";
1474 }
1475 else
1476 {
1477 echo "<p> No data! Invalid refcode? </p>";
1478 Odin32DBSqlError($sql);
1479 }
1480
1481 /*
1482 * Navigation - Bottom
1483 */
1484 Odin32DBNavigationBottom($sExpand, $sCollapse);
1485}
1486
1487
1488
1489/**
1490 * Writes standard file info.
1491 *
1492 * @returns void
1493 * @param $db Database handle.
1494 * @param $iRefcode File reference code.
1495 * @param $fFunctions Flags which tells wether to list all functions or not.
1496 * @param $fAPIGroups Flags which tells wether to list all apigroups or not.
1497 * @param $fAuthors Flags which tells wether to list all authors or not.
1498 * @param $fSortByState Flags which tells wether to sort functions by
1499 * state and function name or just by function name.
1500 * @sketch
1501 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
1502 * @remark
1503 */
1504function Odin32DBFileInfo($db, $iRefcode, $fFunctions, $fAPIGroups, $fAuthors, $fSortByState)
1505{
1506 $sURLArgs = "filerefcode=".$iRefcode.
1507 ($fFunctions ? "&fFunctions=1" : "").
1508 ($fAuthors ? "&fAuthors=1" : "").
1509 ($fAPIGroups ? "&fAPIGroups=1" : "").
1510 ($fSortByState ? "&fSortByState=1" : "");
1511
1512 /*
1513 * Navigation - TOP
1514 */
1515 $sExpand = "filerefcode=".$iRefcode."&fFiles=1&fFunctions=1&fAPIGroups=1&fAuthors=1";
1516 if ($fSortByState) $sExpand = $sExpand."&fSortByState=".$fSortByState;
1517 $sCollapse = "filerefcode=".$iRefcode;
1518 Odin32DBNavigationTop($sExpand, $sCollapse);
1519
1520 /*
1521 * Fetch (vital) data.
1522 */
1523 $sql = sprintf("SELECT\n".
1524 " f.name AS name,\n".
1525 " f.refcode AS refcode,\n".
1526 " f.lastdatetime AS lastdatetime,\n".
1527 " a.name AS lastauthorname,\n".
1528 " f.lastauthor AS lastauthorrefcode,\n".
1529 " f.revision AS revision,\n".
1530 " f.description AS description,\n".
1531 " f.dll AS dllrefcode,\n".
1532 " d.name AS dllname\n".
1533 "FROM\n".
1534 " file f,\n".
1535 " dll d,\n".
1536 " author a\n".
1537 "WHERE\n".
1538 " f.refcode = %d AND\n".
1539 " f.dll = d.refcode AND\n".
1540 " f.lastauthor= a.refcode",
1541 $iRefcode);
1542 if (($result = mysql_query($sql, $db)) && mysql_num_rows($result) > 0 && ($array = mysql_fetch_array($result)))
1543 {
1544 /*
1545 * General
1546 */
1547 Odin32DBNaslov("General", "general");
1548 echo "\n<table width=100% border=3 cellpadding=0>\n";
1549 Odin32DBInfoRow1("Name", $array, "name","","","","");
1550 Odin32DBInfoRow1("Revision", $array, "revision","","","","");
1551 Odin32DBInfoRow1("Changed", $array, "lastdatetime","","","","");
1552 Odin32DBInfoRow1("Last Author", $array, "lastauthorname","lastauthorrefcode","authorrefcode","","");
1553 Odin32DBInfoRow1("Dll", $array, "dllname","dllrefcode","dllrefcode","","");
1554 $sql = sprintf("SELECT\n".
1555 " COUNT(*) as functions\n".
1556 "FROM\n".
1557 " function\n".
1558 "WHERE\n".
1559 " file = %d",
1560 $iRefcode);
1561 $cFunctions = 0;
1562 if (($result2 = mysql_query($sql, $db)) && mysql_num_rows($result2) > 0 && ($aFunctions = mysql_fetch_array($result2)))
1563 {
1564 Odin32DBInfoRow1("# Functions", $aFunctions, "functions","","","","");
1565 $cFunctions = $aFunctions["functions"];
1566 }
1567
1568 $sql = sprintf("SELECT\n".
1569 " COUNT(*) as functions\n".
1570 "FROM\n".
1571 " function\n".
1572 "WHERE\n".
1573 " file = %d AND\n".
1574 " apigroup IS NOT NULL\n".
1575 "GROUP BY apigroup\n",
1576 $iRefcode);
1577 $cAPIGroups = 0;
1578 if (($result2 = mysql_query($sql, $db)) && ($cAPIGroups = mysql_num_rows($result2)) > 0)
1579 Odin32DBInfoRow1NoArray("# API Groups", $cAPIGroups, "","","","");
1580 if (!$result2)
1581 Odin32DBSqlError($sql);
1582
1583 echo "</table>\n";
1584
1585 /*
1586 * Description
1587 */
1588 Odin32DBDocRow("Description", "description", $array, "description");
1589
1590 /*
1591 * Completion
1592 */
1593 Odin32DBNaslov("Completion", "completion");
1594 Odin32DBCompletionBarFile($iRefcode, "", $db);
1595
1596 /*
1597 * States
1598 */
1599 $sql = sprintf("SELECT\n".
1600 " state,\n".
1601 " COUNT(state)\n".
1602 "FROM\n".
1603 " function\n".
1604 "WHERE\n".
1605 " file = %d\n".
1606 "GROUP BY state\n".
1607 "ORDER BY state",
1608 $iRefcode);
1609 Odin32DBWriteStates($cFunctions, $sql, $db);
1610
1611
1612 /*
1613 * Functions
1614 */
1615 Odin32DBNaslov("Functions", "functions");
1616 if ($fFunctions)
1617 {
1618 $sql = sprintf("SELECT\n".
1619 " f.refcode,\n".
1620 " f.name,\n".
1621 " s.color,\n".
1622 " s.name\n".
1623 "FROM\n".
1624 " function f\n".
1625 " LEFT JOIN state s ON f.state = s.refcode\n".
1626 "WHERE\n".
1627 " f.file = %d\n",
1628 $iRefcode);
1629 if ($fSortByState)
1630 $sql = $sql."ORDER BY s.refcode, f.name";
1631 else
1632 $sql = $sql."ORDER BY f.name";
1633 Odin32DBWriteFunctions($sql, $db, $sURLArgs);
1634 }
1635 else
1636 echo "Click <a href=\"Odin32DB.phtml#functions?".$sURLArgs."&fFunctions=1".
1637 "\">here</a> to see all functions.\n";
1638
1639
1640 /*
1641 * API Groups
1642 */
1643 if ($cAPIGroups > 0)
1644 {
1645 Odin32DBNaslov("API Groups", "apigroups");
1646 if ($fAPIGroups)
1647 {
1648 $sql = sprintf("SELECT\n".
1649 " g.refcode,\n".
1650 " g.name,\n".
1651 " COUNT(f.refcode)\n".
1652 "FROM\n".
1653 " apigroup g\n".
1654 " JOIN function f\n".
1655 "WHERE\n".
1656 " f.file = %d AND\n".
1657 " f.apigroup = g.refcode\n".
1658 "GROUP BY f.apigroup\n".
1659 "ORDER BY g.name\n",
1660 $iRefcode);
1661 Odin32DBWriteAPIGroups($sql, $db);
1662 }
1663 else
1664 echo "Click <a href=\"Odin32DB.phtml#apigroups?".$sURLArgs."&fAPIGroups=1".
1665 "\">here</a> to see all the API Groups.\n";
1666 }
1667
1668
1669 /*
1670 * Authors
1671 */
1672 Odin32DBNaslov("Authors", "authors");
1673 if ($fAuthors)
1674 {
1675 $sql = sprintf("SELECT\n".
1676 " a.refcode,\n".
1677 " a.name,\n".
1678 " COUNT(f.refcode)\n".
1679 "FROM\n".
1680 " fnauthor fa\n".
1681 " JOIN function f\n".
1682 " JOIN author a\n".
1683 "WHERE\n".
1684 " f.file = %d AND\n".
1685 " fa.function = f.refcode AND\n".
1686 " fa.author = a.refcode\n".
1687 "GROUP BY a.refcode\n".
1688 "ORDER BY a.name\n",
1689 $iRefcode
1690 );
1691 Odin32DBWriteAuthors($sql, $db);
1692 }
1693 else
1694 echo "Click <a href=\"Odin32DB.phtml#authors?".$sURLArgs."&fAuthors=1".
1695 "\">here</a> to see all authors.\n";
1696 }
1697 else
1698 {
1699 echo "<p> No data! Invalid refcode? </p>";
1700 Odin32DBSqlError($sql);
1701 }
1702
1703 /*
1704 * Navigation - Bottom
1705 */
1706 Odin32DBNavigationBottom($sExpand, $sCollapse);
1707}
1708
1709
1710
1711/**
1712 * Writes standard file info.
1713 *
1714 * @returns void
1715 * @param $db Database handle.
1716 * @param $iRefcode Author reference code.
1717 * @param $fDlls Flags which tells wether to list all dlls or not.
1718 * @param $fFunctions Flags which tells wether to list all functions or not.
1719 * @param $fFiles Flags which tells wether to list all files or not.
1720 * @param $fAPIGroups Flags which tells wether to list all apigroups or not.
1721 * @param $fSortByState Flags which tells wether to sort functions by
1722 * state and function name or just by function name.
1723 * @param $iDllRefcode Dll refcode. All Dll if < 0.
1724 * (not implemented yet)
1725 * @sketch
1726 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
1727 * @remark
1728 */
1729function Odin32DBAuthorInfo($db, $iRefcode, $fDlls, $fFunctions, $fFiles, $fAPIGroups, $fSortByState, $iDllRefcode)
1730{
1731 $sURLArgs = "authorrefcode=".$iRefcode.
1732 ($fDlls ? "&fDlls=1" : "").
1733 ($fFunctions ? "&fFunctions=1" : "").
1734 ($fFiles ? "&fFiles=1" : "").
1735 ($fAPIGroups ? "&fAPIGroups=1" : "").
1736 ($fSortByState ? "&fSortByState=1" : "");
1737
1738 /*
1739 * Navigation - TOP
1740 */
1741 $sExpand = "authorrefcode=".$iRefcode."&fDlls=1&fFiles=1&fFunctions=1&fAPIGroups=1&fAuthors=1&dll=".$iDllRefcode;
1742 if ($fSortByState) $sExpand = $sExpand."&fSortByState=".$fSortByState;
1743 $sCollapse = "authorrefcode=".$iRefcode;
1744 Odin32DBNavigationTop($sExpand, $sCollapse);
1745
1746 /*
1747 * Fetch (vital) data.
1748 */
1749 $sql = sprintf("SELECT\n".
1750 " a.name AS name,\n".
1751 " a.refcode AS refcode,\n".
1752 " a.initials AS initials,\n".
1753 " a.alias AS alias,\n".
1754 " a.email AS email,\n".
1755 " a.country AS country,\n".
1756 " a.location AS location,\n".
1757 " a.description AS description\n".
1758 "FROM\n".
1759 " author a\n".
1760 "WHERE\n".
1761 " a.refcode = %d",
1762 $iRefcode);
1763 if (($result = mysql_query($sql, $db)) && mysql_num_rows($result) > 0 && ($array = mysql_fetch_array($result)))
1764 {
1765 /*
1766 * General
1767 */
1768 Odin32DBNaslov("General", "general");
1769 echo "\n<table width=100% border=3 cellpadding=0>\n";
1770 Odin32DBInfoRow1("Name", $array, "name","","","","");
1771 Odin32DBInfoRow1("e-mail", $array, "email","","","",""); //???? should all authors have email address displayed?
1772 Odin32DBInfoRow1("CVS User", $array, "alias","","","","");
1773 Odin32DBInfoRow1("Country", $array, "country","","","","");
1774 Odin32DBInfoRow1("Location", $array, "location","","","","");
1775 if (isset($array["description"]))
1776 Odin32DBInfoRow1("Description", $array, "description","","","","");
1777 $sql = sprintf("SELECT\n".
1778 " COUNT(*) as functions\n".
1779 "FROM\n".
1780 " fnauthor\n".
1781 "WHERE\n".
1782 " author = %d",
1783 $iRefcode);
1784 $cFunctions = 0;
1785 if (($result2 = mysql_query($sql, $db)) && mysql_num_rows($result2) > 0 && ($aFunctions = mysql_fetch_array($result2)))
1786 {
1787 Odin32DBInfoRow1("# Functions", $aFunctions, "functions","","","","");
1788 $cFunctions = $aFunctions["functions"];
1789 }
1790 $sql = sprintf("SELECT\n".
1791 " COUNT(f.dll) as functions
1792 \n".
1793 "FROM\n".
1794 " fnauthor fa,\n".
1795 " function f\n".
1796 "WHERE\n".
1797 " fa.author = %d AND".
1798 " f.refcode = fa.function\n".
1799 "GROUP BY f.dll",
1800 $iRefcode);
1801 $cDlls = 0;
1802 if (($result2 = mysql_query($sql, $db)) && ($cDlls = mysql_num_rows($result2)) > 0)
1803 Odin32DBInfoRow1NoArray("# Dlls", $cDlls, "","","","");
1804 $sql = sprintf("SELECT\n".
1805 " COUNT(f.dll) as functions
1806 \n".
1807 "FROM\n".
1808 " fnauthor fa,\n".
1809 " function f\n".
1810 "WHERE\n".
1811 " fa.author = %d AND".
1812 " f.file >= 0 AND".
1813 " f.refcode = fa.function \n".
1814 "GROUP BY f.file",
1815 $iRefcode);
1816 $cFiles = 0;
1817 if (($result2 = mysql_query($sql, $db)) && ($cFiles = mysql_num_rows($result2)) > 0)
1818 Odin32DBInfoRow1NoArray("# Files", $cFiles, "","","","");
1819 $sql = sprintf("SELECT\n".
1820 " COUNT(f.dll) as functions
1821 \n".
1822 "FROM\n".
1823 " fnauthor fa,\n".
1824 " function f\n".
1825 "WHERE\n".
1826 " fa.author = %d AND".
1827 " f.apigroup IS NOT NULL AND".
1828 " f.refcode = fa.function\n".
1829 "GROUP BY f.apigroup",
1830 $iRefcode);
1831 $cAPIGroups = 0;
1832 if (($result2 = mysql_query($sql, $db)) && ($cAPIGroups = mysql_num_rows($result2)) > 0)
1833 Odin32DBInfoRow1NoArray("# API Groups", $cAPIGroups, "","","","");
1834
1835 echo "</table>\n";
1836
1837 /*
1838 * Completion
1839 */
1840 Odin32DBNaslov("Completion", "completion");
1841 Odin32DBCompletionBarAuthor($iRefcode, "", $db);
1842
1843 /*
1844 * States
1845 */
1846 //TODO: optimize this further.
1847 $sql = sprintf("SELECT\n".
1848 " f.state,\n".
1849 " COUNT(f.refcode)\n".
1850 "FROM\n".
1851 " function f,\n".
1852 " fnauthor fa\n".
1853 "WHERE\n".
1854 " fa.author = %d AND\n".
1855 " fa.function = f.refcode\n".
1856 "GROUP BY f.state\n".
1857 "ORDER BY f.state",
1858 $iRefcode);
1859 Odin32DBWriteStates($cFunctions, $sql, $db);
1860
1861 /*
1862 * Dlls
1863 */
1864 Odin32DBNaslov("Dlls", "dlls");
1865 if ($fDlls)
1866 {
1867 $sql = sprintf("SELECT\n".
1868 " d.refcode,\n".
1869 " d.name,\n".
1870 " COUNT(f.refcode)\n".
1871 "FROM\n".
1872 " fnauthor fa,\n".
1873 " dll d,\n".
1874 " function f\n".
1875 "WHERE\n".
1876 " fa.author = %d AND\n".
1877 " fa.function = f.refcode AND\n".
1878 " f.dll = d.refcode\n".
1879 "GROUP BY d.refcode\n".
1880 "ORDER BY d.name\n",
1881 $iRefcode);
1882 Odin32DBWriteDlls($sql, $db, $sURLArgs);
1883 }
1884 else
1885 echo "Click <a href=\"Odin32DB.phtml#dlls?".$sURLArgs."&fDlls=1".
1886 "\">here</a> to see all files.\n";
1887
1888
1889 /*
1890 * Functions
1891 */
1892 Odin32DBNaslov("Functions", "functions");
1893 if ($fFunctions)
1894 {
1895 $sql = sprintf("SELECT\n".
1896 " f.refcode,\n".
1897 " f.name,\n".
1898 " d.refcode,\n".
1899 " d.name,\n".
1900 " s.color,\n".
1901 " s.name\n".
1902 "FROM\n".
1903 " fnauthor fa\n".
1904 " JOIN function f\n".
1905 " JOIN dll d\n".
1906 " LEFT JOIN state s ON f.state = s.refcode\n".
1907 "WHERE\n".
1908 " fa.author = %d AND\n".
1909 " fa.function = f.refcode AND \n".
1910 " f.dll = d.refcode\n",
1911 $iRefcode);
1912 if ($fSortByState)
1913 $sql = $sql."ORDER BY s.refcode, f.name, d.name";
1914 else
1915 $sql = $sql."ORDER BY d.name, f.name";
1916 Odin32DBWriteFunctionsWithDlls($sql, $db, $sURLArgs);
1917 }
1918 else
1919 echo "Click <a href=\"Odin32DB.phtml#functions?".$sURLArgs."&fFunctions=1".
1920 "\">here</a> to see all functions.\n";
1921
1922
1923 /*
1924 * Files
1925 */
1926 Odin32DBNaslov("Files", "files");
1927 if ($fFiles)
1928 {
1929 $sql = sprintf("SELECT\n".
1930 " f.refcode,\n".
1931 " f.name,\n".
1932 " COUNT(fn.refcode)\n".
1933 "FROM\n".
1934 " fnauthor fa,\n".
1935 " file f,\n".
1936 " function fn\n".
1937 "WHERE\n".
1938 " fa.author = %d AND\n".
1939 " fa.function = fn.refcode AND\n".
1940 " fn.file = f.refcode\n".
1941 "GROUP BY f.refcode\n".
1942 "ORDER BY f.name\n",
1943 $iRefcode);
1944 Odin32DBWriteFiles($sql, $db);
1945 }
1946 else
1947 echo "Click <a href=\"Odin32DB.phtml#files?".$sURLArgs."&fFiles=1".
1948 "\">here</a> to see all files.\n";
1949
1950
1951 /*
1952 * API Groups
1953 */
1954 if ($cAPIGroups > 0)
1955 {
1956 Odin32DBNaslov("API Groups", "apigroups");
1957 if ($fAPIGroups)
1958 {
1959 $sql = sprintf("SELECT\n".
1960 " g.refcode,\n".
1961 " g.name,\n".
1962 " COUNT(f.refcode)\n".
1963 "FROM\n".
1964 " fnauthor fa\n".
1965 " JOIN apigroup g\n".
1966 " JOIN function f\n".
1967 "WHERE\n".
1968 " fa.author = %d AND\n".
1969 " fa.function = f.refcode AND\n".
1970 " f.apigroup = g.refcode\n".
1971 "GROUP BY f.apigroup\n".
1972 "ORDER BY g.name\n",
1973 $iRefcode);
1974 Odin32DBWriteAPIGroups($sql, $db);
1975 }
1976 else
1977 echo "Click <a href=\"Odin32DB.phtml#apigroups?".$sURLArgs."&fAPIGroups=1".
1978 "\">here</a> to see all the API Groups.\n";
1979 }
1980 }
1981 else
1982 {
1983 echo "<p> No data! Invalid refcode? </p>";
1984 Odin32DBSqlError($sql);
1985 }
1986
1987 /*
1988 * Navigation - Bottom
1989 */
1990 Odin32DBNavigationBottom($sExpand, $sCollapse);
1991}
1992
1993
1994
1995/**
1996 * Writes standard file info.
1997 *
1998 * @returns void
1999 * @param $db Database handle.
2000 * @param $iRefcode Author reference code.
2001 * @param $fFunctions Flags which tells wether to list all functions or not.
2002 * @param $fFiles Flags which tells wether to list all files or not.
2003 * @param $fAuthors Flags which tells wether to list all authors or not.
2004 * @param $fSortByState Flags which tells wether to sort functions by
2005 * state and function name or just by function name.
2006 * @sketch
2007 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
2008 * @remark
2009 */
2010function Odin32DBAPIGroupInfo($db, $iRefcode, $fFunctions, $fFiles, $fAuthors, $fSortByState)
2011{
2012 $sURLArgs = "apigrouprefcode=".$iRefcode.
2013 ($fFunctions ? "&fFunctions=1" : "").
2014 ($fFiles ? "&fFiles=1" : "").
2015 ($fAuthors ? "&fAuthors=1" : "").
2016 ($fSortByState ? "&fSortByState=1" : "");
2017
2018 /*
2019 * Navigation - TOP
2020 */
2021 $sExpand = "apigrouprefcode=".$iRefcode."&fFiles=1&fFunctions=1&fAuthors=1";
2022 if ($fSortByState) $sExpand = $sExpand."&fSortByState=".$fSortByState;
2023 $sCollapse = "apigrouprefcode=".$iRefcode;
2024 Odin32DBNavigationTop($sExpand, $sCollapse);
2025
2026 /*
2027 * Fetch (vital) data.
2028 */
2029 $sql = sprintf("SELECT\n".
2030 " g.name AS name,\n".
2031 " g.refcode AS refcode,\n".
2032 " g.description AS description,\n".
2033 " d.name AS dllname,\n".
2034 " d.refcode AS dllrefcode\n".
2035 "FROM\n".
2036 " apigroup g\n".
2037 " JOIN dll d\n".
2038 "WHERE\n".
2039 " g.refcode = %d AND".
2040 " g.dll = d.refcode\n",
2041 $iRefcode);
2042 if (($result = mysql_query($sql, $db)) && mysql_num_rows($result) > 0 && ($array = mysql_fetch_array($result)))
2043 {
2044 /*
2045 * General
2046 */
2047 Odin32DBNaslov("General", "general");
2048 echo "\n<table width=100% border=3 cellpadding=0>\n";
2049 Odin32DBInfoRow1("Name", $array, "name","","","","");
2050 Odin32DBInfoRow1("Dll", $array, "dllname","dllrefcode","dllrefcode","bad configuration","");
2051 if (isset($array["description"]))
2052 Odin32DBInfoRow1("Description", $array, "description","","","","");
2053 $sql = sprintf("SELECT\n".
2054 " COUNT(*) as functions\n".
2055 "FROM\n".
2056 " function\n".
2057 "WHERE\n".
2058 " apigroup = %d",
2059 $iRefcode);
2060 $cFunctions = 0;
2061 if (($result2 = mysql_query($sql, $db)) && mysql_num_rows($result2) > 0 && ($aFunctions = mysql_fetch_array($result2)))
2062 {
2063 Odin32DBInfoRow1("# Functions", $aFunctions, "functions","","","","");
2064 $cFunctions = $aFunctions["functions"];
2065 }
2066 $sql = sprintf("SELECT\n".
2067 " COUNT(*) as functions\n".
2068 "FROM\n".
2069 " function\n".
2070 "WHERE\n".
2071 " apigroup = %d AND".
2072 " file >= 0\n".
2073 "GROUP BY file",
2074 $iRefcode);
2075 $cFiles = 0;
2076 if (($result2 = mysql_query($sql, $db)) && ($cFiles = mysql_num_rows($result2)) > 0)
2077 Odin32DBInfoRow1NoArray("# Files", $cFiles, "","","","");
2078
2079 $sql = sprintf("SELECT\n".
2080 " COUNT(f.dll) as functions\n".
2081 "FROM\n".
2082 " fnauthor fa,\n".
2083 " function f\n".
2084 "WHERE\n".
2085 " f.apigroup = %d AND".
2086 " f.refcode = fa.function\n".
2087 "GROUP BY fa.author",
2088 $iRefcode);
2089 $cAuthors = 0;
2090 if (($result2 = mysql_query($sql, $db)) && ($cAuthors = mysql_num_rows($result2)) > 0)
2091 Odin32DBInfoRow1NoArray("# Authors", $cAuthors, "","","","");
2092
2093 echo "</table>\n";
2094
2095 /*
2096 * Completion
2097 */
2098 Odin32DBNaslov("Completion", "completion");
2099 Odin32DBCompletionBarAPIGroup($iRefcode, "", $db);
2100
2101 /*
2102 * States
2103 */
2104 $sql = sprintf("SELECT\n".
2105 " f.state,\n".
2106 " COUNT(f.state)\n".
2107 "FROM\n".
2108 " function\n".
2109 "WHERE\n".
2110 " f.apigroup = %d\n".
2111 "GROUP BY f.state\n".
2112 "ORDER BY f.state",
2113 $iRefcode);
2114 Odin32DBWriteStates($cFunctions, $sql, $db);
2115
2116 /*
2117 * Functions
2118 */
2119 Odin32DBNaslov("Functions", "functions");
2120 if ($fFunctions)
2121 {
2122 //TODO: optimize this...
2123 $sql = sprintf("SELECT\n".
2124 " f.refcode,\n".
2125 " f.name,\n".
2126 " s.color,\n".
2127 " s.name\n".
2128 "FROM\n".
2129 " function f\n".
2130 " LEFT JOIN state s ON f.state = s.refcode\n".
2131 "WHERE\n".
2132 " f.apigroup = %d\n",
2133 $iRefcode);
2134 if ($fSortByState)
2135 $sql = $sql."ORDER BY s.refcode, f.name";
2136 else
2137 $sql = $sql."ORDER BY f.name";
2138 Odin32DBWriteFunctions($sql, $db, $sURLArgs);
2139 }
2140 else
2141 echo "Click <a href=\"Odin32DB.phtml#functions?".$sURLArgs."&fFunctions=1".
2142 "\">here</a> to see all functions.\n";
2143
2144
2145 /*
2146 * Files
2147 */
2148 Odin32DBNaslov("Files", "files");
2149 if ($fFiles)
2150 {
2151 //TODO: optimize this...
2152 $sql = sprintf("SELECT\n".
2153 " f.refcode,\n".
2154 " f.name,\n".
2155 " COUNT(fn.refcode)\n".
2156 "FROM\n".
2157 " file f\n".
2158 " LEFT OUTER JOIN function fn ON fn.file = f.refcode\n".
2159 "WHERE\n".
2160 " fn.apigroup = %d\n".
2161 "GROUP BY f.refcode\n".
2162 "ORDER BY f.name\n",
2163 $iRefcode);
2164 Odin32DBWriteFiles($sql, $db);
2165 }
2166 else
2167 echo "Click <a href=\"Odin32DB.phtml#files?".$sURLArgs."&fFiles=1".
2168 "\">here</a> to see all files.\n";
2169
2170
2171 /*
2172 * Authors
2173 */
2174 Odin32DBNaslov("Authors", "authors");
2175 if ($fAuthors)
2176 {
2177 //TODO: optimize this...
2178 $sql = sprintf("SELECT\n".
2179 " a.refcode,\n".
2180 " a.name,\n".
2181 " COUNT(f.refcode)\n".
2182 "FROM\n".
2183 " fnauthor fa\n".
2184 " JOIN function f\n".
2185 " JOIN author a\n".
2186 "WHERE\n".
2187 " f.apigroup = %d AND\n".
2188 " fa.function = f.refcode AND\n".
2189 " fa.author = a.refcode\n".
2190 "GROUP BY a.refcode\n".
2191 "ORDER BY a.name\n",
2192 $iRefcode
2193 );
2194 Odin32DBWriteAuthors($sql, $db);
2195 }
2196 else
2197 echo "Click <a href=\"Odin32DB.phtml#authors?".$sURLArgs."&fAuthors=1".
2198 "\">here</a> to see all authors.\n";
2199 }
2200 else
2201 {
2202 echo "<p> No data! Invalid refcode? </p>";
2203 Odin32DBSqlError($sql);
2204 }
2205
2206 /*
2207 * Navigation - Bottom
2208 */
2209 Odin32DBNavigationBottom($sExpand, $sCollapse);
2210}
2211
2212
2213
2214
2215
2216/* TEXT FORMATTING OVERLOADS */
2217/* TEXT FORMATTING OVERLOADS */
2218/* TEXT FORMATTING OVERLOADS */
2219$aContent = array();
2220$aaSubContent = array();
2221$fNumberSections = 0;
2222
2223/**
2224 * Call this to autogenerate section and subsection numbers.
2225 */
2226function ODin32DBNumberSections()
2227{
2228 global $fNumberSections;
2229 $fNumberSections = 1;
2230}
2231
2232
2233/**
2234 * Makes the contents for this page.
2235 * @sketch Writes the headers present in the contents array.
2236 */
2237function Odin32DBWriteContents()
2238{
2239 global $aContent;
2240 global $aaSubContent;
2241
2242 echo "\n",
2243 "<tr><td>\n";
2244
2245 for ($i = 0; $i < sizeof($aContent); $i += 2)
2246 {
2247 echo "<font size=-2 face=\"WarpSans, Helv, Helvetica, Arial\">".
2248 "<a href=\"#".$aContent[$i+1]."\"><font color=000099>".
2249 $aContent[$i]."</font></a><br>\n";
2250
2251 $aSubContent = $aaSubContent[$i/2];
2252 echo "\n";
2253 if (sizeof($aSubContent) > 0)
2254 {
2255 echo "<table>\n";
2256 for ($j = 0; $j < sizeof($aSubContent); $j += 2)
2257 {
2258 echo "<tr><td width=10%>&nbsp;</td>\n",
2259 " <td><font size=-2 face=\"WarpSans, Helv, Helvetica, Arial\">".
2260 "<font size=-2 face=\"WarpSans, Helv, Helvetica, Arial\">".
2261 "<a href=\"#".$aSubContent[$j+1]."\"><font color=000099>".
2262 $aSubContent[$j]."</font></a><br>\n";
2263 echo "</td></tr>\n";
2264 }
2265 echo "</table>\n";
2266 }
2267 else
2268 echo "<p>\n";
2269 }
2270
2271 echo "</td></tr>\n";
2272}
2273
2274/**
2275 * Forwarder which also maintains the contents array.
2276 */
2277function Odin32DBNaslov($sFull, $sShort)
2278{
2279 global $aContent;
2280 global $aaSubContent;
2281 global $fNumberSections;
2282
2283 if ($fNumberSections)
2284 $sFull = (sizeof($aContent)/2 + 1).". ".$sFull;
2285
2286 $aContent[] = $sFull;
2287 $aContent[] = $sShort;
2288 $aaSubContent[] = array();
2289 return Naslov($sFull, $sShort);
2290}
2291
2292
2293/**
2294 * Forwarder which also maintains the contents array.
2295 * Equal to Odin32DBNaslov, but have allows a different contents text.
2296 */
2297function Odin32DBNaslov2($sFull, $sFullContents, $sShort)
2298{
2299 global $aContent;
2300 global $aaSubContent;
2301 global $fNumberSections;
2302
2303 if ($fNumberSections)
2304 {
2305 $sFull = (sizeof($aContent)/2 + 1).". ".$sFull;
2306 $sFullContents = (sizeof($aContent)/2 + 1).". ".$sFullContents;
2307 }
2308
2309 $aContent[] = $sFullContents;
2310 $aContent[] = $sShort;
2311 $aaSubContent[] = array();
2312 return Naslov($sFull, $sShort);
2313}
2314
2315
2316/**
2317 * Sub title with contents entry.
2318 */
2319function Odin32DBPodNaslov($sFull, $sShort)
2320{
2321 global $aContent;
2322 global $aaSubContent;
2323 global $fNumberSections;
2324
2325 $j = (sizeof($aContent) / 2) - 1;
2326 $aSubContent = $aaSubContent[$j];
2327
2328 if ($fNumberSections)
2329 $sFull = (sizeof($aContent)/2).".".(sizeof($aSubContent)/2 + 1)." ".$sFull;
2330
2331 $aSubContent[] = $sFull;
2332 $aSubContent[] = $sShort;
2333 $aaSubContent[$j] = $aSubContent;
2334 echo "<p><b><a name=\"".$sShort."\"><font size=+0 face=\"Helv, Arial\"><br>".$sFull."</font></b></a><p>";
2335}
2336
2337?>
2338
Note: See TracBrowser for help on using the repository browser.