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

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

More coding done...

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