Location: PHPKode > projects > Study planner > splanner_015/doc/mdoc/auto-documentation.php
<?php
// Script to display a browse PHP code documentation using the Mdoc class
// Author:  JM Faure <hide@address.com>
// Release: 19 Sep 2005
//
// Usage: browse the whole code documentation from this page,
//        ? (no query) view documentation for a whole directory
//        ?lib=libname view the requested library documentation
//        ?lib=libname?constants view the requested all-constants documentation
//        ?lib=libname?constant=constname view the requested constant documentation
//        ?lib=libname?constant_group=0 view the requested constant_group documentation
//        ?class=classname view the requested class documentation
//        ?class=classname&method=methodname view the requested method documentation
//        ?class=classname&property=propertyname view the requested property documentation
//        ?lib=libname&function=functionname view the requested function documentation
//
// The page is made from 4 elements:
//        header (optional, set in config)
//        toc (built with Mdoc)
//        page (built with Mdoc)
//        footer (optional, set in config)

// Timing script execution
$time_start = microtime();

// Define the reference file path to the PHP code to document (relative to DOCUMENT_ROOT)
$ref_dir = "php/spl/class/";

// Set manpage header and footer
$header = "Studiewijzer class documentation";
$footer = "<a href=\"http://www.studiewijzer.nl\">Studiewijzer<a>";

// Choose default view, "public" for API level or "author" to view private and protected members
$default_view = "author";

// PHP4 or PHP5 Manta library is loaded regarding the local phpversion()
// but you can force to run the PHP4 version 
$force_php4 = true;  // force to load PHP4 includes

// Set PHP file extension (unique for classes and libs)
$php_ext = ".php";

// Set appropriate error reporting level
error_reporting(E_ALL);

// Load required Manta classes
if ($force_php4 
    || version_compare(phpversion(), "5") < 0) {
  $manta_lib_path = dirname(__FILE__) . "/../include/php4/";
} else {
  $manta_lib_path = dirname(__FILE__) . "/../include/php5/";
}
//@EWL
$manta_lib_path = 'C:\Documents and Settings\e\My Documents\PHP Projects\spl/doc/mdoc/';
require($manta_lib_path . "Mdoc.php");

// Set view level
if (!empty($_GET['view']) && 
    in_array($_GET['view'], array("author", "public"))) {
  $view_level = $_GET['view'];
} else {
  $view_level = $default_view;
}

// Set current directory in Manta includes
//$current_dir = $manta_lib_path;
$current_dir = 'C:/Documents and Settings/e/My Documents/PHP Projects/spl/class/';

// Set parameters to process the request
if (empty($_GET['class'])) {
  $file = "Mdoc";
  $type = 'home';
} else {
  $file = $_GET['class'];  // you can hack class in URI
  $type = 'class';
}
$file_path = $current_dir . $file . '.class'.$php_ext;
// -- method, function or property?
if ($type != 'home') {
  if (array_key_exists('constants', $_GET)) {
    $constants = true;
  } elseif (!empty($_GET['method'])) {
    $method = $_GET['method'];
  } elseif (!empty($_GET['constant'])) {
    $constant = $_GET['constant'];
  } elseif (array_key_exists('constant_group', $_GET)) {
    $constant_group = $_GET['constant_group'];
  } elseif (!empty($_GET['function'])) {
    $function = $_GET['function'];
  } elseif (!empty($_GET['property'])) {
    $property = $_GET['property'];
  }
}

// Buid requested manual page
if ($type == 'home') {
  // Mdoc manual home
  $manual = new Mdoc($file_path);
  $toc = $manual->getnav_class($view_level);
  $page = "<p><a href=\"/\">Site root:</a> back to home page.</p>\n" .
          "<p><a href=\"?class=Mdoc&view=author\">Mdoc manual \"author view\":</a> for code maintenance and more.</p>\n" .
          "<p><a href=\"?class=Mdoc&view=public\">Mdoc manual \"public view\":</a> for users, an API perspective.</p>\n" .
          "<p><a href=\"view-parsing.php?file=Mdoc&path=manta\">Mdoc documentation parsing:</a> check documentation parsing.</p>\n" .
          "<p><a href=\"view-internals.php?file=Mdoc&path=manta\">Mdoc documentation tree:</a> view internals.</p>\n"; 
} else {
  // Create the manual
  $manual = new Mdoc($file_path);
  // Get the TOC
  if ($type == 'class') {
    $toc = $manual->getnav_class($view_level);
  } elseif ($type == 'lib') {
    $toc = $manual->getnav_library($view_level);
  } else {
    die("INVALID REQUEST : UNEXPECTED SITUATION ENCOUNTERED");
  }
  // Get the documentation
  if (!empty($constants)) {
    $page = $manual->getdoc_constants($view_level);
  } elseif (!empty($constant)) {
    $page = $manual->getdoc_constant($constant, $view_level);
  } elseif (isset($constant_group) && is_numeric($constant_group)) {
    $page = $manual->getdoc_constant_group($constant_group, $view_level);
  } elseif (!empty($method)) {
    $page = $manual->getdoc_method($method, $view_level);
  } elseif (!empty($function)) {
    $page = $manual->getdoc_function($function, $view_level);
  } elseif (!empty($property)) {
    $page = $manual->getdoc_property($property, $view_level);
  // -- so is to document the whole class (or lib) 
  } elseif ($type == 'class') {
    $page = $manual->getdoc_class($view_level);
  } elseif ($type == 'lib') {
    $page = $manual->getdoc_library($view_level);
  } else {
    die("INVALID REQUEST : UNEXPECTED SITUATION ENCOUNTERED");
  }
}

// Compute script execution time before output
$time_end = microtime();
list($usec, $sec) = explode(" ", $time_end);
$time_end = (float)$usec + (float)$sec;
list($usec, $sec) = explode(" ", $time_start);
$time_start = (float)$usec + (float)$sec;
$time_script = number_format ($time_end - $time_start, 3);

// Add header and footer in the big table
$header = empty($header) ? "" : 
          "<tr>\n    <td class=\"header\" colspan=\"3\">$header</td>\n  </tr>";
$footer = empty($footer) ? "" :
          "<tr>\n    <td class=\"footer\" colspan=\"3\">$footer\n" .
          "      <br /><div class=\"subfooter\">Execution time $time_script seconds</span></td>\n  </tr>";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Studiewijzer documentation</title>
<link href="browse-style.css" rel="stylesheet" type="text/css">
</head>

<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <? echo $header; ?>
  <tr valign="top">
    <td width="200" bgcolor="#F0F0F0"><table width="100%" cellpadding="2" cellspacing="0" border="0">
        <tr valign="top">
          <td class="sidebar"><? echo $toc; ?> </td>
        </tr>
      </table></td>
    <td bgcolor="#CCCCCC" background="images/checkerboard.gif" width="1">
      <img src="images/spacer.gif" width="1" height="1" border="0" alt="" /></td>
    <td><table cellpadding="10" cellspacing="0" width="100%">
        <tr>
          <td valign="top"><? echo $page; ?> </td>
        </tr>
      </table></td>
  </tr>
  <? echo $footer; ?>
</table>
</body>
</html>
Return current item: Study planner