home *** CD-ROM | disk | FTP | other *** search
/ Enter 2004 June / ENTER.ISO / files / xampp-win32-1.4.5-installer.exe / xampp / Setup.inc.php < prev    next >
Encoding:
PHP Script  |  2004-03-24  |  28.5 KB  |  744 lines

  1. <?php
  2. //
  3. // +------------------------------------------------------------------------+
  4. // | phpDocumentor                                                          |
  5. // +------------------------------------------------------------------------+
  6. // | Copyright (c) 2000-2003 Joshua Eichorn, Gregory Beaver                 |
  7. // | Email         jeichorn@phpdoc.org, cellog@phpdoc.org                   |
  8. // | Web           http://www.phpdoc.org                                    |
  9. // | Mirror        http://phpdocu.sourceforge.net/                          |
  10. // | PEAR          http://pear.php.net/package-info.php?pacid=137           |
  11. // +------------------------------------------------------------------------+
  12. // | This source file is subject to version 3.00 of the PHP License,        |
  13. // | that is available at http://www.php.net/license/3_0.txt.               |
  14. // | If you did not receive a copy of the PHP license and are unable to     |
  15. // | obtain it through the world-wide-web, please send a note to            |
  16. // | license@php.net so we can mail you a copy immediately.                 |
  17. // +------------------------------------------------------------------------+
  18. //
  19.  
  20. /**
  21.  * This was all in phpdoc.inc, and now encapsulates the complexity
  22.  * @author Greg Beaver <cellog@users.sourceforge.net>
  23.  * @version $Revision: 1.1.2.3 $
  24.  * @package phpDocumentor
  25.  * @since 1.2
  26.  */
  27. error_reporting(E_ALL);
  28. /** common settings */
  29. include_once("phpDocumentor/common.inc.php");
  30.  
  31. include_once("phpDocumentor/Io.inc");
  32. include_once("phpDocumentor/Publisher.inc");
  33. include_once("phpDocumentor/Classes.inc");
  34. include_once("phpDocumentor/ProceduralPages.inc");
  35. include_once("phpDocumentor/IntermediateParser.inc");
  36. include_once("phpDocumentor/WordParser.inc");
  37. include_once("phpDocumentor/EventStack.inc");
  38. include_once("phpDocumentor/ParserData.inc");
  39. include_once("phpDocumentor/InlineTags.inc");
  40. include_once("phpDocumentor/DocBlockTags.inc");
  41. include_once("phpDocumentor/DescHTML.inc");
  42. include_once("phpDocumentor/ParserDocBlock.inc");
  43. include_once("phpDocumentor/ParserElements.inc");
  44. include_once("phpDocumentor/Parser.inc");
  45. include_once("phpDocumentor/phpDocumentorTWordParser.inc");
  46. include_once("phpDocumentor/phpDocumentorTParser.inc");
  47. include_once("phpDocumentor/HighlightParser.inc");
  48. include_once("phpDocumentor/ParserDescCleanup.inc");
  49. include_once("phpDocumentor/PackagePageElements.inc");
  50. include_once("phpDocumentor/XMLpackagePageParser.inc");
  51. include_once("phpDocumentor/LinkClasses.inc");
  52. include_once("phpDocumentor/Converter.inc");
  53. include_once("phpDocumentor/Errors.inc");
  54. if (isset($_GET))
  55. {
  56. /**
  57.  * $interface is either 'web' or is not set at all
  58.  * @global array $interface
  59.  */
  60.     if (isset($_GET['interface'])) $interface = $_GET['interface'];
  61. /**
  62.  * $_phpDocumentor_setting is either the value from the web interface, or is set up by {@link Io::parseArgv()}
  63.  * @global array $_phpDocumentor_setting
  64.  */
  65.     if (isset($_GET['setting'])) $_phpDocumentor_setting = $_GET['setting'];
  66. }
  67.  
  68. /**
  69.  * default package name, set using -dn --defaultpackagename
  70.  * @global string $GLOBALS['phpDocumentor_DefaultPackageName']
  71.  * @name $phpDocumentor_DefaultPackageName
  72.  */
  73. $GLOBALS['phpDocumentor_DefaultPackageName'] = 'default';
  74.  
  75. /**
  76.  * default package name, set using -dn --defaultcategoryname
  77.  * @global string $GLOBALS['phpDocumentor_DefaultCategoryName']
  78.  * @name $phpDocumentor_DefaultCategoryName
  79.  */
  80. $GLOBALS['phpDocumentor_DefaultCategoryName'] = 'default';
  81.  
  82. /**
  83.  * @package phpDocumentor
  84.  */
  85. class phpDocumentor_setup
  86. {
  87.     /**
  88.      * The main parser
  89.      * @var Parser|phpDocumentorTParser
  90.      */
  91.     var $parse;
  92.     /**
  93.      * Used to parse command-line options
  94.      * @var Io
  95.      */
  96.     var $setup;
  97.     /**
  98.      * Used to organize output from the Parser before Conversion
  99.      * @var phpDocumentor_IntermediateParser
  100.      */
  101.     var $render = false;
  102.     /**
  103.      * Packages to create documentation for
  104.      * @var string
  105.      */
  106.     var $packages = false;
  107.     /**
  108.      * contents of --filename commandline
  109.      * @tutorial phpDocumentor.howto.pkg#using.command-line.filename
  110.      * @var string
  111.      */
  112.     var $files = '';
  113.     /**
  114.      * contents of --directory commandline
  115.      * @tutorial phpDocumentor.howto.pkg#using.command-line.directory
  116.      * @var string
  117.      */
  118.     var $dirs = '';
  119.     /**
  120.      * contents of --hidden commandline
  121.      * @tutorial phpDocumentor.howto.pkg#using.command-line.hidden
  122.      * @var boolean
  123.      */
  124.     var $hidden = false;
  125.     /**
  126.      * time that parsing was started, used for informative timing of output
  127.      * @access private
  128.      */
  129.     var $parse_start_time;
  130.     /**
  131.      * contents of --ignore commandline
  132.      * @tutorial phpDocumentor.howto.pkg#using.command-line.ignore
  133.      * @var string
  134.      */
  135.     var $ignore_files = array();
  136.     /**
  137.      * Checks PHP version, makes sure it is 4.2.0+, and chooses the
  138.      * phpDocumentorTParser if version is 4.3.0+
  139.      * @uses parseIni()
  140.      */
  141.     function phpDocumentor_setup()
  142.     {
  143.         global $_phpDocumentor_cvsphpfile_exts;
  144.         if (!function_exists('is_a'))
  145.         {
  146.             print "phpDocumentor requires PHP version 4.2.0 or greater to function";
  147.             exit;
  148.         }
  149.         // set runtime to a large value since this can take quite a while
  150.         set_time_limit(0);    // six minute timeout
  151.         ini_set("memory_limit","256M");
  152.  
  153.         $this->parseIni();
  154.         // create new classes
  155.         $this->setup = new Io;
  156.         if (tokenizer_ext)
  157.         {
  158.             phpDocumentor_out("using experimental tokenizer Parser\n");
  159.             $this->parse = new phpDocumentorTParser;
  160.         } else
  161.         {
  162.             phpDocumentor_out("using default (slower) Parser - get PHP 4.3.0+
  163. and load the tokenizer extension for faster parsing (your version is ".phpversion()."\n");
  164.             $this->parse = new Parser;
  165.         }
  166.     }
  167.     
  168.     /**
  169.      * Get phpDocumentor settings from a user configuration file
  170.      * @param string user configuration file
  171.      */
  172.     function readConfigFile($file)
  173.     {
  174.         global $_phpDocumentor_setting, $_phpDocumentor_options;
  175.         // security
  176.         $file = str_replace(array('..','.ini','\\'),array('','','/'),$file);
  177.         if (strpos($file,'/') !== false)
  178.         {
  179.             $_phpDocumentor_setting = phpDocumentor_parse_ini_file($file.'.ini');
  180.         } else
  181.         {
  182.             $configdir = str_replace('\\','/', 'C:\xampp\php\pear\data/PhpDocumentor') . PATH_DELIMITER . 'user' . PATH_DELIMITER;
  183.             if (isset($_phpDocumentor_options['userdir'])) $configdir = $_phpDocumentor_options['userdir'];
  184.             if (substr($configdir,-1) != '/')
  185.             {
  186.                 $configdir .= '/';
  187.             }
  188.             $_phpDocumentor_setting = phpDocumentor_parse_ini_file( $configdir . $file . '.ini');
  189.             if (empty($_phpDocumentor_setting['defaultpackagename']))
  190.             {
  191.                 $_phpDocumentor_setting['defaultpackagename'] = 'default';
  192.             }
  193.         }
  194.         // don't want a loop condition!
  195.         unset($_phpDocumentor_setting['useconfig']);
  196.         $this->readCommandLineSettings();
  197.     }
  198.     
  199.     /**
  200.      * Get phpDocumentor settings from command-line or web interface
  201.      */
  202.     function readCommandLineSettings()
  203.     {
  204.         global $_phpDocumentor_setting,$interface;
  205.         // subscribe $render class to $parse class events
  206.         if (!isset($interface) && !isset($_GET['interface']) && !isset($_phpDocumentor_setting))
  207.         {
  208.             // Parse the argv settings
  209.             $_phpDocumentor_setting = $this->setup->parseArgv();
  210.         }
  211.         if (isset($_phpDocumentor_setting['useconfig']) && !empty($_phpDocumentor_setting['useconfig'])) return $this->readConfigFile($_phpDocumentor_setting['useconfig']);
  212.         if (!isset($_phpDocumentor_setting['junk'])) $_phpDocumentor_setting['junk'] = '';
  213.         if (!isset($_phpDocumentor_setting['title'])) $_phpDocumentor_setting['title'] = 'Generated Documentation';
  214.         if(array_key_exists('title',$_phpDocumentor_setting))
  215.             $temp_title = $_phpDocumentor_setting['title'];
  216.         else
  217.             $temp_title = "";
  218.         $this->render = new phpDocumentor_IntermediateParser($temp_title);
  219.         if (isset($_phpDocumentor_setting['help']) || $_phpDocumentor_setting['junk'] == "-h" || $_phpDocumentor_setting['junk'] == "--help")
  220.         {
  221.             echo $this->setup->displayHelpMsg();
  222.             die();
  223.         }
  224.         
  225.         if (isset($_phpDocumentor_setting['hidden'])) $this->hidden = true;
  226.         
  227.         // set to parse elements marked private with @access private
  228.         if (isset($_phpDocumentor_setting['parseprivate']) && $_phpDocumentor_setting['parseprivate'] == 'on')
  229.         {
  230.             $this->render->setParsePrivate(true);
  231.         }
  232.         
  233.         if (isset($_phpDocumentor_setting['ignore-tags']))
  234.         {
  235.             $_phpDocumentor_setting['ignore-tags'] = explode(',',str_replace(' ','',$_phpDocumentor_setting['ignore-tags']));
  236.             $tags = array();
  237.             foreach($_phpDocumentor_setting['ignore-tags'] as $tag)
  238.             {
  239.                 if (!in_array($tag,array('@global', '@access', '@package', '@ignore', '@name', '@param', '@return', '@staticvar', '@var')))
  240.                     $tags[] = $tag;
  241.             }
  242.             $_phpDocumentor_setting['ignore-tags'] = $tags;
  243.         }
  244.         
  245.         if (isset($_phpDocumentor_setting['javadocdesc']) && $_phpDocumentor_setting['javadocdesc'] == 'on')
  246.         {
  247.             $this->parse->eventHandlers[PARSER_EVENT_DOCBLOCK] = 'JavaDochandleDocblock';
  248.         }
  249.         if (tokenizer_ext)
  250.         {
  251.             if (isset($_phpDocumentor_setting['sourcecode']) && $_phpDocumentor_setting['sourcecode'] == 'on')
  252.             {
  253.                 $_phpDocumentor_setting['sourcecode'] = true;
  254.             } else
  255.             {
  256.                 $_phpDocumentor_setting['sourcecode'] = false;
  257.             }
  258.         } else
  259.         {
  260.             if (isset($_phpDocumentor_setting['sourcecode']) && $_phpDocumentor_setting['sourcecode'] == 'on')
  261.             {
  262.                 addWarning(PDERROR_SOURCECODE_IGNORED);
  263.             }
  264.             $_phpDocumentor_setting['sourcecode'] = false;
  265.         }
  266.         if (isset($_phpDocumentor_setting['converterparams']))
  267.         {
  268.             $_phpDocumentor_setting['converterparams'] = explode($_phpDocumentor_setting['converterparams']);
  269.             foreach($_phpDocumentor_setting['converterparams'] as $i => $p)
  270.             {
  271.                 $_phpDocumentor_setting['converterparams'][$i] = trim($p);
  272.             }
  273.         }
  274.         if (isset($_phpDocumentor_setting['customtags']) && !empty($_phpDocumentor_setting['customtags']))
  275.         {
  276.             $c = explode(',',$_phpDocumentor_setting['customtags']);
  277.             for($i=0;$i<count($c); $i++)
  278.             {
  279.                 $GLOBALS['_phpDocumentor_tags_allowed'][] = trim($c[$i]);
  280.             }
  281.         }
  282.         if (isset($_phpDocumentor_setting['pear']))
  283.         {
  284.             if ($_phpDocumentor_setting['pear'] === 'off') $_phpDocumentor_setting['pear'] = false;
  285.             if ($_phpDocumentor_setting['pear'] === 'on') $_phpDocumentor_setting['pear'] = true;
  286.         }
  287.         if (!isset($_phpDocumentor_setting['pear'])) $_phpDocumentor_setting['pear'] = false;
  288.         // set to change the default package name from "default" to whatever you want
  289.         if (isset($_phpDocumentor_setting['defaultpackagename']))
  290.         {
  291.             $GLOBALS['phpDocumentor_DefaultPackageName'] = trim($_phpDocumentor_setting['defaultpackagename']);
  292.         }
  293.         // set to change the default category name from "default" to whatever you want
  294.         if (isset($_phpDocumentor_setting['defaultcategoryname']))
  295.         {
  296.             $GLOBALS['phpDocumentor_DefaultCategoryName'] = trim($_phpDocumentor_setting['defaultcategoryname']);
  297.         }
  298.         
  299.         // set the mode (quiet or verbose)
  300.         if ( isset($_phpDocumentor_setting['quiet']) || strcasecmp($_phpDocumentor_setting['junk'], "-q") == 0 || strcasecmp($_phpDocumentor_setting['junk'], "--quiet") == 0) 
  301.         {
  302.             if (isset($_phpDocumentor_setting['quiet']) && $_phpDocumentor_setting['quiet'] != 'on');
  303.             else
  304.             $this->render->setQuietMode(true);
  305.         }
  306.         
  307.         // Setup the different classes
  308.         if (isset($_phpDocumentor_setting['templatebase']))
  309.         {
  310.             $this->render->setTemplateBase($_phpDocumentor_setting['templatebase']);
  311.         }
  312.         if (isset($_phpDocumentor_setting['target']) && !empty($_phpDocumentor_setting['target']))
  313.         {
  314.             $this->render->setTargetDir($_phpDocumentor_setting['target']);
  315.         }
  316.         else
  317.         {
  318.             echo "a target directory must be specified\n try phpdoc -h\n";
  319.             die();
  320.         }
  321.         if (!empty($_phpDocumentor_setting['packageoutput']))
  322.         {
  323.             $this->packages = explode(",",$_phpDocumentor_setting['packageoutput']);
  324.             foreach($this->packages as $p => $v)
  325.             {
  326.                 $this->packages[$p] = trim($v);
  327.             }
  328.         }
  329.         if (!empty($_phpDocumentor_setting['filename']))
  330.         $this->files = $_phpDocumentor_setting['filename'];
  331.         if (!empty($_phpDocumentor_setting['directory']))
  332.         $this->dirs = $_phpDocumentor_setting['directory'];
  333.     }
  334.     
  335.     function checkIgnoreTag($tagname, $inline = false)
  336.     {
  337.         global $_phpDocumentor_setting;
  338.         $tagname = '@'.$tagname;
  339.         if (!isset($_phpDocumentor_setting['ignore-tags'])) return false;
  340.         if ($inline) $tagname = '{'.$tagname.'}';
  341.         return in_array($tagname, $_phpDocumentor_setting['ignore-tags']);
  342.     }
  343.     
  344.     function setJavadocDesc()
  345.     {
  346.            $this->parse->eventHandlers[PARSER_EVENT_DOCBLOCK] = 'JavaDochandleDocblock';
  347.     }
  348.     
  349.     function setParsePrivate()
  350.     {
  351.         $this->render->setParserPrivate(true);
  352.     }
  353.     
  354.     function setQuietMode()
  355.     {
  356.         $this->render->setQuietMode(true);
  357.     }
  358.     
  359.     function setTargetDir($target)
  360.     {
  361.         $this->render->setTargetDir($target);
  362.     }
  363.     
  364.     function setTemplateBase($dir)
  365.     {
  366.         $this->render->setTemplateBase($dir);
  367.     }
  368.     
  369.     function setPackageOutput($po)
  370.     {
  371.         $this->packages = explode(",",$po);
  372.     }
  373.     
  374.     function setTitle($ti)
  375.     {
  376.         $this->render = new phpDocumentor_IntermediateParser($ti);
  377.     }
  378.     
  379.     function setFilesToParse($files)
  380.     {
  381.         $this->files = $files;
  382.     }
  383.     
  384.     function setDirectoriesToParse($dirs)
  385.     {
  386.         $this->dirs = $dirs;
  387.     }
  388.     
  389.     function parseHiddenFiles()
  390.     {
  391.         $this->hidden = true;
  392.     }
  393.     
  394.     function setIgnore($ig)
  395.     {
  396.         if (strstr($ig,","))
  397.         {
  398.             $this->ignore_files = explode(",",$ig);
  399.         } else {
  400.             if (!empty($ig))
  401.             $this->ignore_files = array($ig);
  402.         }
  403.     }
  404.     
  405.     function createDocs($title = false)
  406.     {
  407.         $this->parse_start_time = time();
  408.         global $_phpDocumentor_setting;
  409.         if (!$this->render)
  410.         {
  411.             $this->render = new phpDocumentor_IntermediateParser($title);
  412.         }
  413.         // setup ignore  list
  414.         $this->ignore_files =array();
  415.         if(isset($_phpDocumentor_setting['ignore']))
  416.         {
  417.             $this->setIgnore($_phpDocumentor_setting['ignore']);
  418.         }
  419.         $this->parse->subscribe("*",$this->render);
  420.         // parse the directory
  421.         if (!empty($this->files))
  422.         {
  423.             $files = explode(",",$this->files);
  424.             foreach($files as $file)
  425.             {
  426.                 $file = trim($file);
  427.                 $test = $this->setup->getAllFiles($file);
  428.                 if ($test)
  429.                 {
  430.                     foreach($test as $file)
  431.                     {
  432.                         $file = trim($file);
  433.                         $dir = realpath(dirname($file));
  434.                         $dir = strtr($dir, "\\", "/");
  435.                         $dir = str_replace('//','/',$dir);
  436.                         // strip trailing directory seperator
  437.                         if (substr($dir,-1) == "/" || substr($dir,-1) == "\\")
  438.                         {
  439.                             $dir = substr($dir,0,-1);
  440.                         }
  441.                         $file = strtr(realpath($file), "\\", "/");
  442.                         $file = str_replace('//','/',$file);
  443.  
  444.                         if (!$this->setup->checkIgnore(basename($file),dirname($file),$this->ignore_files))
  445.                         {
  446.                             $filelist[] = str_replace('\\','/',$file);
  447.                         } else {
  448.                             phpDocumentor_out("File $file Ignored\n");
  449.                             flush();
  450.                         }
  451.                     }
  452.                 } else
  453.                 {
  454.                     $dir = realpath(dirname(realpath($file)));
  455.                     $dir = strtr($dir, "\\", "/");
  456.                     $dir = str_replace('//','/',$dir);
  457.                     // strip trailing directory seperator
  458.                     if (substr($dir,-1) == "/" || substr($dir,-1) == "\\")
  459.                     {
  460.                         $dir = substr($dir,0,-1);
  461.                     }
  462.                     $base = count(explode("/",$dir));
  463.                     $file = strtr(realpath($file), "\\", "/");
  464.                     $file = str_replace('//','/',$file);
  465.                     flush();
  466.  
  467.                     if (!$this->setup->checkIgnore(basename($file),dirname($file),$this->ignore_files))
  468.                     {
  469.                         $filelist[] = str_replace('\\','/',$file);
  470.                     } else {
  471.                         phpDocumentor_out("File $file Ignored\n");
  472.                         flush();
  473.                     }
  474.                 }
  475.             }
  476.         }
  477.         if (!empty($this->dirs))
  478.         {
  479.             $dirs = explode(",",$this->dirs);
  480.             foreach($dirs as $dir)
  481.             {
  482.                 $dir = trim(realpath($dir));
  483.                 $dir = strtr($dir, "\\", "/");
  484.                 $dir = str_replace('//','/',$dir);
  485.                 // strip trailing directory seperator
  486.                 if (substr($dir,-1) == "/" || substr($dir,-1) == "\\")
  487.                 {
  488.                     $dir = substr($dir,0,-1);
  489.                 }
  490.                 $files = $this->setup->dirList($dir,$this->hidden);
  491.                 if (is_array($files))
  492.                 {
  493.                     foreach($files as $file)
  494.                     {
  495.                         // Make sure the file isn't a hidden file
  496.                         $file = strtr($file, "\\", "/");
  497.                         $test = array_pop(explode("/",$file));
  498.                         if (substr($test,0,1) != ".") 
  499.                         {
  500.                                if (!$this->setup->checkIgnore(basename($file),str_replace('\\','/',dirname($file)),$this->ignore_files))
  501.                             {
  502.                                 $filelist[] = str_replace('\\','/',$file);
  503.                             } else {
  504.                                 phpDocumentor_out("File $file Ignored\n");
  505.                                 flush();
  506.                             }
  507.                         }
  508.                     }
  509.                 }
  510.             }
  511.         }
  512.         if (isset($filelist))
  513.         {
  514.             if (PHPDOCUMENTOR_WINDOWS)
  515.             {
  516.                 // case insensitive array_unique
  517.                 usort($filelist,'strnatcasecmp');
  518.                 reset($filelist);
  519.                 
  520.                 $newarray = array();
  521.                 $i = 0;
  522.                 
  523.                 $element = current($filelist);
  524.                 for ($n=0;$n<sizeof($filelist);$n++)
  525.                 {
  526.                     if (strtolower(next($filelist)) != strtolower($element))
  527.                     {
  528.                         $newarray[$i] = $element;
  529.                         $element = current($filelist);
  530.                         $i++;
  531.                     }
  532.                 }
  533.                 $filelist = $newarray; 
  534.             } else $filelist = array_unique($filelist);
  535.  
  536.             $base = count(explode("/",$source_base = $this->setup->getBase($filelist)));
  537.             define("PHPDOCUMENTOR_BASE",$source_base);
  538.             list($filelist,$ric) = $this->setup->getReadmeInstallChangelog($source_base, $filelist);
  539.             phpDocumentor_out("\n\nGrabbing README/INSTALL/CHANGELOG\n");
  540.             flush();
  541.             foreach($ric as $file)
  542.             {
  543.                 phpDocumentor_out(basename($file).'...');
  544.                 flush();
  545.                 $fp = fopen($file,'r');
  546.                 $contents = fread($fp,filesize($file));
  547.                 $this->render->HandleEvent(PHPDOCUMENTOR_EVENT_README_INSTALL_CHANGELOG, array(basename($file),$contents));
  548.                 fclose($fp);
  549.             }
  550.             phpDocumentor_out("\ndone\n");
  551.             flush();
  552.             list($filelist,$tutorials) = $this->setup->getTutorials($filelist);
  553.             phpDocumentor_out("\n\nTutorial/Extended Documentation Parsing Stage\n\n");
  554.             flush();
  555.             if (count($tutorials))
  556.             {
  557.                 $tuteparser = new XMLPackagePageParser;
  558.                 $tuteparser->subscribe('*',$this->render);
  559.                 foreach($tutorials as $tutorial)
  560.                 {
  561.                     switch($tutorial['tutetype'])
  562.                     {
  563.                         case 'pkg' :
  564.                         case 'cls' :
  565.                         case 'proc' :
  566.                         switch($tutorial['tutetype'])
  567.                         {
  568.                             case 'pkg' :
  569.                                 $ptext = 'Package-level Docs ';
  570.                                 if (!empty($tutorial['subpackage']))
  571.                                 $ptext = 'Sub-Package Docs ';
  572.                             break;
  573.                             case 'cls' :
  574.                                 $ptext = 'Class-level Docs ';
  575.                             break;
  576.                             case 'proc' :
  577.                                 $ptext = 'Procedural-level Docs ';
  578.                             break;
  579.                         }
  580.                         $fp = @fopen($tutorial['path'],"r");
  581.                         if ($fp)
  582.                         {
  583.                             $ret = fread($fp,filesize($tutorial['path']));
  584.                             fclose($fp);
  585.                             unset($fp);
  586.                             phpDocumentor_out('Parsing '.$ptext.$tutorial['path'].'...');
  587.                             flush();
  588.                             $tuteparser->parse($ret,$tutorial);
  589.                             phpDocumentor_out("done\n");
  590.                             flush();
  591.                         } else
  592.                         {
  593.                             phpDocumentor_out('Error '.$ptext.$tutorial['path'].' doesn\'t exist'."\n");
  594.                             flush();
  595.                         }
  596.                         default :
  597.                         break;
  598.                     }
  599.                 }
  600.             }
  601.             phpDocumentor_out("done\n");
  602.             flush();
  603.             phpDocumentor_out("\n\nGeneral Parsing Stage\n\n");
  604.             flush();
  605.             foreach($filelist as $file)
  606.             {
  607.                 phpDocumentor_out("Reading file $file");
  608.                 flush();
  609.                 $this->parse->parse($this->setup->readPhpFile($file, $this->render->quietMode),$file,$base,$this->packages);
  610.     
  611.             }
  612.             $b = (time() - $this->parse_start_time);
  613.             phpDocumentor_out("done\n");
  614.             flush();
  615.             // render output
  616.             phpDocumentor_out("\nConverting From Abstract Parsed Data\n");
  617.             flush();
  618.             $this->render->output();
  619.             $a = (time() - $this->parse_start_time);
  620.             $c = ($a - $b);
  621.             phpDocumentor_out("\nParsing time: $b seconds\n");
  622.             phpDocumentor_out("\nConversion time: $c seconds\n");
  623.             phpDocumentor_out("\nTotal Documentation Time: $a seconds\n");
  624.             phpDocumentor_out("done\n");
  625.             flush();
  626.         } else
  627.         {
  628.             print "ERROR: nothing parsed";
  629.             exit;
  630.         }
  631.     }
  632.     /**
  633.      * Parse configuration file phpDocumentor.ini
  634.      */
  635.     function parseIni()
  636.     {
  637.         phpDocumentor_out("Parsing configuration file phpDocumentor.ini...");
  638.         flush();
  639.         $options = phpDocumentor_parse_ini_file(str_replace('\\','/', 'C:\xampp\php\pear\data/PhpDocumentor') . PATH_DELIMITER . 'phpDocumentor.ini',true);
  640.  
  641.         if (!$options)
  642.         {
  643.             print "ERROR: cannot open phpDocumentor.ini in directory C:\xampp\php\pear\data/PhpDocumentor\n";
  644.             print "-Is phpdoc in either the path or include_path in your php.ini file?";
  645.             exit;
  646.         }
  647.         
  648.         foreach($options as $var => $values)
  649.         {
  650.             if ($var != 'DEBUG')
  651.             {
  652. //                phpDocumentor_out("\n$var");
  653.                 if ($var != '_phpDocumentor_setting' && $var != '_phpDocumentor_options' && $var != '_phpDocumentor_install_dir' ) $values = array_values($values);
  654. //                fancy_debug("\n$var",$values);
  655.                 $GLOBALS[$var] = $values;
  656.             }
  657.         }
  658.         phpDocumentor_out("\ndone\n");
  659.         flush();
  660.         /** Debug Constant */
  661.         define("PHPDOCUMENTOR_DEBUG",$options['DEBUG']['PHPDOCUMENTOR_DEBUG']);
  662.         define("PHPDOCUMENTOR_KILL_WHITESPACE",$options['DEBUG']['PHPDOCUMENTOR_KILL_WHITESPACE']);
  663.         $GLOBALS['_phpDocumentor_cvsphpfile_exts'] = $GLOBALS['_phpDocumentor_phpfile_exts'];
  664.         foreach($GLOBALS['_phpDocumentor_cvsphpfile_exts'] as $key => $val)
  665.         {
  666.             $GLOBALS['_phpDocumentor_cvsphpfile_exts'][$key] = "$val,v";
  667.         }
  668.         // none of this stuff is used anymore
  669.         if (isset($GLOBALS['_phpDocumentor_html_allowed']))
  670.         {
  671.             $___htmltemp = array_flip($GLOBALS['_phpDocumentor_html_allowed']);
  672.             $___html1 = array();
  673.             foreach($___htmltemp as $tag => $trans)
  674.             {
  675.                 $___html1['<'.$tag.'>'] = htmlentities('<'.$tag.'>');
  676.                 $___html1['</'.$tag.'>'] = htmlentities('</'.$tag.'>');
  677.             }
  678.             $GLOBALS['phpDocumentor___html'] = array_flip($___html1);
  679.         }
  680.     }
  681.     
  682.     function setupConverters($output = false)
  683.     {
  684.         global $_phpDocumentor_setting;
  685.         if ($output)
  686.         {
  687.             $_phpDocumentor_setting['output'] = $output;
  688.         }
  689.         if (isset($_phpDocumentor_setting['output']) && !empty($_phpDocumentor_setting['output']))
  690.         {
  691.             $c = explode(',',$_phpDocumentor_setting['output']);
  692.             for($i=0; $i< count($c); $i++)
  693.             {
  694.                 $c[$i] = explode(':',$c[$i]);
  695.                 $a = $c[$i][0];
  696.                 $b = false;
  697.                 $d = 'default/';
  698.                 if (count($c[$i]) > 1)
  699.                 {
  700.                     $a = $c[$i][0];
  701.                     $b = $c[$i][1];
  702.                     if (isset($c[$i][2]))
  703.                     {
  704.                         $d = $c[$i][2];
  705.                         $d = str_replace("\\","/",$d);
  706.                         if (substr($d,-1) != "/")
  707.                         {
  708.                             $d .= "/";
  709.                         }
  710.                     }
  711.                     else $d = 'default/';
  712.                 }
  713.                 if (strtoupper(trim($a)) == 'HTML' && (trim($b) == 'default'))
  714.                 {
  715.                     phpDocumentor_out("WARNING: HTMLdefaultConverter is deprecated, using HTMLframesConverter.\n");
  716.                     phpDocumentor_out("WARNING: template output is identical, HTMLframes is more flexible.\n");
  717.                     phpDocumentor_out("WARNING: please adjust your usage\n");
  718.                     flush();
  719.                     $b = 'frames'; // change default to frames.
  720.                 }
  721.                 $this->render->addConverter(strtoupper(trim($a)),trim($b),trim($d));
  722.             }
  723.         } else
  724.         {
  725.             $this->render->addConverter('HTML','frames','default/');
  726.         }
  727.         if (empty($this->render->converters)) addErrorDie(PDERROR_NO_CONVERTERS);
  728.     }
  729. }
  730.  
  731. /**
  732.  * Print parse information if quiet setting is off
  733.  */
  734. function phpDocumentor_out($string)
  735. {
  736.     global $_phpDocumentor_setting;
  737.     if (!isset($_phpDocumentor_setting['quiet']) || !$_phpDocumentor_setting['quiet'])
  738.     {
  739.         print $string;
  740.     }
  741.  
  742. }
  743. ?>
  744.