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

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

dll to module conversion.

File size: 85.1 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 module.
116 * @returns Completion percentage. Range 0-100.
117 * On error -1 or -2 is returned.
118 * @param $iModule Module reference code.
119 * @param $db Database connection variable.
120 * @sketch Get total number of function in the module.
121 * Get number of completed functions in the module.
122 * return complete*100 / total
123 * @status Completely implemented
124 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
125 * @remark
126 */
127function Odin32DBComputeCompletion($iModule, $db)
128{
129 /*
130 * Count the total number of functions in the module.
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 module = %d",
139 $iModule);
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 module (or all modules.).
168 * @param $iModule Module reference code.
169 * If < 0 then for the entire project.
170 * @param $iModName Module 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 Odin32DBCompletionBarModule($iModule, $sModName, $db)
177{
178 if ($iModule < 0)
179 return Odin32DBcompletionBar2("", $sModName, $db);
180 return Odin32DBcompletionBar2("module = ".$iModule." AND f.type IN ('A', 'I')", $sModName, $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 for the author.
224 */
225 $sql = "SELECT COUNT(*) FROM fnauthor fa JOIN function f\n".
226 "WHERE fa.function = f.refcode AND fa.author = ".$iAuthor." AND f.type IN ('A', 'I')";
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 AND\n".
263 " f.type IN ('A', 'I')\n".
264 "GROUP BY s.refcode\n".
265 "ORDER BY state\n";
266 $rdCompletePercent = 0.0;
267 if (!($result = mysql_query($sql, $db)))
268 Odin32DBSqlError($sql);
269 else if (mysql_num_rows($result) < 1)
270 echo " <td colspan=2 bgcolor=#dddddd><font size=-1>&nbsp;</font></td>\n";
271 else
272 {
273 while ($row = mysql_fetch_row($result))
274 {
275 $iPercent = (int)($row[0] * 90 /* 10% is reserved to % */ / $cFunctions);
276 if ($iPercent == 0)
277 $iPercent = 1;
278 echo " <td width=".$iPercent." bgcolor=".$row[2]."><font size=-1>&nbsp;</font></td>\n";
279
280 $rdCompletePercent += ((double)$row[3] * (double)$row[0]) / $cFunctions;
281 }
282
283 }
284 mysql_free_result($result);
285
286 /*
287 * Complete bar with a total completion percent.
288 */
289 echo " <td width=10% align=right><font size=-1 color=#000099>".(int)$rdCompletePercent."%</font></td>\n".
290 " </tr>\n".
291 " </table>\n".
292 "</td></tr>\n".
293 "</table>\n";
294}
295
296/**
297 * Draws a completion bar.
298 * @param $sCondition Where conditions.
299 * @param $sName Name...
300 * @param $db Database connection variable.
301 * @sketch Get total number of function in the selection.
302 * Get the number of function per status. (+state color)
303 * Draw bar.
304 * @status Completely implemented
305 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
306 */
307function Odin32DBCompletionBar2($sCondition, $sName, $db)
308{
309 /*
310 * Count the total number of functions in selection.
311 */
312 $sql = "SELECT COUNT(*) FROM function f";
313 if ($sCondition != "") $sql = $sql." WHERE f.".$sCondition;
314 if (($result = mysql_query($sql, $db)) && mysql_num_rows($result) < 1)
315 {
316 printf("\n\n<br>Odin32DBCompletionBar2: IPE(1).<br>\n\n");
317 Odin32DBSqlError($sql);
318 return -1;
319 }
320 $row = mysql_fetch_row($result);
321 $cFunctions = $row[0];
322 mysql_free_result($result);
323
324
325 /*
326 * Double table. Eventually write the name.
327 */
328 echo "\n<table width=100% border=0 cellspacing=0 cellpadding=0>\n";
329 if ($sName != "")
330 echo "<tr><td width=90%><font size=-1 color=#000099><tt>".$sName."</tt></font></td><td width=10%></td></tr>\n";
331 echo "<tr><td width=90%>\n".
332 " <table width=100% border=0 cellspacing=0 cellpadding=0>\n".
333 " <tr>\n";
334
335 /*
336 * Get states and make bar.
337 */
338 if ($sCondition != "") $sCondition = "f.".$sCondition." AND";
339 $sql = "SELECT\n".
340 " COUNT(f.refcode) AS count,\n".
341 " s.refcode AS state,\n".
342 " s.color AS color,\n".
343 " s.weight AS weight\n".
344 "FROM\n".
345 " function f,\n".
346 " state s\n".
347 "WHERE\n".
348 " ".$sCondition."\n".
349 " s.refcode = f.state\n".
350 "GROUP BY s.refcode\n".
351 "ORDER BY state\n";
352 $rdCompletePercent = 0.0;
353 if (!($result = mysql_query($sql, $db)))
354 Odin32DBSqlError($sql);
355 else if (mysql_num_rows($result) < 1)
356 echo " <td colspan=2 bgcolor=#dddddd><font size=-1>&nbsp;</font></td>\n";
357 else
358 {
359 while ($row = mysql_fetch_row($result))
360 {
361 $iPercent = (int)($row[0] * 90 /* 10% is reserved to % */ / $cFunctions);
362 if ($iPercent == 0)
363 $iPercent = 1;
364 echo " <td width=".$iPercent." bgcolor=".$row[2]."><font size=-1>&nbsp;</font></td>\n";
365 $rdCompletePercent += ((double)$row[3] * (double)$row[0]) / $cFunctions;
366 }
367
368 }
369 mysql_free_result($result);
370
371 /*
372 * Complete bar with a total completion percent.
373 */
374 echo " <td width=10% align=right><font size=-1 color=#000099>".(int)$rdCompletePercent."%</font></td>\n".
375 " </tr>\n".
376 " </table>\n".
377 "</td></tr>\n".
378 "</table>\n";
379}
380
381
382/**
383 * Draws a legend for status colors.
384 * @param $db Database connection variable.
385 * @sketch Get status codes; fetch name and color.
386 *
387 *
388 * @status Completely implemented
389 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
390 */
391function Odin32DBStateLegend($db)
392{
393 /*
394 * Select the states.
395 */
396 $sql = "SELECT name,
397 color
398 FROM state
399 ORDER BY refcode";
400 if (($result = mysql_query($sql, $db)) && mysql_num_rows($result) < 1)
401 {
402 printf("\n\n<br>Odin32DBStateLegned: IPE(1).<br>\n\n");
403 return -1;
404 }
405 else
406 {
407 echo "\n".
408 "<tr><td></td></tr>\n".
409 "<tr><td><center><B><font face=\"WarpSans, Arial\" color=\"#990000\">Status Legend:</font></b></center></td></tr>\n".
410 "<tr><td>\n".
411 " <table width=100% border=0 cellspacing=2 cellpadding=0 align=right>\n";
412
413 while ($row = mysql_fetch_row($result))
414 echo " <tr><td width=85% align=right><font size=1 color=#000099>".$row[0]."</font></td>\n".
415 " <td width=15% bgcolor=".$row[1]."><font size=-1>&nbsp;<br>&nbsp;</font></td>\n".
416 " </tr>\n";
417
418 echo " </table>\n".
419 "</td></tr>\n";
420 }
421
422
423 mysql_free_result($result);
424}
425
426
427/**
428 * Dump an SQL statement in HTML.
429 *
430 * @returns nothing.
431 * @param $sql Sql to display.
432 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
433 */
434function Odin32DBSqlError($sql)
435{
436 echo "<p><font size=1 face=\"courier\">
437 SQL-Error:<br>
438 ".mysql_error()."
439 <br>
440 </font>
441 </p>
442 ";
443
444 echo "<p><font size=1 face=\"courier\">
445 SQL:<br>
446 ".str_replace(" ", "&nbsp;", str_replace("\n", "<br>\n", $sql))."
447 <br>
448 </font>
449 </p>
450 ";
451}
452
453
454/**
455 *
456 * @returns
457 * @param $sName
458 * @param $array Result array.
459 * @param $sValueName Name in the $array for the value.
460 * @param $sRefName Name in the $array for the reference.
461 * @param $sOdin32DBArg Odin32DB.phtml argument.
462 * @param $sNullText Null text (if the array element is NULL display this).
463 * @param $sPostText Text to insert after the value.
464 *
465 */
466function Odin32DBInfoRow1($sName, $array, $sValueName, $sRefName, $sOdin32DBArg, $sNullText, $sPostText)
467{
468 echo " <tr>\n".
469 " <td width=35%><tt>".$sName."</tt></td>\n".
470 " <td valign=top>";
471 if (isset($array[$sValueName]))
472 {
473 if ($sRefName != "" && isset($array[$sRefName]) && $sOdin32DBArg != "")
474 {
475 echo "<a href=\"Odin32DB.phtml?".$sOdin32DBArg."=".$array[$sRefName]."\">";
476 $sPostText = "</a>".$sPostText;
477 }
478 echo $array[$sValueName];
479 echo $sPostText;
480 }
481 else if ($sNullText != "")
482 echo "<i>".$sNullText."</i>";
483
484 echo "</td>\n".
485 " </tr>\n";
486}
487
488
489/**
490 *
491 * @returns
492 * @param $sName
493 * @param $sValue Value.
494 * @param $sRef Reference.
495 * @param $sOdin32DBArg Odin32DB.phtml argument.
496 * @param $sNullText Null text (if the array element is NULL display this).
497 * @param $sPostText Text to insert after the value.
498 *
499 */
500function Odin32DBInfoRow1NoArray($sName, $sValue, $sRef, $sOdin32DBArg, $sNullText, $sPostText)
501{
502 echo " <tr>\n".
503 " <td width=35%><tt>".$sName."</tt></td>\n".
504 " <td valign=top>";
505 if (isset($sValue) && $sValue != "")
506 {
507 if (isset($sRef) && $sRef != "" && $sOdin32DBArg != "")
508 {
509 echo "<a href=\"Odin32DB.phtml?".$sOdin32DBArg."=".$sRef."\">";
510 $sPostText = "</a>".$sPostText;
511 }
512 echo $sValue.$sPostText;
513 }
514 else if ($sNullText != "")
515 echo "<i>".$sNullText."</i>";
516
517 echo "</td>\n".
518 " </tr>\n";
519}
520
521
522
523/**
524 *
525 * @returns
526 * @param $sName
527 * @param $array Result array.
528 * @param $sValueName1 Name in the $array for the value.
529 * @param $sRefName1 Name in the $array for the reference.
530 * @param $sOdin32DBArg1 Odin32DB.phtml argument.
531 * @param $sNullText Null text (if the array element is NULL display this).
532 * @param $sPostText Text to insert after the value.
533 * @param $sValueName2 Name in the $array for the value.
534 * @param $sRefName2 Name in the $array for the reference.
535 * @param $sOdin32DBArg2 Odin32DB.phtml argument.
536 *
537 */
538function Odin32DBInfoRow2($sName, $array, $sValueName1, $sRefName1, $sOdin32DBArg1, $sNullText, $sPostText,
539 $sValueName2, $sRefName2, $sOdin32DBArg2)
540{
541 echo " <tr>\n".
542 " <td width=35%><tt>".$sName."</tt></td>\n".
543 " <td valign=top>";
544 if (isset($array[$sValueName1]))
545 {
546 if ($sRefName1 != "" && isset($array[$sRefName1]) && $sOdin32DBArg1 != "")
547 {
548 echo "<a href=\"Odin32DB.phtml?".$sOdin32DBArg1."=".$array[$sRefName1]."\">";
549 $sPostText = "</a>".$sPostText;
550 }
551 echo $array[$sValueName1];
552 echo $sPostText;
553
554 if (isset($array[$sValueName2]))
555 {
556 if ($sRefName2 != "" && isset($array[$sRefName2]) && $sOdin32DBArg2 != "")
557 {
558 echo "<a href=\"Odin32DB.phtml?".$sOdin32DBArg2."=".$array[$sRefName2]."\">";
559 echo $array[$sValueName2]."</a>";
560 }
561 else
562 echo $array[$sValueName2];
563 }
564 }
565 else if ($sNullText != "")
566 echo "<i>".$sNullText."</i>";
567
568 echo "</td>\n".
569 " </tr>\n";
570}
571
572
573
574/**
575 * Inserts a documentation row from database..
576 * @param $sName Name of the information.
577 * @param $array DB result array.
578 * @param $sValueName Name in the DB result array.
579 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
580 * @remark Displays <i>not available</i> if empty field.
581 */
582function Odin32DBDocRow1($sName, $array, $sValueName)
583{
584 PodNaslov($sName);
585 if (isset($array[$sValueName]))
586 {
587 echo $array[$sValueName];
588 }
589 else
590 echo "<i>not available</i>";
591}
592
593
594/**
595 * Using (Odin32DB)Naslov.
596 * Inserts a documentation row from database..
597 * @param $sName Name of the information.
598 * @param $sLabel Section label.
599 * @param $array DB result array.
600 * @param $sValueName Name in the DB result array.
601 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
602 * @remark Displays <i>not available</i> if empty field.
603 */
604function Odin32DBDocRow($sName, $sLabel, $array, $sValueName)
605{
606 Odin32DBNaslov($sName, $sLabel);
607 if (isset($array[$sValueName]))
608 {
609 echo $array[$sValueName];
610 }
611 else
612 echo "<i>not available</i>";
613}
614
615
616/**
617 * Writes a state section based on a sqlstatment returning the following values (ordered):
618 * 0. state
619 * 1. functions
620 *
621 * @returns nothing.
622 * @param $cFunctions Number of functions.
623 * @param $sql Sql statement.
624 * @param $db Database connection.
625 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
626 */
627function Odin32DBWriteStates($cFunctions, $sql, $db)
628{
629 Odin32DBNaslov("Status", "status");
630 if ($result2 = mysql_query($sql, $db))
631 {
632 $result = mysql_query("SELECT refcode, name, color FROM state ORDER BY refcode", $db);
633 if ($result)
634 {
635 echo "\n<table width=100% border=0 cellpadding=0>\n";
636
637 $aState2 = mysql_fetch_array($result2);
638 while ($aState = mysql_fetch_row($result))
639 {
640 if ($aState2 && $aState[0] == $aState2[0])
641 {
642 $cStateFunctions = (int)$aState2[1];
643 $aState2 = mysql_fetch_array($result2);
644 }
645 else
646 $cStateFunctions = 0;
647 printf("<tr>\n".
648 " <td width=75%%><font size=-1 color=%s>%s</font></td>\n".
649 " <td align=right><font size=-1 color=%s>%s</font></td>\n".
650 " <td align=right><font size=-1 color=%s>%d%%</font></td>\n".
651 "</tr>\n",
652 $aState[2], $aState[1],
653 $aState[2], $cStateFunctions,
654 $aState[2], @(int)($cStateFunctions * 100 / $cFunctions));
655 }
656
657 echo "</table>\n";
658 }
659 else
660 Odin32DBSqlError($sql);
661 }
662 else
663 Odin32DBSqlError($sql);
664}
665
666
667/**
668 * Writes the a function listing base sqlstatement with these columns (ordered):
669 * 0. Module refcode
670 * 1. Module name
671 * 2. number of functions
672 *
673 * @returns nothing
674 * @param $sql SQL statement.
675 * @param $db Database connection.
676 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
677 */
678function Odin32DBWriteModules($sql, $db)
679{
680 if ($result2 = mysql_query($sql, $db))
681 {
682 if (mysql_num_rows($result2) > 0)
683 {
684 echo "\n<table width=100% border=0 cellpadding=0>\n".
685 "<tr>\n".
686 " <td width=75%><font size=-1><b>Modules</b></font></td>\n".
687 " <td align=right><font size=-1><b>Functions</b></font></td>\n".
688 "</tr>\n";
689 while ($aFunction = mysql_fetch_array($result2))
690 printf("<tr>".
691 "<td><font size=-1><a href=\"Odin32DB.phtml?modrefcode=%s\">%s</a></font></td>".
692 "<td align=right><font size=-1>%s</font></td>".
693 "</tr>\n",
694 $aFunction[0], $aFunction[1], $aFunction[2]);
695
696 echo "</table>\n";
697 }
698 else
699 echo "<i>No Files.</i><br>\n";
700 }
701 else
702 Odin32DBSqlError($sql);
703}
704
705
706/**
707 * Writes the a function listing base sqlstatement with these columns (ordered):
708 * 0. function refcode
709 * 1. function name
710 * 2. state color
711 * 3. state name
712 *
713 * @returns nothing
714 * @param $sql SQL statement.
715 * @param $db Database connection.
716 * @param $sURLArgs URL arguments.
717 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
718 */
719function Odin32DBWriteFunctions($sql, $db, $sURLArgs)
720{
721 if ($result2 = mysql_query($sql, $db))
722 {
723 if (mysql_num_rows($result2) > 0)
724 {
725 echo
726 "<table width=100% border=0 cellpadding=0>\n",
727 "<tr>\n",
728 " <td width=75%><font size=-1><b>Function Name</b></font></td>\n",
729 " <td><font size=-1><b>State</b></font></td>\n",
730 "</tr>\n";
731
732 while ($aFunction = mysql_fetch_row($result2))
733 printf("<tr>".
734 "<td><font size=-1><a href=\"Odin32DB.phtml?functionrefcode=%s\">%s</a></font></td>".
735 "<td><font size=-1 color=%s>%s</font></td></tr>\n",
736 $aFunction[0], $aFunction[1], $aFunction[2], $aFunction[3]);
737
738 echo "</table></font>\n";
739
740 /*
741 * Sort text.
742 */
743 $fSortByState = strstr($sURLArgs, "&fSortByState=1");
744 if ($fSortByState)
745 $sURLArgs = str_replace("&fSortByState=1", "", $sURLArgs);
746 else
747 $sURLArgs = $sURLArgs."&fSortByState=1";
748
749 echo "<p>Click <a href=\"Odin32DB.phtml#functions?".$sURLArgs."\">here</a> to view functions sorted ".
750 ($fSortByState ? "alphabetical" : "by state"). ".<br>";
751 }
752 else
753 echo "<i>No Functions.</i><br>\n";
754 mysql_free_result($result2);
755 }
756 else
757 Odin32DBSqlError($sql);
758}
759
760
761/**
762 * Writes the a function listing base sqlstatement with these columns (ordered):
763 * 0. module refcode
764 * 1. module name
765 * 2. function refcode
766 * 3. function name
767 * 4. state color
768 * 5. state name
769 *
770 * @returns nothing
771 * @param $sql SQL statement.
772 * @param $db Database connection.
773 * @param $sURLArgs URL arguments.
774 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
775 */
776function Odin32DBWriteFunctionsWithModules($sql, $db, $sURLArgs)
777{
778 if ($result2 = mysql_query($sql, $db))
779 {
780 if (mysql_num_rows($result2) > 0)
781 {
782 echo "\n<table width=100% border=0 cellpadding=0>\n".
783 "<tr>\n".
784 " <td width=30%><font size=-1><b>Module Name</b></font></td>\n".
785 " <td width=45%><font size=-1><b>Function Name</b></font></td>\n".
786 " <td><font size=-1><b>State</b></font></td>\n".
787 "</tr>\n";
788 while ($aFunction = mysql_fetch_row($result2))
789 printf("<tr>".
790 "<td><font size=-1><a href=\"Odin32DB.phtml?modrefcode=%s\">%s</a></font></td>".
791 "<td><font size=-1><a href=\"Odin32DB.phtml?functionrefcode=%s\">%s</a></font></td>".
792 "<td><font size=-1 color=%s>%s</font></td>".
793 "</tr>\n",
794 $aFunction[2], $aFunction[3],
795 $aFunction[0], $aFunction[1],
796 $aFunction[4], $aFunction[5]);
797
798 echo "</table>\n";
799
800 /*
801 * Sort text.
802 */
803 $fSortByState = strstr($sURLArgs, "&fSortByState=1");
804 if ($fSortByState)
805 $sURLArgs = str_replace("&fSortByState=1", "", $sURLArgs);
806 else
807 $sURLArgs = $sURLArgs."&fSortByState=1";
808
809 echo "<p>Click <a href=\"Odin32DB.phtml#functions?".$sURLArgs."\">here</a> to view functions sorted ".
810 ($fSortByState ? "alphabetical by module" : "by state"). ".<br>";
811 }
812 else
813 echo "<i>No functions found</i><br>\n";
814 }
815 else
816 Odin32DBSqlError($sql);
817}
818
819
820/**
821 * Writes the a file listing base sqlstatement with these columns (ordered):
822 * 0. file refcode
823 * 1. file name
824 * 2. number of functions
825 *
826 * @returns nothing
827 * @param $sql SQL statement.
828 * @param $db Database connection.
829 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
830 */
831function Odin32DBWriteFiles($sql, $db)
832{
833 if ($result2 = mysql_query($sql, $db))
834 {
835 if (mysql_num_rows($result2) > 0)
836 {
837 echo "\n<table width=100% border=0 cellpadding=0>\n".
838 "<tr>\n".
839 " <td><font size=-1><b>Filename</b></font></td>\n".
840 " <td align=right><font size=-1><b>Functions</b></font></td>\n".
841 "</tr>\n";
842 while ($aFile = mysql_fetch_row($result2))
843 printf("<tr>".
844 "<td width=75%%><font size=-1><a href=\"Odin32DB.phtml?filerefcode=%s\">%s</a></font></td>".
845 "<td align=right><font size=-1>%s</font></td>".
846 "</tr>\n",
847 $aFile[0], $aFile[1], $aFile[2]);
848
849 echo "</table>\n";
850 }
851 else
852 echo "<i>No Files.</i><br>\n";
853 }
854 else
855 Odin32DBSqlError($sql);
856}
857
858
859/**
860 * Writes the an API Group listing base sqlstatement with these columns (ordered):
861 * 0. apigroup refcode
862 * 1. apigroup name
863 * 2. number of functions
864 *
865 * @returns nothing
866 * @param $sql SQL statement.
867 * @param $db Database connection.
868 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
869 */
870function Odin32DBWriteAPIGroups($sql, $db)
871{
872 if ($result2 = mysql_query($sql, $db))
873 {
874 if (mysql_num_rows($result2) > 0)
875 {
876 echo "\n<table width=100% border=0 cellpadding=0>\n".
877 "<tr>\n".
878 " <td width=75%><font size=-1><b>Group Name</b></font></td>\n".
879 " <td align=right><font size=-1><b>Functions</b></font></td>\n".
880 "</tr>\n";
881 while ($aAPIGroup = mysql_fetch_row($result2))
882 printf("<tr>".
883 "<td><font size=-1><a href=\"Odin32DB.phtml?apigrouprefcode=%s\">%s</a></font></td>".
884 "<td align=right><font size=-1>%s</font></td>".
885 "</tr>\n",
886 $aAPIGroup[0], $aAPIGroup[1], $aAPIGroup[2]);
887 echo "</table>\n";
888 }
889 else
890 echo "<i>No API Groups.</i><br>\n";
891 mysql_free_result($result2);
892 }
893 else
894 Odin32DBSqlError($sql);
895}
896
897
898
899/**
900 * Writes the a author listing base sqlstatement with these columns (ordered):
901 * 0. author refcode
902 * 1. author name
903 * 2. number of functions
904 *
905 * @returns nothing
906 * @param $sql SQL statement.
907 * @param $db Database connection.
908 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
909 */
910function Odin32DBWriteAuthors($sql, $db)
911{
912 if ($result2 = mysql_query($sql, $db))
913 {
914 if (mysql_num_rows($result2) > 0)
915 {
916 echo "\n<table width=100% border=0 cellpadding=0>\n".
917 "<tr>\n".
918 " <td width=75%><font size=-1><b>Author</b></font></td>\n".
919 " <td align=right><font size=-1><b>Functions</b></font></td>\n".
920 "</tr>\n";
921 while ($aAuthor = mysql_fetch_row($result2))
922 printf("<tr>".
923 "<td><font size=-1><a href=\"Odin32DB.phtml?authorrefcode=%s\">%s</a></font></td>".
924 "<td align=right><font size=-1>%s</font></td>".
925 "</tr>\n",
926 $aAuthor[0], $aAuthor[1], $aAuthor[2]);
927
928 echo "</table>\n";
929 }
930 else
931 echo "<i>No Authors</i>.<br>\n";
932 mysql_free_result($result2);
933 }
934 else
935 Odin32DBSqlError($sql);
936}
937
938
939/* NAVIGATION */
940/* NAVIGATION */
941/* NAVIGATION */
942
943/**
944 * Make top of page navigation stuff for the Odin32 database pages.
945 * @param $sExpand Expand arguments.
946 * @param $sCollapse Collapse arguments.
947 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
948 */
949function Odin32DBNavigationTop($sExpand, $sCollapse)
950{
951 echo "\n<center><font size=1>\n";
952
953 echo "<a href=\"Odin32DB.phtml\">Root</a>\n".
954 " - <a href=\"Odin32DB.phtml?modules=1\">Moduless</a>\n".
955 " - <a href=\"Odin32DB.phtml?authors=1\">Authors</a>\n".
956 " - <a href=\"Odin32DB.phtml?apigroups=1\">API Groups</a>\n";
957
958 if ($sExpand != "" && $sCollapse != "")
959 {
960 echo "<br><a href=\"Odin32DB.phtml?".$sExpand."\">Expand All</a> - \n".
961 "<a href=\"Odin32DB.phtml?".$sCollapse."\">Collapse All</a>\n";
962 }
963
964 echo "</font></center>\n";
965}
966
967
968/**
969 * Make bottom of page navigation stuff for the Odin32 database pages.
970 * @param $sExpand Expand arguments.
971 * @param $sCollapse Collapse arguments.
972 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
973 */
974function Odin32DBNavigationBottom($sExpand, $sCollapse)
975{
976 echo "\n<p><br><center>\n".
977 "<font size=1>\n";
978
979 if ($sExpand != "" && $sCollapse != "")
980 {
981 echo "<a href=\"Odin32DB.phtml?".$sExpand."\">Expand All</a> - \n".
982 "<a href=\"Odin32DB.phtml?".$sCollapse."\">Collapse All</a><br>\n";
983 }
984
985 echo
986 "<a href=\"Odin32DB.phtml\">Root</a>\n".
987 " - <a href=\"Odin32DB.phtml?moduless=1\">Modules</a>\n".
988 " - <a href=\"Odin32DB.phtml?authors=1\">Authors</a>\n".
989 " - <a href=\"Odin32DB.phtml?apigroups=1\">API Groups</a>\n";
990 echo "</font></center>\n";
991}
992
993
994
995/* INFO OUTPUT */
996/* INFO OUTPUT */
997/* INFO OUTPUT */
998
999
1000/**
1001 * Writes standard function info.
1002 *
1003 * @returns void
1004 * @param $db Database handle.
1005 * @param $iRefcode Function reference code.
1006 * @sketch
1007 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
1008 * @remark
1009 */
1010function Odin32DBFunctionInfo($db, $iRefcode)
1011{
1012 Odin32DBNavigationTop("","");
1013
1014 $sql = sprintf("SELECT\n".
1015 " f.name AS name,\n".
1016 " f.intname AS intname,\n".
1017 " f.ordinal AS ordinal,\n".
1018 " f.return AS return,\n".
1019 " f.description AS description,\n".
1020 " f.remark AS remark,\n".
1021 " f.returndesc AS returndesc,\n".
1022 " f.sketch AS sketch,\n".
1023 " f.equiv AS equiv,\n".
1024 " f.time AS time,\n".
1025 " f.line AS line,\n".
1026 " g.name AS apigroupname,\n".
1027 " g.refcode AS apigrouprefcode,\n".
1028 " a.name AS aliasname,\n".
1029 " a.refcode AS aliasrefcode,\n".
1030 " ad.name AS aliasnmodname,\n".
1031 " ad.refcode AS aliasmodrefcode,\n".
1032 " d.name AS modname,\n".
1033 " d.refcode AS modrefcode,\n".
1034 " i.name AS filename,\n".
1035 " i.refcode AS filerefcode,\n".
1036 " s.name AS state,\n".
1037 " c.description AS type\n".
1038 "FROM\n".
1039 " function f\n".
1040 " LEFT OUTER JOIN function a ON f.aliasfn = a.refcode\n".
1041 " LEFT OUTER JOIN module ad ON a.module = ad.refcode\n".
1042 " LEFT OUTER JOIN apigroup g ON f.apigroup = g.refcode\n".
1043 " LEFT JOIN module d ON f.module = d.refcode\n".
1044 " LEFT JOIN state s ON f.state = s.refcode\n".
1045 " LEFT OUTER JOIN file i ON f.file = i.refcode\n".
1046 " LEFT JOIN code c ON f.type = c.code\n".
1047 "WHERE\n".
1048 " c.codegroup = 'FTYP' AND\n".
1049 " f.refcode = %d",
1050 $iRefcode);
1051 if (($result = mysql_query($sql, $db)) && @mysql_num_rows($result) > 0 && ($array = mysql_fetch_array($result)))
1052 {
1053 /*
1054 * General
1055 */
1056 Odin32DBNaslov("General", "general");
1057 echo "\n<table width=100% border=3 cellpadding=0>\n";
1058 Odin32DBInfoRow1("Name", $array, "name","","","","");
1059 if (isset($array["intname"]))
1060 Odin32DBInfoRow1("Internal Name", $array, "intname","","","","");
1061 else
1062 Odin32DBInfoRow1("Internal Name", $array, "name","","","","");
1063 Odin32DBInfoRow1("Type", $array, "type", "", "","invalid","");
1064 Odin32DBInfoRow1("State", $array, "state", "", "","invalid","");
1065 Odin32DBInfoRow1("Module", $array, "modname", "modrefcode", "modrefcode","","");
1066 Odin32DBInfoRow1("Ordinal", $array, "ordinal","","","not available","");
1067 if (isset($array["apigroupname"]))
1068 Odin32DBInfoRow1("API Group", $array, "apigroupname", "apigrouprefcode", "apigrouprefcode","","");
1069 Odin32DBInfoRow1("File", $array, "filename", "filerefcode", "filerefcode", "not available",
1070 " (<a href=\"cvs.phtml#".$array["line"]."?sFile=./src/".$array["modname"]."/".$array["filename"].",v&sRevision=\">cvs</a>)");
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, "aliasmodname", "aliasmodrefcode", "modrefcode","",".",
1077 "aliasname", "aliasrefcode", "functionrefcode");
1078 else
1079 {
1080 $sql = sprintf("SELECT\n".
1081 " m.name AS modname,\n".
1082 " m.refcode AS modrefcode,\n".
1083 " f.name AS fnname,\n".
1084 " f.refcode AS fnrefcode\n".
1085 "FROM\n".
1086 " function f,\n".
1087 " module m\n".
1088 "WHERE\n".
1089 " f.aliasfn = %d AND\n".
1090 " f.module = m.refcode\n".
1091 "ORDER BY m.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?modrefcode=".
1104 $aAlias["modrefcode"]."\">".$aAlias["modname"]."</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 module info.
1247 *
1248 * @returns void
1249 * @param $db Database handle.
1250 * @param $iRefcode Module 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 Odin32DBModuleInfo($db, $iRefcode, $fFunctions, $fFiles, $fAPIGroups, $fAuthors, $fSortByState)
1262{
1263 $sURLArgs = "modrefcode=".$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 = "modrefcode=".$iRefcode."&fFiles=1&fFunctions=1&fAPIGroups=1&fAuthors=1";
1274 if ($fSortByState) $sExpand = $sExpand."&fSortByState=".$fSortByState;
1275 $sCollapse = "modrefcode=".$iRefcode;
1276 Odin32DBNavigationTop($sExpand, $sCollapse);
1277
1278 /*
1279 * Fetch (vital) data.
1280 */
1281 $sql = sprintf("SELECT\n".
1282 " m.name AS name,\n".
1283 " m.description AS description,\n".
1284 " c.description AS type\n".
1285 "FROM\n".
1286 " module d,\n".
1287 " code c\n".
1288 "WHERE\n".
1289 " c.codegroup = 'DTYP' AND\n".
1290 " m.type = c.code AND\n".
1291 " m.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 " module = %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 " module = %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 " module = %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 Odin32DBCompletionBarModule($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 " module = %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.module = %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.module = %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.module = %d AND\n".
1439 " f.module = %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.module = %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.module AS modrefcode,\n".
1537 " m.name AS modname\n".
1538 "FROM\n".
1539 " file f,\n".
1540 " module m,\n".
1541 " author a\n".
1542 "WHERE\n".
1543 " f.refcode = %d AND\n".
1544 " f.module = m.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 " (<a href=\"cvs.phtml?sFile=./src/".$array["modname"]."/".$array["name"].",v&sRevision=\">cvs</a>)");
1556 Odin32DBInfoRow1("Revision", $array, "revision","","","","");
1557 Odin32DBInfoRow1("Changed", $array, "lastdatetime","","","","");
1558 Odin32DBInfoRow1("Last Author", $array, "lastauthorname","lastauthorrefcode","authorrefcode","","");
1559 Odin32DBInfoRow1("Module", $array, "modname","modrefcode","modrefcode","","");
1560 $sql = sprintf("SELECT\n".
1561 " COUNT(*) as functions\n".
1562 "FROM\n".
1563 " function\n".
1564 "WHERE\n".
1565 " file = %d",
1566 $iRefcode);
1567 $cFunctions = 0;
1568 if (($result2 = mysql_query($sql, $db)) && mysql_num_rows($result2) > 0 && ($aFunctions = mysql_fetch_array($result2)))
1569 {
1570 Odin32DBInfoRow1("# Functions", $aFunctions, "functions","","","","");
1571 $cFunctions = $aFunctions["functions"];
1572 }
1573
1574 $sql = sprintf("SELECT\n".
1575 " COUNT(*) as functions\n".
1576 "FROM\n".
1577 " function\n".
1578 "WHERE\n".
1579 " file = %d AND\n".
1580 " apigroup IS NOT NULL\n".
1581 "GROUP BY apigroup\n",
1582 $iRefcode);
1583 $cAPIGroups = 0;
1584 if (($result2 = mysql_query($sql, $db)) && ($cAPIGroups = mysql_num_rows($result2)) > 0)
1585 Odin32DBInfoRow1NoArray("# API Groups", $cAPIGroups, "","","","");
1586 if (!$result2)
1587 Odin32DBSqlError($sql);
1588
1589 echo "</table>\n";
1590
1591 /*
1592 * Description
1593 */
1594 Odin32DBDocRow("Description", "description", $array, "description");
1595
1596 /*
1597 * Completion
1598 */
1599 Odin32DBNaslov("Completion", "completion");
1600 Odin32DBCompletionBarFile($iRefcode, "", $db);
1601
1602 /*
1603 * States
1604 */
1605 $sql = sprintf("SELECT\n".
1606 " state,\n".
1607 " COUNT(state)\n".
1608 "FROM\n".
1609 " function\n".
1610 "WHERE\n".
1611 " file = %d\n".
1612 "GROUP BY state\n".
1613 "ORDER BY state",
1614 $iRefcode);
1615 Odin32DBWriteStates($cFunctions, $sql, $db);
1616
1617
1618 /*
1619 * Functions
1620 */
1621 Odin32DBNaslov("Functions", "functions");
1622 if ($fFunctions)
1623 {
1624 $sql = sprintf("SELECT\n".
1625 " f.refcode,\n".
1626 " f.name,\n".
1627 " s.color,\n".
1628 " s.name\n".
1629 "FROM\n".
1630 " function f\n".
1631 " LEFT JOIN state s ON f.state = s.refcode\n".
1632 "WHERE\n".
1633 " f.file = %d\n",
1634 $iRefcode);
1635 if ($fSortByState)
1636 $sql = $sql."ORDER BY s.refcode, f.name";
1637 else
1638 $sql = $sql."ORDER BY f.name";
1639 Odin32DBWriteFunctions($sql, $db, $sURLArgs);
1640 }
1641 else
1642 echo "Click <a href=\"Odin32DB.phtml#functions?".$sURLArgs."&fFunctions=1".
1643 "\">here</a> to see all functions.\n";
1644
1645
1646 /*
1647 * API Groups
1648 */
1649 if ($cAPIGroups > 0)
1650 {
1651 Odin32DBNaslov("API Groups", "apigroups");
1652 if ($fAPIGroups)
1653 {
1654 $sql = sprintf("SELECT\n".
1655 " g.refcode,\n".
1656 " g.name,\n".
1657 " COUNT(f.refcode)\n".
1658 "FROM\n".
1659 " apigroup g\n".
1660 " JOIN function f\n".
1661 "WHERE\n".
1662 " f.file = %d AND\n".
1663 " f.apigroup = g.refcode\n".
1664 "GROUP BY f.apigroup\n".
1665 "ORDER BY g.name\n",
1666 $iRefcode);
1667 Odin32DBWriteAPIGroups($sql, $db);
1668 }
1669 else
1670 echo "Click <a href=\"Odin32DB.phtml#apigroups?".$sURLArgs."&fAPIGroups=1".
1671 "\">here</a> to see all the API Groups.\n";
1672 }
1673
1674
1675 /*
1676 * Authors
1677 */
1678 Odin32DBNaslov("Authors", "authors");
1679 if ($fAuthors)
1680 {
1681 $sql = sprintf("SELECT\n".
1682 " a.refcode,\n".
1683 " a.name,\n".
1684 " COUNT(f.refcode)\n".
1685 "FROM\n".
1686 " fnauthor fa\n".
1687 " JOIN function f\n".
1688 " JOIN author a\n".
1689 "WHERE\n".
1690 " f.file = %d AND\n".
1691 " fa.function = f.refcode AND\n".
1692 " fa.author = a.refcode\n".
1693 "GROUP BY a.refcode\n".
1694 "ORDER BY a.name\n",
1695 $iRefcode
1696 );
1697 Odin32DBWriteAuthors($sql, $db);
1698 }
1699 else
1700 echo "Click <a href=\"Odin32DB.phtml#authors?".$sURLArgs."&fAuthors=1".
1701 "\">here</a> to see all authors.\n";
1702 }
1703 else
1704 {
1705 echo "<p> No data! Invalid refcode? </p>";
1706 Odin32DBSqlError($sql);
1707 }
1708
1709 /*
1710 * Navigation - Bottom
1711 */
1712 Odin32DBNavigationBottom($sExpand, $sCollapse);
1713}
1714
1715
1716
1717/**
1718 * Writes standard file info.
1719 *
1720 * @returns void
1721 * @param $db Database handle.
1722 * @param $iRefcode Author reference code.
1723 * @param $fModules Flags which tells wether to list all modules or not.
1724 * @param $fFunctions Flags which tells wether to list all functions or not.
1725 * @param $fFiles Flags which tells wether to list all files or not.
1726 * @param $fAPIGroups Flags which tells wether to list all apigroups or not.
1727 * @param $fSortByState Flags which tells wether to sort functions by
1728 * state and function name or just by function name.
1729 * @param $iModRefcode Module refcode. All modules if < 0.
1730 * (not implemented yet)
1731 * @sketch
1732 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
1733 * @remark
1734 */
1735function Odin32DBAuthorInfo($db, $iRefcode, $fModules, $fFunctions, $fFiles, $fAPIGroups, $fSortByState, $iModRefcode)
1736{
1737 $sURLArgs = "authorrefcode=".$iRefcode.
1738 ($fModules ? "&fModules=1" : "").
1739 ($fFunctions ? "&fFunctions=1" : "").
1740 ($fFiles ? "&fFiles=1" : "").
1741 ($fAPIGroups ? "&fAPIGroups=1" : "").
1742 ($fSortByState ? "&fSortByState=1" : "");
1743
1744 /*
1745 * Navigation - TOP
1746 */
1747 $sExpand = "authorrefcode=".$iRefcode."&fModules=1&fFiles=1&fFunctions=1&fAPIGroups=1&fAuthors=1&mod=".$iModRefcode;
1748 if ($fSortByState) $sExpand = $sExpand."&fSortByState=".$fSortByState;
1749 $sCollapse = "authorrefcode=".$iRefcode;
1750 Odin32DBNavigationTop($sExpand, $sCollapse);
1751
1752 /*
1753 * Fetch (vital) data.
1754 */
1755 $sql = sprintf("SELECT\n".
1756 " a.name AS name,\n".
1757 " a.refcode AS refcode,\n".
1758 " a.initials AS initials,\n".
1759 " a.alias AS alias,\n".
1760 " a.email AS email,\n".
1761 " a.country AS country,\n".
1762 " a.location AS location,\n".
1763 " a.description AS description\n".
1764 "FROM\n".
1765 " author a\n".
1766 "WHERE\n".
1767 " a.refcode = %d",
1768 $iRefcode);
1769 if (($result = mysql_query($sql, $db)) && mysql_num_rows($result) > 0 && ($array = mysql_fetch_array($result)))
1770 {
1771 /*
1772 * General
1773 */
1774 Odin32DBNaslov("General", "general");
1775 echo "\n<table width=100% border=3 cellpadding=0>\n";
1776 Odin32DBInfoRow1("Name", $array, "name","","","","");
1777 Odin32DBInfoRow1("e-mail", $array, "email","","","",""); //???? should all authors have email address displayed?
1778 Odin32DBInfoRow1("CVS User", $array, "alias","","","","");
1779 Odin32DBInfoRow1("Country", $array, "country","","","","");
1780 Odin32DBInfoRow1("Location", $array, "location","","","","");
1781 if (isset($array["description"]))
1782 Odin32DBInfoRow1("Description", $array, "description","","","","");
1783 $sql = sprintf("SELECT\n".
1784 " COUNT(*) as functions\n".
1785 "FROM\n".
1786 " fnauthor\n".
1787 "WHERE\n".
1788 " author = %d",
1789 $iRefcode);
1790 $cFunctions = 0;
1791 if (($result2 = mysql_query($sql, $db)) && mysql_num_rows($result2) > 0 && ($aFunctions = mysql_fetch_array($result2)))
1792 {
1793 Odin32DBInfoRow1("# Functions", $aFunctions, "functions","","","","");
1794 $cFunctions = $aFunctions["functions"];
1795 }
1796 $sql = sprintf("SELECT\n".
1797 " COUNT(f.module) as functions
1798 \n".
1799 "FROM\n".
1800 " fnauthor fa,\n".
1801 " function f\n".
1802 "WHERE\n".
1803 " fa.author = %d AND".
1804 " f.refcode = fa.function\n".
1805 "GROUP BY f.module",
1806 $iRefcode);
1807 $cModules = 0;
1808 if (($result2 = mysql_query($sql, $db)) && ($cModules = mysql_num_rows($result2)) > 0)
1809 Odin32DBInfoRow1NoArray("# Moduless", $cModules, "","","","");
1810 $sql = sprintf("SELECT\n".
1811 " COUNT(f.module) as functions
1812 \n".
1813 "FROM\n".
1814 " fnauthor fa,\n".
1815 " function f\n".
1816 "WHERE\n".
1817 " fa.author = %d AND".
1818 " f.file >= 0 AND".
1819 " f.refcode = fa.function \n".
1820 "GROUP BY f.file",
1821 $iRefcode);
1822 $cFiles = 0;
1823 if (($result2 = mysql_query($sql, $db)) && ($cFiles = mysql_num_rows($result2)) > 0)
1824 Odin32DBInfoRow1NoArray("# Files", $cFiles, "","","","");
1825 $sql = sprintf("SELECT\n".
1826 " COUNT(f.module) as functions
1827 \n".
1828 "FROM\n".
1829 " fnauthor fa,\n".
1830 " function f\n".
1831 "WHERE\n".
1832 " fa.author = %d AND".
1833 " f.apigroup IS NOT NULL AND".
1834 " f.refcode = fa.function\n".
1835 "GROUP BY f.apigroup",
1836 $iRefcode);
1837 $cAPIGroups = 0;
1838 if (($result2 = mysql_query($sql, $db)) && ($cAPIGroups = mysql_num_rows($result2)) > 0)
1839 Odin32DBInfoRow1NoArray("# API Groups", $cAPIGroups, "","","","");
1840
1841 echo "</table>\n";
1842
1843 /*
1844 * Completion
1845 */
1846 Odin32DBNaslov("Completion", "completion");
1847 Odin32DBCompletionBarAuthor($iRefcode, "", $db);
1848
1849 /*
1850 * States
1851 */
1852 //TODO: optimize this further.
1853 $sql = sprintf("SELECT\n".
1854 " f.state,\n".
1855 " COUNT(f.refcode)\n".
1856 "FROM\n".
1857 " function f,\n".
1858 " fnauthor fa\n".
1859 "WHERE\n".
1860 " fa.author = %d AND\n".
1861 " fa.function = f.refcode\n".
1862 "GROUP BY f.state\n".
1863 "ORDER BY f.state",
1864 $iRefcode);
1865 Odin32DBWriteStates($cFunctions, $sql, $db);
1866
1867 /*
1868 * Modules
1869 */
1870 Odin32DBNaslov("Modules", "Modules");
1871 if ($fModules)
1872 {
1873 $sql = sprintf("SELECT\n".
1874 " m.refcode,\n".
1875 " m.name,\n".
1876 " COUNT(f.refcode)\n".
1877 "FROM\n".
1878 " fnauthor fa,\n".
1879 " module m,\n".
1880 " function f\n".
1881 "WHERE\n".
1882 " fa.author = %d AND\n".
1883 " fa.function = f.refcode AND\n".
1884 " f.module = m.refcode\n".
1885 "GROUP BY m.refcode\n".
1886 "ORDER BY m.name\n",
1887 $iRefcode);
1888 Odin32DBWriteModules($sql, $db, $sURLArgs);
1889 }
1890 else
1891 echo "Click <a href=\"Odin32DB.phtml#modules?".$sURLArgs."&fModules=1".
1892 "\">here</a> to see all files.\n";
1893
1894
1895 /*
1896 * Functions
1897 */
1898 Odin32DBNaslov("Functions", "functions");
1899 if ($fFunctions)
1900 {
1901 $sql = sprintf("SELECT\n".
1902 " f.refcode,\n".
1903 " f.name,\n".
1904 " m.refcode,\n".
1905 " m.name,\n".
1906 " s.color,\n".
1907 " s.name\n".
1908 "FROM\n".
1909 " fnauthor fa\n".
1910 " JOIN function f\n".
1911 " JOIN module m\n".
1912 " LEFT JOIN state s ON f.state = s.refcode\n".
1913 "WHERE\n".
1914 " fa.author = %d AND\n".
1915 " fa.function = f.refcode AND \n".
1916 " f.module = m.refcode\n",
1917 $iRefcode);
1918 if ($fSortByState)
1919 $sql = $sql."ORDER BY s.refcode, f.name, d.name";
1920 else
1921 $sql = $sql."ORDER BY d.name, f.name";
1922 Odin32DBWriteFunctionsWithModules($sql, $db, $sURLArgs);
1923 }
1924 else
1925 echo "Click <a href=\"Odin32DB.phtml#functions?".$sURLArgs."&fFunctions=1".
1926 "\">here</a> to see all functions.\n";
1927
1928
1929 /*
1930 * Files
1931 */
1932 Odin32DBNaslov("Files", "files");
1933 if ($fFiles)
1934 {
1935 $sql = sprintf("SELECT\n".
1936 " f.refcode,\n".
1937 " f.name,\n".
1938 " COUNT(fn.refcode)\n".
1939 "FROM\n".
1940 " fnauthor fa,\n".
1941 " file f,\n".
1942 " function fn\n".
1943 "WHERE\n".
1944 " fa.author = %d AND\n".
1945 " fa.function = fn.refcode AND\n".
1946 " fn.file = f.refcode\n".
1947 "GROUP BY f.refcode\n".
1948 "ORDER BY f.name\n",
1949 $iRefcode);
1950 Odin32DBWriteFiles($sql, $db);
1951 }
1952 else
1953 echo "Click <a href=\"Odin32DB.phtml#files?".$sURLArgs."&fFiles=1".
1954 "\">here</a> to see all files.\n";
1955
1956
1957 /*
1958 * API Groups
1959 */
1960 if ($cAPIGroups > 0)
1961 {
1962 Odin32DBNaslov("API Groups", "apigroups");
1963 if ($fAPIGroups)
1964 {
1965 $sql = sprintf("SELECT\n".
1966 " g.refcode,\n".
1967 " g.name,\n".
1968 " COUNT(f.refcode)\n".
1969 "FROM\n".
1970 " fnauthor fa\n".
1971 " JOIN apigroup g\n".
1972 " JOIN function f\n".
1973 "WHERE\n".
1974 " fa.author = %d AND\n".
1975 " fa.function = f.refcode AND\n".
1976 " f.apigroup = g.refcode\n".
1977 "GROUP BY f.apigroup\n".
1978 "ORDER BY g.name\n",
1979 $iRefcode);
1980 Odin32DBWriteAPIGroups($sql, $db);
1981 }
1982 else
1983 echo "Click <a href=\"Odin32DB.phtml#apigroups?".$sURLArgs."&fAPIGroups=1".
1984 "\">here</a> to see all the API Groups.\n";
1985 }
1986 }
1987 else
1988 {
1989 echo "<p> No data! Invalid refcode? </p>";
1990 Odin32DBSqlError($sql);
1991 }
1992
1993 /*
1994 * Navigation - Bottom
1995 */
1996 Odin32DBNavigationBottom($sExpand, $sCollapse);
1997}
1998
1999
2000
2001/**
2002 * Writes standard file info.
2003 *
2004 * @returns void
2005 * @param $db Database handle.
2006 * @param $iRefcode Author reference code.
2007 * @param $fFunctions Flags which tells wether to list all functions or not.
2008 * @param $fFiles Flags which tells wether to list all files or not.
2009 * @param $fAuthors Flags which tells wether to list all authors or not.
2010 * @param $fSortByState Flags which tells wether to sort functions by
2011 * state and function name or just by function name.
2012 * @sketch
2013 * @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
2014 * @remark
2015 */
2016function Odin32DBAPIGroupInfo($db, $iRefcode, $fFunctions, $fFiles, $fAuthors, $fSortByState)
2017{
2018 $sURLArgs = "apigrouprefcode=".$iRefcode.
2019 ($fFunctions ? "&fFunctions=1" : "").
2020 ($fFiles ? "&fFiles=1" : "").
2021 ($fAuthors ? "&fAuthors=1" : "").
2022 ($fSortByState ? "&fSortByState=1" : "");
2023
2024 /*
2025 * Navigation - TOP
2026 */
2027 $sExpand = "apigrouprefcode=".$iRefcode."&fFiles=1&fFunctions=1&fAuthors=1";
2028 if ($fSortByState) $sExpand = $sExpand."&fSortByState=".$fSortByState;
2029 $sCollapse = "apigrouprefcode=".$iRefcode;
2030 Odin32DBNavigationTop($sExpand, $sCollapse);
2031
2032 /*
2033 * Fetch (vital) data.
2034 */
2035 $sql = sprintf("SELECT\n".
2036 " g.name AS name,\n".
2037 " g.refcode AS refcode,\n".
2038 " g.description AS description,\n".
2039 " m.name AS modname,\n".
2040 " m.refcode AS modrefcode\n".
2041 "FROM\n".
2042 " apigroup g\n".
2043 " JOIN module m\n".
2044 "WHERE\n".
2045 " g.refcode = %d AND".
2046 " g.module = m.refcode\n",
2047 $iRefcode);
2048 if (($result = mysql_query($sql, $db)) && mysql_num_rows($result) > 0 && ($array = mysql_fetch_array($result)))
2049 {
2050 /*
2051 * General
2052 */
2053 Odin32DBNaslov("General", "general");
2054 echo "\n<table width=100% border=3 cellpadding=0>\n";
2055 Odin32DBInfoRow1("Name", $array, "name","","","","");
2056 Odin32DBInfoRow1("Module", $array, "modname","modrefcode","modrefcode","bad configuration","");
2057 if (isset($array["description"]))
2058 Odin32DBInfoRow1("Description", $array, "description","","","","");
2059 $sql = sprintf("SELECT\n".
2060 " COUNT(*) as functions\n".
2061 "FROM\n".
2062 " function\n".
2063 "WHERE\n".
2064 " apigroup = %d",
2065 $iRefcode);
2066 $cFunctions = 0;
2067 if (($result2 = mysql_query($sql, $db)) && mysql_num_rows($result2) > 0 && ($aFunctions = mysql_fetch_array($result2)))
2068 {
2069 Odin32DBInfoRow1("# Functions", $aFunctions, "functions","","","","");
2070 $cFunctions = $aFunctions["functions"];
2071 }
2072 $sql = sprintf("SELECT\n".
2073 " COUNT(*) as functions\n".
2074 "FROM\n".
2075 " function\n".
2076 "WHERE\n".
2077 " apigroup = %d AND".
2078 " file >= 0\n".
2079 "GROUP BY file",
2080 $iRefcode);
2081 $cFiles = 0;
2082 if (($result2 = mysql_query($sql, $db)) && ($cFiles = mysql_num_rows($result2)) > 0)
2083 Odin32DBInfoRow1NoArray("# Files", $cFiles, "","","","");
2084
2085 $sql = sprintf("SELECT\n".
2086 " COUNT(f.module) as functions\n".
2087 "FROM\n".
2088 " fnauthor fa,\n".
2089 " function f\n".
2090 "WHERE\n".
2091 " f.apigroup = %d AND".
2092 " f.refcode = fa.function\n".
2093 "GROUP BY fa.author",
2094 $iRefcode);
2095 $cAuthors = 0;
2096 if (($result2 = mysql_query($sql, $db)) && ($cAuthors = mysql_num_rows($result2)) > 0)
2097 Odin32DBInfoRow1NoArray("# Authors", $cAuthors, "","","","");
2098
2099 echo "</table>\n";
2100
2101 /*
2102 * Completion
2103 */
2104 Odin32DBNaslov("Completion", "completion");
2105 Odin32DBCompletionBarAPIGroup($iRefcode, "", $db);
2106
2107 /*
2108 * States
2109 */
2110 $sql = sprintf("SELECT\n".
2111 " state,\n".
2112 " COUNT(state)\n".
2113 "FROM\n".
2114 " function\n".
2115 "WHERE\n".
2116 " apigroup = %d\n".
2117 "GROUP BY state\n".
2118 "ORDER BY state",
2119 $iRefcode);
2120 Odin32DBWriteStates($cFunctions, $sql, $db);
2121
2122 /*
2123 * Functions
2124 */
2125 Odin32DBNaslov("Functions", "functions");
2126 if ($fFunctions)
2127 {
2128 //TODO: optimize this...
2129 $sql = sprintf("SELECT\n".
2130 " f.refcode,\n".
2131 " f.name,\n".
2132 " s.color,\n".
2133 " s.name\n".
2134 "FROM\n".
2135 " function f\n".
2136 " LEFT JOIN state s ON f.state = s.refcode\n".
2137 "WHERE\n".
2138 " f.apigroup = %d\n",
2139 $iRefcode);
2140 if ($fSortByState)
2141 $sql = $sql."ORDER BY s.refcode, f.name";
2142 else
2143 $sql = $sql."ORDER BY f.name";
2144 Odin32DBWriteFunctions($sql, $db, $sURLArgs);
2145 }
2146 else
2147 echo "Click <a href=\"Odin32DB.phtml#functions?".$sURLArgs."&fFunctions=1".
2148 "\">here</a> to see all functions.\n";
2149
2150
2151 /*
2152 * Files
2153 */
2154 Odin32DBNaslov("Files", "files");
2155 if ($fFiles)
2156 {
2157 //TODO: optimize this...
2158 $sql = sprintf("SELECT\n".
2159 " f.refcode,\n".
2160 " f.name,\n".
2161 " COUNT(fn.refcode)\n".
2162 "FROM\n".
2163 " file f\n".
2164 " LEFT OUTER JOIN function fn ON fn.file = f.refcode\n".
2165 "WHERE\n".
2166 " fn.apigroup = %d\n".
2167 "GROUP BY f.refcode\n".
2168 "ORDER BY f.name\n",
2169 $iRefcode);
2170 Odin32DBWriteFiles($sql, $db);
2171 }
2172 else
2173 echo "Click <a href=\"Odin32DB.phtml#files?".$sURLArgs."&fFiles=1".
2174 "\">here</a> to see all files.\n";
2175
2176
2177 /*
2178 * Authors
2179 */
2180 Odin32DBNaslov("Authors", "authors");
2181 if ($fAuthors)
2182 {
2183 //TODO: optimize this...
2184 $sql = sprintf("SELECT\n".
2185 " a.refcode,\n".
2186 " a.name,\n".
2187 " COUNT(f.refcode)\n".
2188 "FROM\n".
2189 " fnauthor fa\n".
2190 " JOIN function f\n".
2191 " JOIN author a\n".
2192 "WHERE\n".
2193 " f.apigroup = %d AND\n".
2194 " fa.function = f.refcode AND\n".
2195 " fa.author = a.refcode\n".
2196 "GROUP BY a.refcode\n".
2197 "ORDER BY a.name\n",
2198 $iRefcode
2199 );
2200 Odin32DBWriteAuthors($sql, $db);
2201 }
2202 else
2203 echo "Click <a href=\"Odin32DB.phtml#authors?".$sURLArgs."&fAuthors=1".
2204 "\">here</a> to see all authors.\n";
2205 }
2206 else
2207 {
2208 echo "<p> No data! Invalid refcode? </p>";
2209 Odin32DBSqlError($sql);
2210 }
2211
2212 /*
2213 * Navigation - Bottom
2214 */
2215 Odin32DBNavigationBottom($sExpand, $sCollapse);
2216}
2217
2218
2219/**
2220 * Displays a design not.
2221 * @returns void
2222 * @param $db Database handle.
2223 * @param $iRefcode Author reference code.
2224 * @author knut st. osmundsen (kosmunds@csc.com)
2225 * @remark
2226 */
2227function Odin32DBDesignNote($db, $iRefcode)
2228{
2229 /*
2230 * Navigation - TOP
2231 */
2232 $sExpand = "authorrefcode=".$iRefcode."&fModules=1&fFiles=1&fFunctions=1&fAPIGroups=1&fAuthors=1&module=".$iModRefcode;
2233 if ($fSortByState) $sExpand = $sExpand."&fSortByState=".$fSortByState;
2234 $sCollapse = "authorrefcode=".$iRefcode;
2235 Odin32DBNavigationTop($sExpand, $sCollapse);
2236
2237 /*
2238 * Fetch (vital) data.
2239 */
2240 $sql = sprintf("SELECT\n".
2241 " dn.name AS name,\n".
2242 " dn.note AS note,\n".
2243 " dn.refcode AS refcode,\n".
2244 " dn.module AS modrefcode,\n".
2245 " dn.file AS filerefcode,\n".
2246 " dn.seqnbrnote AS seqnbnote,\n".
2247 " dn.level AS level,\n".
2248 " dn.seqnbr AS seqnbr,\n".
2249 " dn.line AS line,\n".
2250 " m.name AS modname,\n".
2251 " f.name AS file\n".
2252 "FROM\n".
2253 " designnote dn,\n".
2254 " module m,\n".
2255 " file f\n".
2256 "WHERE dn.refcode = %d\n".
2257 " AND dn.module = m.refcode\n".
2258 " AND dn.file = f.refcode\n".
2259 "ORDER BY dn.seqnbrnote\n",
2260 $iRefcode);
2261 if (($result = mysql_query($sql, $db)) && mysql_num_rows($result) > 0 && ($array = mysql_fetch_array($result)))
2262 {
2263 /*
2264 * General
2265 */
2266 /*Odin32DBNaslov("General", "general");
2267 echo "\n<table width=100% border=3 cellpadding=0>\n";
2268 Odin32DBInfoRow1("Title", $array, "name","","","","");
2269 Odin32DBInfoRow1("Module", $array, "modname","","","","");
2270 Odin32DBInfoRow1("File", $array, "file","","","","");
2271 Odin32DBInfoRow1("Line", $array, "line","","","","");
2272 Odin32DBInfoRow1("Seq#", $array, "seqnbr","","","","");
2273 echo "</table>\n";
2274 */
2275
2276 /*
2277 * Sections.
2278 */
2279 $iLevel = 0;
2280 $sSectionNbr = "";
2281 do
2282 {
2283 /* make section number */
2284 if ($array["level"] <= 0)
2285 $sSection = $array["seqnbr"].".0";
2286 else
2287 {
2288 while ($iLevel > 0 && $iLevel < $array["level"])
2289 {
2290 $sSection .= '.0';
2291 $iLevel = $iLevel + 1;
2292 }
2293
2294 if ($iLevel == 0) $iLevel++;
2295 while ($iLevel >= $array["level"])
2296 {
2297 $sSection = substr($sSection, 0, strlen($sSection) - strlen(strrchr($sSection, '.')));
2298 $iLevel = $iLevel - 1;
2299 }
2300 $sSection = $sSection.".".$array["seqnbr"];
2301 }
2302 $iLevel = $array["level"];
2303
2304 /* print it */
2305 $sName = $sSection." ".$array["name"];
2306 Odin32DBNaslov($sName, $sName);
2307 echo $array["note"]."\n";
2308
2309 } while ($array = mysql_fetch_array($result));
2310
2311 }
2312 else
2313 {
2314 echo "<p> No data! Invalid refcode? </p>";
2315 Odin32DBSqlError($sql);
2316 }
2317
2318 /*
2319 * Navigation - Bottom
2320 */
2321 Odin32DBNavigationBottom($sExpand, $sCollapse);
2322}
2323
2324
2325
2326
2327
2328/* TEXT FORMATTING OVERLOADS */
2329/* TEXT FORMATTING OVERLOADS */
2330/* TEXT FORMATTING OVERLOADS */
2331$aContent = array();
2332$aaSubContent = array();
2333$fNumberSections = 0;
2334
2335/**
2336 * Call this to autogenerate section and subsection numbers.
2337 */
2338function ODin32DBNumberSections()
2339{
2340 global $fNumberSections;
2341 $fNumberSections = 1;
2342}
2343
2344
2345/**
2346 * Makes the contents for this page.
2347 * @sketch Writes the headers present in the contents array.
2348 */
2349function Odin32DBWriteContents()
2350{
2351 global $aContent;
2352 global $aaSubContent;
2353
2354 echo "\n",
2355 "<tr><td>\n";
2356
2357 for ($i = 0; $i < sizeof($aContent); $i += 2)
2358 {
2359 echo "<font size=-2 face=\"WarpSans, Helv, Helvetica, Arial\">".
2360 "<a href=\"#".$aContent[$i+1]."\"><font color=000099>".
2361 $aContent[$i]."</font></a><br>\n";
2362
2363 $aSubContent = $aaSubContent[$i/2];
2364 echo "\n";
2365 if (sizeof($aSubContent) > 0)
2366 {
2367 echo "<table>\n";
2368 for ($j = 0; $j < sizeof($aSubContent); $j += 2)
2369 {
2370 echo "<tr><td width=10%>&nbsp;</td>\n",
2371 " <td><font size=-2 face=\"WarpSans, Helv, Helvetica, Arial\">".
2372 "<font size=-2 face=\"WarpSans, Helv, Helvetica, Arial\">".
2373 "<a href=\"#".$aSubContent[$j+1]."\"><font color=000099>".
2374 $aSubContent[$j]."</font></a><br>\n";
2375 echo "</td></tr>\n";
2376 }
2377 echo "</table>\n";
2378 }
2379 else
2380 echo "<p>\n";
2381 }
2382
2383 echo "</td></tr>\n";
2384}
2385
2386/**
2387 * Forwarder which also maintains the contents array.
2388 */
2389function Odin32DBNaslov($sFull, $sShort)
2390{
2391 global $aContent;
2392 global $aaSubContent;
2393 global $fNumberSections;
2394
2395 if ($fNumberSections)
2396 $sFull = (sizeof($aContent)/2 + 1).". ".$sFull;
2397
2398 $aContent[] = $sFull;
2399 $aContent[] = $sShort;
2400 $aaSubContent[] = array();
2401 return Naslov($sFull, $sShort);
2402}
2403
2404
2405/**
2406 * Forwarder which also maintains the contents array.
2407 * Equal to Odin32DBNaslov, but have allows a different contents text.
2408 */
2409function Odin32DBNaslov2($sFull, $sFullContents, $sShort)
2410{
2411 global $aContent;
2412 global $aaSubContent;
2413 global $fNumberSections;
2414
2415 if ($fNumberSections)
2416 {
2417 $sFull = (sizeof($aContent)/2 + 1).". ".$sFull;
2418 $sFullContents = (sizeof($aContent)/2 + 1).". ".$sFullContents;
2419 }
2420
2421 $aContent[] = $sFullContents;
2422 $aContent[] = $sShort;
2423 $aaSubContent[] = array();
2424 return Naslov($sFull, $sShort);
2425}
2426
2427
2428/**
2429 * Sub title with contents entry.
2430 */
2431function Odin32DBPodNaslov($sFull, $sShort)
2432{
2433 global $aContent;
2434 global $aaSubContent;
2435 global $fNumberSections;
2436
2437 $j = (sizeof($aContent) / 2) - 1;
2438 $aSubContent = $aaSubContent[$j];
2439
2440 if ($fNumberSections)
2441 $sFull = (sizeof($aContent)/2).".".(sizeof($aSubContent)/2 + 1)." ".$sFull;
2442
2443 $aSubContent[] = $sFull;
2444 $aSubContent[] = $sShort;
2445 $aaSubContent[$j] = $aSubContent;
2446 echo "<p><b><a name=\"".$sShort."\"><font size=+0 face=\"Helv, Arial\"><br>".$sFull."</font></b></a><p>";
2447}
2448
2449?>
2450
Note: See TracBrowser for help on using the repository browser.