Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function ShowDoc ($file)
- {
- echo "<div style='background-color: #A0A0A0; width: 100%; font-size: 20px; padding: 3px; margin-top: 10px;'>File $file</div><br>";
- $code = file_get_contents($file);
- $pos = 0;
- $len = strlen($code);
- $brackets = 0;
- $bracketClass = array(0);
- $inSpecialComment = false;
- $specialComment = "";
- $inClass = 0;
- $class = "";
- for ($i = 0; $i < $len; $i ++)
- {
- $c = $code[$i];
- // Special comment!
- if ($c == "/" && $code[$i + 1] == "*" && $code[$i + 2] == "*")
- {
- $i += 2;
- $specialComment = "";
- $inSpecialComment = true;
- }
- else if ($inSpecialComment && $c == "*" && $code[$i + 1] == "/")
- {
- $i ++;
- $specialComment = preg_replace("/^\\s+\\*/m", "", $specialComment);
- $inSpecialComment = false;
- }
- else if ($inSpecialComment)
- $specialComment .= $c;
- else if (substr($code, $i, 6) == "class " && $specialComment != "")
- {
- $signature = trim(substr($code, $i, strpos($code, "\n", $i) - $i));
- echo "<table border='0' cellspacing='0' cellpadding='5' style='border: solid 1px black; margin-bottom: 5px; width: 100%;'>";
- list (, $class, ) = explode(" ", $signature);
- $wiki = @file_get_contents("http://www.nw-engine.com/wiki/index.php/Class_$class");
- if ($wiki == "" || strpos($wiki, "There is currently no text in this page.") !== FALSE)
- echo "<tr style='background-color: #E0E0E0;'><td colspan='2'><b>" . str_replace(" ", " ", $signature) . "</b></td>";
- else
- echo "<tr style='background-color: #E0E0E0;'><td colspan='2'><a href='http://www.nw-engine.com/wiki/index.php/Class_$class'><b>" . str_replace(" ", " ", $signature) . "</b></a></td>";
- echo "<td width='70%'>$specialComment</td></tr>";
- echo "<tr><td style='width: 20px;'></td><td colspan='2'>";
- $specialComment = "";
- $bracketClass[] = $brackets;
- $inClass ++;
- }
- else if (substr($code, $i, 9) == "function " && $specialComment != "")
- {
- $start = strrpos(substr($code, 0, $i), "\n");
- $signature = trim(substr($code, $start, strpos($code, "\n", $i) - $start));
- if (strpos($signature, "private ") === FALSE)
- {
- echo "<table border='0' cellspacing='0' cellpadding='0' style='margin-bottom: 5px; width: 100%; border: solid 1px #A0A0A0;'>";
- $signature = str_replace(array("public ", "function "), array("", ""), $signature);
- if (strpos($signature, "static ") !== FALSE)
- $signature = str_replace("static ", "$class::", $signature);
- echo "<tr style='background-color: #E0E0E0;'><td colspan='2'><b>" . str_replace(" ", " ", $signature) . "</b></td></tr>";
- $lines = preg_split("/^\\s+@/m", $specialComment);
- echo "<td width='20%'> </td><td>{$lines[0]}</td></tr>";
- array_shift($lines);
- foreach ($lines as $line)
- {
- $line = trim($line);
- if (substr($line, 0, 5) == "param")
- $line = "<b>Parameter</b> " . substr($line, 5);
- else if (substr($line, 0, 7) == "return ")
- $line = "<b>Returns</b> " . substr($line, 7);
- echo "<tr><td> </td><td>$line</td></tr>";
- }
- echo "</table>";
- }
- $specialComment = "";
- }
- else if ($c == "{")
- $brackets ++;
- else if ($c == "}")
- {
- $brackets --;
- if ($brackets <= $bracketClass[count($bracketClass) - 1] && $inClass > 0)
- {
- if (count($bracketClass) > 1)
- array_pop($bracketClass);
- $inClass --;
- echo "</td></tr></table>";
- }
- }
- }
- }
- ShowDoc("demo/libs/common.php");
- ShowDoc("demo/libs/template.php");
- ShowDoc("demo/libs/db.php");
- ShowDoc("demo/libs/items.php");
- ShowDoc("demo/libs/stats.php");
- ShowDoc("demo/libs/roles.php");
- ShowDoc("demo/libs/ajax.php");
Advertisement
Add Comment
Please, Sign In to add comment