Source for file Setup.inc.php
Documentation is available at Setup.inc.php
* This was all in {@link phpdoc.inc}, and now encapsulates the complexity
* phpDocumentor :: automatic documentation generator
* Copyright (c) 2002-2006 Gregory Beaver
* This library is free software; you can redistribute it
* and/or modify it under the terms of the GNU Lesser General
* Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* @category documentation
* @copyright 2002-2006 Gregory Beaver
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @version CVS: $Id: Setup.inc.php,v 1.13 2006/10/23 03:45:08 cellog Exp $
* @link http://www.phpdoc.org
* @link http://pear.php.net/PhpDocumentor
include_once("phpDocumentor/common.inc.php");
include_once("phpDocumentor/Io.inc");
include_once("phpDocumentor/Publisher.inc");
include_once("phpDocumentor/Classes.inc");
include_once("phpDocumentor/ProceduralPages.inc");
include_once("phpDocumentor/IntermediateParser.inc");
include_once("phpDocumentor/WordParser.inc");
include_once("phpDocumentor/EventStack.inc");
include_once("phpDocumentor/ParserData.inc");
include_once("phpDocumentor/InlineTags.inc");
include_once("phpDocumentor/DocBlockTags.inc");
include_once("phpDocumentor/DescHTML.inc");
include_once("phpDocumentor/ParserDocBlock.inc");
include_once("phpDocumentor/ParserElements.inc");
include_once("phpDocumentor/Parser.inc");
include_once("phpDocumentor/phpDocumentorTWordParser.inc");
include_once("phpDocumentor/phpDocumentorTParser.inc");
include_once("phpDocumentor/HighlightParser.inc");
include_once("phpDocumentor/TutorialHighlightParser.inc");
include_once("phpDocumentor/ParserDescCleanup.inc");
include_once("phpDocumentor/PackagePageElements.inc");
include_once("phpDocumentor/XMLpackagePageParser.inc");
include_once("phpDocumentor/LinkClasses.inc");
include_once("phpDocumentor/Converter.inc");
include_once("phpDocumentor/Errors.inc");
* $interface is either 'web' or is not set at all
* @global array $interface
if (isset ($_GET['interface'])) $interface = $_GET['interface'];
* $_phpDocumentor_setting is either the value from the web interface, or is set up by {@link Io::parseArgv()}
* @global array $_phpDocumentor_setting
if (isset ($_GET['setting'])) $_phpDocumentor_setting = $_GET['setting'];
* default package name, set using -dn --defaultpackagename
* @global string $GLOBALS['phpDocumentor_DefaultPackageName']
* @name $phpDocumentor_DefaultPackageName
$GLOBALS['phpDocumentor_DefaultPackageName'] = 'default';
* default package name, set using -dn --defaultcategoryname
* @global string $GLOBALS['phpDocumentor_DefaultCategoryName']
* @name $phpDocumentor_DefaultCategoryName
$GLOBALS['phpDocumentor_DefaultCategoryName'] = 'default';
* @var Parser|phpDocumentorTParser
* Used to parse command-line options
* Used to organize output from the Parser before Conversion
* @var phpDocumentor_IntermediateParser
* Packages to create documentation for
* contents of --filename commandline
* @tutorial phpDocumentor.howto.pkg#using.command-line.filename
* contents of --directory commandline
* @tutorial phpDocumentor.howto.pkg#using.command-line.directory
* contents of --hidden commandline
* @tutorial phpDocumentor.howto.pkg#using.command-line.hidden
* time that parsing was started, used for informative timing of output
* contents of --ignore commandline
* @tutorial phpDocumentor.howto.pkg#using.command-line.ignore
* Checks PHP version, makes sure it is 4.2.0+, and chooses the
* phpDocumentorTParser if version is 4.3.0+
print "phpDocumentor requires PHP version 4.2.0 or greater to function";
if (!isset ($interface) && !isset ($_GET['interface']) && !isset ($_phpDocumentor_setting))
// Parse the argv settings
if (isset ($_phpDocumentor_setting['useconfig']) &&
!empty($_phpDocumentor_setting['useconfig'])) {
// set runtime to a large value since this can take quite a while
// we can only set_time_limit when not in safe_mode bug #912064
phpDocumentor_out("time_limit cannot be set since your in safe_mode, please edit time_limit in your php.ini to allow enough time for phpDocumentor to run");
if (isset ($_GET['interface'])) {
$phpver = "<b>$phpver</b>";
$phpdocver = "<b>$phpdocver</b>";
and load the tokenizer extension for faster parsing (your version is ". phpversion(). "\n");
* Get phpDocumentor settings from a user configuration file
* @param string user configuration file
$file = str_replace(array('..','.ini','\\'),array('','','/'),$file);
if ('@DATA-DIR@' != '@'. 'DATA-DIR@')
if (isset ($_phpDocumentor_options['userdir'])) $configdir = $_phpDocumentor_options['userdir'];
if (substr($configdir,- 1) != '/')
if (empty($_phpDocumentor_setting['defaultpackagename']))
$_phpDocumentor_setting['defaultpackagename'] = 'default';
// don't want a loop condition!
unset ($_phpDocumentor_setting['useconfig']);
* Get phpDocumentor settings from command-line or web interface
// subscribe $render class to $parse class events
if (!isset ($_phpDocumentor_setting['junk'])) $_phpDocumentor_setting['junk'] = '';
if (!isset ($_phpDocumentor_setting['title'])) $_phpDocumentor_setting['title'] = 'Generated Documentation';
$temp_title = $_phpDocumentor_setting['title'];
if (isset ($_phpDocumentor_setting['help']) || $_phpDocumentor_setting['junk'] == "-h" || $_phpDocumentor_setting['junk'] == "--help")
if (isset ($_phpDocumentor_setting['hidden'])) $this->hidden = true;
// set to parse elements marked private with @access private
if (isset ($_phpDocumentor_setting['parseprivate']) && $_phpDocumentor_setting['parseprivate'] == 'on')
if (isset ($_phpDocumentor_setting['ignoretags']))
$ignoretags = explode(',', $_phpDocumentor_setting['ignoretags']);
$ignoretags = array_map('trim', $ignoretags);
foreach($ignoretags as $tag)
if (!in_array($tag,array('@global', '@access', '@package', '@ignore', '@name', '@param', '@return', '@staticvar', '@var')))
$_phpDocumentor_setting['ignoretags'] = $tags;
if (isset ($_phpDocumentor_setting['readmeinstallchangelog']))
$_phpDocumentor_setting['readmeinstallchangelog'] = explode(',',str_replace(' ','',$_phpDocumentor_setting['readmeinstallchangelog']));
foreach($_phpDocumentor_setting['readmeinstallchangelog'] as $ric)
$_phpDocumentor_RIC_files = $rics;
if (isset ($_phpDocumentor_setting['javadocdesc']) && $_phpDocumentor_setting['javadocdesc'] == 'on')
if (isset ($_phpDocumentor_setting['sourcecode']) && $_phpDocumentor_setting['sourcecode'] == 'on')
$_phpDocumentor_setting['sourcecode'] = true;
$_phpDocumentor_setting['sourcecode'] = false;
if (isset ($_phpDocumentor_setting['sourcecode']) && $_phpDocumentor_setting['sourcecode'] == 'on')
$_phpDocumentor_setting['sourcecode'] = false;
if (isset ($_phpDocumentor_setting['converterparams']))
$_phpDocumentor_setting['converterparams'] = explode($_phpDocumentor_setting['converterparams']);
foreach($_phpDocumentor_setting['converterparams'] as $i => $p)
$_phpDocumentor_setting['converterparams'][$i] = trim($p);
if (isset ($_phpDocumentor_setting['customtags']) && !empty($_phpDocumentor_setting['customtags']))
$c = explode(',',$_phpDocumentor_setting['customtags']);
for($i= 0;$i< count($c); $i++ )
$GLOBALS['_phpDocumentor_tags_allowed'][] = trim($c[$i]);
if (isset ($_phpDocumentor_setting['pear']))
if ($_phpDocumentor_setting['pear'] === 'off') $_phpDocumentor_setting['pear'] = false;
if ($_phpDocumentor_setting['pear'] === 'on') $_phpDocumentor_setting['pear'] = true;
if (!isset ($_phpDocumentor_setting['pear'])) $_phpDocumentor_setting['pear'] = false;
// set to change the default package name from "default" to whatever you want
if (isset ($_phpDocumentor_setting['defaultpackagename']))
$GLOBALS['phpDocumentor_DefaultPackageName'] = trim($_phpDocumentor_setting['defaultpackagename']);
// set to change the default category name from "default" to whatever you want
if (isset ($_phpDocumentor_setting['defaultcategoryname']))
$GLOBALS['phpDocumentor_DefaultCategoryName'] = trim($_phpDocumentor_setting['defaultcategoryname']);
// set the mode (quiet or verbose)
if ( isset ($_phpDocumentor_setting['quiet']) || strcasecmp($_phpDocumentor_setting['junk'], "-q") == 0 || strcasecmp($_phpDocumentor_setting['junk'], "--quiet") == 0)
if (isset ($_phpDocumentor_setting['quiet']) && $_phpDocumentor_setting['quiet'] != 'on');
// Setup the different classes
if (isset ($_phpDocumentor_setting['templatebase']))
if (isset ($_phpDocumentor_setting['target']) && !empty($_phpDocumentor_setting['target']))
echo "a target directory must be specified\n try phpdoc -h\n";
if (!empty($_phpDocumentor_setting['packageoutput']))
if (!empty($_phpDocumentor_setting['filename'])) {
$this->files = trim($_phpDocumentor_setting['filename']);
if (!empty($_phpDocumentor_setting['directory'])) {
$this->dirs = trim($_phpDocumentor_setting['directory']);
if (!isset ($_phpDocumentor_setting['ignoretags'])) return false;
if ($inline) $tagname = '{'. $tagname. '}';
return in_array($tagname, $_phpDocumentor_setting['ignoretags']);
$this->parse_start_time = time();
if(isset ($_phpDocumentor_setting['ignore']))
$this->setIgnore($_phpDocumentor_setting['ignore']);
if (!empty($this->files))
$dir = strtr($dir, "\\", "/");
// strip trailing directory seperator
$dir = strtr($dir, "\\", "/");
// strip trailing directory seperator
$dir = strtr($dir, "\\", "/");
// strip trailing directory seperator
// Make sure the file isn't a hidden file
$file = strtr($file, "\\", "/");
// case insensitive array_unique
usort($filelist,'strnatcasecmp');
for ($n= 0;$n< sizeof($filelist);$n++ )
$newarray[$i] = $element;
define("PHPDOCUMENTOR_BASE",$source_base);
$tuteparser->subscribe('*',$this->render);
foreach($tutorials as $tutorial)
switch($tutorial['tutetype'])
switch($tutorial['tutetype'])
$ptext = 'Package-level Docs ';
if (!empty($tutorial['subpackage']))
$ptext = 'Sub-Package Docs ';
$ptext = 'Class-level Docs ';
$ptext = 'Procedural-level Docs ';
$fp = @fopen($tutorial['path'],"r");
$tuteparser->parse($ret,$tutorial);
foreach($filelist as $file)
$b = (time() - $this->parse_start_time);
$a = (time() - $this->parse_start_time);
print "ERROR: nothing parsed";
* Parse configuration file phpDocumentor.ini
if ('@DATA-DIR@' != '@'. 'DATA-DIR@')
print "ERROR: cannot open phpDocumentor.ini in directory " . $GLOBALS['_phpDocumentor_install_dir']. "\n";
print "-Is phpdoc in either the path or include_path in your php.ini file?";
foreach($options as $var => $values)
// phpDocumentor_out("\n$var");
if ($var != '_phpDocumentor_setting' && $var != '_phpDocumentor_options' && $var != '_phpDocumentor_install_dir' ) $values = array_values($values);
// fancy_debug("\n$var",$values);
$GLOBALS[$var] = $values;
define("PHPDOCUMENTOR_DEBUG",$options['DEBUG']['PHPDOCUMENTOR_DEBUG']);
define("PHPDOCUMENTOR_KILL_WHITESPACE",$options['DEBUG']['PHPDOCUMENTOR_KILL_WHITESPACE']);
$GLOBALS['_phpDocumentor_cvsphpfile_exts'] = $GLOBALS['_phpDocumentor_phpfile_exts'];
foreach($GLOBALS['_phpDocumentor_cvsphpfile_exts'] as $key => $val)
$GLOBALS['_phpDocumentor_cvsphpfile_exts'][$key] = "$val,v";
// none of this stuff is used anymore
if (isset ($GLOBALS['_phpDocumentor_html_allowed']))
$___htmltemp = array_flip($GLOBALS['_phpDocumentor_html_allowed']);
foreach($___htmltemp as $tag => $trans)
$GLOBALS['phpDocumentor___html'] = array_flip($___html1);
$_phpDocumentor_setting['output'] = $output;
if (isset ($_phpDocumentor_setting['output']) && !empty($_phpDocumentor_setting['output']))
$c = explode(',',$_phpDocumentor_setting['output']);
for($i= 0; $i< count($c); $i++ )
phpDocumentor_out("WARNING: HTMLdefaultConverter is deprecated, using HTMLframesConverter.\n");
phpDocumentor_out("WARNING: template output is identical, HTMLframes is more flexible.\n");
$b = 'frames'; // change default to frames.
* Print parse information if quiet setting is off
if (!isset ($_phpDocumentor_setting['quiet']) || !$_phpDocumentor_setting['quiet'])
|