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

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

Fixes. Changed database to Odin32.

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